8 using Ele = ForcesAndSourcesCore;
9 using VolEle = VolumeElementForcesAndSourcesCore;
12 using PtsHashMap = std::map<std::string, std::array<double, 3>>;
21 :
eP(ep),
dataFieldEval(ep.mField.getInterface<FieldEvaluatorInterface>()
24 ierr = ep.mField.getInterface<FieldEvaluatorInterface>()->buildTree3D(
26 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
28 auto no_rule = [](
int,
int,
int) {
return -1; };
30 auto set_element_for_field_eval = [&]() {
32 boost::shared_ptr<Ele> vol_ele(
dataFieldEval->feMethodPtr.lock());
33 vol_ele->getRuleHook = no_rule;
34 vol_ele->getUserPolynomialBase() =
35 boost::make_shared<CGGUserPolynomialBase>();
37 vol_ele->getOpPtrVector(), {HDIV, H1, L2},
eP.materialH1Positions,
40 vol_ele->getOpPtrVector().push_back(
new OpCalculateHVecTensorField<3, 3>(
41 eP.piolaStress,
eP.dataAtPts->getApproxPAtPts()));
42 vol_ele->getOpPtrVector().push_back(
43 new OpCalculateHTensorTensorField<3, 3>(
44 eP.bubbleField,
eP.dataAtPts->getApproxPAtPts(), MBMAXTYPE));
45 if (EshelbianCore::noStretch) {
46 vol_ele->getOpPtrVector().push_back(
47 eP.physicalEquations->returnOpCalculateStretchFromStress(
48 eP.dataAtPts,
eP.physicalEquations));
50 vol_ele->getOpPtrVector().push_back(
51 new OpCalculateTensor2SymmetricFieldValues<3>(
52 eP.stretchTensor,
eP.dataAtPts->getLogStretchTensorAtPts(),
55 vol_ele->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>(
56 eP.rotAxis,
eP.dataAtPts->getRotAxisAtPts(), MBTET));
57 vol_ele->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>(
58 eP.spatialL2Disp,
eP.dataAtPts->getSmallWL2AtPts(), MBTET));
61 vol_ele->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>(
62 eP.spatialH1Disp,
eP.dataAtPts->getSmallWH1AtPts()));
63 vol_ele->getOpPtrVector().push_back(
65 eP.spatialH1Disp,
eP.dataAtPts->getSmallWGradH1AtPts()));
67 vol_ele->getOpPtrVector().push_back(
68 new OpCalculateRotationAndSpatialGradient(
eP.dataAtPts));
72 auto set_element_for_post_process_energy = [&]() {
75 auto bubble_cache = boost::make_shared<CGGUserPolynomialBase::CachePhi>(
78 boost::make_shared<CGGUserPolynomialBase>(bubble_cache);
81 eP.materialH1Positions, ep.frontAdjEdges);
83 new OpCalculateHVecTensorField<3, 3>(
84 eP.piolaStress,
eP.dataAtPts->getApproxPAtPts()));
86 new OpCalculateHTensorTensorField<3, 3>(
87 eP.bubbleField,
eP.dataAtPts->getApproxPAtPts(), MBMAXTYPE));
90 eP.physicalEquations->returnOpCalculateStretchFromStress(
91 eP.dataAtPts,
eP.physicalEquations));
94 new OpCalculateTensor2SymmetricFieldValues<3>(
95 eP.stretchTensor,
eP.dataAtPts->getLogStretchTensorAtPts(),
99 new OpCalculateVectorFieldValues<3>(
100 eP.rotAxis,
eP.dataAtPts->getRotAxisAtPts(), MBTET));
102 new OpCalculateRotationAndSpatialGradient(
eP.dataAtPts));
104 if (
auto op =
eP.physicalEquations->returnOpCalculateEnergy(
eP.dataAtPts,
112 auto reads_post_proc_data =
118 if (!file.is_open()) {
124 while (std::getline(file, line)) {
125 std::istringstream iss(line);
127 double col2, col3, col4;
129 if (iss >> col1 >> col2 >> col3 >> col4) {
130 MOFEM_LOG(
"EP", Sev::verbose) <<
"Read: " << col1 <<
", " << col2
131 <<
", " << col3 <<
", " << col4;
132 pts_hash_map[col1] = {col2, col3, col4};
134 MOFEM_LOG(
"EP", Sev::error) <<
"Error parsing line: " << line;
144 "set element for post energy");
146 PetscBool test_cook_flg = PETSC_FALSE;
148 &test_cook_flg, PETSC_NULL),
149 "get post proc points");
152 ptsHashMap[
"Point B"] = {48. / 2., 44. + (60. - 44.) / 2., 0.};
153 ptsHashMap[
"Point C"] = {48. / 2., (44. - 0.) / 2., 0.};
165 MOFEM_LOG(
"EP", Sev::inform) <<
"Monitor postProcess";
167 auto get_step = [](
auto ts_step) {
168 std::ostringstream ss;
169 ss << boost::str(boost::format(
"%d") %
static_cast<int>(ts_step));
170 std::string s = ss.str();
175 CHKERR PetscViewerBinaryOpen(
176 PETSC_COMM_WORLD, (
"restart_" + get_step(ts_step) +
".dat").c_str(),
177 FILE_MODE_WRITE, &viewer);
178 CHKERR VecView(ts_u, viewer);
179 CHKERR PetscViewerDestroy(&viewer);
181 CHKERR eP.postProcessResults(1,
"out_sol_elastic_" + get_step(ts_step) +
187 CHKERR eP.mField.loop_finite_elements(problemPtr->getName(),
"EP",
191 double body_energy = 0;
192 MPI_Allreduce(
gEnergy.get(), &body_energy, 1, MPI_DOUBLE, MPI_SUM,
193 eP.mField.get_comm());
194 MOFEM_LOG_C(
"EP", Sev::inform,
"Step %d time %3.4g strain energy %3.6e",
195 ts_step, ts_t, body_energy);
197 auto post_proc_at_points = [&](std::array<double, 3> point,
201 dataFieldEval->setEvalPoints(point.data(), point.size() / 3);
203 struct OpPrint :
public VolOp {
206 std::array<double, 3> point;
209 OpPrint(EshelbianCore &ep, std::array<double, 3> &point,
218 if (getGaussPts().size2()) {
220 auto t_h = getFTensor2FromMat<3, 3>(
eP.dataAtPts->hAtPts);
222 getFTensor2FromMat<3, 3>(
eP.dataAtPts->approxPAtPts);
229 t_cauchy(
i,
j) = (1. / jac) * (t_approx_P(
i,
k) * t_h(
j,
k));
232 std::ostringstream s;
233 s << str <<
" elem " << getFEEntityHandle() <<
" ";
237 auto print_tensor = [](
auto &
t) {
238 std::ostringstream s;
243 std::ostringstream print;
245 << add() <<
"comm rank " <<
eP.mField.get_comm_rank();
249 << add() <<
"coords at gauss pts " << getCoordsAtGaussPts();
251 << add() <<
"w " <<
eP.dataAtPts->wL2AtPts;
253 << add() <<
"Piola " <<
eP.dataAtPts->approxPAtPts;
255 << add() <<
"Cauchy " << print_tensor(t_cauchy);
264 fe_ptr->getOpPtrVector().push_back(
new OpPrint(
eP, point, str));
265 CHKERR eP.mField.getInterface<FieldEvaluatorInterface>()
266 ->evalFEAtThePoint3D(point.data(), 1e-12, problemPtr->getName(),
270 fe_ptr->getOpPtrVector().pop_back();
278 CHKERR post_proc_at_points(pts.second, pts.first);