Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
LetheGridTools Namespace Reference

Classes

struct  TriangleProjectionData
struct  hash_cell
struct  equal_cell

Enumerations

enum class  ParticleTriangleContactIndicator : std::uint8_t { face_contact , edge_contact , vertex_contact , no_contact }

Functions

template<int dim>
void vertices_cell_mapping (const DoFHandler< dim > &dof_handler, std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > &vertices_cell_map)
template<int dim>
void vertices_cell_mapping_with_periodic_boundaries (const DoFHandler< dim > &dof_handler, std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > &vertices_cell_map)
template<int dim>
DoFHandler< dim >::active_cell_iterator find_cell_around_point_with_tree (const DoFHandler< dim > &dof_handler, const Point< dim > &point)
template<int dim>
DoFHandler< dim >::active_cell_iterator find_cell_around_point_with_neighbors (const DoFHandler< dim > &dof_handler, std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > &vertices_cell_map, const typename DoFHandler< dim >::active_cell_iterator &cell, const Point< dim > &point)
template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > find_cells_around_cell (std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > &vertices_cell_map, const typename DoFHandler< dim >::active_cell_iterator &cell)
template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > find_cells_around_flat_cell (const DoFHandler< dim > &dof_handler, const typename DoFHandler< dim - 1, dim >::active_cell_iterator &cell, std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > &vertices_cell_map)
template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > find_cells_around_edge (const DoFHandler< dim > &dof_handler, std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > &vertices_cell_map, const typename DoFHandler< dim >::active_cell_iterator &cell, Point< dim > &point_1, Point< dim > &point_2)
template<int dim>
void flag_cells_in_refinement_box (const DoFHandler< dim > &dof_handler, const Triangulation< dim > &box_triangulation)
template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > find_cells_in_cells (const DoFHandler< dim > &dof_handler, const typename DoFHandler< dim >::active_cell_iterator &cell)
template<int dim>
bool cell_cut_by_flat (const typename DoFHandler< dim >::active_cell_iterator &cell, const typename DoFHandler< dim - 1, dim >::active_cell_iterator &cell_flat)
template<int dim>
bool cell_pierced_by_edge (const typename DoFHandler< dim >::active_cell_iterator &cell, const TriaIterator< CellAccessor< 1, dim > > &cell_edge)
template<int dim>
bool cell_pierced_by_edge (const typename DoFHandler< dim >::active_cell_iterator &cell, Point< dim > point_1, Point< dim > point_2)
template<int spacedim, int structdim>
std::pair< std::pair< Point< spacedim >, bool >, Tensor< 1, spacedim > > project_to_d_linear_object (const typename DoFHandler< structdim, spacedim >::active_cell_iterator &object, const Point< spacedim > &trial_point)
template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > find_boundary_cells_in_sphere (const DoFHandler< dim > &dof_handler, const Point< dim > &center, const double radius)
template<int spacedim, int structdim>
std::map< typename DoFHandler< spacedim >::active_cell_iterator, std::map< unsigned int, typename DoFHandler< structdim, spacedim >::active_cell_iterator > > find_cells_cut_by_object (const DoFHandler< spacedim > &dof_handler, std::map< unsigned int, std::set< typename DoFHandler< spacedim >::active_cell_iterator > > &vertices_cell_map, std::vector< SerialSolid< structdim, spacedim > > &list_of_objects)
template<int dim>
TriangleProjectionData< dim > prepare_triangle_projection_data (const std::vector< Point< dim > > &triangle)
template<int dim>
std::tuple< bool, Point< 3 >, Tensor< 1, 3 >, ParticleTriangleContactIndicator > find_particle_triangle_projection (const TriangleProjectionData< dim > &triangle_data, const Point< dim > &particle_position, const double cutoff_distance)
template<int dim>
double find_point_triangle_distance (const std::vector< Point< dim > > &triangle_vertices, const Point< dim > &point)
template<int dim>
std::vector< Point< dim > > find_line_sphere_intersection (const Point< dim > &line_start, const Tensor< 1, dim > &line_direction, const Point< dim > &sphere_center, const double &sphere_diameter)
template<int dim>
double find_point_line_distance (const Point< dim > &line_origin, const Tensor< 1, dim > &line_direction, const Point< dim > &point)
template<int dim>
Tensor< 1, dim > angular_to_linear_velocity (const double omega, const Tensor< 1, dim > &point, const unsigned int rotation_axis_direction=2)
template<int dim>
void rotate_mapping (const DoFHandler< dim > &dof_handler, MappingQCache< dim > &mapping_cache, const Mapping< dim > &mapping, const double rotation_angle, const Point< dim > &center_of_rotation=Point< dim >(), const unsigned int rotation_axis_direction=2)
template<int dim, int spacedim>
void vertices_cell_mapping (const Triangulation< dim, spacedim > &tria, std::map< unsigned int, std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > &vertices_cell_map)
template<int dim, int spacedim = dim>
std::vector< typename Triangulation< dim, spacedim >::active_cell_iterator > find_cells_around_cell (std::map< unsigned int, std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > &vertices_cell_map, const typename Triangulation< dim, spacedim >::active_cell_iterator &cell)

