5#ifndef OPENFPM_PDATA_ANALYTICALSDF_HPP
6#define OPENFPM_PDATA_ANALYTICALSDF_HPP
20#ifndef ANALYTICAL_SDF_HPP
21#define ANALYTICAL_SDF_HPP
24#include "Vector/vector_dist.hpp"
25#include "Grid/grid_dist_id.hpp"
45template <
typename po
int_type,
typename space_type>
47 const space_type center_x=0,
const space_type center_y=0,
const space_type center_z=0)
49 typedef typename std::remove_const_t<std::remove_reference_t<
decltype(coords.get(0))>> coord_type;
50 if(!(std::is_same<space_type, coord_type>::value))
52 std::cout <<
"Radius-, Center- and Space-type of grid must be the same! Aborting..." << std::endl;
55 const space_type X = coords.get(0), Y = coords.get(1), Z = coords.get(2);
57 sqrt((X - center_x) * (X - center_x)
58 + (Y - center_y) * (Y - center_y)
59 + (Z - center_z) * (Z - center_z)));
71template <
typename po
int_type,
typename space_type>
72space_type
get_analytic_sdf_sphere(
const point_type coords,
const space_type radius,
const space_type center[point_type::dims])
74 size_t x = 0, y = 1, z = 2;
75 typedef typename std::remove_const_t<std::remove_reference_t<
decltype(coords.get(0))>> coord_type;
76 if(!(std::is_same<space_type, coord_type>::value))
78 std::cout <<
"Radius-, Center- and Space-type of grid must be the same! Aborting..." << std::endl;
81 const space_type X = coords.get(0), Y = coords.get(1), Z = coords.get(2);
83 sqrt((X - center[x]) * (X - center[x])
84 + (Y - center[y]) * (Y - center[y])
85 + (Z - center[z]) * (Z - center[z])));
101template <
size_t SDF_exact,
typename gr
id_type,
typename space_type>
103 const space_type center_z=0)
105 if(!(std::is_same<typename grid_type::stype, space_type>::value))
107 std::cout <<
"Radius-, Center- and Space-type of grid must be the same! Aborting..." << std::endl;
111 auto dom =
grid.getDomainIterator();
114 auto key = dom.get();
137template <
size_t SDF_exact,
typename gr
id_type,
typename space_type>
140 if(!(std::is_same<typename grid_type::stype, space_type>::value))
142 std::cout <<
"Radius-, Center- and Space-type of grid must be the same! Aborting..." << std::endl;
146 auto dom =
grid.getDomainIterator();
149 auto key = dom.get();
180template <
typename po
int_type,
typename space_type>
182 const space_type center_x=0,
const space_type center_y=0)
184 typedef typename std::remove_const_t<std::remove_reference_t<
decltype(coords.get(0))>> coord_type;
185 if(!(std::is_same<space_type, coord_type>::value))
187 std::cout <<
"Radius-, Center- and Space-type of grid must be the same! Aborting..." << std::endl;
190 const space_type X = coords.get(0), Y = coords.get(1);
192 sqrt((X - center_x) * (X - center_x)
193 + (Y - center_y) * (Y - center_y)));
205template <
typename po
int_type,
typename space_type>
206space_type
get_analytic_sdf_circle(
const point_type coords,
const space_type radius,
const space_type center[point_type::dims])
209 typedef typename std::remove_const_t<std::remove_reference_t<
decltype(coords.get(0))>> coord_type;
210 if(!(std::is_same<space_type, coord_type>::value))
212 std::cout <<
"Radius-, Center- and Space-type of grid must be the same! Aborting..." << std::endl;
215 const space_type X = coords.get(0), Y = coords.get(1);
217 sqrt((X - center[x]) * (X - center[x])
218 + (Y - center[y]) * (Y - center[y])));
233template <
size_t SDF_exact,
typename gr
id_type,
typename space_type>
236 if(!(std::is_same<typename grid_type::stype, space_type>::value))
238 std::cout <<
"Radius-, Center- and Space-type of grid must be the same! Aborting..." << std::endl;
241 auto dom =
grid.getDomainIterator();
244 auto key = dom.get();
267template <
size_t SDF_exact,
typename gr
id_type,
typename space_type>
270 if(!(std::is_same<typename grid_type::stype, space_type>::value))
272 std::cout <<
"Radius-, Center- and Space-type of grid must be the same! Aborting..." << std::endl;
276 auto dom =
grid.getDomainIterator();
279 auto key = dom.get();
space_type get_analytic_sdf_circle(point_type coords, const space_type radius, const space_type center_x=0, const space_type center_y=0)
Computes the analytical signed distance function of a circle for a given point in space.
void init_analytic_sdf_circle(grid_type &grid, const space_type radius, const space_type center_x=0, const space_type center_y=0)
Initializes the exact solution of the signed distance function of a circle on an OpenFPM grid.
space_type get_analytic_sdf_sphere(const point_type coords, const space_type radius, const space_type center_x=0, const space_type center_y=0, const space_type center_z=0)
Computes the analytical signed distance function of a sphere for a given point in space.
void init_analytic_sdf_sphere(grid_type &grid, const space_type radius, const space_type center_x=0, const space_type center_y=0, const space_type center_z=0)
Initializes the exact solution of the signed distance function of a sphere on an OpenFPM grid.
This class implement the point shape in an N-dimensional space.
This is a distributed grid.
static const unsigned int dims
Number of dimensions.