COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
NavierStokes.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_PROTO_MAX_ARITY 10
8 #define BOOST_MPL_LIMIT_METAFUNCTION_ARITY 10
9 
11 #include "UFEM/SUPG.hpp"
12 #include "UFEM/Tags.hpp"
13 
15 
16 #include "NavierStokes.hpp"
17 
18 namespace cf3 {
19 namespace UFEM {
20 
21 using namespace solver::actions::Proto;
22 using boost::proto::lit;
23 
25 
26 typedef boost::mpl::vector1<mesh::LagrangeP1::Quad2D> AllowedElmsT;
27 
28 boost::shared_ptr<solver::actions::Proto::ProtoAction> wrap_expression(const boost::shared_ptr<Expression>& expr)
29 {
30  boost::shared_ptr<solver::actions::Proto::ProtoAction> result = common::allocate_component<solver::actions::Proto::ProtoAction>("Assembly");
31  result->set_expression(expr);
32  return result;
33 }
34 
35 boost::shared_ptr<solver::actions::Proto::ProtoAction> stokes_artifdiss(LSSActionUnsteady& solver)
36 {
37  // Expression variables
38  FieldVariable<0, VectorField> u("Velocity", "navier_stokes_solution");
39  FieldVariable<1, ScalarField> p("Pressure", "navier_stokes_solution");
40 
41  PhysicsConstant rho("density");
42  PhysicsConstant mu("dynamic_viscosity");
43 
45  (
46  AllowedElmsT(),
47  group
48  (
49  _A = _0, _T = _0,
51  (
52  _A(p , u[_i]) += transpose(N(p)) * nabla(u)[_i],
53  _A(p , p) += lit(rho) / mu * transpose(nabla(p))*nabla(p),
54  _A(u[_i], u[_i]) += mu * transpose(nabla(u))*nabla(u),
55  _A(u[_i], p) += 1./lit(rho) * transpose(N(u))*nabla(p)[_i],
56  _T(u[_i], u[_i]) += transpose(N(u))*N(u)
57  ),
58  solver.system_matrix += solver.invdt() * _T + 0.5 * _A,
59  solver.system_rhs += -_A * _x
60  )
61  ));
62 }
63 
64 boost::shared_ptr<solver::actions::Proto::ProtoAction> stokes_pspg(LSSActionUnsteady& solver)
65 {
66  // Expression variables
67  FieldVariable<0, VectorField> u("Velocity", "navier_stokes_solution");
68  FieldVariable<1, ScalarField> p("Pressure", "navier_stokes_solution");
69  FieldVariable<2, ScalarField> nu_eff("EffectiveViscosity", "navier_stokes_viscosity");
70 
71  PhysicsConstant rho("density");
72  PhysicsConstant mu("dynamic_viscosity");
73 
74  static Real tau_ps, tau_su, tau_bulk;
75 
77  (
78  AllowedElmsT(),
79  group
80  (
81  _A = _0, _T = _0,
82  compute_tau.apply(u, nu_eff, lit(solver.dt()), lit(tau_ps), lit(tau_su), lit(tau_bulk)),
84  (
85  _A(p , u[_i]) += transpose(N(p)) * nabla(u)[_i], // Continuity, standard
86  _A(p , p) += tau_ps * transpose(nabla(p)) * nabla(p), // Continuity, PSPG
87  _A(u[_i], u[_i]) += mu * transpose(nabla(u)) * nabla(u), // Diffusion
88  _A(u[_i], p) += 1./lit(rho) * transpose(N(u)) * nabla(p)[_i], // Pressure gradient
89  _T(p , u[_i]) += tau_ps * transpose(nabla(p)[_i]) * N(u), // Time, PSPG
90  _T(u[_i], u[_i]) += transpose(N(u)) * N(u) // Time, standard
91  ),
92  solver.system_matrix += solver.invdt() * _T + 0.5 * _A,
93  solver.system_rhs += -_A * _x
94  )
95  ));
96 }
97 
98 boost::shared_ptr<solver::actions::Proto::ProtoAction> navier_stokes_pspg(LSSActionUnsteady& solver)
99 {
100  // Expression variables
101  FieldVariable<0, VectorField> u("Velocity", "navier_stokes_solution");
102  FieldVariable<1, ScalarField> p("Pressure", "navier_stokes_solution");
103  FieldVariable<2, ScalarField> nu_eff("EffectiveViscosity", "navier_stokes_viscosity");
104 
105  PhysicsConstant rho("density");
106  PhysicsConstant mu("dynamic_viscosity");
107 
108  static Real tau_ps, tau_su, tau_bulk;
109 
111  (
112  AllowedElmsT(),
113  group
114  (
115  _A = _0, _T = _0,
116  compute_tau.apply(u, nu_eff, lit(solver.dt()), lit(tau_ps), lit(tau_su), lit(tau_bulk)),
118  (
119  _A(p , u[_i]) += transpose(N(p)) * nabla(u)[_i] + tau_ps * transpose(nabla(p)[_i]) * u*nabla(u), // Standard continuity + PSPG for advection
120  _A(p , p) += tau_ps * transpose(nabla(p)) * nabla(p), // Continuity, PSPG
121  _A(u[_i], u[_i]) += mu * transpose(nabla(u)) * nabla(u) + transpose(N(u)) * u*nabla(u), // Diffusion + advection
122  _A(u[_i], p) += 1./lit(rho) * transpose(N(u)) * nabla(p)[_i], // Pressure gradient
123  _T(p , u[_i]) += tau_ps * transpose(nabla(p)[_i]) * N(u), // Time, PSPG
124  _T(u[_i], u[_i]) += transpose(N(u)) * N(u) // Time, standard
125  ),
126  solver.system_matrix += solver.invdt() * _T + 1.0 * _A,
127  solver.system_rhs += -_A * _x
128  )
129  ));
130 }
131 
132 boost::shared_ptr<solver::actions::Proto::ProtoAction> navier_stokes_supg(LSSActionUnsteady& solver)
133 {
134  // Expression variables
135  FieldVariable<0, VectorField> u("Velocity", "navier_stokes_solution");
136  FieldVariable<1, ScalarField> p("Pressure", "navier_stokes_solution");
137  FieldVariable<2, ScalarField> nu_eff("EffectiveViscosity", "navier_stokes_viscosity");
138 
139  PhysicsConstant rho("density");
140  PhysicsConstant mu("dynamic_viscosity");
141 
142  static Real tau_ps, tau_su, tau_bulk;
143 
145  (
146  AllowedElmsT(),
147  group
148  (
149  _A = _0, _T = _0,
150  compute_tau.apply(u, nu_eff, lit(solver.dt()), lit(tau_ps), lit(tau_su), lit(tau_bulk)),
152  (
153  _A(p , u[_i]) += transpose(N(p)) * nabla(u)[_i] + tau_ps * transpose(nabla(p)[_i]) * u*nabla(u), // Standard continuity + PSPG for advection
154  _A(p , p) += tau_ps * transpose(nabla(p)) * nabla(p)/rho, // Continuity, PSPG
155  _A(u[_i], u[_i]) += mu * transpose(nabla(u)) * nabla(u)/rho + transpose(N(u) + tau_su*u*nabla(u)) * u*nabla(u), // Diffusion + advection
156  _A(u[_i], p) += 1./lit(rho) * transpose(N(u) + tau_su*u*nabla(u)) * nabla(p)[_i], // Pressure gradient (standard and SUPG)
157  _T(p , u[_i]) += tau_ps * transpose(nabla(p)[_i]) * N(u), // Time, PSPG
158  _T(u[_i], u[_i]) += transpose(N(u) + tau_su*u*nabla(u)) * N(u) // Time, standard + SUPG
159  ),
160  solver.system_matrix += solver.invdt() * _T + 1.0 * _A,
161  solver.system_rhs += -_A * _x
162  )
163  ));
164 }
165 
166 }
167 }
boost::proto::terminal< SFOp< ShapeFunctionOp > >::type const N
boost::shared_ptr< solver::actions::Proto::ProtoAction > stokes_pspg(LSSActionUnsteady &solver)
Assembly for the Stokes equations, stabilized with PSPG.
static boost::proto::terminal< ZeroTag >::type _0
Placeholder for the zero matrix.
Definition: Terminals.hpp:209
Real & invdt()
Reference to the inverse timestep, linked to the model time step.
Real & dt()
Reference to the timestep.
boost::shared_ptr< solver::actions::Proto::ProtoAction > wrap_expression(const boost::shared_ptr< Expression > &expr)
static boost::proto::terminal< ElementSystemMatrix< boost::mpl::int_< 0 > > >::type const _A
Some predefined element matrices (more can be user-defined, but you have to change the number in the ...
boost::shared_ptr< solver::actions::Proto::ProtoAction > navier_stokes_pspg(LSSActionUnsteady &solver)
Assembly for the Navier-Stokes equations, stabilized with PSPG.
static boost::proto::terminal< ElementSystemMatrix< boost::mpl::int_< 1 > > >::type const _T
solver::actions::Proto::MakeSFOp< ComputeTauImpl >::reference_type apply
Definition: SUPG.hpp:249
static boost::proto::terminal< ElementQuadratureTag >::type element_quadrature
Use element_quadrature(expr1, expr2, ..., exprN) to evaluate a group of expressions.
boost::shared_ptr< solver::actions::Proto::ProtoAction > navier_stokes_supg(LSSActionUnsteady &solver)
Assembly for the Navier-Stokes equations, stabilized with SUPG.
boost::shared_ptr< ElementsExpression< ExprT, ElementTypes > > elements_expression(ElementTypes, const ExprT &expr)
Definition: Expression.hpp:292
static boost::proto::terminal< ElementRHS >::type const _x
Terminal for the element RHS vector ("b")
Refers to a value from the physical model.
boost::proto::terminal< TransposeFunction >::type const transpose
boost::proto::terminal< SFOp< NablaOp > >::type const nabla
boost::shared_ptr< solver::actions::Proto::ProtoAction > stokes_artifdiss(LSSActionUnsteady &solver)
Assembly for the Stokes equations, stabilized with artificial dissipation.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
static boost::proto::terminal< IndexTag< boost::mpl::int_< 0 > > >::type const _i
Index looping over the dimensions of a variable.
const solver::actions::Proto::SystemMatrix & system_matrix
Proto placeholder for the system matrix.
Definition: LSSAction.hpp:103
boost::mpl::vector1< mesh::LagrangeP1::Quad2D > AllowedElmsT
Convenience type for a compute_tau operation, grouping the stored operator and its proto counterpart...
Definition: SUPG.hpp:238
static boost::proto::terminal< ExpressionGroupTag >::type group
Use group(expr1, expr2, ..., exprN) to evaluate a group of expressions.
const solver::actions::Proto::SystemRHS & system_rhs
Proto placeholder for the right hand side of the system.
Definition: LSSAction.hpp:105
ComputeTau compute_tau
Send comments to:
COOLFluiD Web Admin