1#ifndef ASSEMBLEFE_LAPLACE_DEF_hpp
2#define ASSEMBLEFE_LAPLACE_DEF_hpp
16template <
class SC,
class LO,
class GO,
class NO>
18AssembleFE<SC,LO,GO,NO>(flag, nodesRefConfig, params,tuple)
31template <
class SC,
class LO,
class GO,
class NO>
35 int dofs = std::get<2>(this->diskTuple_->at(0));
36 int dofsElement = nodesElement*dofs;
37 SmallMatrixPtr_Type elementMatrix =Teuchos::rcp(
new SmallMatrix_Type( dofsElement));
39 assemblyLaplacian(elementMatrix);
41 this->jacobian_ = elementMatrix ;
51template <
class SC,
class LO,
class GO,
class NO>
52void AssembleFE_Laplace<SC,LO,GO,NO>::assemblyLaplacian(SmallMatrixPtr_Type &elementMatrix) {
54 int dim = this->getDim();
55 int numNodes= std::get<3>(this->diskTuple_->at(0));
56 std::string FEType = std::get<1>(this->diskTuple_->at(0));
57 int dofs = std::get<2>(this->diskTuple_->at(0));
59 vec3D_dbl_ptr_Type dPhi;
60 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
71 buildTransformation(B);
72 detB = B.computeInverse(Binv);
73 absDetB = std::fabs(detB);
75 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
76 applyBTinv( dPhi, dPhiTrans, Binv );
77 for (UN i=0; i < numNodes; i++) {
78 Teuchos::Array<SC> value( dPhiTrans[0].size(), 0. );
79 for (UN j=0; j < numNodes; j++) {
80 for (UN w=0; w<dPhiTrans.size(); w++) {
81 for (UN d=0; d<dim; d++){
82 value[j] += weights->at(w) * dPhiTrans[w][i][d] * dPhiTrans[w][j][d];
87 for (UN d=0; d<dofs; d++) {
88 (*elementMatrix)[i*dofs +d][j*dofs+d] = value[j];
103template <
class SC,
class LO,
class GO,
class NO>
108 int numNodes= std::get<3>(this->diskTuple_->at(0));
109 std::string FEType = std::get<1>(this->diskTuple_->at(0));
110 vec_dbl_Type elementVector(numNodes);
112 vec2D_dbl_ptr_Type phi;
113 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
124 this->buildTransformation(B);
125 detB = B.computeInverse(Binv);
126 absDetB = std::fabs(detB);
128 std::vector<double> paras0(1);
135 std::vector<double> valueFunc(dim);
136 SC* paras = &(paras0[0]);
138 this->rhsFunc_( &x, &valueFunc[0], paras );
140 for (UN i=0; i < phi->at(0).size(); i++) {
141 value = Teuchos::ScalarTraits<SC>::zero();
142 for (UN w=0; w<weights->size(); w++){
143 value += weights->at(w) * phi->at(w).at(i);
145 value *= absDetB *valueFunc[0];
146 elementVector[i] += value;
149 (*this->rhsVec_) = elementVector;
160template <
class SC,
class LO,
class GO,
class NO>
161void AssembleFE_Laplace<SC,LO,GO,NO>::buildTransformation(
SmallMatrix<SC>& B){
163 TEUCHOS_TEST_FOR_EXCEPTION( (B.size()<2 || B.size()>3), std::logic_error,
"Initialize SmallMatrix for transformation.");
166 for (UN j=0; j<B.size(); j++) {
168 for (UN i=0; i<B.size(); i++) {
169 B[i][j] = this->nodesRefConfig_.at(index).at(i) - this->nodesRefConfig_.at(index0).at(i);
183template <
class SC,
class LO,
class GO,
class NO>
184void AssembleFE_Laplace<SC,LO,GO,NO>::applyBTinv( vec3D_dbl_ptr_Type& dPhiIn,
185 vec3D_dbl_Type& dPhiOut,
187 UN dim = Binv.size();
188 for (UN w=0; w<dPhiIn->size(); w++){
189 for (UN i=0; i < dPhiIn->at(w).size(); i++) {
190 for (UN d1=0; d1<dim; d1++) {
191 for (UN d2=0; d2<dim; d2++) {
192 dPhiOut[w][i][d1] += dPhiIn->at(w).at(i).at(d2) * Binv[d2][d1];
void assembleJacobian() override
Assemble the element Jacobian matrix.
Definition AssembleFE_Laplace_def.hpp:32
void assembleRHS() override
Assemble the element right hand side vector.
Definition AssembleFE_Laplace_def.hpp:104
AssembleFE_Laplace(int flag, vec2D_dbl_Type nodesRefConfig, ParameterListPtr_Type parameters, tuple_disk_vec_ptr_Type tuple)
Constructor for AssembleFE_Laplace.
Definition AssembleFE_Laplace_def.hpp:17
int getDim()
Definition AssembleFE_def.hpp:135
AssembleFE(int flag, vec2D_dbl_Type nodesRefConfig, ParameterListPtr_Type parameters, tuple_disk_vec_ptr_Type tuple)
Definition AssembleFE_def.hpp:8
vec2D_dbl_Type nodesRefConfig_
Definition AssembleFE_decl.hpp:255
static UN determineDegree(UN dim, std::string FEType, VarType orderOfDerivative)
Determine polynomial degree of a finite element basis function or its gradient that is required to se...
Definition Helper.cpp:68
@ Deriv0
order 0, f(x)
Definition Helper.hpp:27
@ Deriv1
order 1, gradient(f(x))
Definition Helper.hpp:28
static int getPhi(vec2D_dbl_ptr_Type &Phi, vec_dbl_ptr_Type &weightsPhi, int dim, std::string FEType, int Degree, std::string FETypeQuadPoints="")
Get basisfunction phi per quadrature point.
Definition Helper.cpp:921
static int getDPhi(vec3D_dbl_ptr_Type &DPhi, vec_dbl_ptr_Type &weightsDPhi, int Dimension, std::string FEType, int Degree)
Full matrix representation of gradient of a basis function for each quadrature point.
Definition Helper.cpp:215
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