PolyDiM
C++ library for POLYtopal DIscretization Methods
Loading...
Searching...
No Matches
VoroInterface.hpp
Go to the documentation of this file.
1// _LICENSE_HEADER_
2//
3// Copyright (C) 2019 - 2025.
4// Terms register on the GPL-3.0 license.
5//
6// This file can be redistributed and/or modified under the license terms.
7//
8// See top level LICENSE file for more details.
9//
10// This file can be used citing references in CITATION.cff file.
11
12#ifndef __VoroInterface_H
13#define __VoroInterface_H
14
15#include "Gedim_Macro.hpp"
16#include "GeometryUtilities.hpp"
17
18#include "CommonUtilities.hpp"
19#include "IMeshDAO.hpp"
20
21#if ENABLE_VORO == 1
22#include "voro++.hh"
23#endif
24
25#define TEST_VORO
26
27namespace Gedim
28{
30{
31 public:
32 struct Cell0D
33 {
34 const Eigen::VectorXd coordinates;
35 unsigned int marker;
36 bool active = true;
37 std::vector<unsigned int> neighbors_1D;
38 std::vector<unsigned int> neighbors_2D;
39
40 Cell0D(const Eigen::VectorXd &coordinates) : coordinates(coordinates){};
41 };
42
43 struct Cell1D
44 {
45 unsigned int marker;
46 unsigned int origin;
47 unsigned int end;
48 bool active = true;
49 std::vector<unsigned int> neighbors_2D;
50 };
51
52 struct Cell2D
53 {
54 unsigned int marker;
55 std::vector<unsigned int> vertices;
56 std::vector<unsigned int> edges;
57 bool active = true;
58 std::vector<int> neighbors_of_related_3D_cells; // only positive ones
59 };
60
61 struct Cell3D
62 {
63 unsigned int marker;
64 std::vector<unsigned int> vertices;
65 std::set<unsigned int> edges;
66 std::vector<unsigned int> faces;
67 std::vector<int> neighbors;
68 bool active = true;
69 };
70
71 private:
72 const Gedim::GeometryUtilities &geometryUtilities;
73
74#if ENABLE_VORO == 1
75 unsigned int InsertNewPoint(const Cell0D &cell0D, std::map<unsigned int, Cell0D> &cell0Ds);
76
77 inline double rnd()
78 {
79 return double(rand()) / RAND_MAX;
80 }
81 void GenerateCartesianPoints3D(const Eigen::MatrixXd &polyhedronVertices, const unsigned int &numPoints, voro::container &con);
82#endif
83 public:
84 VoroInterface(const Gedim::GeometryUtilities &geometryUtilities);
85
95 Eigen::MatrixXd GenerateRandomPoints(const Eigen::MatrixXd &domainVertices,
96 const unsigned int &numPoints,
97 const unsigned int random_seed = Gedim::Utilities::RandomSeed());
98
99 void GenerateVoronoiTassellations2D(const Eigen::MatrixXd &polygonVertices,
100 const unsigned int &numPoints,
101 const unsigned int &numIterations,
103 const unsigned int random_seed = Gedim::Utilities::RandomSeed());
104
115
117 const unsigned int &numIterations,
118 Eigen::MatrixXd &VoronoiPoints,
120
121 void GenerateVoronoiTassellations3D(const Eigen::MatrixXd &polyhedronVertices,
122 const Eigen::MatrixXi &polyhedronEdges,
123 const std::vector<Eigen::MatrixXi> &polyhedronFaces,
124 const unsigned int &numPoints,
125 const unsigned int &numIterations,
127 const unsigned int random_seed = Gedim::Utilities::RandomSeed());
128
142 const Eigen::MatrixXi &domain_edges,
143 const std::vector<Eigen::MatrixXi> &domain_faces,
144 const unsigned int &num_iterations,
145 Eigen::MatrixXd &VoronoiPoints,
147};
148
149} // namespace Gedim
150
151#endif
Eigen column vector.
Definition Eigen_Array.hpp:23
The GeometryUtilities class intersects 3D segments.
Definition GeometryUtilities.hpp:37
The IMeshDAO (mesh data access object) class to read and write mesh data.
Definition IMeshDAO.hpp:24
static unsigned int RandomSeed()
Definition CommonUtilities.hpp:32
Definition VoroInterface.hpp:30
void GenerateVoronoiTassellations2D(const Eigen::MatrixXd &polygonVertices, const unsigned int &numIterations, Eigen::MatrixXd &VoronoiPoints, Gedim::IMeshDAO &mesh)
Generate a 2D centroidal Voronoi tessellation from prescribed seeds. The function computes a centroid...
void GenerateVoronoiTassellations3D(const Eigen::MatrixXd &domain_vertices, const Eigen::MatrixXi &domain_edges, const std::vector< Eigen::MatrixXi > &domain_faces, const unsigned int &num_iterations, Eigen::MatrixXd &VoronoiPoints, Gedim::IMeshDAO &mesh)
Generate a 3D centroidal Voronoi tessellation from prescribed seeds. The function computes a centroid...
Eigen::MatrixXd GenerateRandomPoints(const Eigen::MatrixXd &domainVertices, const unsigned int &numPoints, const unsigned int random_seed=Gedim::Utilities::RandomSeed())
Generate a set of random points inside a parallelepipedal/parallelogram domain.
void GenerateVoronoiTassellations2D(const Eigen::MatrixXd &polygonVertices, const unsigned int &numPoints, const unsigned int &numIterations, Gedim::IMeshDAO &mesh, const unsigned int random_seed=Gedim::Utilities::RandomSeed())
Definition VoroInterface.cpp:50
void GenerateVoronoiTassellations3D(const Eigen::MatrixXd &polyhedronVertices, const Eigen::MatrixXi &polyhedronEdges, const std::vector< Eigen::MatrixXi > &polyhedronFaces, const unsigned int &numPoints, const unsigned int &numIterations, Gedim::IMeshDAO &mesh, const unsigned int random_seed=Gedim::Utilities::RandomSeed())
Definition VoroInterface.cpp:32
Definition Eigen_Array.cpp:22
Definition VoroInterface.hpp:33
unsigned int marker
Definition VoroInterface.hpp:35
bool active
Definition VoroInterface.hpp:36
const Eigen::VectorXd coordinates
Definition VoroInterface.hpp:34
std::vector< unsigned int > neighbors_1D
Definition VoroInterface.hpp:37
std::vector< unsigned int > neighbors_2D
Definition VoroInterface.hpp:38
Cell0D(const Eigen::VectorXd &coordinates)
Definition VoroInterface.hpp:40
Definition VoroInterface.hpp:44
unsigned int marker
Definition VoroInterface.hpp:45
std::vector< unsigned int > neighbors_2D
Definition VoroInterface.hpp:49
bool active
Definition VoroInterface.hpp:48
unsigned int origin
Definition VoroInterface.hpp:46
unsigned int end
Definition VoroInterface.hpp:47
Definition VoroInterface.hpp:53
unsigned int marker
Definition VoroInterface.hpp:54
std::vector< int > neighbors_of_related_3D_cells
Definition VoroInterface.hpp:58
std::vector< unsigned int > vertices
Definition VoroInterface.hpp:55
bool active
Definition VoroInterface.hpp:57
std::vector< unsigned int > edges
Definition VoroInterface.hpp:56
Definition VoroInterface.hpp:62
std::set< unsigned int > edges
Definition VoroInterface.hpp:65
std::vector< int > neighbors
Definition VoroInterface.hpp:67
std::vector< unsigned int > vertices
Definition VoroInterface.hpp:64
std::vector< unsigned int > faces
Definition VoroInterface.hpp:66
bool active
Definition VoroInterface.hpp:68
unsigned int marker
Definition VoroInterface.hpp:63