Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::geometry Namespace Reference

Namespaces

namespace  internal
 Helpers implementing VulPoly's Voronoi construction and cleanup.
namespace  dist2d
namespace  dist3d
namespace  mesh2d
namespace  mesh3d
namespace  vulpoly
 VulPoly meshing options and algorithm parameters.

Classes

class  AbstractAgglomerationModel
 Defines an abstract interface for mesh agglomeration strategies. More...
class  GNNAgglomeration
 GNN-based agglomeration model (GraphSAGE via TorchScript). More...
class  GNNGraph
 Graph wrapper with Torch tensors for features and edges. More...
class  KMeansAgglomeration
 Agglomeration model that clusters cell barycenters with K-Means. More...
class  ParmetisAgglomeration
 Agglomeration model that delegates partitioning to ParMETIS. More...
class  Cell2D
class  Cell3D
class  DistanceExpression
 Template class representing a generic signed distance expression. More...
class  UnionDistance
 Represents the union of two signed distance functions. More...
class  IntersectDistance
 Represents the intersection of two signed distance functions. More...
class  DifferenceDistance
 Represents the difference of two signed distance functions. More...
class  KMeansBase
 Base class template for KMeans clustering algorithms. More...
class  KMeansNaive
 Implementation of the Lloyd algorithm (also known as the naive KMeans) for clustering. More...
class  MappingBase
class  CartesianMapping
class  SimplexMapping
class  Mesh2D
 A class for a 2D mesh, inheriting from MeshBase. More...
class  Mesh3D
 Represents a 3D mesh. More...
 A structure to store global metadata. More...
struct  MeshTag
 A structure to store tags for different parts of a mesh. More...
class  MeshBase
 A base class for creating and managing mesh data structures. More...
struct  VtuOptions
 Configuration options for VTU file export. More...
class  MeshExporterBase
 Base class for exporting a mesh to VTK file formats. More...
class  MeshExporter
 Exports a single mesh as a single VTK grid. More...
class  MeshExporterSubmesh
 Exports a mesh as multiple VTK grids, one for each cell. More...
class  MeshMetrics
 A class template that can be used to compute various mesh metrics (CircleRatio, AreaToPerimeterRatio, UniformityRatio, VolumeDifference). More...
class  ParallelMesh
 This class wraps a serial mesh class and adds attributes and methods for parallelization. More...
class  Triangulation
 Performs triangulation of a 2D cell using the Triangle library. More...
class  Tetrahedralization
 Performs tetrahedralization of a 3D cell using the TetGen library. More...
class  Simplexify
 A templated class that simplifies a geometric cell into simplices (triangles or tetrahedra). More...

Typedefs

using CellInitOptionsType = std::underlying_type_t<CellInitOptions>
template<std::size_t Dim, typename FloatType, typename IndexType, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
using Cell
using MetricsInitOptionsType = std::underlying_type_t<MetricsInitOptions>
template<typename DataType, int Dim>
using Point = Eigen::Matrix<DataType, Dim, 1, Eigen::ColMajor>
template<int32_t Dim, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
using VoronoiCell
 Alias for the Voronoi cell type based on the dimensionality (2D or 3D).

Enumerations

enum  MethodType { BisectNRef , MultFactor , DirectKWay , SegregateBisection }
enum class  SAGEType { Base = 0 , Heterogeneous }
 Variants of pretrained GraphSAGE models supported by this backend. More...
enum class  KMeansAlgType : u_int32_t { Base }
 K-Means algorithm types. More...
enum  CellInitOptions : uint32_t {
  CellInitVtxOnly = 0ULL , CellInitNormals = (1ULL << 0ULL) , CellInitLocalMaps = (1ULL << 1ULL) , CellInitInverseMaps = (1ULL << 2ULL) ,
  CellInitEdgeToCompute = (1ULL << 3ULL) , CellInitFaces = (1ULL << 4ULL) , CellInitBBox = (1ULL << 5ULL) , CellInitDiameter = (1ULL << 6ULL) ,
  CellInitMeasure = (1ULL << 7ULL) , CellInitBarycenter = (1ULL << 8ULL) , CellInitFaceDiameter = (1ULL << 9ULL) , CellInitFaceKb = (1ULL << 10ULL) ,
  CellInitInscribedDiameter = (1ULL << 11ULL) , CellInitAll = 0xFFFFFFFFUL
}
enum  DataMode : std::uint8_t { Ascii = vtkXMLWriterBase::Ascii , Binary = vtkXMLWriterBase::Binary , Base64 = vtkXMLWriterBase::Appended }
 Specifies the data mode for writing XML files. More...
