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
"
9
#include "
moab/IntxMesh/IntxUtils.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
{
43
moab::IntxAreaUtils
areaAdaptor(
moab::IntxAreaUtils::lHuiller
);
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
{
51
moab::IntxAreaUtils
areaAdaptor(
moab::IntxAreaUtils::GaussQuadrature
);
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
}
test
spherical_area_test.cpp
Generated on Wed Oct 4 2023 14:20:32 for MOAB: Mesh Oriented datABase by
1.9.1