11 : sEnse(0), oRder(0), bAse(
NOBASE), entDataBitRefLevel(),
12 N(baseFunctionsAndBaseDerivatives[ZeroDerivative]),
13 diffN(baseFunctionsAndBaseDerivatives[FirstDerivative]) {
14 if (allocate_base_matrices) {
17 for (
int b = 0; b !=
LASTBASE; ++b) {
33boost::shared_ptr<MatrixDouble> &
36 return baseFunctionsAndBaseDerivatives[derivative][base];
39boost::shared_ptr<MatrixDouble> &
53 auto set_default = [&]() {
54 std::array<size_t, MBMAXTYPE> count;
55 std::fill(count.begin(), count.end(), 0);
56 const int dim_type = moab::CN::Dimension(type);
58 if (type != MBVERTEX) {
59 for (
auto dd = dim_type; dd > 0; --dd) {
60 int nb_ents = moab::CN::NumSubEntities(type, dd);
61 for (
int ii = 0; ii != nb_ents; ++ii) {
62 auto sub_ent_type = moab::CN::SubEntityType(type, dd, ii);
63 count[sub_ent_type] = nb_ents;
65 for (
auto tt = moab::CN::TypeDimensionMap[dd].first;
66 tt <= moab::CN::TypeDimensionMap[dd].second; ++tt) {
94 const boost::shared_ptr<EntitiesFieldData> &data_ptr) {
99 for (
int tt = MBVERTEX; tt != MBMAXTYPE; ++tt) {
100 auto &ent_data = data_ptr->dataOnEntities[tt];
102 for (
auto c = derived_ent_data.size();
c < ent_data.size(); ++
c) {
103 boost::shared_ptr<EntData> ent_data_ptr(data_ptr, &ent_data[
c]);
104 derived_ent_data.push_back(
new DerivedEntData(ent_data_ptr));
106 derived_ent_data.resize(ent_data.size());
111 const boost::shared_ptr<EntitiesFieldData> &data_ptr)
129 dOfs.resize(0,
false);
136 for (EntityType
t = MBVERTEX;
t != MBMAXTYPE;
t++)
138 CHKERR e.resetFieldDependentData();
146 auto make_swap = [](boost::shared_ptr<MatrixDouble> &ptr,
147 boost::shared_ptr<MatrixDouble> &ptrBB,
148 boost::shared_ptr<MatrixDouble> &swap_ptr) {
157 make_swap(getNSharedPtr(base), getBBNSharedPtr(
field_name), swapBaseNPtr);
158 make_swap(getDiffNSharedPtr(base), getBBDiffNSharedPtr(
field_name),
167 for (
int tt = MBVERTEX; tt != MBENTITYSET; ++tt) {
169 for (
auto &side_data : ent_data)
178 auto make_swap = [](boost::shared_ptr<MatrixDouble> &ptr,
179 boost::shared_ptr<MatrixDouble> &ptrBB,
180 boost::shared_ptr<MatrixDouble> &swap_ptr) {
189 make_swap(getDerivedNSharedPtr(base), getBBNSharedPtr(
field_name),
191 make_swap(getDerivedDiffNSharedPtr(base), getBBDiffNSharedPtr(
field_name),
197 const boost::shared_ptr<EntitiesFieldData::EntData> &ent_data_ptr)
204boost::shared_ptr<MatrixDouble> &
207 if (baseFunctionsAndBaseDerivatives[derivative][base])
208 return baseFunctionsAndBaseDerivatives[derivative][base];
210 return entDataPtr->getNSharedPtr(base, derivative);
213boost::shared_ptr<MatrixDouble> &
219 return entDataPtr->getNSharedPtr(base);
222boost::shared_ptr<MatrixDouble> &
228 return entDataPtr->getDiffNSharedPtr(base);
230const boost::shared_ptr<MatrixDouble> &
236 return entDataPtr->getNSharedPtr(base);
238const boost::shared_ptr<MatrixDouble> &
244 return entDataPtr->getDiffNSharedPtr(base);
249 os <<
"sEnse: " << e.
getSense() << std::endl
250 <<
"oRder: " << e.
getOrder() << std::endl
251 <<
"global indices: " << e.
getIndices() << std::endl
254 os <<
"fieldData: " << std::fixed << std::setprecision(2) << e.
getFieldData()
259 const double eps = 1e-6;
260 for (
unsigned int ii = 0; ii != base.size1(); ii++) {
261 for (
unsigned int jj = 0; jj != base.size2(); jj++) {
262 if (fabs(base(ii, jj)) <
eps)
266 for (
unsigned int ii = 0; ii != diff_base.size1(); ii++) {
267 for (
unsigned int jj = 0; jj != diff_base.size2(); jj++) {
268 if (fabs(diff_base(ii, jj)) <
eps)
269 diff_base(ii, jj) = 0;
272 os <<
"N: " << std::fixed << base << std::endl
273 <<
"diffN: " << std::fixed << diff_base;
278 for (EntityType
t = MBVERTEX;
t != MBMAXTYPE; ++
t) {
280 os <<
"dataOnEntities[" << moab::CN::EntityTypeName(
t) <<
"][" << nn
294EntitiesFieldData::EntData::getFTensor1FieldData<3>() {
296 for (
auto &d : dOfs) {
298 if (d->getNbOfCoeffs() != 3) {
300 s <<
"Wrong number of coefficients is " << d->getNbOfCoeffs();
301 s <<
" but you ask for tensor rank 1 dimension 3";
308 double *ptr = &*fieldData.data().begin();
315EntitiesFieldData::EntData::getFTensor1FieldData<2>() {
317 for (
auto &d : dOfs) {
319 if (
d->getNbOfCoeffs() != 2) {
321 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
322 s <<
" but you ask for tensor rank 1 dimension 2";
329 double *ptr = &*fieldData.data().begin();
335EntitiesFieldData::EntData::getFTensor1FieldData<1>() {
337 for (
auto &d : dOfs) {
339 if (
d->getNbOfCoeffs() != 1) {
341 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
342 s <<
" but you ask for tensor rank 1 dimension 1";
349 double *ptr = &*fieldData.data().begin();
355EntitiesFieldData::EntData::getFTensor2FieldData<1, 1>() {
357 for (
auto &d : dOfs) {
359 if (
d->getNbOfCoeffs() != 1) {
361 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
362 s <<
" but you ask for tensor rank 2 dimensions 1 by 1 so 1 "
371 double *ptr = &*fieldData.data().begin();
377EntitiesFieldData::EntData::getFTensor2FieldData<1, 2>() {
379 for (
auto &d : dOfs) {
381 if (
d->getNbOfCoeffs() != 2) {
383 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
384 s <<
" but you ask for tensor rank 2 dimensions 1 by 2 so 2 "
393 double *ptr = &*fieldData.data().begin();
399EntitiesFieldData::EntData::getFTensor2FieldData<1, 3>() {
401 for (
auto &d : dOfs) {
403 if (
d->getNbOfCoeffs() != 3) {
405 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
406 s <<
" but you ask for tensor rank 2 dimensions 1 by 3 so 3 "
415 double *ptr = &*fieldData.data().begin();
422EntitiesFieldData::EntData::getFTensor2FieldData<2, 2>() {
424 for(
auto &d : dOfs) {
426 if(
d->getNbOfCoeffs() != 4) {
428 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
429 s <<
" but you ask for tensor rank 2 dimensions 2 by 2 so 4 coefficients "
437 double *ptr = &*fieldData.data().begin();
439 ptr, &ptr[1], &ptr[2], &ptr[3]);
444EntitiesFieldData::EntData::getFTensor2FieldData<3, 3>() {
446 for (
auto &d : dOfs) {
448 if (
d->getNbOfCoeffs() != 9) {
450 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
451 s <<
" but you ask for tensor rank 2 dimensions 3 by 3 so 9 "
460 double *ptr = &*fieldData.data().begin();
462 ptr, &ptr[1], &ptr[2], &ptr[3], &ptr[4], &ptr[5], &ptr[6], &ptr[7],
468EntitiesFieldData::EntData::getFTensor2SymmetricFieldData<3>() {
470 for (
auto &d : dOfs) {
472 if (
d->getNbOfCoeffs() != 6) {
474 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
475 s <<
" but you ask for symmetric tensor rank 2 dimensions 3 by 3 so 6 "
484 double *ptr = &*fieldData.data().begin();
486 ptr, &ptr[1], &ptr[2], &ptr[3], &ptr[4], &ptr[5]);
491EntitiesFieldData::EntData::getFTensor2SymmetricFieldData<2>() {
493 for (
auto &d : dOfs) {
495 if (
d->getNbOfCoeffs() != 3) {
497 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
498 s <<
" but you ask for symmetric tensor rank 2 dimensions 2 by 2 so 3 "
507 double *ptr = &*fieldData.data().begin();
509 ptr, &ptr[1], &ptr[2]);
515 for (
auto &d : dOfs) {
517 if (d->getNbOfCoeffs() != 1) {
519 s <<
"Wrong number of coefficients is " << d->getNbOfCoeffs();
520 s <<
" but expected scalar field, tensor of rank 0";
528 &*fieldData.data().begin());
531template <
int Tensor_Dim>
536 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
541template <
int Tensor_Dim>
544 return getFTensor1DiffN<Tensor_Dim>(
bAse);
552EntitiesFieldData::EntData::getFTensor1DiffN<3>(
554 double *ptr = &*getDiffN(base).data().begin();
564EntitiesFieldData::EntData::getFTensor1DiffN<3>() {
565 return getFTensor1DiffN<3>(
bAse);
573EntitiesFieldData::EntData::getFTensor1DiffN<2>(
575 double *ptr = &*getDiffN(base).data().begin();
584EntitiesFieldData::EntData::getFTensor1DiffN<2>() {
585 return getFTensor1DiffN<2>(
bAse);
588template <
int Tensor_Dim>
591 const int gg,
const int bb) {
593 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
603EntitiesFieldData::EntData::getFTensor1DiffN<3>(
605 double *ptr = &getDiffN(base)(gg, 3 * bb);
615EntitiesFieldData::EntData::getFTensor1DiffN<3>(
const int gg,
const int bb) {
616 return getFTensor1DiffN<3>(
bAse, gg, bb);
624EntitiesFieldData::EntData::getFTensor1DiffN<2>(
626 double *ptr = &getDiffN(base)(gg, 2 * bb);
635EntitiesFieldData::EntData::getFTensor1DiffN<2>(
const int gg,
const int bb) {
636 return getFTensor1DiffN<2>(
bAse, gg, bb);
645template <
int Tensor_Dim>
649 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
654template <
int Tensor_Dim>
657 const int gg,
const int bb) {
659 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
664template <
int Tensor_Dim0,
int Tensor_Dim1>
666 Tensor_Dim0, Tensor_Dim1>
669 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
"x" << Tensor_Dim1
670 <<
" not implemented";
675template <
int Tensor_Dim0,
int Tensor_Dim1>
677 Tensor_Dim0, Tensor_Dim1>
679 const int gg,
const int bb) {
681 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
"x" << Tensor_Dim1
682 <<
" not implemented";
690 double *t_n_ptr = &*getN(base).
data().begin();
699 const int gg,
const int bb) {
700 double *t_n_ptr = &getN(base)(gg, 3 * bb);
708EntitiesFieldData::EntData::getFTensor2DiffN<3, 3>(
710 double *t_diff_n_ptr = &*getDiffN(base).
data().begin();
720 const int gg,
const int bb) {
721 double *t_diff_n_ptr = &getDiffN(base)(gg, 9 * bb);
730EntitiesFieldData::EntData::getFTensor2DiffN<3, 2>(
732 double *t_diff_n_ptr = &*getDiffN(base).data().begin();
741 const int gg,
const int bb) {
742 double *t_diff_n_ptr = &getDiffN(base)(gg, 6 * bb);
751 double *ptr = &(getN(base, BaseDerivatives::SecondDerivative))(0, 0);
766template <
int Tensor_Dim0,
int Tensor_Dim1>
768 Tensor_Dim0, Tensor_Dim1>
771 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
", " << Tensor_Dim1
772 <<
" not implemented";
775 Tensor_Dim0, Tensor_Dim1>();
781 double *t_n_ptr = &*(getN(base).data().begin());
793template <
int Tensor_Dim0,
int Tensor_Dim1>
795 Tensor_Dim0, Tensor_Dim1>
797 const int gg,
const int bb) {
799 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
", " << Tensor_Dim1
800 <<
" not implemented";
803 Tensor_Dim0, Tensor_Dim1>();
809 const int gg,
const int bb) {
810 double *t_n_ptr = &getN(base)(gg, 9 * bb);
822template <
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
825 Tensor_Dim0, Tensor_Dim1, Tensor_Dim2>
828 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
"x" << Tensor_Dim1
829 <<
"x" << Tensor_Dim2 <<
" not implemented";
834template <
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
836 Tensor_Dim0, Tensor_Dim1, Tensor_Dim2>
838 const int gg,
const int bb) {
840 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
"x" << Tensor_Dim1
841 <<
" not implemented";
849 double *ptr = &*getDiffN(base).data().begin();
856 const int gg,
const int bb) {
857 double *ptr = &getDiffN(base)(gg, 27 * bb);
867boost::shared_ptr<MatrixInt> &
873boost::shared_ptr<MatrixDouble> &
881const boost::shared_ptr<MatrixDouble> &
890boost::shared_ptr<MatrixDouble> &
898const boost::shared_ptr<MatrixDouble> &
904std::map<std::string, boost::shared_ptr<MatrixInt>> &
906 return bbAlphaIndices;
909std::map<std::string, boost::shared_ptr<MatrixDouble>> &
914std::map<std::string, boost::shared_ptr<MatrixDouble>> &
919boost::shared_ptr<MatrixInt> &
921 return bbAlphaIndicesByOrder[o];
924boost::shared_ptr<MatrixDouble> &
926 return bbNByOrder[o];
929boost::shared_ptr<MatrixDouble> &
931 return bbDiffNByOrder[o];
934std::array<boost::shared_ptr<MatrixInt>,
937 return bbAlphaIndicesByOrder;
940std::array<boost::shared_ptr<MatrixDouble>,
946std::array<boost::shared_ptr<MatrixDouble>,
949 return bbDiffNByOrder;
952boost::shared_ptr<MatrixInt> &
955 return entDataPtr->getBBAlphaIndicesSharedPtr(
field_name);
958boost::shared_ptr<MatrixDouble> &
961 return entDataPtr->getBBNSharedPtr(
field_name);
964const boost::shared_ptr<MatrixDouble> &
967 return entDataPtr->getBBNSharedPtr(
field_name);
973boost::shared_ptr<MatrixDouble> &
976 return entDataPtr->getBBDiffNSharedPtr(
field_name);
982const boost::shared_ptr<MatrixDouble> &
985 return entDataPtr->getBBDiffNSharedPtr(
field_name);
991 return entDataBitRefLevel;
994std::vector<BitRefLevel> &
996 return entDataPtr->getEntDataBitRefLevel();
T data[Tensor_Dim0][Tensor_Dim1]
FieldApproximationBase
approximation base
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#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 MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
const double c
speed of light (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasMatrix< double > MatrixDouble
implementation of Data Operators for Forces and Sources
static void constructor_derived_data(DerivedEntitiesFieldData *derived_data, const boost::shared_ptr< EntitiesFieldData > &data_ptr)
static void constructor_data(EntitiesFieldData *data, const EntityType type)
FTensor::Tensor3< FTensor::PackPtr< double *, 27 >, 3, 3, 3 > getFTensor3FromPtr< 3, 3, 3 >(double *ptr)
constexpr double t
plate stiffness
constexpr auto field_name
Derived data on single entity (This is passed as argument to DataOperator::doWork)
boost::shared_ptr< MatrixDouble > & getBBNSharedPtr(const std::string &field_name)
MoFEMErrorCode baseSwap(const std::string &field_name, const FieldApproximationBase base)
Used by Bernstein base to keep temporary pointer.
std::vector< BitRefLevel > & getEntDataBitRefLevel()
Get entity bit reference level.
int getSense() const
Get entity sense for conforming approximation fields.
boost::shared_ptr< MatrixInt > & getBBAlphaIndicesSharedPtr(const std::string &field_name)
boost::shared_ptr< MatrixDouble > & getBBDiffNSharedPtr(const std::string &field_name)
boost::shared_ptr< MatrixDouble > & getDiffNSharedPtr(const FieldApproximationBase base)
Get shared pointer to derivatives of base functions.
DerivedEntData(const boost::shared_ptr< EntitiesFieldData::EntData > &ent_data_ptr)
boost::shared_ptr< MatrixDouble > & getNSharedPtr(const FieldApproximationBase base, const BaseDerivatives derivative)
Get shared pointer to base functions with derivatives.
this class derives data from other data structure
MoFEMErrorCode setElementType(const EntityType type)
Set element type for derived data.
const boost::shared_ptr< EntitiesFieldData > dataPtr
DerivedEntitiesFieldData(const boost::shared_ptr< EntitiesFieldData > &data_ptr)
Construct DerivedEntitiesFieldData from existing EntitiesFieldData.
Data on single entity (This is passed as argument to DataOperator::doWork)
virtual std::array< boost::shared_ptr< MatrixDouble >, MaxBernsteinBezierOrder > & getBBDiffNByOrderArray()
FieldSpace sPace
Entity space.
virtual std::array< boost::shared_ptr< MatrixDouble >, MaxBernsteinBezierOrder > & getBBNByOrderArray()
auto getFTensor2N()
Get base functions for Hdiv space.
VectorDouble fieldData
Field data on entity.
ApproximationOrder getOrder() const
Get approximation order.
VectorInt localIndices
Local indices on entity.
virtual std::array< boost::shared_ptr< MatrixInt >, MaxBernsteinBezierOrder > & getBBAlphaIndicesByOrderArray()
virtual std::map< std::string, boost::shared_ptr< MatrixInt > > & getBBAlphaIndicesMap()
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN()
Get derivatives of base functions.
static constexpr size_t MaxBernsteinBezierOrder
VectorInt iNdices
Global indices on entity.
virtual boost::shared_ptr< MatrixDouble > & getNSharedPtr(const FieldApproximationBase base, const BaseDerivatives derivative)
Get shared pointer to base functions with derivatives.
virtual boost::shared_ptr< MatrixInt > & getBBAlphaIndicesSharedPtr(const std::string &field_name)
const VectorDouble & getFieldData() const
Get DOF values on entity.
virtual boost::shared_ptr< MatrixDouble > & getBBDiffNByOrderSharedPtr(const size_t o)
get BB base derivative by order
virtual std::map< std::string, boost::shared_ptr< MatrixDouble > > & getBBNMap()
get hash map of base function for BB base, key is a field name
virtual MoFEMErrorCode baseSwap(const std::string &field_name, const FieldApproximationBase base)
Swap bases functions.
const VectorInt & getLocalIndices() const
Get local indices of degrees of freedom on entity.
FTensor::Tensor3< FTensor::PackPtr< double *, Tensor_Dim0 *Tensor_Dim1 *Tensor_Dim2 >, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2 > getFTensor3DiffN()
Get derivatives of base functions for tonsorial Hdiv space.
virtual std::map< std::string, boost::shared_ptr< MatrixDouble > > & getBBDiffNMap()
get hash map of derivatives base function for BB base, key is a field name
virtual std::vector< BitRefLevel > & getEntDataBitRefLevel()
Get entity bit reference level.
virtual int getSense() const
Get entity sense for conforming approximation fields.
VectorFieldEntities fieldEntities
Field entities.
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0FieldData()
Return scalar files as a FTensor of rank 0.
virtual boost::shared_ptr< MatrixInt > & getBBAlphaIndicesByOrderSharedPtr(const size_t o)
get ALpha indices for BB base by order
MoFEMErrorCode resetFieldDependentData()
FTensor::Tensor3< FTensor::PackPtr< double *, Tensor_Dim0 *Tensor_Dim1 *Tensor_Dim2 >, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2 > getFTensor3Diff2N()
Get second derivatives of base functions for Hvec space.
auto getFTensor1N()
Get base functions for Hdiv space.
virtual boost::shared_ptr< MatrixDouble > & getBBNSharedPtr(const std::string &field_name)
std::array< std::array< boost::shared_ptr< MatrixDouble >, LASTBASE >, LastDerivative > baseFunctionsAndBaseDerivatives
FTensor::Tensor2< FTensor::PackPtr< double *, Tensor_Dim0 *Tensor_Dim1 >, Tensor_Dim0, Tensor_Dim1 > getFTensor2DiffN()
Get derivatives of base functions for Hdiv space.
VectorDofs dOfs
DoFs on entity.
virtual boost::shared_ptr< MatrixDouble > & getDiffNSharedPtr(const FieldApproximationBase base)
Get shared pointer to derivatives of base functions.
virtual boost::shared_ptr< MatrixDouble > & getBBNByOrderSharedPtr(const size_t o)
get BB base by order
const VectorInt & getIndices() const
Get global indices of degrees of freedom on entity.
EntData(const bool allocate_base_matrices=true)
Construct EntData object.
FieldApproximationBase bAse
Field approximation base.
virtual boost::shared_ptr< MatrixDouble > & getBBDiffNSharedPtr(const std::string &field_name)
data structure for finite element entity
friend std::ostream & operator<<(std::ostream &os, const EntitiesFieldData &e)
MoFEMErrorCode resetFieldDependentData()
Reset data associated with particular field name.
std::bitset< LASTBASE > bAse
bases on element
std::array< boost::ptr_vector< EntData >, MBMAXTYPE > dataOnEntities
virtual MoFEMErrorCode baseSwap(const std::string &field_name, const FieldApproximationBase base)
Swap approximation base.
virtual MoFEMErrorCode setElementType(const EntityType type)
Set element type and initialize data structures.