v0.14.0
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
55protected:
56 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
57};
58
59template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
61 OpBase> : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1,
62 FIELD_DIM, A, I, OpBase> {
63
64 using Parent =
67
69 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
70 std::vector<boost::shared_ptr<ScalingMethod>> smv,
71 ScalarFun user_fun = [](double, double, double) { return 1; });
72
73protected:
74 MoFEMErrorCode iNtegrate(EntData &data);
75 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
78};
79
80/**
81 * @brief Base class for OpFluxRhsImpl<NaturalMeshsetType<T>, 1, FIELD_DIM, A,
82 I, OpBase>
83 *
84 * This is only for scalar bases.
85 *
86 * @note It is derivitive from FormsIntegrators<OpBase>::template
87 Assembly<A>::template LinearForm< I>::template OpSource<1, FIELD_DIM>
88 *
89 * @tparam FIELD_DIM field dimension
90 * @tparam A
91 * @tparam I
92 * @tparam OpBase Base element operator for integration volume, face, edge, or
93 vertex
94 */
95template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
97 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
98 I>::template OpSource<1, FIELD_DIM> {
99
102
104 const std::string field_name, FTensor::Tensor1<double, FIELD_DIM> t_force,
105 boost::shared_ptr<Range> ents_ptr,
106 std::vector<boost::shared_ptr<ScalingMethod>> smv,
107 ScalarFun user_fun = [](double, double, double) { return 1; });
108
109protected:
111 const std::string field_name,
112 std::vector<boost::shared_ptr<ScalingMethod>> smv,
113 ScalarFun user_fun = [](double, double, double) { return 1; });
118};
119
120template <AssemblyType A, IntegrationType I, typename OpBase>
122 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
123 I>::template OpSource<1, 1> {
124
127
129 const std::string field_name, double value,
130 boost::shared_ptr<Range> ents_ptr,
131 std::vector<boost::shared_ptr<ScalingMethod>> smv,
132 ScalarFun user_fun = [](double, double, double) { return 1; });
133
134protected:
136 const std::string field_name,
137 std::vector<boost::shared_ptr<ScalingMethod>> smv,
138 ScalarFun user_fun = [](double, double, double) { return 1; });
139
141
142 double scalarValue = 0;
144
146};
147
148template <AssemblyType A, IntegrationType I, typename OpBase>
150 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
151
152 using Parent =
154
156 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
157 std::vector<boost::shared_ptr<ScalingMethod>> smv,
158 ScalarFun user_fun = [](double, double, double) { return 1; });
159
160protected:
161 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
162};
163
164template <AssemblyType A, IntegrationType I, typename OpBase>
166 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
167
168 using Parent =
170
172 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
173 std::vector<boost::shared_ptr<ScalingMethod>> smv,
174 ScalarFun user_fun = [](double, double, double) { return 1; });
175
176protected:
177 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
178};
179
180template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
182 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
183 I>::template OpNormalMixVecTimesScalar<FIELD_DIM> {
184
186 A>::template LinearForm<I>::template OpNormalMixVecTimesScalar<FIELD_DIM>;
187
189 const std::string field_name, const double value,
190 boost::shared_ptr<Range> ents_ptr,
191 std::vector<boost::shared_ptr<ScalingMethod>> smv,
192 ScalarFun user_fun = [](double, double, double) { return 1; });
193
194protected:
196 const std::string field_name,
197 std::vector<boost::shared_ptr<ScalingMethod>> smv,
198 ScalarFun user_fun = [](double, double, double) { return 1; });
202};
203
204template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
206 : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 3, FIELD_DIM, A, I,
207 OpBase> {
209 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
210 std::vector<boost::shared_ptr<ScalingMethod>> smv,
211 ScalarFun user_fun = [](double, double, double) { return 1; });
212
213protected:
214 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
215};
216
217template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
219 OpBase> : OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 3,
220 FIELD_DIM, A, I, OpBase> {
222 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
223 std::vector<boost::shared_ptr<ScalingMethod>> smv,
224 ScalarFun user_fun = [](double, double, double) { return 1; });
225
226protected:
227 MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
228};
229
230template <CubitBC BCTYP> struct NaturalMeshsetTypeVectorScaling {};
231
232template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
234 I, OpBase>
235 : OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<UNKNOWNSET>, 1, FIELD_DIM,
236 A, I, OpBase> {
237
239 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
240 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> 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 A, I, OpBase>
250 : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
251 I>::template OpSource<1, FIELD_DIM> {
252
255
257 const std::string field_name, FTensor::Tensor1<double, FIELD_DIM> t_force,
258 boost::shared_ptr<Range> ents_ptr,
259 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
260 ScalarFun user_fun = [](double, double, double) { return 1; });
261
262protected:
264 const std::string field_name,
265 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
266 ScalarFun user_fun = [](double, double, double) { return 1; });
267
271};
272
273// Definitions
274
275template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
277 OpFluxRhsImpl(const std::string field_name,
279 boost::shared_ptr<Range> ents_ptr,
280 std::vector<boost::shared_ptr<ScalingMethod>> smv,
281 ScalarFun user_fun)
282 : OpFluxRhsImpl(field_name, smv, user_fun) {
284 this->tForce(i) = t_force(i);
285 this->entsPtr = ents_ptr;
286}
287
288template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
290 OpFluxRhsImpl(const std::string field_name,
291 std::vector<boost::shared_ptr<ScalingMethod>> smv,
292 ScalarFun user_fun)
294
295 [this](const double x, const double y, const double z) {
297 tScaledForce(i) = tForce(i) * userFun(x, y, z);
298 return tScaledForce;
299 }
300
301 ),
302 vecOfTimeScalingMethods(smv), userFun(user_fun) {
303 this->timeScalingFun = [this](const double t) {
304 double s = 1;
305 for (auto &o : vecOfTimeScalingMethods) {
306 s *= o->getScale(t);
307 }
308 return s;
309 };
310
311 static_assert(FIELD_DIM > 1, "Not implemented for scalar field");
312}
313
314template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
316 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
317 const std::string field_name,
318 std::vector<boost::shared_ptr<ScalingMethod>> smv,
319 ScalarFun user_fun)
321 field_name, smv, user_fun) {
322 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
323}
324
325template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
327 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
328 int ms_id) {
330
331 auto cubit_meshset_ptr =
332 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
333 NODESET);
334
335 ForceCubitBcData bc_data;
336 CHKERR cubit_meshset_ptr->getBcDataStructure(bc_data);
337
338 this->tForce(0) = bc_data.data.value3;
339 if constexpr (FIELD_DIM > 1)
340 this->tForce(1) = bc_data.data.value4;
341 if constexpr (FIELD_DIM > 2)
342 this->tForce(2) = bc_data.data.value5;
343
345 this->tForce(i) *= bc_data.data.value1;
346
347 this->entsPtr = boost::make_shared<Range>();
348 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
349 *(this->entsPtr), true);
350
352}
353
354template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
356 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
357 const std::string field_name,
358 std::vector<boost::shared_ptr<ScalingMethod>> smv,
359 ScalarFun user_fun)
361 field_name, smv, user_fun) {
362 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
363}
364
365template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
367 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
368 int ms_id) {
370
371 auto cubit_meshset_ptr =
372 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
373 BLOCKSET);
374
375 std::vector<double> block_data;
376 CHKERR cubit_meshset_ptr->getAttributes(block_data);
377 if (block_data.size() != FIELD_DIM) {
378 MOFEM_LOG("SELF", Sev::warning)
379 << "BLOCKSET is expected to have " << FIELD_DIM
380 << " attributes but has size " << block_data.size();
381 if (block_data.size() < FIELD_DIM) {
382 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
383 "Size of attribute in BLOCKSET is too small");
384 }
385 }
386
387 MOFEM_LOG("WORLD", Sev::inform)
388 << "Flux blockset " << cubit_meshset_ptr->getName();
389 MOFEM_LOG("WORLD", Sev::inform)
390 << "Number of attributes " << block_data.size();
391
392 for (unsigned int ii = 0; ii != FIELD_DIM; ++ii) {
393 this->tForce(ii) = block_data[ii];
394 }
395
396 this->entsPtr = boost::make_shared<Range>();
397 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
398 *(this->entsPtr), true);
399
400 MOFEM_LOG("WORLD", Sev::inform)
401 << "tForce vector initialised: " << this->tForce;
402 MOFEM_LOG("WORLD", Sev::inform)
403 << "Number of elements " << this->entsPtr->size();
404
406}
407
408template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
410 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
411 const std::string field_name,
412 std::vector<boost::shared_ptr<ScalingMethod>> smv,
413 ScalarFun user_fun)
415 field_name, smv, user_fun) {
416 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
417}
418
419template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
421 I, OpBase>::iNtegrate(EntData &data) {
423
424 auto t_normal = this->getFTensor1Normal();
426
427 this->sourceFun = [&](const double, const double, const double) {
428 this->tForce(i) = t_normal(i);
429 this->tForce.normalize();
430 this->tForce(i) *= this->surfacePressure;
431 return this->tForce;
432 };
433
434 CHKERR Parent::iNtegrate(data);
436}
437
438template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
441 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
443
444 auto cubit_meshset_ptr =
445 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
446 SIDESET);
447
448 PressureCubitBcData pressure_data;
449 CHKERR cubit_meshset_ptr->getBcDataStructure(pressure_data);
450 this->surfacePressure = pressure_data.data.value1;
451
452 this->entsPtr = boost::make_shared<Range>();
453 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
454 *(this->entsPtr), true);
455
457}
458
459template <AssemblyType A, IntegrationType I, typename OpBase>
461 OpFluxRhsImpl(const std::string field_name, const double value,
462 boost::shared_ptr<Range> ents_ptr,
463 std::vector<boost::shared_ptr<ScalingMethod>> smv,
464 ScalarFun user_fun)
465 : OpFluxRhsImpl(field_name, smv, user_fun) {
466 this->scalarValue = value;
467 this->entsPtr = ents_ptr;
468}
469
470template <AssemblyType A, IntegrationType I, typename OpBase>
472 OpFluxRhsImpl(const std::string field_name,
473 std::vector<boost::shared_ptr<ScalingMethod>> smv,
474 ScalarFun user_fun)
476
477 [this](const double x, const double y, const double z) {
478 return scalarValue * userFun(x, y, z);
479 }
480
481 ),
482 vecOfTimeScalingMethods(smv), userFun(user_fun) {
483
484 this->timeScalingFun = [this](const double t) {
485 double s = 1;
486 for (auto &o : vecOfTimeScalingMethods) {
487 s *= o->getScale(t);
488 }
489 return s;
490 };
491}
492
493template <AssemblyType A, IntegrationType I, typename OpBase>
495 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
496 std::vector<boost::shared_ptr<ScalingMethod>> smv, ScalarFun user_fun)
498 field_name, smv, user_fun) {
499 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
500}
501
502template <AssemblyType A, IntegrationType I, typename OpBase>
505 MoFEM::Interface &m_field, int ms_id) {
507
508 auto cubit_meshset_ptr =
509 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
510 BLOCKSET);
511 std::vector<double> block_data;
512 CHKERR cubit_meshset_ptr->getAttributes(block_data);
513 if (block_data.size() != 1) {
514 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
515 "Expected that block has one attribute, e.g. heat flux value");
516 }
517 this->scalarValue = block_data[0];
518
519 this->entsPtr = boost::make_shared<Range>();
520 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
521 *(this->entsPtr), true);
522
523 MOFEM_LOG("WORLD", Sev::inform)
524 << "Flux blockset " << cubit_meshset_ptr->getName();
525 MOFEM_LOG("WORLD", Sev::inform)
526 << "Scalar attribute value: " << this->scalarValue;
527
529}
530
531template <AssemblyType A, IntegrationType I, typename OpBase>
533 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
534 const std::string field_name,
535 std::vector<boost::shared_ptr<ScalingMethod>> smv,
536 ScalarFun user_fun)
538 field_name, smv, user_fun) {
539 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
540}
541
542template <AssemblyType A, IntegrationType I, typename OpBase>
544 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
545 int ms_id) {
547
548 auto cubit_meshset_ptr =
549 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
550 SIDESET);
551 HeatFluxCubitBcData heat_flux;
552 CHKERR cubit_meshset_ptr->getBcDataStructure(heat_flux);
553 this->scalarValue = heat_flux.data.value1;
554
555 this->entsPtr = boost::make_shared<Range>();
556 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
557 *(this->entsPtr), true);
558
560}
561
562template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
564 OpFluxRhsImpl(const std::string field_name, const double value,
565 boost::shared_ptr<Range> ents_ptr,
566 std::vector<boost::shared_ptr<ScalingMethod>> smv,
567 ScalarFun user_fun)
568 : OpFluxRhsImpl(field_name, smv) {
569 this->scalarValue = value;
570 this->entsPtr = ents_ptr;
571}
572
573template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
575 OpFluxRhsImpl(const std::string field_name,
576 std::vector<boost::shared_ptr<ScalingMethod>> smv,
577 ScalarFun user_fun)
579
580 [this](const double x, const double y, const double z) {
581 return scalarValue * userFun(x, y, z);
582 }
583
584 ),
585 vecOfTimeScalingMethods(smv), userFun(user_fun) {
586
587 this->timeScalingFun = [this](const double t) {
588 double s = 1;
589 for (auto &o : vecOfTimeScalingMethods) {
590 s *= o->getScale(t);
591 }
592 return s;
593 };
594}
595
596template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
598 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
599 const std::string field_name,
600 std::vector<boost::shared_ptr<ScalingMethod>> smv,
601 ScalarFun user_fun)
603 field_name, smv, user_fun) {
604 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
605}
606
607template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
609 OpBase>::getMeshsetData(MoFEM::Interface &m_field,
610 int ms_id) {
612
613 auto cubit_meshset_ptr =
614 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
615 BLOCKSET);
616 std::vector<double> attr_vec;
617 cubit_meshset_ptr->getAttributes(attr_vec);
618 if (attr_vec.size() != 1)
619 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "Should be one attribute");
620 this->scalarValue = attr_vec[0];
621
622 this->entsPtr = boost::make_shared<Range>();
623 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
624 *(this->entsPtr), true);
625
627}
628
629template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
631 OpFluxRhsImpl(MoFEM::Interface &m_field, int ms_id,
632 const std::string field_name,
633 std::vector<boost::shared_ptr<ScalingMethod>> smv,
634 ScalarFun user_fun)
636 field_name, smv, user_fun) {
637 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
638}
639
640template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
643 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
645
646 auto cubit_meshset_ptr =
647 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
648 NODESET);
649
651 CHKERR cubit_meshset_ptr->getBcDataStructure(mydata);
652 this->scalarValue = mydata.data.value1;
653
654 this->entsPtr = boost::make_shared<Range>();
655 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
656 *(this->entsPtr), true);
657
659}
660
661/**
662 * @brief Function to push operators to rhs pipeline. This function user API.
663 *
664 * @tparam BCTYPE
665 * @tparam BASE_DIM
666 * @tparam FIELD_DIM
667 * @tparam A
668 * @tparam I
669 * @tparam OpBase
670 */
671template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
674 OpFluxRhsImpl(
675 const std::string field_name,
677 boost::shared_ptr<Range> ents_ptr,
678 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
679 ScalarFun user_fun)
680 : OpFluxRhsImpl(field_name, smv, user_fun) {
682 this->tForce(i) = t_force(i);
683 this->entsPtr = ents_ptr;
684}
685
686template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
689 OpFluxRhsImpl(
690 const std::string field_name,
691 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
692 ScalarFun user_fun)
694 [this](double x, double y, double z) {
696 auto t = this->getFEMethod()->ts_t;
697 for (auto &o : vecOfTimeVectorScalingMethods) {
698 auto vec = o->getVector(t);
699 this->tForce(i) = vec(i) * userFun(x, y, z);
700 }
701 return this->tForce;
702 }),
703 vecOfTimeVectorScalingMethods(smv), userFun(user_fun) {
704
705 static_assert(FIELD_DIM > 1, "Not implemented for scalar field");
706}
707
708template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
709OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<BLOCKSET>, 1, FIELD_DIM, A, I,
711 OpFluxRhsImpl(
712 MoFEM::Interface &m_field, int ms_id, const std::string field_name,
713 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> smv,
714 ScalarFun user_fun)
716 A, I, OpBase>(field_name, smv, user_fun) {
717 CHK_THROW_MESSAGE(getMeshsetData(m_field, ms_id), "Get meshset data");
718}
719
720template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
723 OpBase>::getMeshsetData(MoFEM::Interface &m_field, int ms_id) {
725
726 auto cubit_meshset_ptr =
727 m_field.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(ms_id,
728 BLOCKSET);
729
730 std::vector<double> block_data;
731 CHKERR cubit_meshset_ptr->getAttributes(block_data);
732 if (block_data.size() != FIELD_DIM) {
733 MOFEM_LOG("SELF", Sev::warning)
734 << "BLOCKSET is expected to have " << FIELD_DIM
735 << " attributes but has size " << block_data.size();
736 if (block_data.size() < FIELD_DIM) {
737
738 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
739 "Size of attribute in BLOCKSET is too small");
740 }
741 }
742
743 for (unsigned int ii = 0; ii != FIELD_DIM; ++ii) {
744 this->tForce(ii) = block_data[ii];
745 }
746
747 MOFEM_LOG("WORLD", Sev::inform)
748 << "Flux blockset " << cubit_meshset_ptr->getName();
749 MOFEM_LOG("WORLD", Sev::inform)
750 << "Number of attributes " << block_data.size();
751 MOFEM_LOG("WORLD", Sev::inform)
752 << "tForce vector initialised: " << this->tForce;
753
754 this->entsPtr = boost::make_shared<Range>();
755 CHKERR m_field.get_moab().get_entities_by_handle(cubit_meshset_ptr->meshset,
756 *(this->entsPtr), true);
757
759}
760
761template <CubitBC BCTYPE, int BASE_DIM, int FIELD_DIM, AssemblyType A,
762 IntegrationType I, typename OpBase>
764
766 OpBase>,
767 A, I, OpBase
768
769 > {
770
772
774
775 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
776 MoFEM::Interface &m_field, const std::string field_name,
777 std::vector<boost::shared_ptr<ScalingMethod>> smv, std::string block_name,
778 ScalarFun user_fun, Sev sev
779
780 ) {
782
783 using OP = typename NaturalBC<OpBase>::template Assembly<
786
787 auto add_op = [&](auto &&meshset_vec_ptr) {
788 for (auto m : meshset_vec_ptr) {
789 MOFEM_TAG_AND_LOG("WORLD", sev, "OpFlux") << "Add " << *m;
790 pipeline.push_back(
791 new OP(m_field, m->getMeshsetId(), field_name, smv, user_fun));
792 }
793 MOFEM_LOG_CHANNEL("WORLD");
794 };
795
796 switch (BCTYPE) {
797 case TEMPERATURESET:
798 case FORCESET:
800 NODESET | BCTYPE));
801 case PRESSURESET:
802 case HEATFLUXSET:
804 SIDESET | BCTYPE));
805 break;
806 case BLOCKSET:
807 add_op(
808
810 std::regex(
811
812 (boost::format("%s(.*)") % block_name).str()
813
814 ))
815
816 );
817
818 break;
819 default:
820 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
821 "Handling of bc type not implemented");
822 break;
823 }
825 }
826
827 static MoFEMErrorCode
828 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
829 MoFEM::Interface &m_field, const std::string field_name,
830 std::vector<boost::shared_ptr<ScalingMethod>> smv,
831 std::string block_name, Sev sev) {
832 return add(
833 pipeline, m_field, field_name, smv, block_name,
834 [](double, double, double) { return 1; }, sev);
835 }
836};
837
838template <CubitBC BCTYPE, int BASE_DIM, int FIELD_DIM, AssemblyType A,
839 IntegrationType I, typename OpBase>
841
843 A, I, OpBase>,
844 A, I, OpBase
845
846 > {
847
849
851
852 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
853 MoFEM::Interface &m_field, const std::string field_name,
854 std::vector<boost::shared_ptr<ScalingMethod>> smv,
855 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> vsmv,
856 std::string block_name, ScalarFun user_fun, Sev sev
857
858 ) {
860
861 using OPV =
862 typename NaturalBC<OpBase>::template Assembly<A>::template LinearForm<
865
866 auto add_opv = [&](auto &&meshset_vec_ptr) {
867 for (auto m : meshset_vec_ptr) {
868 MOFEM_TAG_AND_LOG("WORLD", sev, "OpFlux") << "Add " << *m;
869 pipeline.push_back(
870 new OPV(m_field, m->getMeshsetId(), field_name, vsmv, user_fun));
871 }
872 MOFEM_LOG_CHANNEL("WORLD");
873 };
874
875 switch (BCTYPE) {
876 case BLOCKSET:
877 add_opv(
878
880 std::regex(
881
882 (boost::format("%s(.*)") % block_name).str()
883
884 ))
885
886 );
887
888 break;
889 default:
890 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
891 "Handling of bc type not implemented");
892 break;
893 }
895 }
896
897 static MoFEMErrorCode
898 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
899 MoFEM::Interface &m_field, const std::string field_name,
900 std::vector<boost::shared_ptr<ScalingMethod>> smv,
901 std::vector<boost::shared_ptr<TimeScaleVector<FIELD_DIM>>> vsmv,
902 std::string block_name, Sev sev) {
903 return add(
904 pipeline, m_field, field_name, smv, vsmv, block_name,
905 [](double, double, double) { return 1; }, sev);
906 }
907};
908
909} // namespace MoFEM
910
911#endif //_NATURAL_MESHSET_TYPE_HPP_
static Index< 'o', 3 > o
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:362
constexpr int FIELD_DIM
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:595
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
CubitBC
Types of sets and boundary conditions.
Definition: definitions.h:144
@ TEMPERATURESET
Definition: definitions.h:155
@ PRESSURESET
Definition: definitions.h:152
@ FORCESET
Definition: definitions.h:151
@ HEATFLUXSET
Definition: definitions.h:156
@ NODESET
Definition: definitions.h:146
@ SIDESET
Definition: definitions.h:147
@ UNKNOWNSET
Definition: definitions.h:145
@ BLOCKSET
Definition: definitions.h:148
@ 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()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
constexpr int BASE_DIM
FTensor::Index< 'm', SPACE_DIM > m
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.
Definition: LogManager.hpp:308
SeverityLevel
Severity levels.
Definition: LogManager.hpp:33
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
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.
Definition: Exceptions.hpp:56
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:59
constexpr auto field_name
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)
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)
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:139
Definition of the heat flux bc data structure.
Definition: BCData.hpp:427
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, 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
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, FIELD_DIM > OpSource
Definition of the pressure bc data structure.
Definition: BCData.hpp:379
Definition of the temperature bc data structure.
Definition: BCData.hpp:306
Force scale operator for reading four columns (time and vector)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.