v0.14.0
Loading...
Searching...
No Matches
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 doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
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 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
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]

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 835 of file DataOperators.cpp.

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

◆ calculateValAndGrad() [5/5]

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

Definition at line 893 of file DataOperators.cpp.

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

◆ 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 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
static const char *const ApproximationBaseNames[]
Definition: definitions.h:72
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEMErrorCode calculateValAndGrad(int side, EntityType type, EntitiesFieldData::EntData &data)
Calculate gradient and values at integration points.

◆ 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 }
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:561

◆ getGradAtGaussPtsTensor() [3/3]

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

Definition at line 733 of file DataOperators.cpp.

827 {
828 double *ptr = &*data.data().begin();
829 return FTensor::Tensor2<double *, 3, 3>(ptr, &ptr[1], &ptr[2], &ptr[3],
830 &ptr[4], &ptr[5], &ptr[6], &ptr[7],
831 &ptr[8], 9);
832}

◆ 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 733 of file DataOperators.cpp.

819 {
820 double *ptr = &*data.data().begin();
821 return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2], 3);
822}

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: