Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
Preconditioner_decl.hpp
1#ifndef Preconditioner_DECL_hpp
2#define Preconditioner_DECL_hpp
3
4#include <Xpetra_ThyraUtils.hpp>
5#include <Thyra_PreconditionerBase.hpp>
6#include <Thyra_DefaultPreconditioner_decl.hpp>
7#include <Stratimikos_FROSch_def.hpp>
8
9#include "feddlib/core/General/DefaultTypeDefs.hpp"
10#include "feddlib/core/General/ExporterParaView.hpp"
11#include "feddlib/problems/problems_config.h"
12
13#ifdef FEDD_HAVE_TEKO
14#include <Teko_StratimikosFactory.hpp>
15#include <Teko_StaticRequestCallback.hpp>
16#endif
17
26
27namespace FEDD {
28template <class SC , class LO , class GO , class NO >
29class Problem;
30template <class SC , class LO , class GO , class NO >
31class TimeProblem;
32template <class SC , class LO , class GO , class NO >
33class MinPrecProblem;
34template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
35class Preconditioner {
36
37public:
38
39 typedef Teuchos::RCP<Teuchos::Comm<int> > CommPtr_Type;
40 typedef Teuchos::RCP<const Teuchos::Comm<int> > CommConstPtr_Type;
41
42 typedef Problem<SC,LO,GO,NO> Problem_Type;
43 typedef TimeProblem<SC,LO,GO,NO> TimeProblem_Type;
44 typedef MinPrecProblem<SC,LO,GO,NO> MinPrecProblem_Type;
45 typedef Teuchos::RCP<Problem_Type> ProblemPtr_Type;
46 typedef Teuchos::RCP<TimeProblem_Type> TimeProblemPtr_Type;
47 typedef Teuchos::RCP<MinPrecProblem_Type> MinPrecProblemPtr_Type;
48 typedef Map<LO,GO,NO> Map_Type;
49 typedef Teuchos::RCP<Map<LO,GO,NO> > MapPtr_Type;
50 typedef Teuchos::RCP<const Map<LO,GO,NO> > MapConstPtr_Type;
51 typedef Teuchos::RCP<Thyra::PreconditionerBase<SC> > ThyraPrecPtr_Type;
52 typedef Teuchos::RCP<const Thyra::PreconditionerBase<SC> > ThyraPrecConstPtr_Type;
53 typedef Teuchos::RCP<Thyra::LinearOpBase<SC> > ThyraLinOpPtr_Type;
54 typedef Teuchos::RCP<const Thyra::LinearOpBase<SC> > ThyraLinOpConstPtr_Type;
55 typedef Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder > LinSolverBuilderPtr_Type;
56
57 typedef Mesh<SC,LO,GO,NO> Mesh_Type;
58 typedef Teuchos::RCP<Mesh_Type> MeshPtr_Type;
59 typedef Teuchos::RCP<const Mesh_Type> MeshConstPtr_Type;
60
61 typedef typename Problem_Type::DomainConstPtr_Type DomainConstPtr_Type;
62
63 typedef typename Problem_Type::MultiVector_Type MultiVector_Type;
64 typedef typename Problem_Type::MultiVectorPtr_Type MultiVectorPtr_Type;
65 typedef typename Problem_Type::MultiVectorConstPtr_Type MultiVectorConstPtr_Type;
66
67 typedef typename Problem_Type::BlockMultiVector_Type BlockMultiVector_Type;
68 typedef typename Problem_Type::BlockMultiVectorPtr_Type BlockMultiVectorPtr_Type;
69
70 typedef typename Problem_Type::Matrix_Type Matrix_Type;
71 typedef typename Problem_Type::MatrixPtr_Type MatrixPtr_Type;
72
73 typedef typename Problem_Type::BlockMatrix_Type BlockMatrix_Type;
74 typedef typename Problem_Type::BlockMatrixPtr_Type BlockMatrixPtr_Type;
75
76 typedef typename Problem_Type::BC_Type BC_Type;
77 typedef typename Problem_Type::BCConstPtr_Type BCConstPtr_Type;
78
79 Preconditioner(Problem_Type* problem);
80
81 Preconditioner(TimeProblem_Type* problem);
82
83 ~Preconditioner();
84
85 ThyraPrecPtr_Type getThyraPrec();
86
87 ThyraPrecConstPtr_Type getThyraPrecConst() const;
88
89 void setPreconditionerThyraFromLinOp( ThyraLinOpPtr_Type precLinOp );
90
91 void buildPreconditioner( std::string type="Monolithic" );
92
93 void initializePreconditioner( std::string type="Monolithic" );
94
95 void buildPreconditionerMonolithic( );
96
97 void buildPreconditionerMonolithicFSI( );
98
99 void initPreconditionerMonolithic( );
100
101 void initPreconditionerBlock( );
102
103#ifdef FEDD_HAVE_TEKO
104 void buildPreconditionerTeko( );
105
106 void setVelocityParameters( ParameterListPtr_Type parameterList, int coarseRanks );
107
108 void setPressureParameters( ParameterListPtr_Type parameterList, int coarseRanks );
109
110 ThyraLinOpConstPtr_Type getTekoOp();
111
112 void setVelocityMassMatrix(MatrixPtr_Type massMatrix) const;
113 MatrixPtr_Type getVelocityMassMatrix(){return velocityMassMatrixMatrixPtr_;}
114
115 void setPressureLaplaceMatrix(MatrixPtr_Type matrix) const;
116 MatrixPtr_Type getPressureLaplaceMatrix(){return pressureLaplaceMatrixPtr_;}
117
118 void setPCDOperator(MatrixPtr_Type matrix) const;
119 MatrixPtr_Type getPCDOperatorMatrix(){return pcdOperatorMatrixPtr_;}
120#endif
121
122 void setPressureMassMatrix(MatrixPtr_Type massMatrix) const;
123 MatrixPtr_Type getPressureMassMatrix(){return pressureMassMatrixPtr_;}
124
125 void buildPreconditionerFaCSI( std::string type );
126
127 void buildPreconditionerBlock2x2();
128
129 void setFaCSIBCFactory( BCConstPtr_Type bcFactory ){ faCSIBCFactory_ = bcFactory; }
130
131 bool hasFaCSIBCFactory(){ return !faCSIBCFactory_.is_null(); }
132
133 BCConstPtr_Type getFaCSIBCFactory( ){ return faCSIBCFactory_; }
134
135 void exportCoarseBasis( );
136
137 void exportCoarseBasisFSI( );
138
139 bool isPreconditionerComputed() const{return precondtionerIsBuilt_;}
140
143 void setPressureProjection(BlockMultiVectorPtr_Type pressureProjection) const;
144
147 BlockMultiVectorPtr_Type getPressureProjection(){return pressureProjection_;}
148
149
150private:
151 ThyraPrecPtr_Type thyraPrec_;
152 bool precondtionerIsBuilt_;
153 ProblemPtr_Type problem_;
154 TimeProblemPtr_Type timeProblem_;
155 Teuchos::RCP<Thyra::PreconditionerFactoryBase<SC> > precFactory_;
156#ifdef FEDD_HAVE_TEKO
157 ThyraLinOpConstPtr_Type tekoLinOp_;
158 Teuchos::RCP<Teko::RequestHandler> rh_;
159 Teuchos::RCP< Teko::StaticRequestCallback<Teko::LinearOp> > callbackPCD_;
160#endif
161 // For FaCSI precondtioner
162 ThyraLinOpConstPtr_Type fsiLinOp_;
163 ThyraLinOpPtr_Type precFluid_;
164 ThyraLinOpPtr_Type precStruct_;
165 ThyraLinOpPtr_Type precGeo_;
166 MinPrecProblemPtr_Type probFluid_;
167 MinPrecProblemPtr_Type probSolid_;
168 MinPrecProblemPtr_Type probGeo_;
169 BCConstPtr_Type faCSIBCFactory_;
170
171 // For Stokes-type block diagonal and triangular precondtioner
172 ThyraLinOpPtr_Type precVelocity_;
173 ThyraLinOpPtr_Type precSchur_;
174 MinPrecProblemPtr_Type probVelocity_;
175 MinPrecProblemPtr_Type probSchur_;
176 // mutable MatrixPtr_Type pressureMassMatrix_;
177
178 // For LSC and PCD preconditioner
179 mutable ThyraLinOpConstPtr_Type velocityMassMatrix_; // LSC
180 mutable MatrixPtr_Type velocityMassMatrixMatrixPtr_; // LSC
181
182 mutable MatrixPtr_Type pressureLaplaceMatrixPtr_; // PCD
183 mutable ThyraLinOpConstPtr_Type pressureLaplace_; // PCD
184
185 mutable MatrixPtr_Type pressureMassMatrixPtr_; // PCD
186 mutable ThyraLinOpConstPtr_Type pressureMass_; // PCD
187
188 mutable MatrixPtr_Type pcdOperatorMatrixPtr_; // PCD
189 mutable ThyraLinOpConstPtr_Type pcdOperator_; // PCD
190
191 // Block multivector for pressure projection
192 mutable BlockMultiVectorPtr_Type pressureProjection_;
193
194 // For construction in the FEDDLib
195 MinPrecProblemPtr_Type probLaplace_;
196 MinPrecProblemPtr_Type probMass_;
197 MinPrecProblemPtr_Type probVMass_;
198 ThyraLinOpPtr_Type laplaceInverse_;
199 ThyraLinOpPtr_Type massMatrixInverse_;
200 ThyraLinOpPtr_Type massMatrixVInverse_;
201
202 ParameterListPtr_Type pListPhiExport_;
203#define PRECONDITIONER_TIMER
204#ifdef PRECONDITIONER_TIMER
205 TimePtr_Type preconditionerTimer_;
206#endif
207};
208}
209#endif
Definition Map_decl.hpp:30
Definition Mesh_decl.hpp:25
Definition MinPrecProblem_decl.hpp:27
void setPressureProjection(BlockMultiVectorPtr_Type pressureProjection) const
Setting pressure projection from specific prolem to be used in preconditioner.
Definition Preconditioner_def.hpp:175
BlockMultiVectorPtr_Type getPressureProjection()
Getting pressure projection used in preconditioner.
Definition Preconditioner_decl.hpp:147
Definition Problem_decl.hpp:42
Definition TimeProblem_decl.hpp:31
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36