v0.14.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 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 constexpr double third = boost::math::constants::third<double>();
16 return (t_stress(0, 0) + t_stress(1, 1));
17};
18
19template <typename T> inline double trace(FTensor::Tensor2<T, 3, 3> &t_stress) {
20 constexpr double third = boost::math::constants::third<double>();
21 return (t_stress(0, 0) + t_stress(1, 1) + t_stress(2, 2));
22};
23
24constexpr int SPACE_DIM =
25 EXECUTABLE_DIMENSION; //< Space dimension of problem, mesh
26
33
38
39template <int DIM> struct PostProcEleByDim;
40
41template <> struct PostProcEleByDim<2> {
45};
46
47template <> struct PostProcEleByDim<3> {
51};
52
56
61
64
66 GAUSS>::OpBaseTimesVector<1, SPACE_DIM, 0>;
67
72 SPACE_DIM>;
73
77
80 IntegrationType::GAUSS>::OpBaseTimesVector<1, SPACE_DIM * SPACE_DIM, 1>;
81
85
89
90/** \brief Save field DOFS on vertices/tags
91 */
92
93constexpr double omega = 1.;
94constexpr double young_modulus = 1.;
95constexpr double poisson_ratio = 0.;
96double bulk_modulus_K = young_modulus / (3. * (1. - 2. * poisson_ratio));
98double mu = young_modulus / (2. * (1. + poisson_ratio));
100 ((1. + poisson_ratio) * (1. - 2. * poisson_ratio));
101
102// Operator to Calculate F
103template <int DIM_0, int DIM_1>
105 OpCalculateFStab(boost::shared_ptr<MatrixDouble> def_grad_ptr,
106 boost::shared_ptr<MatrixDouble> def_grad_stab_ptr,
107 boost::shared_ptr<MatrixDouble> def_grad_dot_ptr,
108 double tau_F_ptr, double xi_F_ptr,
109 boost::shared_ptr<MatrixDouble> grad_x_ptr,
110 boost::shared_ptr<MatrixDouble> grad_vel_ptr)
112 defGradPtr(def_grad_ptr), defGradStabPtr(def_grad_stab_ptr),
113 defGradDotPtr(def_grad_dot_ptr), tauFPtr(tau_F_ptr), xiF(xi_F_ptr),
114 gradxPtr(grad_x_ptr), gradVelPtr(grad_vel_ptr) {}
115
117 DataForcesAndSourcesCore::EntData &data) {
119 // Define Indicies
122
123 // Number of Gauss points
124 const size_t nb_gauss_pts = getGaussPts().size2();
125
126 defGradStabPtr->resize(DIM_0 * DIM_1, nb_gauss_pts, false);
127 defGradStabPtr->clear();
128
129 // Extract matrix from data matrix
130 auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradPtr);
131 auto t_Fstab = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradStabPtr);
132 auto t_F_dot = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradDotPtr);
133
134 // tau_F = alpha deltaT
135 auto tau_F = tauFPtr;
136 double xi_F = xiF;
137 auto t_gradx = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*gradxPtr);
138 auto t_gradVel = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*gradVelPtr);
139
140 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
141 // Stabilised Deformation Gradient
142 t_Fstab(i, j) = t_F(i, j) + tau_F * (t_gradVel(i, j) - t_F_dot(i, j)) +
143 xi_F * (t_gradx(i, j) - t_F(i, j));
144
145 ++t_F;
146 ++t_Fstab;
147 ++t_gradVel;
148 ++t_F_dot;
149
150 ++t_gradx;
151 }
152
154 }
155
156private:
157 double tauFPtr;
158 double xiF;
159 boost::shared_ptr<MatrixDouble> defGradPtr;
160 boost::shared_ptr<MatrixDouble> defGradStabPtr;
161 boost::shared_ptr<MatrixDouble> defGradDotPtr;
162 boost::shared_ptr<MatrixDouble> gradxPtr;
163 boost::shared_ptr<MatrixDouble> gradVelPtr;
164};
165
166// Operator to Calculate P
167template <int DIM_0, int DIM_1>
169 OpCalculatePiola(double shear_modulus, double bulk_modulus, double m_u,
170 double lambda_lamme,
171 boost::shared_ptr<MatrixDouble> first_piola_ptr,
172 boost::shared_ptr<MatrixDouble> def_grad_ptr)
174 shearModulus(shear_modulus), bulkModulus(bulk_modulus), mU(m_u),
175 lammeLambda(lambda_lamme), firstPiolaPtr(first_piola_ptr),
176 defGradPtr(def_grad_ptr) {}
177
179 DataForcesAndSourcesCore::EntData &data) {
181 // Define Indicies
185
186 // Define Kronecker Delta
187 constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
188
189 // Number of Gauss points
190 const size_t nb_gauss_pts = getGaussPts().size2();
191
192 // Resize Piola
193 firstPiolaPtr->resize(DIM_0 * DIM_1, nb_gauss_pts, false); // ignatios check
194 firstPiolaPtr->clear();
195
196 // Extract matrix from data matrix
197 auto t_P = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*firstPiolaPtr);
198 auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradPtr);
199 const double two_o_three = 2. / 3.;
200 const double trace_t_dk = DIM_0;
201 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
202
203 t_P(i, j) = shearModulus * (t_F(i, j) + t_F(j, i) - 2. * t_kd(i, j) -
204 two_o_three * trace(t_F) * t_kd(i, j) +
205 two_o_three * trace_t_dk * t_kd(i, j)) +
206 bulkModulus * trace(t_F) * t_kd(i, j) -
207 bulkModulus * trace_t_dk * t_kd(i, j);
208
209 ++t_F;
210 ++t_P;
211 }
212
214 }
215
216private:
219 double mU;
221 boost::shared_ptr<MatrixDouble> firstPiolaPtr;
222 boost::shared_ptr<MatrixDouble> defGradPtr;
223};
224
225template <int DIM>
227 OpCalculateDisplacement(boost::shared_ptr<MatrixDouble> spatial_pos_ptr,
228 boost::shared_ptr<MatrixDouble> reference_pos_ptr,
229 boost::shared_ptr<MatrixDouble> u_ptr)
231 xPtr(spatial_pos_ptr), XPtr(reference_pos_ptr), uPtr(u_ptr) {}
232
234 DataForcesAndSourcesCore::EntData &data) {
236 // Define Indicies
238
239 // Number of Gauss points
240 const size_t nb_gauss_pts = getGaussPts().size2();
241
242 uPtr->resize(DIM, nb_gauss_pts, false); // ignatios check
243 uPtr->clear();
244
245 // Extract matrix from data matrix
246 auto t_x = getFTensor1FromMat<DIM>(*xPtr);
247 auto t_X = getFTensor1FromMat<DIM>(*XPtr);
248 auto t_u = getFTensor1FromMat<DIM>(*uPtr);
249 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
250
251 t_u(i) = t_x(i) - t_X(i);
252 ++t_u;
253 ++t_x;
254 ++t_X;
255 }
256
258 }
259
260private:
261 boost::shared_ptr<MatrixDouble> xPtr;
262 boost::shared_ptr<MatrixDouble> XPtr;
263 boost::shared_ptr<MatrixDouble> uPtr;
264};
265
266template <int DIM_0, int DIM_1>
270 double shear_modulus, double bulk_modulus, double m_u,
271 double lambda_lamme, boost::shared_ptr<MatrixDouble> first_piola_ptr,
272 boost::shared_ptr<MatrixDouble> def_grad_ptr,
273 boost::shared_ptr<MatrixDouble> inv_def_grad_ptr,
274 boost::shared_ptr<VectorDouble> det)
276 shearModulus(shear_modulus), bulkModulus(bulk_modulus), mU(m_u),
277 lammeLambda(lambda_lamme), firstPiolaPtr(first_piola_ptr),
278 defGradPtr(def_grad_ptr), invDefGradPtr(inv_def_grad_ptr), dEt(det) {}
279
281 DataForcesAndSourcesCore::EntData &data) {
283 // Define Indicies
288
289 // Define Kronecker Delta
290 constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
291
292 // Number of Gauss points
293 const size_t nb_gauss_pts = getGaussPts().size2();
294
295 // Resize Piola
296 firstPiolaPtr->resize(DIM_0 * DIM_1, nb_gauss_pts, false); // ignatios check
297 firstPiolaPtr->clear();
298
299 // Extract matrix from data matrix
300 auto t_P = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*firstPiolaPtr);
301 auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradPtr);
302 auto t_inv_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*invDefGradPtr);
303 auto t_det = getFTensor0FromVec<1>(*dEt);
304 const double two_o_three = 2. / 3.;
305 const double one_o_three = 1. / 3.;
306 const double bulk_mod = bulkModulus;
307 const double shear_mod = shearModulus;
308 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
309
310 // Nearly incompressible NH
311 // volumetric part
312 t_P(i, j) = bulk_mod * (t_det - 1.) * t_det * t_inv_F(j, i);
313 // deviatoric part
314 t_P(i, j) +=
315 shear_mod * pow(t_det, two_o_three) *
316 (t_F(i, j) - one_o_three * (t_F(l, k) * t_F(l, k)) * t_inv_F(j, i));
317
318 ++t_F;
319 ++t_P;
320 ++t_inv_F;
321 ++t_det;
322 }
323
325 }
326
327private:
330 double mU;
332 boost::shared_ptr<MatrixDouble> firstPiolaPtr;
333 boost::shared_ptr<MatrixDouble> defGradPtr;
334 boost::shared_ptr<MatrixDouble> invDefGradPtr;
335 boost::shared_ptr<VectorDouble> dEt;
336};
337
338template <int DIM_0, int DIM_1>
342 boost::shared_ptr<MatrixDouble> def_grad_ptr,
343 boost::shared_ptr<MatrixDouble> grad_tensor_ptr)
345 defGradPtr(def_grad_ptr), gradTensorPtr(grad_tensor_ptr) {}
346
348 DataForcesAndSourcesCore::EntData &data) {
350 // Define Indicies
353
354 // Define Kronecker Delta
355 constexpr auto t_kd = FTensor::Kronecker_Delta<double>();
356
357 // Number of Gauss points
358 const size_t nb_gauss_pts = getGaussPts().size2();
359
360 // Resize Piola
361 defGradPtr->resize(DIM_0 * DIM_1, nb_gauss_pts, false);
362 defGradPtr->clear();
363
364 // Extract matrix from data matrix
365 auto t_F = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*defGradPtr);
366 auto t_H = getFTensor2FromMat<SPACE_DIM, SPACE_DIM>(*gradTensorPtr);
367 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
368
369 t_F(i, j) = t_H(i, j) + t_kd(i, j);
370
371 ++t_F;
372 ++t_H;
373 }
374
376 }
377
378private:
379 boost::shared_ptr<MatrixDouble> gradTensorPtr;
380 boost::shared_ptr<MatrixDouble> defGradPtr;
381};
382
383struct Example;
385
386 TSPrePostProc() = default;
387 virtual ~TSPrePostProc() = default;
388
389 /**
390 * @brief Used to setup TS solver
391 *
392 * @param ts
393 * @return MoFEMErrorCode
394 */
395 MoFEMErrorCode tsSetUp(TS ts);
396
397 // SmartPetscObj<VecScatter> getScatter(Vec x, Vec y, enum FR fr);
399 static MoFEMErrorCode tsPostStage(TS ts, PetscReal stagetime,
400 PetscInt stageindex, Vec *Y);
401 static MoFEMErrorCode tsPostStep(TS ts);
402 static MoFEMErrorCode tsPreStep(TS ts);
403};
404
405static boost::weak_ptr<TSPrePostProc> tsPrePostProc;
406
409 double getScale(const double time) {
410 return sin(2. * M_PI * MoFEM::TimeScale::getScale(time));
411 };
412};
413
414struct CommonData {
415 SmartPetscObj<Mat> M; ///< Mass matrix
416 SmartPetscObj<KSP> ksp; ///< Linear solver
417};
418
419struct Example {
420
421 Example(MoFEM::Interface &m_field) : mField(m_field) {}
422
424
425private:
427
435 friend struct TSPrePostProc;
436
439 double getScale(const double time) { return 0.001 * sin(0.1 * time); };
440 };
441
444 double getScale(const double time) { return 0.001; };
445 };
446};
447
448//! [Run problem]
459}
460//! [Run problem]
461
462//! [Read mesh]
466
467 CHKERR simple->getOptions();
468 CHKERR simple->loadFile();
470}
471//! [Read mesh]
472
473//! [Set up problem]
477 enum bases { AINSWORTH, DEMKOWICZ, LASBASETOPT };
478 const char *list_bases[LASBASETOPT] = {"ainsworth", "demkowicz"};
479 PetscInt choice_base_value = AINSWORTH;
480 CHKERR PetscOptionsGetEList(PETSC_NULL, NULL, "-base", list_bases,
481 LASBASETOPT, &choice_base_value, PETSC_NULL);
482
484 switch (choice_base_value) {
485 case AINSWORTH:
487 MOFEM_LOG("WORLD", Sev::inform)
488 << "Set AINSWORTH_LEGENDRE_BASE for displacements";
489 break;
490 case DEMKOWICZ:
492 MOFEM_LOG("WORLD", Sev::inform)
493 << "Set DEMKOWICZ_JACOBI_BASE for displacements";
494 break;
495 default:
496 base = LASTBASE;
497 break;
498 }
499 // Add field
500 CHKERR simple->addDomainField("V", H1, base, SPACE_DIM);
501 CHKERR simple->addBoundaryField("V", H1, base, SPACE_DIM);
502 CHKERR simple->addDomainField("F", H1, base, SPACE_DIM * SPACE_DIM);
503 CHKERR simple->addDataField("x_1", H1, base, SPACE_DIM);
504 CHKERR simple->addDataField("x_2", H1, base, SPACE_DIM);
505 CHKERR simple->addDataField("F_0", H1, base, SPACE_DIM * SPACE_DIM);
506 CHKERR simple->addDataField("F_dot", H1, base, SPACE_DIM * SPACE_DIM);
507
508 CHKERR simple->addDataField("GEOMETRY", H1, base, SPACE_DIM);
509 int order = 2;
510 CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-order", &order, PETSC_NULL);
511 CHKERR simple->setFieldOrder("V", order);
512 CHKERR simple->setFieldOrder("F", order);
513 CHKERR simple->setFieldOrder("F_0", order);
514 CHKERR simple->setFieldOrder("F_dot", order);
515 CHKERR simple->setFieldOrder("x_1", order);
516 CHKERR simple->setFieldOrder("x_2", order);
517 CHKERR simple->setFieldOrder("GEOMETRY", order);
518 CHKERR simple->setUp();
519
520 auto project_ho_geometry = [&]() {
521 Projection10NodeCoordsOnField ent_method_x(mField, "x_1");
522 CHKERR mField.loop_dofs("x_1", ent_method_x);
523 Projection10NodeCoordsOnField ent_method_x_2(mField, "x_2");
524 CHKERR mField.loop_dofs("x_2", ent_method_x_2);
525
526 Projection10NodeCoordsOnField ent_method(mField, "GEOMETRY");
527 return mField.loop_dofs("GEOMETRY", ent_method);
528 };
529 CHKERR project_ho_geometry();
530
532}
533//! [Set up problem]
534
535//! [Boundary condition]
538
540 auto bc_mng = mField.getInterface<BcManager>();
541 auto *pipeline_mng = mField.getInterface<PipelineManager>();
542 auto time_scale = boost::make_shared<TimeScale>();
543
544 PetscBool sin_time_function = PETSC_FALSE;
545 CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-sin_time_function",
546 &sin_time_function, PETSC_NULL);
547
548 if (sin_time_function)
549 time_scale = boost::make_shared<DynamicFirstOrderConsSinusTimeScale>();
550 else
551 time_scale = boost::make_shared<DynamicFirstOrderConsConstantTimeScale>();
552
553 pipeline_mng->getBoundaryExplicitRhsFE().reset();
555 pipeline_mng->getOpBoundaryExplicitRhsPipeline(), {NOSPACE}, "GEOMETRY");
556
558 pipeline_mng->getOpBoundaryExplicitRhsPipeline(), mField, "V",
559 {time_scale}, "FORCE", Sev::inform);
560
561 auto integration_rule = [](int, int, int approx_order) {
562 return 2 * approx_order;
563 };
564
565 CHKERR pipeline_mng->setBoundaryExplicitRhsIntegrationRule(integration_rule);
566 CHKERR pipeline_mng->setDomainExplicitRhsIntegrationRule(integration_rule);
567
568 CHKERR bc_mng->removeBlockDOFsOnEntities<DisplacementCubitBcData>(
569 simple->getProblemName(), "V");
570
571 auto get_pre_proc_hook = [&]() {
573 mField, pipeline_mng->getDomainExplicitRhsFE(), {time_scale});
574 };
575 pipeline_mng->getDomainExplicitRhsFE()->preProcessHook = get_pre_proc_hook();
576
578}
579//! [Boundary condition]
580
582 PetscInt stageindex, Vec *Y) {
584 // cerr << "tsPostStage " <<"\n";
585 if (auto ptr = tsPrePostProc.lock()) {
586 auto &m_field = ptr->fsRawPtr->mField;
587 auto *simple = m_field.getInterface<Simple>();
588 auto *pipeline_mng = m_field.getInterface<PipelineManager>();
589
590 auto fb = m_field.getInterface<FieldBlas>();
591 double dt;
592 CHKERR TSGetTimeStep(ts, &dt);
593 double time;
594 CHKERR TSGetTime(ts, &time);
595 PetscInt num_stages;
596 Vec *stage_solutions;
597
598 CHKERR TSGetStages(ts, &num_stages, &stage_solutions);
599 PetscPrintf(PETSC_COMM_WORLD, "Check timestep %d time %e dt %e\n",
600 num_stages, time, dt);
601
602 const double inv_num_step = (double)num_stages;
603 CHKERR fb->fieldCopy(1., "x_1", "x_2");
604 CHKERR fb->fieldAxpy(dt, "V", "x_2");
605 CHKERR fb->fieldCopy(1., "x_2", "x_1");
606
607 CHKERR fb->fieldCopy(-inv_num_step / dt, "F_0", "F_dot");
608 CHKERR fb->fieldAxpy(inv_num_step / dt, "F", "F_dot");
609 CHKERR fb->fieldCopy(1., "F", "F_0");
610 }
612}
613
616
617 if (auto ptr = tsPrePostProc.lock()) {
618 auto &m_field = ptr->fsRawPtr->mField;
619 auto fb = m_field.getInterface<FieldBlas>();
620 double dt;
621 CHKERR TSGetTimeStep(ts, &dt);
622 double time;
623 CHKERR TSGetTime(ts, &time);
624 }
626}
627
630
631 if (auto ptr = tsPrePostProc.lock()) {
632 auto &m_field = ptr->fsRawPtr->mField;
633 auto *simple = m_field.getInterface<Simple>();
634 auto *pipeline_mng = m_field.getInterface<PipelineManager>();
635
636 double dt;
637 CHKERR TSGetTimeStep(ts, &dt);
638 double time;
639 CHKERR TSGetTime(ts, &time);
640 int step_num;
641 CHKERR TSGetStepNumber(ts, &step_num);
642 }
644}
645
646//! [Push operators to pipeline]
649 auto *simple = mField.getInterface<Simple>();
650 auto *pipeline_mng = mField.getInterface<PipelineManager>();
651
652 auto get_body_force = [this](const double, const double, const double) {
655 t_source(i) = 0.;
656 t_source(0) = 0.1;
657 t_source(1) = 1.;
658 return t_source;
659 };
660
661 // specific time scaling
662 auto get_time_scale = [this](const double time) {
663 return sin(time * omega * M_PI);
664 };
665
666 auto apply_rhs = [&](auto &pip) {
668
670 "GEOMETRY");
671
672 // Calculate Gradient of velocity
673 auto mat_v_grad_ptr = boost::make_shared<MatrixDouble>();
675 "V", mat_v_grad_ptr));
676
677 auto gravity_vector_ptr = boost::make_shared<MatrixDouble>();
678 gravity_vector_ptr->resize(SPACE_DIM, 1);
679 auto set_body_force = [&]() {
682 auto t_force = getFTensor1FromMat<SPACE_DIM, 0>(*gravity_vector_ptr);
683 double unit_weight = 0.;
684 CHKERR PetscOptionsGetReal(PETSC_NULL, "", "-unit_weight", &unit_weight,
685 PETSC_NULL);
686 t_force(i) = 0;
687 if (SPACE_DIM == 2) {
688 t_force(1) = -unit_weight;
689 } else if (SPACE_DIM == 3) {
690 t_force(2) = unit_weight;
691 }
693 };
694
695 CHKERR set_body_force();
696 pip.push_back(new OpBodyForce("V", gravity_vector_ptr,
697 [](double, double, double) { return 1.; }));
698
699 // Calculate unknown F
700 auto mat_H_tensor_ptr = boost::make_shared<MatrixDouble>();
702 "F", mat_H_tensor_ptr));
703
704 // // Calculate F
705 double tau = 0.2;
706 CHKERR PetscOptionsGetReal(PETSC_NULL, "", "-tau", &tau, PETSC_NULL);
707
708 double xi = 0.;
709 CHKERR PetscOptionsGetReal(PETSC_NULL, "", "-xi", &xi, PETSC_NULL);
710
711 // Calculate P stab
712 auto one = [&](const double, const double, const double) {
713 return 3. * bulk_modulus_K;
714 };
715 auto minus_one = [](const double, const double, const double) {
716 return -1.;
717 };
718
719 auto mat_dot_F_tensor_ptr = boost::make_shared<MatrixDouble>();
721 "F_dot", mat_dot_F_tensor_ptr));
722
723 // Calculate Gradient of Spatial Positions
724 auto mat_x_grad_ptr = boost::make_shared<MatrixDouble>();
726 "x_2", mat_x_grad_ptr));
727
728 auto mat_F_tensor_ptr = boost::make_shared<MatrixDouble>();
730 mat_F_tensor_ptr, mat_H_tensor_ptr));
731
732 auto mat_F_stab_ptr = boost::make_shared<MatrixDouble>();
734 mat_F_tensor_ptr, mat_F_stab_ptr, mat_dot_F_tensor_ptr, tau, xi,
735 mat_x_grad_ptr, mat_v_grad_ptr));
736
737 PetscBool is_linear_elasticity = PETSC_TRUE;
738 CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-is_linear_elasticity",
739 &is_linear_elasticity, PETSC_NULL);
740
741 auto mat_P_stab_ptr = boost::make_shared<MatrixDouble>();
742 if (is_linear_elasticity) {
745 mat_F_stab_ptr));
746 } else {
747 auto inv_F = boost::make_shared<MatrixDouble>();
748 auto det_ptr = boost::make_shared<VectorDouble>();
749
750 pip.push_back(
751 new OpInvertMatrix<SPACE_DIM>(mat_F_stab_ptr, det_ptr, inv_F));
752
753 // OpCalculatePiolaIncompressibleNH
756 mat_F_stab_ptr, inv_F, det_ptr));
757 }
758
759 pip.push_back(new OpGradTimesTensor2("V", mat_P_stab_ptr, minus_one));
760 pip.push_back(new OpRhsTestPiola("F", mat_v_grad_ptr, one));
761
763 };
764
765 CHKERR apply_rhs(pipeline_mng->getOpDomainExplicitRhsPipeline());
766
767 auto integration_rule = [](int, int, int approx_order) {
768 return 2 * approx_order;
769 };
770 CHKERR pipeline_mng->setDomainExplicitRhsIntegrationRule(integration_rule);
771
773}
774//! [Push operators to pipeline]
775
776/**
777 * @brief Monitor solution
778 *
779 * This functions is called by TS solver at the end of each step. It is used
780 * to output results to the hard drive.
781 */
782
783struct Monitor : public FEMethod {
786 boost::shared_ptr<PostProcEle> post_proc,
787 boost::shared_ptr<PostProcFaceEle> post_proc_bdry,
788 boost::shared_ptr<MatrixDouble> velocity_field_ptr,
789 boost::shared_ptr<MatrixDouble> x2_field_ptr,
790 boost::shared_ptr<MatrixDouble> geometry_field_ptr,
791 std::array<double, 3> pass_field_eval_coords,
792 boost::shared_ptr<SetPtsData> pass_field_eval_data)
793 : dM(dm), mField(m_field), postProc(post_proc),
794 postProcBdy(post_proc_bdry), velocityFieldPtr(velocity_field_ptr),
795 x2FieldPtr(x2_field_ptr), geometryFieldPtr(geometry_field_ptr),
796 fieldEvalCoords(pass_field_eval_coords),
797 fieldEvalData(pass_field_eval_data){};
800
801 // cerr << "wagawaga\n";
802 auto *simple = mField.getInterface<Simple>();
803
804 if (SPACE_DIM == 3) {
805 CHKERR mField.getInterface<FieldEvaluatorInterface>()->evalFEAtThePoint3D(
806 fieldEvalCoords.data(), 1e-12, simple->getProblemName(),
807 simple->getDomainFEName(), fieldEvalData, mField.get_comm_rank(),
809 } else {
810 CHKERR mField.getInterface<FieldEvaluatorInterface>()->evalFEAtThePoint2D(
811 fieldEvalCoords.data(), 1e-12, simple->getProblemName(),
812 simple->getDomainFEName(), fieldEvalData, mField.get_comm_rank(),
814 }
815
816 if (velocityFieldPtr->size1()) {
817 auto t_vel = getFTensor1FromMat<SPACE_DIM>(*velocityFieldPtr);
818 auto t_x2_field = getFTensor1FromMat<SPACE_DIM>(*x2FieldPtr);
819 auto t_geom = getFTensor1FromMat<SPACE_DIM>(*geometryFieldPtr);
820
821 double u_x = t_x2_field(0) - t_geom(0);
822 double u_y = t_x2_field(1) - t_geom(1);
823 double u_z = t_x2_field(2) - t_geom(2);
824
825 MOFEM_LOG("SYNC", Sev::inform)
826 << "Velocities x: " << t_vel(0) << " y: " << t_vel(1)
827 << " z: " << t_vel(2) << "\n";
828 MOFEM_LOG("SYNC", Sev::inform) << "Displacement x: " << u_x
829 << " y: " << u_y << " z: " << u_z << "\n";
830 }
831
833 std::regex((boost::format("%s(.*)") % "Data_Vertex").str()))) {
834 Range ents;
835 mField.get_moab().get_entities_by_dimension(m->getMeshset(), 0, ents,
836 true);
837 auto print_vets = [](boost::shared_ptr<FieldEntity> ent_ptr) {
839 if (!(ent_ptr->getPStatus() & PSTATUS_NOT_OWNED)) {
840 MOFEM_LOG("SYNC", Sev::inform)
841 << "Velocities: " << ent_ptr->getEntFieldData()[0] << " "
842 << ent_ptr->getEntFieldData()[1] << " "
843 << ent_ptr->getEntFieldData()[2] << "\n";
844 }
846 };
847 CHKERR mField.getInterface<FieldBlas>()->fieldLambdaOnEntities(
848 print_vets, "V", &ents);
849 }
851
852 PetscBool print_volume = PETSC_FALSE;
853 CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-print_volume", &print_volume,
854 PETSC_NULL);
855
856 PetscBool print_skin = PETSC_FALSE;
857 CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-print_skin", &print_skin,
858 PETSC_NULL);
859
860 int save_every_nth_step = 1;
861 CHKERR PetscOptionsGetInt(PETSC_NULL, "", "-save_step",
862 &save_every_nth_step, PETSC_NULL);
863 if (ts_step % save_every_nth_step == 0) {
864
865 if (print_volume) {
867 CHKERR postProc->writeFile(
868 "out_step_" + boost::lexical_cast<std::string>(ts_step) + ".h5m");
869 }
870
871 if (print_skin) {
873 CHKERR postProcBdy->writeFile(
874 "out_boundary_" + boost::lexical_cast<std::string>(ts_step) +
875 ".h5m");
876 }
877 }
879 }
880
881private:
883 boost::shared_ptr<PostProcEle> postProc;
884 boost::shared_ptr<PostProcFaceEle> postProcBdy;
885 boost::shared_ptr<MatrixDouble> velocityFieldPtr;
886 boost::shared_ptr<MatrixDouble> x2FieldPtr;
887 boost::shared_ptr<MatrixDouble> geometryFieldPtr;
888 std::array<double, 3> fieldEvalCoords;
889 boost::shared_ptr<SetPtsData> fieldEvalData;
890};
891
892//! [Solve]
895 auto *simple = mField.getInterface<Simple>();
896 auto *pipeline_mng = mField.getInterface<PipelineManager>();
897
898 auto dm = simple->getDM();
899
900 auto calculate_stress_ops = [&](auto &pip) {
902
903 auto v_ptr = boost::make_shared<MatrixDouble>();
904 pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("V", v_ptr));
905 auto X_ptr = boost::make_shared<MatrixDouble>();
906 pip.push_back(
907 new OpCalculateVectorFieldValues<SPACE_DIM>("GEOMETRY", X_ptr));
908
909 auto x_ptr = boost::make_shared<MatrixDouble>();
910 pip.push_back(new OpCalculateVectorFieldValues<SPACE_DIM>("x_1", x_ptr));
911
912 // Calculate unknown F
913 auto mat_H_tensor_ptr = boost::make_shared<MatrixDouble>();
915 "F", mat_H_tensor_ptr));
916
917 auto u_ptr = boost::make_shared<MatrixDouble>();
918 pip.push_back(new OpCalculateDisplacement<SPACE_DIM>(x_ptr, X_ptr, u_ptr));
919 // Calculate P
920
921 auto mat_F_ptr = boost::make_shared<MatrixDouble>();
923 mat_F_ptr, mat_H_tensor_ptr));
924
925 PetscBool is_linear_elasticity = PETSC_TRUE;
926 CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-is_linear_elasticity",
927 &is_linear_elasticity, PETSC_NULL);
928
929 auto mat_P_ptr = boost::make_shared<MatrixDouble>();
930 if (is_linear_elasticity) {
933 mat_F_ptr));
934 } else {
935 auto inv_F = boost::make_shared<MatrixDouble>();
936 auto det_ptr = boost::make_shared<VectorDouble>();
937
938 pip.push_back(new OpInvertMatrix<SPACE_DIM>(mat_F_ptr, det_ptr, inv_F));
939
942 mat_F_ptr, inv_F, det_ptr));
943 }
944
945 auto mat_v_grad_ptr = boost::make_shared<MatrixDouble>();
947 "V", mat_v_grad_ptr));
948
949 return boost::make_tuple(v_ptr, X_ptr, x_ptr, mat_P_ptr, mat_F_ptr, u_ptr);
950 };
951
952 auto post_proc_boundary = [&]() {
953 auto boundary_post_proc_fe = boost::make_shared<PostProcFaceEle>(mField);
954
956 boundary_post_proc_fe->getOpPtrVector(), {}, "GEOMETRY");
957 auto op_loop_side =
958 new OpLoopSide<SideEle>(mField, simple->getDomainFEName(), SPACE_DIM);
959 // push ops to side element, through op_loop_side operator
960 auto [boundary_v_ptr, boundary_X_ptr, boundary_x_ptr, boundary_mat_P_ptr,
961 boundary_mat_F_ptr, boundary_u_ptr] =
962 calculate_stress_ops(op_loop_side->getOpPtrVector());
963 boundary_post_proc_fe->getOpPtrVector().push_back(op_loop_side);
964
966
967 boundary_post_proc_fe->getOpPtrVector().push_back(
968
969 new OpPPMap(
970
971 boundary_post_proc_fe->getPostProcMesh(),
972 boundary_post_proc_fe->getMapGaussPts(),
973
975
976 OpPPMap::DataMapMat{{"V", boundary_v_ptr},
977 {"GEOMETRY", boundary_X_ptr},
978 {"x", boundary_x_ptr},
979 {"U", boundary_u_ptr}},
980
981 OpPPMap::DataMapMat{{"FIRST_PIOLA", boundary_mat_P_ptr},
982 {"F", boundary_mat_F_ptr}},
983
985
986 )
987
988 );
989 return boundary_post_proc_fe;
990 };
991
992 // Add monitor to time solver
993
994 double rho = 1.;
995 CHKERR PetscOptionsGetReal(PETSC_NULL, "", "-density", &rho, PETSC_NULL);
996 auto get_rho = [rho](const double, const double, const double) {
997 return rho;
998 };
999
1000 SmartPetscObj<Mat> M; ///< Mass matrix
1001 SmartPetscObj<KSP> ksp; ///< Linear solver
1002
1003 auto ts_pre_post_proc = boost::make_shared<TSPrePostProc>();
1004 tsPrePostProc = ts_pre_post_proc;
1005
1007 CHKERR MatZeroEntries(M);
1008
1009 boost::shared_ptr<DomainEle> vol_mass_ele(new DomainEle(mField));
1010
1011 vol_mass_ele->B = M;
1012
1013 auto integration_rule = [](int, int, int approx_order) {
1014 return 2 * approx_order;
1015 };
1016
1017 vol_mass_ele->getRuleHook = integration_rule;
1018
1019 vol_mass_ele->getOpPtrVector().push_back(new OpMassV("V", "V", get_rho));
1020 vol_mass_ele->getOpPtrVector().push_back(new OpMassF("F", "F"));
1021
1022 CHKERR DMoFEMLoopFiniteElements(dm, simple->getDomainFEName(), vol_mass_ele);
1023 CHKERR MatAssemblyBegin(M, MAT_FINAL_ASSEMBLY);
1024 CHKERR MatAssemblyEnd(M, MAT_FINAL_ASSEMBLY);
1025
1026 auto lumpVec = createDMVector(simple->getDM());
1027 CHKERR MatGetRowSum(M, lumpVec);
1028
1029 CHKERR MatZeroEntries(M);
1030 CHKERR MatDiagonalSet(M, lumpVec, INSERT_VALUES);
1031
1032 // Create and septup KSP (linear solver), we need this to calculate g(t,u) =
1033 // M^-1G(t,u)
1034 ksp = createKSP(mField.get_comm());
1035 CHKERR KSPSetOperators(ksp, M, M);
1036 CHKERR KSPSetFromOptions(ksp);
1037 CHKERR KSPSetUp(ksp);
1038
1039 auto solve_boundary_for_g = [&]() {
1041 if (*(pipeline_mng->getBoundaryExplicitRhsFE()->vecAssembleSwitch)) {
1042
1043 CHKERR VecGhostUpdateBegin(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F,
1044 ADD_VALUES, SCATTER_REVERSE);
1045 CHKERR VecGhostUpdateEnd(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F,
1046 ADD_VALUES, SCATTER_REVERSE);
1047 CHKERR VecAssemblyBegin(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
1048 CHKERR VecAssemblyEnd(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
1049 *(pipeline_mng->getBoundaryExplicitRhsFE()->vecAssembleSwitch) = false;
1050
1051 auto D =
1052 smartVectorDuplicate(pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
1053 CHKERR KSPSolve(ksp, pipeline_mng->getBoundaryExplicitRhsFE()->ts_F, D);
1054 CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
1055 CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
1056 CHKERR VecCopy(D, pipeline_mng->getBoundaryExplicitRhsFE()->ts_F);
1057 }
1058
1060 };
1061
1062 pipeline_mng->getBoundaryExplicitRhsFE()->postProcessHook =
1063 solve_boundary_for_g;
1064
1066 ts = pipeline_mng->createTSEX(dm);
1067
1068 // Field eval
1069 PetscBool field_eval_flag = PETSC_TRUE;
1070 boost::shared_ptr<MatrixDouble> velocity_field_ptr;
1071 boost::shared_ptr<MatrixDouble> geometry_field_ptr;
1072 boost::shared_ptr<MatrixDouble> spatial_position_field_ptr;
1073 boost::shared_ptr<SetPtsData> field_eval_data;
1074
1075 std::array<double, 3> field_eval_coords = {0.5, 0.5, 5.};
1076 int dim = 3;
1077 CHKERR PetscOptionsGetRealArray(NULL, NULL, "-field_eval_coords",
1078 field_eval_coords.data(), &dim,
1079 &field_eval_flag);
1080
1081 if (field_eval_flag) {
1082 field_eval_data =
1083 mField.getInterface<FieldEvaluatorInterface>()->getData<DomainEle>();
1084 if (SPACE_DIM == 3) {
1085 CHKERR mField.getInterface<FieldEvaluatorInterface>()->buildTree3D(
1086 field_eval_data, simple->getDomainFEName());
1087 } else {
1088 CHKERR mField.getInterface<FieldEvaluatorInterface>()->buildTree2D(
1089 field_eval_data, simple->getDomainFEName());
1090 }
1091
1092 field_eval_data->setEvalPoints(field_eval_coords.data(), 1);
1093
1094 auto no_rule = [](int, int, int) { return -1; };
1095
1096 auto fe_ptr = field_eval_data->feMethodPtr.lock();
1097 fe_ptr->getRuleHook = no_rule;
1098 velocity_field_ptr = boost::make_shared<MatrixDouble>();
1099 geometry_field_ptr = boost::make_shared<MatrixDouble>();
1100 spatial_position_field_ptr = boost::make_shared<MatrixDouble>();
1101 fe_ptr->getOpPtrVector().push_back(
1102 new OpCalculateVectorFieldValues<SPACE_DIM>("V", velocity_field_ptr));
1103 fe_ptr->getOpPtrVector().push_back(
1105 geometry_field_ptr));
1106 fe_ptr->getOpPtrVector().push_back(
1108 "x_2", spatial_position_field_ptr));
1109 }
1110
1111 auto post_proc_domain = [&]() {
1112 auto post_proc_fe_vol = boost::make_shared<PostProcEle>(mField);
1113
1115
1116 auto [boundary_v_ptr, boundary_X_ptr, boundary_x_ptr, boundary_mat_P_ptr,
1117 boundary_mat_F_ptr, boundary_u_ptr] =
1118 calculate_stress_ops(post_proc_fe_vol->getOpPtrVector());
1119
1120 post_proc_fe_vol->getOpPtrVector().push_back(
1121
1122 new OpPPMap(
1123
1124 post_proc_fe_vol->getPostProcMesh(),
1125 post_proc_fe_vol->getMapGaussPts(),
1126
1127 {},
1128
1129 {{"V", boundary_v_ptr},
1130 {"GEOMETRY", boundary_X_ptr},
1131 {"x", boundary_x_ptr},
1132 {"U", boundary_u_ptr}},
1133
1134 {{"FIRST_PIOLA", boundary_mat_P_ptr}, {"F", boundary_mat_F_ptr}},
1135
1136 {}
1137
1138 )
1139
1140 );
1141 return post_proc_fe_vol;
1142 };
1143
1144 boost::shared_ptr<FEMethod> null_fe;
1145 auto monitor_ptr = boost::make_shared<Monitor>(
1146 SmartPetscObj<DM>(dm, true), mField, post_proc_domain(),
1147 post_proc_boundary(), velocity_field_ptr, spatial_position_field_ptr,
1148 geometry_field_ptr, field_eval_coords, field_eval_data);
1149
1150 CHKERR DMMoFEMTSSetMonitor(dm, ts, simple->getDomainFEName(), null_fe,
1151 null_fe, monitor_ptr);
1152
1153 double ftime = 1;
1154 // CHKERR TSSetMaxTime(ts, ftime);
1155 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
1156
1157 auto T = createDMVector(simple->getDM());
1158 CHKERR DMoFEMMeshToLocalVector(simple->getDM(), T, INSERT_VALUES,
1159 SCATTER_FORWARD);
1160 CHKERR TSSetSolution(ts, T);
1161 CHKERR TSSetFromOptions(ts);
1162
1163 auto fb = mField.getInterface<FieldBlas>();
1164
1165 CHKERR TSSetPostStage(ts, TSPrePostProc::tsPostStage);
1166 CHKERR TSSetPostStep(ts, TSPrePostProc::tsPostStep);
1167 CHKERR TSSetPreStep(ts, TSPrePostProc::tsPreStep);
1168
1169 boost::shared_ptr<ForcesAndSourcesCore> null;
1170
1171 if (auto ptr = tsPrePostProc.lock()) {
1172 ptr->fsRawPtr = this;
1173 CHKERR TSSetUp(ts);
1174 CHKERR TSSolve(ts, NULL);
1175 CHKERR TSGetTime(ts, &ftime);
1176 }
1177
1179}
1180//! [Solve]
1181
1182//! [Postprocess results]
1185 PetscBool test_flg = PETSC_FALSE;
1186 CHKERR PetscOptionsGetBool(PETSC_NULL, "", "-test", &test_flg, PETSC_NULL);
1187 if (test_flg) {
1188 auto *simple = mField.getInterface<Simple>();
1189 auto T = createDMVector(simple->getDM());
1190 CHKERR DMoFEMMeshToLocalVector(simple->getDM(), T, INSERT_VALUES,
1191 SCATTER_FORWARD);
1192 double nrm2;
1193 CHKERR VecNorm(T, NORM_2, &nrm2);
1194 MOFEM_LOG("EXAMPLE", Sev::inform) << "Regression norm " << nrm2;
1195 constexpr double regression_value = 0.0194561;
1196 if (fabs(nrm2 - regression_value) > 1e-2)
1197 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
1198 "Regression test failed; wrong norm value.");
1199 }
1201}
1202//! [Postprocess results]
1203
1204//! [Check]
1208}
1209//! [Check]
1210
1211static char help[] = "...\n\n";
1212
1213int main(int argc, char *argv[]) {
1214
1215 // Initialisation of MoFEM/PETSc and MOAB data structures
1216 const char param_file[] = "param_file.petsc";
1217 MoFEM::Core::Initialize(&argc, &argv, param_file, help);
1218
1219 // Add logging channel for example
1220 auto core_log = logging::core::get();
1221 core_log->add_sink(
1223 LogManager::setLog("EXAMPLE");
1224 MOFEM_LOG_TAG("EXAMPLE", "example");
1225
1226 try {
1227
1228 //! [Register MoFEM discrete manager in PETSc]
1229 DMType dm_name = "DMMOFEM";
1230 CHKERR DMRegister_MoFEM(dm_name);
1231 //! [Register MoFEM discrete manager in PETSc
1232
1233 //! [Create MoAB]
1234 moab::Core mb_instance; ///< mesh database
1235 moab::Interface &moab = mb_instance; ///< mesh database interface
1236 //! [Create MoAB]
1237
1238 //! [Create MoFEM]
1239 MoFEM::Core core(moab); ///< finite element database
1240 MoFEM::Interface &m_field = core; ///< finite element database interface
1241 //! [Create MoFEM]
1242
1243 //! [Example]
1244 Example ex(m_field);
1245 CHKERR ex.runProblem();
1246 //! [Example]
1247 }
1249
1251}
static Index< 'M', 3 > M
std::string param_file
constexpr double third
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
Definition: LogManager.hpp:352
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
int main()
Definition: adol-c_atom.cpp:46
constexpr int SPACE_DIM
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
Kronecker Delta class.
@ QUIET
Definition: definitions.h:208
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
@ MF_EXIST
Definition: definitions.h:100
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 ...
Definition: definitions.h:346
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
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
double lamme_lambda
static char help[]
[Check]
constexpr int SPACE_DIM
FormsIntegrators< DomainEleOp >::Assembly< AssemblyType::PETSC >::LinearForm< IntegrationType::GAUSS >::OpBaseTimesVector< 1, SPACE_DIM *SPACE_DIM, 1 > OpRhsTestPiola
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 >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpGradTimesTensor2
double shear_modulus_G
constexpr double young_modulus
const int dim
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
FTensor::Index< 'm', SPACE_DIM > m
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
auto integration_rule
constexpr auto t_kd
constexpr int SPACE_DIM
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMoFEM.cpp:509
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition: DMMoFEM.cpp:1183
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMoFEM.cpp:47
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:572
auto createDMVector(DM dm)
Get smart vector from DM.
Definition: DMMoFEM.hpp:1003
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
Definition: LogManager.cpp:389
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
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
double dt
Definition: heat_method.cpp:26
double D
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
const double T
FormsIntegrators< DomainEleOp >::Assembly< USER_ASSEMBLE >::LinearForm< GAUSS >::OpBaseTimesVector< 1, 3, 1 > OpInertiaForce
FormsIntegrators< DomainEleOp >::Assembly< USER_ASSEMBLE >::LinearForm< GAUSS >::OpSource< 1, 3 > OpBodyForce
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
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:1042
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
DEPRECATED SmartPetscObj< Vec > smartVectorDuplicate(Vec vec)
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)
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
double rho
Definition: plastic.cpp:191
#define EXECUTABLE_DIMENSION
Definition: plastic.cpp:13
ElementsAndOps< SPACE_DIM >::SideEle SideEle
Definition: plastic.cpp:61
static constexpr int approx_order
constexpr double mu
constexpr double omega
FTensor::Index< 'i', 3 > i
SmartPetscObj< Mat > M
Mass matrix.
SmartPetscObj< KSP > ksp
Linear solver.
double getScale(const double time)
Get scaling at a given time.
double getScale(const double time)
Get scaling at a given time.
[Example]
Definition: plastic.cpp:226
MoFEMErrorCode boundaryCondition()
[Set up problem]
MoFEMErrorCode assembleSystem()
[Push operators to pipeline]
MoFEMErrorCode readMesh()
[Run problem]
FieldApproximationBase base
Definition: plot_base.cpp:68
MoFEMErrorCode checkResults()
[Postprocess results]
MoFEMErrorCode solveSystem()
[Solve]
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
MoFEM::Interface & mField
Definition: plastic.cpp:233
MoFEMErrorCode setupProblem()
MoFEMErrorCode outputResults()
[Solve]
double getScale(const double time)
Get scaling at a given time.
Add operators pushing bases from local to physical configuration.
boost::weak_ptr< CacheTuple > getCacheWeakPtr() const
Get the cache weak ptr object.
Simple interface for fast problem set-up.
Definition: BcManager.hpp:25
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:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112
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:39
structure for User Loop Methods on finite elements
Basic algebra on fields.
Definition: FieldBlas.hpp:21
Field evaluator interface.
structure to get information form mofem into EntitiesFieldData
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:298
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:344
Interface for managing meshsets containing materials and boundary conditions.
Assembly methods.
Definition: Natural.hpp:65
Get values at integration pts for tensor filed rank 2, i.e. matrix field.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Get values at integration pts for tensor filed rank 1, i.e. vector field.
Element used to execute operators on side of the element.
Post post-proc data at points from hash maps.
std::map< std::string, boost::shared_ptr< VectorDouble > > DataMapVec
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat
PipelineManager interface.
Projection of edge entities with one mid-node on hierarchical basis.
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
intrusive_ptr for managing petsc objects
PetscInt ts_step
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)
TimeScale constructor.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce 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()
function is run at the end of loop
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
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
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
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
Example * fsRawPtr
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.