Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
mesher.hpp File Reference

VulPoly centroidal Voronoi mesh generation for 2D and 3D domains. More...

#include <cassert>
#include <cstdint>
#include <iostream>
#include <limits>
#include <random>
#include <stdexcept>
#include <unordered_map>
#include <utility>
#include <vector>
#include <Eigen/Dense>
#include "vulpes/geometry/distance.hpp"
#include "vulpes/geometry/mesh.hpp"
#include "vulpes/geometry/voronoi.hpp"
#include "vulpes/utils/profiler.hpp"
#include "vulpes/utils/random/additive_recurrence.hpp"
#include "vulpes/utils/vmath.hpp"
#include "vulpes/utils/vvutils.hpp"
Include dependency graph for mesher.hpp:

Go to the source code of this file.

Classes

struct  vulpes::geometry::vulpoly::VulPolyParams< FloatType >
 Parameters controlling VulPoly relaxation and mesh cleanup. More...

Namespaces

namespace  vulpes
namespace  vulpes::geometry
namespace  vulpes::geometry::vulpoly
 VulPoly meshing options and algorithm parameters.
namespace  vulpes::geometry::internal
 Helpers implementing VulPoly's Voronoi construction and cleanup.

Typedefs

template<typename FloatType, typename IndexType, IndexType Dim, typename = std::enable_if_t<(Dim == 2) || (Dim == 3)>>
using vulpes::geometry::vulpoly::Mesh
 Select the concrete mesh type for a supported spatial dimension.

Enumerations

enum  vulpes::geometry::vulpoly::RandomEngine : std::uint8_t { vulpes::geometry::vulpoly::Pseudo , vulpes::geometry::vulpoly::AdditiveRecurrence }
 Available random or low-discrepancy seed generation strategies. More...

Functions

template<int32_t Dim>
std::pair< double, double > vulpes::geometry::internal::updateVoronoiCentroid (const std::array< Point< double, Dim >, 2 > &bbox, std::vector< Point< double, Dim > > &points, int32_t n_inside_seeds)
 Move each Voronoi seed to its cell centroid and estimate relaxation error.
template<typename FloatType, typename IndexType, IndexType Dim, typename D>
Point< FloatType, Dim > vulpes::geometry::internal::computeGradient (const Point< FloatType, Dim > x, const DistanceExpression< double, Dim, D > &distanceFunction, IndexType idx, FloatType finite_difference_h)
 Estimate a signed-distance gradient by centered finite differences.
template<int32_t Dim, typename D>
Mesh2D< double, int32_t > vulpes::geometry::internal::computeVoronoiMesh2D (const std::array< Point< double, 2 >, 2 > &bbox, const std::vector< Point< double, 2 > > &points, const DistanceExpression< double, Dim, D > &distanceFunction)
 Convert in-domain 2D Voronoi cells into a Vulpes mesh.
template<int32_t Dim, typename D>
Mesh3D< double, int32_t > vulpes::geometry::internal::computeVoronoiMesh3D (const std::array< Point< double, 3 >, 2 > &bbox, const std::vector< Point< double, 3 > > &points, const DistanceExpression< double, Dim, D > &distanceFunction)
 Convert in-domain 3D Voronoi cells into a Vulpes mesh.
template<typename FloatType, typename IndexType, IndexType Dim>
void vulpes::geometry::internal::vulPolyAdjustFixedPoints (const std::vector< Point< FloatType, Dim > > &fixed_pts, const std::vector< IndexType > &near_boundary_idxs, std::vector< Point< FloatType, Dim > > &seed_pts)
 Adjust nearby seeds to keep fixed points represented in the mesh.
template<typename FloatType, typename IndexType, IndexType Dim, typename D>
std::vector< IndexType > vulpes::geometry::internal::vulPolyReflect (const DistanceExpression< FloatType, Dim, D > &distanceFunction, FloatType alpha, const vulpoly::VulPolyParams< FloatType > &params, std::vector< Point< FloatType, Dim > > &seed_pts)
 Add reflected seeds near domain boundaries.
template<typename FloatType, typename MeshType, typename D>
void vulpes::geometry::internal::vulPolyClipToBoundary (MeshType &mesh, FloatType alpha, const DistanceExpression< FloatType, MeshType::self_dim, D > &distanceFunction, const vulpoly::VulPolyParams< FloatType > &params)
 Improve positions of mesh vertices close to the domain boundary.
template<typename FloatType, typename IndexType>
FloatType vulpes::geometry::internal::vulPolyComputeEdgeAngle (const Mesh2D< FloatType, IndexType > &mesh, IndexType cell_id, const std::array< IndexType, 2 > &edge)
 Estimate an edge's normalized angular size in an adjacent cell.
template<typename FloatType, typename IndexType, IndexType Dim, typename D>
void vulpes::geometry::internal::vulPolyCollapseEdges (Mesh2D< FloatType, IndexType > &mesh, const DistanceExpression< FloatType, Dim, D > &distanceFunction, FloatType edge_collapse_tol)
 Collapse isolated undersized edges in a 2D mesh.
template<typename FloatType, typename IndexType, IndexType Dim, typename D>
std::pair< Mesh< FloatType, IndexType, Dim >, std::vector< Point< FloatType, Dim > > > vulpes::geometry::vulpoly::mesh (const DistanceExpression< FloatType, Dim, D > &distanceFunction, size_t n_elems, const std::vector< Point< FloatType, Dim > > &fixed_pts={}, const VulPolyParams< FloatType > &params={}, size_t seed=0)
 Generate a VulPoly mesh from a requested number of seeds.
template<typename FloatType, typename IndexType, IndexType Dim, typename D>
Mesh< FloatType, IndexType, Dim > vulpes::geometry::vulpoly::mesh (std::vector< Point< FloatType, Dim > > &center_pts, const DistanceExpression< FloatType, Dim, D > &distanceFunction, const std::vector< Point< FloatType, Dim > > &fixed_pts={}, const VulPolyParams< FloatType > &params={})
 Generate a VulPoly mesh from caller-supplied seed points.
template<typename FloatType, typename IndexType>
auto vulpes::geometry::vulpoly::buildHexagonTessellation (const Point< FloatType, 2 > &corner_a, const Point< FloatType, 2 > &corner_b, const Point< IndexType, 2 > &n_divisions)
 Build a 2D hexagonal seed tessellation and mesh its rectangle.
template<typename FloatType, typename IndexType>
auto vulpes::geometry::vulpoly::buildOctahedronTessellation (const Point< FloatType, 3 > &corner_a, const Point< FloatType, 3 > &corner_b, const Point< IndexType, 3 > &n_divisions)
 Build a 3D hexahedral-domain mesh from an octahedral seed pattern.

Detailed Description

VulPoly centroidal Voronoi mesh generation for 2D and 3D domains.

Centroidal relaxation, boundary reflection, fixed-point handling, and short-edge removal are based on PolyMesher. Vulpes adds boundary-vertex correction and adapts Voronoi cells to its mesh data structures.

Reference
Talischi et al., "PolyMesher: a general-purpose mesh generator for polygonal elements written in Matlab," Structural and Multidisciplinary Optimization 45, 309-328 (2012). DOI: https://doi.org/10.1007/s00158-011-0706-z.