enum  CoordinatePrecision : std::uint8_t { Float32 = VTK_FLOAT , Float64 = VTK_DOUBLE }
 Specifies the precision for point coordinates in VTU files. More...
enum  MetricId : uint32_t { CircleRatioID = 0ULL , AreaPerimeterRatioID , UniformityFactorID , VolumeDifferenceID }
 An enum that definies the indexes of various metrics in the global metrics array. More...
enum  MetricsInitOptions : uint32_t {
  CircleRatio = (1ULL << CircleRatioID) , AreaPerimeterRatio = (1ULL << AreaPerimeterRatioID) , UniformityFactor = (1ULL << UniformityFactorID) , VolumeDifference = (1ULL << VolumeDifferenceID) ,
  AllMetrics = 0xFFFFFFFFUL
}
 An enum that can be used to specify the metrics that we desire to be computed. More...

Functions

template<typename FloatType, int32_t Dim, typename D1, typename D2>
UnionDistance< FloatType, Dim, D1, D2 > operator| (const DistanceExpression< FloatType, Dim, D1 > &u, const DistanceExpression< FloatType, Dim, D2 > &v)
 Create a union of two signed distance functions.
template<typename FloatType, int32_t Dim, typename D1, typename D2>
IntersectDistance< FloatType, Dim, D1, D2 > operator& (const DistanceExpression< FloatType, Dim, D1 > &u, const DistanceExpression< FloatType, Dim, D2 > &v)
 Create an intersection of two signed distance functions.
template<typename FloatType, int32_t Dim, typename D1, typename D2>
DifferenceDistance< FloatType, Dim, D1, D2 > operator- (const DistanceExpression< FloatType, Dim, D1 > &u, const DistanceExpression< FloatType, Dim, D2 > &v)
 Create a difference of two distance functions.
template<typename FloatType, int32_t Dim, typename D>
auto computeDistance (const Point< FloatType, Dim > &point, const DistanceExpression< FloatType, Dim, D > &distance_function)
 Computes the signed distance between a point and a shape defined by a distance function.
template<typename T, size_t Dim>
Eigen::Matrix< T, Dim, Eigen::Dynamic > centersRandomPointPick (const Eigen::Matrix< T, Dim, Eigen::Dynamic > &X, size_t K, int32_t seed=0)
template<typename T, int Dim>
Eigen::Matrix< T, Dim, Eigen::Dynamic > centersRandomPointPickMap (Eigen::Map< const Eigen::Matrix< T, Dim, Eigen::Dynamic > > X, size_t K, int32_t seed=0)
template<typename T, int Dim>
Eigen::Matrix< T, Dim, Eigen::Dynamic > centersKMeansPP (Eigen::Map< const Eigen::Matrix< T, Dim, Eigen::Dynamic > > X, size_t K, int32_t seed=0)
template<typename T, int Dim>
Eigen::Matrix< T, Dim, Eigen::Dynamic > centersMaximin (Eigen::Map< const Eigen::Matrix< T, Dim, Eigen::Dynamic > > X, size_t K, int32_t seed=0)
template<typename T, int Dim>
std::vector< T > computeClosestCtrToCtrDist (const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat)
template<std::size_t Dim>
Eigen::Array< double, Dim, 1 > computePeriodicShift (const Eigen::Matrix< double, Dim, 2 > &curr_bbox, const Eigen::Matrix< double, Dim, 2 > &neigh_bbox, const Eigen::Array< double, Dim, 1 > &period)
 Compute periodic shift between two cells based on bboxes.
template<typename MeshType>
void exportMesh (const MeshType &mesh, const std::string &filename)
template<typename MeshDerived>
bool shouldModifyPeriodicMesh (const MeshDerived &mesh)
 Determines if a periodic mesh should be modified for export.
template<typename ScalarType, typename IndexType>
Mesh2D< ScalarType, IndexType > reopenPeriodicMeshForExport (const Mesh2D< ScalarType, IndexType > &mesh)
 Reopens a closed 2D periodic mesh for export.
void voronoi2D (const std::array< Point< double, 2 >, 2 > &bbox, const std::vector< Point< double, 2 > > &points, const std::function< void(voro::voronoicell_neighbor_2d &cell, int32_t id)> &cell_callback)
 Computes a 2D Voronoi tessellation for a given set of points within a bounding box.
void voronoi3D (const std::array< Point< double, 3 >, 2 > &bbox, const std::vector< Point< double, 3 > > &points, const std::function< void(voro::voronoicell_neighbor &cell, int32_t id)> &cell_callback)
 Computes a 3D Voronoi tessellation for a given set of points within a bounding box.