Enumeration Type Documentation

◆ ParticleTriangleContactIndicator

enum class LetheGridTools::ParticleTriangleContactIndicator : std::uint8_t
strong

Indicates the type of contact between a particle and a triangle.

Enumerator
face_contact 
edge_contact 
vertex_contact 
no_contact 

Definition at line 289 of file lethe_grid_tools.h.

Function Documentation

◆ angular_to_linear_velocity()

template<int dim>
Tensor< 1, dim > LetheGridTools::angular_to_linear_velocity ( const double omega,
const Tensor< 1, dim > & point,
const unsigned int rotation_axis_direction = 2 )
inline

Transform angular velocity into linear velocity considering that the angular velocity omega is constant in all directions.

Parameters
[in]omegaAngular velocity value
[in]pointCoordinates of the point at which the linear velocity is being calculated
[in]rotation_axis_directionDirection of the rotation axis. In 2D, we apply a rotation around the z-axis.
Returns
Linear velocity at point

Definition at line 490 of file lethe_grid_tools.h.

◆ cell_cut_by_flat()

template<int dim>
bool LetheGridTools::cell_cut_by_flat ( const typename DoFHandler< dim >::active_cell_iterator & cell,
const typename DoFHandler< dim - 1, dim >::active_cell_iterator & cell_flat )

Return a bool that indicates if a cell is cut by a flat cell.

Parameters
cellThe cell that we want to check.
cell_flatThe cell that describes the flat.

Definition at line 792 of file lethe_grid_tools.cc.

References cell_pierced_by_edge(), and project_to_d_linear_object().

◆ cell_pierced_by_edge() [1/2]

template<int dim>
bool LetheGridTools::cell_pierced_by_edge ( const typename DoFHandler< dim >::active_cell_iterator & cell,
const TriaIterator< CellAccessor< 1, dim > > & cell_edge )

Return a bool that say if a cell is cut by a edge cell.

Parameters
cellThe cell that we want to check.
cell_edgeThe cell that describes the edge.

Definition at line 430 of file lethe_grid_tools.cc.

◆ cell_pierced_by_edge() [2/2]

template<int dim>
bool LetheGridTools::cell_pierced_by_edge ( const typename DoFHandler< dim >::active_cell_iterator & cell,
Point< dim > point_1,
Point< dim > point_2 )

Return a bool that say if a cell is cut by a edge cell.

Parameters
cellThe cell that we want to check.
point_1The first point that describes the edge
point_2The second point that describes the edge

Definition at line 531 of file lethe_grid_tools.cc.

References cell_pierced_by_edge().

◆ find_boundary_cells_in_sphere()

template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > LetheGridTools::find_boundary_cells_in_sphere ( const DoFHandler< dim > & dof_handler,
const Point< dim > & center,
const double radius )

Function returns all the boundary cells with at least one vertex in a sphere.

Parameters
dof_handlerthe dof handler containing all the elements.
centerThe center of the sphere.
radiusThe radius of the sphere.

Definition at line 253 of file lethe_grid_tools.cc.

◆ find_cell_around_point_with_neighbors()

template<int dim>
DoFHandler< dim >::active_cell_iterator LetheGridTools::find_cell_around_point_with_neighbors ( const DoFHandler< dim > & dof_handler,
std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > & vertices_cell_map,
const typename DoFHandler< dim >::active_cell_iterator & cell,
const Point< dim > & point )

Return the cell around a point based on an initial guess of a nearby cell.

Parameters
cellThe initial cell. We suspect that the point is in one of the neighbours of this cell.
pointThe point around which we want to find the cell.
vertices_cell_mapsee vertices_cell_mapping function description.

