11#ifndef _NATURAL_MESHSET_TYPE_HPP_
12#define _NATURAL_MESHSET_TYPE_HPP_
24template <
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; });
45template <
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; });
66template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
69 FIELD_DIM, A, I, OpBase> {
77 std::vector<boost::shared_ptr<ScalingMethod>> smv,
78 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
102template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
105 I>::template
OpSource<1, FIELD_DIM> {
112 boost::shared_ptr<Range> ents_ptr,
113 std::vector<boost::shared_ptr<ScalingMethod>> smv,
114 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
119 std::vector<boost::shared_ptr<ScalingMethod>> smv,
120 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
127template <AssemblyType A, IntegrationType I,
typename OpBase>
137 boost::shared_ptr<Range> ents_ptr,
138 std::vector<boost::shared_ptr<ScalingMethod>> smv,
139 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
144 std::vector<boost::shared_ptr<ScalingMethod>> smv,
145 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
149 double scalarValue = 0;
155template <AssemblyType A, IntegrationType I,
typename OpBase>
157 :
OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
164 std::vector<boost::shared_ptr<ScalingMethod>> smv,
165 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
171template <AssemblyType A, IntegrationType I,
typename OpBase>
173 :
OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 1, 1, A, I, OpBase> {
180 std::vector<boost::shared_ptr<ScalingMethod>> smv,
181 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
187template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
190 I>::template OpNormalMixVecTimesScalar<FIELD_DIM> {
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; });
204 std::vector<boost::shared_ptr<ScalingMethod>> smv,
205 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
211template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
213 :
OpFluxRhsImpl<NaturalMeshsetType<UNKNOWNSET>, 3, FIELD_DIM, A, I,
217 std::vector<boost::shared_ptr<ScalingMethod>> smv,
218 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
224template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
227 FIELD_DIM, A, I, OpBase> {
230 std::vector<boost::shared_ptr<ScalingMethod>> smv,
231 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
239template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
242 :
OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<UNKNOWNSET>, 1, FIELD_DIM,
248 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
254template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
258 I>::template
OpSource<1, FIELD_DIM> {
265 boost::shared_ptr<Range> ents_ptr,
267 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
273 ScalarFun user_fun = [](
double,
double,
double) {
return 1; });
282template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
286 boost::shared_ptr<Range> ents_ptr,
287 std::vector<boost::shared_ptr<ScalingMethod>> smv,
291 this->tForce(
i) = t_force(
i);
292 this->entsPtr = ents_ptr;
295template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
298 std::vector<boost::shared_ptr<ScalingMethod>> smv,
304 tScaledForce(
i) = tForce(
i) * userFun(x, y, z);
309 vecOfTimeScalingMethods(smv), userFun(user_fun) {
310 this->timeScalingFun = [
this](
const double t) {
312 for (
auto &o : vecOfTimeScalingMethods) {
318 static_assert(
FIELD_DIM > 1,
"Not implemented for scalar field");
321template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
325 std::vector<boost::shared_ptr<ScalingMethod>> smv,
332template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
338 auto cubit_meshset_ptr =
343 CHKERR cubit_meshset_ptr->getBcDataStructure(bc_data);
345 this->tForce(0) = bc_data.
data.value3;
347 this->tForce(1) = bc_data.
data.value4;
349 this->tForce(2) = bc_data.
data.value5;
352 this->tForce(
i) *= bc_data.
data.value1;
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);
361template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
365 std::vector<boost::shared_ptr<ScalingMethod>> smv,
368 field_name, smv, user_fun), isPressure(false), surfacePressure(0.0) {
372template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
378 auto cubit_meshset_ptr =
382 std::vector<double> block_data;
383 CHKERR cubit_meshset_ptr->getAttributes(block_data);
386 cubit_meshset_ptr->getName().find(
"PRESSURE") != std::string::npos;
387 if (this->isPressure) {
389 if (block_data.empty())
391 "Size of attribute in BLOCKSET (PRESSURE) is empty");
392 this->surfacePressure = block_data[0];
398 <<
"BLOCKSET is expected to have " <<
FIELD_DIM
399 <<
" attributes but has size " << block_data.size();
402 "Size of attribute in BLOCKSET is too small");
406 for (
unsigned int ii = 0; ii !=
FIELD_DIM; ++ii) {
407 this->tForce(ii) = block_data[ii];
412 <<
"Flux blockset " << cubit_meshset_ptr->getName();
414 <<
"Number of attributes " << block_data.size();
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);
421 <<
"tForce vector initialised: " << this->tForce;
423 <<
"Number of elements " << this->entsPtr->size();
428template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
433 if constexpr (std::is_same<
OpBase, MoFEM::FaceElementForcesAndSourcesCore::
434 UserDataOperator>::value) {
435 if (this->isPressure) {
437 auto t_normal = this->getFTensor1Normal();
441 this->tForce(
i) = t_normal(
i);
442 this->tForce.normalize();
443 this->tForce(
i) *= this->surfacePressure;
449 CHKERR Parent::iNtegrate(data);
453template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
457 std::vector<boost::shared_ptr<ScalingMethod>> smv,
464template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
469 auto t_normal = this->getFTensor1Normal();
473 this->tForce(
i) = t_normal(
i);
474 this->tForce.normalize();
475 this->tForce(
i) *= this->surfacePressure;
479 CHKERR Parent::iNtegrate(data);
483template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
489 auto cubit_meshset_ptr =
494 CHKERR cubit_meshset_ptr->getBcDataStructure(pressure_data);
495 this->surfacePressure = pressure_data.
data.value1;
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);
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,
511 this->scalarValue = value;
512 this->entsPtr = ents_ptr;
515template <AssemblyType A, IntegrationType I,
typename OpBase>
518 std::vector<boost::shared_ptr<ScalingMethod>> smv,
523 return scalarValue * userFun(x, y, z);
527 vecOfTimeScalingMethods(smv), userFun(user_fun) {
529 this->timeScalingFun = [
this](
const double t) {
531 for (
auto &o : vecOfTimeScalingMethods) {
538template <AssemblyType A, IntegrationType I,
typename OpBase>
541 std::vector<boost::shared_ptr<ScalingMethod>> smv,
ScalarFun user_fun)
547template <AssemblyType A, IntegrationType I,
typename OpBase>
553 auto cubit_meshset_ptr =
556 std::vector<double> block_data;
557 CHKERR cubit_meshset_ptr->getAttributes(block_data);
558 if (block_data.size() != 1) {
560 "Expected that block has one attribute, e.g. heat flux value");
562 this->scalarValue = block_data[0];
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);
569 <<
"Flux blockset " << cubit_meshset_ptr->getName();
571 <<
"Scalar attribute value: " << this->scalarValue;
576template <AssemblyType A, IntegrationType I,
typename OpBase>
580 std::vector<boost::shared_ptr<ScalingMethod>> smv,
587template <AssemblyType A, IntegrationType I,
typename OpBase>
593 auto cubit_meshset_ptr =
597 CHKERR cubit_meshset_ptr->getBcDataStructure(heat_flux);
598 this->scalarValue = heat_flux.
data.value1;
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);
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,
614 this->scalarValue = value;
615 this->entsPtr = ents_ptr;
618template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
621 std::vector<boost::shared_ptr<ScalingMethod>> smv,
626 return scalarValue * userFun(x, y, z);
630 vecOfTimeScalingMethods(smv), userFun(user_fun) {
632 this->timeScalingFun = [
this](
const double t) {
634 for (
auto &o : vecOfTimeScalingMethods) {
641template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
645 std::vector<boost::shared_ptr<ScalingMethod>> smv,
652template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
658 auto cubit_meshset_ptr =
661 std::vector<double> attr_vec;
662 cubit_meshset_ptr->getAttributes(attr_vec);
663 if (attr_vec.size() != 1)
665 this->scalarValue = attr_vec[0];
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);
674template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
678 std::vector<boost::shared_ptr<ScalingMethod>> smv,
685template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
691 auto cubit_meshset_ptr =
696 CHKERR cubit_meshset_ptr->getBcDataStructure(mydata);
697 this->scalarValue = mydata.
data.value1;
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);
716template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
722 boost::shared_ptr<Range> ents_ptr,
727 this->tForce(
i) = t_force(
i);
728 this->entsPtr = ents_ptr;
731template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
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);
748 vecOfTimeVectorScalingMethods(smv), userFun(user_fun) {
750 static_assert(
FIELD_DIM > 1,
"Not implemented for scalar field");
753template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
754OpFluxRhsImpl<NaturalMeshsetTypeVectorScaling<BLOCKSET>, 1,
FIELD_DIM,
A,
I,
765template <
int FIELD_DIM, AssemblyType A, IntegrationType I,
typename OpBase>
771 auto cubit_meshset_ptr =
775 std::vector<double> block_data;
776 CHKERR cubit_meshset_ptr->getAttributes(block_data);
779 <<
"BLOCKSET is expected to have " <<
FIELD_DIM
780 <<
" attributes but has size " << block_data.size();
784 "Size of attribute in BLOCKSET is too small");
788 for (
unsigned int ii = 0; ii !=
FIELD_DIM; ++ii) {
789 this->tForce(ii) = block_data[ii];
793 <<
"Flux blockset " << cubit_meshset_ptr->getName();
795 <<
"Number of attributes " << block_data.size();
797 <<
"tForce vector initialised: " << this->tForce;
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);
820 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
822 std::vector<boost::shared_ptr<ScalingMethod>> smv, std::string block_name,
832 auto add_op = [&](
auto &&meshset_vec_ptr) {
833 for (
auto m : meshset_vec_ptr) {
836 new OP(m_field,
m->getMeshsetId(),
field_name, smv, user_fun));
857 (boost::format(
"%s(.*)") % block_name).str()
866 "Handling of bc type not implemented");
873 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
875 std::vector<boost::shared_ptr<ScalingMethod>> smv,
876 std::string block_name,
Sev sev) {
878 pipeline, m_field,
field_name, smv, block_name,
879 [](
double,
double,
double) {
return 1; }, sev);
897 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
899 std::vector<boost::shared_ptr<ScalingMethod>> smv,
911 auto add_opv = [&](
auto &&meshset_vec_ptr) {
912 for (
auto m : meshset_vec_ptr) {
915 new OPV(m_field,
m->getMeshsetId(),
field_name, vsmv, user_fun));
927 (boost::format(
"%s(.*)") % block_name).str()
936 "Handling of bc type not implemented");
943 add(boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
945 std::vector<boost::shared_ptr<ScalingMethod>> smv,
947 std::string block_name,
Sev sev) {
949 pipeline, m_field,
field_name, smv, vsmv, block_name,
950 [](
double,
double,
double) {
return 1; }, sev);
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
#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.
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#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
std::vector< boost::shared_ptr< TimeScaleVector< FIELD_DIM > > > VecOfTimeVectorScalingMethods
Vector of time vector scaling methods.
std::vector< boost::shared_ptr< ScalingMethod > > VecOfTimeScalingMethods
Vector of time scaling methods.
constexpr IntegrationType I
constexpr double t
plate stiffness
constexpr auto field_name
OpBaseImpl< PETSC, EdgeEleOp > OpBase
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)
AddFluxToRhsPipelineImpl()=delete
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)
AddFluxToRhsPipelineImpl()=delete
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 of the heat flux bc data structure.
Interface for managing meshsets containing materials and boundary conditions.
Natural boundary conditions.
Type generating natural b.c. specialisations for meshsets.
FTensor::Tensor1< double, FIELD_DIM > tForce
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, FIELD_DIM > OpSource
VecOfTimeVectorScalingMethods< FIELD_DIM > vecOfTimeVectorScalingMethods
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, 1 > OpSource
MoFEMErrorCode getMeshsetData(MoFEM::Interface &m_field, int ms_id)
VecOfTimeScalingMethods vecOfTimeScalingMethods
Base class for OpFluxRhsImpl<NaturalMeshsetType<T>, 1, FIELD_DIM, A, I, OpBase>
VecOfTimeScalingMethods vecOfTimeScalingMethods
FTensor::Tensor1< double, FIELD_DIM > tForce
FTensor::Tensor1< double, FIELD_DIM > tScaledForce
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpSource< 1, FIELD_DIM > OpSource
VecOfTimeScalingMethods vecOfTimeScalingMethods
typename FormsIntegrators< OpBase >::template Assembly< A >::template LinearForm< I >::template OpNormalMixVecTimesScalar< FIELD_DIM > OpSource
Definition of the pressure bc data structure.
Definition of the temperature bc data structure.
Force scale operator for reading four columns (time and vector)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.