5#define BOOST_TEST_DYN_LINK
7#include <boost/test/unit_test.hpp>
14#include "Draw/DrawSphere.hpp"
16#include "Gaussian.hpp"
18BOOST_AUTO_TEST_SUITE(EnoWenoTestSuite)
19 const size_t f_gaussian = 0;
20 const size_t df_gaussian = 1;
21 const size_t ENO_plus = 2;
22 const size_t ENO_minus = 3;
23 const size_t Error_plus = 4;
24 const size_t Error_minus = 5;
26 double l2_norms_ENO [] = {0.084908, 0.014937, 0.002310};
27 double linf_norms_ENO [] = {0.228915, 0.047215, 0.008046};
29 double l2_norms_WENO [] = {0.032770, 0.000935, 0.000052};
30 double linf_norms_WENO [] = {0.168860, 0.003369, 0.000232};
32 BOOST_AUTO_TEST_CASE(Eno_1D_1stDerivative_test)
35 for (
size_t N = 32; N <= 128; N *= 2)
37 const size_t grid_dim = 1;
38 const size_t sz[grid_dim] = {N};
39 const double box_lower = -1.0;
40 const double box_upper = 1.0;
45 grid_in_type g_dist(sz, box, ghost);
47 g_dist.setPropNames({
"f_gaussian",
"df_gaussian",
"ENO_plus",
"ENO_minus",
"Error_plus",
"Error_minus"});
49 double mu = 0.5 * (box_upper - abs(box_lower));
50 double sigma = 0.3 * (box_upper - box_lower);
52 auto gdom = g_dist.getDomainGhostIterator();
55 auto key = gdom.get();
58 g_dist.getProp<f_gaussian>(key) = gaussian(p, mu, sigma);
62 auto dom = g_dist.getDomainIterator();
68 for (
int d = 0; d < grid_dim; d++)
71 g_dist.getProp<df_gaussian>(key)[d] = hermite_polynomial(p.
get(d), sigma, 1) * g_dist.getProp<f_gaussian>(key);
73 g_dist.getProp<ENO_plus>(key)[d] = ENO_3_Plus<f_gaussian>(g_dist, key, d);
75 g_dist.getProp<ENO_minus>(key)[d] = ENO_3_Minus<f_gaussian>(g_dist, key, d);
81 get_relative_error<df_gaussian, ENO_plus, Error_plus>(g_dist);
82 get_relative_error<df_gaussian, ENO_minus, Error_minus>(g_dist);
87 BOOST_CHECK_MESSAGE(lNorms.l2 < l2_norms_ENO[count] + 0.000001,
"Checking L2-norm ENO");
88 BOOST_CHECK_MESSAGE(lNorms.linf < linf_norms_ENO[count] + 0.000001,
"Checking Linf-norm "
96 BOOST_CHECK_MESSAGE(lNorms.l2 < l2_norms_ENO[count] + 0.000001,
"Checking L2-norm ENO");
97 BOOST_CHECK_MESSAGE(lNorms.linf < linf_norms_ENO[count] + 0.000001,
"Checking Linf-norm "
104 const size_t WENO_plus = 2;
105 const size_t WENO_minus = 3;
106 BOOST_AUTO_TEST_CASE(Weno_1D_1stDerivative_test)
109 for (
size_t N = 32; N <= 128; N *= 2)
111 const size_t grid_dim = 1;
112 const size_t sz[grid_dim] = {N};
113 const double box_lower = -1.0;
114 const double box_upper = 1.0;
119 grid_in_type g_dist(sz, box, ghost);
121 g_dist.setPropNames({
"f_gaussian",
"df_gaussian",
"WENO_plus",
"WENO_minus",
"Error_plus",
"Error_minus"});
123 double mu = 0.5 * (box_upper - abs(box_lower));
124 double sigma = 0.3 * (box_upper - box_lower);
126 auto gdom = g_dist.getDomainGhostIterator();
127 while (gdom.isNext())
129 auto key = gdom.get();
132 g_dist.getProp<f_gaussian>(key) = gaussian(p, mu, sigma);
136 auto dom = g_dist.getDomainIterator();
139 auto key = dom.get();
141 for (
int d = 0; d < grid_dim; d++)
144 g_dist.getProp<df_gaussian>(key)[d] = hermite_polynomial(p.
get(d), sigma, 1) * g_dist.getProp<f_gaussian>(key);
146 g_dist.getProp<WENO_plus>(key)[d] = WENO_5_Plus<f_gaussian>(g_dist, key, d);
148 g_dist.getProp<WENO_minus>(key)[d] = WENO_5_Minus<f_gaussian>(g_dist, key, d);
154 get_relative_error<df_gaussian, WENO_plus, Error_plus>(g_dist);
155 get_relative_error<df_gaussian, WENO_minus, Error_minus>(g_dist);
160 BOOST_CHECK_MESSAGE(lNorms.l2 < l2_norms_WENO[count] + 0.000001,
"Checking L2-norm WENO");
161 BOOST_CHECK_MESSAGE(lNorms.linf < linf_norms_WENO[count] + 0.000001,
"Checking Linf-norm "
169 BOOST_CHECK_MESSAGE(lNorms.l2 < l2_norms_WENO[count] + 0.000001,
"Checking L2-norm WENO");
170 BOOST_CHECK_MESSAGE(lNorms.linf < linf_norms_WENO[count] + 0.000001,
"Checking Linf-norm "
179 BOOST_AUTO_TEST_CASE(Eno_3D_test)
182 for(
size_t N=32; N<=128; N*=2)
184 const size_t grid_dim = 3;
185 const size_t sz[grid_dim] = {N, N, N};
186 const double box_lower = -1.0;
187 const double box_upper = 1.0;
192 grid_in_type g_dist(sz, box, ghost);
194 g_dist.setPropNames({
"f_gaussian",
"df_gaussian",
"ENO_plus",
"ENO_minus",
"Error_plus",
"Error_minus"});
196 double mu = 0.5 * (box_upper - abs(box_lower));
197 double sigma = 0.3 * (box_upper - box_lower);
199 auto gdom = g_dist.getDomainGhostIterator();
200 while (gdom.isNext())
202 auto key = gdom.get();
205 g_dist.getProp<f_gaussian>(key) = gaussian(p, mu, sigma);
209 auto dom = g_dist.getDomainIterator();
212 auto key = dom.get();
214 for (
int d = 0; d < grid_dim; d++)
216 g_dist.getProp<df_gaussian>(key)[d] = hermite_polynomial(p.
get(d), sigma, 1) * g_dist.getProp<f_gaussian>(key);
217 g_dist.getProp<ENO_plus>(key)[d] = ENO_3_Plus<f_gaussian>(g_dist, key, d);
218 g_dist.getProp<ENO_minus>(key)[d] = ENO_3_Minus<f_gaussian>(g_dist, key, d);
225 get_relative_error<df_gaussian, ENO_plus, Error_plus>(g_dist);
226 get_relative_error<df_gaussian, ENO_minus, Error_minus>(g_dist);
231 BOOST_CHECK_MESSAGE(lNorms.l2 < l2_norms_ENO[count] + 0.000001,
"Checking L2-norm ENO");
232 BOOST_CHECK_MESSAGE(lNorms.linf < linf_norms_ENO[count] + 0.000001,
"Checking Linf-norm "
240 BOOST_CHECK_MESSAGE(lNorms.l2 < l2_norms_ENO[count] + 0.000001,
"Checking L2-norm ENO");
241 BOOST_CHECK_MESSAGE(lNorms.linf < linf_norms_ENO[count] + 0.000001,
"Checking Linf-norm "
248 BOOST_AUTO_TEST_CASE(Weno_3D_test)
251 for(
size_t N=32; N<=128; N*=2)
253 const size_t grid_dim = 3;
254 const size_t sz[grid_dim] = {N, N, N};
255 const double box_lower = -1.0;
256 const double box_upper = 1.0;
261 grid_in_type g_dist(sz, box, ghost);
263 g_dist.setPropNames({
"f_gaussian",
"df_gaussian",
"WENO_plus",
"WENO_minus",
"Error_plus",
"Error_minus"});
265 double mu = 0.5 * (box_upper - abs(box_lower));
266 double sigma = 0.3 * (box_upper - box_lower);
268 auto gdom = g_dist.getDomainGhostIterator();
269 while (gdom.isNext())
271 auto key = gdom.get();
274 g_dist.getProp<f_gaussian>(key) = gaussian(p, mu, sigma);
278 auto dom = g_dist.getDomainIterator();
281 auto key = dom.get();
283 for (
int d = 0; d < grid_dim; d++)
285 g_dist.getProp<df_gaussian>(key)[d] = hermite_polynomial(p.
get(d), sigma, 1) * g_dist.getProp<f_gaussian>(key);
286 g_dist.getProp<WENO_plus>(key)[d] = WENO_5_Plus<f_gaussian>(g_dist, key, d);
287 g_dist.getProp<WENO_minus>(key)[d] = WENO_5_Minus<f_gaussian>(g_dist, key, d);
294 get_relative_error<df_gaussian, WENO_plus, Error_plus>(g_dist);
295 get_relative_error<df_gaussian, WENO_minus, Error_minus>(g_dist);
300 BOOST_CHECK_MESSAGE(lNorms.l2 < l2_norms_WENO[count] + 0.000001,
"Checking L2-norm WENO");
301 BOOST_CHECK_MESSAGE(lNorms.linf < linf_norms_WENO[count] + 0.000001,
"Checking Linf-norm "
308 BOOST_CHECK_MESSAGE(lNorms.l2 < l2_norms_WENO[count] + 0.000001,
"Checking L2-norm WENO");
309 BOOST_CHECK_MESSAGE(lNorms.linf < linf_norms_WENO[count] + 0.000001,
"Checking Linf-norm "
316BOOST_AUTO_TEST_SUITE_END()
Header file containing functions for computing the error and the L_2 / L_infinity norm.
Class for getting the narrow band around the interface.
Header file containing functions for creating files and folders.
Class for reinitializing a level-set function into a signed distance function using Sussman redistanc...
This class represent an N-dimensional box.
Class for computing the l2/l_infinity norm for distributed grids and vectors based on given errors.
void get_l_norms_grid(gridtype &grid)
Computes the L_2 and L_infinity norm on the basis of the precomputed error on a grid.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
This is a distributed grid.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...