v0.10.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, D > getGradAtGaussPtsTensor (MatrixDouble &data)
 
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 Calculate gradient and values at integration points. More...
 
MoFEMErrorCode doWork (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
template<>
FTensor::Tensor1< double *, 3 > getValAtGaussPtsTensor (MatrixDouble &data)
 Specialization for field with 3 coefficients in 3 dimension. More...
 
template<>
FTensor::Tensor2< double *, 3, 3 > getGradAtGaussPtsTensor (MatrixDouble &data)
 Specialization for field with 3 coefficients in 3 dimension. More...
 
template<>
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 Specialization for field with 3 coefficients in 3 dimension. More...
 
template<>
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 Specialization for field with for scalar field in 3 dimension. More...
 
template<>
FTensor::Tensor1< double *, 3 > getValAtGaussPtsTensor (MatrixDouble &data)
 
template<>
FTensor::Tensor2< double *, 3, 3 > getGradAtGaussPtsTensor (MatrixDouble &data)
 
template<>
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 
template<>
MoFEMErrorCode calculateValAndGrad (int side, EntityType type, DataForcesAndSourcesCore::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, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side. More...
 
virtual MoFEMErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data)
 
virtual MoFEMErrorCode opRhs (DataForcesAndSourcesCore &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
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...
 

Detailed Description

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

Get field values and gradients at Gauss points.

Definition at line 307 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 
)

Definition at line 312 of file DataOperators.hpp.

314  : dataAtGaussPts(data_at_gauss_pt),
315  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,
DataForcesAndSourcesCore::EntData data 
)

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 340 of file DataOperators.hpp.

341  {
343  const int nb_base_functions = data.getN().size2();
344  bool constant_diff = false;
345  if (type == MBVERTEX && data.getDiffN().size1() * data.getDiffN().size2() ==
346  DIM * nb_base_functions) {
347  constant_diff = true;
348  }
349  const int nb_dofs = data.getFieldData().size();
350  for (unsigned int gg = 0; gg < data.getN().size1(); gg++) {
351  double *data_ptr, *n_ptr, *diff_n_ptr;
352  n_ptr = &data.getN()(gg, 0);
353  if (constant_diff) {
354  diff_n_ptr = &data.getDiffN()(0, 0);
355  } else {
356  diff_n_ptr = &data.getDiffN()(gg, 0);
357  }
358  data_ptr = &*data.getFieldData().data().begin();
359  for (int rr = 0; rr < RANK; rr++, data_ptr++) {
360  dataAtGaussPts(gg, rr) +=
361  cblas_ddot(nb_dofs / RANK, n_ptr, 1, data_ptr, RANK);
362  double *diff_n_ptr2 = diff_n_ptr;
363  for (unsigned int dd = 0; dd < DIM; dd++, diff_n_ptr2++) {
364  dataGradAtGaussPts(gg, DIM * rr + dd) +=
365  cblas_ddot(nb_dofs / RANK, diff_n_ptr2, DIM, data_ptr, RANK);
366  }
367  }
368  }
370  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
double cblas_ddot(const int N, const double *X, const int incX, const double *Y, const int incY)
Definition: cblas_ddot.c:12
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

◆ calculateValAndGrad() [2/5]

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

Specialization for field with 3 coefficients in 3 dimension.

◆ calculateValAndGrad() [3/5]

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

Specialization for field with for scalar field in 3 dimension.

◆ calculateValAndGrad() [4/5]

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

Definition at line 1239 of file DataOperators.cpp.

1240  {
1242  if (data.getBase() == NOBASE)
1244  const unsigned int nb_gauss_pts = data.getN().size1();
1245  const unsigned int nb_base_functions = data.getN().size2();
1246  const unsigned int nb_dofs = data.getFieldData().size();
1247  if (!nb_dofs)
1249  auto t_n = data.getFTensor0N();
1250  auto t_val = getValAtGaussPtsTensor<3>(dataAtGaussPts);
1251  auto t_grad = getGradAtGaussPtsTensor<3, 3>(dataGradAtGaussPts);
1254  if (type == MBVERTEX &&
1255  data.getDiffN().data().size() == 3 * nb_base_functions) {
1256  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
1257  auto t_data = data.getFTensor1FieldData<3>();
1258  auto t_diff_n = data.getFTensor1DiffN<3>();
1259  unsigned int bb = 0;
1260  for (; bb != nb_dofs / 3; ++bb) {
1261  t_val(i) += t_data(i) * t_n;
1262  t_grad(i, j) += t_data(i) * t_diff_n(j);
1263  ++t_n;
1264  ++t_diff_n;
1265  ++t_data;
1266  }
1267  ++t_val;
1268  ++t_grad;
1269  for (; bb != nb_base_functions; ++bb) {
1270  ++t_n;
1271  }
1272  }
1273  } else {
1274  auto t_diff_n = data.getFTensor1DiffN<3>();
1275  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
1276  auto t_data = data.getFTensor1FieldData<3>();
1277  unsigned int bb = 0;
1278  for (; bb != nb_dofs / 3; ++bb) {
1279  t_val(i) += t_data(i) * t_n;
1280  t_grad(i, j) += t_data(i) * t_diff_n(j);
1281  ++t_n;
1282  ++t_diff_n;
1283  ++t_data;
1284  }
1285  ++t_val;
1286  ++t_grad;
1287  for (; bb != nb_base_functions; ++bb) {
1288  ++t_n;
1289  ++t_diff_n;
1290  }
1291  }
1292  }
1294 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
static Index< 'i', 3 > i
static Index< 'j', 3 > j

