Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
Problem_decl.hpp
1#ifndef PROBLEM_DECL_hpp
2#define PROBLEM_DECL_hpp
3
4#include "feddlib/problems/problems_config.h"
5#include "feddlib/core/FEDDCore.hpp"
6#include "feddlib/core/FE/FE.hpp"
7#include "feddlib/core/FE/Domain.hpp"
8#include "feddlib/core/General/BCBuilder.hpp"
9#include "feddlib/core/General/DefaultTypeDefs.hpp"
10#include "feddlib/problems/Solver/Preconditioner.hpp"
11#include "feddlib/core/LinearAlgebra/BlockMultiVector.hpp"
12#include "feddlib/core/LinearAlgebra/BlockMatrix.hpp"
13#include "feddlib/problems/Solver/LinearSolver.hpp"
14
15#include <Stratimikos_DefaultLinearSolverBuilder.hpp>
16#include <Thyra_PreconditionerBase.hpp>
17#include <Thyra_LinearOpBase_decl.hpp>
18
19#ifdef FEDD_HAVE_TEKO
20#include <Teko_StratimikosFactory.hpp>
21#endif
22
31
32
33namespace FEDD {
34template<class SC_, class LO_, class GO_, class NO_>
35class Preconditioner;
36
37template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
38class Problem {
39
40public:
41
42 typedef Domain<SC,LO,GO,NO> Domain_Type;
43 typedef Teuchos::RCP<const Domain_Type> DomainConstPtr_Type;
44 typedef std::vector<DomainConstPtr_Type> DomainConstPtr_vec_Type;
45
46 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
47 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
48
49 typedef typename Matrix_Type::Map_Type Map_Type;
50 typedef typename Matrix_Type::MapPtr_Type MapPtr_Type;
51 typedef typename Matrix_Type::MapConstPtr_Type MapConstPtr_Type;
52
53 typedef BlockMatrix<SC,LO,GO,NO> BlockMatrix_Type;
54 typedef Teuchos::RCP<BlockMatrix_Type> BlockMatrixPtr_Type;
55 typedef Teuchos::RCP<const BlockMatrix_Type> BlockMatrixConstPtr_Type;
56
57 typedef MultiVector<SC,LO,GO,NO> MultiVector_Type;
58 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
59 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
60
61 typedef BlockMultiVector<SC,LO,GO,NO> BlockMultiVector_Type;
62 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
63 typedef Teuchos::RCP<const BlockMultiVector_Type> BlockMultiVectorConstPtr_Type;
64
65 typedef Preconditioner<SC,LO,GO,NO> Preconditioner_Type;
66 typedef Teuchos::RCP<Preconditioner_Type> PreconditionerPtr_Type;
67 typedef Teuchos::RCP<const Preconditioner_Type> PreconditionerConstPtr_Type;
68
69 typedef BCBuilder<SC,LO,GO,NO> BC_Type;
70 typedef Teuchos::RCP<BC_Type> BCPtr_Type;
71 typedef Teuchos::RCP<const BC_Type> BCConstPtr_Type;
72
73 typedef FE<SC,LO,GO,NO> FEFac_Type;
74 typedef Teuchos::RCP<FEFac_Type> FEFacPtr_Type;
75 typedef Teuchos::RCP<const FEFac_Type> FEFacConstPtr_Type;
76
77 typedef Teuchos::ParameterList ParameterList_Type;
78 typedef Teuchos::RCP<ParameterList_Type> ParameterListPtr_Type;
79
80 typedef Teuchos::RCP<Stratimikos::DefaultLinearSolverBuilder > LinSolverBuilderPtr_Type;
81 typedef Teuchos::RCP<const Stratimikos::DefaultLinearSolverBuilder > LinSolverBuilderConstPtr_Type;
82
83 typedef Teuchos::Comm<int> Comm_Type;
84 typedef Teuchos::RCP<const Comm_Type> CommConstPtr_Type;
85
86 typedef Teuchos::ArrayRCP<GO> GOVecPtr;
87
88 typedef std::vector<std::string> string_vec_Type;
89
90 typedef Teuchos::RCP<Thyra::PreconditionerBase<SC> > ThyraPrecPtr_Type;
91 typedef Teuchos::RCP<Thyra::LinearOpBase<SC> > ThyraLinOpPtr_Type;
92
93 Problem(CommConstPtr_Type comm);
94
95 Problem(ParameterListPtr_Type &parameterList, CommConstPtr_Type comm);
96
97 virtual ~Problem() = default;
98
99 virtual void info() = 0;
100
101 void infoProblem();
102
103 void addVariable(const DomainConstPtr_Type &domain, std::string FEType, std::string name, int dofsPerNode);
104
110 void addRhsFunction(RhsFunc_Type func);
111
113 void addRhsFunction(RhsFunc_Type func,int i);
114
116 // void addRhsFunctionAndFlag(RhsFunc_Type func, int i, int flag);
117
118 RhsFunc_Type& getRhsFunction( int i );
119
120 virtual void assemble( std::string type ) const = 0;
121
122// virtual void assembleExternal( std::string type ) = 0;
123
124 //void reAssemble();
125
126 void assembleSourceTerm( double time = 0. ) const;
127
128 void assembleVolumeTerm( double time ) const;
129
130 void assembleSurfaceTerm( double time ) const;
131
132 bool hasSourceTerm() const;
133
134 int solve( BlockMultiVectorPtr_Type rhs = Teuchos::null );
135
136 void setupPreconditioner( std::string type="Monolithic" ) const;
137
138 void initializePreconditioner( std::string type="Monolithic" ) const;
139
140 void addBoundaries(const BCConstPtr_Type &bcFactory);
141
142 void setBoundaries(double time=.0) const;
143
144 void setBoundariesRHS(double time=.0) const;
145
146 void setAllDirichletZero( BlockMultiVectorPtr_Type rhs) const;
147
148 void setBoundariesSystem() const;
149
150 void initializeProblem(int nmbVectors=1);
151
152 void initializeVectors(int nmbVectors=1);
153
154 BlockMultiVectorPtr_Type getRhs();
155
156 BlockMultiVectorPtr_Type getRhs() const;
157
158 BlockMultiVectorPtr_Type getSolution();
159
160 BlockMatrixPtr_Type getSystem() const;
161
162 PreconditionerPtr_Type getPreconditioner();
163
164 PreconditionerConstPtr_Type getPreconditionerConst() const;
165
166 void setPreconditionerThyraFromLinOp( ThyraLinOpPtr_Type precLinOp );
167
168 void initializeSolverBuilder() const;
169
170 bool getVerbose() const;
171
172 FEFacConstPtr_Type getFEFactory();
173
174 BCConstPtr_Type getBCFactory();
175
176 DomainConstPtr_Type getDomain(int i) const;
177
178 DomainConstPtr_vec_Type getDomainVector() const{
179 return domainPtr_vec_;
180 };
181
182 std::string getFEType(int i) const;
183
184 std::string getVariableName(int i) const;
185
186 int getDofsPerNode(int i) const;
187
188 ParameterListPtr_Type getParameterList() const;
189
190 void addToRhs(BlockMultiVectorPtr_Type x) const;
191
192 BlockMultiVectorPtr_Type getSourceTerm();
193
194 void initSolutionWithVector(MultiVector_Type& mv);
195
196 LinSolverBuilderPtr_Type getLinearSolverBuilder() const{return linearSolverBuilder_;};
197
198 CommConstPtr_Type getComm() const{return comm_;};
199
200 virtual void getValuesOfInterest( vec_dbl_Type& values ) = 0 ;
201
202 virtual void computeValuesOfInterestAndExport() = 0;
203
204 void addParemeterRhs(double para){ parasSourceFunc_.push_back( para ); }
205
206
207 double calculateH1Norm(MultiVectorConstPtr_Type mv, int blockId1=0, int blockId2=0, int domainInd=0); // Function that calculates H1 Error in the 'mv * K * mv' sense, with K beeing the Stiffness Matrix
208
209 double calculateL2Norm(MultiVectorConstPtr_Type mv, int domainInd=0); // Function that calculates L2 Error in the 'mv * M * mv' sense, with M beeing the Mass Matrix
210
211
212 int dim_;
213 mutable CommConstPtr_Type comm_;
214 mutable BlockMatrixPtr_Type system_;
215 mutable BlockMultiVectorPtr_Type rhs_;
216 mutable BlockMultiVectorPtr_Type solution_;
217 PreconditionerPtr_Type preconditioner_;
218 LinSolverBuilderPtr_Type linearSolverBuilder_;
219
220 bool verbose_;
221
222 std::vector<RhsFunc_Type> rhsFuncVec_; // RHS functions of different blocks
223 vec_dbl_Type parasSourceFunc_; //
224
225protected:
226
227 mutable ParameterListPtr_Type parameterList_;
228 mutable DomainConstPtr_vec_Type domainPtr_vec_;
229 string_vec_Type domain_FEType_vec_;
230 string_vec_Type variableName_vec_;
231 mutable BCConstPtr_Type bcFactory_;
232
233 FEFacPtr_Type feFactory_;
234 std::vector<int> dofsPerNode_vec_;
235
237 BlockMultiVectorPtr_Type sourceTerm_; // BlockMV of all assembled RHS functions
238
239#ifdef FEDD_TIMER
240 TimePtr_Type solveProblemTimer_;
241 TimePtr_Type bcMatrixTimer_;
242 TimePtr_Type bcRHSTimer_;
243#endif
244
245
246
247};
248}
249#endif
This class is responsible for setting the boundary conditions into the system and rhs.
Definition BCBuilder_decl.hpp:45
Definition BlockMatrix_decl.hpp:23
Definition BlockMultiVector_decl.hpp:25
Definition Domain_decl.hpp:20
Definition FE_decl.hpp:48
Definition Matrix_decl.hpp:32
Definition MultiVector_decl.hpp:36
Definition Preconditioner_decl.hpp:41
void addRhsFunction(RhsFunc_Type func)
Definition Problem_def.hpp:141
void addRhsFunction(RhsFunc_Type func, int i)
Definition Problem_def.hpp:146
RhsFunc_Type & getRhsFunction(int i)
Definition Problem_def.hpp:176
BlockMultiVectorPtr_Type sourceTerm_
Definition Problem_decl.hpp:237
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5