v0.14.0
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 
14 namespace MoFEM {
15 
16 /**
17  * @brief Type generating natural b.c. specialisations for meshsets
18  *
19  * @tparam BCTYP
20  */
21 template <CubitBC BCTYP> struct NaturalMeshsetType {};
22 
23 /** Evaluate boundary integral on the right hand side*/
24 template <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 
34 protected:
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 
45 template <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 protected:
56  MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
57 };
58 
59 template <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 
73 protected:
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  */
95 template <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 
100  using OpSource = typename FormsIntegrators<OpBase>::template Assembly<
101  A>::template LinearForm<I>::template OpSource<1, FIELD_DIM>;
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 
109 protected:
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 
120 template <AssemblyType A, IntegrationType I, typename OpBase>
122  : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
123  I>::template OpSource<1, 1> {
124 
125  using OpSource = typename FormsIntegrators<OpBase>::template Assembly<
126  A>::template LinearForm<I>::template OpSource<1, 1>;
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 
134 protected:
136  const std::string field_name,
137  std::vector<boost::shared_ptr<ScalingMethod>> smv,
138  ScalarFun user_fun = [](double, double, double) { return 1; });
139 
140  MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
141 
142  double scalarValue = 0;
144 
146 };
147 
148 template <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 
160 protected:
161  MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
162 };
163 
164 template <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 
176 protected:
177  MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
178 };
179 
180 template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
182  : FormsIntegrators<OpBase>::template Assembly<A>::template LinearForm<
183  I>::template OpNormalMixVecTimesScalar<FIELD_DIM> {
184 
185  using OpSource = typename FormsIntegrators<OpBase>::template Assembly<
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 
194 protected:
196  const std::string field_name,
197  std::vector<boost::shared_ptr<ScalingMethod>> smv,
198  ScalarFun user_fun = [](double, double, double) { return 1; });
199  double scalarValue;
202 };
203 
204 template <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 
213 protected:
214  MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
215 };
216 
217 template <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 
226 protected:
227  MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
228 };
229 
230 template <CubitBC BCTYP> struct NaturalMeshsetTypeVectorScaling {};
231 
232 template <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 
243 protected:
244  MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id);
245 };
246 
247 template <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 
253  using OpSource = typename FormsIntegrators<OpBase>::template Assembly<
254  A>::template LinearForm<I>::template OpSource<1, FIELD_DIM>;
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 
262 protected:
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 
275 template <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 
288 template <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 
314 template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
315 OpFluxRhsImpl<NaturalMeshsetType<FORCESET>, 1, FIELD_DIM, A, I, 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 
325 template <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 
354 template <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 
365 template <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 
408 template <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 
419 template <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 
438 template <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 
459 template <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 
470 template <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 
493 template <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 
502 template <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 
531 template <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 
542 template <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 
562 template <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 
573 template <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 
596 template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
597 OpFluxRhsImpl<NaturalMeshsetType<BLOCKSET>, 3, FIELD_DIM, A, I, 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 
607 template <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 
629 template <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 
640 template <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 
650  TemperatureCubitBcData mydata;
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  */
671 template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
673  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 
686 template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
688  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 
708 template <int FIELD_DIM, AssemblyType A, IntegrationType I, typename OpBase>
709 OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<BLOCKSET>, 1, FIELD_DIM, A, I,
710  OpBase>::
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 
720 template <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 
761 template <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 
771  AddFluxToRhsPipelineImpl() = delete;
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<
784  A>::template LinearForm<I>::template OpFlux<NaturalMeshsetType<BCTYPE>,
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 
838 template <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 
848  AddFluxToRhsPipelineImpl() = delete;
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_
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::EntitiesFieldData::EntData
Data on single entity (This is passed as argument to DataOperator::doWork)
Definition: EntitiesFieldData.hpp:128
SIDESET
@ SIDESET
Definition: definitions.h:160
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::userFun
ScalarFun userFun
Definition: NaturalMeshsetType.hpp:117
MoFEM::AddFluxToRhsPipelineImpl< OpFluxRhsImpl< NaturalMeshsetType< BCTYPE >, BASE_DIM, FIELD_DIM, A, I, OpBase >, A, I, OpBase >::add
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)
Definition: NaturalMeshsetType.hpp:773
MoFEM::TemperatureCubitBcData
Definition of the temperature bc data structure.
Definition: BCData.hpp:306
FTensor::Tensor1< double, FIELD_DIM >
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
MoFEM::OpFluxRhsImpl
Definition: Natural.hpp:39
PRESSURESET
@ PRESSURESET
Definition: definitions.h:165
CHK_THROW_MESSAGE
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:609
MoFEM::NaturalBC
Natural boundary conditions.
Definition: Natural.hpp:57
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::NaturalMeshsetTypeVectorScaling
Definition: NaturalMeshsetType.hpp:230
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 3, FIELD_DIM, A, I, OpBase >::scalarValue
double scalarValue
Definition: NaturalMeshsetType.hpp:199
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 3, FIELD_DIM, A, I, OpBase >::OpSource
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpNormalMixVecTimesScalar< FIELD_DIM > OpSource
Definition: NaturalMeshsetType.hpp:186
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
MoFEM::ForceCubitBcData
Definition of the force bc data structure.
Definition: BCData.hpp:139
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 3, FIELD_DIM, A, I, OpBase >::vecOfTimeScalingMethods
VecOfTimeScalingMethods vecOfTimeScalingMethods
Definition: NaturalMeshsetType.hpp:200
BASE_DIM
constexpr int BASE_DIM
Definition: dg_projection.cpp:15
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< PRESSURESET >, 1, FIELD_DIM, A, I, OpBase >::userFun
ScalarFun userFun
Definition: NaturalMeshsetType.hpp:77
MoFEM::PressureCubitBcData
Definition of the pressure bc data structure.
Definition: BCData.hpp:379
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
FIELD_DIM
constexpr int FIELD_DIM
Definition: child_and_parent.cpp:15
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::tForce
FTensor::Tensor1< double, FIELD_DIM > tForce
Definition: NaturalMeshsetType.hpp:114
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, 1, A, I, OpBase >
Definition: NaturalMeshsetType.hpp:121
I
constexpr IntegrationType I
Definition: operators_tests.cpp:31
NODESET
@ NODESET
Definition: definitions.h:159
MoFEM::OpBaseImpl
Definition: FormsIntegrators.hpp:178
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::tScaledForce
FTensor::Tensor1< double, FIELD_DIM > tScaledForce
Definition: NaturalMeshsetType.hpp:115
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 3, FIELD_DIM, A, I, OpBase >::userFun
ScalarFun userFun
Definition: NaturalMeshsetType.hpp:201
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< PRESSURESET >, 1, FIELD_DIM, A, I, OpBase >::surfacePressure
double surfacePressure
Definition: NaturalMeshsetType.hpp:76
FORCESET
@ FORCESET
Definition: definitions.h:164
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, 1, A, I, OpBase >::userFun
ScalarFun userFun
Definition: NaturalMeshsetType.hpp:143
double
OpFlux
Definition: hcurl_divergence_operator_2d.cpp:56
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::vecOfTimeScalingMethods
VecOfTimeScalingMethods vecOfTimeScalingMethods
Definition: NaturalMeshsetType.hpp:116
MoFEM::ForceCubitBcData::data
_data_ data
Definition: BCData.hpp:152
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, 1, A, I, OpBase >::vecOfTimeScalingMethods
VecOfTimeScalingMethods vecOfTimeScalingMethods
Definition: NaturalMeshsetType.hpp:145
MoFEM::ScalarFun
boost::function< double(const double, const double, const double)> ScalarFun
Scalar function type.
Definition: FormsIntegrators.hpp:144
MoFEM::LogManager::SeverityLevel
SeverityLevel
Severity levels.
Definition: LogManager.hpp:33
MoFEM::AddFluxToRhsPipelineImpl
Definition: Natural.hpp:46
t
constexpr double t
plate stiffness
Definition: plate.cpp:58
MoFEM::TimeScaleVector
Force scale operator for reading four columns (time and vector)
Definition: ScalingMethod.hpp:97
UNKNOWNSET
@ UNKNOWNSET
Definition: definitions.h:158
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
MoFEM::NaturalMeshsetType
Type generating natural b.c. specialisations for meshsets.
Definition: NaturalMeshsetType.hpp:21
EntData
EntitiesFieldData::EntData EntData
Definition: child_and_parent.cpp:37
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
FTensor::Index< 'i', FIELD_DIM >
MoFEM::IntegrationType
IntegrationType
Form integrator integration types.
Definition: FormsIntegrators.hpp:136
MoFEM::PressureCubitBcData::data
_data_ data
Definition: BCData.hpp:387
MoFEM::OpFluxRhsImpl< NaturalMeshsetTypeVectorScaling< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::userFun
ScalarFun userFun
Definition: NaturalMeshsetType.hpp:270
MoFEM::AddFluxToRhsPipelineImpl< OpFluxRhsImpl< NaturalMeshsetType< BCTYPE >, BASE_DIM, FIELD_DIM, A, I, OpBase >, A, I, OpBase >::add
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)
Definition: NaturalMeshsetType.hpp:828
MoFEM::TemperatureCubitBcData::data
_data_ data
Definition: BCData.hpp:325
MOFEM_TAG_AND_LOG
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:362
MoFEM::AddFluxToRhsPipelineImpl< OpFluxRhsImpl< NaturalMeshsetTypeVectorScaling< BCTYPE >, BASE_DIM, FIELD_DIM, A, I, OpBase >, A, I, OpBase >::add
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)
Definition: NaturalMeshsetType.hpp:898
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::AssemblyType
AssemblyType
[Storage and set boundary conditions]
Definition: FormsIntegrators.hpp:104
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, 1, A, I, OpBase >::OpSource
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, 1 > OpSource
Definition: NaturalMeshsetType.hpp:126
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::OpSource
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, FIELD_DIM > OpSource
Definition: NaturalMeshsetType.hpp:101
BLOCKSET
@ BLOCKSET
Definition: definitions.h:161
MoFEM::OpFluxRhsImpl< NaturalMeshsetTypeVectorScaling< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::tForce
FTensor::Tensor1< double, FIELD_DIM > tForce
Definition: NaturalMeshsetType.hpp:268
MoFEM::VecOfTimeScalingMethods
std::vector< boost::shared_ptr< ScalingMethod > > VecOfTimeScalingMethods
Vector of time scaling methods.
Definition: Natural.hpp:20
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
TEMPERATURESET
@ TEMPERATURESET
Definition: definitions.h:168
MoFEM::MeshsetsManager
Interface for managing meshsets containing materials and boundary conditions.
Definition: MeshsetsManager.hpp:104
MoFEM::FormsIntegrators
Integrator forms.
Definition: FormsIntegrators.hpp:306
MoFEM::HeatFluxCubitBcData
Definition of the heat flux bc data structure.
Definition: BCData.hpp:427
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
MoFEM::HeatFluxCubitBcData::data
_data_ data
Definition: BCData.hpp:441
HEATFLUXSET
@ HEATFLUXSET
Definition: definitions.h:169
MoFEM::AddFluxToRhsPipelineImpl< OpFluxRhsImpl< NaturalMeshsetTypeVectorScaling< BCTYPE >, BASE_DIM, FIELD_DIM, A, I, OpBase >, A, I, OpBase >::add
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)
Definition: NaturalMeshsetType.hpp:850
MoFEM::MeshsetsManager::getCubitMeshsetPtr
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
Definition: MeshsetsManager.cpp:578
MoFEM::OpFluxRhsImpl< NaturalMeshsetType< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >
Base class for OpFluxRhsImpl<NaturalMeshsetType<T>, 1, FIELD_DIM, A, I, OpBase>
Definition: NaturalMeshsetType.hpp:96
MoFEM::VecOfTimeVectorScalingMethods
std::vector< boost::shared_ptr< TimeScaleVector< FIELD_DIM > >> VecOfTimeVectorScalingMethods
Vector of time vector scaling methods.
Definition: Natural.hpp:28
OP
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
MoFEM::OpFluxRhsImpl< NaturalMeshsetTypeVectorScaling< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::OpSource
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, FIELD_DIM > OpSource
Definition: NaturalMeshsetType.hpp:254
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
MOFEM_INVALID_DATA
@ MOFEM_INVALID_DATA
Definition: definitions.h:36
CubitBC
CubitBC
Types of sets and boundary conditions.
Definition: definitions.h:157
MoFEM::OpFluxRhsImpl< NaturalMeshsetTypeVectorScaling< UNKNOWNSET >, 1, FIELD_DIM, A, I, OpBase >::vecOfTimeVectorScalingMethods
VecOfTimeVectorScalingMethods< FIELD_DIM > vecOfTimeVectorScalingMethods
Definition: NaturalMeshsetType.hpp:269