v0.15.5
Loading...
Searching...
No Matches
NaturalMeshsetType.hpp
Go to the documentation of this file.
1/**
2 * @file NaturalMeshsetType.hpp
3 * @brief Specialisation for NaturalMeshsetType
4 * @version 0.13.2
5 * @date 2022-09-18
6 *
7 * @copyright Copyright (c) 2022
8 *
9 */
10
11#ifndef _NATURAL_MESHSET_TYPE_HPP_
12#define _NATURAL_MESHSET_TYPE_HPP_
13
14namespace MoFEM {
15
16/**
17 * @brief Type generating natural b.c. specialisations for meshsets
18 *
19 * @tparam BCTYP
20 */
21template <CubitBC BCTYP> struct NaturalMeshsetType {};
22template <CubitBC BCTYP> struct NaturalMeshsetPressureType {};
23
24/** Evaluate boundary integral on the right hand side*/
25template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
27 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, FIELD_DIM, A, I,
28 OpBase> {
29
31 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
32 std::vector<boost::shared_ptr<ScalingMethod>> smv,
33 ScalarFun user_fun = [](double, double, double) { return 1; });
34
35protected:
36 /**
37 * @brief Extract information stored on meshset (BLOCKSET)
38 *
39 * @param m_field
40 * @param ms_id
41 * @return MoFEMErrorCode
42 */
43 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
44};
45
46template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
48 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, FIELD_DIM, A, I,
49 OpBase> {
50
52 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
53 std::vector<boost::shared_ptr<ScalingMethod>> smv,
54 ScalarFun user_fun = [](double, double, double) { return 1; });
55
56 using Parent =
59
60protected:
61 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
62};
63
64template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
66 OpBase> : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1,
67 FIELD_DIM, A, I, OpBase> {
68
69 using Parent =
72
74 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
75 std::vector<boost::shared_ptr<ScalingMethod>> smv,
76 ScalarFun user_fun = [](double, double, double) { return 1; });
77
78protected:
80 MoFEM::Interface &m_field, const std::string field_name,
81 std::vector<boost::shared_ptr<ScalingMethod>> smv,
82 ScalarFun user_fun = [](double, double, double) { return 1; });
83
85 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
88};
89
90template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
92 OpBase> : OpFluxRhsImpl<NaturalMeshsetType<PRESSURESET>, 1,
93 FIELD_DIM, A, I, OpBase> {
94
96 I, OpBase>;
98
100 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
101 std::vector<boost::shared_ptr<ScalingMethod>> smv,
102 ScalarFun user_fun = [](double, double, double) { return 1; });
103
104protected:
105
106
107 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
108};
109
110/**
111 * @brief Base class for OpFluxRhsImpl<NaturalMeshsetType<T>, 1, FIELD_DIM, A,
112 I, OpBase>
113 *
114 * This is only for scalar bases.
115 *
116 * @note It is derivitive from FormsIntegrators<OpBase>::template
117 Assembly<A>::template LinearForm< I>::template OpSource<1, FIELD_DIM>
118 *
119 * @tparam FIELD_DIM field dimension
120 * @tparam A
121 * @tparam I
122 * @tparam OpBase Base element operator for integration volume, face, edge, or
123 vertex
124 */
125template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
127 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
128 I>::template OpSource<1, FIELD_DIM> {
129
132
134 const std::string field_name, FTensor::Tensor1<double, FIELD_DIM> t_force,
135 boost::shared_ptr<Range> ents_ptr,
136 std::vector<boost::shared_ptr<ScalingMethod>> smv,
137 ScalarFun user_fun = [](double, double, double) { return 1; });
138
139protected:
141 const std::string field_name,
142 std::vector<boost::shared_ptr<ScalingMethod>> smv,
143 ScalarFun user_fun = [](double, double, double) { return 1; });
148};
149
150template <AssemblyType A, IntegrationType I, typename OpBase>
152 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
153 I>::template OpSource<1, 1> {
154
157
159 const std::string field_name, double value,
160 boost::shared_ptr<Range> ents_ptr,
161 std::vector<boost::shared_ptr<ScalingMethod>> smv,
162 ScalarFun user_fun = [](double, double, double) { return 1; });
163
164protected:
166 const std::string field_name,
167 std::vector<boost::shared_ptr<ScalingMethod>> smv,
168 ScalarFun user_fun = [](double, double, double) { return 1; });
169
171
172 double scalarValue = 0;
174
176};
177
178template <AssemblyType A, IntegrationType I, typename OpBase>
180 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
181
182 using Parent =
184
186 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
187 std::vector<boost::shared_ptr<ScalingMethod>> smv,
188 ScalarFun user_fun = [](double, double, double) { return 1; });
189
190protected:
191 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
192};
193
194template <AssemblyType A, IntegrationType I, typename OpBase>
196 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
197
198 using Parent =
200
202 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
203 std::vector<boost::shared_ptr<ScalingMethod>> smv,
204 ScalarFun user_fun = [](double, double, double) { return 1; });
205
206protected:
207 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
208};
209
210template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
212 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
213 I>::template OpNormalMixVecTimesScalar<FIELD_DIM> {
214
216 A>::template LinearForm<I>::template OpNormalMixVecTimesScalar<FIELD_DIM>;
217
219 const std::string field_name, const double value,
220 boost::shared_ptr<Range> ents_ptr,
221 std::vector<boost::shared_ptr<ScalingMethod>> smv,
222 ScalarFun user_fun = [](double, double, double) { return 1; });
223
224protected:
226 const std::string field_name,
227 std::vector<boost::shared_ptr<ScalingMethod>> smv,
228 ScalarFun user_fun = [](double, double, double) { return 1; });
232};
233
234template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
236 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 3, FIELD_DIM, A, I,
237 OpBase> {
239 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
240 std::vector<boost::shared_ptr<ScalingMethod>> smv,
241 ScalarFun user_fun = [](double, double, double) { return 1; });
242
243protected:
244 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
245};
246
247template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
249 OpBase> : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 3,
250 FIELD_DIM, A, I, OpBase> {
252 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
253 std::vector<boost::shared_ptr<ScalingMethod>> smv,
254 ScalarFun user_fun = [](double, double, double) { return 1; });
255
256protected:
257 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
258};
259
260template <CubitBC BCTYP> struct NaturalMeshsetTypeVectorScaling {};
261
262template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
264 I, OpBase>
265 : OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<UNKNOWNSET>, 1, FIELD_DIM,
266 A, I, OpBase> {
267
269 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
270 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
271 ScalarFun user_fun = [](double, double, double) { return 1; });
272
273protected:
274 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
275};
276
277template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
279 A, I, OpBase>
280 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
281 I>::template OpSource<1, FIELD_DIM> {
282
285
287 const std::string field_name, FTensor::Tensor1<double, FIELD_DIM> t_force,
288 boost::shared_ptr<Range> ents_ptr,
289 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
290 ScalarFun user_fun = [](double, double, double) { return 1; });
291
292protected:
294 const std::string field_name,
295 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
296 ScalarFun user_fun = [](double, double, double) { return 1; });
297
301};
302
303// Definitions
304
305template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
307 OpFluxRhsImpl(const std::string field_name,
309 boost::shared_ptr<Range> ents_ptr,
310 std::vector<boost::shared_ptr<ScalingMethod>> smv,
311 ScalarFun user_fun)
312 : OpFluxRhsImpl(field_name, smv, user_fun) {
314 this->tForce(i) = t_force(i);
315 this->entsPtr = ents_ptr;
316}
317
318template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
320 OpFluxRhsImpl(const std::string field_name,
321 std::vector<boost::shared_ptr<ScalingMethod>> smv,
322 ScalarFun user_fun)
324
325 [this](const double x, const double y, const double z) {
327 tScaledForce(i) = tForce(i) * userFun(x, y, z);
328 return tScaledForce;
329 }
330
331 ),
332 vecOfTimeScalingMethods(smv), userFun(user_fun) {
333 this->timeScalingFun = [this](const double t) {
334 double s = 1;
335 for (auto &o : vecOfTimeScalingMethods) {
336 s *= o->getScale(t);
337 }
338 return s;
339 };
340
341 static_assert(FIELD_DIM > 1, "Not implemented for scalar field");
342}
343
344template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
346 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
347 const std::string field_name,
348 std::vector<boost::shared_ptr<ScalingMethod>> smv,
349 ScalarFun user_fun)
351 field_name, smv, user_fun) {
352 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
353}
354
355template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
357 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
358 int ms_id) {
360
361 auto cubit_meshset_ptr =
362 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
363 NODESET);
364
365 ForceCubitBcData bc_data;
366 CHKERR cubit_meshset_ptr->getBcDataStructure(bc_data);
367
368 this->tForce(0) = bc_data.data.value3;
369 if constexpr (FIELD_DIM > 1)
370 this->tForce(1) = bc_data.data.value4;
371 if constexpr (FIELD_DIM > 2)
372 this->tForce(2) = bc_data.data.value5;
373
375 this->tForce(i) *= bc_data.data.value1;
376
377 this->entsPtr = boost::make_shared<Range>();
378 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
379 *(this->entsPtr), true);
380
382}
383
384template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
386 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
387 const std::string field_name,
388 std::vector<boost::shared_ptr<ScalingMethod>> smv,
389 ScalarFun user_fun)
391 field_name, smv, user_fun) {
392 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
393}
394
395template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
397 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
398 int ms_id) {
400
401 auto cubit_meshset_ptr =
402 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
403 BLOCKSET);
404
405 std::vector<double> block_data;
406 CHKERR cubit_meshset_ptr->getAttributes(block_data);
407
408 if (block_data.size() != FIELD_DIM) {
409 MOFEM_LOG("SELF", Sev::warning)
410 << "BLOCKSET is expected to have " << FIELD_DIM
411 << " attributes but has size " << block_data.size();
412 if (block_data.size() < FIELD_DIM) {
413 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
414 "Size of attribute in BLOCKSET is too small");
415 }
416 }
417
418 for (unsigned int ii = 0; ii != FIELD_DIM; ++ii) {
419 this->tForce(ii) = block_data[ii];
420 }
421
422 MOFEM_LOG("WORLD", Sev::inform)
423 << "Flux blockset " << cubit_meshset_ptr->getName();
424 MOFEM_LOG("WORLD", Sev::inform)
425 << "Number of attributes " << block_data.size();
426
427 this->entsPtr = boost::make_shared<Range>();
428 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
429 *(this->entsPtr), true);
430
431 MOFEM_LOG("WORLD", Sev::inform)
432 << "tForce vector initialised: " << this->tForce;
433 MOFEM_LOG("WORLD", Sev::inform)
434 << "Number of elements " << this->entsPtr->size();
435
437}
438
439template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
441 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
442 const std::string field_name,
443 std::vector<boost::shared_ptr<ScalingMethod>> smv,
444 ScalarFun user_fun)
446 field_name, smv, user_fun) {
447 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
448}
449
450template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
452 OpFluxRhsImpl(MoFEM::Interface &m_field, const std::string field_name,
453 std::vector<boost::shared_ptr<ScalingMethod>> smv,
454 ScalarFun user_fun)
456 field_name, smv, user_fun) {}
457
458template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
462
463 auto t_normal = this->getFTensor1Normal();
465
466 this->sourceFun = [&](const double, const double, const double) {
467 this->tForce(i) = t_normal(i);
468 this->tForce.normalize();
469 this->tForce(i) *= this->surfacePressure;
470 return this->tForce;
471 };
472
473 CHKERR Parent::iNtegrate(data);
475}
476
477template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
480 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
482
483 auto cubit_meshset_ptr =
484 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
485 SIDESET);
486
487 PressureCubitBcData pressure_data;
488 CHKERR cubit_meshset_ptr->getBcDataStructure(pressure_data);
489 this->surfacePressure = pressure_data.data.value1;
490
491 this->entsPtr = boost::make_shared<Range>();
492 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
493 *(this->entsPtr), true);
494 MOFEM_LOG("WORLD", Sev::inform)
495 << "Pressure blockset from PRESSURESET ms_id = " << ms_id;
496 MOFEM_LOG("WORLD", Sev::inform)
497 << "Number of elements " << this->entsPtr->size();
499}
500
501template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
504 OpBase>::OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
505 const std::string field_name,
506 std::vector<boost::shared_ptr<ScalingMethod>> smv,
507 ScalarFun user_fun)
508 : Parent(m_field, field_name, smv, user_fun) {
509 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
510}
511
512template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
515 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
517
518 auto cubit_meshset_ptr =
519 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
520 BLOCKSET);
521
522 std::vector<double> block_data;
523 CHKERR cubit_meshset_ptr->getAttributes(block_data);
524
525 MOFEM_LOG("SELF", Sev::warning)
526 << "BLOCKSET is expected to have " << FIELD_DIM
527 << " attributes but has size " << block_data.size();
528 if (block_data.size() != 1) {
529 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
530 "Size of attribute in BLOCKSET is too small");
531 }
532 this->surfacePressure = block_data[0];
533
534 MOFEM_LOG("WORLD", Sev::inform)
535 << "Pressure blockset " << cubit_meshset_ptr->getName();
536
537 this->entsPtr = boost::make_shared<Range>();
538 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
539 *(this->entsPtr), true);
540 MOFEM_LOG("WORLD", Sev::inform)
541 << "Number of elements " << this->entsPtr->size();
542
544}
545
546template <AssemblyType A, IntegrationType I, typename OpBase>
548 OpFluxRhsImpl(const std::string field_name, const double value,
549 boost::shared_ptr<Range> ents_ptr,
550 std::vector<boost::shared_ptr<ScalingMethod>> smv,
551 ScalarFun user_fun)
552 : OpFluxRhsImpl(field_name, smv, user_fun) {
553 this->scalarValue = value;
554 this->entsPtr = ents_ptr;
555}
556
557template <AssemblyType A, IntegrationType I, typename OpBase>
559 OpFluxRhsImpl(const std::string field_name,
560 std::vector<boost::shared_ptr<ScalingMethod>> smv,
561 ScalarFun user_fun)
563
564 [this](const double x, const double y, const double z) {
565 return scalarValue * userFun(x, y, z);
566 }
567
568 ),
569 vecOfTimeScalingMethods(smv), userFun(user_fun) {
570
571 this->timeScalingFun = [this](const double t) {
572 double s = 1;
573 for (auto &o : vecOfTimeScalingMethods) {
574 s *= o->getScale(t);
575 }
576 return s;
577 };
578}
579
580template <AssemblyType A, IntegrationType I, typename OpBase>
582 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
583 std::vector<boost::shared_ptr<ScalingMethod>> smv, ScalarFun user_fun)
585 field_name, smv, user_fun) {
586 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
587}
588
589template <AssemblyType A, IntegrationType I, typename OpBase>
592 MoFEM::Interface &m_field, int ms_id) {
594
595 auto cubit_meshset_ptr =
596 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
597 BLOCKSET);
598 std::vector<double> block_data;
599 CHKERR cubit_meshset_ptr->getAttributes(block_data);
600 if (block_data.size() != 1) {
601 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
602 "Expected that block has one attribute, e.g. heat flux value");
603 }
604 this->scalarValue = block_data[0];
605
606 this->entsPtr = boost::make_shared<Range>();
607 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
608 *(this->entsPtr), true);
609
610 MOFEM_LOG("WORLD", Sev::inform)
611 << "Flux blockset " << cubit_meshset_ptr->getName();
612 MOFEM_LOG("WORLD", Sev::inform)
613 << "Scalar attribute value: " << this->scalarValue;
614
616}
617
618template <AssemblyType A, IntegrationType I, typename OpBase>
620 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
621 const std::string field_name,
622 std::vector<boost::shared_ptr<ScalingMethod>> smv,
623 ScalarFun user_fun)
625 field_name, smv, user_fun) {
626 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
627}
628
629template <AssemblyType A, IntegrationType I, typename OpBase>
631 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
632 int ms_id) {
634
635 auto cubit_meshset_ptr =
636 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
637 SIDESET);
638 HeatFluxCubitBcData heat_flux;
639 CHKERR cubit_meshset_ptr->getBcDataStructure(heat_flux);
640 this->scalarValue = heat_flux.data.value1;
641
642 this->entsPtr = boost::make_shared<Range>();
643 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
644 *(this->entsPtr), true);
645
647}
648
649template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
651 OpFluxRhsImpl(const std::string field_name, const double value,
652 boost::shared_ptr<Range> ents_ptr,
653 std::vector<boost::shared_ptr<ScalingMethod>> smv,
654 ScalarFun user_fun)
655 : OpFluxRhsImpl(field_name, smv) {
656 this->scalarValue = value;
657 this->entsPtr = ents_ptr;
658}
659
660template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
662 OpFluxRhsImpl(const std::string field_name,
663 std::vector<boost::shared_ptr<ScalingMethod>> smv,
664 ScalarFun user_fun)
666
667 [this](const double x, const double y, const double z) {
668 return scalarValue * userFun(x, y, z);
669 }
670
671 ),
672 vecOfTimeScalingMethods(smv), userFun(user_fun) {
673
674 this->timeScalingFun = [this](const double t) {
675 double s = 1;
676 for (auto &o : vecOfTimeScalingMethods) {
677 s *= o->getScale(t);
678 }
679 return s;
680 };
681}
682
683template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
685 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
686 const std::string field_name,
687 std::vector<boost::shared_ptr<ScalingMethod>> smv,
688 ScalarFun user_fun)
690 field_name, smv, user_fun) {
691 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
692}
693
694template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
696 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
697 int ms_id) {
699
700 auto cubit_meshset_ptr =
701 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
702 BLOCKSET);
703 std::vector<double> attr_vec;
704 cubit_meshset_ptr->getAttributes(attr_vec);
705 if (attr_vec.size() != 1)
706 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "Should be one attribute");
707 this->scalarValue = attr_vec[0];
708
709 this->entsPtr = boost::make_shared<Range>();
710 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
711 *(this->entsPtr), true);
712
714}
715
716template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
718 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
719 const std::string field_name,
720 std::vector<boost::shared_ptr<ScalingMethod>> smv,
721 ScalarFun user_fun)
723 field_name, smv, user_fun) {
724 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
725}
726
727template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
730 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
732
733 auto cubit_meshset_ptr =
734 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
735 NODESET);
736
738 CHKERR cubit_meshset_ptr->getBcDataStructure(mydata);
739 this->scalarValue = mydata.data.value1;
740
741 this->entsPtr = boost::make_shared<Range>();
742 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
743 *(this->entsPtr), true);
744
746}
747
748/**
749 * @brief Function to push operators to rhs pipeline. This function user API.
750 *
751 * @tparam BCTYPE
752 * @tparam BASE_DIM
753 * @tparam FIELD_DIM
754 * @tparam A
755 * @tparam I
756 * @tparam OpBase
757 */
758template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
761 OpFluxRhsImpl(
762 const std::string field_name,
764 boost::shared_ptr<Range> ents_ptr,
765 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
766 ScalarFun user_fun)
767 : OpFluxRhsImpl(field_name, smv, user_fun) {
769 this->tForce(i) = t_force(i);
770 this->entsPtr = ents_ptr;
771}
772
773template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
776 OpFluxRhsImpl(
777 const std::string field_name,
778 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
779 ScalarFun user_fun)
781 [this](double x, double y, double z) {
783 auto t = this->getFEMethod()->ts_t;
784 for (auto &o : vecOfTimeVectorScalingMethods) {
785 auto vec = o->getVector(t);
786 this->tForce(i) = vec(i) * userFun(x, y, z);
787 }
788 return this->tForce;
789 }),
790 vecOfTimeVectorScalingMethods(smv), userFun(user_fun) {
791
792 static_assert(FIELD_DIM > 1, "Not implemented for scalar field");
793}
794
795template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
796OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<BLOCKSET>, 1, FIELD_DIM, A, I,
798 OpFluxRhsImpl(
799 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
800 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
801 ScalarFun user_fun)
803 A, I, OpBase>(field_name, smv, user_fun) {
804 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
805}
806
807template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
810 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
812
813 auto cubit_meshset_ptr =
814 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
815 BLOCKSET);
816
817 std::vector<double> block_data;
818 CHKERR cubit_meshset_ptr->getAttributes(block_data);
819 if (block_data.size() != FIELD_DIM) {
820 MOFEM_LOG("SELF", Sev::warning)
821 << "BLOCKSET is expected to have " << FIELD_DIM
822 << " attributes but has size " << block_data.size();
823 if (block_data.size() < FIELD_DIM) {
824
825 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
826 "Size of attribute in BLOCKSET is too small");
827 }
828 }
829
830 for (unsigned int ii = 0; ii != FIELD_DIM; ++ii) {
831 this->tForce(ii) = block_data[ii];
832 }
833
834 MOFEM_LOG("WORLD", Sev::inform)
835 << "Flux blockset " << cubit_meshset_ptr->getName();
836 MOFEM_LOG("WORLD", Sev::inform)
837 << "Number of attributes " << block_data.size();
838 MOFEM_LOG("WORLD", Sev::inform)
839 << "tForce vector initialised: " << this->tForce;
840
841 this->entsPtr = boost::make_shared<Range>();
842 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
843 *(this->entsPtr), true);
844
846}
847
848template <CubitBC BCTYPE, int BASE_DIM, int FIELD_DIM, AssemblyType A,
849 IntegrationType I, typename OpBase>
851
853 OpBase>,
854 A, I, OpBase
855
856 > {
857
859
861
862 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
863 MoFEM::Interface &m_field, const std::string field_name,
864 std::vector<boost::shared_ptr<ScalingMethod>> smv, std::string block_name,
865 ScalarFun user_fun, Sev sev
866
867 ) {
869
870 using OP = typename NaturalBC<OpBase>::template Assembly<
873
874 auto add_op = [&](auto &&meshset_vec_ptr) {
875 for (auto m : meshset_vec_ptr) {
876 MOFEM_TAG_AND_LOG("WORLD", sev, "OpFlux") << "Add " << *m;
877 pipeline.push_back(
878 new OP(m_field, m->getMeshsetId(), field_name, smv, user_fun));
879 }
880 MOFEM_LOG_CHANNEL("WORLD");
881 };
882
883 switch (BCTYPE) {
884 case TEMPERATURESET:
885 case FORCESET:
887 NODESET | BCTYPE));
888 case PRESSURESET:
889 case HEATFLUXSET:
891 SIDESET | BCTYPE));
892 break;
893 case BLOCKSET:
894 add_op(
895
897 std::regex(
898
899 (boost::format("%s(.*)") % block_name).str()
900
901 ))
902
903 );
904
905 break;
906 default:
907 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
908 "Handling of bc type not implemented");
909 break;
910 }
912 }
913
914 static MoFEMErrorCode
915 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
916 MoFEM::Interface &m_field, const std::string field_name,
917 std::vector<boost::shared_ptr<ScalingMethod>> smv,
918 std::string block_name, Sev sev) {
919 return add(
920 pipeline, m_field, field_name, smv, block_name,
921 [](double, double, double) { return 1; }, sev);
922 }
923};
924
925template <CubitBC BCTYPE, int BASE_DIM, int FIELD_DIM, AssemblyType A,
926 IntegrationType I, typename OpBase>
928
930 OpBase>,
931 A, I, OpBase
932
933 > {
934
936
938
939 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
940 MoFEM::Interface &m_field, const std::string field_name,
941 std::vector<boost::shared_ptr<ScalingMethod>> smv, std::string block_name,
942 ScalarFun user_fun, Sev sev
943
944 ) {
946
947 using OPV =
948 typename NaturalBC<OpBase>::template Assembly<A>::template LinearForm<
950 FIELD_DIM>;
951
952 auto add_opv = [&](auto &&meshset_vec_ptr) {
953 for (auto m : meshset_vec_ptr) {
954 MOFEM_TAG_AND_LOG("WORLD", sev, "OpFlux") << "Add " << *m;
955 pipeline.push_back(
956 new OPV(m_field, m->getMeshsetId(), field_name, smv, user_fun));
957 }
958 MOFEM_LOG_CHANNEL("WORLD");
959 };
960
961 switch (BCTYPE) {
962 case BLOCKSET:
963 add_opv(
964
966 std::regex(
967
968 (boost::format("%s(.*)") % block_name).str()
969
970 ))
971
972 );
973
974 break;
975 default:
976 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
977 "Handling of bc type not implemented");
978 break;
979 }
981 }
982
983 static MoFEMErrorCode
984 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
985 MoFEM::Interface &m_field, const std::string field_name,
986 std::vector<boost::shared_ptr<ScalingMethod>> smv, std::string block_name,
987 Sev sev) {
988 return add(
989 pipeline, m_field, field_name, smv, block_name,
990 [](double, double, double) { return 1; }, sev);
991 }
992};
993
994template <CubitBC BCTYPE, int BASE_DIM, int FIELD_DIM, AssemblyType A,
995 IntegrationType I, typename OpBase>
997
999 A, I, OpBase>,
1000 A, I, OpBase
1001
1002 > {
1003
1005
1007
1008 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
1009 MoFEM::Interface &m_field, const std::string field_name,
1010 std::vector<boost::shared_ptr<ScalingMethod>> smv,
1011 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> vsmv,
1012 std::string block_name, ScalarFun user_fun, Sev sev
1013
1014 ) {
1016
1017 using OPV =
1018 typename NaturalBC<OpBase>::template Assembly<A>::template LinearForm<
1021
1022 auto add_opv = [&](auto &&meshset_vec_ptr) {
1023 for (auto m : meshset_vec_ptr) {
1024 MOFEM_TAG_AND_LOG("WORLD", sev, "OpFlux") << "Add " << *m;
1025 pipeline.push_back(
1026 new OPV(m_field, m->getMeshsetId(), field_name, vsmv, user_fun));
1027 }
1028 MOFEM_LOG_CHANNEL("WORLD");
1029 };
1030
1031 switch (BCTYPE) {
1032 case BLOCKSET:
1033 add_opv(
1034
1036 std::regex(
1037
1038 (boost::format("%s(.*)") % block_name).str()
1039
1040 ))
1041
1042 );
1043
1044 break;
1045 default:
1046 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1047 "Handling of bc type not implemented");
1048 break;
1049 }
1051 }
1052
1053 static MoFEMErrorCode
1054 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
1055 MoFEM::Interface &m_field, const std::string field_name,
1056 std::vector<boost::shared_ptr<ScalingMethod>> smv,
1057 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> vsmv,
1058 std::string block_name, Sev sev) {
1059 return add(
1060 pipeline, m_field, field_name, smv, vsmv, block_name,
1061 [](double, double, double) { return 1; }, sev);
1062 }
1063};
1064
1065} // namespace MoFEM
1066
1067#endif //_NATURAL_MESHSET_TYPE_HPP_
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
constexpr int FIELD_DIM
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
CubitBC
Types of sets and boundary conditions.
@ TEMPERATURESET
@ PRESSURESET
@ FORCESET
@ HEATFLUXSET
@ NODESET
@ SIDESET
@ UNKNOWNSET
@ BLOCKSET
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_INVALID_DATA
Definition definitions.h:36
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int BASE_DIM
IntegrationType
Form integrator integration types.
boost::function< double(const double, const double, const double)> ScalarFun
Scalar function type.
AssemblyType
[Storage and set boundary conditions]
#define MOFEM_LOG(channel, severity)
Log.
SeverityLevel
Severity levels.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
FTensor::Index< 'i', SPACE_DIM > i
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
std::vector< boost::shared_ptr< TimeScaleVector< FIELD_DIM > > > VecOfTimeVectorScalingMethods
Vector of time vector scaling methods.
Definition Natural.hpp:28
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data)
std::vector< boost::shared_ptr< ScalingMethod > > VecOfTimeScalingMethods
Vector of time scaling methods.
Definition Natural.hpp:20
MoFEM::OpBrokenTopoBase OP
constexpr IntegrationType I
constexpr AssemblyType A
constexpr double t
plate stiffness
Definition plate.cpp:58
constexpr auto field_name
FTensor::Index< 'm', 3 > m
static MoFEMErrorCode add(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, MoFEM::Interface &m_field, const std::string field_name, std::vector< boost::shared_ptr< ScalingMethod > > smv, std::string block_name, Sev sev)
static MoFEMErrorCode add(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, MoFEM::Interface &m_field, const std::string field_name, std::vector< boost::shared_ptr< ScalingMethod > > smv, std::string block_name, ScalarFun user_fun, Sev sev)
static MoFEMErrorCode add(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, MoFEM::Interface &m_field, const std::string field_name, std::vector< boost::shared_ptr< ScalingMethod > > smv, std::vector< boost::shared_ptr< TimeScaleVector< FIELD_DIM > > > vsmv, std::string block_name, Sev sev)
static MoFEMErrorCode add(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, MoFEM::Interface &m_field, const std::string field_name, std::vector< boost::shared_ptr< ScalingMethod > > smv, std::vector< boost::shared_ptr< TimeScaleVector< FIELD_DIM > > > vsmv, std::string block_name, ScalarFun user_fun, Sev sev)
static MoFEMErrorCode add(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, MoFEM::Interface &m_field, const std::string field_name, std::vector< boost::shared_ptr< ScalingMethod > > smv, std::string block_name, ScalarFun user_fun, Sev sev)
static MoFEMErrorCode add(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, MoFEM::Interface &m_field, const std::string field_name, std::vector< boost::shared_ptr< ScalingMethod > > smv, std::string block_name, Sev sev)
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
Definition of the force bc data structure.
Definition BCData.hpp:135
Definition of the heat flux bc data structure.
Definition BCData.hpp:423
Interface for managing meshsets containing materials and boundary conditions.
Natural boundary conditions.
Definition Natural.hpp:57
Type generating natural b.c. specialisations for meshsets.
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, FIELD_DIM > OpSource
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, 1 > OpSource
MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id)
Base class for OpFluxRhsImpl<NaturalMeshsetType<T>, 1, FIELD_DIM, A, I, OpBase>
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, FIELD_DIM > OpSource
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpNormalMixVecTimesScalar< FIELD_DIM > OpSource
Definition of the pressure bc data structure.
Definition BCData.hpp:375
Definition of the temperature bc data structure.
Definition BCData.hpp:302
Force scale operator for reading four columns (time and vector)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.