Definition at line 340 of file lethe_grid_tools.cc.

References find_cell_around_point_with_tree(), and find_cells_around_cell().

◆ find_cell_around_point_with_tree()

template<int dim>
DoFHandler< dim >::active_cell_iterator LetheGridTools::find_cell_around_point_with_tree ( const DoFHandler< dim > & dof_handler,
const Point< dim > & point )

Return the cell around a point by starting from the least refined level and iterating over children.

Parameters
pointThe point around which we want to find the cell.

Definition at line 146 of file lethe_grid_tools.cc.

◆ find_cells_around_cell() [1/2]

template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > LetheGridTools::find_cells_around_cell ( std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > & vertices_cell_map,
const typename DoFHandler< dim >::active_cell_iterator & cell )

Return a vector of cells around a cell. The vector of cells includes all the cells that share a vertex with the initial cell, including the initial cell.

Parameters
cellThe initial cell. We want to know all the cells that share a vertex with this cell.
vertices_cell_mapsee vertices_cell_mapping function description.

Definition at line 367 of file lethe_grid_tools.cc.

◆ find_cells_around_cell() [2/2]

template<int dim, int spacedim = dim>
std::vector< typename Triangulation< dim, spacedim >::active_cell_iterator > LetheGridTools::find_cells_around_cell ( std::map< unsigned int, std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > & vertices_cell_map,
const typename Triangulation< dim, spacedim >::active_cell_iterator & cell )

Return a vector of cells around a cell. This vector includes all the cells that share a vertex with the initial cell, including the initial cell.

Parameters
cellThe initial cell. We want to know all the cells that share a vertex with this cell.
vertices_cell_mapMap of vertex ids to the set of neighbor cells.

Definition at line 1916 of file lethe_grid_tools.cc.

◆ find_cells_around_edge()

template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > LetheGridTools::find_cells_around_edge ( const DoFHandler< dim > & dof_handler,
std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > & vertices_cell_map,
const typename DoFHandler< dim >::active_cell_iterator & cell,
Point< dim > & point_1,
Point< dim > & point_2 )

Return a vector of cells around an edge cell in spacedim. An edge cell as a dim of 1.

Parameters
point_1The first point that describes the edge
point_2The second point that describes the edge
vertices_cell_mapsee vertices_cell_mapping function description.

Definition at line 683 of file lethe_grid_tools.cc.

References cell_pierced_by_edge(), find_cell_around_point_with_tree(), find_cells_around_cell(), and find_cells_around_flat_cell().

◆ find_cells_around_flat_cell()

template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > LetheGridTools::find_cells_around_flat_cell ( const DoFHandler< dim > & dof_handler,
const typename DoFHandler< dim - 1, dim >::active_cell_iterator & cell,
std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > & vertices_cell_map )

Return a vector of cells around a flat cell in spacedim. A flat cell has a dim of spacedim-1.

Parameters
cellThe cell that describes the flat. We want to know all the cells that are cut by the flat.
vertices_cell_mapsee vertices_cell_mapping function description.

Definition at line 914 of file lethe_grid_tools.cc.

References cell_cut_by_flat(), find_cell_around_point_with_tree(), and find_cells_around_cell().

◆ find_cells_cut_by_object()

template<int spacedim, int structdim>
std::map< typename DoFHandler< spacedim >::active_cell_iterator, std::map< unsigned int, typename DoFHandler< structdim, spacedim >::active_cell_iterator > > LetheGridTools::find_cells_cut_by_object ( const DoFHandler< spacedim > & dof_handler,
std::map< unsigned int, std::set< typename DoFHandler< spacedim >::active_cell_iterator > > & vertices_cell_map,
std::vector< SerialSolid< structdim, spacedim > > & list_of_objects )

Function returns all the cells cut by a list of object defined by a mesh.

Parameters
dof_handlerthe dof handler containing all the elements.
vertices_cell_mapAn objects that maps the vertices to cells.
list_of_objectsSolid objects

Definition at line 993 of file lethe_grid_tools.cc.

References find_cells_around_flat_cell().

◆ find_cells_in_cells()

template<int dim>
std::vector< typename DoFHandler< dim >::active_cell_iterator > LetheGridTools::find_cells_in_cells ( const DoFHandler< dim > & dof_handler,
const typename DoFHandler< dim >::active_cell_iterator & cell )

