4#define BOOST_TEST_DYN_LINK
6#include <boost/test/unit_test.hpp>
13#include "Draw/DrawSphere.hpp"
14#include "Draw/DrawDisk.hpp"
18BOOST_AUTO_TEST_SUITE(RedistancingSussmanSinglePointConvergenceTestSuite)
20 BOOST_AUTO_TEST_CASE(RedistancingSussmanSinglePoint_1D_test)
24 const double EPSILON = std::numeric_limits<double>::epsilon();
26 std::cout <<
"epsilon = " << EPSILON << std::endl;
27 const size_t grid_dim = 1;
31 const size_t Phi_0_grid = 0;
32 const size_t SDF_sussman_grid = 1;
33 const size_t SDF_exact_grid = 2;
34 const size_t Error_grid = 3;
37 double dt = 0.000503905;
44 size_t max_iter = (size_t) std::round(tf / dt);
45 const size_t sz[grid_dim] = {N};
46 const double box_lower = -1.0;
47 const double box_upper = 1.0;
52 grid_in_type g_dist(sz, box, ghost);
53 g_dist.setPropNames({
"Phi_0",
"SDF_sussman",
"SDF_exact",
"Relative error"});
56 auto dom = g_dist.getDomainIterator();
61 g_dist.template get<Phi_0_grid>(key) =
sgn(coords.
get(x));
62 g_dist.template get<SDF_exact_grid>(key) = coords.
get(x);
66 g_dist.write(
"grid_1D_preRedistancing", FORMAT_BINARY);
71 redist_options.order_space_op = 1;
72 redist_options.order_timestepper = 1;
74 redist_options.convTolChange.check =
true;
76 redist_options.convTolChange.value = EPSILON;
78 redist_options.convTolResidual.check =
false;
79 redist_options.interval_check_convergence = 100;
81 redist_options.width_NB_in_grid_points = 32;
83 redist_options.print_current_iterChangeResidual =
true;
84 redist_options.print_steadyState_iter =
true;
88 redist_obj.set_user_time_step(dt);
90 std::cout <<
"dt set to = " << dt << std::endl;
92 redist_obj.run_redistancing<Phi_0_grid, SDF_sussman_grid>();
95 get_absolute_error<SDF_sussman_grid, SDF_exact_grid, Error_grid>(g_dist);
96 g_dist.write(
"grid_RKorder" + std::to_string(redist_options.order_timestepper) +
"_i_" + std::to_string(i),
126 BOOST_AUTO_TEST_CASE(RedistancingSussmanSinglePoint_2D_test)
129 const double EPSILON = std::numeric_limits<double>::epsilon();
131 const size_t grid_dim = 2;
136 const size_t Phi_0_grid = 0;
137 const size_t SDF_sussman_grid = 1;
138 const size_t SDF_exact_grid = 2;
139 const size_t Error_grid = 3;
142 double dt = 0.00100781;
143 double tf = 1e4 * dt;
148 size_t max_iter = (size_t) std::round(tf / dt);
149 const size_t sz[grid_dim] = {N, N};
150 const double radius = 1.0;
151 const double box_lower = 0.0;
152 const double box_upper = 4.0 * radius;
157 grid_in_type g_dist(sz, box, ghost);
158 g_dist.setPropNames({
"Phi_0",
"SDF_sussman",
"SDF_exact",
"Relative error"});
160 const double center[grid_dim] = {0.5 * (box_upper + box_lower), 0.5 * (box_upper + box_lower)};
161 init_grid_with_disk<Phi_0_grid>(g_dist, radius, center[x], center[y]);
167 redist_options.min_iter = max_iter;
168 redist_options.max_iter = max_iter;
170 redist_options.order_space_op = 1;
171 redist_options.order_timestepper = 1;
174 redist_options.convTolChange.check =
false;
175 redist_options.convTolResidual.check =
false;
177 redist_options.interval_check_convergence = 100;
179 redist_options.width_NB_in_grid_points = 8;
180 redist_options.print_current_iterChangeResidual =
true;
181 redist_options.print_steadyState_iter =
true;
185 redist_obj.set_user_time_step(dt);
186 std::cout <<
"dt set to = " << dt << std::endl;
189 redist_obj.run_redistancing<Phi_0_grid, SDF_sussman_grid>();
192 init_analytic_sdf_circle<SDF_exact_grid>(g_dist, radius, center[x], center[y]);
195 get_absolute_error<SDF_sussman_grid, SDF_exact_grid, Error_grid>(g_dist);
230BOOST_AUTO_TEST_SUITE_END()
Header file containing functions that compute the analytical solution of the signed distance function...
int sgn(T val)
Gets the sign of a variable.
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.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Class for reinitializing a level-set function into a signed distance function using Sussman redistanc...
This is a distributed grid.
Structure to bundle options for redistancing.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...