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

Namespaces

namespace  internal

Functions

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > intersectCartesianGrid (const Mesh2D< FloatType, IndexType > &mesh, const std::array< std::vector< FloatType >, 2 > &grids, FloatType agglomeration_threshold=0.25)
 Creates a new mesh by intersecting an existing mesh with a Cartesian grid.
template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > mergeMeshes (const Mesh2D< FloatType, IndexType > &mesh_a, const Mesh2D< FloatType, IndexType > &mesh_b, FloatType atol=0.0, FloatType rtol=1e-4)
 Merges two separate meshes into a single mesh.
template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > read (const std::string &filename, bool check_vtxs_unique=true, bool add_tags=true)
 Reads a mesh from a .vtk or .vtu file and creates a Mesh2D object.
template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > rectangle (const Point< FloatType, 2 > &corner_a, const Point< FloatType, 2 > &corner_b, const Point< IndexType, 2 > &n_divisions, bool tria_elements=false)
 Creates a simple rectangular mesh.
template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > collapseEdges (const Mesh2D< FloatType, IndexType > &mesh, FloatType edge_collapse_tol)
 Remove edges smaller than a given tolerance.
template Mesh2D< double, int32_t > intersectCartesianGrid< double, int32_t > (const Mesh2D< double, int32_t > &, const std::array< std::vector< double >, 2 > &, double)
template Mesh2D< double, int32_t > mergeMeshes< double, int32_t > (const Mesh2D< double, int32_t > &, const Mesh2D< double, int32_t > &, double, double)
template Mesh2D< double, int32_t > collapseEdges (const Mesh2D< double, int32_t > &, double)
template Mesh2D< double, int32_t > read< double, int32_t > (const std::string &, bool, bool)
template Mesh2D< double, uint32_t > read< double, uint32_t > (const std::string &, bool, bool)
template Mesh2D< double, int64_t > read< double, int64_t > (const std::string &, bool, bool)
template Mesh2D< double, uint64_t > read< double, uint64_t > (const std::string &, bool, bool)
template Mesh2D< double, int32_t > rectangle< double, int32_t > (const Point< double, 2 > &, const Point< double, 2 > &, const Point< int32_t, 2 > &, bool)
template Mesh2D< double, uint32_t > rectangle< double, uint32_t > (const Point< double, 2 > &, const Point< double, 2 > &, const Point< uint32_t, 2 > &, bool)
template Mesh2D< double, int64_t > rectangle< double, int64_t > (const Point< double, 2 > &, const Point< double, 2 > &, const Point< int64_t, 2 > &, bool)
template Mesh2D< double, uint64_t > rectangle< double, uint64_t > (const Point< double, 2 > &, const Point< double, 2 > &, const Point< uint64_t, 2 > &, bool)
template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > rectangle_periodic (const Point< FloatType, 2 > &corner_a, const Point< FloatType, 2 > &corner_b, const Point< IndexType, 2 > &n_divisions, bool tria_elements=false, bool x_periodic=true, bool y_periodic=true)
 Creates a rectangular mesh and directly annotates it as periodic.
