OpenFPM  5.2.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 (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. More...
 
template<typename point_type , typename space_type >
space_type get_analytic_sdf_sphere (const point_type coords, const space_type radius, const space_type center[point_type::dims])
 Based on coordinates, radius and center, returns signed distance function of a sphere. More...
 
template<size_t SDF_exact, typename grid_type , typename space_type >
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. More...
 
template<size_t SDF_exact, typename grid_type , typename space_type >
void init_analytic_sdf_sphere (grid_type &grid, const space_type radius, const space_type center[grid_type::dims])
 Computes the analytical signed distance function of a sphere for a given point in space. More...
 
template<typename point_type , typename space_type >
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. More...
 
template<typename point_type , typename space_type >
space_type get_analytic_sdf_circle (const point_type coords, const space_type radius, const space_type center[point_type::dims])
 Based on coordinates, radius and center, returns signed distance function of a disk. More...
 
template<size_t SDF_exact, typename grid_type , typename space_type >
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. More...
 
template<size_t SDF_exact, typename grid_type , typename space_type >
void init_analytic_sdf_circle (grid_type &grid, const space_type radius, const space_type center[grid_type::dims])
 Computes the analytical signed distance function of a disk for a given point in space. 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() [1/2]

template<typename point_type , typename space_type >
space_type get_analytic_sdf_circle ( const point_type  coords,
const space_type  radius,
const space_type  center[point_type::dims] 
)

Based on coordinates, radius and center, returns signed distance function of a disk.

Template Parameters
point_typeTemplate type of input coordinates.
space_typeTemplate type of space.
Parameters
coordsInput coordinates of type point_type.
radiusRadius of type space_type.
centerCenter array of type space_type[2].
Returns
Value of signed distance function.

Definition at line 206 of file AnalyticalSDF.hpp.

◆ get_analytic_sdf_circle() [2/2]

template<typename point_type , typename space_type >
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.

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) is thus:

\[ \phi_{SDF}(x, y, z) = R - \sqrt{((x-a)^2 + (y-b)^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 disk.
center_xSpace_type x-coordinate of disk center.
center_ySpace_type y-coordinate of disk center.
Returns
Space_type variable that contains the exact solution for the signed distance function of a given point in a disk of given radius, where the SDF has positive values inside and negative values outside the disk.

Definition at line 181 of file AnalyticalSDF.hpp.

◆ get_analytic_sdf_sphere() [1/2]

template<typename point_type , typename space_type >
space_type get_analytic_sdf_sphere ( const point_type  coords,
const space_type  radius,
const space_type  center[point_type::dims] 
)

Based on coordinates, radius and center, returns signed distance function of a sphere.

Template Parameters
point_typeTemplate type of input coordinates.
space_typeTemplate type of space.
Parameters
coordsInput coordinates of type point_type.
radiusRadius of type space_type.
centerCenter array of type space_type[3].
Returns
Value of signed distance function.

Definition at line 72 of file AnalyticalSDF.hpp.

◆ get_analytic_sdf_sphere() [2/2]

template<typename point_type , typename space_type >
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.

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() [1/2]

template<size_t SDF_exact, typename grid_type , typename space_type >
void init_analytic_sdf_circle ( grid_type grid,
const space_type  radius,
const space_type  center[grid_type::dims] 
)

Computes the analytical signed distance function of a disk 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) is thus:

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

Template Parameters
SDF_exactSize_t index of property to which analytical SDF of circle will be saved.
grid_typeTemplate type of input grid.
space_typeTemplate type of space.
Parameters
gridInput grid of type grid_type.
radiusRadius of type space_type.
centerArray containing 2 elements for center coordinate in x and y.

Definition at line 268 of file AnalyticalSDF.hpp.

◆ init_analytic_sdf_circle() [2/2]

template<size_t SDF_exact, typename grid_type , typename space_type >
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.

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 234 of file AnalyticalSDF.hpp.

◆ init_analytic_sdf_sphere() [1/2]

template<size_t SDF_exact, typename grid_type , typename space_type >
void init_analytic_sdf_sphere ( grid_type grid,
const space_type  radius,
const space_type  center[grid_type::dims] 
)

Computes the analytical signed distance function of a sphere 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
SDF_exactSize_t index of property to which analytical SDF of sphere will be saved.
grid_typeTemplate type of input grid.
space_typeTemplate type of space.
Parameters
gridInput grid of type grid_type.
radiusRadius of type space_type.
centerArray containing 3 elements for center coordinate in x, y and z.

Definition at line 138 of file AnalyticalSDF.hpp.

◆ init_analytic_sdf_sphere() [2/2]

template<size_t SDF_exact, typename grid_type , typename space_type >
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.

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 102 of file AnalyticalSDF.hpp.