21 {
23
24 try {
25
26 PetscBool flg = PETSC_TRUE;
29 255, &flg);
30
31 moab::Core mb_instance;
32 moab::Interface &moab = mb_instance;
33
34 const char *option;
35 option = "";
37
38 std::string mwls_stress_tag_name = "MED_SIGP";
39 std::string mwls_rho_tag_name = "RHO_CELL";
41 double def[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0};
42 CHKERR moab.tag_get_handle(mwls_stress_tag_name.c_str(), 9, MB_TYPE_DOUBLE,
43 th, MB_TAG_CREAT | MB_TAG_SPARSE, def);
44 CHKERR moab.tag_get_handle(mwls_rho_tag_name.c_str(), 1, MB_TYPE_DOUBLE,
45 th_rho, MB_TAG_CREAT | MB_TAG_SPARSE, def);
46
47 Range three_dimensional_entities;
48 CHKERR moab.get_entities_by_dimension(0, 3, three_dimensional_entities,
49 true);
51 for (auto ent : three_dimensional_entities) {
53 int num_nodes;
54 CHKERR moab.get_connectivity(ent, conn, num_nodes,
true);
55 coords.resize(num_nodes, 3, false);
56 CHKERR moab.get_coords(conn, num_nodes, &*coords.data().begin());
57 auto get_centroid = [](auto &coords) {
59 &coords(0, 0), &coords(0, 1), &coords(0, 2));
63 for (int rr = 0; rr != coords.size1(); ++rr) {
64 t_center(
i) += t_coords(
i);
65 ++t_coords;
66 }
67 t_center(
i) /= coords.size1();
68 return t_center;
69 };
70 auto t_centre = get_centroid(coords);
71
72 auto get_stress = [](auto t_center) {
74 voight_stress(0) = 0.5*t_center(1);
75 voight_stress(1) = 0.5*t_center(1);
76 voight_stress(2) = 0.5*t_center(1);
77 voight_stress(3) = 0;
78 voight_stress(4) = 0;
79 voight_stress(5) = 0;
80 voight_stress(6) = 0;
81 voight_stress(7) = 0;
82 voight_stress(8) = 0;
83 return voight_stress;
84 };
85
86 auto get_density = [](auto t_center) {
87 double density = 0.;
88 density = 1 + t_center(0) * 2;
89 return density;
90 };
91
92 auto voight_stress = get_stress(t_centre);
93 double density = get_density(t_centre);
94
95 CHKERR moab.tag_set_data(
th, &ent, 1, &*voight_stress.data().begin());
96 CHKERR moab.tag_set_data(th_rho, &ent, 1, &density);
97 }
98
100 CHKERR moab.write_file(
"out_for_mwls.h5m",
"MOAB",
"", &meshset, 1);
101 }
103
105 return 0;
106}
#define CATCH_ERRORS
Catch errors.
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.