v0.15.0
Loading...
Searching...
No Matches
OpValsDiffVals Struct Reference
Inheritance diagram for OpValsDiffVals:
[legend]
Collaboration diagram for OpValsDiffVals:
[legend]

Public Member Functions

 OpValsDiffVals (VectorDouble &vals, MatrixDouble &diff_vals, bool check_grads)
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 

Public Attributes

VectorDoublevAls
 
MatrixDoublediffVals
 
const bool checkGradients
 
FTensor::Index< 'i', SPACE_DIMi
 

Detailed Description

Constructor & Destructor Documentation

◆ OpValsDiffVals()

OpValsDiffVals::OpValsDiffVals ( VectorDouble & vals,
MatrixDouble & diff_vals,
bool check_grads )
inline
Examples
scalar_check_approximation.cpp.

Definition at line 102 of file scalar_check_approximation.cpp.

103 : DomainEleOp("FIELD1", OPROW), vAls(vals), diffVals(diff_vals),
104 checkGradients(check_grads) {}
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.

Member Function Documentation

◆ doWork()

MoFEMErrorCode OpValsDiffVals::doWork ( int side,
EntityType type,
EntitiesFieldData::EntData & data )
inline
Examples
scalar_check_approximation.cpp.

Definition at line 108 of file scalar_check_approximation.cpp.

109 {
111 const int nb_gauss_pts = getGaussPts().size2();
112 if (type == MBVERTEX) {
113 vAls.resize(nb_gauss_pts, false);
114 diffVals.resize(SPACE_DIM, nb_gauss_pts, false);
115 vAls.clear();
116 diffVals.clear();
117 }
118
119 const int nb_dofs = data.getIndices().size();
120 if (nb_dofs) {
121
122 MOFEM_LOG("AT", Sev::noisy)
123 << "Type " << moab::CN::EntityTypeName(type) << " side " << side;
124 MOFEM_LOG("AT", Sev::noisy) << data.getN();
125 MOFEM_LOG("AT", Sev::noisy) << data.getDiffN();
126
127 auto t_vals = getFTensor0FromVec(vAls);
128 auto t_base_fun = data.getFTensor0N();
129 for (int gg = 0; gg != nb_gauss_pts; gg++) {
130 auto t_data = data.getFTensor0FieldData();
131 for (int bb = 0; bb != nb_dofs; bb++) {
132 t_vals += t_base_fun * t_data;
133 ++t_base_fun;
134 ++t_data;
135 }
136 const double v = t_vals;
137 if (!std::isnormal(v))
138 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID, "Not a number");
139 ++t_vals;
140 }
141
142 if (checkGradients) {
143 auto t_diff_vals = getFTensor1FromMat<SPACE_DIM>(diffVals);
144 auto t_diff_base_fun = data.getFTensor1DiffN<SPACE_DIM>();
145 for (int gg = 0; gg != nb_gauss_pts; gg++) {
146 auto t_data = data.getFTensor0FieldData();
147 for (int bb = 0; bb != nb_dofs; bb++) {
148 t_diff_vals(i) += t_diff_base_fun(i) * t_data;
149 ++t_diff_base_fun;
150 ++t_data;
151 }
152 for (int d = 0; d != SPACE_DIM; ++d)
153 if (!std::isnormal(t_diff_vals(d)))
154 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID, "Not a number");
155 ++t_diff_vals;
156 }
157 }
158 }
160 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MOFEM_LOG(channel, severity)
Log.
const double v
phase velocity of light in medium (cm/ns)
FTensor::Tensor1< FTensor::PackPtr< T *, S >, Tensor_Dim > getFTensor1FromMat(ublas::matrix< T, L, A > &data)
Get tensor rank 1 (vector) form data matrix.
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
constexpr int SPACE_DIM
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
MatrixDouble & getDiffN(const FieldApproximationBase base)
get derivatives of base functions
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0FieldData()
Resturn scalar files as a FTensor of rank 0.
const VectorInt & getIndices() const
Get global indices of dofs on entity.
FTensor::Index< 'i', SPACE_DIM > i

Member Data Documentation

◆ checkGradients

const bool OpValsDiffVals::checkGradients

◆ diffVals

MatrixDouble& OpValsDiffVals::diffVals

◆ i

FTensor::Index<'i', SPACE_DIM> OpValsDiffVals::i

◆ vAls

VectorDouble& OpValsDiffVals::vAls

The documentation for this struct was generated from the following file: