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) {
26boost::shared_ptr<MatrixDouble> &
29 return baseFunctionsAndBaseDerivatives[direvatie][base];
32boost::shared_ptr<MatrixDouble> &
46 auto set_default = [&]() {
47 std::array<size_t, MBMAXTYPE> count;
48 std::fill(count.begin(), count.end(), 0);
49 const int dim_type = moab::CN::Dimension(type);
51 if (type != MBVERTEX) {
52 for (
auto dd = dim_type; dd > 0; --dd) {
53 int nb_ents = moab::CN::NumSubEntities(type, dd);
54 for (
int ii = 0; ii != nb_ents; ++ii) {
55 auto sub_ent_type = moab::CN::SubEntityType(type, dd, ii);
56 count[sub_ent_type] = nb_ents;
58 for (
auto tt = moab::CN::TypeDimensionMap[dd].first;
59 tt <= moab::CN::TypeDimensionMap[dd].second; ++tt) {
87 const boost::shared_ptr<EntitiesFieldData> &data_ptr) {
92 for (
int tt = MBVERTEX; tt != MBMAXTYPE; ++tt) {
93 auto &ent_data = data_ptr->dataOnEntities[tt];
95 for (
auto c = derived_ent_data.size();
c < ent_data.size(); ++
c) {
96 boost::shared_ptr<EntData> ent_data_ptr(data_ptr, &ent_data[
c]);
97 derived_ent_data.push_back(
new DerivedEntData(ent_data_ptr));
99 derived_ent_data.resize(ent_data.size());
104 const boost::shared_ptr<EntitiesFieldData> &data_ptr)
122 dOfs.resize(0,
false);
129 for (EntityType
t = MBVERTEX;
t != MBMAXTYPE;
t++)
131 CHKERR e.resetFieldDependentData();
139 auto make_swap = [](boost::shared_ptr<MatrixDouble> &ptr,
140 boost::shared_ptr<MatrixDouble> &ptrBB,
141 boost::shared_ptr<MatrixDouble> &swap_ptr) {
150 make_swap(getNSharedPtr(base), getBBNSharedPtr(
field_name), swapBaseNPtr);
151 make_swap(getDiffNSharedPtr(base), getBBDiffNSharedPtr(
field_name),
160 for (
int tt = MBVERTEX; tt != MBENTITYSET; ++tt) {
162 for (
auto &side_data : ent_data)
171 auto make_swap = [](boost::shared_ptr<MatrixDouble> &ptr,
172 boost::shared_ptr<MatrixDouble> &ptrBB,
173 boost::shared_ptr<MatrixDouble> &swap_ptr) {
182 make_swap(getDerivedNSharedPtr(base), getBBNSharedPtr(
field_name),
184 make_swap(getDerivedDiffNSharedPtr(base), getBBDiffNSharedPtr(
field_name),
190 const boost::shared_ptr<EntitiesFieldData::EntData> &ent_data_ptr)
197boost::shared_ptr<MatrixDouble> &
200 if (baseFunctionsAndBaseDerivatives[derivative][base])
201 return baseFunctionsAndBaseDerivatives[derivative][base];
203 return entDataPtr->getNSharedPtr(base, derivative);
206boost::shared_ptr<MatrixDouble> &
212 return entDataPtr->getNSharedPtr(base);
215boost::shared_ptr<MatrixDouble> &
221 return entDataPtr->getDiffNSharedPtr(base);
223const boost::shared_ptr<MatrixDouble> &
229 return entDataPtr->getNSharedPtr(base);
231const boost::shared_ptr<MatrixDouble> &
237 return entDataPtr->getDiffNSharedPtr(base);
242 os <<
"sEnse: " << e.
getSense() << std::endl
243 <<
"oRder: " << e.
getOrder() << std::endl
244 <<
"global indices: " << e.
getIndices() << std::endl
247 os <<
"fieldData: " << std::fixed << std::setprecision(2) << e.
getFieldData()
252 const double eps = 1e-6;
253 for (
unsigned int ii = 0; ii != base.size1(); ii++) {
254 for (
unsigned int jj = 0; jj != base.size2(); jj++) {
255 if (fabs(base(ii, jj)) <
eps)
259 for (
unsigned int ii = 0; ii != diff_base.size1(); ii++) {
260 for (
unsigned int jj = 0; jj != diff_base.size2(); jj++) {
261 if (fabs(diff_base(ii, jj)) <
eps)
262 diff_base(ii, jj) = 0;
265 os <<
"N: " << std::fixed << base << std::endl
266 <<
"diffN: " << std::fixed << diff_base;
271 for (EntityType
t = MBVERTEX;
t != MBMAXTYPE; ++
t) {
273 os <<
"dataOnEntities[" << moab::CN::EntityTypeName(
t) <<
"][" << nn
287EntitiesFieldData::EntData::getFTensor1FieldData<3>() {
289 for (
auto &d : dOfs) {
291 if (d->getNbOfCoeffs() != 3) {
293 s <<
"Wrong number of coefficients is " << d->getNbOfCoeffs();
294 s <<
" but you ask for tensor rank 1 dimension 3";
301 double *ptr = &*fieldData.data().begin();
308EntitiesFieldData::EntData::getFTensor1FieldData<2>() {
310 for (
auto &d : dOfs) {
312 if (
d->getNbOfCoeffs() != 2) {
314 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
315 s <<
" but you ask for tensor rank 1 dimension 2";
322 double *ptr = &*fieldData.data().begin();
328EntitiesFieldData::EntData::getFTensor1FieldData<1>() {
330 for (
auto &d : dOfs) {
332 if (
d->getNbOfCoeffs() != 1) {
334 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
335 s <<
" but you ask for tensor rank 1 dimension 1";
342 double *ptr = &*fieldData.data().begin();
348EntitiesFieldData::EntData::getFTensor2FieldData<1, 1>() {
350 for (
auto &d : dOfs) {
352 if (
d->getNbOfCoeffs() != 1) {
354 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
355 s <<
" but you ask for tensor rank 2 dimensions 1 by 1 so 1 "
364 double *ptr = &*fieldData.data().begin();
370EntitiesFieldData::EntData::getFTensor2FieldData<1, 2>() {
372 for (
auto &d : dOfs) {
374 if (
d->getNbOfCoeffs() != 2) {
376 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
377 s <<
" but you ask for tensor rank 2 dimensions 1 by 2 so 2 "
386 double *ptr = &*fieldData.data().begin();
392EntitiesFieldData::EntData::getFTensor2FieldData<1, 3>() {
394 for (
auto &d : dOfs) {
396 if (
d->getNbOfCoeffs() != 3) {
398 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
399 s <<
" but you ask for tensor rank 2 dimensions 1 by 3 so 3 "
408 double *ptr = &*fieldData.data().begin();
415EntitiesFieldData::EntData::getFTensor2FieldData<2, 2>() {
417 for(
auto &d : dOfs) {
419 if(
d->getNbOfCoeffs() != 4) {
421 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
422 s <<
" but you ask for tensor rank 2 dimensions 2 by 2 so 4 coefficients "
430 double *ptr = &*fieldData.data().begin();
432 ptr, &ptr[1], &ptr[2], &ptr[3]);
437EntitiesFieldData::EntData::getFTensor2FieldData<3, 3>() {
439 for (
auto &d : dOfs) {
441 if (
d->getNbOfCoeffs() != 9) {
443 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
444 s <<
" but you ask for tensor rank 2 dimensions 3 by 3 so 9 "
453 double *ptr = &*fieldData.data().begin();
455 ptr, &ptr[1], &ptr[2], &ptr[3], &ptr[4], &ptr[5], &ptr[6], &ptr[7],
461EntitiesFieldData::EntData::getFTensor2SymmetricFieldData<3>() {
463 for (
auto &d : dOfs) {
465 if (
d->getNbOfCoeffs() != 6) {
467 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
468 s <<
" but you ask for symmetric tensor rank 2 dimensions 3 by 3 so 6 "
477 double *ptr = &*fieldData.data().begin();
479 ptr, &ptr[1], &ptr[2], &ptr[3], &ptr[4], &ptr[5]);
484EntitiesFieldData::EntData::getFTensor2SymmetricFieldData<2>() {
486 for (
auto &d : dOfs) {
488 if (
d->getNbOfCoeffs() != 3) {
490 s <<
"Wrong number of coefficients is " <<
d->getNbOfCoeffs();
491 s <<
" but you ask for symmetric tensor rank 2 dimensions 2 by 2 so 3 "
500 double *ptr = &*fieldData.data().begin();
502 ptr, &ptr[1], &ptr[2]);
508 for (
auto &d : dOfs) {
510 if (d->getNbOfCoeffs() != 1) {
512 s <<
"Wrong number of coefficients is " << d->getNbOfCoeffs();
513 s <<
" but expected scalar field, tensor of rank 0";
521 &*fieldData.data().begin());
524template <
int Tensor_Dim>
529 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
534template <
int Tensor_Dim>
537 return getFTensor1DiffN<Tensor_Dim>(
bAse);
545EntitiesFieldData::EntData::getFTensor1DiffN<3>(
547 double *ptr = &*getDiffN(base).data().begin();
557EntitiesFieldData::EntData::getFTensor1DiffN<3>() {
558 return getFTensor1DiffN<3>(
bAse);
566EntitiesFieldData::EntData::getFTensor1DiffN<2>(
568 double *ptr = &*getDiffN(base).data().begin();
577EntitiesFieldData::EntData::getFTensor1DiffN<2>() {
578 return getFTensor1DiffN<2>(
bAse);
581template <
int Tensor_Dim>
584 const int gg,
const int bb) {
586 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
596EntitiesFieldData::EntData::getFTensor1DiffN<3>(
598 double *ptr = &getDiffN(base)(gg, 3 * bb);
608EntitiesFieldData::EntData::getFTensor1DiffN<3>(
const int gg,
const int bb) {
609 return getFTensor1DiffN<3>(
bAse, gg, bb);
617EntitiesFieldData::EntData::getFTensor1DiffN<2>(
619 double *ptr = &getDiffN(base)(gg, 2 * bb);
628EntitiesFieldData::EntData::getFTensor1DiffN<2>(
const int gg,
const int bb) {
629 return getFTensor1DiffN<2>(
bAse, gg, bb);
638template <
int Tensor_Dim>
642 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
647template <
int Tensor_Dim>
650 const int gg,
const int bb) {
652 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
657template <
int Tensor_Dim0,
int Tensor_Dim1>
659 Tensor_Dim0, Tensor_Dim1>
662 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
"x" << Tensor_Dim1
663 <<
" not implemented";
668template <
int Tensor_Dim0,
int Tensor_Dim1>
670 Tensor_Dim0, Tensor_Dim1>
672 const int gg,
const int bb) {
674 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
"x" << Tensor_Dim1
675 <<
" not implemented";
683 double *t_n_ptr = &*getN(base).
data().begin();
692 const int gg,
const int bb) {
693 double *t_n_ptr = &getN(base)(gg, 3 * bb);
701EntitiesFieldData::EntData::getFTensor2DiffN<3, 3>(
703 double *t_diff_n_ptr = &*getDiffN(base).
data().begin();
713 const int gg,
const int bb) {
714 double *t_diff_n_ptr = &getDiffN(base)(gg, 9 * bb);
723EntitiesFieldData::EntData::getFTensor2DiffN<3, 2>(
725 double *t_diff_n_ptr = &*getDiffN(base).data().begin();
734 const int gg,
const int bb) {
735 double *t_diff_n_ptr = &getDiffN(base)(gg, 6 * bb);
744 double *ptr = &(getN(base, BaseDerivatives::SecondDerivative))(0, 0);
759template <
int Tensor_Dim0,
int Tensor_Dim1>
761 Tensor_Dim0, Tensor_Dim1>
764 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
", " << Tensor_Dim1
765 <<
" not implemented";
768 Tensor_Dim0, Tensor_Dim1>();
774 double *t_n_ptr = &*(getN(base).data().begin());
786template <
int Tensor_Dim0,
int Tensor_Dim1>
788 Tensor_Dim0, Tensor_Dim1>
790 const int gg,
const int bb) {
792 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
", " << Tensor_Dim1
793 <<
" not implemented";
796 Tensor_Dim0, Tensor_Dim1>();
802 const int gg,
const int bb) {
803 double *t_n_ptr = &getN(base)(gg, 9 * bb);
815template <
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
818 Tensor_Dim0, Tensor_Dim1, Tensor_Dim2>
821 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
"x" << Tensor_Dim1
822 <<
"x" << Tensor_Dim2 <<
" not implemented";
827template <
int Tensor_Dim0,
int Tensor_Dim1,
int Tensor_Dim2>
829 Tensor_Dim0, Tensor_Dim1, Tensor_Dim2>
831 const int gg,
const int bb) {
833 s <<
"Template for tensor dimension " << Tensor_Dim0 <<
"x" << Tensor_Dim1
834 <<
" not implemented";
842 double *ptr = &*getDiffN(base).data().begin();
849 const int gg,
const int bb) {
850 double *ptr = &getDiffN(base)(gg, 27 * bb);
860boost::shared_ptr<MatrixInt> &
866boost::shared_ptr<MatrixDouble> &
874const boost::shared_ptr<MatrixDouble> &
883boost::shared_ptr<MatrixDouble> &
891const boost::shared_ptr<MatrixDouble> &
897std::map<std::string, boost::shared_ptr<MatrixInt>> &
899 return bbAlphaIndices;
902std::map<std::string, boost::shared_ptr<MatrixDouble>> &
907std::map<std::string, boost::shared_ptr<MatrixDouble>> &
912boost::shared_ptr<MatrixInt> &
914 return bbAlphaIndicesByOrder[o];
917boost::shared_ptr<MatrixDouble> &
919 return bbNByOrder[o];
922boost::shared_ptr<MatrixDouble> &
924 return bbDiffNByOrder[o];
927std::array<boost::shared_ptr<MatrixInt>,
930 return bbAlphaIndicesByOrder;
933std::array<boost::shared_ptr<MatrixDouble>,
939std::array<boost::shared_ptr<MatrixDouble>,
942 return bbDiffNByOrder;
945boost::shared_ptr<MatrixInt> &
948 return entDataPtr->getBBAlphaIndicesSharedPtr(
field_name);
951boost::shared_ptr<MatrixDouble> &
954 return entDataPtr->getBBNSharedPtr(
field_name);
957const boost::shared_ptr<MatrixDouble> &
960 return entDataPtr->getBBNSharedPtr(
field_name);
966boost::shared_ptr<MatrixDouble> &
969 return entDataPtr->getBBDiffNSharedPtr(
field_name);
975const boost::shared_ptr<MatrixDouble> &
978 return entDataPtr->getBBDiffNSharedPtr(
field_name);
984 return entDataBitRefLevel;
987std::vector<BitRefLevel> &
989 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.