11 #ifndef _NATURAL_MESHSET_TYPE_HPP_
12 #define _NATURAL_MESHSET_TYPE_HPP_
24 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
26 :
OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, FIELD_DIM, A, I,
31 std::vector<boost::shared_ptr<ScalingMethod>> smv,
32 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
45 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
47 :
OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, FIELD_DIM, A, I,
52 std::vector<boost::shared_ptr<ScalingMethod>> smv,
53 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
59 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
62 FIELD_DIM, A, I, OpBase> {
70 std::vector<boost::shared_ptr<ScalingMethod>> smv,
71 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
95 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
98 I>::template
OpSource<1, FIELD_DIM> {
105 boost::shared_ptr<Range> ents_ptr,
106 std::vector<boost::shared_ptr<ScalingMethod>> smv,
107 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
112 std::vector<boost::shared_ptr<ScalingMethod>> smv,
113 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
120 template <AssemblyType A, IntegrationType I,
typename OpBase>
130 boost::shared_ptr<Range> ents_ptr,
131 std::vector<boost::shared_ptr<ScalingMethod>> smv,
132 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
137 std::vector<boost::shared_ptr<ScalingMethod>> smv,
138 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
142 double scalarValue = 0;
148 template <AssemblyType A, IntegrationType I,
typename OpBase>
150 :
OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
157 std::vector<boost::shared_ptr<ScalingMethod>> smv,
158 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
164 template <AssemblyType A, IntegrationType I,
typename OpBase>
166 :
OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
173 std::vector<boost::shared_ptr<ScalingMethod>> smv,
174 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
180 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
183 I>::template OpNormalMixVecTimesScalar<FIELD_DIM> {
186 A>::template LinearForm<I>::template OpNormalMixVecTimesScalar<FIELD_DIM>;
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; });
197 std::vector<boost::shared_ptr<ScalingMethod>> smv,
198 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
204 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
206 :
OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 3, FIELD_DIM, A, I,
210 std::vector<boost::shared_ptr<ScalingMethod>> smv,
211 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
217 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
220 FIELD_DIM, A, I, OpBase> {
223 std::vector<boost::shared_ptr<ScalingMethod>> smv,
224 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
232 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
235 :
OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<UNKNOWNSET>, 1, FIELD_DIM,
241 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
247 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
251 I>::template
OpSource<1, FIELD_DIM> {
258 boost::shared_ptr<Range> ents_ptr,
260 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
266 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
275 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
279 boost::shared_ptr<Range> ents_ptr,
280 std::vector<boost::shared_ptr<ScalingMethod>> smv,
284 this->tForce(
i) = t_force(
i);
285 this->entsPtr = ents_ptr;
288 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
291 std::vector<boost::shared_ptr<ScalingMethod>> smv,
297 tScaledForce(
i) = tForce(
i) * userFun(x, y, z);
302 vecOfTimeScalingMethods(smv), userFun(user_fun) {
303 this->timeScalingFun = [
this](
const double t) {
305 for (
auto &o : vecOfTimeScalingMethods) {
311 static_assert(
FIELD_DIM > 1,
"Not implemented for scalar field");
314 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
318 std::vector<boost::shared_ptr<ScalingMethod>> smv,
325 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
331 auto cubit_meshset_ptr =
336 CHKERR cubit_meshset_ptr->getBcDataStructure(bc_data);
338 this->tForce(0) = bc_data.
data.value3;
340 this->tForce(1) = bc_data.
data.value4;
342 this->tForce(2) = bc_data.
data.value5;
345 this->tForce(
i) *= bc_data.
data.value1;
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);
354 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
358 std::vector<boost::shared_ptr<ScalingMethod>> smv,
365 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
371 auto cubit_meshset_ptr =
375 std::vector<double> block_data;
376 CHKERR cubit_meshset_ptr->getAttributes(block_data);
379 <<
"BLOCKSET is expected to have " <<
FIELD_DIM
380 <<
" attributes but has size " << block_data.size();
383 "Size of attribute in BLOCKSET is too small");
388 <<
"Flux blockset " << cubit_meshset_ptr->getName();
390 <<
"Number of attributes " << block_data.size();
392 for (
unsigned int ii = 0; ii !=
FIELD_DIM; ++ii) {
393 this->tForce(ii) = block_data[ii];
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);
401 <<
"tForce vector initialised: " << this->tForce;
403 <<
"Number of elements " << this->entsPtr->size();
408 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
412 std::vector<boost::shared_ptr<ScalingMethod>> smv,
419 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
424 auto t_normal = this->getFTensor1Normal();
428 this->tForce(
i) = t_normal(
i);
429 this->tForce.normalize();
430 this->tForce(
i) *= this->surfacePressure;
434 CHKERR Parent::iNtegrate(data);
438 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
444 auto cubit_meshset_ptr =
449 CHKERR cubit_meshset_ptr->getBcDataStructure(pressure_data);
450 this->surfacePressure = pressure_data.
data.value1;
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);
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,
466 this->scalarValue = value;
467 this->entsPtr = ents_ptr;
470 template <AssemblyType A, IntegrationType I,
typename OpBase>
473 std::vector<boost::shared_ptr<ScalingMethod>> smv,
478 return scalarValue * userFun(x, y, z);
482 vecOfTimeScalingMethods(smv), userFun(user_fun) {
484 this->timeScalingFun = [
this](
const double t) {
486 for (
auto &o : vecOfTimeScalingMethods) {
493 template <AssemblyType A, IntegrationType I,
typename OpBase>
496 std::vector<boost::shared_ptr<ScalingMethod>> smv,
ScalarFun user_fun)
502 template <AssemblyType A, IntegrationType I,
typename OpBase>
508 auto cubit_meshset_ptr =
511 std::vector<double> block_data;
512 CHKERR cubit_meshset_ptr->getAttributes(block_data);
513 if (block_data.size() != 1) {
515 "Expected that block has one attribute, e.g. heat flux value");
517 this->scalarValue = block_data[0];
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);
524 <<
"Flux blockset " << cubit_meshset_ptr->getName();
526 <<
"Scalar attribute value: " << this->scalarValue;
531 template <AssemblyType A, IntegrationType I,
typename OpBase>
535 std::vector<boost::shared_ptr<ScalingMethod>> smv,
542 template <AssemblyType A, IntegrationType I,
typename OpBase>
548 auto cubit_meshset_ptr =
552 CHKERR cubit_meshset_ptr->getBcDataStructure(heat_flux);
553 this->scalarValue = heat_flux.
data.value1;
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);
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,
569 this->scalarValue = value;
570 this->entsPtr = ents_ptr;
573 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
576 std::vector<boost::shared_ptr<ScalingMethod>> smv,
581 return scalarValue * userFun(x, y, z);
585 vecOfTimeScalingMethods(smv), userFun(user_fun) {
587 this->timeScalingFun = [
this](
const double t) {
589 for (
auto &o : vecOfTimeScalingMethods) {
596 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
600 std::vector<boost::shared_ptr<ScalingMethod>> smv,
607 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
613 auto cubit_meshset_ptr =
616 std::vector<double> attr_vec;
617 cubit_meshset_ptr->getAttributes(attr_vec);
618 if (attr_vec.size() != 1)
620 this->scalarValue = attr_vec[0];
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);
629 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
633 std::vector<boost::shared_ptr<ScalingMethod>> smv,
640 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
646 auto cubit_meshset_ptr =
651 CHKERR cubit_meshset_ptr->getBcDataStructure(mydata);
652 this->scalarValue = mydata.
data.value1;
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);
671 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
677 boost::shared_ptr<Range> ents_ptr,
682 this->tForce(
i) = t_force(
i);
683 this->entsPtr = ents_ptr;
686 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
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);
703 vecOfTimeVectorScalingMethods(smv), userFun(user_fun) {
705 static_assert(
FIELD_DIM > 1,
"Not implemented for scalar field");
708 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
709 OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<BLOCKSET>, 1,
FIELD_DIM,
A,
I,
720 template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
726 auto cubit_meshset_ptr =
730 std::vector<double> block_data;
731 CHKERR cubit_meshset_ptr->getAttributes(block_data);
734 <<
"BLOCKSET is expected to have " <<
FIELD_DIM
735 <<
" attributes but has size " << block_data.size();
739 "Size of attribute in BLOCKSET is too small");
743 for (
unsigned int ii = 0; ii !=
FIELD_DIM; ++ii) {
744 this->tForce(ii) = block_data[ii];
748 <<
"Flux blockset " << cubit_meshset_ptr->getName();
750 <<
"Number of attributes " << block_data.size();
752 <<
"tForce vector initialised: " << this->tForce;
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);
775 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
777 std::vector<boost::shared_ptr<ScalingMethod>> smv, std::string block_name,
787 auto add_op = [&](
auto &&meshset_vec_ptr) {
788 for (
auto m : meshset_vec_ptr) {
791 new OP(m_field,
m->getMeshsetId(),
field_name, smv, user_fun));
812 (boost::format(
"%s(.*)") % block_name).str()
821 "Handling of bc type not implemented");
828 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
830 std::vector<boost::shared_ptr<ScalingMethod>> smv,
831 std::string block_name,
Sev sev) {
833 pipeline, m_field,
field_name, smv, block_name,
834 [](
double,
double,
double) {
return 1; }, sev);
852 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
854 std::vector<boost::shared_ptr<ScalingMethod>> smv,
866 auto add_opv = [&](
auto &&meshset_vec_ptr) {
867 for (
auto m : meshset_vec_ptr) {
870 new OPV(m_field,
m->getMeshsetId(),
field_name, vsmv, user_fun));
882 (boost::format(
"%s(.*)") % block_name).str()
891 "Handling of bc type not implemented");
898 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
900 std::vector<boost::shared_ptr<ScalingMethod>> smv,
902 std::string block_name,
Sev sev) {
904 pipeline, m_field,
field_name, smv, vsmv, block_name,
905 [](
double,
double,
double) {
return 1; }, sev);
911 #endif //_NATURAL_MESHSET_TYPE_HPP_