template Mesh2D< double, int32_t > rectangle_periodic< double, int32_t > (const Point< double, 2 > &, const Point< double, 2 > &, const Point< int32_t, 2 > &, bool, bool, bool)
template Mesh2D< double, uint32_t > rectangle_periodic< double, uint32_t > (const Point< double, 2 > &, const Point< double, 2 > &, const Point< uint32_t, 2 > &, bool, bool, bool)
template Mesh2D< double, int64_t > rectangle_periodic< double, int64_t > (const Point< double, 2 > &, const Point< double, 2 > &, const Point< int64_t, 2 > &, bool, bool, bool)
template Mesh2D< double, uint64_t > rectangle_periodic< double, uint64_t > (const Point< double, 2 > &, const Point< double, 2 > &, const Point< uint64_t, 2 > &, bool, bool, bool)
template<typename FloatType, typename IndexType>
bool isPeriodic (const Mesh2D< FloatType, IndexType > &mesh)
template bool isPeriodic< double, int32_t > (const Mesh2D< double, int32_t > &)
template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > closePeriodicTopology (const Mesh2D< FloatType, IndexType > &mesh)
template Mesh2D< double, int32_t > closePeriodicTopology< double, int32_t > (const Mesh2D< double, int32_t > &)
template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > openPeriodicTopology (const Mesh2D< FloatType, IndexType > &mesh)
template Mesh2D< double, int32_t > openPeriodicTopology< double, int32_t > (const Mesh2D< double, int32_t > &)
template<typename FloatType, typename IndexType>
std::vector< Point< FloatType, 2 > > getCellVertexesPeriodic (const Mesh2D< FloatType, IndexType > &mesh, IndexType cell_id)
template std::vector< Point< double, 2 > > getCellVertexesPeriodic< double, int32_t > (const Mesh2D< double, int32_t > &, int32_t)
template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > intersectCartesianGrid (const Mesh2D< FloatType, IndexType > &mesh, IndexType n_cells_x, FloatType stretch=1, FloatType agglomeration_threshold=0.25)
 Creates a new mesh by intersecting an existing mesh with a Cartesian grid.

Function Documentation

◆ closePeriodicTopology()

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::closePeriodicTopology ( const Mesh2D< FloatType, IndexType > & mesh)

Remove ghost points and close the periodic topology of the mesh.

◆ closePeriodicTopology< double, int32_t >()

template Mesh2D< double, int32_t > vulpes::geometry::mesh2d::closePeriodicTopology< double, int32_t > ( const Mesh2D< double, int32_t > & )

◆ collapseEdges() [1/2]

template Mesh2D< double, int32_t > vulpes::geometry::mesh2d::collapseEdges ( const Mesh2D< double, int32_t > & ,
double  )

◆ collapseEdges() [2/2]

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::collapseEdges ( const Mesh2D< FloatType, IndexType > & mesh,
FloatType edge_collapse_tol )

Remove edges smaller than a given tolerance.

Parameters
meshThe mesh.
edge_collapse_tolMinimal edge length to preserve.
Returns
A new Mesh2D without the small edges.

◆ getCellVertexesPeriodic()

template<typename FloatType, typename IndexType>
std::vector< Point< FloatType, 2 > > vulpes::geometry::mesh2d::getCellVertexesPeriodic ( const Mesh2D< FloatType, IndexType > & mesh,
IndexType cell_id )

◆ getCellVertexesPeriodic< double, int32_t >()

template std::vector< Point< double, 2 > > vulpes::geometry::mesh2d::getCellVertexesPeriodic< double, int32_t > ( const Mesh2D< double, int32_t > & ,
int32_t  )

◆ intersectCartesianGrid() [1/2]

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::intersectCartesianGrid ( const Mesh2D< FloatType, IndexType > & mesh,
const std::array< std::vector< FloatType >, 2 > & grids,
FloatType agglomeration_threshold = 0.25 )

Creates a new mesh by intersecting an existing mesh with a Cartesian grid.

This function "cuts" the boundary of the input mesh with the grid lines, resulting in a new, less complex mesh. Small fragments created during intersection with the boundary can be merged into larger cells based on a threshold.

Parameters
meshThe original mesh to intersect.
gridsThe Cartesian grid lines (x and y coordinates).
agglomeration_thresholdA threshold (relative to cell area) below which small cells are merged.
Returns
A new Mesh2D object representing the intersected mesh.

◆ intersectCartesianGrid() [2/2]

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::intersectCartesianGrid ( const Mesh2D< FloatType, IndexType > & mesh,
IndexType n_cells_x,
FloatType stretch = 1,
FloatType agglomeration_threshold = 0.25 )

Creates a new mesh by intersecting an existing mesh with a Cartesian grid.

This function "cuts" the boundary of the input mesh with the grid lines, resulting in a new, less complex mesh. Small fragments created during intersection with the boundary can be merged into larger cells based on a threshold.

Parameters
meshThe original mesh to intersect.
n_cells_xThe number of grid cells to create along the x-axis.
stretchA factor to stretch the grid cells in the y-direction.
agglomeration_thresholdA threshold (relative to cell area) below which small cells are merged.
Returns
A new Mesh2D object representing the intersected mesh.

