v0.14.0
Public Member Functions | Public Attributes | List of all members
MoFEM::OpGetDataAndGradient< RANK, DIM > Struct Template Reference

Get field values and gradients at Gauss points. More...

#include <src/finite_elements/DataOperators.hpp>

Inheritance diagram for MoFEM::OpGetDataAndGradient< RANK, DIM >:
[legend]
Collaboration diagram for MoFEM::OpGetDataAndGradient< RANK, DIM >:
[legend]

Public Member Functions

 OpGetDataAndGradient (MatrixDouble &data_at_gauss_pt, MatrixDouble &data_grad_at_gauss_pt)
 
template<int R>
FTensor::Tensor1< double *, RgetValAtGaussPtsTensor (MatrixDouble &data)
 
template<int R, int D>
FTensor::Tensor2< double *, R, DgetGradAtGaussPtsTensor (MatrixDouble &data)
 
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, EntitiesFieldData::EntData &data)
 Calculate gradient and values at integration points. More...
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
FTensor::Tensor1< double *, 3 > getValAtGaussPtsTensor (MatrixDouble &data)
 Specialization for field with 3 coefficients in 3 dimension. More...
 
FTensor::Tensor2< double *, 3, 3 > getGradAtGaussPtsTensor (MatrixDouble &data)
 Specialization for field with 3 coefficients in 3 dimension. More...
 
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, EntitiesFieldData::EntData &data)
 Specialization for field with 3 coefficients in 3 dimension. More...
 
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, EntitiesFieldData::EntData &data)
 Specialization for field with for scalar field in 3 dimension. More...
 
FTensor::Tensor1< double *, 3 > getValAtGaussPtsTensor (MatrixDouble &data)
 
FTensor::Tensor2< double *, 3, 3 > getGradAtGaussPtsTensor (MatrixDouble &data)
 
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, EntitiesFieldData::EntData &data)
 
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, EntitiesFieldData::EntData &data)
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side. More...
 
virtual MoFEMErrorCode opLhs (EntitiesFieldData &row_data, EntitiesFieldData &col_data)
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not. More...
 
void setSymm ()
 set if operator is executed taking in account symmetry More...
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem More...
 

Public Attributes

MatrixDoubledataAtGaussPts
 
MatrixDoubledataGradAtGaussPts
 
- Public Attributes inherited from MoFEM::DataOperator
DoWorkLhsHookFunType doWorkLhsHook
 
DoWorkRhsHookFunType doWorkRhsHook
 
bool sYmm
 If true assume that matrix is symmetric structure. More...
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity. More...
 
booldoVertices
 \deprectaed If false skip vertices More...
 
booldoEdges
 \deprectaed If false skip edges More...
 
booldoQuads
 \deprectaed More...
 
booldoTris
 \deprectaed More...
 
booldoTets
 \deprectaed More...
 
booldoPrisms
 \deprectaed More...
 

Additional Inherited Members

- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)>
 
using DoWorkRhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int side, EntityType type, EntitiesFieldData::EntData &data)>
 

Detailed Description

template<int RANK, int DIM>
struct MoFEM::OpGetDataAndGradient< RANK, DIM >

Get field values and gradients at Gauss points.

Definition at line 240 of file DataOperators.hpp.

Constructor & Destructor Documentation

◆ OpGetDataAndGradient()

template<int RANK, int DIM>
MoFEM::OpGetDataAndGradient< RANK, DIM >::OpGetDataAndGradient ( MatrixDouble data_at_gauss_pt,
MatrixDouble data_grad_at_gauss_pt 
)
inline

Definition at line 245 of file DataOperators.hpp.

247  : dataAtGaussPts(data_at_gauss_pt),
248  dataGradAtGaussPts(data_grad_at_gauss_pt) {}

Member Function Documentation

◆ calculateValAndGrad() [1/5]

template<int RANK, int DIM>
MoFEMErrorCode MoFEM::OpGetDataAndGradient< RANK, DIM >::calculateValAndGrad ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
inline

