https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PointInPolyhedronBaseUO.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
12namespace
13{
16methodFromEnum(const MooseEnum & method)
17{
18 if (method == "pca_ray")
20 if (method == "user_selected_ray")
23}
24}
25
28{
30 params.addClassDescription("Base class for user objects that determine whether a point is inside "
31 "a closed surface mesh.");
32
33 MooseEnum methods("pca_ray user_selected_ray fixed_x_ray", "pca_ray");
34 params.addParam<MooseEnum>(
35 "point_containment_method",
36 methods,
37 "Algorithm used for point-containment queries. 'pca_ray' (default) uses the ray-casting "
38 "engine with a PCA-selected ray; 'user_selected_ray' uses the ray-casting engine with the "
39 "'ray_direction' parameter; 'fixed_x_ray' uses the TriangleManifold engine (fixed +x ray, "
40 "TRI3 surfaces only).");
41
42 params.addParam<Point>(
43 "ray_direction",
44 Point(0.0, 0.0, 0.0),
45 "Ray direction for the 'user_selected_ray' method, used exactly as given (no "
46 "auto-selection). Any finite non-zero direction is allowed, including oblique; for a 2D "
47 "surface it must lie in the mesh plane (zero z component). The user is responsible for "
48 "avoiding directions that graze vertices/edges or are tangent to the surface. Other "
49 "methods ignore this parameter.");
50
51 params.addParam<Real>("tolerance",
53 "Tolerance used for intersection or surface-proximity checks. Determines "
54 "whether a point is considered on the surface.");
55
56 params.addParam<int>(
57 "leaf_max_size", 10, "Maximum number of elements in a leaf node of the KD-tree.");
58
59 params.addParam<FileName>("obb_file_name", "", "Oriented Bounding Box (OBB) debug file name.");
60 params.addParam<FileName>("ray_file_name", "", "Ray debug file name.");
61
62 return params;
63}
64
66 : GeneralUserObject(parameters),
67 _method(methodFromEnum(getParam<MooseEnum>("point_containment_method"))),
68 _ray_direction(getParam<Point>("ray_direction")),
69 _tolerance(getParam<Real>("tolerance")),
70 _leaf_max_size(getParam<int>("leaf_max_size")),
71 _obb_file_name(getParam<FileName>("obb_file_name")),
72 _ray_file_name(getParam<FileName>("ray_file_name"))
73{
74 if (_leaf_max_size <= 0)
75 paramError("leaf_max_size", "must be greater than zero.");
76 if (_tolerance <= 0.0)
77 paramError("tolerance", "must be greater than zero.");
78
79 const bool ray_direction_set = !_ray_direction.absolute_fuzzy_equals(Point(0.0, 0.0, 0.0));
80
81 // user_selected_ray needs a direction; the other methods ignore it.
84 "ray_direction",
85 "must be set to a non-zero vector when point_containment_method = user_selected_ray.");
87 paramError("ray_direction", "is only used by point_containment_method = user_selected_ray.");
88
89 // The fixed_x_ray (TriangleManifold) backend does not emit OBB/ray debug files.
91 (!_obb_file_name.empty() || !_ray_file_name.empty()))
92 mooseInfo("point_containment_method = fixed_x_ray does not produce OBB/ray debug files; "
93 "obb_file_name/ray_file_name will be ignored.");
94}
95
98{
104 options.comm = &comm();
105 return options;
106}
void mooseInfo(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
Definition MooseError.h:401
void ErrorVector unsigned int
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
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).
PointInPolyhedronBaseUO(const InputParameters &parameters)
const Point _ray_direction
User-supplied ray direction (used only by user_selected_ray).
const PointContainmentClassifier::Method _method
Selected point-containment backend.
const FileName _obb_file_name
Oriented Bounding Box (OBB) debug file name (ray backends only).
const FileName _ray_file_name
Ray debug file name (ray backends only).
static InputParameters validParams()
PointContainmentClassifier::RayOptions pcaRayOptions() const
Assemble the ray-backend tuning/debug options from the shared parameters.
const Real _tolerance
eps / surface tolerance for on-surface and intersection checks.
const int _leaf_max_size
Maximum number of elements in a leaf node of the KD-tree (ray backends).
const Parallel::Communicator & comm() const
static constexpr Real TOLERANCE
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