◆ intersectCartesianGrid< double, int32_t >()

template Mesh2D< double, int32_t > vulpes::geometry::mesh2d::intersectCartesianGrid< double, int32_t > ( const Mesh2D< double, int32_t > & ,
const std::array< std::vector< double >, 2 > & ,
double  )

◆ isPeriodic()

template<typename FloatType, typename IndexType>
bool vulpes::geometry::mesh2d::isPeriodic ( const Mesh2D< FloatType, IndexType > & mesh)

Check if the mesh has the periodic metadata XPeriod and YPeriod; a period of 0 means not periodic in that direction.

◆ isPeriodic< double, int32_t >()

template bool vulpes::geometry::mesh2d::isPeriodic< double, int32_t > ( const Mesh2D< double, int32_t > & )

◆ mergeMeshes()

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::mergeMeshes ( const Mesh2D< FloatType, IndexType > & mesh_a,
const Mesh2D< FloatType, IndexType > & mesh_b,
FloatType atol = 0.0,
FloatType rtol = 1e-4 )

Merges two separate meshes into a single mesh.

This function combines the vertices and cells from two meshes. It can identify and merge vertices that are very close to each other, based on the specified tolerances.

Warning
If the boundaries are not completely matching the merging will fails. This does not mean that the tolerances must be zero but the discretization of the matching boundary must be the same (e.g., you can merge two edges (0, 0)-(1, 0) and (eps, eps)-(1-eps, -eps) but you cannot merge (0,0)-(0.5,0)-(1,0) with (0,0)-(1,0))
Parameters
mesh_aThe first mesh.
mesh_bThe second mesh.
atolAbsolute tolerance for merging vertices.
rtolRelative tolerance for merging vertices.
Returns
A new Mesh2D object containing both input meshes.

◆ mergeMeshes< double, int32_t >()

template Mesh2D< double, int32_t > vulpes::geometry::mesh2d::mergeMeshes< double, int32_t > ( const Mesh2D< double, int32_t > & ,
const Mesh2D< double, int32_t > & ,
double ,
double  )

◆ openPeriodicTopology()

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::openPeriodicTopology ( const Mesh2D< FloatType, IndexType > & mesh)

Reopen periodic topology by restoring ghost vertices and original compressed connectivity from mesh tags/metadata produced by closePeriodicTopology.

◆ openPeriodicTopology< double, int32_t >()

template Mesh2D< double, int32_t > vulpes::geometry::mesh2d::openPeriodicTopology< double, int32_t > ( const Mesh2D< double, int32_t > & )

◆ read()

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::read ( const std::string & filename,
bool check_vtxs_unique = true,
bool add_tags = true )

Reads a mesh from a .vtk or .vtu file and creates a Mesh2D object.

Parameters
filenameThe path to the mesh file.
check_vtxs_uniqueIf true, checks for duplicate vertices and raises warnings.
add_tagsIf true, reads and attaches any tags found in the file.
Returns
A new Mesh2D object loaded from the file.

◆ read< double, int32_t >()

template Mesh2D< double, int32_t > vulpes::geometry::mesh2d::read< double, int32_t > ( const std::string & ,
bool ,
bool  )

◆ read< double, int64_t >()

template Mesh2D< double, int64_t > vulpes::geometry::mesh2d::read< double, int64_t > ( const std::string & ,
bool ,
bool  )

◆ read< double, uint32_t >()

template Mesh2D< double, uint32_t > vulpes::geometry::mesh2d::read< double, uint32_t > ( const std::string & ,
bool ,
bool  )

◆ read< double, uint64_t >()

template Mesh2D< double, uint64_t > vulpes::geometry::mesh2d::read< double, uint64_t > ( const std::string & ,
bool ,
bool  )

◆ rectangle()

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::rectangle ( const Point< FloatType, 2 > & corner_a,
const Point< FloatType, 2 > & corner_b,
const Point< IndexType, 2 > & n_divisions,
bool tria_elements = false )

Creates a simple rectangular mesh.

