2 #include <lifev/fsi_blocks/solver/BlockJacobiPreconditioner.hpp> 4 #include <lifev/core/linear_algebra/IfpackPreconditioner.hpp> 5 #include <lifev/core/linear_algebra/MLPreconditioner.hpp> 6 #include <lifev/core/linear_algebra/TwoLevelPreconditioner.hpp> 7 #include <lifev/core/linear_algebra/AztecooOperatorAlgebra.hpp> 8 #include <lifev/core/linear_algebra/BelosOperatorAlgebra.hpp> 9 #include <lifev/core/linear_algebra/ApproximatedInvertibleRowMatrix.hpp> 11 #include <lifev/core/util/Displayer.hpp> 12 #include <lifev/core/util/LifeChrono.hpp> 24 M_label(
"BlockJacobiPreconditioner"),
55 M_FluidPrec.reset ( Operators::NSPreconditionerFactory::instance().createObject (type));
68 M_X_displacement.reset(
new VectorEpetra_Type( M_S->map(), Unique) );
69 M_Y_displacement.reset(
new VectorEpetra_Type( M_S->map(), Unique) );
70 M_structure = M_S->map().mapSize();
77 M_X_geometry.reset(
new VectorEpetra_Type (M_G->map(), Unique) );
78 M_Y_geometry.reset(
new VectorEpetra_Type (M_G->map(), Unique) );
89 M_X_velocity.reset(
new VectorEpetra_Type (M_F->map(), Unique) );
90 M_X_pressure.reset(
new VectorEpetra_Type (M_B->map(), Unique) );
91 M_Y_velocity.reset(
new VectorEpetra_Type (M_F->map(), Unique) );
92 M_Y_pressure.reset(
new VectorEpetra_Type (M_B->map(), Unique) );
93 M_fluidVelocity = M_F->map().mapSize();
94 M_fluid = M_fluidVelocity + M_B->map().mapSize();
107 M_D.reset(
new matrixEpetra_Type ( *D ) );
108 M_X_velocity.reset(
new VectorEpetra_Type (M_F->map(), Unique) );
109 M_X_pressure.reset(
new VectorEpetra_Type (M_B->map(), Unique) );
110 M_Y_velocity.reset(
new VectorEpetra_Type (M_F->map(), Unique) );
111 M_Y_pressure.reset(
new VectorEpetra_Type (M_B->map(), Unique) );
112 M_fluidVelocity = M_F->map().mapSize();
113 M_fluid = M_fluidVelocity + M_B->map().mapSize();
129 M_X_lambda.reset(
new VectorEpetra_Type ( M_C1->map(), Unique) );
130 M_Y_lambda.reset(
new VectorEpetra_Type ( M_C1->map(), Unique) );
131 M_lambda = M_C1->map().mapSize();
142 M_lagrangeMap = lagrangeMap;
143 M_X_lambda.reset(
new VectorEpetra_Type ( *M_lagrangeMap, Unique) );
144 M_Y_lambda.reset(
new VectorEpetra_Type ( *M_lagrangeMap, Unique) );
145 M_lambda = M_lagrangeMap->map(Unique)->NumGlobalElements();
183 std::shared_ptr<Teuchos::ParameterList> structureMomentumOptions;
184 structureMomentumOptions.reset(
new Teuchos::ParameterList(solversOptions.sublist(
"StructureMomentumOperator")) );
185 setStructureMomentumOptions(structureMomentumOptions);
187 std::shared_ptr<Teuchos::ParameterList> geometryMomentumOptions;
188 geometryMomentumOptions.reset(
new Teuchos::ParameterList(solversOptions.sublist(
"ALEOperator")) );
189 setGeometryOptions(geometryMomentumOptions);
191 std::shared_ptr<Teuchos::ParameterList> fluidMomentumOptions;
192 fluidMomentumOptions.reset(
new Teuchos::ParameterList(solversOptions.sublist(
"FluidMomentumOperator")) );
193 setFluidMomentumOptions(fluidMomentumOptions);
195 std::shared_ptr<Teuchos::ParameterList> schurFluidOptions;
196 schurFluidOptions.reset(
new Teuchos::ParameterList(solversOptions.sublist(
"ApproximatedSchurOperatorFluid")) );
197 setSchurOptions(schurFluidOptions);
199 if ( std::strcmp(M_FluidPrec->Label(),
"aPCDOperator") == 0 )
201 std::shared_ptr<Teuchos::ParameterList> pressureMassOptions;
202 pressureMassOptions.reset(
new Teuchos::ParameterList(solversOptions.sublist(
"PressureMassOperator")) );
203 setPressureMassOptions(pressureMassOptions);
211 ASSERT_PRE(_oList.get() != 0,
"oList pointer not valid");
218 ASSERT_PRE(_oList.get() != 0,
"oList pointer not valid");
225 ASSERT_PRE(_oList.get() != 0,
"oList pointer not valid");
227 M_FluidPrec->setMomentumOptions( M_fluidMomentumOptions );
233 ASSERT_PRE(_oList.get() != 0,
"oList pointer not valid");
235 M_FluidPrec->setSchurOptions( M_schurOptions );
241 ASSERT_PRE(_oList.get() != 0,
"oList pointer not valid");
243 M_FluidPrec->setPressureMassOptions( M_pressureMassOptions );
249 M_approximatedStructureMomentumOperator->SetRowMatrix(M_S->matrixPtr());
250 M_approximatedStructureMomentumOperator->SetParameterList(*M_structureMomentumOptions);
251 M_approximatedStructureMomentumOperator->Compute();
258 M_approximatedGeometryOperator->SetRowMatrix(M_G->matrixPtr());
259 M_approximatedGeometryOperator->SetParameterList(*M_geometryOptions);
260 M_approximatedGeometryOperator->Compute();
268 Fprecc.reset (
new matrixEpetra_Type(*M_F) );
269 Btprecc.reset (
new matrixEpetra_Type(*M_Btranspose) );
271 if ( !M_myBC->bcUpdateDone() )
272 M_myBC->bcUpdate ( *M_velocityFESpace->mesh(), M_velocityFESpace->feBd(), M_velocityFESpace->dof() );
274 bcManageMatrix ( *Fprecc, *M_velocityFESpace->mesh(), M_velocityFESpace->dof(), *M_myBC, M_velocityFESpace->feBd(), 1.0, 0.0 );
276 bcManageMatrix ( *Btprecc, *M_velocityFESpace->mesh(), M_velocityFESpace->dof(), *M_myBC, M_velocityFESpace->feBd(), 0.0, 0.0 );
278 if ( std::strcmp(M_FluidPrec->Label(),
"aSIMPLEOperator")==0 )
280 if ( !M_useStabilization )
281 M_FluidPrec->setUp( Fprecc, M_B, Btprecc);
283 M_FluidPrec->setUp( Fprecc, M_B, Btprecc, M_D);
285 else if ( std::strcmp(M_FluidPrec->Label(),
"aPCDOperator")==0 )
287 M_FluidPrec->setUp( Fprecc, M_B, Btprecc, M_Fp, M_Mp, M_Mu);
290 Displayer M_displayer( M_F->map().commPtr() );
292 M_displayer.leaderPrint(
"\tNS operator - set up the block operator...");
296 Operators::NavierStokesOperator::operatorPtrContainer_Type operData(2,2);
297 operData(0,0) = Fprecc->matrixPtr();
298 operData(0,1) = Btprecc->matrixPtr();
299 operData(1,0) = M_B->matrixPtr();
300 if ( M_useStabilization )
301 operData(1,1) = M_D->matrixPtr();
303 M_oper.reset(
new Operators::NavierStokesOperator );
304 M_oper->setUp(operData, M_displayer.comm());
306 M_displayer.leaderPrintMax(
" done in " , chrono.diff() );
308 M_displayer.leaderPrint(
"\tPreconditioner operator - set up the block operator...");
312 M_FluidPrec->setDomainMap(M_oper->OperatorDomainBlockMapPtr());
313 M_FluidPrec->setRangeMap(M_oper->OperatorRangeBlockMapPtr());
314 M_FluidPrec->updateApproximatedMomentumOperator();
315 M_FluidPrec->updateApproximatedSchurComplementOperator();
316 if ( std::strcmp(M_FluidPrec->Label(),
"aPCDOperator")==0 )
318 M_displayer.leaderPrint(
"\tNS operator - UPDATING PRESSURE MASS...");
319 M_FluidPrec->updateApproximatedPressureMassOperator();
323 M_displayer.leaderPrintMax(
" done in " , chrono.diff() );
325 M_displayer.leaderPrint(
"\tset up the Trilinos solver...");
328 std::string solverType(M_fluidMomentumOptions->sublist(
"FluidSolver").get<std::string>(
"Linear Solver Type"));
329 M_invOper.reset(Operators::InvertibleOperatorFactory::instance().createObject(solverType));
330 M_invOper->setParameterList(M_fluidMomentumOptions->sublist(
"FluidSolver").sublist(solverType));
332 M_invOper->setOperator(M_oper);
333 M_invOper->setPreconditioner(M_FluidPrec);
336 M_displayer.leaderPrintMax(
" done in " , chrono.diff() );
343 ASSERT_PRE(X.NumVectors() == Y.NumVectors(),
"X and Y must have the same number of vectors");
349 M_X_velocity->zero();
350 M_X_velocity->subset(X_vectorEpetra, M_F->map(), 0, 0);
352 M_X_pressure->zero();
353 M_X_pressure->subset(X_vectorEpetra, M_B->map(), M_fluidVelocity, 0 );
355 M_X_displacement->zero();
356 M_X_displacement->subset(X_vectorEpetra, M_S->map(), M_fluid, 0 );
361 M_X_lambda->subset(X_vectorEpetra, *M_lagrangeMap, M_fluid + M_structure, 0 );
366 M_X_lambda->subset(X_vectorEpetra, M_C1->map(), M_fluid + M_structure, 0 );
369 M_X_geometry->zero();
370 M_X_geometry->subset(X_vectorEpetra, M_G->map(), M_fluid + M_structure + M_lambda , 0 );
372 M_Y_displacement->zero();
373 M_approximatedStructureMomentumOperator->ApplyInverse(M_X_displacement->epetraVector(), M_Y_displacement->epetraVector() );
377 M_Y_geometry->zero();
380 M_StructureToFluidInterpolant->updateRhs(M_Y_displacement);
381 M_StructureToFluidInterpolant->interpolate();
382 M_StructureToFluidInterpolant->solution(tmp_geo);
384 M_approximatedGeometryOperator->ApplyInverse(( *M_X_geometry ).epetraVector(), M_Y_geometry->epetraVector() );
388 M_approximatedGeometryOperator->ApplyInverse(( *M_X_geometry ).epetraVector(), M_Y_geometry->epetraVector() );
398 tmp_z_lambda->zero();
399 tmp_z_lambda_omega->zero();
401 M_StructureToFluidInterpolant->updateRhs(M_Y_displacement);
402 M_StructureToFluidInterpolant->interpolate();
403 M_StructureToFluidInterpolant->solution(tmp_z_lambda_omega);
405 *tmp_z_lambda_omega /= M_timeStep;
409 *tmp_z_lambda_omega *= M_bdfCoef;
413 *tmp_z_lambda_omega *= M_gamma;
414 *tmp_z_lambda_omega /= M_beta;
417 M_FluidToStructureInterpolant->restrictOmegaToGamma_Known(tmp_z_lambda_omega, tmp_z_lambda);
419 *Zlambda = ( *M_X_lambda - *tmp_z_lambda ) ;
423 *Zlambda = ( *M_X_lambda + *M_C2* ( *M_Y_displacement ) ) ;
434 Wf_velocity
+= Zf_velocity;
436 if ( !M_myBC->bcUpdateDone() )
438 M_myBC->bcUpdate ( *M_velocityFESpace->mesh(), M_velocityFESpace->feBd(), M_velocityFESpace->dof() );
441 bcManageRhs ( Wf_velocity, *M_velocityFESpace->mesh(), M_velocityFESpace->dof(), *M_myBC, M_velocityFESpace->feBd(), 0.0, 0.0 );
445 M_FluidToStructureInterpolant->expandGammaToOmega_Known( Zlambda, Zlambda_omega );
447 Wf_velocity += *Zlambda_omega;
451 Wf_velocity = Zf_velocity - ( *M_C1transpose * (*M_C1 * Zf_velocity) - ( *M_C1transpose * ( *Zlambda ) ) );
454 M_Y_velocity->zero();
455 M_Y_pressure->zero();
457 M_FluidPrec->ApplyInverse( Wf_velocity, Zf_pressure, *M_Y_velocity, *M_Y_pressure);
469 *tmp_omega = Zf_velocity + ( *M_F * ( *M_Y_velocity ) + *M_Btranspose * ( *M_Y_pressure ) );
471 M_FluidToStructureInterpolant->restrictOmegaToGamma_Known( tmp_omega, tmp_gamma);
473 *M_Y_lambda += *tmp_gamma;
477 *M_Y_lambda = *M_C1 * ( Zf_velocity + ( *M_F * ( *M_Y_velocity ) ) );
481 Y_vectorEpetra.zero();
483 Y_vectorEpetra.subset(*M_Y_velocity, M_Y_velocity->map(), 0, 0 );
484 Y_vectorEpetra.subset(*M_Y_pressure, M_Y_pressure->map(), 0, M_fluidVelocity );
485 Y_vectorEpetra.subset(*M_Y_displacement, M_Y_displacement->map(), 0, M_fluid );
486 Y_vectorEpetra.subset(*M_Y_lambda, M_Y_lambda->map(), 0, M_fluid + M_structure );
487 Y_vectorEpetra.subset(*M_Y_geometry, M_Y_geometry->map(), 0, M_fluid + M_structure + M_lambda );
488 Y =
dynamic_cast<Epetra_MultiVector &>( Y_vectorEpetra.epetraVector() );
std::shared_ptr< Teuchos::ParameterList > parameterListPtr_Type
matrixEpetraPtr_Type M_shapePressure
void start()
Start the timer.
void setPressureMassOptions(const parameterListPtr_Type &_oList)
Set the list of the shur complement of the fluid.
void setStructureBlock(const matrixEpetraPtr_Type &S)
Set the structure block.
matrixEpetraPtr_Type M_Mu
mapEpetraPtr_Type M_monolithicMap
interpolationPtr_Type M_StructureToFluidInterpolant
BlockJacobiPreconditioner()
Empty constructor.
matrixEpetraPtr_Type M_Fp
PCD blocks.
matrixEpetraPtr_Type M_C1transpose
Coupling blocks.
VectorEpetra VectorEpetra_Type
void setOptions(const Teuchos::ParameterList &solversOptions)
Interface to set the parameters of each block.
void setUseShapeDerivatives(const bool &useShapeDerivatives)
Set the use of shape derivatives.
parameterListPtr_Type M_structureMomentumOptions
Parameters for the structure.
parameterListPtr_Type M_geometryOptions
Parameters for the geometry.
void setGeometryOptions(const parameterListPtr_Type &_oList)
Set the list of the geometry.
VectorEpetra(const MapEpetra &map, const MapEpetraType &mapType=Unique, const combineMode_Type combineMode=Add)
Constructor - Using Maps.
void updateApproximatedStructureMomentumOperator()
Update the approximation of the structure momentum.
void updateInverseJacobian(const UInt &iQuadPt)
void setFluidBlocks(const matrixEpetraPtr_Type &F, const matrixEpetraPtr_Type &Btranspose, const matrixEpetraPtr_Type &B, const matrixEpetraPtr_Type &D)
Set the fluid blocks.
parameterListPtr_Type M_pressureMassOptions
Parameters for the pressure mass of the PCD.
void setGeometryBlock(const matrixEpetraPtr_Type &G)
Set the geometry block.
virtual ~BlockJacobiPreconditioner()
bool M_subiterateFluidDirichlet
int ApplyInverse(const vector_Type &X, vector_Type &Y) const
Returns the High Order Yosida approximation of the inverse pressure Schur Complement applied to X...
void setStructureMomentumOptions(const parameterListPtr_Type &_oList)
Set the list of the structure momentum.
matrixEpetraPtr_Type M_C1
VectorEpetra & operator+=(const VectorEpetra &vector)
Addition operator.
std::shared_ptr< VectorEpetra_Type > VectorEpetraPtr_Type
const MapEpetra & map() const
Return the MapEpetra of the vector.
void setPCDBlocks(const matrixEpetraPtr_Type &Fp, const matrixEpetraPtr_Type &Mp, const matrixEpetraPtr_Type &Mu)
Set the blocks needed by the PCD preconditioner.
void setCouplingOperators_nonconforming(interpolationPtr_Type fluidToStructure, interpolationPtr_Type structureToFluid, mapEpetraPtr_Type lagrangeMap)
Copy the pointer of the interpolation objects.
matrixEpetraPtr_Type M_Mp
parameterListPtr_Type M_schurOptions
Parameters for the shur complent of the fluid.
void showMe()
Show information about the class.
void setFluidBlocks(const matrixEpetraPtr_Type &F, const matrixEpetraPtr_Type &Btranspose, const matrixEpetraPtr_Type &B)
Set the fluid blocks.
matrixEpetraPtr_Type M_shapeVelocity
void setFluidPreconditioner(const std::string &type)
Set the preconditioner type.
matrixEpetraPtr_Type M_G
Geometry block.
parameterListPtr_Type M_fluidMomentumOptions
Parameters for the fluid momentum.
matrixEpetraPtr_Type M_C2transpose
matrixEpetraPtr_Type M_C3
Epetra_MultiVector vector_Type
void setFluidMomentumOptions(const parameterListPtr_Type &_oList)
Set the list of the fluid momentum.
void stop()
Stop the timer.
matrixEpetraPtr_Type M_C2
void setSchurOptions(const parameterListPtr_Type &_oList)
Set the list of the shur complement of the fluid.
void updateApproximatedGeometryOperator()
Update the approximation of the the geometry.
void setShapeDerivativesBlocks(const matrixEpetraPtr_Type &ShapeVelocity, const matrixEpetraPtr_Type &ShapePressure)
Set the shape derivatives.
matrixEpetraPtr_Type M_S
Structure block.
interpolationPtr_Type M_FluidToStructureInterpolant
std::shared_ptr< Interpolation > interpolationPtr_Type
void setSubiterateFluidDirichlet(const bool &subiterateFluidDirichlet)
void updateApproximatedFluidOperator()
Update the approximation of the the geometry.
std::shared_ptr< mapEpetra_Type > mapEpetraPtr_Type
void zero()
set zero in all the vector entries
void setCouplingBlocks(const matrixEpetraPtr_Type &C1transpose, const matrixEpetraPtr_Type &C2transpose, const matrixEpetraPtr_Type &C2, const matrixEpetraPtr_Type &C1, const matrixEpetraPtr_Type &C3)
Set the coupling blocks.
matrixEpetraPtr_Type M_F
Fluid blocks.
Displayer - This class is used to display messages in parallel simulations.
std::shared_ptr< matrixEpetra_Type > matrixEpetraPtr_Type
void setMonolithicMap(const mapEpetraPtr_Type &monolithicMap)
Set the monolithic map.
matrixEpetraPtr_Type M_Btranspose