26 using namespace MoFEM;
56 GAUSS>::OpGradTensorGrad<1, SPACE_DIM, SPACE_DIM, 1>;
61 GAUSS>::OpSource<1, SPACE_DIM>;
92 boost::shared_ptr<MatrixDouble> matGradPtr;
93 boost::shared_ptr<MatrixDouble> matStrainPtr;
94 boost::shared_ptr<MatrixDouble> matStressPtr;
95 boost::shared_ptr<MatrixDouble> matDPtr;
96 boost::shared_ptr<HenckyOps::CommonData> commonHenckyDataPtr;
103 auto set_material_stiffness = [&]() {
114 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*matDPtr);
121 matGradPtr = boost::make_shared<MatrixDouble>();
122 matStrainPtr = boost::make_shared<MatrixDouble>();
123 matStressPtr = boost::make_shared<MatrixDouble>();
124 matDPtr = boost::make_shared<MatrixDouble>();
126 commonHenckyDataPtr = boost::make_shared<HenckyOps::CommonData>();
127 commonHenckyDataPtr->matGradPtr = matGradPtr;
128 commonHenckyDataPtr->matDPtr = matDPtr;
131 matDPtr->resize(size_symm * size_symm, 1);
133 CHKERR set_material_stiffness();
144 CHKERR createCommonData();
145 CHKERR boundaryCondition();
186 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX_X",
188 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX_Y",
190 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX_Z",
192 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX_ALL",
195 auto get_time = [&](double, double, double) {
198 return fe_domain_rhs->ts_t;
202 if (it->getName().compare(0, 5,
"FORCE") == 0) {
204 std::vector<double> attr_vec;
205 CHKERR it->getMeshsetIdEntitiesByDimension(mField.get_moab(), 1,
207 it->getAttributes(attr_vec);
210 "Wrong size of boundary attributes vector. Set right block "
212 auto force_vec_ptr = boost::make_shared<MatrixDouble>(
SPACE_DIM, 1);
213 std::copy(&attr_vec[0], &attr_vec[
SPACE_DIM],
214 force_vec_ptr->data().begin());
215 pipeline_mng->getOpBoundaryRhsPipeline().push_back(
217 boost::make_shared<Range>(force_edges)));
222 auto get_body_force = [
this](
const double,
const double,
const double) {
227 const auto time = fe_domain_rhs->ts_t;
230 t_source(1) = 1 * time;
235 pipeline_mng->getOpDomainRhsPipeline().push_back(
248 auto add_domain_base_ops = [&](
auto &pipeline) {
251 auto det_ptr = boost::make_shared<VectorDouble>();
252 auto jac_ptr = boost::make_shared<MatrixDouble>();
253 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
275 auto add_domain_ops_lhs = [&](
auto &pipeline) {
280 pipeline.push_back(
new OpK(
"U",
"U", commonHenckyDataPtr->getMatTangent()));
285 auto add_domain_ops_rhs = [&](
auto &pipeline) {
289 "U", commonHenckyDataPtr->getMatFirstPiolaStress()));
294 CHKERR add_domain_base_ops(pipeline_mng->getOpDomainLhsPipeline());
295 CHKERR add_domain_ops_lhs(pipeline_mng->getOpDomainLhsPipeline());
296 CHKERR add_domain_base_ops(pipeline_mng->getOpDomainRhsPipeline());
297 CHKERR add_domain_ops_rhs(pipeline_mng->getOpDomainRhsPipeline());
319 : dM(dm), postProc(post_proc){};
325 CHKERR postProc->writeFile(
326 "out_step_" + boost::lexical_cast<std::string>(ts_step) +
".h5m");
333 boost::shared_ptr<PostProcEle> postProc;
342 auto dm =
simple->getDM();
343 auto ts = pipeline_mng->createTSIM();
346 auto post_proc_fe = boost::make_shared<PostProcEle>(mField);
347 post_proc_fe->generateReferenceElementMesh();
349 auto det_ptr = boost::make_shared<VectorDouble>();
350 auto jac_ptr = boost::make_shared<MatrixDouble>();
351 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
352 post_proc_fe->getOpPtrVector().push_back(
354 post_proc_fe->getOpPtrVector().push_back(
356 post_proc_fe->getOpPtrVector().push_back(
359 post_proc_fe->getOpPtrVector().push_back(
361 "U", commonHenckyDataPtr->matGradPtr));
362 post_proc_fe->getOpPtrVector().push_back(
364 post_proc_fe->getOpPtrVector().push_back(
366 post_proc_fe->getOpPtrVector().push_back(
368 post_proc_fe->getOpPtrVector().push_back(
370 post_proc_fe->getOpPtrVector().push_back(
374 "U", post_proc_fe->postProcMesh, post_proc_fe->mapGaussPts,
375 commonHenckyDataPtr));
377 post_proc_fe->addFieldValuesPostProc(
"U");
380 boost::shared_ptr<FEMethod> null_fe;
381 auto monitor_ptr = boost::make_shared<Monitor>(dm, post_proc_fe);
383 null_fe, monitor_ptr);
386 CHKERR TSSetDuration(ts, PETSC_DEFAULT, ftime);
387 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
392 CHKERR TSSetFromOptions(ts);
395 CHKERR TSGetTime(ts, &ftime);
397 PetscInt steps, snesfails, rejects, nonlinits, linits;
398 CHKERR TSGetTimeStepNumber(ts, &steps);
399 CHKERR TSGetSNESFailures(ts, &snesfails);
400 CHKERR TSGetStepRejections(ts, &rejects);
401 CHKERR TSGetSNESIterations(ts, &nonlinits);
402 CHKERR TSGetKSPIterations(ts, &linits);
404 "steps %D (%D rejected, %D SNES fails), ftime %g, nonlinits "
406 steps, rejects, snesfails, ftime, nonlinits, linits);
415 PetscBool test_flg = PETSC_FALSE;
423 CHKERR VecNorm(
T, NORM_2, &nrm2);
424 MOFEM_LOG(
"EXAMPLE", Sev::inform) <<
"Regression norm " << nrm2;
425 constexpr
double regression_value = 1.09572;
426 if (fabs(nrm2 - regression_value) > 1e-2)
428 "Regression test faileed; wrong norm value.");
441 static char help[] =
"...\n\n";
443 int main(
int argc,
char *argv[]) {
450 auto core_log = logging::core::get();
459 DMType dm_name =
"DMMOFEM";
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MOFEM_LOG_C(channel, severity, format,...)
void simple(double P1[], double P2[], double P3[], double c[], const int N)
int main(int argc, char *argv[])
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
Kronecker Delta class symmetric.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpInternalForce
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, SPACE_DIM > OpBodyForce
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#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.
auto smartCreateDMVector
Get smart vector from DM.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
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.
FaceElementForcesAndSourcesCoreSwitch< 0 > FaceElementForcesAndSourcesCore
Face finite element default.
VolumeElementForcesAndSourcesCoreSwitch< 0 > VolumeElementForcesAndSourcesCore
Volume finite element default.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#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
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
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)
OpCalculateHOJacForFaceImpl< 2 > OpCalculateHOJacForFace
DeprecatedCoreInterface Interface
const double D
diffusivity
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, 0 > OpBoundaryVec
static constexpr int approx_order
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
PipelineManager::FaceEle DomainEle
MoFEMErrorCode boundaryCondition()
MoFEMErrorCode assembleSystem()
MoFEMErrorCode readMesh()
MoFEMErrorCode checkResults()
MoFEMErrorCode solveSystem()
MoFEMErrorCode createCommonData()
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
MoFEMErrorCode setupProblem()
MoFEMErrorCode outputResults()
Simple interface for fast problem set-up.
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.
default operator for EDGE element
Data on single entity (This is passed as argument to DataOperator::doWork)
structure for User Loop Methods on finite elements
default operator for TRI element
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.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
PipelineManager interface.
boost::shared_ptr< FEMethod > & getDomainRhsFE()
MoFEM::FaceElementForcesAndSourcesCore FaceEle
MoFEM::EdgeElementForcesAndSourcesCore EdgeEle
Simple interface for fast problem set-up.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Volume finite element with switches.
VolumeElementForcesAndSourcesCoreBase::UserDataOperator UserDataOperator
[Push operators to pipeline]
Monitor(SmartPetscObj< DM > dm, boost::shared_ptr< PostProcEle > post_proc)
MoFEMErrorCode postProcess()
function is run at the end of loop
EntitiesFieldData::EntData EntData
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpInternalForce
static char help[]
[Check]
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradTensorGrad< 1, SPACE_DIM, SPACE_DIM, 1 > OpK
constexpr double poisson_ratio
constexpr double shear_modulus_G
constexpr double bulk_modulus_K
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, 0 > OpBoundaryVec
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, SPACE_DIM > OpBodyForce
constexpr double young_modulus