25 using namespace MoFEM;
45 GAUSS>::OpGradTensorGrad<1, SPACE_DIM, SPACE_DIM, 1>;
51 GAUSS>::OpSource<1, SPACE_DIM>;
56 constexpr
double rho = 1;
103 auto set_matrial_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 matAccelerationPtr = boost::make_shared<MatrixDouble>();
125 matInertiaPtr = boost::make_shared<MatrixDouble>();
126 matDPtr = boost::make_shared<MatrixDouble>();
128 matTangentPtr = boost::make_shared<MatrixDouble>();
131 matDPtr->resize(size_symm * size_symm, 1);
133 CHKERR set_matrial_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(),
193 "FIX_ALL",
"U", 0, 3);
206 auto det_ptr = boost::make_shared<VectorDouble>();
207 auto jac_ptr = boost::make_shared<MatrixDouble>();
208 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
209 pipeline_mng->getOpDomainLhsPipeline().push_back(
211 pipeline_mng->getOpDomainLhsPipeline().push_back(
213 pipeline_mng->getOpDomainLhsPipeline().push_back(
215 pipeline_mng->getOpDomainRhsPipeline().push_back(
217 pipeline_mng->getOpDomainRhsPipeline().push_back(
219 pipeline_mng->getOpDomainRhsPipeline().push_back(
224 auto get_rho = [
this](
const double,
const double,
const double) {
226 auto &fe_domain_lhs = pipeline_mng->getDomainLhsFE();
227 return rho * fe_domain_lhs->ts_aa;
230 auto get_body_force = [
this](
const double,
const double,
const double) {
232 auto fe_domain_rhs = pipeline_mng->getDomainRhsFE();
238 const auto time = fe_domain_rhs->ts_t;
239 t_source(
i) *= sin(time *
omega * M_PI);
243 auto henky_common_data_ptr = boost::make_shared<HenckyOps::CommonData>();
244 henky_common_data_ptr->matGradPtr = matGradPtr;
245 henky_common_data_ptr->matDPtr = matDPtr;
247 pipeline_mng->getOpDomainLhsPipeline().push_back(
251 pipeline_mng->getOpDomainLhsPipeline().push_back(
253 pipeline_mng->getOpDomainLhsPipeline().push_back(
255 pipeline_mng->getOpDomainLhsPipeline().push_back(
257 pipeline_mng->getOpDomainLhsPipeline().push_back(
259 pipeline_mng->getOpDomainLhsPipeline().push_back(
261 pipeline_mng->getOpDomainLhsPipeline().push_back(
263 pipeline_mng->getOpDomainLhsPipeline().push_back(
264 new OpK(
"U",
"U", henky_common_data_ptr->getMatTangent()));
267 pipeline_mng->getOpDomainLhsPipeline().push_back(
268 new OpMass(
"U",
"U", get_rho));
270 pipeline_mng->getOpDomainRhsPipeline().push_back(
272 pipeline_mng->getOpDomainRhsPipeline().push_back(
276 pipeline_mng->getOpDomainRhsPipeline().push_back(
278 pipeline_mng->getOpDomainRhsPipeline().push_back(
280 pipeline_mng->getOpDomainRhsPipeline().push_back(
282 pipeline_mng->getOpDomainRhsPipeline().push_back(
284 pipeline_mng->getOpDomainRhsPipeline().push_back(
288 "U", henky_common_data_ptr->getMatFirstPiolaStress()));
290 pipeline_mng->getOpDomainRhsPipeline().push_back(
292 matAccelerationPtr));
293 pipeline_mng->getOpDomainRhsPipeline().push_back(
295 pipeline_mng->getOpDomainRhsPipeline().push_back(
new OpInertiaForce(
296 "U", matInertiaPtr, [](
double,
double,
double) {
return 1.; }));
317 : dM(dm), postProc(post_proc){};
323 CHKERR postProc->writeFile(
324 "out_step_" + boost::lexical_cast<std::string>(ts_step) +
".h5m");
340 auto dm =
simple->getDM();
343 ts = pipeline_mng->createTSIM();
345 ts = pipeline_mng->createTSIM2();
348 auto post_proc_fe = boost::make_shared<PostProcEle>(mField);
349 post_proc_fe->generateReferenceElementMesh();
351 auto det_ptr = boost::make_shared<VectorDouble>();
352 auto jac_ptr = boost::make_shared<MatrixDouble>();
353 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
354 post_proc_fe->getOpPtrVector().push_back(
356 post_proc_fe->getOpPtrVector().push_back(
358 post_proc_fe->getOpPtrVector().push_back(
361 post_proc_fe->getOpPtrVector().push_back(
364 post_proc_fe->getOpPtrVector().push_back(
366 post_proc_fe->getOpPtrVector().push_back(
368 "U", matStrainPtr, matStressPtr, matDPtr));
370 "U", post_proc_fe->postProcMesh, post_proc_fe->mapGaussPts, matStrainPtr,
372 post_proc_fe->addFieldValuesPostProc(
"U");
375 boost::shared_ptr<FEMethod> null_fe;
376 auto monitor_ptr = boost::make_shared<Monitor>(dm, post_proc_fe);
378 null_fe, monitor_ptr);
382 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
389 CHKERR TSSetFromOptions(ts);
392 CHKERR TS2SetSolution(ts,
T, TT);
393 CHKERR TSSetFromOptions(ts);
397 CHKERR TSGetTime(ts, &ftime);
399 PetscInt steps, snesfails, rejects, nonlinits, linits;
400 #if PETSC_VERSION_GE(3, 8, 0)
401 CHKERR TSGetStepNumber(ts, &steps);
403 CHKERR TSGetTimeStepNumber(ts, &steps);
405 CHKERR TSGetSNESFailures(ts, &snesfails);
406 CHKERR TSGetStepRejections(ts, &rejects);
407 CHKERR TSGetSNESIterations(ts, &nonlinits);
408 CHKERR TSGetKSPIterations(ts, &linits);
410 "steps %D (%D rejected, %D SNES fails), ftime %g, nonlinits "
412 steps, rejects, snesfails, ftime, nonlinits, linits);
421 PetscBool test_flg = PETSC_FALSE;
429 CHKERR VecNorm(
T, NORM_2, &nrm2);
430 MOFEM_LOG(
"EXAMPLE", Sev::inform) <<
"Regression norm " << nrm2;
431 constexpr
double regression_value = 1.09572;
432 if (fabs(nrm2 - regression_value) > 1e-2)
434 "Regression test faileed; wrong norm value.");
447 static char help[] =
"...\n\n";
449 int main(
int argc,
char *argv[]) {
456 auto core_log = logging::core::get();
465 DMType dm_name =
"DMMOFEM";
#define MOFEM_LOG_C(channel, severity, format,...)
Post-process fields on refined mesh.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
Kronecker Delta class symmetric.
int main(int argc, char *argv[])
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpInternalForce
static char help[]
[Check]
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradTensorGrad< 1, SPACE_DIM, SPACE_DIM, 1 > OpK
static double * ts_aa_ptr
constexpr double poisson_ratio
constexpr double shear_modulus_G
constexpr double bulk_modulus_K
DataForcesAndSourcesCore::EntData EntData
static double * ts_time_ptr
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< 1, SPACE_DIM > OpBodyForce
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, 1 > OpInertiaForce
constexpr bool is_quasi_static
constexpr double young_modulus
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_BERNSTEIN_BEZIER_BASE
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
#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.
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.
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
SmartPetscObj< Vec > smartVectorDuplicate(SmartPetscObj< Vec > &vec)
Create duplicate vector of smart vector.
static constexpr int approx_order
MoFEMErrorCode boundaryCondition()
[Set up problem]
MoFEMErrorCode assembleSystem()
[Boundary condition]
MoFEMErrorCode readMesh()
[Run problem]
boost::shared_ptr< MatrixDouble > matTangentPtr
boost::shared_ptr< MatrixDouble > matAccelerationPtr
boost::shared_ptr< MatrixDouble > matInertiaPtr
boost::shared_ptr< MatrixDouble > matGradPtr
boost::shared_ptr< MatrixDouble > matStressPtr
boost::shared_ptr< MatrixDouble > matStrainPtr
MoFEMErrorCode checkResults()
[Postprocess results]
MoFEMErrorCode solveSystem()
[Solve]
MoFEMErrorCode createCommonData()
[Create common data]
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
[Create common data]
MoFEM::Interface & mField
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode outputResults()
[Solve]
boost::shared_ptr< MatrixDouble > matDPtr
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.
Data on single entity (This is passed as argument to DataOperator::doWork)
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.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Approximate field valuse for given petsc vector.
PipelineManager interface.
Simple interface for fast problem set-up.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Volume finite element base.
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
boost::shared_ptr< PostProcEle > postProc