MOAB: Mesh Oriented datABase
(version 5.5.0)
mergemesh_test.cpp
Go to the documentation of this file.
1
#include "
moab/Core.hpp
"
2
#include "
moab/Range.hpp
"
3
#include "
moab/MergeMesh.hpp
"
4
#include <iostream>
5
#include "
TestUtil.hpp
"
6
7
#ifdef MOAB_HAVE_MPI
8
#include "
moab_mpi.h
"
9
#endif
10
11
#ifndef MOAB_HAVE_HDF5
12
#error This test requires HDF5 support
13
#endif
14
15
using namespace
moab
;
16
17
std::string
meshfile
= TestDir +
"unittest/16_unmerged_hex.h5m"
;
18
std::string
meshfile2
= TestDir +
"unittest/merge_with_tag.h5m"
;
19
std::string
meshfile3
= TestDir +
"unittest/triangles.h5m"
;
20
std::string
outfile
=
"mm_out.h5m"
;
21
22
void
mergesimple_test
();
23
void
merge_with_tag_test
();
24
void
merge_all_test
();
25
26
#ifdef MOAB_HAVE_MPI
27
int
main
(
int
argc,
char
** argv )
28
#else
29
int
main
()
30
#endif
31
{
32
#ifdef MOAB_HAVE_MPI
33
MPI_Init( &argc, &argv );
34
#endif
35
int
result = 0;
36
37
result +=
RUN_TEST
(
mergesimple_test
);
38
result +=
RUN_TEST
(
merge_with_tag_test
);
39
result +=
RUN_TEST
(
merge_all_test
);
40
41
#ifdef MOAB_HAVE_MPI
42
MPI_Finalize();
43
#endif
44
return
result;
45
}
46
47
void
mergesimple_test
()
48
{
49
ErrorCode
rval;
50
Core
mb
;
51
Interface
*
iface
= &
mb
;
52
// can be generalized to load user defined input/output file
53
54
rval =
iface
->
load_mesh
(
meshfile
.c_str() );
CHECK_ERR
( rval );
55
int
dim
= 3;
56
moab::Range
ents;
57
iface
->
get_entities_by_dimension
( 0,
dim
, ents );
58
59
MergeMesh
mm(
iface
);
60
double
merge_tol = 1e-3;
61
62
rval = mm.
merge_entities
( ents, merge_tol );
CHECK_ERR
( rval );
63
64
// Fixed for now
65
66
rval =
iface
->
write_file
(
outfile
.c_str() );
CHECK_ERR
( rval );
67
68
return
;
69
}
70
71
void
merge_with_tag_test
()
72
{
73
ErrorCode
rval;
74
Core
mb
;
75
Interface
*
iface
= &
mb
;
76
// can be generalized to load user defined input/output file
77
78
rval =
iface
->
load_mesh
(
meshfile2
.c_str() );
CHECK_ERR
( rval );
79
int
dim
= 0;
80
moab::Range
verts;
81
iface
->
get_entities_by_dimension
( 0,
dim
, verts );
82
Tag
tag_for_merge;
83
rval =
iface
->
tag_get_handle
(
"IDFTAG"
, tag_for_merge );
CHECK_ERR
( rval );
84
85
MergeMesh
mm(
iface
);
86
rval = mm.
merge_using_integer_tag
( verts, tag_for_merge );
CHECK_ERR
( rval );
87
rval =
iface
->
write_file
(
outfile
.c_str() );
CHECK_ERR
( rval );
88
89
verts.
clear
();
90
iface
->
get_entities_by_dimension
( 0,
dim
, verts );
91
CHECK_EQUAL
( 405, (
int
)verts.
size
() );
92
93
return
;
94
}
95
96
void
merge_all_test
()
97
{
98
ErrorCode
rval;
99
Core
mb
;
100
Interface
*
iface
= &
mb
;
101
102
rval =
iface
->
load_mesh
(
meshfile3
.c_str() );
CHECK_ERR
( rval );
103
104
MergeMesh
mm(
iface
);
105
double
merge_tol = 1e-3;
106
rval = mm.
merge_all
( 0, merge_tol );
// root set
107
CHECK_ERR
( rval );
108
rval =
iface
->
write_file
(
outfile
.c_str() );
CHECK_ERR
( rval );
109
110
return
;
111
}
test
mergemesh_test.cpp
Generated on Wed Oct 4 2023 14:20:29 for MOAB: Mesh Oriented datABase by
1.9.1