MOAB: Mesh Oriented datABase  (version 5.5.0)
gnom_project_test.cpp
Go to the documentation of this file.
1 /*
2  * gnom_project_test.cpp
3  * will test new global gnomonic projection method, to be used by zoltan for partitioning
4  *
5  */
6 #include <iostream>
7 #include <sstream>
8 
9 #include "moab/Core.hpp"
10 #include "moab/Interface.hpp"
11 
13 #include "moab/ProgOptions.hpp"
14 #include "TestUtil.hpp"
15 
16 using namespace moab;
17 using namespace std;
18 
19 int main( int argc, char* argv[] )
20 {
21  string filein = STRINGIFY( MESHDIR ) "/mbcslam/eulerHomme.vtk";
22  string fileout = "project.vtk";
23 
24  ProgOptions opts;
25  opts.addOpt< std::string >( "model,m", "input file ", &filein );
26 
27  opts.addOpt< std::string >( "output,o", "output filename", &fileout );
28 
29  opts.parseCommandLine( argc, argv );
30 
31  Core moab;
32  Interface* mb = &moab;
33  EntityHandle sf;
34  ErrorCode rval = mb->create_meshset( MESHSET_SET, sf );MB_CHK_ERR( rval );
35 
36  rval = mb->load_file( filein.c_str(), &sf );MB_CHK_ERR( rval );
37 
38  double R = 1.; // should be input
39  EntityHandle outSet;
40  rval = mb->create_meshset( MESHSET_SET, outSet );MB_CHK_ERR( rval );
41 
42  rval = IntxUtils::global_gnomonic_projection( mb, sf, R, false, outSet );MB_CHK_ERR( rval );
43  rval = mb->write_file( fileout.c_str(), 0, 0, &outSet, 1 );
44  ;MB_CHK_ERR( rval );
45  // skip the test for 32 bit builds, CHECK_ARRAYS_EQUAL macro is not working correctly
46 #ifndef MOAB_FORCE_32_BIT_HANDLES
47  // check first cell position
48  Range cells;
49  rval = mb->get_entities_by_dimension( outSet, 2, cells );MB_CHK_ERR( rval );
50  EntityHandle firstCell = cells[0];
51  double coords[3];
52  rval = mb->get_coords( &firstCell, 1, coords );MB_CHK_ERR( rval );
53  // check position
54  double values[3] = { -0.78867513420303437, 0.78867513420303437, 0 };
55  CHECK_ARRAYS_EQUAL( coords, 3, values, 3 );
56 #endif
57 
58  return 0;
59 }