1#ifndef ASSEMBLEFE_LAPLACE_DEF_hpp
2#define ASSEMBLEFE_LAPLACE_DEF_hpp
4#include "AssembleFE_Laplace_decl.hpp"
18template <
class SC,
class LO,
class GO,
class NO>
20AssembleFE<SC,LO,GO,NO>(flag, nodesRefConfig, params,tuple)
33template <
class SC,
class LO,
class GO,
class NO>
37 int dofs = std::get<2>(this->diskTuple_->at(0));
38 int dofsElement = nodesElement*dofs;
39 SmallMatrixPtr_Type elementMatrix =Teuchos::rcp(
new SmallMatrix_Type( dofsElement));
41 assemblyLaplacian(elementMatrix);
43 this->jacobian_ = elementMatrix ;
53template <
class SC,
class LO,
class GO,
class NO>
54void AssembleFE_Laplace<SC,LO,GO,NO>::assemblyLaplacian(SmallMatrixPtr_Type &elementMatrix) {
56 int dim = this->getDim();
57 int numNodes= std::get<3>(this->diskTuple_->at(0));
58 std::string FEType = std::get<1>(this->diskTuple_->at(0));
59 int dofs = std::get<2>(this->diskTuple_->at(0));
61 vec3D_dbl_ptr_Type dPhi;
62 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
73 buildTransformation(B);
74 detB = B.computeInverse(Binv);
75 absDetB = std::fabs(detB);
77 vec3D_dbl_Type dPhiTrans( dPhi->size(), vec2D_dbl_Type( dPhi->at(0).size(), vec_dbl_Type(dim,0.) ) );
78 applyBTinv( dPhi, dPhiTrans, Binv );
79 for (UN i=0; i < numNodes; i++) {
80 Teuchos::Array<SC> value( dPhiTrans[0].size(), 0. );
81 for (UN j=0; j < numNodes; j++) {
82 for (UN w=0; w<dPhiTrans.size(); w++) {
83 for (UN d=0; d<dim; d++){
84 value[j] += weights->at(w) * dPhiTrans[w][i][d] * dPhiTrans[w][j][d];
89 for (UN d=0; d<dofs; d++) {
90 (*elementMatrix)[i*dofs +d][j*dofs+d] = value[j];
105template <
class SC,
class LO,
class GO,
class NO>
110 int numNodes= std::get<3>(this->diskTuple_->at(0));
111 std::string FEType = std::get<1>(this->diskTuple_->at(0));
112 vec_dbl_Type elementVector(numNodes);
114 vec2D_dbl_ptr_Type phi;
115 vec_dbl_ptr_Type weights = Teuchos::rcp(
new vec_dbl_Type(0));
126 this->buildTransformation(B);
127 detB = B.computeInverse(Binv);
128 absDetB = std::fabs(detB);
130 std::vector<double> paras0(1);
137 std::vector<double> valueFunc(dim);
138 SC* paras = &(paras0[0]);
140 this->rhsFunc_( &x, &valueFunc[0], paras );
142 for (UN i=0; i < phi->at(0).size(); i++) {
143 value = Teuchos::ScalarTraits<SC>::zero();
144 for (UN w=0; w<weights->size(); w++){
145 value += weights->at(w) * phi->at(w).at(i);
147 value *= absDetB *valueFunc[0];
148 elementVector[i] += value;
151 (*this->rhsVec_) = elementVector;
162template <
class SC,
class LO,
class GO,
class NO>
163void AssembleFE_Laplace<SC,LO,GO,NO>::buildTransformation(
SmallMatrix<SC>& B){
165 TEUCHOS_TEST_FOR_EXCEPTION( (B.size()<2 || B.size()>3), std::logic_error,
"Initialize SmallMatrix for transformation.");
168 for (UN j=0; j<B.size(); j++) {
170 for (UN i=0; i<B.size(); i++) {
171 B[i][j] = this->nodesRefConfig_.at(index).at(i) - this->nodesRefConfig_.at(index0).at(i);
185template <
class SC,
class LO,
class GO,
class NO>
186void AssembleFE_Laplace<SC,LO,GO,NO>::applyBTinv( vec3D_dbl_ptr_Type& dPhiIn,
187 vec3D_dbl_Type& dPhiOut,
189 UN dim = Binv.size();
190 for (UN w=0; w<dPhiIn->size(); w++){
191 for (UN i=0; i < dPhiIn->at(w).size(); i++) {
192 for (UN d1=0; d1<dim; d1++) {
193 for (UN d2=0; d2<dim; d2++) {
194 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:34
void assembleRHS() override
Assemble the element right hand side vector.
Definition AssembleFE_Laplace_def.hpp:106
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:19
int getDim()
Definition AssembleFE_def.hpp:137
AssembleFE(int flag, vec2D_dbl_Type nodesRefConfig, ParameterListPtr_Type parameters, tuple_disk_vec_ptr_Type tuple)
Definition AssembleFE_def.hpp:10
vec2D_dbl_Type nodesRefConfig_
Definition AssembleFE_decl.hpp:252
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:604
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:22
Adaptive Mesh Refinement.
Definition AdaptiveMeshRefinement.cpp:5