v0.15.0
Loading...
Searching...
No Matches
extrude_prisms.cpp
Go to the documentation of this file.
1/** \file extrude_prisms.cpp
2 * \brief Extrude prisms from surface elements block
3 * \example mesh_cut.cpp
4 *
5 * \ingroup mesh_cut
6 */
7
8
9
10#include <MoFEM.hpp>
11
12using namespace MoFEM;
13
14static char help[] = "mesh cutting\n\n";
15
16int main(int argc, char *argv[]) {
17
18 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
19
20 try {
21
22 PetscBool flg_myfile = PETSC_TRUE;
23 char mesh_file_name[255];
24 char mesh_out_file[255] = "out.h5m";
25
26 PetscOptionsBegin(PETSC_COMM_WORLD, "", "Prism surface", "none");
27 CHKERR PetscOptionsString("-my_file", "mesh file name", "", "mesh.h5m",
29 CHKERR PetscOptionsString("-output_file", "output mesh file name", "",
30 "out.h5m", mesh_out_file, 255, PETSC_NULLPTR);
31 PetscOptionsEnd();
32
33 if (flg_myfile != PETSC_TRUE)
34 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
35 "error -my_file (mesh file needed)");
36
37 moab::Core mb_instance;
38 moab::Interface &moab = mb_instance;
39 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
40 if (pcomm == NULL)
41 pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
42
43 const char *option;
44 option = "";
45 CHKERR moab.load_file(mesh_file_name, 0, option);
46
47 MoFEM::Core core(moab);
48 MoFEM::CoreInterface &m_field =
50
51 PrismsFromSurfaceInterface *prisms_from_surface_interface;
52 CHKERR m_field.getInterface(prisms_from_surface_interface);
53
54 const std::string extrude_block_name = "EXTRUDE_PRISMS";
56 if (it->getName().compare(0, extrude_block_name.length(),
57 extrude_block_name) == 0) {
58 std::vector<double> thickness;
59 CHKERR it->getAttributes(thickness);
60 if (thickness.size() != 2)
61 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
62 "Data inconsistency");
63 Range tris;
64 CHKERR m_field.get_moab().get_entities_by_type(it->meshset, MBTRI, tris,
65 true);
66 Range block_prisms;
67 CHKERR prisms_from_surface_interface->createPrisms(
68 tris, PrismsFromSurfaceInterface::NO_SWAP, block_prisms);
69 CHKERR prisms_from_surface_interface->setNormalThickness(
70 block_prisms, thickness[0], thickness[1]);
71 CHKERR prisms_from_surface_interface->updateMeshestByEdgeBlock(
72 block_prisms);
73 CHKERR prisms_from_surface_interface->updateMeshestByTriBlock(
74 block_prisms);
75
76 std::cout << "Extrude block " << it->getMeshsetId() << " set prisms "
77 << block_prisms.size() << endl;
78 }
79 }
80
81 CHKERR moab.write_file(mesh_out_file);
82 }
84
86
87 return 0;
88}
int main()
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
@ BLOCKSET
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
@ MOFEM_INVALID_DATA
Definition definitions.h:36
#define CHKERR
Inline error check.
static char help[]
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
PetscBool flg_myfile
char mesh_file_name[255]
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
virtual moab::Interface & get_moab()=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:118
MoFEMErrorCode setNormalThickness(const Range &prisms, double thickness3, double thickness4)
MoFEMErrorCode createPrisms(const Range &ents, const SwapType swap_type, Range &prisms, int verb=-1)
Make prisms from triangles.
MoFEMErrorCode updateMeshestByEdgeBlock(const Range &prisms)
Add quads to bockset.
MoFEMErrorCode updateMeshestByTriBlock(const Range &prisms)
Add prism to bockset.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.