v0.15.4
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 {};
22
23/** Evaluate boundary integral on the right hand side*/
24template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
26 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, FIELD_DIM, A, I,
27 OpBase> {
28
30 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
31 std::vector<boost::shared_ptr<ScalingMethod>> smv,
32 ScalarFun user_fun = [](double, double, double) { return 1; });
33
34protected:
35 /**
36 * @brief Extract information stored on meshset (BLOCKSET)
37 *
38 * @param m_field
39 * @param ms_id
40 * @return MoFEMErrorCode
41 */
42 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
43};
44
45template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
47 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, FIELD_DIM, A, I,
48 OpBase> {
49
51 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
52 std::vector<boost::shared_ptr<ScalingMethod>> smv,
53 ScalarFun user_fun = [](double, double, double) { return 1; });
54
55 using Parent =
58
59protected:
60 MoFEMErrorCode iNtegrate(EntData &data);
61 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
64};
65
66template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
68 OpBase> : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1,
69 FIELD_DIM, A, I, OpBase> {
70
71 using Parent =
74
76 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
77 std::vector<boost::shared_ptr<ScalingMethod>> smv,
78 ScalarFun user_fun = [](double, double, double) { return 1; });
79
80protected:
81 MoFEMErrorCode iNtegrate(EntData &data);
82 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
85};
86
87/**
88 * @brief Base class for OpFluxRhsImpl<NaturalMeshsetType<T>, 1, FIELD_DIM, A,
89 I, OpBase>
90 *
91 * This is only for scalar bases.
92 *
93 * @note It is derivitive from FormsIntegrators<OpBase>::template
94 Assembly<A>::template LinearForm< I>::template OpSource<1, FIELD_DIM>
95 *
96 * @tparam FIELD_DIM field dimension
97 * @tparam A
98 * @tparam I
99 * @tparam OpBase Base element operator for integration volume, face, edge, or
100 vertex
101 */
102template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
104 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
105 I>::template OpSource<1, FIELD_DIM> {
106
109
111 const std::string field_name, FTensor::Tensor1<double, FIELD_DIM> t_force,
112 boost::shared_ptr<Range> ents_ptr,
113 std::vector<boost::shared_ptr<ScalingMethod>> smv,
114 ScalarFun user_fun = [](double, double, double) { return 1; });
115
116protected:
118 const std::string field_name,
119 std::vector<boost::shared_ptr<ScalingMethod>> smv,
120 ScalarFun user_fun = [](double, double, double) { return 1; });
125};
126
127template <AssemblyType A, IntegrationType I, typename OpBase>
129 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
130 I>::template OpSource<1, 1> {
131
134
136 const std::string field_name, double value,
137 boost::shared_ptr<Range> ents_ptr,
138 std::vector<boost::shared_ptr<ScalingMethod>> smv,
139 ScalarFun user_fun = [](double, double, double) { return 1; });
140
141protected:
143 const std::string field_name,
144 std::vector<boost::shared_ptr<ScalingMethod>> smv,
145 ScalarFun user_fun = [](double, double, double) { return 1; });
146
148
149 double scalarValue = 0;
151
153};
154
155template <AssemblyType A, IntegrationType I, typename OpBase>
157 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
158
159 using Parent =
161
163 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
164 std::vector<boost::shared_ptr<ScalingMethod>> smv,
165 ScalarFun user_fun = [](double, double, double) { return 1; });
166
167protected:
168 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
169};
170
171template <AssemblyType A, IntegrationType I, typename OpBase>
173 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
174
175 using Parent =
177
179 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
180 std::vector<boost::shared_ptr<ScalingMethod>> smv,
181 ScalarFun user_fun = [](double, double, double) { return 1; });
182
183protected:
184 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
185};
186
187template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
189 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
190 I>::template OpNormalMixVecTimesScalar<FIELD_DIM> {
191
193 A>::template LinearForm<I>::template OpNormalMixVecTimesScalar<FIELD_DIM>;
194
196 const std::string field_name, const double value,
197 boost::shared_ptr<Range> ents_ptr,
198 std::vector<boost::shared_ptr<ScalingMethod>> smv,
199 ScalarFun user_fun = [](double, double, double) { return 1; });
200
201protected:
203 const std::string field_name,
204 std::vector<boost::shared_ptr<ScalingMethod>> smv,
205 ScalarFun user_fun = [](double, double, double) { return 1; });
209};
210
211template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
213 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 3, FIELD_DIM, A, I,
214 OpBase> {
216 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
217 std::vector<boost::shared_ptr<ScalingMethod>> smv,
218 ScalarFun user_fun = [](double, double, double) { return 1; });
219
220protected:
221 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
222};
223
224template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
226 OpBase> : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 3,
227 FIELD_DIM, A, I, OpBase> {
229 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
230 std::vector<boost::shared_ptr<ScalingMethod>> smv,
231 ScalarFun user_fun = [](double, double, double) { return 1; });
232
233protected:
234 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
235};
236
237template <CubitBC BCTYP> struct NaturalMeshsetTypeVectorScaling {};
238
239template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
241 I, OpBase>
242 : OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<UNKNOWNSET>, 1, FIELD_DIM,
243 A, I, OpBase> {
244
246 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
247 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
248 ScalarFun user_fun = [](double, double, double) { return 1; });
249
250protected:
251 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
252};
253
254template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
256 A, I, OpBase>
257 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
258 I>::template OpSource<1, FIELD_DIM> {
259
262
264 const std::string field_name, FTensor::Tensor1<double, FIELD_DIM> t_force,
265 boost::shared_ptr<Range> ents_ptr,
266 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
267 ScalarFun user_fun = [](double, double, double) { return 1; });
268
269protected:
271 const std::string field_name,
272 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
273 ScalarFun user_fun = [](double, double, double) { return 1; });
274
278};
279
280// Definitions
281
282template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
284 OpFluxRhsImpl(const std::string field_name,
286 boost::shared_ptr<Range> ents_ptr,
287 std::vector<boost::shared_ptr<ScalingMethod>> smv,
288 ScalarFun user_fun)
289 : OpFluxRhsImpl(field_name, smv, user_fun) {
291 this->tForce(i) = t_force(i);
292 this->entsPtr = ents_ptr;
293}
294
295template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
297 OpFluxRhsImpl(const std::string field_name,
298 std::vector<boost::shared_ptr<ScalingMethod>> smv,
299 ScalarFun user_fun)
301
302 [this](const double x, const double y, const double z) {
304 tScaledForce(i) = tForce(i) * userFun(x, y, z);
305 return tScaledForce;
306 }
307
308 ),
309 vecOfTimeScalingMethods(smv), userFun(user_fun) {
310 this->timeScalingFun = [this](const double t) {
311 double s = 1;
312 for (auto &o : vecOfTimeScalingMethods) {
313 s *= o->getScale(t);
314 }
315 return s;
316 };
317
318 static_assert(FIELD_DIM > 1, "Not implemented for scalar field");
319}
320
321template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
323 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
324 const std::string field_name,
325 std::vector<boost::shared_ptr<ScalingMethod>> smv,
326 ScalarFun user_fun)
328 field_name, smv, user_fun) {
329 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
330}
331
332template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
334 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
335 int ms_id) {
337
338 auto cubit_meshset_ptr =
339 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
340 NODESET);
341
342 ForceCubitBcData bc_data;
343 CHKERR cubit_meshset_ptr->getBcDataStructure(bc_data);
344
345 this->tForce(0) = bc_data.data.value3;
346 if constexpr (FIELD_DIM > 1)
347 this->tForce(1) = bc_data.data.value4;
348 if constexpr (FIELD_DIM > 2)
349 this->tForce(2) = bc_data.data.value5;
350
352 this->tForce(i) *= bc_data.data.value1;
353
354 this->entsPtr = boost::make_shared<Range>();
355 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
356 *(this->entsPtr), true);
357
359}
360
361template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
363 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
364 const std::string field_name,
365 std::vector<boost::shared_ptr<ScalingMethod>> smv,
366 ScalarFun user_fun)
368 field_name, smv, user_fun), isPressure(false), surfacePressure(0.0) {
369 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
370}
371
372template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
374 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
375 int ms_id) {
377
378 auto cubit_meshset_ptr =
379 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
380 BLOCKSET);
381
382 std::vector<double> block_data;
383 CHKERR cubit_meshset_ptr->getAttributes(block_data);
384
385 this->isPressure =
386 cubit_meshset_ptr->getName().find("PRESSURE") != std::string::npos;
387 if (this->isPressure) {
388
389 if (block_data.empty())
390 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
391 "Size of attribute in BLOCKSET (PRESSURE) is empty");
392 this->surfacePressure = block_data[0];
393
394 } else {
395
396 if (block_data.size() != FIELD_DIM) {
397 MOFEM_LOG("SELF", Sev::warning)
398 << "BLOCKSET is expected to have " << FIELD_DIM
399 << " attributes but has size " << block_data.size();
400 if (block_data.size() < FIELD_DIM) {
401 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
402 "Size of attribute in BLOCKSET is too small");
403 }
404 }
405
406 for (unsigned int ii = 0; ii != FIELD_DIM; ++ii) {
407 this->tForce(ii) = block_data[ii];
408 }
409 }
410
411 MOFEM_LOG("WORLD", Sev::inform)
412 << "Flux blockset " << cubit_meshset_ptr->getName();
413 MOFEM_LOG("WORLD", Sev::inform)
414 << "Number of attributes " << block_data.size();
415
416 this->entsPtr = boost::make_shared<Range>();
417 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
418 *(this->entsPtr), true);
419
420 MOFEM_LOG("WORLD", Sev::inform)
421 << "tForce vector initialised: " << this->tForce;
422 MOFEM_LOG("WORLD", Sev::inform)
423 << "Number of elements " << this->entsPtr->size();
424
426}
427
428template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
430 I, OpBase>::iNtegrate(EntData &data) {
432
433 if constexpr (std::is_same<OpBase, MoFEM::FaceElementForcesAndSourcesCore::
434 UserDataOperator>::value) {
435 if (this->isPressure) {
436
437 auto t_normal = this->getFTensor1Normal();
439
440 this->sourceFun = [&](const double, const double, const double) {
441 this->tForce(i) = t_normal(i);
442 this->tForce.normalize();
443 this->tForce(i) *= this->surfacePressure;
444 return this->tForce;
445 };
446 }
447 }
448
449 CHKERR Parent::iNtegrate(data);
451}
452
453template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
455 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
456 const std::string field_name,
457 std::vector<boost::shared_ptr<ScalingMethod>> smv,
458 ScalarFun user_fun)
460 field_name, smv, user_fun) {
461 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
462}
463
464template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
466 I, OpBase>::iNtegrate(EntData &data) {
468
469 auto t_normal = this->getFTensor1Normal();
471
472 this->sourceFun = [&](const double, const double, const double) {
473 this->tForce(i) = t_normal(i);
474 this->tForce.normalize();
475 this->tForce(i) *= this->surfacePressure;
476 return this->tForce;
477 };
478
479 CHKERR Parent::iNtegrate(data);
481}
482
483template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
486 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
488
489 auto cubit_meshset_ptr =
490 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
491 SIDESET);
492
493 PressureCubitBcData pressure_data;
494 CHKERR cubit_meshset_ptr->getBcDataStructure(pressure_data);
495 this->surfacePressure = pressure_data.data.value1;
496
497 this->entsPtr = boost::make_shared<Range>();
498 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
499 *(this->entsPtr), true);
500
502}
503
504template <AssemblyType A, IntegrationType I, typename OpBase>
506 OpFluxRhsImpl(const std::string field_name, const double value,
507 boost::shared_ptr<Range> ents_ptr,
508 std::vector<boost::shared_ptr<ScalingMethod>> smv,
509 ScalarFun user_fun)
510 : OpFluxRhsImpl(field_name, smv, user_fun) {
511 this->scalarValue = value;
512 this->entsPtr = ents_ptr;
513}
514
515template <AssemblyType A, IntegrationType I, typename OpBase>
517 OpFluxRhsImpl(const std::string field_name,
518 std::vector<boost::shared_ptr<ScalingMethod>> smv,
519 ScalarFun user_fun)
521
522 [this](const double x, const double y, const double z) {
523 return scalarValue * userFun(x, y, z);
524 }
525
526 ),
527 vecOfTimeScalingMethods(smv), userFun(user_fun) {
528
529 this->timeScalingFun = [this](const double t) {
530 double s = 1;
531 for (auto &o : vecOfTimeScalingMethods) {
532 s *= o->getScale(t);
533 }
534 return s;
535 };
536}
537
538template <AssemblyType A, IntegrationType I, typename OpBase>
540 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
541 std::vector<boost::shared_ptr<ScalingMethod>> smv, ScalarFun user_fun)
543 field_name, smv, user_fun) {
544 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
545}
546
547template <AssemblyType A, IntegrationType I, typename OpBase>
550 MoFEM::Interface &m_field, int ms_id) {
552
553 auto cubit_meshset_ptr =
554 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
555 BLOCKSET);
556 std::vector<double> block_data;
557 CHKERR cubit_meshset_ptr->getAttributes(block_data);
558 if (block_data.size() != 1) {
559 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
560 "Expected that block has one attribute, e.g. heat flux value");
561 }
562 this->scalarValue = block_data[0];
563
564 this->entsPtr = boost::make_shared<Range>();
565 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
566 *(this->entsPtr), true);
567
568 MOFEM_LOG("WORLD", Sev::inform)
569 << "Flux blockset " << cubit_meshset_ptr->getName();
570 MOFEM_LOG("WORLD", Sev::inform)
571 << "Scalar attribute value: " << this->scalarValue;
572
574}
575
576template <AssemblyType A, IntegrationType I, typename OpBase>
578 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
579 const std::string field_name,
580 std::vector<boost::shared_ptr<ScalingMethod>> smv,
581 ScalarFun user_fun)
583 field_name, smv, user_fun) {
584 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
585}
586
587template <AssemblyType A, IntegrationType I, typename OpBase>
589 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
590 int ms_id) {
592
593 auto cubit_meshset_ptr =
594 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
595 SIDESET);
596 HeatFluxCubitBcData heat_flux;
597 CHKERR cubit_meshset_ptr->getBcDataStructure(heat_flux);
598 this->scalarValue = heat_flux.data.value1;
599
600 this->entsPtr = boost::make_shared<Range>();
601 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
602 *(this->entsPtr), true);
603
605}
606
607template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
609 OpFluxRhsImpl(const std::string field_name, const double value,
610 boost::shared_ptr<Range> ents_ptr,
611 std::vector<boost::shared_ptr<ScalingMethod>> smv,
612 ScalarFun user_fun)
613 : OpFluxRhsImpl(field_name, smv) {
614 this->scalarValue = value;
615 this->entsPtr = ents_ptr;
616}
617
618template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
620 OpFluxRhsImpl(const std::string field_name,
621 std::vector<boost::shared_ptr<ScalingMethod>> smv,
622 ScalarFun user_fun)
624
625 [this](const double x, const double y, const double z) {
626 return scalarValue * userFun(x, y, z);
627 }
628
629 ),
630 vecOfTimeScalingMethods(smv), userFun(user_fun) {
631
632 this->timeScalingFun = [this](const double t) {
633 double s = 1;
634 for (auto &o : vecOfTimeScalingMethods) {
635 s *= o->getScale(t);
636 }
637 return s;
638 };
639}
640
641template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
643 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
644 const std::string field_name,
645 std::vector<boost::shared_ptr<ScalingMethod>> smv,
646 ScalarFun user_fun)
648 field_name, smv, user_fun) {
649 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
650}
651
652template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
654 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
655 int ms_id) {
657
658 auto cubit_meshset_ptr =
659 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
660 BLOCKSET);
661 std::vector<double> attr_vec;
662 cubit_meshset_ptr->getAttributes(attr_vec);
663 if (attr_vec.size() != 1)
664 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "Should be one attribute");
665 this->scalarValue = attr_vec[0];
666
667 this->entsPtr = boost::make_shared<Range>();
668 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
669 *(this->entsPtr), true);
670
672}
673
674template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
676 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
677 const std::string field_name,
678 std::vector<boost::shared_ptr<ScalingMethod>> smv,
679 ScalarFun user_fun)
681 field_name, smv, user_fun) {
682 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
683}
684
685template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
688 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
690
691 auto cubit_meshset_ptr =
692 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
693 NODESET);
694
696 CHKERR cubit_meshset_ptr->getBcDataStructure(mydata);
697 this->scalarValue = mydata.data.value1;
698
699 this->entsPtr = boost::make_shared<Range>();
700 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
701 *(this->entsPtr), true);
702
704}
705
706/**
707 * @brief Function to push operators to rhs pipeline. This function user API.
708 *
709 * @tparam BCTYPE
710 * @tparam BASE_DIM
711 * @tparam FIELD_DIM
712 * @tparam A
713 * @tparam I
714 * @tparam OpBase
715 */
716template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
719 OpFluxRhsImpl(
720 const std::string field_name,
722 boost::shared_ptr<Range> ents_ptr,
723 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
724 ScalarFun user_fun)
725 : OpFluxRhsImpl(field_name, smv, user_fun) {
727 this->tForce(i) = t_force(i);
728 this->entsPtr = ents_ptr;
729}
730
731template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
734 OpFluxRhsImpl(
735 const std::string field_name,
736 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
737 ScalarFun user_fun)
739 [this](double x, double y, double z) {
741 auto t = this->getFEMethod()->ts_t;
742 for (auto &o : vecOfTimeVectorScalingMethods) {
743 auto vec = o->getVector(t);
744 this->tForce(i) = vec(i) * userFun(x, y, z);
745 }
746 return this->tForce;
747 }),
748 vecOfTimeVectorScalingMethods(smv), userFun(user_fun) {
749
750 static_assert(FIELD_DIM > 1, "Not implemented for scalar field");
751}
752
753template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
754OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<BLOCKSET>, 1, FIELD_DIM, A, I,
756 OpFluxRhsImpl(
757 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
758 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
759 ScalarFun user_fun)
761 A, I, OpBase>(field_name, smv, user_fun) {
762 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
763}
764
765template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
768 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
770
771 auto cubit_meshset_ptr =
772 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
773 BLOCKSET);
774
775 std::vector<double> block_data;
776 CHKERR cubit_meshset_ptr->getAttributes(block_data);
777 if (block_data.size() != FIELD_DIM) {
778 MOFEM_LOG("SELF", Sev::warning)
779 << "BLOCKSET is expected to have " << FIELD_DIM
780 << " attributes but has size " << block_data.size();
781 if (block_data.size() < FIELD_DIM) {
782
783 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
784 "Size of attribute in BLOCKSET is too small");
785 }
786 }
787
788 for (unsigned int ii = 0; ii != FIELD_DIM; ++ii) {
789 this->tForce(ii) = block_data[ii];
790 }
791
792 MOFEM_LOG("WORLD", Sev::inform)
793 << "Flux blockset " << cubit_meshset_ptr->getName();
794 MOFEM_LOG("WORLD", Sev::inform)
795 << "Number of attributes " << block_data.size();
796 MOFEM_LOG("WORLD", Sev::inform)
797 << "tForce vector initialised: " << this->tForce;
798
799 this->entsPtr = boost::make_shared<Range>();
800 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
801 *(this->entsPtr), true);
802
804}
805
806template <CubitBC BCTYPE, int BASE_DIM, int FIELD_DIM, AssemblyType A,
807 IntegrationType I, typename OpBase>
809
811 OpBase>,
812 A, I, OpBase
813
814 > {
815
817
819
820 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
821 MoFEM::Interface &m_field, const std::string field_name,
822 std::vector<boost::shared_ptr<ScalingMethod>> smv, std::string block_name,
823 ScalarFun user_fun, Sev sev
824
825 ) {
827
828 using OP = typename NaturalBC<OpBase>::template Assembly<
831
832 auto add_op = [&](auto &&meshset_vec_ptr) {
833 for (auto m : meshset_vec_ptr) {
834 MOFEM_TAG_AND_LOG("WORLD", sev, "OpFlux") << "Add " << *m;
835 pipeline.push_back(
836 new OP(m_field, m->getMeshsetId(), field_name, smv, user_fun));
837 }
838 MOFEM_LOG_CHANNEL("WORLD");
839 };
840
841 switch (BCTYPE) {
842 case TEMPERATURESET:
843 case FORCESET:
845 NODESET | BCTYPE));
846 case PRESSURESET:
847 case HEATFLUXSET:
849 SIDESET | BCTYPE));
850 break;
851 case BLOCKSET:
852 add_op(
853
855 std::regex(
856
857 (boost::format("%s(.*)") % block_name).str()
858
859 ))
860
861 );
862
863 break;
864 default:
865 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
866 "Handling of bc type not implemented");
867 break;
868 }
870 }
871
872 static MoFEMErrorCode
873 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
874 MoFEM::Interface &m_field, const std::string field_name,
875 std::vector<boost::shared_ptr<ScalingMethod>> smv,
876 std::string block_name, Sev sev) {
877 return add(
878 pipeline, m_field, field_name, smv, block_name,
879 [](double, double, double) { return 1; }, sev);
880 }
881};
882
883template <CubitBC BCTYPE, int BASE_DIM, int FIELD_DIM, AssemblyType A,
884 IntegrationType I, typename OpBase>
886
888 A, I, OpBase>,
889 A, I, OpBase
890
891 > {
892
894
896
897 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
898 MoFEM::Interface &m_field, const std::string field_name,
899 std::vector<boost::shared_ptr<ScalingMethod>> smv,
900 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> vsmv,
901 std::string block_name, ScalarFun user_fun, Sev sev
902
903 ) {
905
906 using OPV =
907 typename NaturalBC<OpBase>::template Assembly<A>::template LinearForm<
910
911 auto add_opv = [&](auto &&meshset_vec_ptr) {
912 for (auto m : meshset_vec_ptr) {
913 MOFEM_TAG_AND_LOG("WORLD", sev, "OpFlux") << "Add " << *m;
914 pipeline.push_back(
915 new OPV(m_field, m->getMeshsetId(), field_name, vsmv, user_fun));
916 }
917 MOFEM_LOG_CHANNEL("WORLD");
918 };
919
920 switch (BCTYPE) {
921 case BLOCKSET:
922 add_opv(
923
925 std::regex(
926
927 (boost::format("%s(.*)") % block_name).str()
928
929 ))
930
931 );
932
933 break;
934 default:
935 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
936 "Handling of bc type not implemented");
937 break;
938 }
940 }
941
942 static MoFEMErrorCode
943 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
944 MoFEM::Interface &m_field, const std::string field_name,
945 std::vector<boost::shared_ptr<ScalingMethod>> smv,
946 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> vsmv,
947 std::string block_name, Sev sev) {
948 return add(
949 pipeline, m_field, field_name, smv, vsmv, block_name,
950 [](double, double, double) { return 1; }, sev);
951 }
952};
953
954} // namespace MoFEM
955
956#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
std::vector< boost::shared_ptr< ScalingMethod > > VecOfTimeScalingMethods
Vector of time scaling methods.
Definition Natural.hpp:20
constexpr IntegrationType I
constexpr AssemblyType A
constexpr double t
plate stiffness
Definition plate.cpp:58
constexpr auto field_name
OpBaseImpl< PETSC, EdgeEleOp > OpBase
Definition radiation.cpp:29
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::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.