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