OpenFPM  5.2.0
Project that contain the implementation of distributed structures
poly_levelset_test.cpp
1 /*
2  * Unit tests for the Regression module PolyLevelset submodule
3  * author : Sachin (sthekke@mpi-cbg.de)
4  * date : 18.01.2023
5  *
6  */
7 
8 
9 #define BOOST_TEST_DYN_LINK
10 #include <boost/test/unit_test.hpp>
11 #include "poly_levelset.hpp"
12 #include "Vector/vector_dist.hpp"
13 #include "DMatrix/EMatrix.hpp"
14 
15 BOOST_AUTO_TEST_SUITE( Regression_test )
16 
17 
18 
19 BOOST_AUTO_TEST_CASE ( PolyLevelset_Sphere )
20 {
21  Box<3,double> domain({-2.0,-2.0,-2.0},{2.0,2.0,2.0});
22 
23  // Here we define the boundary conditions of our problem
24  size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};
25 
26  // extended boundary around the domain, and the processor domain
27  Ghost<3,double> g(0.01);
28 
30 
31  vectorType vd(1024,domain,bc,g);
32 
33  constexpr int mean_curvature = 0;
34  constexpr int gauss_curvature = 1;
35 
36  // Initialize points on sphere
37  auto it = vd.getDomainIterator();
38  while (it.isNext())
39  {
40  auto key = it.get();
41  double theta = ((double)rand() / RAND_MAX) * M_PI;
42  double phi = ((double)rand() / RAND_MAX) * 2.0 * M_PI;
43 
44  vd.getPos(key)[0] = cos(theta) * sin(phi);
45  vd.getPos(key)[1] = cos(theta) * cos(phi);
46  vd.getPos(key)[2] = sin(theta);
47 
48  vd.template getProp<mean_curvature>(key) = 0.0;
49  vd.template getProp<gauss_curvature>(key) = 0.0;
50 
51  ++it;
52  }
53  vd.map();
54 
55  // auto model = PolyLevelset<3>(vd, 1e-4);
56 /*
57  double max_err = -1.0;
58  auto it2 = vd.getDomainIterator();
59  while (it2.isNext())
60  {
61  auto key = it2.get();
62  Point<3, double> pos = {vd.getPos(key)[0], vd.getPos(key)[1], vd.getPos(key)[2]};
63  // vd.template getProp<mean_curvature>(key) = model.estimate_mean_curvature_at(pos);
64  // vd.template getProp<gauss_curvature>(key) = model->estimate_gauss_curvature_at(vd.getPos(key));
65 
66  double val = vd.getProp<mean_curvature>(key);
67  double actual = 1.0;
68  double err = std::abs(actual - val);
69  if (err > max_err) max_err = err;
70 
71  ++it2;
72  }
73 
74 
75  double tolerance = 1e-4;
76  bool check;
77  if (std::abs(max_err) < tolerance)
78  check = true;
79  else
80  check = false;
81  std::cout<<"Max err (poly level) = "<<max_err<<"\n";
82 
83  BOOST_TEST( check );
84  */
85  // if(model)
86  // delete model;
87 
88 }
89 
90 
91 BOOST_AUTO_TEST_SUITE_END()
92 
This class represent an N-dimensional box.
Definition: Box.hpp:60
Definition: Ghost.hpp:40
Distributed vector.