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)
194 return entDataPtr->getSense();
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
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();
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();
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();
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();
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();
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();
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]);
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],
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]);
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);
547 double *ptr = &*getDiffN(base).data().begin();
558 return getFTensor1DiffN<3>(
bAse);
568 double *ptr = &*getDiffN(base).data().begin();
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";
598 double *ptr = &getDiffN(base)(gg, 3 * bb);
609 return getFTensor1DiffN<3>(
bAse, gg, bb);
619 double *ptr = &getDiffN(base)(gg, 2 * 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);
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);
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);
821boost::shared_ptr<MatrixInt> &
827boost::shared_ptr<MatrixDouble> &
835const boost::shared_ptr<MatrixDouble> &
844boost::shared_ptr<MatrixDouble> &
852const boost::shared_ptr<MatrixDouble> &
858std::map<std::string, boost::shared_ptr<MatrixInt>> &
860 return bbAlphaIndices;
863std::map<std::string, boost::shared_ptr<MatrixDouble>> &
868std::map<std::string, boost::shared_ptr<MatrixDouble>> &
873boost::shared_ptr<MatrixInt> &
875 return bbAlphaIndicesByOrder[o];
878boost::shared_ptr<MatrixDouble> &
880 return bbNByOrder[o];
883boost::shared_ptr<MatrixDouble> &
885 return bbDiffNByOrder[o];
888std::array<boost::shared_ptr<MatrixInt>,
891 return bbAlphaIndicesByOrder;
894std::array<boost::shared_ptr<MatrixDouble>,
900std::array<boost::shared_ptr<MatrixDouble>,
903 return bbDiffNByOrder;
906boost::shared_ptr<MatrixInt> &
909 return entDataPtr->getBBAlphaIndicesSharedPtr(
field_name);
912boost::shared_ptr<MatrixDouble> &
915 return entDataPtr->getBBNSharedPtr(
field_name);
918const boost::shared_ptr<MatrixDouble> &
921 return entDataPtr->getBBNSharedPtr(
field_name);
927boost::shared_ptr<MatrixDouble> &
930 return entDataPtr->getBBDiffNSharedPtr(
field_name);
936const boost::shared_ptr<MatrixDouble> &
939 return entDataPtr->getBBDiffNSharedPtr(
field_name);
945 return entDataBitRefLevel;
948std::vector<BitRefLevel> &
950 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)
constexpr double t
plate stiffness
constexpr auto field_name
Derived ata 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 temporally pointer.
std::vector< BitRefLevel > & getEntDataBitRefLevel()
int getSense() const
get entity sense, need to calculate base functions with 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)
DerivedEntData(const boost::shared_ptr< EntitiesFieldData::EntData > &ent_data_ptr)
boost::shared_ptr< MatrixDouble > & getNSharedPtr(const FieldApproximationBase base, const BaseDerivatives derivative)
this class derive data form other data structure
MoFEMErrorCode setElementType(const EntityType type)
const boost::shared_ptr< EntitiesFieldData > dataPtr
DerivedEntitiesFieldData(const boost::shared_ptr< EntitiesFieldData > &data_ptr)
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)
virtual boost::shared_ptr< MatrixInt > & getBBAlphaIndicesSharedPtr(const std::string &field_name)
const VectorDouble & getFieldData() const
get dofs values
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 dofs on entity
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1FieldData()
Return FTensor of rank 1, i.e. vector from field data coefficients.
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()
virtual int getSense() const
get entity sense, need to calculate base functions with conforming approximation fields
VectorFieldEntities fieldEntities
Field entities.
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0FieldData()
Resturn 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::Tensor2_symmetric< FTensor::PackPtr< double *,(Tensor_Dim *(Tensor_Dim+1))/2 >, Tensor_Dim > getFTensor2SymmetricFieldData()
Return symmetric FTensor rank 2, i.e. matrix from field data coefficients.
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)
FTensor::Tensor2< FTensor::PackPtr< double *, Tensor_Dim0 *Tensor_Dim1 >, Tensor_Dim0, Tensor_Dim1 > getFTensor2FieldData()
Return FTensor rank 2, i.e. matrix from field data coefficients.
virtual boost::shared_ptr< MatrixDouble > & getBBNByOrderSharedPtr(const size_t o)
get BB base by order
const VectorInt & getIndices() const
Get global indices of dofs on entity.
EntData(const bool allocate_base_matrices=true)
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()
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)