Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
Shape< dim > Class Template Referenceabstract

#include <shape.h>

Inheritance diagram for Shape< dim >:
[legend]

Public Types

enum class  ShapeType : std::int8_t {
  sphere , hyper_rectangle , ellipsoid , torus ,
  cone , cylinder , cylindrical_tube , cylindrical_helix ,
  cut_hollow_sphere , death_star , composite , rbf ,
  opencascade , superquadric , plane
}

Public Member Functions

 Shape (double radius, const Point< dim > &position, const Tensor< 1, 3 > &orientation)
virtual double value (const Point< dim > &evaluation_point, const unsigned int component=0) const override=0
virtual double value_with_cell_guess (const Point< dim > &evaluation_point, const typename DoFHandler< dim >::active_cell_iterator &cell, const unsigned int component=0)
virtual std::tuple< double, Tensor< 1, dim >, Point< dim > > distance_to_shape_with_cell_guess (Shape< dim > &shape, const typename DoFHandler< dim >::active_cell_iterator &cell, std::vector< Point< dim > > &candidate_points, double precision=1e-6, bool exact_distance_outside_of_contact=false)
virtual std::tuple< double, Tensor< 1, dim >, Point< dim > > distance_to_shape (Shape< dim > &shape, std::vector< Point< dim > > &candidate_points, double precision=1e-6, bool exact_distance_outside_of_contact=false)
bool bounding_box_contact (Shape< dim > &shape)
virtual Tensor< 1, dim > gradient_with_cell_guess (const Point< dim > &evaluation_point, const typename DoFHandler< dim >::active_cell_iterator &cell, const unsigned int component=0)
virtual std::shared_ptr< Shape< dim > > static_copy () const =0
virtual void closest_surface_point (const Point< dim > &p, Point< dim > &closest_point, const typename DoFHandler< dim >::active_cell_iterator &cell_guess)
virtual void closest_surface_point (const Point< dim > &p, Point< dim > &closest_point) const
virtual double displaced_volume ()
virtual double local_curvature_radius (Point< dim > p)
virtual double local_curvature_radius_with_cell_guess (const Point< dim > &p, const typename DoFHandler< dim >::active_cell_iterator &cell)
virtual void set_position (const Point< dim > &new_position)
virtual void set_orientation (const Tensor< 1, 3 > &new_orientation)
virtual Point< dim > get_position ()
virtual Tensor< 1, 3 > get_orientation ()
virtual Tensor< 2, 3 > get_rotation_matrix ()
virtual Tensor< 1, dim > get_bounding_box_half_length ()
virtual Point< dim > get_bounding_box_center ()
virtual std::shared_ptr< Manifold< dim - 1, dim > > get_shape_manifold ()
virtual void clear_cache ()
Point< dim > align_and_center (const Point< dim > &evaluation_point) const
Point< dim > reverse_align_and_center (const Point< dim > &evaluation_point) const
std::string point_to_string (const Point< dim > &evaluation_point) const
void set_part_of_a_composite (const bool is_part_of_a_composite)
virtual void set_layer_thickening (const double the_layer_thickening)

Static Public Member Functions

static double smooth_max (const double a, const double b, const double smooth_factor=10)
static Tensor< 1, 3 > rotation_matrix_to_xyz_angles (Tensor< 2, 3 > &rotation_matrix_representation)

Public Attributes

enum Shape::ShapeType type
double effective_radius
std::string additional_info_on_shape
Tensor< 1, dim > bounding_box_half_length
Point< dim > bounding_box_center

Protected Attributes

Point< dim > position
Tensor< 1, 3 > orientation
std::unordered_map< std::string, double > value_cache
std::unordered_map< std::string, Tensor< 1, dim > > gradient_cache
std::unordered_map< std::string, Point< dim > > closest_point_cache
bool part_of_a_composite
Tensor< 2, 3 > rotation_matrix
double layer_thickening

Detailed Description

template<int dim>
class Shape< dim >

A base class used to represent geometrical entities. Its main uses are to return signed distance and its gradient. It inherits AutoDerivativeFunction so that it can evaluate gradients even when they are not implemented analytically.

Template Parameters
dimAn integer that denotes the dimension of the space in which the flow is solved

Definition at line 52 of file shape.h.

Member Enumeration Documentation

◆ ShapeType

template<int dim>
enum class Shape::ShapeType : std::int8_t
strong

enum class that associate an integer index tp each type of shape. The enumerator names are the values of the "type" parameter of the particles.

Enumerator
sphere 
hyper_rectangle 
ellipsoid 
torus 
cone 
cylinder 
cylindrical_tube 
cylindrical_helix 
cut_hollow_sphere 
death_star 
composite 
rbf 
opencascade 
superquadric 
plane 

Definition at line 60 of file shape.h.

Constructor & Destructor Documentation

◆ Shape()

template<int dim>
Shape< dim >::Shape ( double radius,
const Point< dim > & position,
const Tensor< 1, 3 > & orientation )
inline

A general constructor for the Shapes.

Parameters
radiusThe effective radius to be set for the shape. It's necessary for some calculations since not all shapes are spheres.
positionThe position to set the shape at
orientationThe orientation to set the shape at

Definition at line 86 of file shape.h.

References effective_radius, layer_thickening, orientation, part_of_a_composite, and position.

Member Function Documentation

◆ align_and_center()

template<int dim>
Point< dim > Shape< dim >::align_and_center ( const Point< dim > & evaluation_point) const

Most value functions assume that the particle's position is at the origin and that the shape is aligned with one of the main axes. This function returns a point that is rotated and translated, in accordance with the current shape position and orientation, so that subsequent calculations for the value function are made more easily; it abstracts a step that is required in the value function for most shapes.

Returns the centered and aligned point used on the level set evaluation.

Parameters
evaluation_pointThe point that will be recentered and realigned
Returns
The aligned and centered point

Definition at line 44 of file shape.cc.

References effective_radius, orientation, and position.

◆ bounding_box_contact()

template<int dim>
bool Shape< dim >::bounding_box_contact ( Shape< dim > & shape)
inline

Check if the bounding box of this shape and another one are overlapping. This function uses the Separating Axis Theorem (SAT) to perform the bounding box check.

Parameters
shapeThe shape with which the distance is evaluated
Returns
This function returns false if the shapes are not overlapping.

Definition at line 741 of file shape.h.

References bounding_box_center, bounding_box_half_length, layer_thickening, point_nd_to_2d(), point_nd_to_3d(), position, rotation_matrix, Shape(), and value().

◆ clear_cache()

template<int dim>
void Shape< dim >::clear_cache ( )
virtual

Clear the cache of the shape.

Reimplemented in CompositeShape< dim >.

Definition at line 31 of file shape.cc.

References closest_point_cache, gradient_cache, and value_cache.

◆ closest_surface_point() [1/2]

template<int dim>
void Shape< dim >::closest_surface_point ( const Point< dim > & p,
Point< dim > & closest_point ) const
virtual

Reimplemented in Superquadric< dim >.

Definition at line 244 of file shape.cc.

References effective_radius, and value().

◆ closest_surface_point() [2/2]

template<int dim>
void Shape< dim >::closest_surface_point ( const Point< dim > & p,
Point< dim > & closest_point,
const typename DoFHandler< dim >::active_cell_iterator & cell_guess )
virtual

Sets the closest_point parameter to be the point on the surface of the shape which has the minimal distance from the given point p.

Parameters
pThe point at which the evaluation is performed
closest_pointThe reference to the closest point. This point will be modified by the function.
cell_guessA guess of the cell containing the evaluation point, which is useful to reduce computation time

Reimplemented in Superquadric< dim >.

Definition at line 224 of file shape.cc.

References effective_radius, gradient_with_cell_guess(), and value_with_cell_guess().

◆ displaced_volume()

template<int dim>
double Shape< dim >::displaced_volume ( )
virtual

Return the volume displaced by the solid.

Returns
The displaced volume, or 0 for shapes whose volume is not computed. The caller is responsible to handle this second case (0) and estimate the volume differently.

Reimplemented in Cone< dim >, CutHollowSphere< dim >, Cylinder< dim >, CylindricalHelix< dim >, CylindricalTube< dim >, DeathStar< dim >, Ellipsoid< dim >, HyperRectangle< dim >, OpenCascadeShape< dim >, Plane< dim >, RBFShape< dim >, Sphere< dim >, and Torus< dim >.

Definition at line 24 of file shape.cc.

◆ distance_to_shape()

template<int dim>
virtual std::tuple< double, Tensor< 1, dim >, Point< dim > > Shape< dim >::distance_to_shape ( Shape< dim > & shape,
std::vector< Point< dim > > & candidate_points,
double precision = 1e-6,
bool exact_distance_outside_of_contact = false )
inlinevirtual

Return the distance, the center point, and the normal between the current shape and the shape given in the argument. The center point is the point where both shapes are at the same distance from each other. The normal is defined using the closest surface point on the two shapes. By default, the function does not calculate the distance between the two shapes if their bounding boxes are not in contact. This behavior can be modified using the appropriate parameter.

Parameters
shapeThe shape with which the distance is evaluated
candidate_pointsThis is the initial guess points used in the calculation.
precisionThis is the precision of the distance between the two shapes.
exact_distance_outside_of_contactThis is a boolean to force the exact distance evaluation if the shapes are not in contact.

Reimplemented in Sphere< dim >.

Definition at line 450 of file shape.h.

References bounding_box_center, bounding_box_contact(), bounding_box_half_length, closest_surface_point(), effective_radius, point_nd_to_3d(), position, rotation_matrix, Shape(), smooth_max(), tensor_nd_to_2d(), and value().

◆ distance_to_shape_with_cell_guess()

template<int dim>
virtual std::tuple< double, Tensor< 1, dim >, Point< dim > > Shape< dim >::distance_to_shape_with_cell_guess ( Shape< dim > & shape,
const typename DoFHandler< dim >::active_cell_iterator & cell,
std::vector< Point< dim > > & candidate_points,
double precision = 1e-6,
bool exact_distance_outside_of_contact = false )
inlinevirtual

Return the distance, the center point, and the unit normal vector between the current shape and the shape given in the argument. The center point is the point where both shapes are at the same distance from each other. The unit normal vector is defined using the closest surface point of the two shapes. By default, the function does not calculate the distance between the two shapes if their bounding boxes are not in contact. This behavior can be modified by setting exact_distance_outside_of_contact to true.

Parameters
shapeThe shape with which the distance is evaluated
cellThe cell that is likely to contain the evaluation point
candidate_pointsThis is the initial guess points used in the calculation.
precisionThis is the precision of the distance between the two shapes.
exact_distance_outside_of_contactThis is a boolean to force the exact distance evaluation if the shapes are not in contact.

Reimplemented in Sphere< dim >.

Definition at line 147 of file shape.h.

References bounding_box_center, bounding_box_contact(), bounding_box_half_length, closest_surface_point(), effective_radius, gradient_with_cell_guess(), point_nd_to_3d(), position, rotation_matrix, Shape(), smooth_max(), tensor_nd_to_2d(), and value_with_cell_guess().

◆ get_bounding_box_center()

template<int dim>
virtual Point< dim > Shape< dim >::get_bounding_box_center ( )
inlinevirtual

Returns the bounding box position.

Definition at line 1227 of file shape.h.

References bounding_box_center.

◆ get_bounding_box_half_length()

template<int dim>
virtual Tensor< 1, dim > Shape< dim >::get_bounding_box_half_length ( )
inlinevirtual

Returns the bounding box half length.

Definition at line 1217 of file shape.h.

References bounding_box_half_length.

◆ get_orientation()

template<int dim>
virtual Tensor< 1, 3 > Shape< dim >::get_orientation ( )
inlinevirtual

Returns the orientation of the shape.

Definition at line 1197 of file shape.h.

References orientation.

◆ get_position()

template<int dim>
virtual Point< dim > Shape< dim >::get_position ( )
inlinevirtual

Returns the position of the shape.

Definition at line 1187 of file shape.h.

References position.

◆ get_rotation_matrix()

template<int dim>
virtual Tensor< 2, 3 > Shape< dim >::get_rotation_matrix ( )
inlinevirtual

Returns the orientation of the shape.

Definition at line 1207 of file shape.h.

References rotation_matrix.

◆ get_shape_manifold()

template<int dim>
std::shared_ptr< Manifold< dim - 1, dim > > Shape< dim >::get_shape_manifold ( )
virtual

Returns the default manifold of the shape. If not redefined, it is a flat manifold.

Reimplemented in Sphere< dim >.

Definition at line 200 of file shape.cc.

◆ gradient_with_cell_guess()

template<int dim>
Tensor< 1, dim > Shape< dim >::gradient_with_cell_guess ( const Point< dim > & evaluation_point,
const typename DoFHandler< dim >::active_cell_iterator & cell,
const unsigned int component = 0 )
virtual

Return the analytical gradient of the distance.

Parameters
evaluation_pointThe point at which the function will be evaluated
cellThe cell that is likely to contain the evaluation point
componentThis parameter is not used, but it is necessary because Shapes inherit from the Function class of deal.II.

Reimplemented in CompositeShape< dim >, OpenCascadeShape< dim >, RBFShape< dim >, and Superquadric< dim >.

Definition at line 272 of file shape.cc.

◆ local_curvature_radius()

template<int dim>
virtual double Shape< dim >::local_curvature_radius ( Point< dim > p)
inlinevirtual

Return the curvature of the level set at a given point.

Reimplemented in Sphere< dim >.

Definition at line 1077 of file shape.h.

References effective_radius.

◆ local_curvature_radius_with_cell_guess()

template<int dim>
virtual double Shape< dim >::local_curvature_radius_with_cell_guess ( const Point< dim > & p,
const typename DoFHandler< dim >::active_cell_iterator & cell )
inlinevirtual

Return the curvature of the level at a given point using the cell guess functions.

Parameters
cellThe cell that is likely to contain the evaluation point
pThe point where the curvature is evaluated.

Reimplemented in Sphere< dim >.

Definition at line 1105 of file shape.h.

References effective_radius, and gradient_with_cell_guess().

◆ point_to_string()

template<int dim>
std::string Shape< dim >::point_to_string ( const Point< dim > & evaluation_point) const

This function returns a point in a string of text. This is used in the cache of the shape.

Parameters
evaluation_pointis the point that is transformed to its text form.

Definition at line 207 of file shape.cc.

◆ reverse_align_and_center()

template<int dim>
Point< dim > Shape< dim >::reverse_align_and_center ( const Point< dim > & evaluation_point) const

This function applies the inverse operation of align_and_center.

Returns the centered and aligned point used on the level set evaluation in the global reference frame.

Parameters
evaluation_pointThe point that will be centered and aligned in the global reference frame.
Returns
The aligned and centered point

Definition at line 122 of file shape.cc.

References effective_radius, orientation, and position.

◆ rotation_matrix_to_xyz_angles()

template<int dim>
Tensor< 1, 3 > Shape< dim >::rotation_matrix_to_xyz_angles ( Tensor< 2, 3 > & rotation_matrix_representation)
inlinestatic

Function that return the XYZ rotation angles from a rotation matrix.

Parameters
rotation_matrix_representationThe rotation matrix.

Definition at line 1321 of file shape.h.

◆ set_layer_thickening()

template<int dim>
virtual void Shape< dim >::set_layer_thickening ( const double the_layer_thickening)
inlinevirtual

Sets the layer thickening value (positive or negative) of the particle's shape.

Parameters
the_layer_thickeningThickness to be artificially added to the particle. A negative value will decrease the particle's thickness by subtracting a layer of specified width.

Reimplemented in CompositeShape< dim >.

Definition at line 1309 of file shape.h.

References layer_thickening.

◆ set_orientation()

template<int dim>
virtual void Shape< dim >::set_orientation ( const Tensor< 1, 3 > & new_orientation)
inlinevirtual

Sets a new orientation for the shape.

Parameters
new_orientationThe new orientation the shape will be set at

Definition at line 1153 of file shape.h.

References clear_cache(), orientation, and rotation_matrix.

◆ set_part_of_a_composite()

template<int dim>
void Shape< dim >::set_part_of_a_composite ( const bool is_part_of_a_composite)
inline

Defines if this shape is part of a composite. If true, cache management is deactivated and delegated to the upper level shape, to avoid cache duplication.

Parameters
is_part_of_a_compositeis true if this shape is a constituent of a composite shape

Definition at line 1294 of file shape.h.

References part_of_a_composite.

◆ set_position()

template<int dim>
virtual void Shape< dim >::set_position ( const Point< dim > & new_position)
inlinevirtual

