42constexpr double rho = 1;
47#include <HenckyOps.hpp>
107 auto project_ho_geometry = [&]() {
111 CHKERR project_ho_geometry();
125 simple->getProblemName(),
"U");
136 [[maybe_unused]]
auto get_body_force = [
this](
const double,
const double,
146 auto rho_ptr = boost::make_shared<double>(
rho);
148 auto add_rho_block = [
this, rho_ptr](
auto &pip,
auto block_name,
Sev sev) {
152 OpMatRhoBlocks(boost::shared_ptr<double> rho_ptr,
154 std::vector<const CubitMeshSets *> meshset_vec_ptr)
157 "Can not get data from block");
165 for (
auto &b : blockData) {
166 if (b.blockEnts.find(getFEEntityHandle()) != b.blockEnts.end()) {
183 std::vector<BlockData> blockData;
187 std::vector<const CubitMeshSets *> meshset_vec_ptr,
191 for (
auto m : meshset_vec_ptr) {
193 std::vector<double> block_data;
194 CHKERR m->getAttributes(block_data);
195 if (block_data.size() < 1) {
197 "Expected that block has two attributes");
199 auto get_block_ents = [&]() {
202 m_field.
get_moab().get_entities_by_handle(
m->meshset, ents,
true);
207 <<
m->getName() <<
": ro = " << block_data[0];
209 blockData.push_back({block_data[0], get_block_ents()});
216 boost::shared_ptr<double> rhoPtr;
219 pip.push_back(
new OpMatRhoBlocks(
225 (boost::format(
"%s(.*)") % block_name).str()
239 [[maybe_unused]]
auto get_time_scale = [
this](
const double time) {
240 return sin(time *
omega * M_PI);
243 auto apply_lhs = [&](
auto &pip) {
247 CHKERR HenckyOps::opFactoryDomainLhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
248 mField, pip,
"U",
"MAT_ELASTIC", Sev::verbose);
249 CHKERR add_rho_block(pip,
"MAT_RHO", Sev::verbose);
251 pip.push_back(
new OpMass(
"U",
"U", get_rho));
252 static_cast<OpMass &
>(pip.back()).feScalingFun =
257 auto apply_rhs = [&](
auto &pip) {
261 pipeline_mng->getOpDomainRhsPipeline(), {H1},
"GEOMETRY");
262 CHKERR HenckyOps::opFactoryDomainRhs<SPACE_DIM, PETSC, GAUSS, DomainEleOp>(
263 mField, pip,
"U",
"MAT_ELASTIC", Sev::inform);
264 CHKERR add_rho_block(pip,
"MAT_RHO", Sev::inform);
266 auto mat_acceleration_ptr = boost::make_shared<MatrixDouble>();
269 "U", mat_acceleration_ptr));
270 pip.push_back(
new OpInertiaForce(
"U", mat_acceleration_ptr, get_rho));
274 {boost::make_shared<TimeScaleVector<SPACE_DIM>>(
"-time_vector_file",
276 "BODY_FORCE", Sev::inform);
281 CHKERR apply_lhs(pipeline_mng->getOpDomainLhsPipeline());
282 CHKERR apply_rhs(pipeline_mng->getOpDomainRhsPipeline());
290 auto get_bc_hook = [&]() {
292 mField, pipeline_mng->getDomainRhsFE(),
293 {boost::make_shared<TimeScale>()});
297 pipeline_mng->getDomainRhsFE()->preProcessHook = get_bc_hook();
318 "out_step_" + boost::lexical_cast<std::string>(
ts_step) +
".h5m");
325 boost::shared_ptr<PostProcEle>
postProc;
334 auto dm =
simple->getDM();
336 ts = pipeline_mng->createTSIM2();
339 auto post_proc_fe = boost::make_shared<PostProcEle>(
mField);
341 post_proc_fe->getOpPtrVector(), {H1});
342 auto common_ptr = commonDataFactory<SPACE_DIM, GAUSS, DomainEleOp>(
343 mField, post_proc_fe->getOpPtrVector(),
"U",
"MAT_ELASTIC", Sev::inform);
345 auto u_ptr = boost::make_shared<MatrixDouble>();
346 post_proc_fe->getOpPtrVector().push_back(
348 auto X_ptr = boost::make_shared<MatrixDouble>();
349 post_proc_fe->getOpPtrVector().push_back(
354 post_proc_fe->getOpPtrVector().push_back(
358 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
362 {{
"U", u_ptr}, {
"GEOMETRY", X_ptr}},
364 {{
"GRAD", common_ptr->matGradPtr},
365 {
"FIRST_PIOLA", common_ptr->getMatFirstPiolaStress()}},
374 boost::shared_ptr<FEMethod> null_fe;
375 auto monitor_ptr = boost::make_shared<Monitor>(dm, post_proc_fe);
377 null_fe, monitor_ptr);
381 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
387 CHKERR TS2SetSolution(ts, T, TT);
389 CHKERR TSSetI2Jacobian(ts,
B,
B, PETSC_NULLPTR, PETSC_NULLPTR);
390 CHKERR TSSetFromOptions(ts);
393 CHKERR TSGetTime(ts, &ftime);
395 PetscInt steps, snesfails, rejects, nonlinits, linits;
396#if PETSC_VERSION_GE(3, 8, 0)
397 CHKERR TSGetStepNumber(ts, &steps);
399 CHKERR TSGetStepNumber(ts, &steps);
401 CHKERR TSGetSNESFailures(ts, &snesfails);
402 CHKERR TSGetStepRejections(ts, &rejects);
403 CHKERR TSGetSNESIterations(ts, &nonlinits);
404 CHKERR TSGetKSPIterations(ts, &linits);
406 "steps %d (%d rejected, %d SNES fails), ftime %g, nonlinits "
408 steps, rejects, snesfails, ftime, nonlinits, linits);
417 PetscBool test_flg = PETSC_FALSE;
425 CHKERR VecNorm(T, NORM_2, &nrm2);
426 MOFEM_LOG(
"EXAMPLE", Sev::inform) <<
"Regression norm " << nrm2;
427 constexpr double regression_value = 0.0194561;
428 if (fabs(nrm2 - regression_value) > 1e-2)
430 "Regression test failed; wrong norm value.");
445int main(
int argc,
char *argv[]) {
448 const char param_file[] =
"param_file.petsc";
452 auto core_log = logging::core::get();
461 DMType dm_name =
"DMMOFEM";
466 moab::Core mb_instance;
467 moab::Interface &moab = mb_instance;
#define MOFEM_LOG_C(channel, severity, format,...)
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ AINSWORTH_BERNSTEIN_BEZIER_BASE
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#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 ...
@ MOFEM_ATOM_TEST_INVALID
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, SPACE_DIM > OpInertiaForce
constexpr double omega
Save field DOFS on vertices/tags.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
auto createDMMatrix(DM dm)
Get smart matrix from DM.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
SeverityLevel
Severity levels.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
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
PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
Set Monitor To TS solver.
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
static char help[]
[Check]
constexpr double poisson_ratio
constexpr double young_modulus
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
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::Index< 'm', 3 > m
MoFEMErrorCode boundaryCondition()
MoFEMErrorCode assembleSystem()
MoFEMErrorCode readMesh()
MoFEMErrorCode checkResults()
MoFEMErrorCode solveSystem()
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
MoFEM::Interface & mField
Reference to MoFEM interface.
MoFEMErrorCode setupProblem()
MoFEMErrorCode outputResults()
Add operators pushing bases from local to physical configuration.
Boundary condition manager for finite element problem setup.
virtual moab::Interface & get_moab()=0
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Definition of the displacement bc data structure.
Data on single entity (This is passed as argument to DataOperator::doWork)
Class (Function) to enforce essential constrains.
Structure for user loop methods on finite elements.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Interface for managing meshsets containing materials and boundary conditions.
Approximate field values for given petsc vector.
Specialization for MatrixDouble vector field values calculation.
Post post-proc data at points from hash maps.
PipelineManager interface.
Projection of edge entities with one mid-node on hierarchical basis.
Simple interface for fast problem set-up.
MoFEMErrorCode addDomainField(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
MoFEMErrorCode getOptions()
get options
intrusive_ptr for managing petsc objects
PetscInt ts_step
Current time step number.
PetscReal ts_aa
Shift parameter for U_tt (second time derivative)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Volume finite element base.
[Push operators to pipeline]
Monitor(SmartPetscObj< DM > dm, boost::shared_ptr< PostProcEle > post_proc)
MoFEMErrorCode postProcess()
Post-processing function executed at loop completion.
boost::shared_ptr< PostProcEle > postProc
#define EXECUTABLE_DIMENSION