MOAB: Mesh Oriented datABase  (version 5.5.0)
intx_rll_cs_sphere_test.cpp
Go to the documentation of this file.
1 /*
2  * IntxRllCssphere_test.cpp
3  */
4 
7 #include "TestUtil.hpp"
8 
9 using namespace moab;
10 
11 int main( int argc, char* argv[] )
12 {
13  // check command line arg// Euler grid is red, arrival, Lagrangian is blue, departure
14  // will will keep the
15  const char* filename_mesh1 = STRINGIFY( MESHDIR ) "/mbcslam/outRLLMesh.g";
16  const char* filename_mesh2 = STRINGIFY( MESHDIR ) "/mbcslam/outCSMesh.g";
17  double R = 1.; // input
18  double epsrel = 1.e-8;
19  const char* newFile = "intx.vtk";
20  if( argc == 6 )
21  {
22  filename_mesh1 = argv[1];
23  filename_mesh2 = argv[2];
24  R = atof( argv[3] );
25  epsrel = atof( argv[4] );
26  newFile = argv[5];
27  }
28  else
29  {
30  printf( "Usage: %s <mesh_filename1> <mesh_filename2> <radius> <epsrel> <newFile>\n", argv[0] );
31  if( argc != 1 ) return 1;
32  printf( "No files specified. Defaulting to: %s %s %f %g %s\n", filename_mesh1, filename_mesh2, R, epsrel,
33  newFile );
34  }
35 
36  // read meshes in 2 file sets
37  Core moab;
38  Interface* mb = &moab; // global
39  EntityHandle sf1, sf2;
40  ErrorCode rval = mb->create_meshset( MESHSET_SET, sf1 );
41  if( MB_SUCCESS != rval ) return 1;
42  rval = mb->create_meshset( MESHSET_SET, sf2 );
43  if( MB_SUCCESS != rval ) return 1;
44  rval = mb->load_file( filename_mesh1, &sf1 );
45  if( MB_SUCCESS != rval ) return 1;
46  rval = mb->load_file( filename_mesh2, &sf2 );
47  if( MB_SUCCESS != rval ) return 1;
48 
49  EntityHandle outputSet;
50  rval = mb->create_meshset( MESHSET_SET, outputSet );
51  if( MB_SUCCESS != rval ) return 1;
52 
53  // IntxUtils
54  rval = IntxUtils::fix_degenerate_quads( mb, sf1 );
55  if( MB_SUCCESS != rval ) return 1;
56 
57  IntxAreaUtils areaAdaptor;
58  rval = areaAdaptor.positive_orientation( mb, sf1, R );
59  if( MB_SUCCESS != rval ) return 1;
60 
61  rval = areaAdaptor.positive_orientation( mb, sf2, R );
62  if( MB_SUCCESS != rval ) return 1;
63 
64  /*// set the edge tags on all elements sf1
65  rval = set_edge_type_flag(mb, sf1); // form all edges, and set on them type 1 if constant
66  latitude
67  // add them to the set after this, just so we have them
68  if (MB_SUCCESS != rval)
69  return 1;*/
70 
71  IntxRllCssphere worker( mb );
72 
73  worker.set_error_tolerance( R * epsrel );
74  // worker.SetEntityType(moab::MBQUAD);
75  worker.set_radius( R );
76  // worker.enable_debug();
77  rval = worker.FindMaxEdges( sf1, sf2 );
78  if( MB_SUCCESS != rval ) return 1;
79 
80  rval = worker.intersect_meshes( sf1, sf2, outputSet );
81  // compute total area with 2 methods
82 
83  if( MB_SUCCESS != rval ) std::cout << " failed to intersect meshes\n";
84  rval = mb->write_mesh( newFile, &outputSet, 1 );
85  if( MB_SUCCESS != rval ) return 1;
86  return 0;
87 }