Sets a new position for the shape.

Parameters
new_positionThe new position the shape will be placed at

Reimplemented in OpenCascadeShape< dim >, and Sphere< dim >.

Definition at line 1140 of file shape.h.

References clear_cache(), and position.

◆ smooth_max()

template<int dim>
double Shape< dim >::smooth_max ( const double a,
const double b,
const double smooth_factor = 10 )
inlinestatic

Return the smoothed maximum of two variables used for shape contact calculation.

Parameters
afirst variable
bsecond variable
smooth_factor

Definition at line 132 of file shape.h.

◆ static_copy()

◆ value()

template<int dim>
virtual double Shape< dim >::value ( const Point< dim > & evaluation_point,
const unsigned int component = 0 ) const
overridepure virtual

Return the evaluation of the signed distance function of this solid at the given point evaluation point Most level set functions implemented come from Inigo Quilez: iquilezles.org/articles/distfunctions.

Parameters
evaluation_pointThe point at which the function will be evaluated
componentThis parameter is not used, but it is necessary because Shapes inherit from the Function class of deal.II.

Implemented in CompositeShape< dim >, Cone< dim >, CutHollowSphere< dim >, Cylinder< dim >, CylindricalHelix< dim >, CylindricalTube< dim >, DeathStar< dim >, Ellipsoid< dim >, HyperRectangle< dim >, OpenCascadeShape< dim >, Plane< dim >, RBFShape< dim >, Sphere< dim >, Superquadric< dim >, and Torus< dim >.

◆ value_with_cell_guess()

template<int dim>
double Shape< dim >::value_with_cell_guess ( const Point< dim > & evaluation_point,
const typename DoFHandler< dim >::active_cell_iterator & cell,
const unsigned int component = 0 )
virtual

Return the evaluation of the signed distance function of this solid at the given point evaluation point with a guess for the cell containing the evaluation point.

Parameters
evaluation_pointThe point at which the function will be evaluated
cellThe cell that is likely to contain the evaluation point
componentThis parameter is not used, but it is necessary because Shapes inherit from the Function class of deal.II.

Reimplemented in CompositeShape< dim >, OpenCascadeShape< dim >, RBFShape< dim >, and Superquadric< dim >.

Definition at line 262 of file shape.cc.

References value().

Member Data Documentation

◆ additional_info_on_shape

template<int dim>
std::string Shape< dim >::additional_info_on_shape

Definition at line 1338 of file shape.h.

◆ bounding_box_center

template<int dim>
Point<dim> Shape< dim >::bounding_box_center

Definition at line 1343 of file shape.h.

◆ bounding_box_half_length

template<int dim>
Tensor<1, dim> Shape< dim >::bounding_box_half_length

Definition at line 1341 of file shape.h.

◆ closest_point_cache

template<int dim>
std::unordered_map<std::string, Point<dim> > Shape< dim >::closest_point_cache
protected

Definition at line 1357 of file shape.h.

◆ effective_radius

template<int dim>
double Shape< dim >::effective_radius

Definition at line 1333 of file shape.h.

◆ gradient_cache

template<int dim>
std::unordered_map<std::string, Tensor<1, dim> > Shape< dim >::gradient_cache
protected

Definition at line 1356 of file shape.h.

◆ layer_thickening

template<int dim>
double Shape< dim >::layer_thickening
protected

Definition at line 1364 of file shape.h.

◆ orientation

template<int dim>
Tensor<1, 3> Shape< dim >::orientation
protected

Definition at line 1351 of file shape.h.

◆ part_of_a_composite

template<int dim>
bool Shape< dim >::part_of_a_composite
protected

Definition at line 1358 of file shape.h.

◆ position

template<int dim>
Point<dim> Shape< dim >::position
protected

Definition at line 1348 of file shape.h.

◆ rotation_matrix

template<int dim>
Tensor<2, 3> Shape< dim >::rotation_matrix
protected

Definition at line 1362 of file shape.h.

◆ type

template<int dim>
enum Shape::ShapeType Shape< dim >::type

◆ value_cache

template<int dim>
std::unordered_map<std::string, double> Shape< dim >::value_cache
protected

Definition at line 1355 of file shape.h.


The documentation for this class was generated from the following files: