13#ifndef __BASICBOUNDARYCONDIONSINTERFACE_HPP__
14#define __BASICBOUNDARYCONDIONSINTERFACE_HPP__
22 using DomainEle = VolumeElementForcesAndSourcesCore;
57 :
sCale(
scale), TimeScaleVector3(file_name, false) {}
115 string mesh_pos_field_name =
"MESH_NODE_POSITIONS",
116 string problem_name =
"ELASTIC",
117 string domain_element_name =
"ELASTIC_FE",
119 double *snes_load_factor =
nullptr,
bool is_partitioned =
true)
133 PetscBool quasi_static = PETSC_FALSE;
134 PetscBool is_linear = PETSC_FALSE;
135 CHKERR PetscOptionsGetBool(PETSC_NULLPTR,
"-is_quasi_static", &quasi_static,
137 CHKERR PetscOptionsGetBool(PETSC_NULLPTR,
"-is_linear", &is_linear,
158 dirichletBcPtr = boost::make_shared<DirichletSpatialRemoveDofsBc>(
162 dirichletBcPtr = boost::make_shared<DirichletDisplacementRemoveDofsBc>(
219 boost::make_shared<VolumeElementForcesAndSourcesCore>(
mField);
221 boost::make_shared<VolumeElementForcesAndSourcesCore>(
mField);
237 auto get_id_block_param = [&](
string base_name,
int id) {
238 char load_hist_file[255] =
"hist.in";
239 PetscBool ctg_flag = PETSC_FALSE;
240 string param_name_with_id =
"-" + base_name +
"_" + to_string(
id);
241 CHKERR PetscOptionsGetString(PETSC_NULLPTR, PETSC_NULLPTR,
242 param_name_with_id.c_str(), load_hist_file,
245 return param_name_with_id;
247 param_name_with_id =
"-" + base_name;
248 CHKERR PetscOptionsGetString(PETSC_NULLPTR, PETSC_NULLPTR,
249 param_name_with_id.c_str(), load_hist_file,
253 <<
"Setting one accelerogram for all blocks!";
254 return param_name_with_id;
260 auto get_adj_ents = [&](
const Range &ents) {
263 for (
size_t d = 1; d < 3; ++d)
265 moab::Interface::UNION);
272 const std::string block_name =
"BODY_FORCE";
273 if (it->getName().compare(0, block_name.size(), block_name) == 0) {
274 std::vector<double> attr;
275 CHKERR it->getAttributes(attr);
276 if (attr.size() > 3) {
278 const int id = it->getMeshsetId();
283 auto bc_ents_ptr = boost::make_shared<Range>(get_adj_ents(bc_ents));
287 VectorDouble acc({attr[1], attr[2], attr[3]});
288 double density = attr[0];
290 attr.size() > 4 ?
bool(std::floor(attr[4])) :
true;
293 std::vector<boost::shared_ptr<TimeScaleVector3>> methods_for_scaling;
294 std::string param_name_for_scaling =
295 get_id_block_param(
"accelerogram",
id);
297 if (!param_name_for_scaling.empty())
298 methods_for_scaling.push_back(
299 boost::make_shared<BasicBCVectorScale>(density,
300 param_name_for_scaling));
302 methods_for_scaling.push_back(
303 boost::make_shared<BasicBCVectorConst>(
310 return density * fe_domain_lhs->ts_aa;
322 pipeline_rhs.push_back(
328 pipeline_rhs,
mField,
"U", {}, methods_for_scaling,
329 it->getName(), Sev::inform);
332 pipeline_lhs.push_back(
334 pipeline_lhs.push_back(
336 auto mat_acceleration = boost::make_shared<MatrixDouble>();
337 pipeline_rhs.push_back(
new OpCalculateVectorFieldValuesDotDot<3>(
341 [&](
double,
double,
double) {
return density; }, bc_ents_ptr));
349 "There should be (1 density + 3 accelerations ) attributes in "
350 "BODY_FORCE blockset, but is %ld. Optionally, you can set 5th "
351 "parameter to inertia flag.",
357 auto integration_rule_vol = [](int, int,
int approx_order) {
360 auto integration_rule_boundary = [](int, int,
int approx_order) {
398 bc_mng->getMergedBlocksMarker(vector<string>{
"FIX_",
"ROTATE"});
407 vector<const char *> element_list{
"FORCE_FE",
"PRESSURE_FE",
411 for (
auto &el : element_list) {
413 simple->getOtherFiniteElements().push_back(el);
428 char load_hist_file[255] =
"hist.in";
429 PetscBool ctg_flag = PETSC_FALSE;
430 string new_param_file = string(
"-") + prefix + string(
"_history");
431 CHKERR PetscOptionsGetString(PETSC_NULLPTR, PETSC_NULLPTR, new_param_file.c_str(),
432 load_hist_file, 255, &ctg_flag);
434 return new_param_file;
435 return string(
"-load_history");
438 template <
typename T>
444 template <
typename T>
450 template <
typename T,
bool RHS>
456 auto set_solver_pipelines =
457 [&](PetscErrorCode (*function)(DM,
const char fe_name[],
MoFEM::FEMethod *,
460 PetscErrorCode (*jacobian)(DM,
const char fe_name[],
MoFEM::FEMethod *,
466 if (std::is_same_v<T, TS>)
476 auto set_neumann_methods = [&](
auto &neumann_el,
string hist_name,
479 for (
auto &&mit : neumann_el) {
480 if constexpr (std::is_same_v<T, SNES>)
481 mit->second->methodsOp.push_back(
483 if constexpr (std::is_same_v<T, TS>)
484 mit->second->methodsOp.push_back(
486 string element_name = mit->first;
490 mit->second->getLoopFe().getOpPtrVector(), {},
495 mit->second->getLoopFe().getOpPtrVector(), {},
505 CHKERR function(
dM, element_name.c_str(),
506 &mit->second->getLoopFe(), NULL, NULL);
522 CHKERR function(
dM,
"FLUID_PRESSURE_FE",
539 if constexpr (std::is_same_v<T, SNES>) {
543 "SNES lambda factor pointer not set in the module constructor");
545 CHKERR set_solver_pipelines(&DMMoFEMSNESSetFunction,
546 &DMMoFEMSNESSetJacobian);
548 }
else if constexpr (std::is_same_v<T, TS>) {
552 CHKERR set_solver_pipelines(&DMMoFEMTSSetIFunction,
553 &DMMoFEMTSSetIJacobian);
556 CHKERR set_solver_pipelines(&DMMoFEMTSSetI2Function,
557 &DMMoFEMTSSetI2Jacobian);
560 CHKERR set_solver_pipelines(&DMMoFEMTSSetRHSFunction,
561 &DMMoFEMTSSetRHSJacobian);
565 "This TS is not yet implemented for basic BCs");
570 static_assert(!std::is_same_v<T, KSP>,
571 "this solver has not been implemented for basic BCs yet");
579 CHKERR this->setupSolverFunction<SNES>();
584 CHKERR this->setupSolverJacobian<SNES>();
void simple(double P1[], double P2[], double P3[], double c[], const int N)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_field)=0
set finite element field data
#define MOFEM_LOG(channel, severity)
Log.
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
FTensor::Index< 'i', SPACE_DIM > i
static constexpr int approx_order
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
[Only used with Hooke equation (linear material model)]
FTensor::Tensor1< double, 3 > getVector(const double time)
FTensor::Tensor1< double, 3 > tForce
BasicBCVectorConst(double scale, FTensor::Tensor1< double, 3 > t_vec)
BasicBCVectorScale(double scale, std::string file_name)
FTensor::Tensor1< double, 3 > getVector(const double time)
MoFEMErrorCode scaleNf(const FEMethod *fe, VectorDouble &nf)
LoadScale(double *my_lambda)
Set of functions declaring elements and setting operators for basic boundary conditions interface.
MoFEMErrorCode setupSolverFunctionSNES() override
BasicBoundaryConditionsInterface(MoFEM::Interface &m_field, string postion_field, string mesh_pos_field_name="MESH_NODE_POSITIONS", string problem_name="ELASTIC", string domain_element_name="ELASTIC_FE", bool is_displacement_field=true, bool is_quasi_static=true, double *snes_load_factor=nullptr, bool is_partitioned=true)
double * snesLambdaLoadFactorPtr
boost::shared_ptr< FaceElementForcesAndSourcesCore > springLhsPtr
MoFEMErrorCode getCommandLineParameters() override
MoFEMErrorCode addElementFields() override
MoFEMErrorCode setupSolverFunction(const TSType type=IM)
~BasicBoundaryConditionsInterface()
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, 3, 3 > OpInertiaForce
const string domainElementName
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, 3 > OpBodyForce
MoFEMErrorCode setupSolverJacobianTS(const TSType type) override
MoFEM::Interface & mField
boost::shared_ptr< VolumeElementForcesAndSourcesCore > bodyForceLhsPtr
boost::shared_ptr< FluidPressure > fluidPressureElementPtr
boost::shared_ptr< FaceElementForcesAndSourcesCore > springRhsPtr
boost::ptr_map< std::string, EdgeForce > edge_forces
MoFEMErrorCode setupSolverImpl(const TSType type=IM)
MoFEMErrorCode setOperators() override
boost::ptr_map< std::string, NodalForce > nodal_forces
MoFEMErrorCode createElements() override
string getHistoryParam(string prefix)
boost::ptr_map< std::string, NeumannForcesSurface > neumann_forces
MoFEMErrorCode setupSolverFunctionTS(const TSType type) override
NaturalBC< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS > DomainNaturalBC
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, 3 > OpMass
boost::shared_ptr< VolumeElementForcesAndSourcesCore > bodyForceRhsPtr
MoFEMErrorCode addElementsToDM(SmartPetscObj< DM > dm) override
MoFEMErrorCode setupSolverJacobian(const TSType type=IM)
boost::shared_ptr< KelvinVoigtDamper > damperElementPtr
boost::shared_ptr< DirichletDisplacementBc > dirichletBcPtr
const string domainProblemName
MoFEMErrorCode updateElementVariables() override
VolumeElementForcesAndSourcesCore DomainEle
MoFEMErrorCode postProcessElement(int step) override
MoFEMErrorCode setupSolverJacobianSNES() override
Set of functions declaring elements and setting operators for generic element interface.
BcMarkerPtr mBoundaryMarker
Constitutive model functions.
Class used to scale loads, f.e. in arc-length control.
Data structure to exchange data between MoFEM and User Loop Methods.
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
Structure for user loop methods on finite elements.
Force scale operator for reading four columns (time and vector)
virtual FTensor::Tensor1< double, SPACE_DIM > getVector(const double time)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Force scale operator for reading two columns.
PetscBool is_quasi_static