8 using Ele = ForcesAndSourcesCore;
9 using VolEle = VolumeElementForcesAndSourcesCore;
12 using PtsHashMap = std::map<std::string, std::array<double, 3>>;
23 :
eP(ep),
dataFieldEval(ep.mField.getInterface<FieldEvaluatorInterface>()
28 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
30 auto no_rule = [](
int,
int,
int) {
return -1; };
32 auto set_element_for_field_eval = [&]() {
34 boost::shared_ptr<Ele> vol_ele(
dataFieldEval->feMethodPtr.lock());
35 vol_ele->getRuleHook = no_rule;
36 vol_ele->getUserPolynomialBase() =
37 boost::make_shared<CGGUserPolynomialBase>();
38 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
42 auto piola_scale_ptr = boost::make_shared<double>(1.0);
43 vol_ele->getOpPtrVector().push_back(
46 vol_ele->getOpPtrVector().push_back(
new OpCalculateHVecTensorField<3, 3>(
48 vol_ele->getOpPtrVector().push_back(
49 new OpCalculateHTensorTensorField<3, 3>(
51 SmartPetscObj<Vec>(), MBMAXTYPE));
53 vol_ele->getOpPtrVector().push_back(
57 vol_ele->getOpPtrVector().push_back(
58 new OpCalculateTensor2SymmetricFieldValues<3>(
62 vol_ele->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>(
64 vol_ele->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>(
66 vol_ele->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>(
70 vol_ele->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>(
72 vol_ele->getOpPtrVector().push_back(
76 vol_ele->getOpPtrVector().push_back(
81 auto set_element_for_post_process_energy = [&]() {
88 auto bubble_cache = boost::make_shared<CGGUserPolynomialBase::CachePhi>(
91 boost::make_shared<CGGUserPolynomialBase>(bubble_cache);
92 EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
95 auto piola_scale_ptr = boost::make_shared<double>(1.0);
104 new OpCalculateHTensorTensorField<3, 3>(
106 SmartPetscObj<Vec>(), MBMAXTYPE));
113 new OpCalculateTensor2SymmetricFieldValues<3>(
118 new OpCalculateVectorFieldValues<3>(
121 new OpCalculateVectorFieldValues<3>(
eP.
rotAxis,
139 auto reads_post_proc_data = [](
PtsHashMap &pts_hash_map) {
144 if (!file.is_open()) {
150 while (std::getline(file, line)) {
151 std::istringstream iss(line);
153 double col2, col3, col4;
155 if (iss >> col1 >> col2 >> col3 >> col4) {
156 MOFEM_LOG(
"EP", Sev::verbose) <<
"Read: " << col1 <<
", " << col2
157 <<
", " << col3 <<
", " << col4;
158 pts_hash_map[col1] = {col2, col3, col4};
160 MOFEM_LOG(
"EP", Sev::error) <<
"Error parsing line: " << line;
170 "set element for post energy");
172 PetscBool test_cook_flg = PETSC_FALSE;
174 &test_cook_flg, PETSC_NULL),
175 "get post proc points");
178 ptsHashMap[
"Point B"] = {48. / 2., 44. + (60. - 44.) / 2., 0.};
179 ptsHashMap[
"Point C"] = {48. / 2., (44. - 0.) / 2., 0.};
191 MOFEM_LOG(
"EP", Sev::inform) <<
"Monitor postProcess";
194 auto get_ents_on_mesh_skin = [&]() {
196 std::map<std::string, Range> boundary_entities_vec;
197 Range boundary_entities;
199 std::string meshset_name = it->getName();
200 std::string block_name_disp =
"SPATIAL_DISP";
201 std::string block_name_fix =
"FIX";
202 if (meshset_name.compare(0, block_name_disp.size(), block_name_disp) == 0 ||
203 meshset_name.compare(0, block_name_fix.size(), block_name_fix) == 0) {
205 boundary_entities,
true);
207 boundary_entities_vec[meshset_name] = boundary_entities;
208 boundary_entities.clear();
211 return boundary_entities_vec;
214 auto boundary_entities_vec = get_ents_on_mesh_skin();
216 std::vector<std::tuple<std::string, Range, std::array<double, 6>>>
218 for (
const auto &pair : boundary_entities_vec) {
219 reactionForces.push_back(
220 std::make_tuple(pair.first, pair.second,
221 std::array<double, 6>{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}));
228 boost::make_shared<FaceElementForcesAndSourcesCore>(
eP.
mField);
229 auto no_rule = [](
int,
int,
int) {
return -1; };
230 face_fe->getRuleHook = integration_rule_face;
232 EshelbianPlasticity::AddHOOps<SPACE_DIM - 1, SPACE_DIM, SPACE_DIM>::add(
238 face_fe->getOpPtrVector().push_back(op_side);
239 auto side_fe_ptr = op_side->getSideFEPtr();
241 boost::make_shared<EshelbianPlasticity::CGGUserPolynomialBase>();
242 side_fe_ptr->getUserPolynomialBase() = base_ptr;
243 CHKERR EshelbianPlasticity::AddHOOps<SPACE_DIM, SPACE_DIM, SPACE_DIM>::add(
246 auto piola_scale_ptr = boost::make_shared<double>(1.0);
247 side_fe_ptr->getOpPtrVector().push_back(
250 side_fe_ptr->getOpPtrVector().push_back(
251 new OpCalculateHVecTensorField<SPACE_DIM, SPACE_DIM>(
253 side_fe_ptr->getOpPtrVector().push_back(
254 new OpCalculateHTensorTensorField<3, 3>(
256 side_fe_ptr->getOpPtrVector().push_back(
258 side_fe_ptr->getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>(
260 for (
auto &[name, ents, reaction_vec] : reactionForces) {
268 for (
auto &[name, ents, reaction_vec] : reactionForces) {
269 std::array<double, 6> block_reaction_force{0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
271 MPI_Allreduce(reaction_vec.data(), &block_reaction_force, 6, MPI_DOUBLE,
274 for (
auto &force : block_reaction_force) {
275 if (std::abs(force) < 1e-12) {
281 "Step %d time %3.4g Block %s Reaction force [%3.6e, %3.6e, %3.6e]",
282 ts_step, ts_t, name.c_str(), block_reaction_force[0],
283 block_reaction_force[1], block_reaction_force[2]);
285 "Step %d time %3.4g Block %s Moment [%3.6e, %3.6e, %3.6e]",
286 ts_step, ts_t, name.c_str(), block_reaction_force[3],
287 block_reaction_force[4], block_reaction_force[5]);
290 auto get_step = [](
auto ts_step) {
291 std::ostringstream ss;
292 ss << boost::str(boost::format(
"%d") %
static_cast<int>(ts_step));
293 std::string s = ss.str();
299 CHKERR PetscViewerBinaryOpen(
300 PETSC_COMM_WORLD, (
"restart_" + get_step(ts_step) +
".dat").c_str(),
301 FILE_MODE_WRITE, &viewer);
302 CHKERR VecView(ts_u, viewer);
303 CHKERR PetscViewerDestroy(&viewer);
316 double body_energy = 0;
317 MPI_Allreduce(
gEnergy.get(), &body_energy, 1, MPI_DOUBLE, MPI_SUM,
319 MOFEM_LOG_C(
"EP", Sev::inform,
"Step %d time %3.4g strain energy %3.6e",
320 ts_step, ts_t, body_energy);
322 auto post_proc_at_points = [&](std::array<double, 3> point,
326 dataFieldEval->setEvalPoints(point.data(), point.size() / 3);
328 struct OpPrint :
public VolOp {
331 std::array<double, 3> point;
343 if (getGaussPts().size2()) {
345 auto t_h = getFTensor2FromMat<3, 3>(
eP.
dataAtPts->hAtPts);
347 getFTensor2FromMat<3, 3>(
eP.
dataAtPts->approxPAtPts);
354 t_cauchy(
i,
j) = (1. / jac) * (t_approx_P(
i,
k) * t_h(
j,
k));
357 std::ostringstream s;
358 s << str <<
" elem " << getFEEntityHandle() <<
" ";
362 auto print_tensor = [](
auto &
t) {
363 std::ostringstream s;
368 std::ostringstream print;
374 << add() <<
"coords at gauss pts " << getCoordsAtGaussPts();
378 << add() <<
"Piola " <<
eP.
dataAtPts->approxPAtPts;
380 << add() <<
"Cauchy " << print_tensor(t_cauchy);
389 fe_ptr->getOpPtrVector().push_back(
new OpPrint(
eP, point, str));
391 ->evalFEAtThePoint3D(point.data(), 1e-12, problemPtr->getName(),
395 fe_ptr->getOpPtrVector().pop_back();
403 CHKERR post_proc_at_points(pts.second, pts.first);