2 #include <UnitTest++.h>
14 void init(
double resfac=1. )
18 emm_log = log(mesh.emm());
19 egamry_log = log(mesh.egamry());
34 TEST_FIXTURE(MeshFixture,TestMeshValues)
37 const double* anu = mesh.anuptr();
38 const double* anulog10 = mesh.anulog10ptr();
39 CHECK( mesh.lgMeshSetUp() );
40 CHECK(
fp_equal( mesh.anumin(0), mesh.emm() ) );
41 CHECK(
fp_equal( mesh.anumax(mesh.ncells()-1), mesh.egamry() ) );
42 for(
long i=0; i < mesh.ncells(); ++i )
44 CHECK(
fp_equal( mesh.anu(i), anu[i] ) );
45 CHECK( mesh.anumin(i) < mesh.anu(i) );
46 CHECK( mesh.anumax(i) > mesh.anu(i) );
47 CHECK(
fp_equal( mesh.anu(i), (mesh.anumin(i)+mesh.anumax(i))/2. ) );
48 CHECK(
fp_equal( mesh.widflx(i), mesh.anumax(i)-mesh.anumin(i) ) );
51 CHECK( mesh.anu(i-1) < mesh.anu(i) );
52 CHECK(
fp_equal( mesh.anumax(i-1), mesh.anumin(i) ) );
56 CHECK(
fp_equal( sqrt(mesh.anu(i)), mesh.anusqrt(i) ) );
57 CHECK(
fp_equal( log(mesh.anu(i)), mesh.anuln(i) ) );
58 CHECK(
fp_equal( log10(mesh.anu(i)), mesh.anulog10(i) ) );
59 CHECK(
fp_equal( log10(mesh.anu(i)), anulog10[i] ) );
63 TEST_FIXTURE(MeshFixture,TestMeshValues0p1)
66 const double* anu = mesh.anuptr();
67 const double* anulog10 = mesh.anulog10ptr();
68 CHECK( mesh.lgMeshSetUp() );
69 CHECK(
fp_equal( mesh.anumin(0), mesh.emm() ) );
70 CHECK(
fp_equal( mesh.anumax(mesh.ncells()-1), mesh.egamry() ) );
71 for(
long i=0; i < mesh.ncells(); ++i )
73 CHECK(
fp_equal( mesh.anu(i), anu[i] ) );
74 CHECK( mesh.anumin(i) < mesh.anu(i) );
75 CHECK( mesh.anumax(i) > mesh.anu(i) );
76 CHECK(
fp_equal( mesh.anu(i), (mesh.anumin(i)+mesh.anumax(i))/2. ) );
77 CHECK(
fp_equal( mesh.widflx(i), mesh.anumax(i)-mesh.anumin(i) ) );
80 CHECK( mesh.anu(i-1) < mesh.anu(i) );
81 CHECK(
fp_equal( mesh.anumax(i-1), mesh.anumin(i) ) );
85 CHECK(
fp_equal( sqrt(mesh.anu(i)), mesh.anusqrt(i) ) );
86 CHECK(
fp_equal( log(mesh.anu(i)), mesh.anuln(i) ) );
87 CHECK(
fp_equal( log10(mesh.anu(i)), mesh.anulog10(i) ) );
88 CHECK(
fp_equal( log10(mesh.anu(i)), anulog10[i] ) );
92 TEST_FIXTURE(MeshFixture,TestMeshValues10)
95 const double* anu = mesh.anuptr();
96 const double* anulog10 = mesh.anulog10ptr();
97 CHECK( mesh.lgMeshSetUp() );
98 CHECK(
fp_equal( mesh.anumin(0), mesh.emm() ) );
99 CHECK(
fp_equal( mesh.anumax(mesh.ncells()-1), mesh.egamry() ) );
100 for(
long i=0; i < mesh.ncells(); ++i )
102 CHECK(
fp_equal( mesh.anu(i), anu[i] ) );
103 CHECK( mesh.anumin(i) < mesh.anu(i) );
104 CHECK( mesh.anumax(i) > mesh.anu(i) );
105 CHECK(
fp_equal( mesh.anu(i), (mesh.anumin(i)+mesh.anumax(i))/2. ) );
106 CHECK(
fp_equal( mesh.widflx(i), mesh.anumax(i)-mesh.anumin(i) ) );
109 CHECK( mesh.anu(i-1) < mesh.anu(i) );
110 CHECK(
fp_equal( mesh.anumax(i-1), mesh.anumin(i) ) );
114 CHECK(
fp_equal( sqrt(mesh.anu(i)), mesh.anusqrt(i) ) );
115 CHECK(
fp_equal( log(mesh.anu(i)), mesh.anuln(i) ) );
116 CHECK(
fp_equal( log10(mesh.anu(i)), mesh.anulog10(i) ) );
117 CHECK(
fp_equal( log10(mesh.anu(i)), anulog10[i] ) );
121 TEST_FIXTURE(MeshFixture,TestMeshIpoint)
124 CHECK(
fp_equal( mesh.getResolutionScaleFactor(), 1. ) );
125 for(
int i=0; i < 50000; ++i )
127 double anu = randnu();
128 size_t ic = mesh.ipointC(anu);
129 size_t ifor = mesh.ipointF(anu);
130 CHECK( mesh.anumin(ic) <= anu );
131 CHECK( anu < mesh.anumax(ic) );
132 CHECK( ifor == ic + 1 );
133 if( mesh.anu(0) < anu && anu < mesh.anu(mesh.ncells()-1) )
135 ic = mesh.ithreshC(anu);
136 ifor = mesh.ithreshF(anu);
137 CHECK( mesh.anu(ic) >= anu );
138 CHECK( mesh.anu(ic-1) < anu );
139 CHECK( ifor == ic + 1 );
145 TEST_FIXTURE(MeshFixture,TestMeshIpoint0p1)
149 CHECK(
fp_equal( mesh.getResolutionScaleFactor(), 0.1 ) );
150 for(
int i=0; i < 50000; ++i )
152 double anu = randnu();
153 size_t ic = mesh.ipointC(anu);
154 CHECK( mesh.anumin(ic) <= anu );
155 CHECK( anu < mesh.anumax(ic) );
156 if( mesh.anu(0) < anu && anu < mesh.anu(mesh.ncells()-1) )
158 ic = mesh.ithreshC(anu);
159 CHECK( mesh.anu(ic) >= anu );
160 CHECK( mesh.anu(ic-1) < anu );
165 TEST_FIXTURE(MeshFixture,TestMeshIpoint0p01)
168 CHECK(
fp_equal( mesh.getResolutionScaleFactor(), 0.01 ) );
169 for(
int i=0; i < 50000; ++i )
171 double anu = randnu();
172 size_t ic = mesh.ipointC(anu);
173 CHECK( mesh.anumin(ic) <= anu );
174 CHECK( anu < mesh.anumax(ic) );
175 if( mesh.anu(0) < anu && anu < mesh.anu(mesh.ncells()-1) )
177 ic = mesh.ithreshC(anu);
178 CHECK( mesh.anu(ic) >= anu );
179 CHECK( mesh.anu(ic-1) < anu );
185 TEST_FIXTURE(MeshFixture,TestMeshIpoint10)
188 CHECK(
fp_equal( mesh.getResolutionScaleFactor(), 10. ) );
189 for(
int i=0; i < 10000; ++i )
191 double anu = randnu();
192 size_t ic = mesh.ipointC(anu);
193 CHECK( mesh.anumin(ic) <= anu );
194 CHECK( anu < mesh.anumax(ic) );
195 if( mesh.anu(0) < anu && anu < mesh.anu(mesh.ncells()-1) )
197 ic = mesh.ithreshC(anu);
198 CHECK( mesh.anu(ic) >= anu );
199 CHECK( mesh.anu(ic-1) < anu );
204 TEST_FIXTURE(MeshFixture,TestMeshIpoint100)
207 CHECK(
fp_equal( mesh.getResolutionScaleFactor(), 100. ) );
208 for(
int i=0; i < 10000; ++i )
210 double anu = randnu();
211 size_t ic = mesh.ipointC(anu);
212 CHECK( mesh.anumin(ic) <= anu );
213 CHECK( anu < mesh.anumax(ic) );
214 if( mesh.anu(0) < anu && anu < mesh.anu(mesh.ncells()-1) )
216 ic = mesh.ithreshC(anu);
217 CHECK( mesh.anu(ic) >= anu );
218 CHECK( mesh.anu(ic-1) < anu );
void setResolutionScaleFactor(double fac)
bool fp_equal(sys_float x, sys_float y, int n=3)
void init_genrand(unsigned long s)