LifeV
StabilizationSUPG_semi_implicit.cpp
Go to the documentation of this file.
1 #include <lifev/navier_stokes_blocks/solver/StabilizationSUPG_semi_implicit.hpp>
2 
3 // MACRO TO DEFINE TAU_M
4 #define TAU_M value(1.0)/( eval(squareroot,TAU_M_DEN) )
6 #define TAU_M_DEN_DT value(M_density*M_density)*value(M_bdfOrder*M_bdfOrder)/value(M_timestep * M_timestep)
7 #define TAU_M_DEN_VEL ( value(M_density*M_density)*dot(value(M_fespaceUETA, velocity_extrapolated_rep), G* value(M_fespaceUETA, velocity_extrapolated_rep)) )
8 #define TAU_M_DEN_VISC ( value(M_C_I)*value(M_viscosity*M_viscosity) *dot (G, G) )
9 
10 // MACRO TO DEFINE TAU_C
11 #define TAU_C value(1.0)/( dot(g, TAU_M*g ) )
12 
13 namespace LifeV
14 {
15 
16 //=============================================================================
17 // Constructor
18 //=============================================================================
19 
20 StabilizationSUPG_semi_implicit::StabilizationSUPG_semi_implicit():
21  M_label("SUPG_semi_implicit")
22 {
23 }
24 
25 //=============================================================================
26 // Methods
27 //=============================================================================
28 
29 void StabilizationSUPG_semi_implicit::setConstant(const int & value)
30 {
31  if ( value == 1 )
32  M_C_I = 30;
33  else if ( value == 2 )
34  M_C_I = 60;
35  else
36  ASSERT(0!=0, "Please implement a suitable value for M_C_I for your velocity FE order");
37 }
38 
39 // This will be applied to the system matrix
40 void StabilizationSUPG_semi_implicit::apply_matrix( const vector_Type& velocityExtrapolated )
41 {
42 
43  M_block_00.reset (new matrix_Type ( M_uFESpace->map() ) );
44 
45  M_block_01.reset (new matrix_Type ( M_uFESpace->map() ) );
46 
47  M_block_10.reset (new matrix_Type ( M_pFESpace->map() ) );
48 
49  M_block_11.reset (new matrix_Type ( M_pFESpace->map() ) );
50 
51  M_block_00->zero();
52 
53  M_block_01->zero();
54 
55  M_block_10->zero();
56 
57  M_block_11->zero();
58 
59  vector_Type velocity_extrapolated_rep( velocityExtrapolated, Repeated);
60  std::shared_ptr<SquareRoot_supg_semi_implicit> squareroot(new SquareRoot_supg_semi_implicit());
61 
62  using namespace ExpressionAssembly;
63 
64  integrate(
65  elements(M_uFESpace->mesh()),
66  M_uFESpace->qr(),
67  M_fespaceUETA, // test w -> phi_i
68  M_fespaceUETA, // trial u^{n+1} -> phi_j
69 
70  TAU_M* (
71  dot( value(M_fespaceUETA, velocity_extrapolated_rep)*grad(phi_i), value(M_density*M_density*M_alpha/M_timestep) * phi_j
72  +value(M_density*M_density) * value(M_fespaceUETA, velocity_extrapolated_rep)*grad(phi_j)
73  -value(M_density*M_viscosity)*laplacian(phi_j)
74  )
75 
76  )
77 
78  + TAU_C*div(phi_i)*div(phi_j)
79 
80  ) >> M_block_00;
81 
82  M_block_00->globalAssemble();
83 
84  integrate(
85  elements(M_uFESpace->mesh()),
86  M_pFESpace->qr(),
87  M_fespacePETA, // test q -> phi_i
88  M_fespaceUETA, // trial u^{n+1} -> phi_j
89 
90  TAU_M * (
91 
92  dot( grad(phi_i), value(M_density*M_alpha/M_timestep)*phi_j
93  +value(M_density)*value(M_fespaceUETA, velocity_extrapolated_rep)*grad(phi_j)
94  -value(M_viscosity)*laplacian(phi_j)
95  )
96 
97  )
98 
99  ) >> M_block_10;
100 
101  M_block_10->globalAssemble( M_uFESpace->mapPtr(), M_pFESpace->mapPtr() );
102 
103  integrate(
104  elements(M_uFESpace->mesh()),
105  M_uFESpace->qr(),
106  M_fespaceUETA, // test w -> phi_i
107  M_fespacePETA, // trial p^{n+1} -> phi_j
108 
109  TAU_M*value(M_density)*dot( value(M_fespaceUETA, velocity_extrapolated_rep)*grad(phi_i), grad(phi_j) )
110 
111  ) >> M_block_01;
112 
113  M_block_01->globalAssemble( M_pFESpace->mapPtr(), M_uFESpace->mapPtr() );
114 
115  integrate(
116  elements(M_uFESpace->mesh()),
117  M_pFESpace->qr(),
118  M_fespacePETA, // test q -> phi_i
119  M_fespacePETA, // trial p^{n+1} -> phi_j
120 
121  TAU_M*dot( grad(phi_j), grad(phi_i) )
122 
123  ) >> M_block_11;
124 
125  M_block_11->globalAssemble();
126 
127 }
128 
129 void StabilizationSUPG_semi_implicit::apply_vector( vectorPtr_Type& rhs_velocity,
130  vectorPtr_Type& rhs_pressure,
131  const vector_Type& velocityExtrapolated,
132  const vector_Type& velocity_rhs)
133 {
134  M_rhsVelocity.reset( new vector_Type ( velocity_rhs, Unique ) );
135 
136  vector_Type velocity_rhs_rep( velocity_rhs, Repeated);
137 
138  vector_Type velocity_extrapolated_rep( velocityExtrapolated, Repeated);
139 
140  std::shared_ptr<SquareRoot_supg_semi_implicit> squareroot(new SquareRoot_supg_semi_implicit());
141 
142  using namespace ExpressionAssembly;
143 
144  integrate(
145  elements(M_uFESpace->mesh()),
146  M_uFESpace->qr(),
147  M_fespaceUETA,
148 
149  TAU_M*value(M_density*M_density)*dot( value(M_fespaceUETA, velocity_extrapolated_rep)*grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep) )
150 
151  ) >> rhs_velocity;
152 
153  integrate(
154  elements(M_uFESpace->mesh()),
155  M_pFESpace->qr(),
156  M_fespacePETA,
157 
158  TAU_M*value(M_density)*dot( grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep))
159 
160  ) >> rhs_pressure;
161 }
162 
163 } // namespace LifeV
#define TAU_M_DEN
#define TAU_M_DEN_VEL
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
#define TAU_M_DEN_VISC
#define TAU_C
#define TAU_M
#define TAU_M_DEN_DT