MOAB: Mesh Oriented datABase  (version 5.4.1)
spherical_area_test.cpp
Go to the documentation of this file.
00001 /*
00002  * spherical_area_test.cpp
00003  *
00004  *  Created on: Feb 1, 2013
00005  */
00006 #include <iostream>
00007 #include "moab/Core.hpp"
00008 #include "moab/Interface.hpp"
00009 #include "moab/IntxMesh/IntxUtils.hpp"
00010 #include "TestUtil.hpp"
00011 
00012 using namespace moab;
00013 
00014 int main( int /* argc*/, char** /* argv[]*/ )
00015 {
00016     // check command line arg
00017     const char* filename_mesh = STRINGIFY( MESHDIR ) "/mbcslam/eulerHomme.vtk";
00018 
00019     // read input mesh in a set
00020     Core moab;
00021     Interface* mb = &moab;  // global
00022     EntityHandle sf;
00023     ErrorCode rval = mb->create_meshset( MESHSET_SET, sf );
00024     if( MB_SUCCESS != rval ) return 1;
00025 
00026     rval = mb->load_file( filename_mesh, &sf );
00027     if( MB_SUCCESS != rval ) return 1;
00028 
00029     double R = 6.;  // should be input
00030     // compare total area with 4*M_PI * R^2
00031 
00032     const double area_sphere = R * R * M_PI * 4.;
00033     std::cout << "total area of the sphere        :  " << area_sphere << "\n";
00034 
00035     {
00036         moab::IntxAreaUtils areaAdaptor( moab::IntxAreaUtils::Girard );  // use_lHuiller = true
00037         double area1 = areaAdaptor.area_on_sphere( mb, sf, R );
00038         std::cout << "total area with Girard          :  " << area1
00039                   << " rel error:" << fabs( ( area1 - area_sphere ) / area_sphere ) << "\n";
00040     }
00041 
00042     {
00043         moab::IntxAreaUtils areaAdaptor( moab::IntxAreaUtils::lHuiller );
00044         double area2 = areaAdaptor.area_on_sphere( mb, sf, R );
00045         std::cout << "total area with l'Huiller       : " << area2
00046                   << " rel error:" << fabs( ( area2 - area_sphere ) / area_sphere ) << "\n";
00047     }
00048 
00049 #ifdef MOAB_HAVE_TEMPESTREMAP
00050     {
00051         moab::IntxAreaUtils areaAdaptor( moab::IntxAreaUtils::GaussQuadrature );
00052         double area3 = areaAdaptor.area_on_sphere( mb, sf, R );
00053         std::cout << "total area with GaussQuadrature : " << area3
00054                   << " rel error:" << fabs( ( area3 - area_sphere ) / area_sphere ) << "\n";
00055     }
00056 #endif
00057 
00058     return 0;
00059 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines