v0.16.0
Loading...
Searching...
No Matches
dynamic_first_order_con_law.cpp
Go to the documentation of this file.
1/**
2 * \file dynamic_first_order_con_law.cpp
3 * \example mofem/tutorials/adv-4_dynamic_first_order_con_law/dynamic_first_order_con_law.cpp
4 *
5 * Explicit first order conservation laws for solid dynamics
6 *
7 */
8
9#include <MoFEM.hpp>
10#include <MatrixFunction.hpp>
11
12using namespace MoFEM;
13
14template <typename T> inline double trace(FTensor::Tensor2<T, 2, 2> &t_stress) {
15 return (t_stress(0, 0) + t_stress(1, 1));
16};
17
18template <typename T> inline double trace(FTensor::Tensor2<T, 3, 3> &t_stress) {
19 return (t_stress(0, 0) + t_stress(1, 1) + t_stress(2, 2));
20};
21
22constexpr int SPACE_DIM =
23 EXECUTABLE_DIMENSION; //< Space dimension of problem, mesh
24
27using DomainEleOp = DomainEle::UserDataOperator;
31
34using BoundaryEleOp = BoundaryEle::UserDataOperator;
36
37template <int DIM> struct PostProcEleByDim;
38
44
50
54
59
62
64 GAUSS>::OpBaseTimesVector<1, SPACE_DIM, 0>;
65
70 SPACE_DIM>;
71
75
78 IntegrationType::GAUSS>::OpBaseTimesVector<1, SPACE_DIM * SPACE_DIM,
80
84
88
89/** \brief Save field DOFS on vertices/tags
90 */
91
92constexpr double omega = 1.;
93constexpr double young_modulus = 1.;
94constexpr double poisson_ratio = 0.;
95double bulk_modulus_K = young_modulus / (3. * (1. - 2. * poisson_ratio));
97double mu = young_modulus / (2. * (1. + poisson_ratio));
99 ((1. + poisson_ratio) * (1. - 2. * poisson_ratio));
100
101// Operator to Calculate F
102template <int DIM_0, int DIM_1>
104 OpCalculateFStab(boost::shared_ptr<MatrixDouble> def_grad_ptr,
105 boost::shared_ptr<MatrixDouble> def_grad_stab_ptr,
106 boost::shared_ptr<MatrixDouble> def_grad_dot_ptr,
107 double tau_F_ptr, double xi_F_ptr,
108 boost::shared_ptr<MatrixDouble> grad_x_ptr,
109 boost::shared_ptr<MatrixDouble> grad_vel_ptr)
111 defGradPtr(def_grad_ptr), defGradStabPtr(def_grad_stab_ptr),
112 defGradDotPtr(def_grad_dot_ptr), tauFPtr(tau_F_ptr), xiF(xi_F_ptr),
113 gradxPtr(grad_x_ptr), gradVelPtr(grad_vel_ptr) {}
114
115 MoFEMErrorCode doWork(int side, EntityType type,
116 DataForcesAndSourcesCore::EntData &data) {
118 // Define Indicies
121
122 // Number of Gauss points
123 const size_t nb_gauss_pts = getGaussPts().size2();
124
125 defGradStabPtr->resize(nb_gauss_pts, DIM_0 * DIM_1, false);
126 defGradStabPtr->clear();
127
128 // Extract matrix from data matrix
129 auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradPtr);
130 auto t_Fstab = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradStabPtr);
131 auto t_F_dot = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradDotPtr);
132
133 // tau_F = alpha deltaT
134 auto tau_F = tauFPtr;
135 double xi_F = xiF;
136 auto t_gradx = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*gradxPtr);
137 auto t_gradVel = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*gradVelPtr);
138
139 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
140 // Stabilised Deformation Gradient
141 t_Fstab(i, j) = t_F(i, j) + tau_F * (t_gradVel(i, j) - t_F_dot(i, j)) +
142 xi_F * (t_gradx(i, j) - t_F(i, j));
143
144 ++t_F;
145 ++t_Fstab;
146 ++t_gradVel;
147 ++t_F_dot;
148
149 ++t_gradx;
150 }
151
153 }
154
155private:
156 double tauFPtr;
157 double xiF;
158 boost::shared_ptr<MatrixDouble> defGradPtr;
159 boost::shared_ptr<MatrixDouble> defGradStabPtr;
160 boost::shared_ptr<MatrixDouble> defGradDotPtr;
161 boost::shared_ptr<MatrixDouble> gradxPtr;
162 boost::shared_ptr<MatrixDouble> gradVelPtr;
163};
164
165// Operator to Calculate P
166template <int DIM_0, int DIM_1>
168 OpCalculatePiola(double shear_modulus, double bulk_modulus, double m_u,
169 double lambda_lamme,
170 boost::shared_ptr<MatrixDouble> first_piola_ptr,
171 boost::shared_ptr<MatrixDouble> def_grad_ptr)
173 shearModulus(shear_modulus), bulkModulus(bulk_modulus), mU(m_u),
174 lammeLambda(lambda_lamme), firstPiolaPtr(first_piola_ptr),
175 defGradPtr(def_grad_ptr) {}
176
177 MoFEMErrorCode doWork(int side, EntityType type,
178 DataForcesAndSourcesCore::EntData &data) {
180 // Define Indicies
184
185 // Define Kronecker Delta
186 constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
187
188 // Number of Gauss points
189 const size_t nb_gauss_pts = getGaussPts().size2();
190
191 // Resize Piola
192 firstPiolaPtr->resize(nb_gauss_pts, DIM_0 * DIM_1, false); // ignatios check
193 firstPiolaPtr->clear();
194
195 // Extract matrix from data matrix
196 auto t_P = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*firstPiolaPtr);
197 auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradPtr);
198 const double two_o_three = 2. / 3.;
199 const double trace_t_dk = DIM_0;
200 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
201
202 t_P(i, j) = shearModulus * (t_F(i, j) + t_F(j, i) - 2. * t_kd(i, j) -
203 two_o_three * trace(t_F) * t_kd(i, j) +
204 two_o_three * trace_t_dk * t_kd(i, j)) +
205 bulkModulus * trace(t_F) * t_kd(i, j) -
206 bulkModulus * trace_t_dk * t_kd(i, j);
207
208 ++t_F;
209 ++t_P;
210 }
211
213 }
214
215private:
218 double mU;
220 boost::shared_ptr<MatrixDouble> firstPiolaPtr;
221 boost::shared_ptr<MatrixDouble> defGradPtr;
222};
223
224template <int DIM>
226 OpCalculateDisplacement(boost::shared_ptr<MatrixDouble> spatial_pos_ptr,
227 boost::shared_ptr<MatrixDouble> reference_pos_ptr,
228 boost::shared_ptr<MatrixDouble> u_ptr)
230 xPtr(spatial_pos_ptr), XPtr(reference_pos_ptr), uPtr(u_ptr) {}
231
232 MoFEMErrorCode doWork(int side, EntityType type,
233 DataForcesAndSourcesCore::EntData &data) {
235 // Define Indicies
236 FTensor::Index<'i', DIM> i;
237
238 // Number of Gauss points
239 const size_t nb_gauss_pts = getGaussPts().size2();
240
241 uPtr->resize(DIM, nb_gauss_pts, false); // ignatios check
242 uPtr->clear();
243
244 // Extract matrix from data matrix
245 auto t_x = getFTensor1FromMat<DIM>(*xPtr);
246 auto t_X = getFTensor1FromMat<DIM>(*XPtr);
247 auto t_u = getFTensor1FromMat<DIM>(*uPtr);
248 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
249
250 t_u(i) = t_x(i) - t_X(i);
251 ++t_u;
252 ++t_x;
253 ++t_X;
254 }
255
257 }
258
259private:
260 boost::shared_ptr<MatrixDouble> xPtr;
261 boost::shared_ptr<MatrixDouble> XPtr;
262 boost::shared_ptr<MatrixDouble> uPtr;
263};
264
265template <int DIM_0, int DIM_1>
269 double shear_modulus, double bulk_modulus, double m_u,
270 double lambda_lamme, boost::shared_ptr<MatrixDouble> first_piola_ptr,
271 boost::shared_ptr<MatrixDouble> def_grad_ptr,
272 boost::shared_ptr<MatrixDouble> inv_def_grad_ptr,
273 boost::shared_ptr<VectorDouble> det)
275 shearModulus(shear_modulus), bulkModulus(bulk_modulus), mU(m_u),
276 lammeLambda(lambda_lamme), firstPiolaPtr(first_piola_ptr),
277 defGradPtr(def_grad_ptr), invDefGradPtr(inv_def_grad_ptr), dEt(det) {}
278
279 MoFEMErrorCode doWork(int side, EntityType type,
280 DataForcesAndSourcesCore::EntData &data) {
282 // Define Indicies
287
288 // Number of Gauss points
289 const size_t nb_gauss_pts = getGaussPts().size2();
290
291 // Resize Piola
292 firstPiolaPtr->resize(nb_gauss_pts, DIM_0 * DIM_1, false); // ignatios check
293 firstPiolaPtr->clear();
294
295 // Extract matrix from data matrix
296 auto t_P = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*firstPiolaPtr);
297 auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradPtr);
298 auto t_inv_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*invDefGradPtr);
299 auto t_det = getFTensor0FromVec<1>(*dEt);
300 const double two_o_three = 2. / 3.;
301 const double one_o_three = 1. / 3.;
302 const double bulk_mod = bulkModulus;
303 const double shear_mod = shearModulus;
304 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
305
306 // Nearly incompressible NH
307 // volumetric part
308 t_P(i, j) = bulk_mod * (t_det - 1.) * t_det * t_inv_F(j, i);
309 // deviatoric part
310 t_P(i, j) +=
311 shear_mod * pow(t_det, two_o_three) *
312 (t_F(i, j) - one_o_three * (t_F(l, k) * t_F(l, k)) * t_inv_F(j, i));
313
314 ++t_F;
315 ++t_P;
316 ++t_inv_F;
317 ++t_det;
318 }
319
321 }
322
323private:
326 double mU;
328 boost::shared_ptr<MatrixDouble> firstPiolaPtr;
329 boost::shared_ptr<MatrixDouble> defGradPtr;
330 boost::shared_ptr<MatrixDouble> invDefGradPtr;
331 boost::shared_ptr<VectorDouble> dEt;
332};
333
334template <int DIM_0, int DIM_1>
338 boost::shared_ptr<MatrixDouble> def_grad_ptr,
339 boost::shared_ptr<MatrixDouble> grad_tensor_ptr)
341 defGradPtr(def_grad_ptr), gradTensorPtr(grad_tensor_ptr) {}
342
343 MoFEMErrorCode doWork(int side, EntityType type,
344 DataForcesAndSourcesCore::EntData &data) {
346 // Define Indicies
349
350 // Define Kronecker Delta
351 constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
352
353 // Number of Gauss points
354 const size_t nb_gauss_pts = getGaussPts().size2();
355
356 // Resize Piola
357 defGradPtr->resize(nb_gauss_pts, DIM_0 * DIM_1, false);
358 defGradPtr->clear();
359
360 // Extract matrix from data matrix
361 auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradPtr);
362 auto t_H = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*gradTensorPtr);
363 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
364
365 t_F(i, j) = t_H(i, j) + t_kd(i, j);
366
367 ++t_F;
368 ++t_H;
369 }
370
372 }
373
374private:
375 boost::shared_ptr<MatrixDouble> gradTensorPtr;
376 boost::shared_ptr<MatrixDouble> defGradPtr;
377};
378
379struct Example;
381
382 TSPrePostProc() = default;
383 virtual ~TSPrePostProc() = default;
384
385 /**
386 * @brief Used to setup TS solver
387 *
388 * @param ts
389 * @return MoFEMErrorCode
390 */
391 MoFEMErrorCode tsSetUp(TS ts);
392
393 // SmartPetscObj<VecScatter> getScatter(Vec x, Vec y, enum FR fr);
395 static MoFEMErrorCode tsPostStage(TS ts, PetscReal stagetime,
396 PetscInt stageindex, Vec *Y);
397 static MoFEMErrorCode tsPostStep(TS ts);
398 static MoFEMErrorCode tsPreStep(TS ts);
399};
400
401static boost::weak_ptr<TSPrePostProc> tsPrePostProc;
402
405 double getScale(const double time) {
406 return sin(2. * M_PI * MoFEM::TimeScale::getScale(time));
407 };
408};
409
410struct CommonData {
411 SmartPetscObj<Mat> M; ///< Mass matrix
412 SmartPetscObj<KSP> ksp; ///< Linear solver
413};
414
415struct Example {
416
417 Example(MoFEM::Interface &m_field) : mField(m_field) {}
418
420
421private:
423
431 friend struct TSPrePostProc;
432
435 double getScale(const double time) { return 0.001 * sin(0.1 * time); };
436 };
437
440 double getScale(const double time) { return 0.001; };
441 };
442};
443
444//! [Run problem]
455}
456//! [Run problem]
457
458//! [Read mesh]
467//! [Read mesh]
468
469//! [Set up problem]
473 enum bases { AINSWORTH, DEMKOWICZ, LASBASETOPT };
474 const char *list_bases[LASBASETOPT] = {"ainsworth", "demkowicz"};
475 PetscInt choice_base_value = AINSWORTH;
476 CHKERR PetscOptionsGetEList(PETSC_NULLPTR, NULL, "-base", list_bases,
477 LASBASETOPT, &choice_base_value, PETSC_NULLPTR);
478
480 switch (choice_base_value) {
481 case AINSWORTH:
483 MOFEM_LOG("WORLD", Sev::inform)
484 << "Set AINSWORTH_LEGENDRE_BASE for displacements";
485 break;
486 case DEMKOWICZ:
488 MOFEM_LOG("WORLD", Sev::inform)
489 << "Set DEMKOWICZ_JACOBI_BASE for displacements";
490 break;
491 default:
492 base = LASTBASE;
493 break;
494 }
495 // Add field
496 CHKERR simple->addDomainField("V", H1, base, SPACE_DIM);
497 CHKERR simple->addBoundaryField("V", H1, base, SPACE_DIM);
498 CHKERR simple->addDomainField("F", H1, base, SPACE_DIM * SPACE_DIM);
499 CHKERR simple->addDataField("x_1", H1, base, SPACE_DIM);
500 CHKERR simple->addDataField("x_2", H1, base, SPACE_DIM);
501 CHKERR simple->addDataField("F_0", H1, base, SPACE_DIM * SPACE_DIM);
502 CHKERR simple->addDataField("F_dot", H1, base, SPACE_DIM * SPACE_DIM);
503
504 CHKERR simple->addDataField("GEOMETRY", H1, base, SPACE_DIM);
505 int order = 2;
506 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-order", &order, PETSC_NULLPTR);
507 CHKERR simple->setFieldOrder("V", order);
508 CHKERR simple->setFieldOrder("F", order);
509 CHKERR simple->setFieldOrder("F_0", order);
510 CHKERR simple->setFieldOrder("F_dot", order);
511 CHKERR simple->setFieldOrder("x_1", order);
512 CHKERR simple->setFieldOrder("x_2", order);
513 CHKERR simple->setFieldOrder("GEOMETRY", order);
514 CHKERR simple->setUp();
515
516 auto project_ho_geometry = [&]() {
517 Projection10NodeCoordsOnField ent_method_x(mField, "x_1");
518 CHKERR mField.loop_dofs("x_1", ent_method_x);
519 Projection10NodeCoordsOnField ent_method_x_2(mField, "x_2");
520 CHKERR mField.loop_dofs("x_2", ent_method_x_2);
521
522 Projection10NodeCoordsOnField ent_method(mField, "GEOMETRY");
523 return mField.loop_dofs("GEOMETRY", ent_method);
524 };
525 CHKERR project_ho_geometry();
526
528}
529//! [Set up problem]
530
531//! [Boundary condition]
534
536 auto bc_mng = mField.getInterface<BcManager>();
537 auto *pipeline_mng = mField.getInterface<PipelineManager>();
538 auto time_scale = boost::make_shared<TimeScale>();
539
540 PetscBool sin_time_function = PETSC_FALSE;
541 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-sin_time_function",
542 &sin_time_function, PETSC_NULLPTR);
543
544 if (sin_time_function)
545 time_scale = boost::make_shared<DynamicFirstOrderConsSinusTimeScale>();
546 else
547 time_scale = boost::make_shared<DynamicFirstOrderConsConstantTimeScale>();
548
549 pipeline_mng->getBoundaryExplicitRhsFE().reset();
551 pipeline_mng->getOpBoundaryExplicitRhsPipeline(), {NOSPACE}, "GEOMETRY");
552
554 pipeline_mng->getOpBoundaryExplicitRhsPipeline(), mField, "V",
555 {time_scale}, "FORCE", "PRESSURE", Sev::inform);
556
557 auto integration_rule = [](int, int, int approx_order) {
558 return 2 * approx_order;
559 };
560
561 CHKERR pipeline_mng->setBoundaryExplicitRhsIntegrationRule(integration_rule);
562 CHKERR pipeline_mng->setDomainExplicitRhsIntegrationRule(integration_rule);
563
564 CHKERR bc_mng->removeBlockDOFsOnEntities<DisplacementCubitBcData>(
565 simple->getProblemName(), "V");
566
567 auto get_pre_proc_hook = [&]() {
569 mField, pipeline_mng->getDomainExplicitRhsFE(), {time_scale});
570 };
571 pipeline_mng->getDomainExplicitRhsFE()->preProcessHook = get_pre_proc_hook();
572
574}
575//! [Boundary condition]
576
578 PetscInt stageindex, Vec *Y) {
580 // cerr << "tsPostStage " <<"\n";
581 if (auto ptr = tsPrePostProc.lock()) {
582 auto &m_field = ptr->fsRawPtr->mField;
583
584 auto fb = m_field.getInterface<FieldBlas>();
585 double dt;
586 CHKERR TSGetTimeStep(ts, &dt);
587 double time;
588 CHKERR TSGetTime(ts, &time);
589 PetscInt num_stages;
590 Vec *stage_solutions;
591
592 CHKERR TSGetStages(ts, &num_stages, &stage_solutions);
593 PetscPrintf(PETSC_COMM_WORLD, "Check timestep %d time %e dt %e\n",
594 num_stages, time, dt);
595
596 const double inv_num_step = (double)num_stages;
597 CHKERR fb->fieldCopy(1., "x_1", "x_2");
598 CHKERR fb->fieldAxpy(dt, "V", "x_2");
599 CHKERR fb->fieldCopy(1., "x_2", "x_1");
600
601 CHKERR fb->fieldCopy(-inv_num_step / dt, "F_0", "F_dot");
602 CHKERR fb->fieldAxpy(inv_num_step / dt, "F", "F_dot");
603 CHKERR fb->fieldCopy(1., "F", "F_0");
604 }
606}
607
610
611 if (auto ptr = tsPrePostProc.lock()) {
612 double dt;
613 CHKERR TSGetTimeStep(ts, &dt);
614 double time;
615 CHKERR TSGetTime(ts, &time);
616 }
618}
619
622
623 if (auto ptr = tsPrePostProc.lock()) {
624 double dt;
625 CHKERR TSGetTimeStep(ts, &dt);
626 double time;
627 CHKERR TSGetTime(ts, &time);
628 int step_num;
629 CHKERR TSGetStepNumber(ts, &step_num);
630 }
632}
633
634//! [Push operators to pipeline]
637 [[maybe_unused]] auto get_body_force = [this](const double, const double,
638 const double) {
641 t_source(i) = 0.;
642 t_source(0) = 0.1;
643 t_source(1) = 1.;
644 return t_source;
645 };
646
647 // specific time scaling
648 [[maybe_unused]] auto get_time_scale = [this](const double time) {
649 return sin(time * omega * M_PI);
650 };
651
652 auto apply_rhs = [&](auto &pip) {
654
656 "GEOMETRY");
657
658 // Calculate Gradient of velocity
659 auto mat_v_grad_ptr = boost::make_shared<MatrixDouble>();
661 "V", mat_v_grad_ptr));
662
663 auto gravity_vector_ptr = boost::make_shared<MatrixDouble>();
664 gravity_vector_ptr->resize(1, SPACE_DIM);
665 auto set_body_force = [&]() {
668 auto t_force = getFTensor1FromMat<SPACE_DIM, 0>(*gravity_vector_ptr);
669 double unit_weight = 0.;
670 CHKERR PetscOptionsGetReal(PETSC_NULLPTR, "", "-unit_weight", &unit_weight,
671 PETSC_NULLPTR);
672 t_force(i) = 0;
673 if (SPACE_DIM == 2) {
674 t_force(1) = -unit_weight;
675 } else if (SPACE_DIM == 3) {
676 t_force(2) = unit_weight;
677 }
679 };
680
681 CHKERR set_body_force();
682 pip.push_back(new OpBodyForce("V", gravity_vector_ptr,
683 [](double, double, double) { return 1.; }));
684
685 // Calculate unknown F
686 auto mat_H_tensor_ptr = boost::make_shared<MatrixDouble>();
688 "F", mat_H_tensor_ptr));
689
690 // // Calculate F
691 double tau = 0.2;
692 CHKERR PetscOptionsGetReal(PETSC_NULLPTR, "", "-tau", &tau, PETSC_NULLPTR);
693
694 double xi = 0.;
695 CHKERR PetscOptionsGetReal(PETSC_NULLPTR, "", "-xi", &xi, PETSC_NULLPTR);
696
697 // Calculate P stab
698 auto one = [&](const double, const double, const double) {
699 return 3. * bulk_modulus_K;
700 };
701 auto minus_one = [](const double, const double, const double) {
702 return -1.;
703 };
704
705 auto mat_dot_F_tensor_ptr = boost::make_shared<MatrixDouble>();
707 "F_dot", mat_dot_F_tensor_ptr));
708
709 // Calculate Gradient of Spatial Positions
710 auto mat_x_grad_ptr = boost::make_shared<MatrixDouble>();
712 "x_2", mat_x_grad_ptr));
713
714 auto mat_F_tensor_ptr = boost::make_shared<MatrixDouble>();
716 mat_F_tensor_ptr, mat_H_tensor_ptr));
717
718 auto mat_F_stab_ptr = boost::make_shared<MatrixDouble>();
720 mat_F_tensor_ptr, mat_F_stab_ptr, mat_dot_F_tensor_ptr, tau, xi,
721 mat_x_grad_ptr, mat_v_grad_ptr));
722
723 PetscBool is_linear_elasticity = PETSC_TRUE;
724 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-is_linear_elasticity",
725 &is_linear_elasticity, PETSC_NULLPTR);
726
727 auto mat_P_stab_ptr = boost::make_shared<MatrixDouble>();
728 if (is_linear_elasticity) {
731 mat_F_stab_ptr));
732 } else {
733 auto inv_F = boost::make_shared<MatrixDouble>();
734 auto det_ptr = boost::make_shared<VectorDouble>();
735
736 pip.push_back(
737 new OpInvertMatrix<SPACE_DIM>(mat_F_stab_ptr, det_ptr, inv_F));
738
739 // OpCalculatePiolaIncompressibleNH
742 mat_F_stab_ptr, inv_F, det_ptr));
743 }
744
745 pip.push_back(new OpGradTimesTensor2("V", mat_P_stab_ptr, minus_one));
746 pip.push_back(new OpRhsTestPiola("F", mat_v_grad_ptr, one));
747
749 };
750
751 auto *pipeline_mng = mField.getInterface<PipelineManager>();
752 CHKERR apply_rhs(pipeline_mng->getOpDomainExplicitRhsPipeline());
753
754 auto integration_rule = [](int, int, int approx_order) {
755 return 2 * approx_order;
756 };
757 CHKERR pipeline_mng->setDomainExplicitRhsIntegrationRule(integration_rule);
758
760}
761//! [Push operators to pipeline]
762
763/**
764 * @brief Monitor solution
765 *
766 * This functions is called by TS solver at the end of each step. It is used
767 * to output results to the hard drive.
768 */
769
770struct Monitor : public FEMethod {
773 boost::shared_ptr<PostProcEle> post_proc,
774 boost::shared_ptr<PostProcFaceEle> post_proc_bdry,
775 boost::shared_ptr<MatrixDouble> velocity_field_ptr,
776 boost::shared_ptr<MatrixDouble> x2_field_ptr,
777 boost::shared_ptr<MatrixDouble> geometry_field_ptr,
778 std::array<double, 3> pass_field_eval_coords,
779 boost::shared_ptr<SetPtsData> pass_field_eval_data)
780 : dM(dm), mField(m_field), postProc(post_proc),
781 postProcBdy(post_proc_bdry), velocityFieldPtr(velocity_field_ptr),
782 x2FieldPtr(x2_field_ptr), geometryFieldPtr(geometry_field_ptr),
783 fieldEvalCoords(pass_field_eval_coords),
784 fieldEvalData(pass_field_eval_data){};
787
788 auto *simple = mField.getInterface<Simple>();
789
791 ->evalFEAtThePoint<SPACE_DIM>(
792 fieldEvalCoords.data(), 1e-12, simple->getProblemName(),
793 simple->getDomainFEName(), fieldEvalData, mField.get_comm_rank(),
795
796 if (velocityFieldPtr->size1()) {
797 auto t_vel = getFTensor1FromMat<SPACE_DIM>(*velocityFieldPtr);
798 auto t_x2_field = getFTensor1FromMat<SPACE_DIM>(*x2FieldPtr);
799 auto t_geom = getFTensor1FromMat<SPACE_DIM>(*geometryFieldPtr);
800
801 double u_x = t_x2_field(0) - t_geom(0);
802 double u_y = t_x2_field(1) - t_geom(1);
803 double u_z = t_x2_field(2) - t_geom(2);
804
805 MOFEM_LOG("SYNC", Sev::inform)
806 << "Velocities x: " << t_vel(0) << " y: " << t_vel(1)
807 << " z: " << t_vel(2) << "\n";
808 MOFEM_LOG("SYNC", Sev::inform) << "Displacement x: " << u_x
809 << " y: " << u_y << " z: " << u_z << "\n";
810 }
811
812 for (auto m : mField.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(
813 std::regex((boost::format("%s(.*)") % "Data_Vertex").str()))) {
814 Range ents;
815 mField.get_moab().get_entities_by_dimension(m->getMeshset(), 0, ents,
816 true);
817 auto print_vets = [](boost::shared_ptr<FieldEntity> ent_ptr) {
819 if (!(ent_ptr->getPStatus() & PSTATUS_NOT_OWNED)) {
820 MOFEM_LOG("SYNC", Sev::inform)
821 << "Velocities: " << ent_ptr->getEntFieldData()[0] << " "
822 << ent_ptr->getEntFieldData()[1] << " "
823 << ent_ptr->getEntFieldData()[2] << "\n";
824 }
826 };
827 CHKERR mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
828 print_vets, "V", &ents);
829 }
831
832 PetscBool print_volume = PETSC_FALSE;
833 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-print_volume", &print_volume,
834 PETSC_NULLPTR);
835
836 PetscBool print_skin = PETSC_FALSE;
837 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-print_skin", &print_skin,
838 PETSC_NULLPTR);
839
840 int save_every_nth_step = 1;
841 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-save_step",
842 &save_every_nth_step, PETSC_NULLPTR);
843 if (ts_step % save_every_nth_step == 0) {
844
845 if (print_volume) {
847 CHKERR postProc->writeFile(
848 "out_step_" + boost::lexical_cast<std::string>(ts_step) + ".h5m");
849 }
850
851 if (print_skin) {
853 CHKERR postProcBdy->writeFile(
854 "out_boundary_" + boost::lexical_cast<std::string>(ts_step) +
855 ".h5m");
856 }
857 }
859 }
860
861private:
863 boost::shared_ptr<PostProcEle> postProc;
864 boost::shared_ptr<PostProcFaceEle> postProcBdy;
865 boost::shared_ptr<MatrixDouble> velocityFieldPtr;
866 boost::shared_ptr<MatrixDouble> x2FieldPtr;
867 boost::shared_ptr<MatrixDouble> geometryFieldPtr;
868 std::array<double, 3> fieldEvalCoords;
869 boost::shared_ptr<SetPtsData> fieldEvalData;
870};
871
872//! [Solve]
875 auto *simple = mField.getInterface<Simple>();
876 auto *pipeline_mng = mField.getInterface<PipelineManager>();
877
878 auto dm = simple->getDM();
879
880 auto calculate_stress_ops = [&](auto &pip) {
882
883 auto v_ptr = boost::make_shared<MatrixDouble>();
884 pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("V", v_ptr));
885 auto X_ptr = boost::make_shared<MatrixDouble>();
886 pip.push_back(
887 new OpCalculateVectorFieldValues<SPACE_DIM>("GEOMETRY", X_ptr));
888
889 auto x_ptr = boost::make_shared<MatrixDouble>();
890 pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("x_1", x_ptr));
891
892 // Calculate unknown F
893 auto mat_H_tensor_ptr = boost::make_shared<MatrixDouble>();
895 "F", mat_H_tensor_ptr));
896
897 auto u_ptr = boost::make_shared<MatrixDouble>();
898 pip.push_back(new OpCalculateDisplacement<SPACE_DIM>(x_ptr, X_ptr, u_ptr));
899 // Calculate P
900
901 auto mat_F_ptr = boost::make_shared<MatrixDouble>();
903 mat_F_ptr, mat_H_tensor_ptr));
904
905 PetscBool is_linear_elasticity = PETSC_TRUE;
906 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-is_linear_elasticity",
907 &is_linear_elasticity, PETSC_NULLPTR);
908
909 auto mat_P_ptr = boost::make_shared<MatrixDouble>();
910 if (is_linear_elasticity) {
913 mat_F_ptr));
914 } else {
915 auto inv_F = boost::make_shared<MatrixDouble>();
916 auto det_ptr = boost::make_shared<VectorDouble>();
917
918 pip.push_back(new OpInvertMatrix<SPACE_DIM>(mat_F_ptr, det_ptr, inv_F));
919
922 mat_F_ptr, inv_F, det_ptr));
923 }
924
925 auto mat_v_grad_ptr = boost::make_shared<MatrixDouble>();
927 "V", mat_v_grad_ptr));
928
929 return boost::make_tuple(v_ptr, X_ptr, x_ptr, mat_P_ptr, mat_F_ptr, u_ptr);
930 };
931
932 auto post_proc_boundary = [&]() {
933 auto boundary_post_proc_fe = boost::make_shared<PostProcFaceEle>(mField);
934
936 boundary_post_proc_fe->getOpPtrVector(), {}, "GEOMETRY");
937 auto op_loop_side =
938 new OpLoopSide<SideEle>(mField, simple->getDomainFEName(), SPACE_DIM);
939 // push ops to side element, through op_loop_side operator
940 auto [boundary_v_ptr, boundary_X_ptr, boundary_x_ptr, boundary_mat_P_ptr,
941 boundary_mat_F_ptr, boundary_u_ptr] =
942 calculate_stress_ops(op_loop_side->getOpPtrVector());
943 boundary_post_proc_fe->getOpPtrVector().push_back(op_loop_side);
944
946
947 boundary_post_proc_fe->getOpPtrVector().push_back(
948
949 new OpPPMap(
950
951 boundary_post_proc_fe->getPostProcMesh(),
952 boundary_post_proc_fe->getMapGaussPts(),
953
955
956 OpPPMap::DataMapMat{{"V", boundary_v_ptr},
957 {"GEOMETRY", boundary_X_ptr},
958 {"x", boundary_x_ptr},
959 {"U", boundary_u_ptr}},
960
961 OpPPMap::DataMapMat{{"FIRST_PIOLA", boundary_mat_P_ptr},
962 {"F", boundary_mat_F_ptr}},
963
965
966 )
967
968 );
969 return boundary_post_proc_fe;
970 };
971
972 // Add monitor to time solver
973
974 double rho = 1.;
975 CHKERR PetscOptionsGetReal(PETSC_NULLPTR, "", "-density", &rho, PETSC_NULLPTR);
976 auto get_rho = [rho](const double, const double, const double) {
977 return rho;
978 };
979
980 SmartPetscObj<Mat> M; ///< Mass matrix
981 SmartPetscObj<KSP> ksp; ///< Linear solver
982
983 auto ts_pre_post_proc = boost::make_shared<TSPrePostProc>();
984 tsPrePostProc = ts_pre_post_proc;
985
987 CHKERR MatZeroEntries(M);
988
989 boost::shared_ptr<DomainEle> vol_mass_ele(new DomainEle(mField));
990
991 vol_mass_ele->B = M;
992
993 auto integration_rule = [](int, int, int approx_order) {
994 return 2 * approx_order;
995 };
996
997 vol_mass_ele->getRuleHook = integration_rule;
998
999 vol_mass_ele->getOpPtrVector().push_back(new OpMassV("V", "V", get_rho));
1000 vol_mass_ele->getOpPtrVector().push_back(new OpMassF("F", "F"));
1001
1002 CHKERR DMoFEMLoopFiniteElements(dm, simple->getDomainFEName(), vol_mass_ele);
1003 CHKERR MatAssemblyBegin(M, MAT_FINAL_ASSEMBLY);
1004 CHKERR MatAssemblyEnd(M, MAT_FINAL_ASSEMBLY);
1005
1006 auto lumpVec = createDMVector(simple->getDM());
1007 CHKERR MatGetRowSum(M, lumpVec);
1008
1009 CHKERR MatZeroEntries(M);
1010 CHKERR MatDiagonalSet(M, lumpVec, INSERT_VALUES);
1011
1012 // Create and septup KSP (linear solver), we need this to calculate g(t,u) =
1013 // M^-1G(t,u)
1014 ksp = createKSP(mField.get_comm());
1015 CHKERR KSPSetOperators(ksp, M, M);
1016 CHKERR KSPSetFromOptions(ksp);
1017 CHKERR KSPSetUp(ksp);
1018
1019 auto solve_boundary_for_g = [&]() {
1021 if (*(pipeline_mng->getBoundaryExplicitRhsFE()->vecAssembleSwitch)) {
1022
1023 CHKERR VecGhostUpdateBegin(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F,
1024 ADD_VALUES, SCATTER_REVERSE);
1025 CHKERR VecGhostUpdateEnd(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F,
1026 ADD_VALUES, SCATTER_REVERSE);
1027 CHKERR VecAssemblyBegin(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
1028 CHKERR VecAssemblyEnd(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
1029 *(pipeline_mng->getBoundaryExplicitRhsFE()->vecAssembleSwitch) = false;
1030
1031 auto D =
1032 vectorDuplicate(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
1033 CHKERR KSPSolve(ksp, pipeline_mng->getBoundaryExplicitRhsFE()->ts_F, D);
1034 CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
1035 CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
1036 CHKERR VecCopy(D, pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
1037 }
1038
1040 };
1041
1042 pipeline_mng->getBoundaryExplicitRhsFE()->postProcessHook =
1043 solve_boundary_for_g;
1044
1046 ts = pipeline_mng->createTSEX(dm);
1047
1048 // Field eval
1049 PetscBool field_eval_flag = PETSC_TRUE;
1050 boost::shared_ptr<MatrixDouble> velocity_field_ptr;
1051 boost::shared_ptr<MatrixDouble> geometry_field_ptr;
1052 boost::shared_ptr<MatrixDouble> spatial_position_field_ptr;
1053 boost::shared_ptr<SetPtsData> field_eval_data;
1054
1055 std::array<double, 3> field_eval_coords = {0.5, 0.5, 5.};
1056 int dim = 3;
1057 CHKERR PetscOptionsGetRealArray(NULL, NULL, "-field_eval_coords",
1058 field_eval_coords.data(), &dim,
1059 &field_eval_flag);
1060
1061 if (field_eval_flag) {
1062 field_eval_data =
1063 mField.getInterface<FieldEvaluatorInterface>()->getData<DomainEle>();
1064 CHKERR mField.getInterface<FieldEvaluatorInterface>()->buildTree<SPACE_DIM>(
1065 field_eval_data, simple->getDomainFEName());
1066
1067 field_eval_data->setEvalPoints(field_eval_coords.data(), 1);
1068
1069 auto no_rule = [](int, int, int) { return -1; };
1070
1071 auto fe_ptr = field_eval_data->feMethodPtr;
1072 fe_ptr->getRuleHook = no_rule;
1073 velocity_field_ptr = boost::make_shared<MatrixDouble>();
1074 geometry_field_ptr = boost::make_shared<MatrixDouble>();
1075 spatial_position_field_ptr = boost::make_shared<MatrixDouble>();
1076 fe_ptr->getOpPtrVector().push_back(
1077 new OpCalculateVectorFieldValues<SPACE_DIM>("V", velocity_field_ptr));
1078 fe_ptr->getOpPtrVector().push_back(
1080 geometry_field_ptr));
1081 fe_ptr->getOpPtrVector().push_back(
1083 "x_2", spatial_position_field_ptr));
1084 }
1085
1086 auto post_proc_domain = [&]() {
1087 auto post_proc_fe_vol = boost::make_shared<PostProcEle>(mField);
1088
1090
1091 auto [boundary_v_ptr, boundary_X_ptr, boundary_x_ptr, boundary_mat_P_ptr,
1092 boundary_mat_F_ptr, boundary_u_ptr] =
1093 calculate_stress_ops(post_proc_fe_vol->getOpPtrVector());
1094
1095 post_proc_fe_vol->getOpPtrVector().push_back(
1096
1097 new OpPPMap(
1098
1099 post_proc_fe_vol->getPostProcMesh(),
1100 post_proc_fe_vol->getMapGaussPts(),
1101
1102 {},
1103
1104 {{"V", boundary_v_ptr},
1105 {"GEOMETRY", boundary_X_ptr},
1106 {"x", boundary_x_ptr},
1107 {"U", boundary_u_ptr}},
1108
1109 {{"FIRST_PIOLA", boundary_mat_P_ptr}, {"F", boundary_mat_F_ptr}},
1110
1111 {}
1112
1113 )
1114
1115 );
1116 return post_proc_fe_vol;
1117 };
1118
1119 boost::shared_ptr<FEMethod> null_fe;
1120 auto monitor_ptr = boost::make_shared<Monitor>(
1121 SmartPetscObj<DM>(dm, true), mField, post_proc_domain(),
1122 post_proc_boundary(), velocity_field_ptr, spatial_position_field_ptr,
1123 geometry_field_ptr, field_eval_coords, field_eval_data);
1124
1125 CHKERR DMMoFEMTSSetMonitor(dm, ts, simple->getDomainFEName(), null_fe,
1126 null_fe, monitor_ptr);
1127
1128 double ftime = 1;
1129 // CHKERR TSSetMaxTime(ts, ftime);
1130 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
1131
1132 auto T = createDMVector(simple->getDM());
1133 CHKERR DMoFEMMeshToLocalVector(simple->getDM(), T, INSERT_VALUES,
1134 SCATTER_FORWARD);
1135 CHKERR TSSetSolution(ts, T);
1136 CHKERR TSSetFromOptions(ts);
1137
1138 CHKERR TSSetPostStage(ts, TSPrePostProc::tsPostStage);
1139 CHKERR TSSetPostStep(ts, TSPrePostProc::tsPostStep);
1140 CHKERR TSSetPreStep(ts, TSPrePostProc::tsPreStep);
1141
1142 boost::shared_ptr<ForcesAndSourcesCore> null;
1143
1144 if (auto ptr = tsPrePostProc.lock()) {
1145 ptr->fsRawPtr = this;
1146 CHKERR TSSetUp(ts);
1147 CHKERR TSSolve(ts, NULL);
1148 CHKERR TSGetTime(ts, &ftime);
1149 }
1150
1152}
1153//! [Solve]
1154
1155//! [Postprocess results]
1158 PetscBool test_flg = PETSC_FALSE;
1159 CHKERR PetscOptionsGetBool(PETSC_NULLPTR, "", "-test", &test_flg, PETSC_NULLPTR);
1160 if (test_flg) {
1161 auto *simple = mField.getInterface<Simple>();
1162 auto T = createDMVector(simple->getDM());
1163 CHKERR DMoFEMMeshToLocalVector(simple->getDM(), T, INSERT_VALUES,
1164 SCATTER_FORWARD);
1165 double nrm2;
1166 CHKERR VecNorm(T, NORM_2, &nrm2);
1167 MOFEM_LOG("EXAMPLE", Sev::inform) << "Regression norm " << nrm2;
1168 constexpr double regression_value = 0.0194561;
1169 if (fabs(nrm2 - regression_value) > 1e-2)
1170 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
1171 "Regression test failed; wrong norm value.");
1172 }
1174}
1175//! [Postprocess results]
1176
1177//! [Check]
1182//! [Check]
1183
1184static char help[] = "...\n\n";
1185
1186int main(int argc, char *argv[]) {
1187
1188 // Initialisation of MoFEM/PETSc and MOAB data structures
1189 const char param_file[] = "param_file.petsc";
1190 MoFEM::Core::Initialize(&argc, &argv, param_file, help);
1191
1192 // Add logging channel for example
1193 auto core_log = logging::core::get();
1194 core_log->add_sink(
1196 LogManager::setLog("EXAMPLE");
1197 MOFEM_LOG_TAG("EXAMPLE", "example");
1198
1199 try {
1200
1201 //! [Register MoFEM discrete manager in PETSc]
1202 DMType dm_name = "DMMOFEM";
1203 CHKERR DMRegister_MoFEM(dm_name);
1204 //! [Register MoFEM discrete manager in PETSc
1205
1206 //! [Create MoAB]
1207 moab::Core mb_instance; ///< mesh database
1208 moab::Interface &moab = mb_instance; ///< mesh database interface
1209 //! [Create MoAB]
1210
1211 //! [Create MoFEM]
1212 MoFEM::Core core(moab); ///< finite element database
1213 MoFEM::Interface &m_field = core; ///< finite element database interface
1214 //! [Create MoFEM]
1215
1216 //! [Example]
1217 Example ex(m_field);
1218 CHKERR ex.runProblem();
1219 //! [Example]
1220 }
1222
1224}
std::string type
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition acoustic.cpp:69
int main()
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
Kronecker Delta class.
@ QUIET
#define CATCH_ERRORS
Catch errors.
@ MF_EXIST
FieldApproximationBase
approximation base
Definition definitions.h:58
@ LASTBASE
Definition definitions.h:69
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition definitions.h:60
@ DEMKOWICZ_JACOBI_BASE
Definition definitions.h:66
@ H1
continuous field
Definition definitions.h:85
@ NOSPACE
Definition definitions.h:83
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int order
PostProcEleByDim< SPACE_DIM >::PostProcEleDomain PostProcEleDomain
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMassV
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM *SPACE_DIM > OpMassF
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
static char help[]
[Check]
constexpr int SPACE_DIM
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, SPACE_DIM > OpInertiaForce
constexpr double poisson_ratio
constexpr double omega
Save field DOFS on vertices/tags.
PostProcEleByDim< SPACE_DIM >::PostProcEleBdy PostProcEleBdy
PipelineManager::ElementsAndOpsByDim< SPACE_DIM >::DomainEle DomainEle
double trace(FTensor::Tensor2< T, 2, 2 > &t_stress)
FormsIntegrators< DomainEleOp >::Assembly< AssemblyType::PETSC >::LinearForm< IntegrationType::GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpGradTimesPiola
double bulk_modulus_K
FormsIntegrators< DomainEleOp >::Assembly< AssemblyType::PETSC >::LinearForm< IntegrationType::GAUSS >::OpBaseTimesVector< 1, SPACE_DIM *SPACE_DIM, SPACE_DIM *SPACE_DIM > OpRhsTestPiola
FormsIntegrators< DomainEleOp >::Assembly< AssemblyType::PETSC >::LinearForm< IntegrationType::GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpGradTimesTensor2
double shear_modulus_G
constexpr double young_modulus
auto integration_rule
constexpr auto t_kd
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition DMMoFEM.cpp:1188
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
Definition DMMoFEM.cpp:514
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition DMMoFEM.cpp:43
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition DMMoFEM.cpp:576
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1237
@ GAUSS
Gaussian quadrature integration.
@ PETSC
Standard PETSc assembly.
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.
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.
FTensor::Index< 'i', SPACE_DIM > i
double dt
double D
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
Definition Common.hpp:10
auto createKSP(MPI_Comm comm)
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.
Definition DMMoFEM.cpp:1046
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, 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.
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< I >::OpGradTimesTensor< 1, FIELD_DIM, SPACE_DIM > OpGradTimesTensor
int save_every_nth_step
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)]
Definition seepage.cpp:56
FTensor::Index< 'm', 3 > m
SmartPetscObj< Mat > M
Mass matrix.
SmartPetscObj< KSP > ksp
Linear solver.
double getScale(const double time)
Get scaling at given time.
double getScale(const double time)
Get scaling at given time.
[Example]
Definition plastic.cpp:217
MoFEMErrorCode boundaryCondition()
[Set up problem]
MoFEMErrorCode assembleSystem()
[Push operators to pipeline]
MoFEMErrorCode readMesh()
[Run problem]
FieldApproximationBase base
Choice of finite element basis functions.
Definition plot_base.cpp:68
MoFEMErrorCode checkResults()
[Postprocess results]
MoFEMErrorCode solveSystem()
[Solve]
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
MoFEM::Interface & mField
Reference to MoFEM interface.
Definition plastic.cpp:227
MoFEMErrorCode setupProblem()
MoFEMErrorCode outputResults()
[Solve]
double getScale(const double time)
Get scaling at given time.
Add operators pushing bases from local to physical configuration.
boost::weak_ptr< CacheTuple > getCacheWeakPtr() const
Get the cache weak pointer object.
Boundary condition manager for finite element problem setup.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Core (interface) class.
Definition Core.hpp:83
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition Core.cpp:68
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition Core.cpp:123
Deprecated interface functions.
Definition of the displacement bc data structure.
Definition BCData.hpp:72
Data on single entity (This is passed as argument to DataOperator::doWork)
Class (Function) to enforce essential constrains.
Definition Essential.hpp:25
Structure for user loop methods on finite elements.
Basic algebra on fields.
Definition FieldBlas.hpp:21
Field evaluator interface.
SetIntegrationPtsMethodData SetPtsData
structure to get information from mofem into EntitiesFieldData
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.
Assembly methods.
Definition Natural.hpp:65
Get values at integration pts for tensor field rank 2, i.e. matrix field.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for MatrixDouble vector field values calculation.
Operator for inverting matrices at integration points.
Element used to execute operators on side of the element.
Post post-proc data at points from hash maps.
std::map< std::string, ScalarDataPtr > DataMapVec
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat
Template struct for dimension-specific finite element types.
PipelineManager interface.
Projection of edge entities with one mid-node on hierarchical basis.
Simple interface for fast problem set-up.
Definition Simple.hpp:27
MoFEMErrorCode getOptions()
get options
Definition Simple.cpp:180
intrusive_ptr for managing petsc objects
PetscInt ts_step
Current time step number.
Force scale operator for reading two columns.
double getScale(const double time)
Get scaling at a given time.
TimeScale(std::string file_name="", bool error_if_file_not_given=false, ScalingFun def_scaling_fun=[](double time) { return time;})
TimeScale constructor.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
[Push operators to pipeline]
boost::shared_ptr< PostProcFaceEle > postProcBdy
std::array< double, 3 > fieldEvalCoords
MoFEM::Interface & mField
Monitor(SmartPetscObj< DM > dm, MoFEM::Interface &m_field, boost::shared_ptr< PostProcEle > post_proc, boost::shared_ptr< PostProcFaceEle > post_proc_bdry, boost::shared_ptr< MatrixDouble > velocity_field_ptr, boost::shared_ptr< MatrixDouble > x2_field_ptr, boost::shared_ptr< MatrixDouble > geometry_field_ptr, std::array< double, 3 > pass_field_eval_coords, boost::shared_ptr< SetPtsData > pass_field_eval_data)
boost::shared_ptr< MatrixDouble > geometryFieldPtr
SmartPetscObj< DM > dM
MoFEMErrorCode postProcess()
Post-processing function executed at loop completion.
boost::shared_ptr< MatrixDouble > velocityFieldPtr
boost::shared_ptr< SetPtsData > fieldEvalData
boost::shared_ptr< MatrixDouble > x2FieldPtr
boost::shared_ptr< PostProcEle > postProc
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
boost::shared_ptr< MatrixDouble > defGradPtr
boost::shared_ptr< MatrixDouble > gradTensorPtr
OpCalculateDeformationGradient(boost::shared_ptr< MatrixDouble > def_grad_ptr, boost::shared_ptr< MatrixDouble > grad_tensor_ptr)
boost::shared_ptr< MatrixDouble > XPtr
boost::shared_ptr< MatrixDouble > uPtr
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
OpCalculateDisplacement(boost::shared_ptr< MatrixDouble > spatial_pos_ptr, boost::shared_ptr< MatrixDouble > reference_pos_ptr, boost::shared_ptr< MatrixDouble > u_ptr)
boost::shared_ptr< MatrixDouble > xPtr
boost::shared_ptr< MatrixDouble > gradxPtr
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
OpCalculateFStab(boost::shared_ptr< MatrixDouble > def_grad_ptr, boost::shared_ptr< MatrixDouble > def_grad_stab_ptr, boost::shared_ptr< MatrixDouble > def_grad_dot_ptr, double tau_F_ptr, double xi_F_ptr, boost::shared_ptr< MatrixDouble > grad_x_ptr, boost::shared_ptr< MatrixDouble > grad_vel_ptr)
boost::shared_ptr< MatrixDouble > defGradStabPtr
boost::shared_ptr< MatrixDouble > gradVelPtr
boost::shared_ptr< MatrixDouble > defGradPtr
boost::shared_ptr< MatrixDouble > defGradDotPtr
OpCalculatePiolaIncompressibleNH(double shear_modulus, double bulk_modulus, double m_u, double lambda_lamme, boost::shared_ptr< MatrixDouble > first_piola_ptr, boost::shared_ptr< MatrixDouble > def_grad_ptr, boost::shared_ptr< MatrixDouble > inv_def_grad_ptr, boost::shared_ptr< VectorDouble > det)
boost::shared_ptr< VectorDouble > dEt
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
boost::shared_ptr< MatrixDouble > invDefGradPtr
boost::shared_ptr< MatrixDouble > defGradPtr
boost::shared_ptr< MatrixDouble > firstPiolaPtr
OpCalculatePiola(double shear_modulus, double bulk_modulus, double m_u, double lambda_lamme, boost::shared_ptr< MatrixDouble > first_piola_ptr, boost::shared_ptr< MatrixDouble > def_grad_ptr)
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
boost::shared_ptr< MatrixDouble > defGradPtr
boost::shared_ptr< MatrixDouble > firstPiolaPtr
PipelineManager::ElementsAndOpsByDim< 2 >::FaceSideEle SideEle
PipelineManager::ElementsAndOpsByDim< 3 >::FaceSideEle SideEle
Set of functions called by PETSc solver used to refine and update mesh.
static MoFEMErrorCode tsPostStep(TS ts)
virtual ~TSPrePostProc()=default
static MoFEMErrorCode tsPreStep(TS ts)
TSPrePostProc()=default
static MoFEMErrorCode tsPostStage(TS ts, PetscReal stagetime, PetscInt stageindex, Vec *Y)
[Boundary condition]
MoFEMErrorCode tsSetUp(TS ts)
Used to setup TS solver.
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
double rho
Definition plastic.cpp:145
#define EXECUTABLE_DIMENSION
Definition plastic.cpp:13
ElementsAndOps< SPACE_DIM >::SideEle SideEle
Definition plastic.cpp:62
constexpr int SPACE_DIM
DomainNaturalBC::OpFlux< NaturalMeshsetType< BLOCKSET >, 1, SPACE_DIM > OpBodyForce