Calculate gradient and values at integration points.

Parameters
sideside of entity on element
typetype of entity
datadata stored on entity (dofs values, dofs indices, etc.)
Returns
error code

Definition at line 273 of file DataOperators.hpp.

274  {
276  const int nb_base_functions = data.getN().size2();
277  bool constant_diff = false;
278  if (type == MBVERTEX && data.getDiffN().size1() * data.getDiffN().size2() ==
279  DIM * nb_base_functions) {
280  constant_diff = true;
281  }
282  const int nb_dofs = data.getFieldData().size();
283  for (unsigned int gg = 0; gg < data.getN().size1(); gg++) {
284  double *data_ptr, *n_ptr, *diff_n_ptr;
285  n_ptr = &data.getN()(gg, 0);
286  if (constant_diff) {
287  diff_n_ptr = &data.getDiffN()(0, 0);
288  } else {
289  diff_n_ptr = &data.getDiffN()(gg, 0);
290  }
291  data_ptr = &*data.getFieldData().data().begin();
292  for (int rr = 0; rr < RANK; rr++, data_ptr++) {
293  dataAtGaussPts(gg, rr) +=
294  cblas_ddot(nb_dofs / RANK, n_ptr, 1, data_ptr, RANK);
295  double *diff_n_ptr2 = diff_n_ptr;
296  for (unsigned int dd = 0; dd < DIM; dd++, diff_n_ptr2++) {
297  dataGradAtGaussPts(gg, DIM * rr + dd) +=
298  cblas_ddot(nb_dofs / RANK, diff_n_ptr2, DIM, data_ptr, RANK);
299  }
300  }
301  }
303  }

◆ calculateValAndGrad() [2/5]

MoFEMErrorCode MoFEM::OpGetDataAndGradient< 3, 3 >::calculateValAndGrad ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)

Specialization for field with 3 coefficients in 3 dimension.

◆ calculateValAndGrad() [3/5]

MoFEMErrorCode MoFEM::OpGetDataAndGradient< 1, 3 >::calculateValAndGrad ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)

Specialization for field with for scalar field in 3 dimension.

◆ calculateValAndGrad() [4/5]

MoFEMErrorCode MoFEM::OpGetDataAndGradient< 3, 3 >::calculateValAndGrad ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)

Definition at line 840 of file DataOperators.cpp.

841  {
843  if (data.getBase() == NOBASE)
845  const unsigned int nb_gauss_pts = data.getN().size1();
846  const unsigned int nb_base_functions = data.getN().size2();
847  const unsigned int nb_dofs = data.getFieldData().size();
848  if (!nb_dofs)
850  auto t_n = data.getFTensor0N();
851  auto t_val = getValAtGaussPtsTensor<3>(dataAtGaussPts);
852  auto t_grad = getGradAtGaussPtsTensor<3, 3>(dataGradAtGaussPts);
855  if (type == MBVERTEX &&
856  data.getDiffN().data().size() == 3 * nb_base_functions) {
857  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
858  auto t_data = data.getFTensor1FieldData<3>();
859  auto t_diff_n = data.getFTensor1DiffN<3>();
860  unsigned int bb = 0;
861  for (; bb != nb_dofs / 3; ++bb) {
862  t_val(i) += t_data(i) * t_n;
863  t_grad(i, j) += t_data(i) * t_diff_n(j);
864  ++t_n;
865  ++t_diff_n;
866  ++t_data;
867  }
868  ++t_val;
869  ++t_grad;
870  for (; bb != nb_base_functions; ++bb) {
871  ++t_n;
872  }
873  }
874  } else {
875  auto t_diff_n = data.getFTensor1DiffN<3>();
876  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
877  auto t_data = data.getFTensor1FieldData<3>();
878  unsigned int bb = 0;
879  for (; bb != nb_dofs / 3; ++bb) {
880  t_val(i) += t_data(i) * t_n;
881  t_grad(i, j) += t_data(i) * t_diff_n(j);
882  ++t_n;
883  ++t_diff_n;
884  ++t_data;
885  }
886  ++t_val;
887  ++t_grad;
888  for (; bb != nb_base_functions; ++bb) {
889  ++t_n;
890  ++t_diff_n;
891  }
892  }
893  }
895 }