Return a vector of cells from the dof_handler that are inside a cell from another mesh.

Parameters
cellDescribes the volume for which we want to obtain the enclosed cells.

Definition at line 394 of file lethe_grid_tools.cc.

◆ find_line_sphere_intersection()

template<int dim>
std::vector< Point< dim > > LetheGridTools::find_line_sphere_intersection ( const Point< dim > & line_start,
const Tensor< 1, dim > & line_direction,
const Point< dim > & sphere_center,
const double & sphere_diameter )

Calculates the intersection points between a line and a sphere. The full calculation is taken from Geometric Tools for Computer Graphics, Eberly 2003 Chapter 11.3.2 - LINEAR COMPONENTS AND A SPHERE. The entire reference is available at: https://www.sciencedirect.com/science/article/pii/B978155860594750014X.

Parameters
[in]line_startThe starting point of the line
[in]line_directionThe direction of the line
[in]sphere_centerThe center of the sphere
[in]sphere_diameterThe diameter of the sphere
Returns
A vector of points that are the intersection points between the line and the sphere. The vector can be empty if there is no intersection, or contain one or two points if there is an intersection.

Definition at line 1725 of file lethe_grid_tools.cc.

◆ find_particle_triangle_projection()

template<int dim>
std::tuple< bool, Point< 3 >, Tensor< 1, 3 >, ParticleTriangleContactIndicator > LetheGridTools::find_particle_triangle_projection ( const TriangleProjectionData< dim > & triangle_data,
const Point< dim > & particle_position,
const double cutoff_distance )

Finds the contact point between a triangle (defined using three vertices) and a particle center, the normal contact vector and the contact type. The particle center is first compared to the plane formed by the triangle. If the particle is farther from the plane than the defined cutoff distance, the function returns right away with a "pass_distance_check = false". Otherwise, the full contact point calculation is taken from Geometric Tools for Computer Graphics, Eberly 2003 Chapter 10.3.2 - Point to triangle. The entire reference is available at: https://www.sciencedirect.com/science/article/pii/B9781558605947500138 A full implementation of the above reference is also available here: https://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf Variables name are taken straight from this reference to ensure a better readability.

Template Parameters
dimAn integer that denotes the number of spatial dimensions.
Parameters
triangle_dataPrecomputed particle-independent geometric data of the triangle, from prepare_triangle_projection_data. Reusing it across several particles tested against the same triangle avoids recomputing this triangle's edge vectors, normal and fundamental-form coefficients for each particle.
particle_positionLocation of the particle center.
cutoff_distanceLargest distance between the particle center and the plane of the triangle for which the projection is calculated.
Returns
A tuple in which: 0. a bool that is true if the particle center is at most cutoff_distance away from the triangle plane, 1. a projected location of the particle on the triangle, 2. a normal contact vector between the triangle and the particle, 3. a contact type between the particle and the triangle. When the bool is false, the projected location and the normal vector are zero and the contact type is no_contact.

◆ find_point_line_distance()

template<int dim>
double LetheGridTools::find_point_line_distance ( const Point< dim > & line_origin,
const Tensor< 1, dim > & line_direction,
const Point< dim > & point )
inline

Calculate the minimum distance between a point and a line (defined using its orign and direction). The full calculation is taken from Geometric Tools for Computer Graphics, Eberly 2003 Chapter 10.2 - Point to linear component. The entire reference is available at: https://www.sciencedirect.com/science/article/pii/B9781558605947500138 A full implementation of the above reference is also available here: https://www.geometrictools.com/Documentation/DistancePointLine.pdf Variables name are taken straight from this reference to ensure a better readability.

Returns
A distance
Parameters
[in]line_originOrigin of the line (any point on the line)
[in]line_directionVector tangent to the line
[in]pointA point for which we want to find the minimum distance to the line

return distance

Definition at line 446 of file lethe_grid_tools.h.

◆ find_point_triangle_distance()

template<int dim>
double LetheGridTools::find_point_triangle_distance ( const std::vector< Point< dim > > & triangle_vertices,
const Point< dim > & point )

Calculates the distance between points and a triangle (defined using three vertices). The full calculation is taken from Geometric Tools for Computer Graphics, Eberly 2003 Chapter 10.3.2 - Point to triangle. The entire reference is available at: https://www.sciencedirect.com/science/article/pii/B9781558605947500138 A full implementation of the above reference is also available here: https://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf Variables name are taken straight from this reference to ensure a better readability.

