v0.8.23
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 *, R > getValAtGaussPtsTensor (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, const bool do_vertices=true, const bool do_edges=true, const bool do_quads=true, const bool do_tris=true, const bool do_tets=true, const bool do_prisms=true)
 
virtual ~DataOperator ()
 
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, bool symm=true)
 
virtual MoFEMErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data)
 
virtual MoFEMErrorCode opRhs (DataForcesAndSourcesCore &data, const bool do_vertices, const bool do_edges, const bool do_quads, const bool do_tris, const bool do_tets, const bool do_prisms, const bool error_if_no_base=true)
 
virtual MoFEMErrorCode opRhs (DataForcesAndSourcesCore &data, const bool error_if_no_base=true)
 
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...
 
bool doVertices
 If false skip vertices. More...
 
bool doEdges
 If false skip edges. More...
 
bool doQuads
 
bool doTris
 
bool doTets
 
bool doPrisms
 

Detailed Description

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

Get field values and gradients at Gauss points.

Definition at line 312 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 317 of file DataOperators.hpp.

319  : dataAtGaussPts(data_at_gauss_pt),
320  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 345 of file DataOperators.hpp.

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

1649  {
1651  if (data.getBase() == NOBASE)
1653  const unsigned int nb_gauss_pts = data.getN().size1();
1654  const unsigned int nb_base_functions = data.getN().size2();
1655  const unsigned int nb_dofs = data.getFieldData().size();
1656  if (!nb_dofs)
1658  auto t_n = data.getFTensor0N();
1659  auto t_val = getValAtGaussPtsTensor<3>(dataAtGaussPts);
1660  auto t_grad = getGradAtGaussPtsTensor<3, 3>(dataGradAtGaussPts);
1663  if (type == MBVERTEX &&
1664  data.getDiffN().data().size() == 3 * nb_base_functions) {
1665  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
1666  auto t_data = data.getFTensor1FieldData<3>();
1667  auto t_diff_n = data.getFTensor1DiffN<3>();
1668  unsigned int bb = 0;
1669  for (; bb != nb_dofs / 3; ++bb) {
1670  t_val(i) += t_data(i) * t_n;
1671  t_grad(i, j) += t_data(i) * t_diff_n(j);
1672  ++t_n;
1673  ++t_diff_n;
1674  ++t_data;
1675  }
1676  ++t_val;
1677  ++t_grad;
1678  for (; bb != nb_base_functions; ++bb) {
1679  ++t_n;
1680  }
1681  }
1682  } else {
1683  auto t_diff_n = data.getFTensor1DiffN<3>();
1684  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
1685  auto t_data = data.getFTensor1FieldData<3>();
1686  unsigned int bb = 0;
1687  for (; bb != nb_dofs / 3; ++bb) {
1688  t_val(i) += t_data(i) * t_n;
1689  t_grad(i, j) += t_data(i) * t_diff_n(j);
1690  ++t_n;
1691  ++t_diff_n;
1692  ++t_data;
1693  }
1694  ++t_val;
1695  ++t_grad;
1696  for (; bb != nb_base_functions; ++bb) {
1697  ++t_n;
1698  ++t_diff_n;
1699  }
1700  }
1701  }
1703 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:500
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:507

◆ calculateValAndGrad() [5/5]

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

Definition at line 1706 of file DataOperators.cpp.