◆ calculateValAndGrad() [5/5]

MoFEMErrorCode MoFEM::OpGetDataAndGradient< 1, 3 >::calculateValAndGrad ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)

Definition at line 898 of file DataOperators.cpp.

899  {
901  const unsigned int nb_gauss_pts = data.getN().size1();
902  const unsigned int nb_base_functions = data.getN().size2();
903  // bool constant_diff = false;
904  const unsigned int nb_dofs = data.getFieldData().size();
905  auto t_n = data.getFTensor0N();
907  FTensor::Tensor0<double *>(&*dataAtGaussPts.data().begin(), 1);
908  double *ptr = &*dataGradAtGaussPts.data().begin();
909  FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3> t_grad(ptr, &ptr[1],
910  &ptr[2]);
912  if (type == MBVERTEX &&
913  data.getDiffN().data().size() == 3 * nb_base_functions) {
914  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
915  auto t_data = data.getFTensor0FieldData();
916  auto t_diff_n = data.getFTensor1DiffN<3>();
917  unsigned int bb = 0;
918  for (; bb != nb_dofs / 3; ++bb) {
919  t_val += t_data * t_n;
920  t_grad(i) += t_data * t_diff_n(i);
921  ++t_n;
922  ++t_diff_n;
923  ++t_data;
924  }
925  ++t_val;
926  ++t_grad;
927  for (; bb != nb_base_functions; ++bb) {
928  ++t_n;
929  }
930  }
931  } else {
932  auto t_diff_n = data.getFTensor1DiffN<3>();
933  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
934  auto t_data = data.getFTensor0FieldData();
935  unsigned int bb = 0;
936  for (; bb != nb_dofs / 3; ++bb) {
937  t_val = t_data * t_n;
938  t_grad(i) += t_data * t_diff_n(i);
939  ++t_n;
940  ++t_diff_n;
941  ++t_data;
942  }
943  ++t_val;
944  ++t_grad;
945  for (; bb != nb_base_functions; ++bb) {
946  ++t_n;
947  ++t_diff_n;
948  }
949  }
950  }
952 }

◆ doWork()

template<int RANK, int DIM>
MoFEMErrorCode MoFEM::OpGetDataAndGradient< RANK, DIM >::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
inlinevirtual

Operator for linear form, usually to calculate values on right hand side.

Reimplemented from MoFEM::DataOperator.

Definition at line 305 of file DataOperators.hpp.

306  {
307 
309 
310  if (data.getFieldData().size() == 0) {
312  }
313 
314  unsigned int nb_dofs = data.getFieldData().size();
315  if (nb_dofs == 0)
317 
318  if (nb_dofs % RANK != 0) {
319  SETERRQ4(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
320  "data inconsistency, type %d, side %d, nb_dofs %d, rank %d",
321  type, side, nb_dofs, RANK);
322  }
323  if (nb_dofs / RANK > data.getN().size2()) {
324  std::cerr << side << " " << type << " "
325  << ApproximationBaseNames[data.getBase()] << std::endl;
326  std::cerr << data.getN() << std::endl;
327  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
328  "data inconsistency nb_dofs >= data.N.size2(), i.e. %u >= %u",
329  nb_dofs, data.getN().size2());
330  }
331 
332  if (type == MBVERTEX) {
333  dataAtGaussPts.resize(data.getN().size1(), RANK, false);
334  dataGradAtGaussPts.resize(data.getN().size1(), RANK * DIM, false);
335  dataAtGaussPts.clear();
336  dataGradAtGaussPts.clear();
337  }
338 
339  CHKERR calculateValAndGrad(side, type, data);
340 
342  }

◆ getGradAtGaussPtsTensor() [1/3]

