v0.14.0
Public Member Functions | Public Attributes | List of all members
Example::OpError< 1 > Struct Reference
Inheritance diagram for Example::OpError< 1 >:
[legend]
Collaboration diagram for Example::OpError< 1 >:
[legend]

Public Member Functions

 OpError (boost::shared_ptr< CommonData > &common_data_ptr)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 

Public Attributes

boost::shared_ptr< CommonDatacommonDataPtr
 

Detailed Description

Definition at line 86 of file approximaton.cpp.

Constructor & Destructor Documentation

◆ OpError()

Example::OpError< 1 >::OpError ( boost::shared_ptr< CommonData > &  common_data_ptr)
inline

Definition at line 88 of file approximaton.cpp.

89  : DomainEleOp(FIELD_NAME, OPROW), commonDataPtr(common_data_ptr) {}

Member Function Documentation

◆ doWork()

MoFEMErrorCode Example::OpError< 1 >::doWork ( int  side,
EntityType  type,
EntData data 
)
inline

Definition at line 90 of file approximaton.cpp.

90  {
92 
93  if (const size_t nb_dofs = data.getIndices().size()) {
94 
95  const int nb_integration_pts = getGaussPts().size2();
96  auto t_w = getFTensor0IntegrationWeight();
97  auto t_val = getFTensor0FromVec(*(commonDataPtr->approxVals));
98  auto t_coords = getFTensor1CoordsAtGaussPts();
99 
100  VectorDouble nf(nb_dofs, false);
101  nf.clear();
102 
104  const double volume = getMeasure();
105 
106  auto t_row_base = data.getFTensor0N();
107  double error = 0;
108  for (int gg = 0; gg != nb_integration_pts; ++gg) {
109 
110  const double alpha = t_w * volume;
111  double diff = t_val - Example::approxFunction(t_coords(0), t_coords(1),
112  t_coords(2));
113  error += alpha * pow(diff, 2);
114 
115  for (size_t r = 0; r != nb_dofs; ++r) {
116  nf[r] += alpha * t_row_base * diff;
117  ++t_row_base;
118  }
119 
120  ++t_w;
121  ++t_val;
122  ++t_coords;
123  }
124 
125  const int index = 0;
126  CHKERR VecSetValue(commonDataPtr->L2Vec, index, error, ADD_VALUES);
127  CHKERR VecSetValues(commonDataPtr->resVec, data, &nf[0], ADD_VALUES);
128  }
129 
131  }

Member Data Documentation

◆ commonDataPtr

boost::shared_ptr<CommonData> Example::OpError< 1 >::commonDataPtr

Definition at line 87 of file approximaton.cpp.


The documentation for this struct was generated from the following file:
Example::approxFunction
static ApproxFieldFunction< FIELD_DIM > approxFunction
Definition: approximaton.cpp:61
MoFEM::VecSetValues
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
Definition: EntitiesFieldData.hpp:1589
sdf.r
int r
Definition: sdf.py:8
MoFEM::EntitiesFieldData::EntData::getFTensor0N
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
Definition: EntitiesFieldData.hpp:1502
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
DomainEleOp
DomainEle::UserDataOperator DomainEleOp
Definition: approximaton.cpp:33
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
Example::OpError< 1 >::commonDataPtr
boost::shared_ptr< CommonData > commonDataPtr
Definition: approximaton.cpp:87
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index< 'i', 3 >
FIELD_NAME
constexpr char FIELD_NAME[]
Definition: approximaton.cpp:18
MoFEM::Types::VectorDouble
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
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