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) {
26 boost::shared_ptr<MatrixDouble> &
29 return baseFunctionsAndBaseDerivatives[direvatie][base];
32 boost::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();
197 boost::shared_ptr<MatrixDouble> &
200 if (baseFunctionsAndBaseDerivatives[derivative][base])
201 return baseFunctionsAndBaseDerivatives[derivative][base];
203 return entDataPtr->getNSharedPtr(base, derivative);
206 boost::shared_ptr<MatrixDouble> &
212 return entDataPtr->getNSharedPtr(base);
215 boost::shared_ptr<MatrixDouble> &
221 return entDataPtr->getDiffNSharedPtr(base);
223 const boost::shared_ptr<MatrixDouble> &
229 return entDataPtr->getNSharedPtr(base);
231 const 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
287 EntitiesFieldData::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();
308 EntitiesFieldData::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();
328 EntitiesFieldData::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();
348 EntitiesFieldData::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();
370 EntitiesFieldData::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();
392 EntitiesFieldData::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();
415 EntitiesFieldData::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]);
437 EntitiesFieldData::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],
461 EntitiesFieldData::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]);
484 EntitiesFieldData::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());
524 template <
int Tensor_Dim>
529 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
534 template <
int Tensor_Dim>
537 return getFTensor1DiffN<Tensor_Dim>(
bAse);
545 EntitiesFieldData::EntData::getFTensor1DiffN<3>(
547 double *ptr = &*getDiffN(base).data().begin();
557 EntitiesFieldData::EntData::getFTensor1DiffN<3>() {
558 return getFTensor1DiffN<3>(
bAse);
566 EntitiesFieldData::EntData::getFTensor1DiffN<2>(
568 double *ptr = &*getDiffN(base).data().begin();
577 EntitiesFieldData::EntData::getFTensor1DiffN<2>() {
578 return getFTensor1DiffN<2>(
bAse);
581 template <
int Tensor_Dim>
584 const int gg,
const int bb) {
586 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
596 EntitiesFieldData::EntData::getFTensor1DiffN<3>(
598 double *ptr = &getDiffN(base)(gg, 3 * bb);
608 EntitiesFieldData::EntData::getFTensor1DiffN<3>(
const int gg,
const int bb) {
609 return getFTensor1DiffN<3>(
bAse, gg, bb);
617 EntitiesFieldData::EntData::getFTensor1DiffN<2>(
619 double *ptr = &getDiffN(base)(gg, 2 * bb);
628 EntitiesFieldData::EntData::getFTensor1DiffN<2>(
const int gg,
const int bb) {
629 return getFTensor1DiffN<2>(
bAse, gg, bb);
638 template <
int Tensor_Dim>
642 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
647 template <
int Tensor_Dim>
650 const int gg,
const int bb) {
652 s <<
"Template for tensor dimension " << Tensor_Dim <<
" not implemented";
657 template <
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";
668 template <
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);
701 EntitiesFieldData::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);
723 EntitiesFieldData::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);
759 template <
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());
786 template <
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);
821 boost::shared_ptr<MatrixInt> &
827 boost::shared_ptr<MatrixDouble> &
835 const boost::shared_ptr<MatrixDouble> &
844 boost::shared_ptr<MatrixDouble> &
852 const boost::shared_ptr<MatrixDouble> &
858 std::map<std::string, boost::shared_ptr<MatrixInt>> &
860 return bbAlphaIndices;
863 std::map<std::string, boost::shared_ptr<MatrixDouble>> &
868 std::map<std::string, boost::shared_ptr<MatrixDouble>> &
873 boost::shared_ptr<MatrixInt> &
875 return bbAlphaIndicesByOrder[o];
878 boost::shared_ptr<MatrixDouble> &
880 return bbNByOrder[o];
883 boost::shared_ptr<MatrixDouble> &
885 return bbDiffNByOrder[o];
888 std::array<boost::shared_ptr<MatrixInt>,
891 return bbAlphaIndicesByOrder;
894 std::array<boost::shared_ptr<MatrixDouble>,
900 std::array<boost::shared_ptr<MatrixDouble>,
903 return bbDiffNByOrder;
906 boost::shared_ptr<MatrixInt> &
909 return entDataPtr->getBBAlphaIndicesSharedPtr(
field_name);
912 boost::shared_ptr<MatrixDouble> &
915 return entDataPtr->getBBNSharedPtr(
field_name);
918 const boost::shared_ptr<MatrixDouble> &
921 return entDataPtr->getBBNSharedPtr(
field_name);
927 boost::shared_ptr<MatrixDouble> &
930 return entDataPtr->getBBDiffNSharedPtr(
field_name);
936 const boost::shared_ptr<MatrixDouble> &
939 return entDataPtr->getBBDiffNSharedPtr(
field_name);
945 return entDataBitRefLevel;
948 std::vector<BitRefLevel> &
950 return entDataPtr->getEntDataBitRefLevel();