template<int32_t Dim, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
void voronoi (const std::array< Point< double, Dim >, 2 > &bbox, std::vector< Point< double, Dim > > &points, const std::function< void(VoronoiCell< Dim > &cell, int32_t id)> &cell_callback)
 Computes a Voronoi tessellation in either 2D or 3D space.

Typedef Documentation

◆ Cell

template<std::size_t Dim, typename FloatType, typename IndexType, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
using vulpes::geometry::Cell
Initial value:
std::conditional_t<
Dim == 2,
Definition cell.hpp:98
Definition cell.hpp:151

◆ CellInitOptionsType

using vulpes::geometry::CellInitOptionsType = std::underlying_type_t<CellInitOptions>

◆ MetricsInitOptionsType

◆ Point

template<typename DataType, int Dim>
using vulpes::geometry::Point = Eigen::Matrix<DataType, Dim, 1, Eigen::ColMajor>

◆ VoronoiCell

template<int32_t Dim, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
using vulpes::geometry::VoronoiCell
Initial value:
std::conditional_t<
Dim == 2,
voro::voronoicell_neighbor_2d,
voro::voronoicell_neighbor>

Alias for the Voronoi cell type based on the dimensionality (2D or 3D).

This template alias defines the appropriate type of Voronoi cell (either 2D or 3D) based on the provided dimensionality Dim. For Dim == 2, it resolves to voro::voronoicell_neighbor_2d, and for Dim == 3, it resolves to voro::voronoicell_neighbor.

Template Parameters
DimDimensionality of the Voronoi tessellation. Must be either 2 or 3.

Enumeration Type Documentation

◆ CellInitOptions

Enumerator
CellInitVtxOnly 
CellInitNormals 
CellInitLocalMaps 
CellInitInverseMaps 
CellInitEdgeToCompute 
CellInitFaces 
CellInitBBox 
CellInitDiameter 
CellInitMeasure 
CellInitBarycenter 
CellInitFaceDiameter 
CellInitFaceKb 
CellInitInscribedDiameter 
CellInitAll 

◆ CoordinatePrecision

Specifies the precision for point coordinates in VTU files.

This enum defines different precision levels for storing point coordinates, which affects file size and geometric accuracy.

Enumerator
Float32 

32-bit floating-point precision (float).

Smaller file size, suitable for most applications.

Float64 

64-bit floating-point precision (double).

Larger file size, required for high-precision geometric applications.

◆ DataMode

enum vulpes::geometry::DataMode : std::uint8_t

Specifies the data mode for writing XML files.

This enum defines different methods for storing data within a VTK XML file, which affects how the data is encoded and compressed.

Enumerator
Ascii 

Data is written as plain text (ASCII).

Binary 

Data is written as raw binary.

Base64 

Data is appended in a Base64-encoded format.

This is generally the recommended mode for efficiency.

◆ KMeansAlgType

enum class vulpes::geometry::KMeansAlgType : u_int32_t
strong

K-Means algorithm types.

  • Base: single-threaded baseline;
Enumerator
Base 

◆ MethodType

Enumerator
BisectNRef 
MultFactor 
DirectKWay 
SegregateBisection 

◆ MetricId

enum vulpes::geometry::MetricId : uint32_t

An enum that definies the indexes of various metrics in the global metrics array.

Enumerator
CircleRatioID 
AreaPerimeterRatioID 
UniformityFactorID 
VolumeDifferenceID 

◆ MetricsInitOptions

An enum that can be used to specify the metrics that we desire to be computed.

This enum can be used with the bitwise operator to specify the metrics we want the MeshMetrics object to compute. If we want to compute all the metrics we can use the AllMetrics value

Enumerator
CircleRatio 
AreaPerimeterRatio 
UniformityFactor 
VolumeDifference 
AllMetrics 

◆ SAGEType

enum class vulpes::geometry::SAGEType
strong

Variants of pretrained GraphSAGE models supported by this backend.

  • Base: homogeneous feature set;
  • Heterogeneous: feature set with material/region heterogeneity.
Enumerator
Base 
Heterogeneous 

Function Documentation

◆ centersKMeansPP()

template<typename T, int Dim>
Eigen::Matrix< T, Dim, Eigen::Dynamic > vulpes::geometry::centersKMeansPP ( Eigen::Map< const Eigen::Matrix< T, Dim, Eigen::Dynamic > > X,
size_t K,
int32_t seed = 0 )

◆ centersMaximin()

