10 for(std::set<libMesh::Point>::const_iterator it_set = input_points.begin();
11 it_set != input_points.end();
14 libMesh::Point dummy = *it_set;
23 temp_tetgen_interface.triangulate_pointset();
35 const libMesh::Point * dummy_libMesh_point;
36 for(
int iii = 0; iii < input_points.size(); ++iii)
39 dummy_CGAL_point =
Point_3( (*dummy_libMesh_point)(0),(*dummy_libMesh_point)(1),(*dummy_libMesh_point)(2));
43 dummy_vertex_handle->info().ExtIndex = iii;
47 unsigned int dummy_vertex_idx = 0;
53 for(
int iii = 0; iii < 4; ++iii)
55 dummy_vertex_idx = cell_it->vertex(iii)->info().ExtIndex;
74 libMesh::Elem * poly_elem = * it_poly_mesh;
76 if(std::abs(poly_elem->volume()) >
m_vol_tol)
79 libMesh::Elem * mesh_elem =
m_libMesh_Mesh.add_elem(
new libMesh::Tet4);
82 for(
unsigned int iii = 0; iii < 4; ++iii)
172 libMesh::MeshTools::BoundingBox bbox_A = libMesh::MeshTools::bounding_box(mesh_A);
173 libMesh::MeshTools::BoundingBox bbox_B = libMesh::MeshTools::bounding_box(mesh_B);
176 homemade_assert_msg(bbox_A.intersect(bbox_B),
"Meshes' bounding boxes do not intersect!\n");
179 std::vector<double> eps_candidates(3,0);
180 for(
unsigned int iii = 0; iii < 3; ++iii)
187 m_eps = *std::min_element(eps_candidates.begin(),eps_candidates.end());
189 for(
unsigned int iii = 0; iii < 3; ++iii)
203 double fraction_vol_A = (bbox_A.max()(0) - bbox_A.min()(0)) *
204 (bbox_A.max()(1) - bbox_A.min()(1)) *
205 (bbox_A.max()(2) - bbox_A.min()(2)) /
208 double fraction_vol_B = (bbox_B.max()(0) - bbox_B.min()(0)) *
209 (bbox_B.max()(1) - bbox_B.min()(1)) *
210 (bbox_B.max()(2) - bbox_B.min()(2)) /
213 unsigned int est_elem = std::max(fraction_vol_A * mesh_A.n_elem(),fraction_vol_B * mesh_B.n_elem());
215 m_vol_tol = 1E-6 * grid_volume / est_elem;
222 for(
unsigned int iii = 0; iii < 3; ++iii)
229 std::cout <<
" DEBUG: discrete grid" << std::endl;
230 std::cout <<
" -> eps : " <<
m_eps << std::endl;
231 std::cout <<
" -> volume : " <<
m_vol_tol << std::endl;
232 std::cout <<
" -> Grid dimensions : " <<
m_GridN[0] <<
" " <<
m_GridN[1] <<
" " <<
m_GridN[2] <<
" " << std::endl << std::endl;
237 unsigned int elem_idx_A,
238 unsigned int elem_idx_B,
239 unsigned int elem_idx_C)
253 if(intersection_range_end != intersection_range_start)
267 std::string mesh_file_out = filename_base + mesh_format;
268 std::string table_file_out = filename_base +
"_inter_table.dat";
272 output_mesh.write(mesh_file_out);
275 std::ofstream table_out(table_file_out);
276 unsigned int nb_of_inter_elements = 0;
285 << nb_of_inter_elements;
286 for(
unsigned int jjj = 0; jjj < nb_of_inter_elements; ++jjj)
290 table_out << std::endl;
300 size_t collisions = 0;
309 std::cout <<
" DEBUG: discrete grid hash collisions" << std::endl;
310 std::cout <<
" -> Nb. of collisions / size : " << collisions <<
" / " <<
m_discrete_vertices.size()
324 for(libMesh::ReplicatedMesh::element_iterator it_elem =
m_libMesh_Mesh.elements_begin();
328 const libMesh::Elem * elem = * it_elem;
329 volume += elem->volume();
345 const libMesh::Elem * elem = * it_elem;
346 volume += elem->volume();
double get_total_volume()
Calculate the intersection mesh's total volume.
libMesh::Point & min_point()
Returns the minimal point of the discrete grid.
unsigned int m_nb_of_points
(Unused!)
libMesh::ReplicatedMesh & m_libMesh_Mesh
Address of the intersection mesh.
void update_intersection_mesh()
Update the intersection mesh with the current polyhedron mesh data.
unsigned int m_nb_of_intersections
libMesh::Point & max_point()
Returns the maximum point of the discrete grid.
void convert_to_discrete(const libMesh::Point &iPoint, std::vector< long > &oPoint)
Convert a real valued point to a discrete point.
const libMesh::ReplicatedMesh & mesh()
Returns the address of the intersection mesh.
std::unordered_map< std::vector< long >, unsigned int, PointHash_3D, PointHash_3D_Equal > m_discrete_vertices
Unordered map (or hash) for the discrete points (key).
long grid_min_size()
Returns the minimum discrete grid size.
void increase_intersection_mesh(const std::set< libMesh::Point > &input_points, unsigned int elem_idx_A, unsigned int elem_idx_B, unsigned int elem_idx_C)
Increase the intersection mesh with the current polyhedron mesh and update its data structures...
void export_intersection_data(const std::string &filename_base, const std::string &mesh_format=std::string(".e"))
Export both the intersection mesh its data structures.
std::unordered_map< unsigned int, std::pair< unsigned int, unsigned int > > m_intersection_pairs
Unordered map containing the element pair associated to each intersection (key).
IntersectionMeshingMethod m_MeshingMethod
Choice of meshing algorithm.
libMesh::Point m_Grid_MinPoint
Minimal point of the discrete grid.
void set_grid_constraints(const libMesh::Mesh &mesh_A, const libMesh::Mesh &mesh_B, double vol_tol=-1)
Set the boundaries of the discrete points grid, taking into account the geometry of meshes mesh_A and...
std::unordered_map< unsigned int, unsigned int > m_intersection_couplings
Unordered map associating each intersection (key) to a coupling element (useless!) ...
double eps()
Returns the discrete grid step.
void triangulate_intersection(const std::set< libMesh::Point > &input_points)
Triangulate an intersection defined by a set of libMesh::Points, using either CGAL or Tetgen...
DT_3::Vertex_handle Vertex_handle_3
unsigned int m_nb_of_vertices
Number of vertices of the intersection mesh.
std::unordered_map< unsigned int, std::pair< unsigned int, unsigned int > > m_intersection_element_range
Unordered map associating each intersection (key) to a range of elements in the intersection mesh...
bool m_bPrintDebug
Print debug information? Default: false.
double min_vol()
Returns the minimal polyhedron volume.
double m_eps
Precision of the discrete point grid.
bool m_bMeshFinalized
Boolean controlling if the intersection mesh was finished or not.
void initialize()
Initialize the data structures.
std::vector< long > & grid_sizes()
Returns the discrete grid sizes.
std::vector< long > m_dummy_discrete_point
libMesh::Mesh m_libMesh_PolyhedronMesh
libMesh Mesh containing the tetrahedrization of an intersection polyhedron (the polyhedron mesh)...
double get_intersection_volume(std::set< libMesh::Point > &input_points)
Calculate the volume of an polyhedron defined by the point set.
void preallocate_grid(int map_preallocation)
Preallocate the discrete points grid.
void update_intersection_pairs(unsigned int elem_idx_A, unsigned int elem_idx_B, unsigned int inter_id)
Update the intersection pair map with a new pair associated to the intersection no. inter_id.
double m_vol_tol
Minimal volume for the intersection polyhedrons.
long m_GridN_min
Minimal number of integers over each dimension of the discrete grid.
DT_3 m_CGAL_PolyhedronMesh
Auxiliary CGAL mesh, used if CGAL is chosen for the tetrahedrization.
void prepare_for_use()
Prepare the intersection mesh for use.
std::vector< long > m_GridN
Dimensions of the discrete point grid.
DT_3::Finite_cells_iterator Finite_cells_iterator_3
unsigned int m_nb_of_elements
Number of elements of the intersection mesh.
void update_intersection_element_range(unsigned int range_start, unsigned int range_end, unsigned int inter_id)
Update the intersection element range map with a new range associated to the intersection no...
libMesh::Point m_Grid_MaxPoint
Maximum point of the discrete grid.