Returns
A distance
Parameters
triangle_verticesA vector of points that defines a triangle
pointA point for which we want to find the distance to the triangle

Definition at line 1514 of file lethe_grid_tools.cc.

◆ flag_cells_in_refinement_box()

template<int dim>
void LetheGridTools::flag_cells_in_refinement_box ( const DoFHandler< dim > & dof_handler,
const Triangulation< dim > & box_triangulation )

Flag for refinement of all the cells of a triangulation which lie within a refinement box.

Parameters
[in]dof_handlerThe DoFHandler of the triangulation whose cells must be flagged. No dofs need to be distributed on it, since the search is purely geometric.
[in]box_triangulationThe triangulation delimiting the refinement box, as built by build_refinement_box_triangulation()
Remarks
Only the refinement flags are set. It is up to the caller to execute the coarsening and refinement of the triangulation, since the solvers must transfer their solutions across it.

Definition at line 1973 of file lethe_grid_tools.cc.

References find_cells_in_cells().

◆ prepare_triangle_projection_data()

template<int dim>
TriangleProjectionData< dim > LetheGridTools::prepare_triangle_projection_data ( const std::vector< Point< dim > > & triangle)

Precomputes the particle-independent geometric data of a triangle (see TriangleProjectionData) used by find_particle_triangle_projection.

Template Parameters
dimAn integer that denotes the number of spatial dimensions.
Parameters
triangleA vector of points that defines a triangle
Returns
The precomputed triangle data.

◆ project_to_d_linear_object()

template<int spacedim, int structdim>
std::pair< std::pair< Point< spacedim >, bool >, Tensor< 1, spacedim > > LetheGridTools::project_to_d_linear_object ( const typename DoFHandler< structdim, spacedim >::active_cell_iterator & object,
const Point< spacedim > & trial_point )

A copy of the project_to_d_linear from dealii that also outputs the normal of the flat.

Parameters
objectThe flat or the edge.
trial_pointThe point we project on the flat or edge

Definition at line 562 of file lethe_grid_tools.cc.

◆ rotate_mapping()

template<int dim>
void LetheGridTools::rotate_mapping ( const DoFHandler< dim > & dof_handler,
MappingQCache< dim > & mapping_cache,
const Mapping< dim > & mapping,
const double rotation_angle,
const Point< dim > & center_of_rotation = Point<dim>(),
const unsigned int rotation_axis_direction = 2 )

Rotate the mapping according to the rotation angle in a rotor-stator configuration.

Parameters
[in]dof_handlerDofHandler of the triangulation
[in,out]mapping_cacheRotated mapping
[in]mappingCurrent mapping
[in]rotation_angleRotation angle of the rotor domain
[in]center_of_rotationCenter of rotation of the rotor domain. Default is the origin
[in]rotation_axis_directionDirection of the rotation axis

Definition at line 1787 of file lethe_grid_tools.cc.

◆ vertices_cell_mapping() [1/2]

template<int dim>
void LetheGridTools::vertices_cell_mapping ( const DoFHandler< dim > & dof_handler,
std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > & vertices_cell_map )

Map the vertex index to the cells that includes that vertex.

Parameters
dof_handlerDofHandler of the triangulation on which to create the map
vertices_cell_mapThe map container of vertex ids with its set of neighbor cells

Definition at line 22 of file lethe_grid_tools.cc.

◆ vertices_cell_mapping() [2/2]

template<int dim, int spacedim>
void LetheGridTools::vertices_cell_mapping ( const Triangulation< dim, spacedim > & tria,
std::map< unsigned int, std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > > & vertices_cell_map )

Map the vertex index to the cells which include that vertex.

Parameters
triaTriangulation
vertices_cell_mapThe map container of vertex ids with its set of neighbor cells.

Definition at line 1861 of file lethe_grid_tools.cc.

◆ vertices_cell_mapping_with_periodic_boundaries()

template<int dim>
void LetheGridTools::vertices_cell_mapping_with_periodic_boundaries ( const DoFHandler< dim > & dof_handler,
std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > & vertices_cell_map )

Map the vertex index to the cells on periodic boundaries that includes the periodic coinciding vertex.

Parameters
dof_handlerDofHandler of the triangulation on which to create the map
vertices_cell_mapThe map of vertex ids at periodic boundary to the set of periodic neighbor cells

Definition at line 53 of file lethe_grid_tools.cc.