◆ calculateValAndGrad() [5/5]

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

Definition at line 1297 of file DataOperators.cpp.

1298  {
1300  const unsigned int nb_gauss_pts = data.getN().size1();
1301  const unsigned int nb_base_functions = data.getN().size2();
1302  // bool constant_diff = false;
1303  const unsigned int nb_dofs = data.getFieldData().size();
1304  auto t_n = data.getFTensor0N();
1306  FTensor::Tensor0<double *>(&*dataAtGaussPts.data().begin(), 1);
1307  double *ptr = &*dataGradAtGaussPts.data().begin();
1308  FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3> t_grad(ptr, &ptr[1],
1309  &ptr[2]);
1311  if (type == MBVERTEX &&
1312  data.getDiffN().data().size() == 3 * nb_base_functions) {
1313  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
1314  auto t_data = data.getFTensor0FieldData();
1315  auto t_diff_n = data.getFTensor1DiffN<3>();
1316  unsigned int bb = 0;
1317  for (; bb != nb_dofs / 3; ++bb) {
1318  t_val += t_data * t_n;
1319  t_grad(i) += t_data * t_diff_n(i);
1320  ++t_n;
1321  ++t_diff_n;
1322  ++t_data;
1323  }
1324  ++t_val;
1325  ++t_grad;
1326  for (; bb != nb_base_functions; ++bb) {
1327  ++t_n;
1328  }
1329  }
1330  } else {
1331  auto t_diff_n = data.getFTensor1DiffN<3>();
1332  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
1333  auto t_data = data.getFTensor0FieldData();
1334  unsigned int bb = 0;
1335  for (; bb != nb_dofs / 3; ++bb) {
1336  t_val = t_data * t_n;
1337  t_grad(i) += t_data * t_diff_n(i);
1338  ++t_n;
1339  ++t_diff_n;
1340  ++t_data;
1341  }
1342  ++t_val;
1343  ++t_grad;
1344  for (; bb != nb_base_functions; ++bb) {
1345  ++t_n;
1346  ++t_diff_n;
1347  }
1348  }
1349  }
1351 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
static Index< 'i', 3 > i

◆ doWork()

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

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

Reimplemented from MoFEM::DataOperator.

Definition at line 372 of file DataOperators.hpp.

373  {
374 
376 
377  if (data.getFieldData().size() == 0) {
379  }
380 
381  unsigned int nb_dofs = data.getFieldData().size();
382  if (nb_dofs == 0)
384 
385  if (nb_dofs % RANK != 0) {
386  SETERRQ4(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
387  "data inconsistency, type %d, side %d, nb_dofs %d, rank %d",
388  type, side, nb_dofs, RANK);
389  }
390  if (nb_dofs / RANK > data.getN().size2()) {
391  std::cerr << side << " " << type << " "
392  << ApproximationBaseNames[data.getBase()] << std::endl;
393  std::cerr << data.getN() << std::endl;
394  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
395  "data inconsistency nb_dofs >= data.N.size2(), i.e. %u >= %u",
396  nb_dofs, data.getN().size2());
397  }
398 
399  if (type == MBVERTEX) {
400  dataAtGaussPts.resize(data.getN().size1(), RANK, false);
401  dataGradAtGaussPts.resize(data.getN().size1(), RANK * DIM, false);
402  dataAtGaussPts.clear();
403  dataGradAtGaussPts.clear();
404  }
405 
406  CHKERR calculateValAndGrad(side, type, data);
407 
409  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
static const char *const ApproximationBaseNames[]
Definition: definitions.h:164
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
MoFEMErrorCode calculateValAndGrad(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
Calculate gradient and values at integration points.

◆ getGradAtGaussPtsTensor() [1/3]

template<>
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)

Return tensor associated with matrix storing gradient values

Definition at line 329 of file DataOperators.hpp.

329  {
330  THROW_MESSAGE("Not implemented");
331  }
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:628

◆ getGradAtGaussPtsTensor() [3/3]

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

Definition at line 1231 of file DataOperators.cpp.

1231  {
1232  double *ptr = &*data.data().begin();
1233  return FTensor::Tensor2<double *, 3, 3>(ptr, &ptr[1], &ptr[2], &ptr[3],
1234  &ptr[4], &ptr[5], &ptr[6], &ptr[7],
1235  &ptr[8], 9);
1236 }

◆ getValAtGaussPtsTensor() [1/3]

template<>
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)

Return tensor associated with matrix storing values

Definition at line 321 of file DataOperators.hpp.

321  {
322  THROW_MESSAGE("Not implemented");
323  }
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:628

◆ getValAtGaussPtsTensor() [3/3]

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

Definition at line 1223 of file DataOperators.cpp.

1223  {
1224  double *ptr = &*data.data().begin();
1225  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2], 3);
1226 }

Member Data Documentation

◆ dataAtGaussPts

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

Definition at line 309 of file DataOperators.hpp.

◆ dataGradAtGaussPts

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

Definition at line 310 of file DataOperators.hpp.


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