13static char help[] =
"testing mesh cut test\n\n";
23 <<
"bit_level nb ents " <<
bit <<
" " << ents.size();
24 if (expected_size != -1 && expected_size !=
static_cast<int>(ents.size())) {
26 "Wrong bit ref size %d!=%d", expected_size, ents.size());
32int main(
int argc,
char *argv[]) {
40 PetscBool flg = PETSC_TRUE;
45 if (flg != PETSC_TRUE)
47 "*** ERROR -my_file (MESH FILE NEEDED)");
53 int restricted_side_set = 205;
55 &restricted_side_set, PETSC_NULL);
57 double shift[] = {0, 0, 0};
62 "three values expected");
64 int fixed_edges_blockset = 100;
66 &fixed_edges_blockset, PETSC_NULL);
68 int corner_nodes_blockset = 1;
70 &corner_nodes_blockset, PETSC_NULL);
72 double tol[] = {0, 0, 0};
75 if (flg && nmax_tol != 3)
78 PetscBool test = PETSC_FALSE;
82 moab::Core mb_instance;
83 moab::Interface &moab = mb_instance;
84 ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
86 boost::make_shared<WrapMPIComm>(PETSC_COMM_WORLD,
false);
89 new ParallelComm(&moab, moab_comm_wrap->get_comm());
116 bit_level0,
BitRefLevel().set(), MBTET,
"out_tets_init_level0.vtk",
119 bit_last,
BitRefLevel().set(), MBTET,
"out_tets_bit_last.vtk",
"VTK",
122 int no_of_ents_not_in_database = -1;
123 Range ents_not_in_database;
126 ents_not_in_database);
127 no_of_ents_not_in_database = ents_not_in_database.size();
141 Range fixed_edges, corner_nodes;
144 fixed_edges_blockset,
SIDESET, 1, fixed_edges,
true);
148 fixed_edges_blockset,
BLOCKSET, 1, fixed_edges,
true);
152 corner_nodes_blockset,
BLOCKSET, 0, corner_nodes,
true);
156 Range restriced_surface;
159 restricted_side_set,
SIDESET, 2, restriced_surface,
true);
179 CHKERR moab.get_entities_by_dimension(0, 3, tets,
false);
184 const int nb_ref_cut = 1;
185 const int nb_ref_trim = 1;
188 auto shift_after_ref = [&]() {
192 for (
int ll = 1; ll != nb_ref_cut + nb_ref_trim + 1; ++ll)
195 nb_ref_cut + nb_ref_trim, mask,
VERBOSE);
201 ->writeEntitiesAllBitLevelsByType(
BitRefLevel().set(), MBTET,
202 "all_bits.vtk",
"VTK",
"");
205 double def_position[] = {0, 0, 0};
207 CHKERR moab.tag_get_handle(
"POSITION", 3, MB_TYPE_DOUBLE,
th,
208 MB_TAG_CREAT | MB_TAG_SPARSE, def_position);
215 fixed_edges, corner_nodes,
true,
false);
222 ->updateAllMeshsetsByEntitiesChildren(
BitRefLevel().set(first_bit + 1));
226 "out_split_tets.vtk",
"VTK",
"");
230 "out_split_prism.vtk",
"VTK",
"");
233 for (
int ll = 0; ll != first_bit + 2; ++ll)
240 for (
int ll = 0; ll != first_bit; ++ll)
243 first_bit, shift_mask,
VERBOSE);
249 "out_tets_shift_level0.vtk",
"VTK",
"");
252 "out_tets_shift_level1.vtk",
"VTK",
"");
255 "out_tets_shift_level1_prism.vtk",
"VTK",
"");
259 Range adj_surface_edges;
261 adj_surface_edges, moab::Interface::UNION);
263 CHKERR moab.delete_entities(adj_surface_edges);
264 CHKERR moab.delete_entities(surface_verts);
271 CHKERR moab.create_meshset(MESHSET_SET, meshset);
273 CHKERR moab.get_entities_by_dimension(0, 3, tets,
true);
274 CHKERR moab.add_entities(meshset, tets);
275 CHKERR moab.write_file(
"out.vtk",
"VTK",
"", &meshset, 1);
276 CHKERR moab.delete_entities(&meshset, 1);
279 bit_last,
BitRefLevel().set(), MBTET,
"out_tets_bit_last.vtk",
"VTK",
282 "left_entities.vtk",
"VTK",
"");
288 if (no_of_ents_not_in_database !=
static_cast<int>(ents.size())) {
289 MOFEM_LOG(
"WORLD", Sev::inform) << subtract(ents, ents_not_in_database);
291 CHKERR moab.create_meshset(MESHSET_SET, meshset);
293 CHKERR moab.get_entities_by_dimension(0, 3, tets,
true);
294 CHKERR moab.add_entities(meshset, subtract(ents, ents_not_in_database));
295 CHKERR moab.write_file(
"not_cleanded.vtk",
"VTK",
"", &meshset, 1);
296 CHKERR moab.delete_entities(&meshset, 1);
298 "Inconsistent number of ents %d!=%d",
299 no_of_ents_not_in_database, ents.size());
#define CATCH_ERRORS
Catch errors.
#define BITREFLEVEL_SIZE
max number of refinements
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
MoFEMErrorCode getEntitiesByRefLevel(const BitRefLevel bit, const BitRefLevel mask, const EntityHandle meshset, const int verb=QUIET) const
add all ents from ref level given by bit to meshset
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
bool checkMeshset(const int ms_id, const CubitBCType cubit_bc_type) const
check for CUBIT Id and CUBIT type
MoFEMErrorCode getEntitiesByDimension(const int ms_id, const unsigned int cubit_bc_type, const int dimension, Range &entities, const bool recursive=true) const
get entities from CUBIT/meshset of a particular entity dimension
#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.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
virtual MoFEMErrorCode delete_ents_by_bit_ref(const BitRefLevel bit, const BitRefLevel mask, const bool remove_parent=false, int verb=DEFAULT_VERBOSITY, MoFEMTypes mf=MF_ZERO)=0
delete entities form mofem and moab 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.
MoFEMErrorCode copySurface(const Range surface, Tag th=NULL, double *shift=NULL, double *origin=NULL, double *transform=NULL, const std::string save_mesh="")
copy surface entities
MoFEMErrorCode setCoords(Tag th, const BitRefLevel bit=BitRefLevel(), const BitRefLevel mask=BitRefLevel().set())
set coords from tag
const Range & getMergedSurfaces() const
MoFEMErrorCode setSurface(const Range surface)
set surface entities
MoFEMErrorCode buildTree()
build tree
MoFEMErrorCode splitSides(const BitRefLevel split_bit, const BitRefLevel bit, const Range &ents, Tag th=NULL)
split sides
const Range & getSurface() const
MoFEMErrorCode setConstrainSurface(const Range surf)
Set the constrain surface object.
MoFEMErrorCode setVolume(const Range volume)
set volume entities
MoFEMErrorCode setTagData(Tag th, const BitRefLevel bit=BitRefLevel())
set coords to tag
MoFEMErrorCode cutTrimAndMerge(int &first_bit, const int fraction_level, Tag th, const double tol_geometry, const double tol_cut_close, const double tol_trim_close, Range &fixed_edges, Range &corner_nodes, const bool update_meshsets=false, const bool debug=false)
Cut, trim and merge.
MoFEMErrorCode makeFront(const bool debug=false)
Create front from the surface.
MoFEMErrorCode refineMesh(const int init_bit_level, const int surf_levels, const int front_levels, Range *fixed_edges=nullptr, int verb=QUIET, const bool debug=false)
Refine and set level sets.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
TestBitLevel(BitRefManager *mng_ptr)
MoFEMErrorCode operator()(const BitRefLevel &bit, const int expected_size)