Parameters
corner_aThe coordinates of one corner of the rectangle.
corner_bThe coordinates of the opposite corner of the rectangle.
n_divisionsThe number of cell divisions along the x and y axes.
tria_elementsIf true, divides each rectangular cell into two triangles.
Returns
A new Mesh2D object representing the rectangle.

◆ rectangle< double, int32_t >()

template Mesh2D< double, int32_t > vulpes::geometry::mesh2d::rectangle< double, int32_t > ( const Point< double, 2 > & ,
const Point< double, 2 > & ,
const Point< int32_t, 2 > & ,
bool  )

◆ rectangle< double, int64_t >()

template Mesh2D< double, int64_t > vulpes::geometry::mesh2d::rectangle< double, int64_t > ( const Point< double, 2 > & ,
const Point< double, 2 > & ,
const Point< int64_t, 2 > & ,
bool  )

◆ rectangle< double, uint32_t >()

template Mesh2D< double, uint32_t > vulpes::geometry::mesh2d::rectangle< double, uint32_t > ( const Point< double, 2 > & ,
const Point< double, 2 > & ,
const Point< uint32_t, 2 > & ,
bool  )

◆ rectangle< double, uint64_t >()

template Mesh2D< double, uint64_t > vulpes::geometry::mesh2d::rectangle< double, uint64_t > ( const Point< double, 2 > & ,
const Point< double, 2 > & ,
const Point< uint64_t, 2 > & ,
bool  )

◆ rectangle_periodic()

template<typename FloatType, typename IndexType>
Mesh2D< FloatType, IndexType > vulpes::geometry::mesh2d::rectangle_periodic ( const Point< FloatType, 2 > & corner_a,
const Point< FloatType, 2 > & corner_b,
const Point< IndexType, 2 > & n_divisions,
bool tria_elements = false,
bool x_periodic = true,
bool y_periodic = true )

Creates a rectangular mesh and directly annotates it as periodic.

This is the periodic counterpart of rectangle. It generates the same Cartesian mesh, adds periodic metadata and vertex Index tags, and returns it with periodic topology already closed.

Added metadata keys:

  • XPeriod, YPeriod (0 in a direction that is not periodic)
  • NumVertices, NumCells, NumEdges
  • NumPeriodicGhosts
  • MeshPeriodicTopologyClosed (set to 1 in the returned mesh)
Parameters
corner_aThe coordinates of one corner of the rectangle.
corner_bThe coordinates of the opposite corner of the rectangle.
n_divisionsThe number of cell divisions along the x and y axes, at least 3 along a periodic direction.
tria_elementsIf true, divides each rectangular cell into two triangles.
x_periodicIf true, the left and right sides are identified.
y_periodicIf true, the bottom and top sides are identified.
Returns
A periodic-ready rectangular Mesh2D with closed topology.
Exceptions
std::invalid_argumentif neither direction is periodic.

◆ rectangle_periodic< double, int32_t >()

template Mesh2D< double, int32_t > vulpes::geometry::mesh2d::rectangle_periodic< double, int32_t > ( const Point< double, 2 > & ,
const Point< double, 2 > & ,
const Point< int32_t, 2 > & ,
bool ,
bool ,
bool  )

◆ rectangle_periodic< double, int64_t >()

template Mesh2D< double, int64_t > vulpes::geometry::mesh2d::rectangle_periodic< double, int64_t > ( const Point< double, 2 > & ,
const Point< double, 2 > & ,
const Point< int64_t, 2 > & ,
bool ,
bool ,
bool  )

◆ rectangle_periodic< double, uint32_t >()

template Mesh2D< double, uint32_t > vulpes::geometry::mesh2d::rectangle_periodic< double, uint32_t > ( const Point< double, 2 > & ,
const Point< double, 2 > & ,
const Point< uint32_t, 2 > & ,
bool ,
bool ,
bool  )

◆ rectangle_periodic< double, uint64_t >()

template Mesh2D< double, uint64_t > vulpes::geometry::mesh2d::rectangle_periodic< double, uint64_t > ( const Point< double, 2 > & ,
const Point< double, 2 > & ,
const Point< uint64_t, 2 > & ,
bool ,
bool ,
bool  )