v0.14.0
Public Member Functions | Public Attributes | List of all members
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

VectorDouble & vAls
 
MatrixDouble & diffVals
 
const bool checkGradients
 
FTensor::Index< 'i', SPACE_DIMi
 

Detailed Description

Examples
scalar_check_approximation.cpp.

Definition at line 98 of file scalar_check_approximation.cpp.

Constructor & Destructor Documentation

◆ OpValsDiffVals()

OpValsDiffVals::OpValsDiffVals ( VectorDouble &  vals,
MatrixDouble &  diff_vals,
bool  check_grads 
)
inline

Definition at line 102 of file scalar_check_approximation.cpp.

103  : DomainEleOp("FIELD1", OPROW), vAls(vals), diffVals(diff_vals),
104  checkGradients(check_grads) {}

Member Function Documentation

◆ doWork()

MoFEMErrorCode OpValsDiffVals::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
inline

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  }

Member Data Documentation

◆ checkGradients

const bool OpValsDiffVals::checkGradients

Definition at line 101 of file scalar_check_approximation.cpp.

◆ diffVals

MatrixDouble& OpValsDiffVals::diffVals

Definition at line 100 of file scalar_check_approximation.cpp.

◆ i

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

Definition at line 106 of file scalar_check_approximation.cpp.

◆ vAls

VectorDouble& OpValsDiffVals::vAls

Definition at line 99 of file scalar_check_approximation.cpp.


The documentation for this struct was generated from the following file:
SPACE_DIM
constexpr int SPACE_DIM
Definition: scalar_check_approximation.cpp:21
OpValsDiffVals::checkGradients
const bool checkGradients
Definition: scalar_check_approximation.cpp:101
DomainEleOp
DomainEle::UserDataOperator DomainEleOp
Definition: scalar_check_approximation.cpp:30
MoFEM::EntitiesFieldData::EntData::getDiffN
MatrixDouble & getDiffN(const FieldApproximationBase base)
get derivatives of base functions
Definition: EntitiesFieldData.hpp:1329
MoFEM::EntitiesFieldData::EntData::getFTensor0N
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
Definition: EntitiesFieldData.hpp:1502
convert.type
type
Definition: convert.py:64
MoFEM::getFTensor0FromVec
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Definition: Templates.hpp:135
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1214
v
const double v
phase velocity of light in medium (cm/ns)
Definition: initial_diffusion.cpp:40
MoFEM::EntitiesFieldData::EntData::getFTensor0FieldData
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0FieldData()
Resturn scalar files as a FTensor of rank 0.
Definition: EntitiesFieldData.cpp:506
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::EntitiesFieldData::EntData::getFTensor1DiffN
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
Definition: EntitiesFieldData.cpp:526
MoFEM::EntitiesFieldData::EntData::getN
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
Definition: EntitiesFieldData.hpp:1318
OpValsDiffVals::vAls
VectorDouble & vAls
Definition: scalar_check_approximation.cpp:99
sdf_hertz_2d_axisymm_plane.d
float d
Definition: sdf_hertz_2d_axisymm_plane.py:4
MOFEM_ATOM_TEST_INVALID
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
OpValsDiffVals::diffVals
MatrixDouble & diffVals
Definition: scalar_check_approximation.cpp:100
OpValsDiffVals::i
FTensor::Index< 'i', SPACE_DIM > i
Definition: scalar_check_approximation.cpp:106
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359