template<typename T, int Dim>
Eigen::Matrix< T, Dim, Eigen::Dynamic > vulpes::geometry::centersMaximin ( Eigen::Map< const Eigen::Matrix< T, Dim, Eigen::Dynamic > > X,
size_t K,
int32_t seed = 0 )

◆ centersRandomPointPick()

template<typename T, size_t Dim>
Eigen::Matrix< T, Dim, Eigen::Dynamic > vulpes::geometry::centersRandomPointPick ( const Eigen::Matrix< T, Dim, Eigen::Dynamic > & X,
size_t K,
int32_t seed = 0 )

◆ centersRandomPointPickMap()

template<typename T, int Dim>
Eigen::Matrix< T, Dim, Eigen::Dynamic > vulpes::geometry::centersRandomPointPickMap ( Eigen::Map< const Eigen::Matrix< T, Dim, Eigen::Dynamic > > X,
size_t K,
int32_t seed = 0 )

◆ computeClosestCtrToCtrDist()

template<typename T, int Dim>
std::vector< T > vulpes::geometry::computeClosestCtrToCtrDist ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > & mat)

◆ computeDistance()

template<typename FloatType, int32_t Dim, typename D>
auto vulpes::geometry::computeDistance ( const Point< FloatType, Dim > & point,
const DistanceExpression< FloatType, Dim, D > & distance_function )

Computes the signed distance between a point and a shape defined by a distance function.

This function takes a point and a distance function (which conforms to the DistanceExpression interface) and computes the distance from the point to the shape represented by the distance function. The result is stored in a buffer and returned as a std::array of distances.

Template Parameters
FloatTypeThe type of floating-point value used for distance computation (e.g., float, double).
DimThe dimensionality of the space (e.g., 2 for 2D, 3 for 3D).
DThe type of the distance function, which must inherit from DistanceExpression<FloatType, Dim, D>.
Parameters
pointThe point for which the distance to the shape is to be computed.
distance_functionThe distance function object representing the shape.
Returns
A std::array of distances, where the number of elements is determined by the size of the distance buffer.

◆ computePeriodicShift()

template<std::size_t Dim>
Eigen::Array< double, Dim, 1 > vulpes::geometry::computePeriodicShift ( const Eigen::Matrix< double, Dim, 2 > & curr_bbox,
const Eigen::Matrix< double, Dim, 2 > & neigh_bbox,
const Eigen::Array< double, Dim, 1 > & period )
inline

Compute periodic shift between two cells based on bboxes.

Template Parameters
DimSpatial dimension
Parameters
curr_bboxBounding box of current cell (dim x 2: [min, max])
neigh_bboxBounding box of neighbor cell (dim x 2: [min, max])
periodPeriod in each dimension (0.0 = not periodic)
Returns
Shift vector in PHYSICAL coordinates (+/- period per wrapped dimension)

Detects if neighbor cell is a periodic wrap by checking if center distance > period/2. Returns +/- period (in physical coordinates) for each wrapped dimension. The caller should apply jacobian_neigh_inv transformation to convert to neighbor ref space.

◆ exportMesh()

template<typename MeshType>
void vulpes::geometry::exportMesh ( const MeshType & mesh,
const std::string & filename )

◆ operator&()

template<typename FloatType, int32_t Dim, typename D1, typename D2>
IntersectDistance< FloatType, Dim, D1, D2 > vulpes::geometry::operator& ( const DistanceExpression< FloatType, Dim, D1 > & u,
const DistanceExpression< FloatType, Dim, D2 > & v )

Create an intersection of two signed distance functions.

Template Parameters
FloatTypeThe type of floating-point value.
DimThe dimensionality of the space.
D1The first distance function.
D2The second distance function.
Parameters
uThe first distance function object.
vThe second distance function object.
Returns
An IntersectDistance object representing the intersection of the two shapes.

◆ operator-()

template<typename FloatType, int32_t Dim, typename D1, typename D2>
DifferenceDistance< FloatType, Dim, D1, D2 > vulpes::geometry::operator- ( const DistanceExpression< FloatType, Dim, D1 > & u,
const DistanceExpression< FloatType, Dim, D2 > & v )

Create a difference of two distance functions.

Template Parameters
FloatTypeThe type of floating-point value.
DimThe dimensionality of the space.
D1The first distance function.
D2The second distance function.
Parameters
uThe first distance function object.
vThe second distance function object.
Returns
A DifferenceDistance object representing the difference of the two shapes.

◆ operator|()

template<typename FloatType, int32_t Dim, typename D1, typename D2>
UnionDistance< FloatType, Dim, D1, D2 > vulpes::geometry::operator| ( const DistanceExpression< FloatType, Dim, D1 > & u,
const DistanceExpression< FloatType, Dim, D2 > & v )

