MOAB: Mesh Oriented datABase  (version 5.5.0)
spherical_area_test.cpp
Go to the documentation of this file.
1 /*
2  * spherical_area_test.cpp
3  *
4  * Created on: Feb 1, 2013
5  */
6 #include <iostream>
7 #include "moab/Core.hpp"
8 #include "moab/Interface.hpp"
10 #include "TestUtil.hpp"
11 
12 using namespace moab;
13 
14 int main( int /* argc*/, char** /* argv[]*/ )
15 {
16  // check command line arg
17  const char* filename_mesh = STRINGIFY( MESHDIR ) "/mbcslam/eulerHomme.vtk";
18 
19  // read input mesh in a set
20  Core moab;
21  Interface* mb = &moab; // global
22  EntityHandle sf;
23  ErrorCode rval = mb->create_meshset( MESHSET_SET, sf );
24  if( MB_SUCCESS != rval ) return 1;
25 
26  rval = mb->load_file( filename_mesh, &sf );
27  if( MB_SUCCESS != rval ) return 1;
28 
29  double R = 6.; // should be input
30  // compare total area with 4*M_PI * R^2
31 
32  const double area_sphere = R * R * M_PI * 4.;
33  std::cout << "total area of the sphere : " << area_sphere << "\n";
34 
35  {
36  moab::IntxAreaUtils areaAdaptor( moab::IntxAreaUtils::Girard ); // use_lHuiller = true
37  double area1 = areaAdaptor.area_on_sphere( mb, sf, R );
38  std::cout << "total area with Girard : " << area1
39  << " rel error:" << fabs( ( area1 - area_sphere ) / area_sphere ) << "\n";
40  }
41 
42  {
44  double area2 = areaAdaptor.area_on_sphere( mb, sf, R );
45  std::cout << "total area with l'Huiller : " << area2
46  << " rel error:" << fabs( ( area2 - area_sphere ) / area_sphere ) << "\n";
47  }
48 
49 #ifdef MOAB_HAVE_TEMPESTREMAP
50  {
52  double area3 = areaAdaptor.area_on_sphere( mb, sf, R );
53  std::cout << "total area with GaussQuadrature : " << area3
54  << " rel error:" << fabs( ( area3 - area_sphere ) / area_sphere ) << "\n";
55  }
56 #endif
57 
58  return 0;
59 }