12 const int index, boost::shared_ptr<VectorDouble> diff_data_ptr,
13 boost::shared_ptr<Range> ent_ptr)
16 dataPtr(data_ptr), dataVec(data_vec), iNdex(index),
17 diffDataPtr(diff_data_ptr), entsPtr(ent_ptr) {
39 const auto nb_integration_points =
getGaussPts().size2();
47 double norm_on_element = 0.;
49 for (
int gg = 0; gg != nb_integration_points; gg++) {
51 norm_on_element += t_w * t_data * t_data;
58 norm_on_element *= vol;
68 const int index, boost::shared_ptr<MatrixDouble> diff_data_ptr,
69 boost::shared_ptr<Range> ent_ptr)
72 dataPtr(data_ptr), dataVec(data_vec), iNdex(index),
73 diffDataPtr(diff_data_ptr), entsPtr(ent_ptr) {
88 if (entsPtr->find(this->getFEEntityHandle()) == entsPtr->end())
93 if (dataPtr != diffDataPtr)
94 *diffDataPtr -= *dataPtr;
99 const auto nb_integration_points = getGaussPts().size2();
101 const double vol = getMeasure();
103 auto t_w = getFTensor0IntegrationWeight();
106 if (diffDataPtr->size2() != DIM)
107 THROW_MESSAGE(
"OpCalcNormL2Tensor1: wrong number of matrix columns");
109 auto t_data = getFTensor1FromPtr<DIM, DIM>(diffDataPtr->data().data());
111 double norm_on_element = 0.;
113 for (
int gg = 0; gg != nb_integration_points; ++gg) {
115 norm_on_element += t_w * (t_data(
i) * t_data(
i));
122 norm_on_element *= vol;
124 CHKERR VecSetValue(dataVec, iNdex, norm_on_element, ADD_VALUES);
129template <
int DIM_1,
int DIM_2>
132 const int index, boost::shared_ptr<MatrixDouble> diff_data_ptr,
133 boost::shared_ptr<Range> ent_ptr)
136 dataPtr(data_ptr), dataVec(data_vec), iNdex(index),
137 diffDataPtr(diff_data_ptr), entsPtr(ent_ptr) {
144template <
int DIM_1,
int DIM_2>
152 if (entsPtr->find(this->getFEEntityHandle()) == entsPtr->end())
157 if (dataPtr != diffDataPtr)
158 *diffDataPtr -= *dataPtr;
164 const auto nb_integration_points = getGaussPts().size2();
166 const double vol = getMeasure();
168 auto t_w = getFTensor0IntegrationWeight();
170 auto t_data = getFTensor2FromMat<DIM_1, DIM_2>(*diffDataPtr);
172 double norm_on_element = 0.;
174 for (
int gg = 0; gg != nb_integration_points; gg++) {
176 norm_on_element += t_w * (t_data(
i,
j) * t_data(
i,
j));
183 norm_on_element *= vol;
185 CHKERR VecSetValue(dataVec, iNdex, norm_on_element, ADD_VALUES);
198 if (this->entsPtr->find(this->getFEEntityHandle()) == this->entsPtr->end())
203 if (this->dataPtr != this->diffDataPtr)
204 *this->diffDataPtr -= *this->dataPtr;
210 const auto nb_integration_points = this->getGaussPts().size2();
212 const double vol = this->getMeasure();
214 auto t_w = this->getFTensor0IntegrationWeight();
216 auto t_data = getFTensor2SymmetricFromMat<DIM>(*this->diffDataPtr);
218 double norm_on_element = 0.;
220 for (
int gg = 0; gg != nb_integration_points; gg++) {
222 norm_on_element += t_w * (t_data(
i,
j) * t_data(
i,
j));
229 norm_on_element *= vol;
231 CHKERR VecSetValue(this->dataVec, this->iNdex, norm_on_element, ADD_VALUES);
237 boost::shared_ptr<VectorDouble> data_ptr,
ScalarFun scalar_function)
240 dataPtr(data_ptr), sFunc(scalar_function) {}
247 const int nb_integration_pts =
getGaussPts().size2();
249 dataPtr->resize(nb_integration_pts);
256 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
259 t_val =
sFunc(t_coords(0), t_coords(1), t_coords(2));
269template <
int TENS_DIM,
int FUNC_DIM>
271 boost::shared_ptr<MatrixDouble> data_ptr,
VectorFunc vector_function)
274 dataPtr(data_ptr), vFunc(vector_function) {}
276template <
int TENS_DIM,
int FUNC_DIM>
280 if (TENS_DIM > FUNC_DIM) {
282 "Output tensor dimension TENS_DIM (%d) is larger than FUNC_DIM "
290 const int nb_integration_pts = getGaussPts().size2();
293 auto get_values_at_pts =
295 *dataPtr, nb_integration_pts);
298 auto t_val = get_values_at_pts();
301 auto t_coords = getFTensor1CoordsAtGaussPts();
303 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
305 auto func_val = vFunc(t_coords(0), t_coords(1), t_coords(2));
307 auto t_func_val = getFTensor1FromArray<FUNC_DIM, FUNC_DIM>(func_val);
309 t_val(
i) = t_func_val(
i);
320template <
int TENS_DIM,
int FUNC_DIM>
322 boost::shared_ptr<MatrixDouble> data_ptr,
MatrixFunc matrix_function)
325 dataPtr(data_ptr), mFunc(matrix_function) {}
327template <
int TENS_DIM,
int FUNC_DIM>
331 if (TENS_DIM > FUNC_DIM) {
333 "Output tensor dimension TENS_DIM (%d) is larger than FUNC_DIM "
342 const int nb_integration_pts = getGaussPts().size2();
344 dataPtr->resize(TENS_DIM * TENS_DIM, nb_integration_pts);
346 auto t_val = getFTensor2FromMat<TENS_DIM, TENS_DIM>(*(dataPtr));
349 auto t_coords = getFTensor1CoordsAtGaussPts();
351 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
353 auto func_val = mFunc(t_coords(0), t_coords(1), t_coords(2));
356 getFTensor2FromArray<FUNC_DIM, FUNC_DIM, FUNC_DIM>(func_val, 0);
358 t_val(
i,
j) = t_func_val(
i,
j);
369template <
int TENS_DIM,
int FUNC_DIM>
374 if constexpr (TENS_DIM > FUNC_DIM) {
376 "Output tensor dimension TENS_DIM (%d) is larger than FUNC_DIM "
381 const auto nb_gauss_pts = this->getGaussPts().size2();
383 auto get_values_at_gauss_pts =
385 DL>::size(*this->dataPtr, nb_gauss_pts);
386 this->dataPtr->clear();
388 auto t_values_at_gauss_pts = get_values_at_gauss_pts();
389 auto t_coords = this->getFTensor1CoordsAtGaussPts();
393 for (
size_t gg = 0; gg != nb_gauss_pts; ++gg) {
394 auto values = this->mFunc(t_coords(0), t_coords(1), t_coords(2));
397 t_values_at_gauss_pts(
i,
j) = t_values(
i,
j);
398 ++t_values_at_gauss_pts;
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
decltype(GetFTensor2SymmetricFromMatImpl< Tensor_Dim, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor2SymmetricFromMatType
static auto getFTensor2SymmetricFromMat(M &data)
Get symmetric tensor rank 2 (matrix) form data matrix.
boost::function< MatrixDouble(const double, const double, const double)> MatrixFunc
boost::function< VectorDouble(const double, const double, const double)> VectorFunc
decltype(GetFTensor1FromMatImpl< Tensor_Dim, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor1FromMatType
static auto getFTensor0FromVec(V &data)
Get tensor rank 0 (scalar) form data vector.
Data on single entity (This is passed as argument to DataOperator::doWork)
auto getFTensor1CoordsAtGaussPts()
Get coordinates at integration points assuming linear geometry.
auto getFTensor0IntegrationWeight()
Get integration weights.
double getMeasure() const
get measure of element
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
structure to get information from mofem into EntitiesFieldData
boost::shared_ptr< VectorDouble > dataPtr
boost::shared_ptr< VectorDouble > diffDataPtr
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
calculate norm of scalar values at integration points
OpCalcNormL2Tensor0(boost::shared_ptr< VectorDouble > data_ptr, SmartPetscObj< Vec > data_vec, const int index, boost::shared_ptr< VectorDouble > diff_data_ptr=nullptr, boost::shared_ptr< Range > ent_ptr=nullptr)
SmartPetscObj< Vec > dataVec
boost::shared_ptr< Range > entsPtr
Get norm of input MatrixDouble for Tensor1.
boost::shared_ptr< MatrixDouble > diffDataPtr
OpCalcNormL2Tensor1(boost::shared_ptr< MatrixDouble > data_ptr, SmartPetscObj< Vec > data_vec, const int index, boost::shared_ptr< MatrixDouble > diff_data_ptr=nullptr, boost::shared_ptr< Range > ent_ptr=nullptr)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
calculate norm of vector values at integration points
boost::shared_ptr< MatrixDouble > dataPtr
Get norm of input MatrixDouble for symmetric Tensor2.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
calculate norm of symmetric tensor values at integration points
Get norm of input MatrixDouble for Tensor2.
OpCalcNormL2Tensor2(boost::shared_ptr< MatrixDouble > data_ptr, SmartPetscObj< Vec > data_vec, const int index, boost::shared_ptr< MatrixDouble > diff_data_ptr=nullptr, boost::shared_ptr< Range > ent_ptr=nullptr)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
calculate norm of tensor values at integration points
boost::shared_ptr< MatrixDouble > diffDataPtr
boost::shared_ptr< MatrixDouble > dataPtr
OpGetTensor0fromFunc(boost::shared_ptr< VectorDouble > data_ptr, ScalarFun scalar_function)
boost::shared_ptr< VectorDouble > dataPtr
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
calculate values of scalar function at integration points
Get values from vector function at integration points and save them to MatrixDouble for Tensor1.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
calculate values of vector function at integration points
OpGetTensor1fromFunc(boost::shared_ptr< MatrixDouble > data_ptr, VectorFunc vector_function)
Get values from matrix function in symmetric tensor storage at integration points and save them to Ma...
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
calculate values of matrix function at integration points
Get values from matrix function at integration points and save them to MatrixDouble for Tensor2.
OpGetTensor2fromFunc(boost::shared_ptr< MatrixDouble > data_ptr, MatrixFunc matrix_function)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
calculate values of matrix function at integration points
intrusive_ptr for managing petsc objects