Create a union of two signed distance functions.

Template Parameters
FloatTypeThe type of floating-point value.
DimThe dimensionality of the space.
D1The first distance function.
D2The second distance function.
Parameters
uThe first distance function object.
vThe second distance function object.
Returns
A UnionDistance object representing the union of the two shapes.

◆ reopenPeriodicMeshForExport()

template<typename ScalarType, typename IndexType>
Mesh2D< ScalarType, IndexType > vulpes::geometry::reopenPeriodicMeshForExport ( const Mesh2D< ScalarType, IndexType > & mesh)

Reopens a closed 2D periodic mesh for export.

This function creates a copy of the input mesh and reopens its periodic topology by restoring ghost cells. Only called for 2D periodic meshes that are in the closed state.

Template Parameters
ScalarTypeThe scalar type of the mesh (typically double).
IndexTypeThe index type of the mesh.
Parameters
meshThe closed periodic 2D mesh to reopen.
Returns
A reopened copy of the input mesh with periodic ghost cells restored.

◆ shouldModifyPeriodicMesh()

template<typename MeshDerived>
bool vulpes::geometry::shouldModifyPeriodicMesh ( const MeshDerived & mesh)

Determines if a periodic mesh should be modified for export.

A 2D mesh should be modified if it is a closed periodic mesh that would benefit from reopening for better visualization. Checks if the mesh is periodic and in the closed state (has MeshPeriodicTopologyClosed = 1).

Template Parameters
MeshDerivedThe derived mesh class.
Parameters
meshThe mesh to check.
Returns
true if the mesh should be modified, false otherwise.

◆ voronoi()

template<int32_t Dim, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
void vulpes::geometry::voronoi ( const std::array< Point< double, Dim >, 2 > & bbox,
std::vector< Point< double, Dim > > & points,
const std::function< void(VoronoiCell< Dim > &cell, int32_t id)> & cell_callback )

Computes a Voronoi tessellation in either 2D or 3D space.

This function is a general wrapper that selects between 2D and 3D Voronoi tessellation based on the template parameter Dim. It calls either voronoi2D or voronoi3D internally.

Template Parameters
DimDimensionality of the Voronoi tessellation. Must be either 2 or 3.
Parameters
bboxA bounding box defined by two corner points. The array should contain two Point<double, Dim> values representing the corners of the bounding box.
pointsA vector of Point<double, Dim> representing the coordinates of the points for which the Voronoi diagram is to be computed.
cell_callbackA function callback that is invoked for each generated Voronoi cell. The callback function takes two parameters: the generated VoronoiCell<Dim> and an integer representing the ID of the cell.

◆ voronoi2D()

void vulpes::geometry::voronoi2D ( const std::array< Point< double, 2 >, 2 > & bbox,
const std::vector< Point< double, 2 > > & points,
const std::function< void(voro::voronoicell_neighbor_2d &cell, int32_t id)> & cell_callback )

Computes a 2D Voronoi tessellation for a given set of points within a bounding box.

This function utilizes the Voro++ library to generate Voronoi cells in a 2D space. Each generated Voronoi cell is passed to the provided callback function for further processing.

Parameters
bboxA bounding box defined by two corner points. The array should contain two Point<double, 2> values representing the lower-left and upper-right corners.
pointsA vector of Point<double, 2> representing the coordinates of the points for which the Voronoi diagram is to be computed.
cell_callbackA function callback that is invoked for each generated Voronoi cell. The callback function takes two parameters: the generated voro::voronoicell_neighbor_2d and an integer representing the ID of the cell.

◆ voronoi3D()

void vulpes::geometry::voronoi3D ( const std::array< Point< double, 3 >, 2 > & bbox,
const std::vector< Point< double, 3 > > & points,
const std::function< void(voro::voronoicell_neighbor &cell, int32_t id)> & cell_callback )

Computes a 3D Voronoi tessellation for a given set of points within a bounding box.

This function utilizes the Voro++ library to generate Voronoi cells in a 3D space. Each generated Voronoi cell is passed to the provided callback function for further processing.

Parameters
bboxA bounding box defined by two corner points. The array should contain two Point<double, 3> values representing the lower-front-left and upper-back-right corners.
pointsA vector of Point<double, 3> representing the coordinates of the points for which the Voronoi diagram is to be computed.
cell_callbackA function callback that is invoked for each generated Voronoi cell. The callback function takes two parameters: the generated voro::voronoicell_neighbor and an integer representing the ID of the cell.