OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
AnalyticalSDF.hpp File Reference

Header file containing functions that compute the analytical solution of the signed distance function (SDF) for a 3D sphere and a 2D disk of defined radius on a grid. More...

#include <iostream>
#include "Vector/vector_dist.hpp"
#include "Grid/grid_dist_id.hpp"

Go to the source code of this file.

Functions

template<typename point_type , typename space_type >
space_type get_analytic_sdf_sphere (point_type coords, space_type radius, space_type center_x=0, space_type center_y=0, space_type center_z=0)
 Computes the analytical signed distance function of a sphere for a given point in space. More...
 
template<size_t SDF_exact, typename grid_type , typename space_type >
void init_analytic_sdf_sphere (grid_type &grid, space_type radius, space_type center_x=0, space_type center_y=0, space_type center_z=0)
 Initializes the exact solution of the signed distance function of a sphere on an OpenFPM grid. More...
 
template<typename point_type , typename space_type >
space_type get_analytic_sdf_circle (point_type coords, space_type radius, space_type center_x=0, space_type center_y=0)
 Computes the analytical signed distance function of a circle for a given point in space. More...
 
template<size_t SDF_exact, typename grid_type , typename space_type >
void init_analytic_sdf_circle (grid_type &grid, space_type radius, space_type center_x=0, space_type center_y=0)
 Initializes the exact solution of the signed distance function of a circle on an OpenFPM grid. More...
 

Detailed Description

Header file containing functions that compute the analytical solution of the signed distance function (SDF) for a 3D sphere and a 2D disk of defined radius on a grid.

Author
Justina Stark
Date
October 2020

Definition in file AnalyticalSDF.hpp.

Function Documentation

◆ get_analytic_sdf_circle()

template<typename point_type , typename space_type >
space_type get_analytic_sdf_circle ( point_type  coords,
space_type  radius,
space_type  center_x = 0,
space_type  center_y = 0 
)

Computes the analytical signed distance function of a circle for a given point in space.

At the center of the circle, φ_SDF_analytic = Radius. Moving outwards from the center on, the value for the SDF decreases steadily, eventually becomes 0 at the circle surface and negative beyond the surface. The analytic SDF for a circle of radius R and center (a, b, c) is thus:

\[ \phi_{SDF}(x, y, z) = R - \sqrt{((x-a)^2 + (y-b)^2 + (z-c)^2)} \]

Template Parameters
point_typeTemplate type of OpenFPM Point<dimension, type>.
space_typeTemplate type of radius.
Parameters
coordsPoint_type coordinates of point.
radiusSpace_type radius of the sphere.
center_xSpace_type x-coordinate of sphere center.
center_ySpace_type y-coordinate of sphere center.
center_zSpace_type z-coordinate of sphere center.
Returns
Space_type variable that contains the exact solution for the signed distance function of a given point in a sphere of given radius, where the SDF has positive values inside and negative values outside the sphere.

Definition at line 116 of file AnalyticalSDF.hpp.

◆ get_analytic_sdf_sphere()

template<typename point_type , typename space_type >
space_type get_analytic_sdf_sphere ( point_type  coords,
space_type  radius,
space_type  center_x = 0,
space_type  center_y = 0,
space_type  center_z = 0 
)

Computes the analytical signed distance function of a sphere for a given point in space.

At the center of the sphere, φ_SDF_analytic = Radius. Moving outwards from the center on, the value for the SDF decreases steadily, eventually becomes 0 at the sphere surface and negative beyond the surface. The analytic SDF for a sphere of radius R and center (a, b, c) is thus:

\[ \phi_{SDF}(x, y, z) = R - \sqrt{((x-a)^2 + (y-b)^2 + (z-c)^2)} \]

Template Parameters
point_typeTemplate type of OpenFPM Point<dimension, type>.
space_typeTemplate type of radius.
Parameters
coordsPoint_type coordinates of point.
radiusSpace_type radius of the sphere.
center_xSpace_type x-coordinate of sphere center.
center_ySpace_type y-coordinate of sphere center.
center_zSpace_type z-coordinate of sphere center.
Returns
Space_type variable that contains the exact solution for the signed distance function of a given point in a sphere of given radius, where the SDF has positive values inside and negative values outside the sphere.

Definition at line 46 of file AnalyticalSDF.hpp.

◆ init_analytic_sdf_circle()

template<size_t SDF_exact, typename grid_type , typename space_type >
void init_analytic_sdf_circle ( grid_type grid,
space_type  radius,
space_type  center_x = 0,
space_type  center_y = 0 
)

Initializes the exact solution of the signed distance function of a circle on an OpenFPM grid.

Solves the exact SDF for each grid nodes and writes the solution to a given property.

Template Parameters
SDF_exactIndex of property where the anaytical solution for the SDF should be written to.
grid_typeTemplate type of the input grid.
space_typeTemplate type of radius and center coordinates.
Parameters
gridInput OpenFPM grid.
radiusRadius of the filled circle.
center_xX-coordinate of the circle center.
center_yY-coordinate of the circle center.

Definition at line 144 of file AnalyticalSDF.hpp.

◆ init_analytic_sdf_sphere()

template<size_t SDF_exact, typename grid_type , typename space_type >
void init_analytic_sdf_sphere ( grid_type grid,
space_type  radius,
space_type  center_x = 0,
space_type  center_y = 0,
space_type  center_z = 0 
)

Initializes the exact solution of the signed distance function of a sphere on an OpenFPM grid.

Solves the exact SDF for each grid nodes and writes the solution to a given property.

Template Parameters
SDF_exactIndex of property where the anaytical solution for the SDF should be written to.
grid_typeTemplate type of the input grid.
space_typeTemplate type of radius the sphere is supposed to have.
Parameters
gridInput OpenFPM grid.
radiusRadius of the filled sphere.
center_xSpace_type x-coordinate of sphere center.
center_ySpace_type y-coordinate of sphere center.
center_zSpace_type z-coordinate of sphere center.

Definition at line 77 of file AnalyticalSDF.hpp.