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