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

◆ 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 
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  }

◆ 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 =
239  getFTensor1FromMat<SPACE_DIM>(*(commonDataPtr->divApproxVals));
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  }

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:
FIELD_NAME
constexpr char FIELD_NAME[]
Definition: child_and_parent.cpp:14
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
AtomTest::OpError< 1 >::commonDataPtr
boost::shared_ptr< CommonData > commonDataPtr
Definition: child_and_parent.cpp:89
DomainEleOp
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
Definition: child_and_parent.cpp:36
DomainEleOp
DomainEle::UserDataOperator DomainEleOp
Definition: hanging_node_approx.cpp:26
MoFEM::getFTensor0FromVec
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Definition: Templates.hpp:135
AtomTest::divApproxFunction
static ApproxFieldFunctionDerivative< FIELD_DIM > divApproxFunction
Definition: hanging_node_approx.cpp:189
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1214
AtomTest::approxFunction
static ApproxFieldFunction< FIELD_DIM > approxFunction
Definition: child_and_parent.cpp:67
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index< 'i', 3 >
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
FIELD_NAME
constexpr char FIELD_NAME[]
Definition: hanging_node_approx.cpp:14