https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PointContainmentClassifier.C
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
11#include "RayDirectionOptions.h"
12#include "SurfaceElementSet.h"
14#include "TriangleManifold.h"
15#include "MooseError.h"
16
17namespace
18{
20defaultRayOptions(const PointContainmentClassifier::Method method)
21{
23 mooseError("PointContainmentClassifier: user_selected_ray requires explicit RayOptions.");
24
25 return {};
26}
27} // namespace
28
30 const SurfaceElementSet * set,
31 Method method,
32 Real tolerance)
33 : PointContainmentClassifier(mesh, set, method, tolerance, defaultRayOptions(method))
34{
35}
36
38 MeshBase & mesh,
39 const SurfaceElementSet * set,
41 Real tolerance,
43 : _method(method)
44{
45 switch (_method)
46 {
49 {
50 if (!set)
52 "PointContainmentClassifier: a SurfaceElementSet is required for the pca_ray and "
53 "user_selected_ray methods.");
54
56 _method == Method::PCA_RAY ? SurfaceGeometry::RayDirectionMode::AUTO_PCA
58 options.ray_direction};
59 _pca = std::make_unique<AdaptiveRayContainmentCheck>(set->elements(),
60 set->centroids(),
61 ray_options,
62 tolerance,
63 options.leaf_max_size,
64 options.obb_file_name,
65 options.ray_file_name,
66 options.comm);
67
68 _bounding_box = set->boundingBox();
69 _num_elements = set->size();
70 break;
71 }
72
74 {
75 _tri = std::make_unique<TriangleManifold>(mesh, tolerance);
76 _bounding_box = _tri->boundingBox();
77 _num_elements = _tri->numTriangles();
78 break;
79 }
80 }
81}
82
84
86PointContainmentClassifier::sideness(const Point & point) const
87{
88 if (_tri)
89 return _tri->sideness(point);
90
91 mooseAssert(_pca, "PointContainmentClassifier: no backend was constructed.");
92 return _pca->sideness(point);
93}
94
95Point
97{
98 if (!_pca)
99 mooseError("PointContainmentClassifier::rayDirection() is only defined for the pca_ray and "
100 "user_selected_ray methods; the fixed_x_ray method has no ray-casting backend.");
101 return _pca->rayDirection();
102}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Unified wrapper (facade) over the point-containment backends.
SurfaceGeometry::SurfaceSide sideness(const Point &point) const
Classify a query point relative to the closed surface.
Point rayDirection() const
The resolved ray direction of the ray-casting backend (user-selected direction for USER_SELECTED_RAY,...
PointContainmentClassifier(libMesh::MeshBase &mesh, const SurfaceElementSet *set, Method method, Real tolerance)
Builds PCA_RAY with default ray options or FIXED_X_RAY without unused options.
std::unique_ptr< TriangleManifold > _tri
FIXED_X_RAY.
std::unique_ptr< AdaptiveRayContainmentCheck > _pca
One of the two backends is constructed; the other stays null.
Method
Backend algorithm used for point-containment queries.
@ USER_SELECTED_RAY
AdaptiveRayContainmentCheck with a user-supplied ray_direction, used exactly as given (no PCA,...
@ FIXED_X_RAY
TriangleManifold engine (fixed +x ray parity + solid-angle fallback).
@ PCA_RAY
AdaptiveRayContainmentCheck with a PCA-selected ray (default SBM behavior).
A group of surface elements wrapped for point-containment / distance queries.
const libMesh::BoundingBox & boundingBox() const
Global AABB of the group (plain union of element loose bounding boxes).
std::size_t size() const
Number of surface elements in the group.
const std::vector< Point > & centroids() const
Per-element centroids (vertex averages), aligned index-for-index with elements().
const std::vector< std::unique_ptr< SurfaceElement > > & elements() const
Owned surface-element wrappers, one per input element (input order preserved).
MeshBase & mesh
@ USER_SPECIFIED
The engine uses the caller-supplied direction exactly, with no auto-selection.
@ AUTO_PCA
The engine auto-selects a robust direction via PCA (may use a fallback).
SurfaceSide
The side of a closed surface where a query point is located.
Definition SurfaceSide.h:21
Ray-backend tuning + debug output; ignored by FIXED_X_RAY (TriangleManifold).
Point ray_direction
Direction used by USER_SELECTED_RAY; ignored by PCA_RAY.
const libMesh::Parallel::Communicator * comm
Ray-direction intent for AdaptiveRayContainmentCheck: an explicit mode plus the direction to use when...