FTensor::Tensor2< double *, 3, 3 > MoFEM::OpGetDataAndGradient< 3, 3 >::getGradAtGaussPtsTensor< 3, 3 > ( MatrixDouble data)

Specialization for field with 3 coefficients in 3 dimension.

◆ getGradAtGaussPtsTensor() [2/3]

template<int RANK, int DIM>
template<int R, int D>
FTensor::Tensor2<double *, R, D> MoFEM::OpGetDataAndGradient< RANK, DIM >::getGradAtGaussPtsTensor ( MatrixDouble data)
inline

Return tensor associated with matrix storing gradient values

Definition at line 262 of file DataOperators.hpp.

262  {
263  THROW_MESSAGE("Not implemented");
264  }

◆ getGradAtGaussPtsTensor() [3/3]

FTensor::Tensor2< double *, 3, 3 > MoFEM::OpGetDataAndGradient< 3, 3 >::getGradAtGaussPtsTensor< 3, 3 > ( MatrixDouble data)

Definition at line 832 of file DataOperators.cpp.

832  {
833  double *ptr = &*data.data().begin();
834  return FTensor::Tensor2<double *, 3, 3>(ptr, &ptr[1], &ptr[2], &ptr[3],
835  &ptr[4], &ptr[5], &ptr[6], &ptr[7],
836  &ptr[8], 9);
837 }

◆ getValAtGaussPtsTensor() [1/3]

FTensor::Tensor1< double *, 3 > MoFEM::OpGetDataAndGradient< 3, 3 >::getValAtGaussPtsTensor< 3 > ( MatrixDouble data)

Specialization for field with 3 coefficients in 3 dimension.

◆ getValAtGaussPtsTensor() [2/3]

template<int RANK, int DIM>
template<int R>
FTensor::Tensor1<double *, R> MoFEM::OpGetDataAndGradient< RANK, DIM >::getValAtGaussPtsTensor ( MatrixDouble data)
inline

Return tensor associated with matrix storing values

Definition at line 254 of file DataOperators.hpp.

254  {
255  THROW_MESSAGE("Not implemented");
256  }

◆ getValAtGaussPtsTensor() [3/3]

FTensor::Tensor1< double *, 3 > MoFEM::OpGetDataAndGradient< 3, 3 >::getValAtGaussPtsTensor< 3 > ( MatrixDouble data)

Definition at line 824 of file DataOperators.cpp.

824  {
825  double *ptr = &*data.data().begin();
826  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2], 3);
827 }

Member Data Documentation

◆ dataAtGaussPts

template<int RANK, int DIM>
MatrixDouble& MoFEM::OpGetDataAndGradient< RANK, DIM >::dataAtGaussPts

Definition at line 242 of file DataOperators.hpp.

◆ dataGradAtGaussPts

template<int RANK, int DIM>
MatrixDouble& MoFEM::OpGetDataAndGradient< RANK, DIM >::dataGradAtGaussPts

Definition at line 243 of file DataOperators.hpp.


The documentation for this struct was generated from the following file:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
NOBASE
@ NOBASE
Definition: definitions.h:59
MoFEM::OpGetDataAndGradient::dataAtGaussPts
MatrixDouble & dataAtGaussPts
Definition: DataOperators.hpp:242
ApproximationBaseNames
const static char *const ApproximationBaseNames[]
Definition: definitions.h:72
MoFEM::OpGetDataAndGradient::calculateValAndGrad
MoFEMErrorCode calculateValAndGrad(int side, EntityType type, EntitiesFieldData::EntData &data)
Calculate gradient and values at integration points.
Definition: DataOperators.hpp:273
THROW_MESSAGE
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:574
FTensor::Tensor2< double *, 3, 3 >
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
convert.type
type
Definition: convert.py:64
MoFEM::OpGetDataAndGradient::dataGradAtGaussPts
MatrixDouble & dataGradAtGaussPts
Definition: DataOperators.hpp:243
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index< 'i', 3 >
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
FTensor::Tensor0
Definition: Tensor0.hpp:16
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
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