v0.13.1
Loading...
Searching...
No Matches
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) {}
constexpr char FIELD_NAME[]
ElementsAndOps< FE_DIM >::DomainEleOp DomainEleOp
boost::shared_ptr< CommonData > commonDataPtr

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 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Definition: Templates.hpp:135
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
const double r
rate factor
FTensor::Index< 'i', 3 > i
static ApproxFieldFunction< FIELD_DIM > approxFunction
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
const VectorInt & getIndices() const
Get global indices of dofs on entity.

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: