v0.15.0
Loading...
Searching...
No Matches
AtomTest::OpError< 1 > Struct Reference
Inheritance diagram for AtomTest::OpError< 1 >:
[legend]
Collaboration diagram for AtomTest::OpError< 1 >:
[legend]

Public Member Functions

 OpError (boost::shared_ptr< CommonData > &common_data_ptr)
 
MoFEMErrorCode doWork (int side, EntityType type, EntData &data)
 
 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 88 of file child_and_parent.cpp.

Constructor & Destructor Documentation

◆ OpError() [1/2]

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

Definition at line 90 of file child_and_parent.cpp.

91 : DomainEleOp(FIELD_NAME, OPROW), commonDataPtr(common_data_ptr) {}
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
constexpr char FIELD_NAME[]
boost::shared_ptr< CommonData > commonDataPtr

◆ OpError() [2/2]

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

Definition at line 226 of file hanging_node_approx.cpp.

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

Member Function Documentation

◆ doWork() [1/2]

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

Definition at line 92 of file child_and_parent.cpp.

92 {
94
95 if (const size_t nb_dofs = data.getIndices().size()) {
96
97 const int nb_integration_pts = getGaussPts().size2();
98 auto t_w = getFTensor0IntegrationWeight();
99 auto t_val = getFTensor0FromVec(*(commonDataPtr->approxVals));
100 auto t_coords = getFTensor1CoordsAtGaussPts();
101
102 VectorDouble nf(nb_dofs, false);
103 nf.clear();
104
105 FTensor::Index<'i', 3> i;
106 const double volume = getMeasure();
107
108 auto t_row_base = data.getFTensor0N();
109 double error = 0;
110 for (int gg = 0; gg != nb_integration_pts; ++gg) {
111
112 const double alpha = t_w * volume;
113 double diff = t_val - AtomTest::approxFunction(t_coords(0), t_coords(1),
114 t_coords(2));
115 error += alpha * pow(diff, 2);
116
117 for (size_t r = 0; r != nb_dofs; ++r) {
118 nf[r] += alpha * t_row_base * diff;
119 ++t_row_base;
120 }
121
122 ++t_w;
123 ++t_val;
124 ++t_coords;
125 }
126
127 const int index = 0;
128 CHKERR VecSetValue(commonDataPtr->L2Vec, index, error, ADD_VALUES);
129 CHKERR VecSetValues(commonDataPtr->resVec, data, &nf[0], ADD_VALUES);
130 }
131
133 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
int r
Definition sdf.py:8
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.

◆ doWork() [2/2]

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

Definition at line 228 of file hanging_node_approx.cpp.

228 {
230
231 if (const size_t nb_dofs = data.getIndices().size()) {
232
234
235 const int nb_integration_pts = getGaussPts().size2();
236 auto t_w = getFTensor0IntegrationWeight();
237 auto t_val = getFTensor0FromVec(*(commonDataPtr->approxVals));
238 auto t_grad_val =
240 auto t_coords = getFTensor1CoordsAtGaussPts();
241
242 VectorDouble nf(nb_dofs, false);
243 nf.clear();
244
245 const double volume = getMeasure();
246
247 auto t_row_base = data.getFTensor0N();
248 double error = 0;
249 for (int gg = 0; gg != nb_integration_pts; ++gg) {
250
251 const double alpha = t_w * volume;
252 double diff = t_val - AtomTest::approxFunction(t_coords(0), t_coords(1),
253 t_coords(2));
254
255 auto t_grad_diff =
256 AtomTest::divApproxFunction(t_coords(0), t_coords(1), t_coords(2));
257 t_grad_diff(i) -= t_grad_val(i);
258
259 error += alpha * (pow(diff, 2) + t_grad_diff(i) * t_grad_diff(i));
260
261 for (size_t r = 0; r != nb_dofs; ++r) {
262 nf[r] += alpha * t_row_base * diff;
263 ++t_row_base;
264 }
265
266 ++t_w;
267 ++t_val;
268 ++t_grad_val;
269 ++t_coords;
270 }
271
272 const int index = 0;
273 CHKERR VecSetValue(commonDataPtr->L2Vec, index, error, ADD_VALUES);
274 CHKERR VecSetValues(commonDataPtr->resVec, data, &nf[0], ADD_VALUES);
275 }
276
278 }
constexpr int SPACE_DIM
FTensor::Tensor1< FTensor::PackPtr< T *, S >, Tensor_Dim > getFTensor1FromMat(ublas::matrix< T, L, A > &data)
Get tensor rank 1 (vector) form data matrix.
static ApproxFieldFunctionDerivative< FIELD_DIM > divApproxFunction

Member Data Documentation

◆ commonDataPtr

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

Definition at line 89 of file child_and_parent.cpp.


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