Finite Element Domain Decomposition Library
FEDDLib
Loading...
Searching...
No Matches
FE_ElementAssembly_decl.hpp
1#ifndef FE_ELEMENTASSEMBLY_DECL_hpp
2#define FE_ELEMENTASSEMBLY_DECL_hpp
3
4
5#include "feddlib/core/FEDDCore.hpp"
6#include "feddlib/core/General/SmallMatrix.hpp"
7#include "feddlib/core/General/DefaultTypeDefs.hpp"
8#include "feddlib/core/LinearAlgebra/Matrix.hpp"
9#include "feddlib/core/LinearAlgebra/MultiVector.hpp"
10#include "feddlib/core/LinearAlgebra/BlockMatrix.hpp"
11#include "Domain.hpp"
12#include "Helper.hpp"
13#include "sms.hpp"
14#include "feddlib/core/AceFemAssembly/AssembleFE.hpp"
15#include "feddlib/core/AceFemAssembly/specific/AssembleFE_SCI_SMC_Active_Growth_Reorientation.hpp"
16#include "feddlib/core/AceFemAssembly/specific/AssembleFENavierStokes.hpp"
17
18#include "feddlib/core/AceFemAssembly/AssembleFEFactory.hpp"
19
20#include <Teuchos_Array.hpp>
21#include <Teuchos_BLAS.hpp>
22
23
32
33namespace FEDD {
34
35
36template <class SC = default_sc, class LO = default_lo, class GO = default_go, class NO = default_no>
37class FE_ElementAssembly {
38 public:
39
40 typedef Domain<SC,LO,GO,NO> Domain_Type;
41 typedef Teuchos::RCP<Domain_Type> DomainPtr_Type;
42 typedef Teuchos::RCP<const Domain_Type> DomainConstPtr_Type;
43 typedef std::vector<DomainConstPtr_Type> DomainConstPtr_vec_Type;
44
45 typedef Teuchos::RCP<Mesh<SC,LO,GO,NO> > MeshPtr_Type;
46 typedef MeshUnstructured<SC,LO,GO,NO> MeshUnstr_Type;
47 typedef Teuchos::RCP<MeshUnstr_Type> MeshUnstrPtr_Type;
48
49 typedef Elements Elements_Type;
50 typedef Teuchos::RCP<Elements_Type> ElementsPtr_Type;
51 typedef Teuchos::RCP<const Elements_Type> ElementsConstPtr_Type;
52
53 typedef Matrix<SC,LO,GO,NO> Matrix_Type;
54 typedef Teuchos::RCP<Matrix_Type> MatrixPtr_Type;
55
56 typedef typename Matrix_Type::MapPtr_Type MapPtr_Type;
57 typedef typename Matrix_Type::MapConstPtr_Type MapConstPtr_Type;
58
59 typedef MultiVector<SC,LO,GO,NO> MultiVector_Type;
60 typedef Teuchos::RCP<MultiVector_Type> MultiVectorPtr_Type;
61 typedef Teuchos::RCP<const MultiVector_Type> MultiVectorConstPtr_Type;
62
63 typedef std::vector<GO> vec_GO_Type;
64 typedef std::vector<vec_GO_Type> vec2D_GO_Type;
65 typedef std::vector<vec2D_GO_Type> vec3D_GO_Type;
66 typedef Teuchos::RCP<vec3D_GO_Type> vec3D_GO_ptr_Type;
67
68 typedef AssembleFE<SC,LO,GO,NO> AssembleFE_Type;
69 typedef Teuchos::RCP<AssembleFE_Type> AssembleFEPtr_Type;
70
71 typedef AssembleFENavierStokes<SC,LO,GO,NO> AssembleFENavierStokes_Type;
72 typedef Teuchos::RCP<AssembleFENavierStokes_Type> AssembleFENavierStokesPtr_Type;
73
74 typedef AssembleFEGeneralizedNewtonian<SC,LO,GO,NO> AssembleFEGeneralizedNewtonian_Type;
75 typedef Teuchos::RCP<AssembleFEGeneralizedNewtonian_Type> AssembleFEGeneralizedNewtonianPtr_Type;
76
77 typedef AssembleFE_SCI_SMC_Active_Growth_Reorientation<SC,LO,GO,NO> AssembleFE_SCI_SMC_Active_Growth_Reorientation_Type;
78 typedef Teuchos::RCP<AssembleFE_SCI_SMC_Active_Growth_Reorientation_Type> AssembleFE_SCI_SMC_Active_Growth_Reorientation_Ptr_Type;
79
80 typedef std::vector<AssembleFEPtr_Type> AssembleFEPtr_vec_Type;
81
82 typedef BlockMatrix<SC,LO,GO,NO> BlockMatrix_Type ;
83 typedef Teuchos::RCP<BlockMatrix_Type> BlockMatrixPtr_Type;
84
85 typedef BlockMultiVector<SC,LO,GO,NO> BlockMultiVector_Type ;
86 typedef Teuchos::RCP<BlockMultiVector_Type> BlockMultiVectorPtr_Type;
87
88 typedef SmallMatrix<SC> SmallMatrix_Type;
89 typedef Teuchos::RCP<SmallMatrix_Type> SmallMatrixPtr_Type;
90
91 /* ###################################################################### */
92
93 FE_ElementAssembly(bool saveAssembly=false);
94
95 void addFE(DomainConstPtr_Type domain);
96
97 void doSetZeros(double eps = 10*Teuchos::ScalarTraits<SC>::eps());
98
99 void assemblyEmptyMatrix(MatrixPtr_Type &A);
100
102 int dim, std::string FEType, int degree, MultiVectorPtr_Type u_rep,
103 BlockMatrixPtr_Type &A, BlockMultiVectorPtr_Type &resVec,
104 ParameterListPtr_Type params, std::string assembleMode,
105 bool callFillComplete = true, int FELocExternal = -1);
106
107
108 void assemblyNavierStokes(int dim,
109 std::string FETypeVelocity,
110 std::string FETypePressure,
111 int degree,
112 int dofsVelocity,
113 int dofsPressure,
114 MultiVectorPtr_Type u_rep,
115 MultiVectorPtr_Type p_rep,
116 BlockMatrixPtr_Type &A,
117 BlockMultiVectorPtr_Type &resVec,
118 SmallMatrix_Type coeff,
119 ParameterListPtr_Type params,
120 bool reAssemble,
121 std::string assembleMode,
122 bool callFillComplete = true,
123 int FELocExternal=-1);
124
125 void assemblyLaplaceAssFE(int dim,
126 std::string FEType,
127 int degree,
128 int dofs,
129 BlockMatrixPtr_Type &A,
130 bool callFillComplete,
131 int FELocExternal=-1);
132
133 void assemblyAceDeformDiffu(int dim,
134 std::string FETypeChem,
135 std::string FETypeSolid,
136 int degree,
137 int dofsChem,
138 int dofsSolid,
139 MultiVectorPtr_Type c_rep,
140 MultiVectorPtr_Type d_rep,
141 BlockMatrixPtr_Type &A,
142 BlockMultiVectorPtr_Type &resVec,
143 ParameterListPtr_Type params,
144 std::string assembleMode,
145 bool callFillComplete = true,
146 int FELocExternal=-1);
147
148 void assemblyAceDeformDiffuBlock(int dim,
149 std::string FETypeChem,
150 std::string FETypeSolid,
151 int degree,
152 int dofsChem,
153 int dofsSolid,
154 MultiVectorPtr_Type c_rep,
155 MultiVectorPtr_Type d_rep,
156 BlockMatrixPtr_Type &A,
157 int blockRow,
158 int blockCol,
159 BlockMultiVectorPtr_Type &resVec,
160 int block,
161 ParameterListPtr_Type params,
162 std::string assembleMode,
163 bool callFillComplete = true,
164 int FELocExternal=-1);
165
166 void advanceInTimeAssemblyFEElements(double dt ,MultiVectorPtr_Type d_rep , MultiVectorPtr_Type c_rep)
167 {
168 //UN FElocChem = 1; //checkFE(dim,FETypeChem); // Checks for different domains which belongs to a certain fetype
169 UN FElocSolid = 0; //checkFE(dim,FETypeSolid); // Checks for different domains which belongs to a certain fetype
170
171 //ElementsPtr_Type elementsChem= domainVec_.at(FElocChem)->getElementsC();
172
173 ElementsPtr_Type elementsSolid = domainVec_.at(FElocSolid)->getElementsC();
174
175 vec_dbl_Type solution_c;
176 vec_dbl_Type solution_d;
177 for (UN T=0; T<assemblyFEElements_.size(); T++) {
178 vec_dbl_Type solution(0);
179
180 solution_c = getSolution(elementsSolid->getElement(T).getVectorNodeList(), c_rep,1);
181 solution_d = getSolution(elementsSolid->getElement(T).getVectorNodeList(), d_rep,3);
182 // First Solid, then Chemistry
183 solution.insert( solution.end(), solution_d.begin(), solution_d.end() );
184 solution.insert( solution.end(), solution_c.begin(), solution_c.end() );
185
186 assemblyFEElements_[T]->updateSolution(solution);
187
188 assemblyFEElements_[T]->advanceInTime(dt);
189 }
190
191 }
192
193 void assemblyLinearElasticity(int dim,
194 std::string FEType,
195 int degree,
196 int dofs,
197 MultiVectorPtr_Type d_rep,
198 BlockMatrixPtr_Type &A,
199 BlockMultiVectorPtr_Type &resVec,
200 ParameterListPtr_Type params,
201 bool reAssemble,
202 std::string assembleMode,
203 bool callFillComplete=true,
204 int FELocExternal=-1);
205
206 void assemblyNonLinearElasticity(int dim,
207 std::string FEType,
208 int degree,
209 int dofs,
210 MultiVectorPtr_Type d_rep,
211 BlockMatrixPtr_Type &A,
212 BlockMultiVectorPtr_Type &resVec,
213 ParameterListPtr_Type params,
214 bool callFillComplete=true,
215 int FELocExternal=-1);
216
217 void assemblyNonLinearElasticity(int dim,
218 std::string FEType,
219 int degree,
220 int dofs,
221 MultiVectorPtr_Type d_rep,
222 BlockMatrixPtr_Type &A,
223 BlockMultiVectorPtr_Type &resVec,
224 ParameterListPtr_Type params,
225 DomainConstPtr_Type domain,
226 MultiVectorPtr_Type eModVec,
227 bool callFillComplete = true,
228 int FELocExternal=-1);
229
230
231 /* Given a converged velocity solution this function
232 computes the averaged viscosity estimate in each cell at the center of mass
233 - CM stands for center of mass so the values at the node are averaged to obtain one value
234 */
235 void computeSteadyViscosityFE_CM(int dim,
236 std::string FETypeVelocity,
237 std::string FETypePressure,
238 int dofsVelocity,
239 int dofsPressure,
240 MultiVectorPtr_Type u_rep,
241 MultiVectorPtr_Type p_rep,
242 ParameterListPtr_Type params);
243
244 // Change for all assembleFEElements the linearization type to the specified ones
245 void changeLinearizationFE(std::string linearization);
246
247 // Write prostprocessing output fields like e.g. the viscosity based on velocity, pressure .. solution
248 // inside this BMV -> For visualization or postprocessing
249 BlockMultiVectorPtr_Type const_output_fields;
250
251 DomainConstPtr_vec_Type domainVec_;
252
253
254/* ----------------------------------------------------------------------------------------*/
255protected:
256 // Protected attributes/ functions such that derived FE classes can access them
257 bool setZeros_;
258 SC myeps_;
259 bool saveAssembly_;
260
261 int checkFE(int Dimension,
262 std::string FEType);
263
264 vec2D_dbl_Type getCoordinates(vec_LO_Type localIDs, vec2D_dbl_ptr_Type points);
265 vec_dbl_Type getSolution(vec_LO_Type localIDs, MultiVectorPtr_Type u_rep, int dofsVelocity);
266
267
268/* ----------------------------------------------------------------------------------------*/
269private:
270 // Functions to add element contributions to global system matrices/ vectors
271 void addFeBlockMatrix(BlockMatrixPtr_Type &A, SmallMatrixPtr_Type elementMatrix, FiniteElement element1,FiniteElement element2, MapConstPtr_Type mapFirstColumn,MapConstPtr_Type mapSecondColumn, tuple_disk_vec_ptr_Type problemDisk);
272
273 void addFeBlock(BlockMatrixPtr_Type &A, SmallMatrixPtr_Type elementMatrix, FiniteElement element, MapConstPtr_Type mapFirstRow, int row, int column, tuple_disk_vec_ptr_Type problemDisk);
274
275 void initAssembleFEElements(std::string elementType, tuple_disk_vec_ptr_Type problemDisk, ElementsPtr_Type elements, ParameterListPtr_Type params, vec2D_dbl_ptr_Type pointsRep, MapConstPtr_Type elementMap);
276
277 void addFeBlockMv(BlockMultiVectorPtr_Type &res, vec_dbl_ptr_Type rhsVec, FiniteElement elementBlock1,FiniteElement elementBlock2, int dofs1, int dofs2 );
278
279 void addFeBlockMv(BlockMultiVectorPtr_Type &res, vec_dbl_ptr_Type rhsVec, FiniteElement elementBlock, int dofs);
280
281
282 AssembleFEPtr_vec_Type assemblyFEElements_;
283
284
285};
286}
287#endif
Definition AssembleFEGeneralizedNewtonian_decl.hpp:21
Definition AssembleFENavierStokes_decl.hpp:13
Definition AssembleFE_SCI_SMC_Active_Growth_Reorientation_decl.hpp:29
This abstract class defining the interface for any type of element assembly rountines in the FEDDLib.
Definition AssembleFE_decl.hpp:61
Definition BlockMatrix_decl.hpp:25
Definition BlockMultiVector_decl.hpp:25
Definition Domain_decl.hpp:20
Definition Elements.hpp:23
vec2D_dbl_Type getCoordinates(vec_LO_Type localIDs, vec2D_dbl_ptr_Type points)
Returns coordinates of local node ids.
Definition FE_ElementAssembly_def.hpp:1383
int checkFE(int Dimension, std::string FEType)
Checks which domain corresponds to certain FE Type and dimension.
Definition FE_ElementAssembly_def.hpp:1608
void computeSteadyViscosityFE_CM(int dim, std::string FETypeVelocity, std::string FETypePressure, int dofsVelocity, int dofsPressure, MultiVectorPtr_Type u_rep, MultiVectorPtr_Type p_rep, ParameterListPtr_Type params)
Postprocessing: Using a converged velocity solution -> compute averaged viscosity inside an element a...
Definition FE_ElementAssembly_def.hpp:1214
void changeLinearizationFE(std::string linearization)
Method to loop over all assembleFESpecific elements and set the defined linearization.
Definition FE_ElementAssembly_def.hpp:1194
vec_dbl_Type getSolution(vec_LO_Type localIDs, MultiVectorPtr_Type u_rep, int dofsVelocity)
Returns entries of u of element.
Definition FE_ElementAssembly_def.hpp:1404
void assemblyNonLinearElasticity(int dim, std::string FEType, int degree, int dofs, MultiVectorPtr_Type d_rep, BlockMatrixPtr_Type &A, BlockMultiVectorPtr_Type &resVec, ParameterListPtr_Type params, bool callFillComplete=true, int FELocExternal=-1)
Assembly of Jacobian for nonlinear Elasticity.
Definition FE_ElementAssembly_def.hpp:398
void assemblyNonlinearLaplace(int dim, std::string FEType, int degree, MultiVectorPtr_Type u_rep, BlockMatrixPtr_Type &A, BlockMultiVectorPtr_Type &resVec, ParameterListPtr_Type params, std::string assembleMode, bool callFillComplete=true, int FELocExternal=-1)
Assembly of Jacobian for nonlinear Laplace example.
Definition FE_ElementAssembly_def.hpp:1492
void assemblyLinearElasticity(int dim, std::string FEType, int degree, int dofs, MultiVectorPtr_Type d_rep, BlockMatrixPtr_Type &A, BlockMultiVectorPtr_Type &resVec, ParameterListPtr_Type params, bool reAssemble, std::string assembleMode, bool callFillComplete=true, int FELocExternal=-1)
Assembly of Jacobian.
Definition FE_ElementAssembly_def.hpp:311
void assemblyAceDeformDiffuBlock(int dim, std::string FETypeChem, std::string FETypeSolid, int degree, int dofsChem, int dofsSolid, MultiVectorPtr_Type c_rep, MultiVectorPtr_Type d_rep, BlockMatrixPtr_Type &A, int blockRow, int blockCol, BlockMultiVectorPtr_Type &resVec, int block, ParameterListPtr_Type params, std::string assembleMode, bool callFillComplete=true, int FELocExternal=-1)
Definition FE_ElementAssembly_def.hpp:770
void assemblyLaplaceAssFE(int dim, std::string FEType, int degree, int dofs, BlockMatrixPtr_Type &A, bool callFillComplete, int FELocExternal=-1)
Assembly of constant stiffness matix for laplacian operator .
Definition FE_ElementAssembly_def.hpp:1436
void assemblyNavierStokes(int dim, std::string FETypeVelocity, std::string FETypePressure, int degree, int dofsVelocity, int dofsPressure, MultiVectorPtr_Type u_rep, MultiVectorPtr_Type p_rep, BlockMatrixPtr_Type &A, BlockMultiVectorPtr_Type &resVec, SmallMatrix_Type coeff, ParameterListPtr_Type params, bool reAssemble, std::string assembleMode, bool callFillComplete=true, int FELocExternal=-1)
Assembly of Jacobian for NavierStokes.
Definition FE_ElementAssembly_def.hpp:1026
void assemblyAceDeformDiffu(int dim, std::string FETypeChem, std::string FETypeSolid, int degree, int dofsChem, int dofsSolid, MultiVectorPtr_Type c_rep, MultiVectorPtr_Type d_rep, BlockMatrixPtr_Type &A, BlockMultiVectorPtr_Type &resVec, ParameterListPtr_Type params, std::string assembleMode, bool callFillComplete=true, int FELocExternal=-1)
Definition FE_ElementAssembly_def.hpp:592
Definition FiniteElement.hpp:17
Definition Matrix_decl.hpp:30
Definition MeshUnstructured_decl.hpp:33
Definition MultiVector_decl.hpp:61
This class represents a templated small Matrix of type T. Primarily created for 2x2 and 3x3 matrices....
Definition SmallMatrix.hpp:20
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement_decl.hpp:36