OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
narrowBand_unit_test.cpp
1 //
2 // Created by jstark on 10.06.21.
3 //
4 #define BOOST_TEST_DYN_LINK
5 //#define BOOST_TEST_MAIN // in only one cpp file
6 #include <boost/test/unit_test.hpp>
7 
8 // Include redistancing files
10 // Include header files for testing
11 #include "Draw/DrawSphere.hpp"
13 
14 BOOST_AUTO_TEST_SUITE(NarrowBandTestSuite)
15  BOOST_AUTO_TEST_CASE(NarrowBand_unit_sphere)
16  {
17  auto & v_cl = create_vcluster();
18  typedef double phi_type;
19  const size_t dims = 3;
20  // some indices
21  const size_t x = 0;
22  const size_t y = 1;
23  const size_t z = 2;
24 
25  const size_t Phi_0_grid = 0;
26  const size_t SDF_exact_grid = 1;
27 
28  const size_t SDF_vd = 0;
29  const size_t Gradient_vd = 1;
30  const size_t magnOfGrad_vd = 2;
31 
32 
33  size_t N = 32;
34  const double dt = 0.000165334;
35  const size_t sz[dims] = {N, N, N};
36  const double radius = 1.0;
37  const double box_lower = 0.0;
38  const double box_upper = 4.0 * radius;
39  Box<dims, double> box({box_lower, box_lower, box_lower}, {box_upper, box_upper, box_upper});
40  Ghost<dims, long int> ghost(0);
41  typedef aggregate<phi_type, phi_type> props;
42  typedef grid_dist_id<dims, double, props > grid_in_type;
43  grid_in_type g_dist(sz, box, ghost);
44  g_dist.setPropNames({"Phi_0", "SDF_exact"});
45 
46  const double center[dims] = {0.5*(box_upper+box_lower), 0.5*(box_upper+box_lower), 0.5*(box_upper+box_lower)};
47  init_grid_with_sphere<Phi_0_grid>(g_dist, radius, center[x], center[y], center[z]); // Initialize sphere onto grid
48  // Compute exact signed distance function at each grid point
49  init_analytic_sdf_sphere<SDF_exact_grid>(g_dist, radius, center[x], center[y], center[z]);
50 
52  // Get narrow band: Place particles on interface
53  size_t bc[dims] = {NON_PERIODIC, NON_PERIODIC, NON_PERIODIC};
56  Ghost<dims, double> ghost_vd(0);
57  vd_type vd_narrow_band(0, box, bc, ghost_vd);
58  vd_narrow_band.setPropNames({"SDF_exact", "Gradient of Phi", "Gradient magnitude of Phi"});
59  size_t narrow_band_width = 8;
60  NarrowBand<grid_in_type, phi_type> narrowBand(g_dist, narrow_band_width); // Instantiation of NarrowBand class
61  narrowBand.get_narrow_band<SDF_exact_grid, SDF_vd, Gradient_vd, magnOfGrad_vd>(g_dist, vd_narrow_band);
62 
63  size_t narrow_band_size = vd_narrow_band.size_local();
64  if (v_cl.size() > 1)
65  {
66  v_cl.sum(narrow_band_size);
67  v_cl.execute();
68  }
69 
70  BOOST_CHECK(narrow_band_size == 6568);
71  }
72 BOOST_AUTO_TEST_SUITE_END()
Class for getting the narrow band around the interface.
Definition: NarrowBand.hpp:42
Definition: Ghost.hpp:39
This is a distributed grid.
This class represent an N-dimensional box.
Definition: Box.hpp:60
Distributed vector.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:214
Class for getting the narrow band around the interface.
Header file containing functions that compute the analytical solution of the signed distance function...