1707  {
1709  const unsigned int nb_gauss_pts = data.getN().size1();
1710  const unsigned int nb_base_functions = data.getN().size2();
1711  // bool constant_diff = false;
1712  const unsigned int nb_dofs = data.getFieldData().size();
1713  auto t_n = data.getFTensor0N();
1715  FTensor::Tensor0<double *>(&*dataAtGaussPts.data().begin(), 1);
1716  double *ptr = &*dataGradAtGaussPts.data().begin();
1717  FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3> t_grad(ptr, &ptr[1],
1718  &ptr[2]);
1720  if (type == MBVERTEX &&
1721  data.getDiffN().data().size() == 3 * nb_base_functions) {
1722  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
1723  auto t_data = data.getFTensor0FieldData();
1724  auto t_diff_n = data.getFTensor1DiffN<3>();
1725  unsigned int bb = 0;
1726  for (; bb != nb_dofs / 3; ++bb) {
1727  t_val += t_data * t_n;
1728  t_grad(i) += t_data * t_diff_n(i);
1729  ++t_n;
1730  ++t_diff_n;
1731  ++t_data;
1732  }
1733  ++t_val;
1734  ++t_grad;
1735  for (; bb != nb_base_functions; ++bb) {
1736  ++t_n;
1737  }
1738  }
1739  } else {
1740  auto t_diff_n = data.getFTensor1DiffN<3>();
1741  for (unsigned int gg = 0; gg != nb_gauss_pts; ++gg) {
1742  auto t_data = data.getFTensor0FieldData();
1743  unsigned int bb = 0;
1744  for (; bb != nb_dofs / 3; ++bb) {
1745  t_val = t_data * t_n;
1746  t_grad(i) += t_data * t_diff_n(i);
1747  ++t_n;
1748  ++t_diff_n;
1749  ++t_data;
1750  }
1751  ++t_val;
1752  ++t_grad;
1753  for (; bb != nb_base_functions; ++bb) {
1754  ++t_n;
1755  ++t_diff_n;
1756  }
1757  }
1758  }
1760 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:500
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:507

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

378  {
379 
381 
382  if (data.getFieldData().size() == 0) {
384  }
385 
386  unsigned int nb_dofs = data.getFieldData().size();
387  if (nb_dofs == 0)
389 
390  if (nb_dofs % RANK != 0) {
391  SETERRQ4(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
392  "data inconsistency, type %d, side %d, nb_dofs %d, rank %d",
393  type, side, nb_dofs, RANK);
394  }
395  if (nb_dofs / RANK > data.getN().size2()) {
396  std::cerr << side << " " << type << " "
397  << ApproximationBaseNames[data.getBase()] << std::endl;
398  std::cerr << data.getN() << std::endl;
399  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
400  "data inconsistency nb_dofs >= data.N.size2(), i.e. %u >= %u",
401  nb_dofs, data.getN().size2());
402  }
403 
404  if (type == MBVERTEX) {
405  dataAtGaussPts.resize(data.getN().size1(), RANK, false);
406  dataGradAtGaussPts.resize(data.getN().size1(), RANK * DIM, false);
407  dataAtGaussPts.clear();
408  dataGradAtGaussPts.clear();
409  }
410 
411  CHKERR calculateValAndGrad(side, type, data);
412 
414  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:476
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:507
static const char *const ApproximationBaseNames[]
Definition: definitions.h:157
#define CHKERR
Inline error check.
Definition: definitions.h:595
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:406
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 334 of file DataOperators.hpp.

334  {
335  THROW_MESSAGE("Not implemented");
336  }
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:619

◆ getGradAtGaussPtsTensor() [3/3]

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

Definition at line 1640 of file DataOperators.cpp.

1640  {
1641  double *ptr = &*data.data().begin();
1642  return FTensor::Tensor2<double *, 3, 3>(ptr, &ptr[1], &ptr[2], &ptr[3],
1643  &ptr[4], &ptr[5], &ptr[6], &ptr[7],
1644  &ptr[8], 9);
1645 }

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

326  {
327  THROW_MESSAGE("Not implemented");
328  }
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:619

◆ getValAtGaussPtsTensor() [3/3]

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

Definition at line 1632 of file DataOperators.cpp.

1632  {
1633  double *ptr = &*data.data().begin();
1634  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2], 3);
1635 }

Member Data Documentation

◆ dataAtGaussPts

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

Definition at line 314 of file DataOperators.hpp.

◆ dataGradAtGaussPts

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

Definition at line 315 of file DataOperators.hpp.


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