23 {
25
26 try {
27
28 moab::Core mb_instance;
29 moab::Interface &moab = mb_instance;
30
31
32 char mesh_file_name[255];
33 char data_file_name1[255];
34 char data_file_name2[255];
35 PetscBool flg_file = PETSC_FALSE;
37 PetscBool flg_n_part = PETSC_FALSE;
38 PetscInt n_partas = 1;
39
40 PetscOptionsBegin(PETSC_COMM_WORLD, "", "none", "none");
41 CHKERR PetscOptionsString(
"-my_file",
"mesh file name",
"",
"mesh.h5m",
42 mesh_file_name, 255, &flg_file);
43
44 CHKERR PetscOptionsString(
"-my_data_x",
"data file name",
"",
"data_x.h5m",
45 data_file_name1, 255, PETSC_NULLPTR);
46
47 CHKERR PetscOptionsString(
"-my_data_y",
"data file name",
"",
"data_y.h5m",
48 data_file_name2, 255, PETSC_NULLPTR);
49
50 CHKERR PetscOptionsInt(
"-my_order",
"default approximation order",
"", 1,
51 &
order, PETSC_NULLPTR);
52
53 CHKERR PetscOptionsInt(
"-my_nparts",
"number of parts",
"", 1, &n_partas,
54 &flg_n_part);
55
56 PetscOptionsEnd();
57
58 if (flg_file != PETSC_TRUE) {
59 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
60 }
61
62 if (flg_n_part != PETSC_TRUE) {
63 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR partitioning number not given");
64 }
65
66 const char *option;
67 option = "";
68 CHKERR moab.load_file(mesh_file_name, 0, option);
69 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
70 if (pcomm == nullptr)
71 pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
72
75
77
78
79
80
82 bit_level0.set(0);
84 root_set, 3, bit_level0);
85
88
90
92 CHKERR meshsets_manager_ptr->getEntitiesByDimension(101,
SIDESET, 2,
96
100
104
106
109 "DISP_X");
111 "DISP_X");
113 "DISP_X");
115 "DISP_Y");
116
117
119 "DISP_MAP_ELEMENT");
120
121
123
125
126
127 DM dm_disp;
128 DMType dm_name = "DM_DISP";
129
131 CHKERR DMCreate(PETSC_COMM_WORLD, &dm_disp);
132 CHKERR DMSetType(dm_disp, dm_name);
133
135
136
137 CHKERR DMSetFromOptions(dm_disp);
138
140
142
144
145
146
147
148 string file1(data_file_name1);
150 CHKERR data_from_files.fromOptions();
151 CHKERR data_from_files.loadFileData();
152
153 string file2(data_file_name2);
155 CHKERR data_from_files2.fromOptions();
156 CHKERR data_from_files2.loadFileData();
157
158 auto &list_of_operators = fe_face.getOpPtrVector();
159
162 CHKERR DMCreateMatrix(dm_disp, &A);
164 &Fx);
166 &Dx);
168 CHKERR VecDuplicate(Fx, &Fy);
169 CHKERR VecDuplicate(Dx, &Dy);
170
172 CHKERR VecZeroEntries(Fx);
173 CHKERR VecZeroEntries(Fy);
174
176 common_data.globA =
A;
177
178 common_data.globF = Fx;
179
180 auto det_ptr = boost::make_shared<VectorDouble>();
181 auto jac_ptr = boost::make_shared<MatrixDouble>();
182 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
184 list_of_operators.push_back(
187 list_of_operators.push_back(
188 new OpCalculateLhs(
"DISP_X",
"DISP_X", common_data, data_from_files));
189 list_of_operators.push_back(
191 list_of_operators.push_back(
new OpAssembleRhs(
"DISP_X", common_data));
192
194
195
196 CHKERR MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY);
197 CHKERR MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY);
198 CHKERR VecGhostUpdateBegin(Fx, ADD_VALUES, SCATTER_REVERSE);
199 CHKERR VecGhostUpdateEnd(Fx, ADD_VALUES, SCATTER_REVERSE);
200 CHKERR VecAssemblyBegin(Fx);
201 CHKERR VecAssemblyEnd(Fx);
202
203
204 common_data.globF = Fy;
205 list_of_operators.clear();
207 list_of_operators.push_back(
210 list_of_operators.push_back(
212 list_of_operators.push_back(
new OpAssembleRhs(
"DISP_X", common_data));
213
214
216
217 CHKERR VecGhostUpdateBegin(Fy, ADD_VALUES, SCATTER_REVERSE);
218 CHKERR VecGhostUpdateEnd(Fy, ADD_VALUES, SCATTER_REVERSE);
219 CHKERR VecAssemblyBegin(Fy);
220 CHKERR VecAssemblyEnd(Fy);
221
222
223
224
225
226
227
228 {
229 KSP ksp;
230 CHKERR KSPCreate(PETSC_COMM_WORLD, &ksp);
231 CHKERR KSPSetOperators(ksp, A, A);
232 CHKERR KSPSetFromOptions(ksp);
233 CHKERR KSPSolve(ksp, Fx, Dx);
234 CHKERR KSPSolve(ksp, Fy, Dy);
235 }
236
237 CHKERR VecGhostUpdateBegin(Dx, INSERT_VALUES, SCATTER_FORWARD);
238 CHKERR VecGhostUpdateEnd(Dx, INSERT_VALUES, SCATTER_FORWARD);
240 "DM_DISP",
COL, Dx, INSERT_VALUES, SCATTER_REVERSE);
241 CHKERR VecGhostUpdateBegin(Dy, INSERT_VALUES, SCATTER_FORWARD);
242 CHKERR VecGhostUpdateEnd(Dy, INSERT_VALUES, SCATTER_FORWARD);
244 "DM_DISP",
"DISP_X",
"DISP_Y",
COL, Dy, INSERT_VALUES, SCATTER_REVERSE);
245
246
247 double sum_dx = 0;
248 int nb_dx = 0;
250 MBVERTEX, dof)) {
251 sum_dx += (*dof)->getFieldData();
252 nb_dx++;
253 }
254 sum_dx /= nb_dx;
256 MBVERTEX, dof)) {
257 (*dof)->getFieldData() -= sum_dx;
258 }
259 double sum_dy = 0;
260 int nb_dy = 0;
262 MBVERTEX, dof)) {
263 sum_dy += (*dof)->getFieldData();
264 nb_dy++;
265 }
266 sum_dy /= nb_dy;
268 MBVERTEX, dof)) {
269 (*dof)->getFieldData() -= sum_dy;
270 }
271
275
278
279 auto disp_x_ptr = boost::make_shared<VectorDouble>();
280 auto disp_y_ptr = boost::make_shared<VectorDouble>();
281 post_proc.getOpPtrVector().push_back(
283 post_proc.getOpPtrVector().push_back(
285 post_proc.getOpPtrVector().push_back(
new OpPPMap(
286 post_proc.getPostProcMesh(), post_proc.getMapGaussPts(),
288 {"DISP_Y", disp_y_ptr}},
291
293 CHKERR post_proc.writeFile(
"out_disp.h5m");
294
300 CHKERR DMDestroy(&dm_disp);
301
302
304
305 {
306
308 Range ents_1st_layer;
310 ents_1st_layer, true);
311 int num_nodes;
313 CHKERR moab.get_connectivity(ents_1st_layer[0], conn, num_nodes);
314 Skinner skin(&moab);
316 CHKERR skin.find_skin(0, ents_1st_layer,
false, skin_edges);
318 CHKERR moab.get_adjacencies(&*ents_1st_layer.begin(), 1, 1,
false, edges);
321 CHKERR moab.add_entities(meshset, conn, 1);
322 CHKERR moab.add_entities(meshset, skin_edges);
323 }
324
325 {
327 CHKERR moab.get_entities_by_type(0, MBTET, tets,
false);
329 n_partas);
330 }
331
332 CHKERR moab.write_file(
"analysis_mesh.h5m");
333 }
335
337
338 return 0;
339}
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHKERR
Inline error check.
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
#define _IT_GET_DOFS_FIELD_BY_NAME_AND_TYPE_FOR_LOOP_(MFIELD, NAME, TYPE, IT)
loop over all dofs from a moFEM field and particular field
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_field)=0
set finite element field data
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
const FTensor::Tensor2< T, Dim, Dim > Vec
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
OpCalculateHOJacForFaceImpl< 2 > OpCalculateHOJacForFace
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
Add operators pushing bases from local to physical configuration.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MoFEMErrorCode add_field(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
virtual MoFEMErrorCode delete_finite_element(const std::string name, int verb=DEFAULT_VERBOSITY)=0
Delete finite element from MoFEM database.
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.
Deprecated interface functions.
Interface for managing meshsets containing materials and boundary conditions.
Specialization for double precision scalar field values calculation.
Operator for inverting matrices at integration points.
Post post-proc data at points from hash maps.
std::map< std::string, ScalarDataPtr > DataMapVec
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.