https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PointInPolyhedronCheckUO.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 "BoundaryMeshBuilder.h"
12
13#include "libmesh/elem.h"
14#include "libmesh/string_to_enum.h"
15
17
20{
22 params.addClassDescription("Determines whether a point is inside a closed surface mesh provided "
23 "by a BoundaryMeshBuilder.");
24
25 params.addRequiredParam<UserObjectName>(
26 "builder", "The BoundaryMeshBuilder providing the surface mesh and boundary elements.");
27
28 return params;
29}
30
32 : PointInPolyhedronBaseUO(parameters),
33 _builder(getUserObject<BoundaryMeshBuilder>("builder")),
34 _classifier(nullptr)
35{
36}
37
38void
40{
41 // The fixed_x_ray backend (TriangleManifold) handles only 3D TRI3 surface
42 // meshes (mesh_dimension 2). Reject 2D EDGE2 surfaces here with a clear
43 // message; use pca_ray or user_selected_ray for 2D instead.
45 {
46 if (_builder.mesh().mesh_dimension() != 2)
47 paramError("point_containment_method",
48 "fixed_x_ray (the TriangleManifold engine) supports only 3D TRI3 surface meshes. "
49 "For a 2D (EDGE2) surface use pca_ray, or user_selected_ray with "
50 "ray_direction = '1 0 0'.");
51
52 // TriangleManifold accepts TRI3 only. Validate the element type up front so an
53 // unsupported surface (e.g. QUAD4) fails with a method-aware message here rather
54 // than inside the later manifold construction.
55 for (const auto * elem : _builder.mesh().active_element_ptr_range())
56 if (elem->type() != TRI3)
57 paramError("point_containment_method",
58 "fixed_x_ray (the TriangleManifold engine) supports only TRI3 surface elements, "
59 "but the surface mesh contains ",
61 ". Use pca_ray or user_selected_ray instead.");
62 }
63
64 // The fixed_x_ray (TriangleManifold) backend classifies from the mesh directly
65 // and ignores the SurfaceElementSet. Skip surfaceElementSet() in that case so
66 // the builder never builds the whole-mesh set that would go unused.
68 ? nullptr
70 _classifier = std::make_unique<PointContainmentClassifier>(
72}
registerMooseObject("MooseApp", PointInPolyhedronCheckUO)
Owns a saved boundary (surface) mesh and the SurfaceElementSet wrapping it.
MeshBase & mesh() const
The owned boundary mesh.
const SurfaceElementSet & surfaceElementSet() const
The whole-mesh SurfaceElementSet, built lazily on first call.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
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
@ FIXED_X_RAY
TriangleManifold engine (fixed +x ray parity + solid-angle fallback).
Common base class providing shared parameters and validation for point-containment user objects.
const PointContainmentClassifier::Method _method
Selected point-containment backend.
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.
Determines whether a point is inside a single closed surface mesh provided by a BoundaryMeshBuilder.
std::unique_ptr< PointContainmentClassifier > _classifier
The selected point-containment backend, built in initialSetup().
static InputParameters validParams()
const BoundaryMeshBuilder & _builder
Builder that owns the surface mesh and SurfaceElementSet.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
PointInPolyhedronCheckUO(const InputParameters &parameters)
A group of surface elements wrapped for point-containment / distance queries.
std::string enum_to_string(const T e)