v0.15.0
Loading...
Searching...
No Matches
EntitiesFieldData.cpp
Go to the documentation of this file.
1/** \file EntitiesFieldData.cpp
2\brief Implementation for Data Structures in Forces and Sources
3
4*/
5
6
7
8namespace MoFEM {
9
10EntitiesFieldData::EntData::EntData(const bool allocate_base_matrices)
11 : sEnse(0), oRder(0), bAse(NOBASE), entDataBitRefLevel(),
12 N(baseFunctionsAndBaseDerivatives[ZeroDerivative]),
13 diffN(baseFunctionsAndBaseDerivatives[FirstDerivative]) {
14 if (allocate_base_matrices) {
15
16 for (auto d = 0; d != LastDerivative; ++d) {
17 for (int b = 0; b != LASTBASE; ++b) {
19 }
20 }
21 }
22}
23
24int EntitiesFieldData::EntData::getSense() const { return sEnse; }
25
26boost::shared_ptr<MatrixDouble> &
28 const BaseDerivatives direvatie) {
29 return baseFunctionsAndBaseDerivatives[direvatie][base];
30}
31
32boost::shared_ptr<MatrixDouble> &
36
37boost::shared_ptr<MatrixDouble> &EntitiesFieldData::EntData::getDiffNSharedPtr(
38 const FieldApproximationBase base) {
39 return diffN[base];
40}
41
42static void constructor_data(EntitiesFieldData *data, const EntityType type) {
43
45
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);
50 data->dataOnEntities[MBVERTEX].resize(1);
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;
57 }
58 for (auto tt = moab::CN::TypeDimensionMap[dd].first;
59 tt <= moab::CN::TypeDimensionMap[dd].second; ++tt) {
60 data->dataOnEntities[tt].resize(count[tt]);
61 }
62 }
63 }
64 };
65
66 switch (type) {
67 case MBENTITYSET:
68 break;
69
70 default:
71 set_default();
72 }
73}
74
76 constructor_data(this, type);
77}
78
84
85static void
87 const boost::shared_ptr<EntitiesFieldData> &data_ptr) {
88
90 using DerivedEntData = DerivedEntitiesFieldData::DerivedEntData;
91
92 for (int tt = MBVERTEX; tt != MBMAXTYPE; ++tt) {
93 auto &ent_data = data_ptr->dataOnEntities[tt];
94 auto &derived_ent_data = derived_data->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));
98 }
99 derived_ent_data.resize(ent_data.size());
100 }
101}
102
104 const boost::shared_ptr<EntitiesFieldData> &data_ptr)
105 : EntitiesFieldData(), dataPtr(data_ptr) {
107}
108
114
117 sPace = NOSPACE;
118 bAse = NOBASE;
119 fieldEntities.resize(0, false);
120 iNdices.resize(0, false);
121 localIndices.resize(0, false);
122 dOfs.resize(0, false);
123 fieldData.resize(0, false);
125}
126
129 for (EntityType t = MBVERTEX; t != MBMAXTYPE; t++)
130 for (auto &e : dataOnEntities[t])
131 CHKERR e.resetFieldDependentData();
133}
134
137 const FieldApproximationBase base) {
139 auto make_swap = [](boost::shared_ptr<MatrixDouble> &ptr,
140 boost::shared_ptr<MatrixDouble> &ptrBB,
141 boost::shared_ptr<MatrixDouble> &swap_ptr) {
142 if (swap_ptr) {
143 ptr = swap_ptr;
144 swap_ptr.reset();
145 } else {
146 swap_ptr = ptr;
147 ptr = ptrBB;
148 }
149 };
150 make_swap(getNSharedPtr(base), getBBNSharedPtr(field_name), swapBaseNPtr);
151 make_swap(getDiffNSharedPtr(base), getBBDiffNSharedPtr(field_name),
152 swapBaseDiffNPtr);
154}
155
157 const FieldApproximationBase base) {
159 // Note: Do not swap bases on entities sets
160 for (int tt = MBVERTEX; tt != MBENTITYSET; ++tt) {
161 auto &ent_data = dataOnEntities[tt];
162 for (auto &side_data : ent_data)
163 CHKERR side_data.baseSwap(field_name, base);
164 }
166}
167
169 const std::string &field_name, const FieldApproximationBase base) {
171 auto make_swap = [](boost::shared_ptr<MatrixDouble> &ptr,
172 boost::shared_ptr<MatrixDouble> &ptrBB,
173 boost::shared_ptr<MatrixDouble> &swap_ptr) {
174 if (swap_ptr) {
175 ptr = swap_ptr;
176 swap_ptr.reset();
177 } else {
178 swap_ptr = ptr;
179 ptr = ptrBB;
180 }
181 };
182 make_swap(getDerivedNSharedPtr(base), getBBNSharedPtr(field_name),
183 swapBaseNPtr);
184 make_swap(getDerivedDiffNSharedPtr(base), getBBDiffNSharedPtr(field_name),
185 swapBaseDiffNPtr);
187}
188
190 const boost::shared_ptr<EntitiesFieldData::EntData> &ent_data_ptr)
191 : EntitiesFieldData::EntData(false), entDataPtr(ent_data_ptr) {}
192
194 return entDataPtr->getSense();
195}
196
197boost::shared_ptr<MatrixDouble> &
199 const FieldApproximationBase base, const BaseDerivatives derivative) {
200 if (baseFunctionsAndBaseDerivatives[derivative][base])
201 return baseFunctionsAndBaseDerivatives[derivative][base];
202 else
203 return entDataPtr->getNSharedPtr(base, derivative);
204}
205
206boost::shared_ptr<MatrixDouble> &
208 const FieldApproximationBase base) {
209 if (N[base])
210 return N[base];
211 else
212 return entDataPtr->getNSharedPtr(base);
213}
214
215boost::shared_ptr<MatrixDouble> &
217 const FieldApproximationBase base) {
218 if (diffN[base])
219 return diffN[base];
220 else
221 return entDataPtr->getDiffNSharedPtr(base);
222}
223const boost::shared_ptr<MatrixDouble> &
225 const FieldApproximationBase base) const {
226 if (N[base])
227 return N[base];
228 else
229 return entDataPtr->getNSharedPtr(base);
230}
231const boost::shared_ptr<MatrixDouble> &
233 const FieldApproximationBase base) const {
234 if (diffN[base])
235 return diffN[base];
236 else
237 return entDataPtr->getDiffNSharedPtr(base);
238}
239
240std::ostream &operator<<(std::ostream &os,
242 os << "sEnse: " << e.getSense() << std::endl
243 << "oRder: " << e.getOrder() << std::endl
244 << "global indices: " << e.getIndices() << std::endl
245 << "local indices: " << e.getLocalIndices() << std::endl;
246 // FIXME: precision should not be set here
247 os << "fieldData: " << std::fixed << std::setprecision(2) << e.getFieldData()
248 << std::endl;
249 MatrixDouble base = const_cast<EntitiesFieldData::EntData &>(e).getN();
250 MatrixDouble diff_base =
251 const_cast<EntitiesFieldData::EntData &>(e).getDiffN();
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)
256 base(ii, jj) = 0;
257 }
258 }
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;
263 }
264 }
265 os << "N: " << std::fixed << base << std::endl
266 << "diffN: " << std::fixed << diff_base;
267 return os;
268}
269
270std::ostream &operator<<(std::ostream &os, const EntitiesFieldData &e) {
271 for (EntityType t = MBVERTEX; t != MBMAXTYPE; ++t) {
272 for (unsigned int nn = 0; nn < e.dataOnEntities[t].size(); nn++) {
273 os << "dataOnEntities[" << moab::CN::EntityTypeName(t) << "][" << nn
274 << "]" << std::endl
275 << e.dataOnEntities[t][nn] << std::endl;
276 }
277 }
278 return os;
279}
280
281/** \name Specializations for H1/L2 */
282
283/**@{*/
284
285template <>
287EntitiesFieldData::EntData::getFTensor1FieldData<3>() {
288#ifndef NDEBUG
289 for (auto &d : dOfs) {
290 if (d) {
291 if (d->getNbOfCoeffs() != 3) {
292 std::stringstream s;
293 s << "Wrong number of coefficients is " << d->getNbOfCoeffs();
294 s << " but you ask for tensor rank 1 dimension 3";
296 }
297 break;
298 }
299 }
300#endif
301 double *ptr = &*fieldData.data().begin();
303 &ptr[2]);
304}
305
306template <>
308EntitiesFieldData::EntData::getFTensor1FieldData<2>() {
309#ifndef NDEBUG
310 for (auto &d : dOfs) {
311 if (d) {
312 if (d->getNbOfCoeffs() != 2) {
313 std::stringstream s;
314 s << "Wrong number of coefficients is " << d->getNbOfCoeffs();
315 s << " but you ask for tensor rank 1 dimension 2";
317 }
318 break;
319 }
320 }
321#endif
322 double *ptr = &*fieldData.data().begin();
323 return FTensor::Tensor1<FTensor::PackPtr<double *, 2>, 2>(ptr, &ptr[1]);
324}
325
326template <>
328EntitiesFieldData::EntData::getFTensor1FieldData<1>() {
329#ifndef NDEBUG
330 for (auto &d : dOfs) {
331 if (d) {
332 if (d->getNbOfCoeffs() != 1) {
333 std::stringstream s;
334 s << "Wrong number of coefficients is " << d->getNbOfCoeffs();
335 s << " but you ask for tensor rank 1 dimension 1";
337 }
338 break;
339 }
340 }
341#endif
342 double *ptr = &*fieldData.data().begin();
344}
345
346template <>
348EntitiesFieldData::EntData::getFTensor2FieldData<1, 1>() {
349#ifndef NDEBUG
350 for (auto &d : dOfs) {
351 if (d) {
352 if (d->getNbOfCoeffs() != 1) {
353 std::stringstream s;
354 s << "Wrong number of coefficients is " << d->getNbOfCoeffs();
355 s << " but you ask for tensor rank 2 dimensions 1 by 1 so 1 "
356 "coefficients "
357 "is expected";
359 }
360 break;
361 }
362 }
363#endif
364 double *ptr = &*fieldData.data().begin();
366}
367
368template <>
370EntitiesFieldData::EntData::getFTensor2FieldData<1, 2>() {
371#ifndef NDEBUG
372 for (auto &d : dOfs) {
373 if (d) {
374 if (d->getNbOfCoeffs() != 2) {
375 std::stringstream s;
376 s << "Wrong number of coefficients is " << d->getNbOfCoeffs();
377 s << " but you ask for tensor rank 2 dimensions 1 by 2 so 2 "
378 "coefficients "
379 "is expected";
381 }
382 break;
383 }
384 }
385#endif
386 double *ptr = &*fieldData.data().begin();
387 return FTensor::Tensor2<FTensor::PackPtr<double *, 2>, 1, 2>(ptr, &ptr[1]);
388}
389
390template <>
392EntitiesFieldData::EntData::getFTensor2FieldData<1, 3>() {
393#ifndef NDEBUG
394 for (auto &d : dOfs) {
395 if (d) {
396 if (d->getNbOfCoeffs() != 3) {
397 std::stringstream s;
398 s << "Wrong number of coefficients is " << d->getNbOfCoeffs();
399 s << " but you ask for tensor rank 2 dimensions 1 by 3 so 3 "
400 "coefficients "
401 "is expected";
403 }
404 break;
405 }
406 }
407#endif
408 double *ptr = &*fieldData.data().begin();
409 return FTensor::Tensor2<FTensor::PackPtr<double *, 3>, 1, 3>(ptr, &ptr[1],
410 &ptr[2]);
411}
412
413template <>
415EntitiesFieldData::EntData::getFTensor2FieldData<2, 2>() {
416#ifndef NDEBUG
417 for(auto &d : dOfs) {
418 if(d) {
419 if(d->getNbOfCoeffs() != 4) {
420 std::stringstream s;
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 "
423 "is expected";
425 }
426 break;
427 }
428 }
429#endif
430 double *ptr = &*fieldData.data().begin();
432 ptr, &ptr[1], &ptr[2], &ptr[3]);
433}
434
435template <>
437EntitiesFieldData::EntData::getFTensor2FieldData<3, 3>() {
438#ifndef NDEBUG
439 for (auto &d : dOfs) {
440 if (d) {
441 if (d->getNbOfCoeffs() != 9) {
442 std::stringstream s;
443 s << "Wrong number of coefficients is " << d->getNbOfCoeffs();
444 s << " but you ask for tensor rank 2 dimensions 3 by 3 so 9 "
445 "coefficients "
446 "is expected";
448 }
449 break;
450 }
451 }
452#endif
453 double *ptr = &*fieldData.data().begin();
455 ptr, &ptr[1], &ptr[2], &ptr[3], &ptr[4], &ptr[5], &ptr[6], &ptr[7],
456 &ptr[8]);
457}
458
459template <>
461EntitiesFieldData::EntData::getFTensor2SymmetricFieldData<3>() {
462#ifndef NDEBUG
463 for (auto &d : dOfs) {
464 if (d) {
465 if (d->getNbOfCoeffs() != 6) {
466 std::stringstream s;
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 "
469 "coefficients "
470 "is expected";
472 }
473 break;
474 }
475 }
476#endif
477 double *ptr = &*fieldData.data().begin();
479 ptr, &ptr[1], &ptr[2], &ptr[3], &ptr[4], &ptr[5]);
480}
481
482template <>
484EntitiesFieldData::EntData::getFTensor2SymmetricFieldData<2>() {
485#ifndef NDEBUG
486 for (auto &d : dOfs) {
487 if (d) {
488 if (d->getNbOfCoeffs() != 3) {
489 std::stringstream s;
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 "
492 "coefficients "
493 "is expected";
495 }
496 break;
497 }
498 }
499#endif
500 double *ptr = &*fieldData.data().begin();
502 ptr, &ptr[1], &ptr[2]);
503}
504
507#ifndef NDEBUG
508 for (auto &d : dOfs) {
509 if (d) {
510 if (d->getNbOfCoeffs() != 1) {
511 std::stringstream s;
512 s << "Wrong number of coefficients is " << d->getNbOfCoeffs();
513 s << " but expected scalar field, tensor of rank 0";
515 }
516 break;
517 }
518 }
519#endif
521 &*fieldData.data().begin());
522}
523
524template <int Tensor_Dim>
527 const FieldApproximationBase base) {
528 std::stringstream s;
529 s << "Template for tensor dimension " << Tensor_Dim << " not implemented";
530 THROW_MESSAGE(s.str());
532}
533
534template <int Tensor_Dim>
537 return getFTensor1DiffN<Tensor_Dim>(bAse);
538}
539
540/**
541 * \brief Get spatial derivative of base function tensor for dimension 3d
542 */
543template <>
545EntitiesFieldData::EntData::getFTensor1DiffN<3>(
546 const FieldApproximationBase base) {
547 double *ptr = &*getDiffN(base).data().begin();
549 &ptr[2]);
550}
551
552/**
553 * \brief Get spatial derivative of base function tensor for dimension 3d
554 */
555template <>
557EntitiesFieldData::EntData::getFTensor1DiffN<3>() {
558 return getFTensor1DiffN<3>(bAse);
559}
560
561/**
562 * \brief Get spatial derivative of base function tensor for dimension 2d
563 */
564template <>
566EntitiesFieldData::EntData::getFTensor1DiffN<2>(
567 const FieldApproximationBase base) {
568 double *ptr = &*getDiffN(base).data().begin();
569 return FTensor::Tensor1<FTensor::PackPtr<double *, 2>, 2>(ptr, &ptr[1]);
570}
571
572/**
573 * \brief Get spatial derivative of base function tensor for dimension 2d
574 */
575template <>
577EntitiesFieldData::EntData::getFTensor1DiffN<2>() {
578 return getFTensor1DiffN<2>(bAse);
579}
580
581template <int Tensor_Dim>
584 const int gg, const int bb) {
585 std::stringstream s;
586 s << "Template for tensor dimension " << Tensor_Dim << " not implemented";
587 THROW_MESSAGE(s.str());
589}
590
591/**
592 * \brief Get spatial derivative of base function tensor for dimension 3d
593 */
594template <>
596EntitiesFieldData::EntData::getFTensor1DiffN<3>(
597 const FieldApproximationBase base, const int gg, const int bb) {
598 double *ptr = &getDiffN(base)(gg, 3 * bb);
600 &ptr[2]);
601}
602
603/**
604 * \brief Get spatial derivative of base function tensor for dimension 3d
605 */
606template <>
608EntitiesFieldData::EntData::getFTensor1DiffN<3>(const int gg, const int bb) {
609 return getFTensor1DiffN<3>(bAse, gg, bb);
610}
611
612/**
613 * \brief Get spatial derivative of base function tensor for dimension 2d
614 */
615template <>
617EntitiesFieldData::EntData::getFTensor1DiffN<2>(
618 const FieldApproximationBase base, const int gg, const int bb) {
619 double *ptr = &getDiffN(base)(gg, 2 * bb);
620 return FTensor::Tensor1<FTensor::PackPtr<double *, 2>, 2>(ptr, &ptr[1]);
621}
622
623/**
624 * \brief Get spatial derivative of base function tensor for dimension 2d
625 */
626template <>
628EntitiesFieldData::EntData::getFTensor1DiffN<2>(const int gg, const int bb) {
629 return getFTensor1DiffN<2>(bAse, gg, bb);
630}
631
632/**@}*/
633
634/** \name Specializations for HDiv/HCrul */
635
636/**@{*/
637
638template <int Tensor_Dim>
641 std::stringstream s;
642 s << "Template for tensor dimension " << Tensor_Dim << " not implemented";
643 THROW_MESSAGE(s.str());
645}
646
647template <int Tensor_Dim>
650 const int gg, const int bb) {
651 std::stringstream s;
652 s << "Template for tensor dimension " << Tensor_Dim << " not implemented";
653 THROW_MESSAGE(s.str());
655}
656
657template <int Tensor_Dim0, int Tensor_Dim1>
659 Tensor_Dim0, Tensor_Dim1>
661 std::stringstream s;
662 s << "Template for tensor dimension " << Tensor_Dim0 << "x" << Tensor_Dim1
663 << " not implemented";
664 THROW_MESSAGE(s.str());
666}
667
668template <int Tensor_Dim0, int Tensor_Dim1>
670 Tensor_Dim0, Tensor_Dim1>
672 const int gg, const int bb) {
673 std::stringstream s;
674 s << "Template for tensor dimension " << Tensor_Dim0 << "x" << Tensor_Dim1
675 << " not implemented";
676 THROW_MESSAGE(s.str());
678}
679
680template <>
682EntitiesFieldData::EntData::getFTensor1N<3>(FieldApproximationBase base) {
683 double *t_n_ptr = &*getN(base).data().begin();
684 return FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3>(t_n_ptr, // HVEC0
685 &t_n_ptr[HVEC1],
686 &t_n_ptr[HVEC2]);
687}
688
689template <>
691EntitiesFieldData::EntData::getFTensor1N<3>(FieldApproximationBase base,
692 const int gg, const int bb) {
693 double *t_n_ptr = &getN(base)(gg, 3 * bb);
694 return FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3>(t_n_ptr, // HVEC0
695 &t_n_ptr[HVEC1],
696 &t_n_ptr[HVEC2]);
697}
698
699template <>
701EntitiesFieldData::EntData::getFTensor2DiffN<3, 3>(
703 double *t_diff_n_ptr = &*getDiffN(base).data().begin();
705 t_diff_n_ptr, &t_diff_n_ptr[HVEC0_1], &t_diff_n_ptr[HVEC0_2],
706 &t_diff_n_ptr[HVEC1_0], &t_diff_n_ptr[HVEC1_1], &t_diff_n_ptr[HVEC1_2],
707 &t_diff_n_ptr[HVEC2_0], &t_diff_n_ptr[HVEC2_1], &t_diff_n_ptr[HVEC2_2]);
708}
709
710template <>
712EntitiesFieldData::EntData::getFTensor2DiffN<3, 3>(FieldApproximationBase base,
713 const int gg, const int bb) {
714 double *t_diff_n_ptr = &getDiffN(base)(gg, 9 * bb);
716 t_diff_n_ptr, &t_diff_n_ptr[HVEC0_1], &t_diff_n_ptr[HVEC0_2],
717 &t_diff_n_ptr[HVEC1_0], &t_diff_n_ptr[HVEC1_1], &t_diff_n_ptr[HVEC1_2],
718 &t_diff_n_ptr[HVEC2_0], &t_diff_n_ptr[HVEC2_1], &t_diff_n_ptr[HVEC2_2]);
719}
720
721template <>
723EntitiesFieldData::EntData::getFTensor2DiffN<3, 2>(
725 double *t_diff_n_ptr = &*getDiffN(base).data().begin();
727 t_diff_n_ptr, &t_diff_n_ptr[HVEC0_1], &t_diff_n_ptr[HVEC1_0],
728 &t_diff_n_ptr[HVEC1_1], &t_diff_n_ptr[HVEC2_0], &t_diff_n_ptr[HVEC2_1]);
729}
730
731template <>
733EntitiesFieldData::EntData::getFTensor2DiffN<3, 2>(FieldApproximationBase base,
734 const int gg, const int bb) {
735 double *t_diff_n_ptr = &getDiffN(base)(gg, 6 * bb);
737 t_diff_n_ptr, &t_diff_n_ptr[HVEC0_1], &t_diff_n_ptr[HVEC1_0],
738 &t_diff_n_ptr[HVEC1_1], &t_diff_n_ptr[HVEC2_0], &t_diff_n_ptr[HVEC2_1]);
739}
740
741template <>
744 double *ptr = &(getN(base, BaseDerivatives::SecondDerivative))(0, 0);
746
747 &ptr[2 * HVEC0_0 + 0], &ptr[2 * HVEC0_0 + 1], &ptr[2 * HVEC0_1 + 0],
748 &ptr[2 * HVEC0_1 + 1],
749
750 &ptr[2 * HVEC1_0 + 0], &ptr[2 * HVEC1_0 + 1], &ptr[2 * HVEC1_1 + 0],
751 &ptr[2 * HVEC1_1 + 1],
752
753 &ptr[2 * HVEC2_0 + 0], &ptr[2 * HVEC2_0 + 1], &ptr[2 * HVEC2_1 + 0],
754 &ptr[2 * HVEC2_1 + 1]
755
756 };
757}
758
759template <int Tensor_Dim0, int Tensor_Dim1>
761 Tensor_Dim0, Tensor_Dim1>
763 std::stringstream s;
764 s << "Template for tensor dimension " << Tensor_Dim0 << ", " << Tensor_Dim1
765 << " not implemented";
766 THROW_MESSAGE(s.str());
768 Tensor_Dim0, Tensor_Dim1>();
769}
770
771template <>
773EntitiesFieldData::EntData::getFTensor2N<3, 3>(FieldApproximationBase base) {
774 double *t_n_ptr = &*(getN(base).data().begin());
776
777 &t_n_ptr[HVEC0], &t_n_ptr[HVEC1], &t_n_ptr[HVEC2],
778
779 &t_n_ptr[3 + HVEC0], &t_n_ptr[3 + HVEC1], &t_n_ptr[3 + HVEC2],
780
781 &t_n_ptr[6 + HVEC0], &t_n_ptr[6 + HVEC1], &t_n_ptr[6 + HVEC2]
782
783 );
784}
785
786template <int Tensor_Dim0, int Tensor_Dim1>
788 Tensor_Dim0, Tensor_Dim1>
790 const int gg, const int bb) {
791 std::stringstream s;
792 s << "Template for tensor dimension " << Tensor_Dim0 << ", " << Tensor_Dim1
793 << " not implemented";
794 THROW_MESSAGE(s.str());
796 Tensor_Dim0, Tensor_Dim1>();
797}
798
799template <>
801EntitiesFieldData::EntData::getFTensor2N<3, 3>(FieldApproximationBase base,
802 const int gg, const int bb) {
803 double *t_n_ptr = &getN(base)(gg, 9 * bb);
805
806 &t_n_ptr[HVEC0], &t_n_ptr[HVEC1], &t_n_ptr[HVEC2],
807
808 &t_n_ptr[3 + HVEC0], &t_n_ptr[3 + HVEC1], &t_n_ptr[3 + HVEC2],
809
810 &t_n_ptr[6 + HVEC0], &t_n_ptr[6 + HVEC1], &t_n_ptr[6 + HVEC2]
811
812 );
813}
814
815template <int Tensor_Dim0, int Tensor_Dim1, int Tensor_Dim2>
818 Tensor_Dim0, Tensor_Dim1, Tensor_Dim2>
820 std::stringstream s;
821 s << "Template for tensor dimension " << Tensor_Dim0 << "x" << Tensor_Dim1
822 << "x" << Tensor_Dim2 << " not implemented";
823 THROW_MESSAGE(s.str());
825}
826
827template <int Tensor_Dim0, int Tensor_Dim1, int Tensor_Dim2>
829 Tensor_Dim0, Tensor_Dim1, Tensor_Dim2>
831 const int gg, const int bb) {
832 std::stringstream s;
833 s << "Template for tensor dimension " << Tensor_Dim0 << "x" << Tensor_Dim1
834 << " not implemented";
835 THROW_MESSAGE(s.str());
837}
838
839template <>
842 double *ptr = &*getDiffN(base).data().begin();
843 return getFTensor3FromPtr<3, 3, 3>(ptr);
844};
845
846template <>
849 const int gg, const int bb) {
850 double *ptr = &getDiffN(base)(gg, 27 * bb);
851 return getFTensor3FromPtr<3, 3, 3>(ptr);
852};
853
854/**@}*/
855
856/** \name Bernstein-Bezier base only functions */
857
858/**@{*/
859
860boost::shared_ptr<MatrixInt> &
862 const std::string &field_name) {
863 return bbAlphaIndices[field_name];
864}
865
866boost::shared_ptr<MatrixDouble> &
868 return bbN[field_name];
869}
870
871/**
872 * Get shared pointer to BB base base functions
873 */
874const boost::shared_ptr<MatrixDouble> &
876 const std::string &field_name) const {
877 return bbN.at(field_name);
878}
879
880/**
881 * Get shared pointer to BB derivatives of base base functions
882 */
883boost::shared_ptr<MatrixDouble> &
885 return bbDiffN[field_name];
886}
887
888/**
889 * Get shared pointer to derivatives of BB base base functions
890 */
891const boost::shared_ptr<MatrixDouble> &
893 const std::string &field_name) const {
894 return bbDiffN.at(field_name);
895}
896
897std::map<std::string, boost::shared_ptr<MatrixInt>> &
899 return bbAlphaIndices;
900}
901
902std::map<std::string, boost::shared_ptr<MatrixDouble>> &
906
907std::map<std::string, boost::shared_ptr<MatrixDouble>> &
909 return bbDiffN;
910}
911
912boost::shared_ptr<MatrixInt> &
914 return bbAlphaIndicesByOrder[o];
915}
916
917boost::shared_ptr<MatrixDouble> &
919 return bbNByOrder[o];
920}
921
922boost::shared_ptr<MatrixDouble> &
924 return bbDiffNByOrder[o];
925}
926
927std::array<boost::shared_ptr<MatrixInt>,
930 return bbAlphaIndicesByOrder;
931}
932
933std::array<boost::shared_ptr<MatrixDouble>,
938
939std::array<boost::shared_ptr<MatrixDouble>,
942 return bbDiffNByOrder;
943}
944
945boost::shared_ptr<MatrixInt> &
947 const std::string &field_name) {
948 return entDataPtr->getBBAlphaIndicesSharedPtr(field_name);
949}
950
951boost::shared_ptr<MatrixDouble> &
953 const std::string &field_name) {
954 return entDataPtr->getBBNSharedPtr(field_name);
955}
956
957const boost::shared_ptr<MatrixDouble> &
959 const std::string &field_name) const {
960 return entDataPtr->getBBNSharedPtr(field_name);
961}
962
963/**
964 * Get shared pointer to BB derivatives of base base functions
965 */
966boost::shared_ptr<MatrixDouble> &
968 const std::string &field_name) {
969 return entDataPtr->getBBDiffNSharedPtr(field_name);
970}
971
972/**
973 * Get shared pointer to derivatives of BB base base functions
974 */
975const boost::shared_ptr<MatrixDouble> &
977 const std::string &field_name) const {
978 return entDataPtr->getBBDiffNSharedPtr(field_name);
979}
980
981/**@}*/
982
984 return entDataBitRefLevel;
985}
986
987std::vector<BitRefLevel> &
989 return entDataPtr->getEntDataBitRefLevel();
990}
991
992
993} // namespace MoFEM
static const double eps
T data[Tensor_Dim]
T data[Tensor_Dim0][Tensor_Dim1]
FieldApproximationBase
approximation base
Definition definitions.h:58
@ LASTBASE
Definition definitions.h:69
@ NOBASE
Definition definitions.h:59
#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()
@ NOSPACE
Definition definitions.h:83
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ HVEC0
@ HVEC1
@ HVEC2
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ HVEC1_1
@ HVEC0_1
@ HVEC1_0
@ HVEC2_1
@ HVEC1_2
@ HVEC2_2
@ HVEC2_0
@ HVEC0_2
@ HVEC0_0
#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
Definition Types.hpp:77
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
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
Definition plate.cpp:58
constexpr auto field_name
const int N
Definition speed_test.cpp:3
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()
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
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.
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.