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