https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TriangleManifold.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "MooseTypes.h"
13#include "SurfaceSide.h"
14
15#include "libmesh/bounding_box.h"
16#include "libmesh/mesh_base.h"
17#include "libmesh/point_locator_base.h"
18
19#include <iosfwd>
20#include <memory>
21#include <cstdint>
22#include <string>
23#include <unordered_map>
24#include <vector>
25
46{
47public:
57 TriangleManifold(MeshBase & mesh, const Real surface_tolerance);
58
62 bool contains(const Point & point) const;
63
73 SurfaceGeometry::SurfaceSide sideness(const Point & point) const;
74
78 const libMesh::BoundingBox & boundingBox() const { return _bounding_box; };
79
83 std::size_t numTriangles() const { return _mesh.n_active_elem(); }
84
85private:
93 enum class RayIntersection
94 {
95 Miss,
96 Hit,
98 };
99
101 void finalize();
102
104 void buildCandidateGrid();
105
107 bool pointInsideBoundingBox(const Point & point) const;
108
110 bool pointOnSurface(const Point & point) const;
111
113 RayIntersection rayIntersectsTriangle(const Point & point, const libMesh::Elem & tri) const;
114
116 bool containsBySolidAngle(const Point & point) const;
117
121 SurfaceGeometry::SurfaceSide classifyByParity(const Point & point) const;
122
124 std::vector<dof_id_type> rayCandidates(const Point & point) const;
125
127 std::size_t _num_y_cells = 1;
128
130 std::size_t _num_z_cells = 1;
131
133 Real _y_min = 0.0;
134
136 Real _z_min = 0.0;
137
139 Real _y_cell_size = 1.0;
140
142 Real _z_cell_size = 1.0;
143
145 std::unordered_map<std::uint64_t, std::vector<dof_id_type>> _ray_grid;
146
147 MeshBase & _mesh;
148
151
154
156 const std::unique_ptr<libMesh::PointLocatorBase> _point_locator;
157};
Utility for querying point containment against a closed triangulated surface mesh.
std::size_t _num_y_cells
Number of yz-grid bins in the y direction.
bool contains(const Point &point) const
const Real _surface_tolerance
Absolute tolerance used throughout validation and geometric classification.
std::size_t _num_z_cells
Number of yz-grid bins in the z direction.
const libMesh::BoundingBox _bounding_box
Global bounding box of the transformed manifold.
std::size_t numTriangles() const
bool pointInsideBoundingBox(const Point &point) const
Cheap global bounding-box rejection for containment queries.
SurfaceGeometry::SurfaceSide sideness(const Point &point) const
Classify a query point relative to the manifold surface.
Real _y_cell_size
Width of one yz-grid cell in the y direction.
Real _z_min
Minimum global z coordinate used to map query points into yz-grid bins.
RayIntersection rayIntersectsTriangle(const Point &point, const libMesh::Elem &tri) const
Intersect a positive x-direction ray with a single triangle.
void buildCandidateGrid()
Build the yz-plane lookup grid used to accelerate +x ray queries.
Real _z_cell_size
Width of one yz-grid cell in the z direction.
bool containsBySolidAngle(const Point &point) const
Robust fallback containment query based on accumulated solid angle.
std::unordered_map< std::uint64_t, std::vector< dof_id_type > > _ray_grid
Lookup from packed yz-grid cell index to triangles that could intersect the +x query ray.
Real _y_min
Minimum global y coordinate used to map query points into yz-grid bins.
SurfaceGeometry::SurfaceSide classifyByParity(const Point &point) const
Resolve INSIDE vs OUTSIDE via the fixed +x ray parity test (with solid-angle fallback for ambiguous g...
bool pointOnSurface(const Point &point) const
Detect whether a query point lies on or extremely near the manifold surface.
std::vector< dof_id_type > rayCandidates(const Point &point) const
Get the subset of triangles whose yz extents may intersect the query ray.
const libMesh::BoundingBox & boundingBox() const
void finalize()
Complete post-parse validation and acceleration-structure setup.
const std::unique_ptr< libMesh::PointLocatorBase > _point_locator
Pre-built point locator for fast proximity-to-surface detection.
RayIntersection
Result of intersecting the positive x-direction ray with a triangle.
MeshBase & mesh
SurfaceSide
The side of a closed surface where a query point is located.
Definition SurfaceSide.h:21