1 #include <lifev/navier_stokes_blocks/solver/StabilizationSUPG_semi_implicit_ale.hpp> 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, beta_rep), value(M_fespaceUETA, beta_rep))/(h_K*h_K) 8 #define TAU_M_DEN_VISC value(M_C_I)*value(M_viscosity*M_viscosity)/(h_K*h_K*h_K*h_K) 11 #define TAU_M_DEN_DT_NOSQUARED value(M_density)*value(M_alpha)/value(M_timestep) 23 #define TAU_M_DEN_VEL_UPRIME value(M_density*M_density)*dot(value(M_fespaceUETA, *velocity_repeated), value(M_fespaceUETA, *velocity_repeated))/(h_K*h_K) 24 #define TAU_M_DEN_VISC_UPRIME value(M_C_I)*value(M_viscosity*M_viscosity)/(h_K*h_K*h_K*h_K) 37 StabilizationSUPG_semi_implicit_ale::StabilizationSUPG_semi_implicit_ale():
38 M_label(
"SUPG_semi_implicit_ale"),
39 M_useODEfineScale (
false )
47 void StabilizationSUPG_semi_implicit_ale::setConstant(
const int & value)
51 else if ( value == 2 )
54 ASSERT(0!=0,
"Please implement a suitable value for M_C_I for your velocity FE order");
57 void StabilizationSUPG_semi_implicit_ale::setUseODEfineScale (
const bool& useODEfineScale )
59 M_useODEfineScale = useODEfineScale;
63 void StabilizationSUPG_semi_implicit_ale::setupODEfineScale ( )
65 int numVolumes = M_uFESpace->mesh()->numVolumes();
66 UInt numQuadraturePointsVelocity = M_uFESpace->qr().nbQuadPt();
68 std::vector<std::vector<VectorSmall<3>>> velocity_fine;
69 velocity_fine.resize(numVolumes);
71 M_fineScaleVelocity.resize(numVolumes);
72 M_fineScalePressure.resize(numVolumes);
73 M_fineScaleVelocityRhs.resize(numVolumes);
75 for (
int i = 0; i < numVolumes; ++i )
77 velocity_fine[i].resize( numQuadraturePointsVelocity );
78 M_fineScaleVelocityRhs[i].resize( numQuadraturePointsVelocity );
79 M_fineScaleVelocity[i].resize( numQuadraturePointsVelocity );
80 M_fineScalePressure[i].resize( numQuadraturePointsVelocity );
84 for (
int j = 0; j < numQuadraturePointsVelocity; ++j )
86 velocity_fine[i][j](0) = 0.0;
87 velocity_fine[i][j](1) = 0.0;
88 velocity_fine[i][j](2) = 0.0;
90 M_fineScaleVelocity[i][j](0) = 0.0;
91 M_fineScaleVelocity[i][j](1) = 0.0;
92 M_fineScaleVelocity[i][j](2) = 0.0;
94 M_fineScalePressure[i][j](0) = 0.0;
96 M_fineScaleVelocityRhs[i][j](0) = 0.0;
97 M_fineScaleVelocityRhs[i][j](1) = 0.0;
98 M_fineScaleVelocityRhs[i][j](2) = 0.0;
102 M_handlerFineScaleVelocity.reset(
new TimeAndExtrapolationHandlerQuadPts<3> ( ) );
103 M_handlerFineScaleVelocity->setBDForder(M_bdfOrder);
104 M_handlerFineScaleVelocity->setTimeStep(M_timestep);
105 std::vector<std::vector<std::vector<VectorSmall<3>>>> initial_state_velocity;
106 for (
int i = 0; i < M_bdfOrder; ++i )
108 initial_state_velocity.push_back ( velocity_fine );
110 M_handlerFineScaleVelocity->initialize(initial_state_velocity);
114 void StabilizationSUPG_semi_implicit_ale::updateODEfineScale (
const vectorPtr_Type& velocity,
const vectorPtr_Type& pressure )
116 computeFineScales(velocity, pressure );
117 computeFineScalesForVisualization ( velocity, pressure );
118 M_handlerFineScaleVelocity->shift(M_fineScaleVelocity);
119 M_handlerFineScaleVelocity->rhsContribution(M_fineScaleVelocityRhs);
122 void StabilizationSUPG_semi_implicit_ale::computeFineScales (
const vectorPtr_Type& velocity,
const vectorPtr_Type& pressure )
124 vectorPtr_Type velocity_repeated(
new vector_Type( *velocity, Repeated ) );
125 vectorPtr_Type pressure_repeated(
new vector_Type( *pressure, Repeated ) );
126 vectorPtr_Type velocity_rhs_repeated(
new vector_Type( *M_rhsVelocity, Repeated) );
128 using namespace ExpressionAssembly;
130 std::shared_ptr<SquareRoot_supg_semi_implicit_ale> squareroot(
new SquareRoot_supg_semi_implicit_ale());
132 EvaluateAtQuadrature ( elements ( M_uFESpace->mesh() ),
136 value(-M_density*M_alpha/M_timestep)*value(M_fespaceUETA, *velocity_repeated)
137 +value(M_density)*value(M_fespaceUETA, *velocity_rhs_repeated)
138 -value(M_density)*value(M_fespaceUETA, *velocity_repeated)*grad(M_fespaceUETA, *velocity_repeated)
139 -grad(M_fespacePETA, *pressure_repeated)
140 +value(M_viscosity)*laplacian(M_fespaceUETA, *velocity_repeated)
141 +value(M_density)*quadpts(M_fespaceUETA, M_fineScaleVelocityRhs )
143 ) >> M_fineScaleVelocity;
145 EvaluateAtQuadrature ( elements ( M_uFESpace->mesh() ),
148 value(-1.0) *
TAU_C_NO_DT_PPRIME * trace( grad ( M_fespaceUETA, *velocity_repeated ) )
149 ) >> M_fineScalePressure;
153 void StabilizationSUPG_semi_implicit_ale::computeFineScalesForVisualization (
const vectorPtr_Type& velocity,
const vectorPtr_Type& pressure )
155 QuadratureRule qr ( quadRuleTetra1pt );
157 using namespace ExpressionAssembly;
159 vectorPtr_Type velocity_repeated(
new vector_Type( *velocity, Repeated ) );
160 vectorPtr_Type pressure_repeated(
new vector_Type( *pressure, Repeated ) );
161 vectorPtr_Type velocity_rhs_repeated(
new vector_Type( *M_rhsVelocity, Repeated) );
163 std::shared_ptr<SquareRoot_supg_semi_implicit_ale> squareroot(
new SquareRoot_supg_semi_implicit_ale());
165 ComputeFineScaleVel ( elements ( M_fespaceUETA->mesh() ),
169 value(-M_density*M_alpha/M_timestep)*value(M_fespaceUETA, *velocity_repeated)
170 +value(M_density)*value(M_fespaceUETA, *velocity_rhs_repeated)
171 -value(M_density)*value(M_fespaceUETA, *velocity_repeated)*grad(M_fespaceUETA, *velocity_repeated)
172 -grad(M_fespacePETA, *pressure_repeated)
173 +value(M_viscosity)*laplacian(M_fespaceUETA, *velocity_repeated)
174 +value(M_density)*quadpts(M_fespaceUETA, M_fineScaleVelocityRhs )
176 ) >> *M_fineVelocity;
178 ComputeFineScalePres ( elements ( M_pFESpace->mesh() ),
181 value(-1.0) *
TAU_C_NO_DT_PPRIME * trace( grad ( M_fespaceUETA, *velocity_repeated ) )
182 ) >> *M_finePressure;
186 void StabilizationSUPG_semi_implicit_ale::setExportFineScaleVelocity ( ExporterHDF5<mesh_Type> & exporter,
const int& numElementsTotal )
188 int numVolumes = M_uFESpace->mesh()->numVolumes();
189 std::vector<
int> id_elem;
190 std::vector<
int> id_elem_scalar;
191 for (
int i = 0; i < numVolumes; ++i )
193 id_elem_scalar.push_back ( M_uFESpace->mesh()->element(i).id() );
195 for (
int j = 0; j < 3; ++j )
197 id_elem.push_back ( M_uFESpace->mesh()->element(i).id() + numElementsTotal * j );
201 int* pointerToDofs_scalar (0);
202 pointerToDofs_scalar = &id_elem_scalar[0];
203 std::shared_ptr<MapEpetra> map_scalar (
new MapEpetra ( -1,
static_cast<
int> (id_elem_scalar.size() ), pointerToDofs_scalar, M_uFESpace->map().commPtr() ) );
205 int* pointerToDofs (0);
206 pointerToDofs = &id_elem[0];
207 std::shared_ptr<MapEpetra> map (
new MapEpetra ( -1,
static_cast<
int> (id_elem.size() ), pointerToDofs, M_uFESpace->map().commPtr() ) );
209 M_fineVelocity.reset (
new vector_Type (*map, Unique ) );
210 M_fineVelocity->zero();
212 M_finePressure.reset (
new vector_Type (*map, Unique ) );
213 M_finePressure->zero();
215 exporter.addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"fine scale velocity", M_uFESpace, M_fineVelocity, UInt (0),
216 ExporterData< mesh_Type >::UnsteadyRegime, ExporterData< mesh_Type >::Cell );
217 exporter.addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField,
"fine scale pressure", M_pFESpace, M_finePressure, UInt (0),
218 ExporterData< mesh_Type >::UnsteadyRegime, ExporterData< mesh_Type >::Cell );
221 void StabilizationSUPG_semi_implicit_ale::buildGraphs()
317 void StabilizationSUPG_semi_implicit_ale::apply_matrix(
const vector_Type& velocityExtrapolated,
const vector_Type& velocityALE )
321 M_block_00.reset (
new matrix_Type ( M_uFESpace->map() ) );
323 M_block_01.reset (
new matrix_Type ( M_uFESpace->map() ) );
325 M_block_10.reset (
new matrix_Type ( M_pFESpace->map() ) );
327 M_block_11.reset (
new matrix_Type ( M_pFESpace->map() ) );
337 vector_Type beta( velocityExtrapolated - velocityALE );
338 vector_Type beta_rep ( beta, Repeated );
340 vector_Type velocity_extrapolated_rep( velocityExtrapolated, Repeated);
341 vector_Type velocity_ALE_rep( velocityALE, Repeated);
343 std::shared_ptr<SquareRoot_supg_semi_implicit_ale> squareroot(
new SquareRoot_supg_semi_implicit_ale());
345 using namespace ExpressionAssembly;
347 if ( M_useODEfineScale )
350 elements(M_uFESpace->mesh()),
355 TAU_M_TILDE*value(M_density*M_density)*value(M_alpha/M_timestep) * dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), phi_j )
356 +
TAU_M_TILDE*value(M_density*M_density) * dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), value(M_fespaceUETA, beta_rep)*grad(phi_j) )
358 -
TAU_M_TILDE*value(M_density*M_viscosity)*dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), laplacian(phi_j) )
365 elements(M_uFESpace->mesh()),
372 dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), value(M_density*M_density*M_alpha/M_timestep) * phi_j
373 +value(M_density*M_density)*value(M_fespaceUETA, beta_rep)*grad(phi_j)
374 -value(M_density*M_viscosity)*laplacian(phi_j)
379 +
TAU_C*div(phi_i)*div(phi_j)
390 M_block_00->globalAssemble();
392 if ( M_useODEfineScale )
395 elements(M_uFESpace->mesh()),
400 TAU_M_TILDE*value(M_density*M_alpha/M_timestep)*dot( grad(phi_i), phi_j )
401 +
TAU_M_TILDE*value(M_density) * dot( grad(phi_i), value(M_fespaceUETA, beta_rep)*grad(phi_j) )
402 -
TAU_M_TILDE*value(M_viscosity)*dot(grad(phi_i), laplacian(phi_j))
409 elements(M_uFESpace->mesh()),
415 dot( grad(phi_i), value(M_density*M_alpha/M_timestep)*phi_j
416 +value(M_density)*value(M_fespaceUETA, beta_rep)*grad(phi_j)
417 -value(M_viscosity)*laplacian(phi_j)
430 M_block_10->globalAssemble( M_uFESpace->mapPtr(), M_pFESpace->mapPtr() );
432 if ( M_useODEfineScale )
435 elements(M_uFESpace->mesh()),
440 TAU_M_TILDE*value(M_density)*dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), grad(phi_j) )
447 elements(M_uFESpace->mesh()),
452 TAU_M*value(M_density)*dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), grad(phi_j) )
456 M_block_01->globalAssemble( M_pFESpace->mapPtr(), M_uFESpace->mapPtr() );
458 if ( M_useODEfineScale )
461 elements(M_uFESpace->mesh()),
473 elements(M_uFESpace->mesh()),
478 TAU_M*dot( grad(phi_j), grad(phi_i) )
482 M_block_11->globalAssemble();
486 void StabilizationSUPG_semi_implicit_ale::apply_vector( vectorPtr_Type& rhs_velocity,
487 vectorPtr_Type& rhs_pressure,
488 const vector_Type& velocityExtrapolated,
489 const vector_Type& velocityALE,
490 const vector_Type& velocity_rhs)
492 M_rhsVelocity.reset(
new vector_Type ( velocity_rhs, Unique ) );
496 vector_Type beta( velocityExtrapolated - velocityALE );
497 vector_Type beta_rep ( beta, Repeated );
499 vector_Type velocity_rhs_rep( velocity_rhs, Repeated);
500 vector_Type velocity_extrapolated_rep( velocityExtrapolated, Repeated);
502 std::shared_ptr<SquareRoot_supg_semi_implicit_ale> squareroot(
new SquareRoot_supg_semi_implicit_ale());
504 using namespace ExpressionAssembly;
506 if ( M_useODEfineScale )
509 elements(M_uFESpace->mesh()),
513 TAU_M_TILDE*value(M_density*M_density)*dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep) )
514 +
TAU_M_TILDE*value(M_density*M_density)*dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), quadpts(M_fespaceUETA, M_fineScaleVelocityRhs) )
519 elements(M_uFESpace->mesh()),
523 TAU_M_TILDE*value(M_density)*dot( grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep))
524 +
TAU_M_TILDE*value(M_density)*dot( grad(phi_i), quadpts(M_fespaceUETA, M_fineScaleVelocityRhs))
533 elements(M_uFESpace->mesh()),
537 TAU_M*value(M_density*M_density)*dot( value(M_fespaceUETA, beta_rep)*grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep) )
542 elements(M_uFESpace->mesh()),
546 TAU_M*value(M_density)*dot( grad(phi_i), value(M_fespaceUETA, velocity_rhs_rep))
#define TAU_M_DEN_VISC_UPRIME
#define TAU_M_DEN_DT_NOSQUARED
#define TAU_M_DEN_VEL_UPRIME
#define TAU_C_NO_DT_PPRIME
#define TAU_M_NO_DT_UPRIME