1 #include <lifev/navier_stokes_blocks/solver/StabilizationSUPG.hpp> 4 #define TAU_M value(1
)/( 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_previous_newton_step_rep), G * value(M_fespaceUETA, velocity_previous_newton_step_rep) ) ) 8 #define TAU_M_DEN_VISC ( value(M_C_I)*value(M_viscosity*M_viscosity) *dot (G, G) ) 11 #define TAU_C ( value(1.0
)/( dot(g, TAU_M*g ) ) ) 20 StabilizationSUPG::StabilizationSUPG():
29 void StabilizationSUPG::setConstant(
const int & value)
33 else if ( value == 2 )
36 ASSERT(0!=0,
"Please implement a suitable value for M_C_I for your velocity FE order");
39 void StabilizationSUPG::buildGraphs()
41 vector_Type velocity_previous_newton_step_rep( M_uFESpace->map(), Repeated);
42 vector_Type pressure_previous_newton_step_rep( M_pFESpace->map(), Repeated);
43 vector_Type velocity_rhs_rep( M_uFESpace->map(), Repeated);
45 velocity_previous_newton_step_rep.zero();
46 pressure_previous_newton_step_rep.zero();
47 velocity_rhs_rep.zero();
49 velocity_previous_newton_step_rep += 1;
50 pressure_previous_newton_step_rep += 1;
51 velocity_rhs_rep += 1;
53 std::shared_ptr<SquareRoot> squareroot(
new SquareRoot());
55 MatrixSmall<3, 3> Eye;
62 using namespace ExpressionAssembly;
65 M_graph_block00.reset (
new Epetra_FECrsGraph (Copy, * (M_uFESpace->map().map (Unique) ), 0) );
66 buildGraph ( elements ( M_uFESpace->mesh() ),
70 TAU_M*value(M_density*M_density)*value(M_alpha/M_timestep) * dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), phi_j )
71 +
TAU_M*value(M_density*M_density)*value(M_alpha/M_timestep) * dot( phi_j*grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep) )
72 -
TAU_M*value(M_density*M_density) * dot( phi_j*grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep) )
73 +
TAU_M*value(M_density*M_density) * dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), phi_j*grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
74 +
TAU_M*value(M_density*M_density) * dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_j) )
75 +
TAU_M*value(M_density*M_density) * dot( phi_j*grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
76 +
TAU_M*value(M_density)*dot( phi_j*grad(phi_i), grad(M_fespacePETA, pressure_previous_newton_step_rep) )
77 -
TAU_M*value(M_density*M_viscosity)*dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), laplacian(phi_j) )
78 -
TAU_M*value(M_density*M_viscosity)*dot( phi_j*grad(phi_i), laplacian(M_fespaceUETA, velocity_previous_newton_step_rep) )
79 +
TAU_C*div(phi_i)*div(phi_j)
81 M_graph_block00->GlobalAssemble();
82 M_graph_block00->OptimizeStorage();
85 M_graph_block10.reset (
new Epetra_FECrsGraph (Copy, * (M_pFESpace->map().map (Unique) ), 0) );
86 buildGraph ( elements (M_pFESpace->mesh() ),
90 TAU_M*value(M_density*M_alpha/M_timestep)*dot( grad(phi_i), phi_j )
91 +
TAU_M*value(M_density) * dot( grad(phi_i), phi_j*grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
92 +
TAU_M*value(M_density) * dot( grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_j) )
93 -
TAU_M*value(M_viscosity)*dot(grad(phi_i), laplacian(phi_j))
95 M_graph_block10->GlobalAssemble ( * (M_uFESpace->map().map (Unique) ), * (M_pFESpace->map().map (Unique) ) );
96 M_graph_block10->OptimizeStorage();
99 M_graph_block01.reset (
new Epetra_FECrsGraph (Copy, * (M_uFESpace->map().map (Unique) ), 0) );
100 buildGraph ( elements (M_pFESpace->mesh() ),
104 TAU_M*value(M_density)*dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), grad(phi_j) )
105 ) >> M_graph_block01;
106 M_graph_block01->GlobalAssemble ( * (M_pFESpace->map().map (Unique) ), * (M_uFESpace->map().map (Unique) ) );
107 M_graph_block01->OptimizeStorage();
110 M_graph_block11.reset (
new Epetra_FECrsGraph (Copy, * (M_pFESpace->map().map (Unique) ), 0) );
111 buildGraph ( elements (M_pFESpace->mesh() ),
115 TAU_M*dot( grad(phi_i), grad(phi_j) )
116 ) >> M_graph_block11;
117 M_graph_block11->GlobalAssemble ( );
118 M_graph_block11->OptimizeStorage();
122 M_block_00.reset (
new matrix_Type ( M_uFESpace->map(), *M_graph_block00 ) );
124 M_block_00->globalAssemble();
126 M_block_01.reset (
new matrix_Type ( M_uFESpace->map(), *M_graph_block01 ) );
128 M_block_01->globalAssemble( M_pFESpace->mapPtr(), M_uFESpace->mapPtr() );
130 M_block_10.reset (
new matrix_Type ( M_pFESpace->map(), *M_graph_block10 ) );
132 M_block_10->globalAssemble( M_uFESpace->mapPtr(), M_pFESpace->mapPtr() );
134 M_block_11.reset (
new matrix_Type ( M_pFESpace->map(), *M_graph_block11 ) );
136 M_block_11->globalAssemble( );
139 void StabilizationSUPG::apply_matrix(
const vector_Type& velocity_previous_newton_step,
140 const vector_Type& pressure_previous_newton_step,
141 const vector_Type& velocity_rhs)
146 M_block_00.reset (
new matrix_Type ( M_uFESpace->map() ) );
148 M_block_01.reset (
new matrix_Type ( M_uFESpace->map() ) );
150 M_block_10.reset (
new matrix_Type ( M_pFESpace->map() ) );
152 M_block_11.reset (
new matrix_Type ( M_pFESpace->map() ) );
160 vector_Type velocity_previous_newton_step_rep( velocity_previous_newton_step, Repeated);
161 vector_Type pressure_previous_newton_step_rep( pressure_previous_newton_step, Repeated);
162 vector_Type velocity_rhs_rep( velocity_rhs, Repeated);
164 std::shared_ptr<SquareRoot> squareroot(
new SquareRoot());
166 MatrixSmall<3, 3> Eye;
172 using namespace ExpressionAssembly;
175 elements(M_uFESpace->mesh()),
179 TAU_M*value(M_density*M_density)*value(M_alpha/M_timestep) * dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), phi_j )
180 +
TAU_M*value(M_density*M_density)*value(M_alpha/M_timestep) * dot( phi_j*grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep) )
181 -
TAU_M*value(M_density*M_density) * dot( phi_j*grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep) )
182 +
TAU_M*value(M_density*M_density) * dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), phi_j*grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
183 +
TAU_M*value(M_density*M_density) * dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_j) )
184 +
TAU_M*value(M_density*M_density) * dot( phi_j*grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
185 +
TAU_M*value(M_density)*dot( phi_j*grad(phi_i), grad(M_fespacePETA, pressure_previous_newton_step_rep) )
186 -
TAU_M*value(M_density*M_viscosity)*dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), laplacian(phi_j) )
187 -
TAU_M*value(M_density*M_viscosity)*dot( phi_j*grad(phi_i), laplacian(M_fespaceUETA, velocity_previous_newton_step_rep) )
188 +
TAU_C*div(phi_i)*div(phi_j)
190 M_block_00->globalAssemble();
193 elements(M_uFESpace->mesh()),
197 TAU_M*value(M_density*M_alpha/M_timestep)*dot( grad(phi_i), phi_j )
198 +
TAU_M*value(M_density) * dot( grad(phi_i), phi_j*grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
199 +
TAU_M*value(M_density) * dot( grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_j) )
200 -
TAU_M*value(M_viscosity)*dot(grad(phi_i), laplacian(phi_j))
202 M_block_10->globalAssemble( M_uFESpace->mapPtr(), M_pFESpace->mapPtr() );
205 elements(M_uFESpace->mesh()),
209 TAU_M*value(M_density)*dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), grad(phi_j) )
211 M_block_01->globalAssemble( M_pFESpace->mapPtr(), M_uFESpace->mapPtr() );
214 elements(M_uFESpace->mesh()),
218 TAU_M*dot( grad(phi_i), grad(phi_j) )
220 M_block_11->globalAssemble();
224 void StabilizationSUPG::apply_vector( vectorPtr_Type& residual_velocity,
225 vectorPtr_Type& residual_pressure,
226 const vector_Type& velocity_previous_newton_step,
227 const vector_Type& pressure_previous_newton_step,
228 const vector_Type& velocity_rhs)
232 vector_Type velocity_previous_newton_step_rep( velocity_previous_newton_step, Repeated);
233 vector_Type pressure_previous_newton_step_rep( pressure_previous_newton_step, Repeated);
234 vector_Type velocity_rhs_rep( velocity_rhs, Repeated);
236 std::shared_ptr<SquareRoot> squareroot(
new SquareRoot());
239 MatrixSmall<3, 3> Eye;
245 using namespace ExpressionAssembly;
248 elements(M_uFESpace->mesh()),
251 TAU_M*value(M_density*M_density)*value(M_alpha/M_timestep) * dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep) )
252 -
TAU_M*value(M_density*M_density)*dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep) )
253 +
TAU_M*value(M_density*M_density)*dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
254 +
TAU_M*value(M_density)*dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), grad(M_fespacePETA,pressure_previous_newton_step_rep) )
255 -
TAU_M*value(M_density*M_viscosity)*dot( value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(phi_i), laplacian(M_fespaceUETA, velocity_previous_newton_step_rep) )
256 +
TAU_C*div(phi_i)* trace ( grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
258 >> residual_velocity;
261 elements(M_uFESpace->mesh()),
264 TAU_M*value(M_density*M_alpha/M_timestep)*dot( grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep) )
265 -
TAU_M*value(M_density)*dot( grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep))
266 +
TAU_M*value(M_density)*dot( grad(phi_i), value(M_fespaceUETA, velocity_previous_newton_step_rep)*grad(M_fespaceUETA, velocity_previous_newton_step_rep) )
267 +
TAU_M*dot( grad(phi_i), grad(M_fespacePETA,pressure_previous_newton_step_rep) )
268 -
TAU_M*value(M_viscosity)*dot(grad(phi_i), laplacian(M_fespaceUETA, velocity_previous_newton_step_rep))
270 >> residual_pressure;