https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PointInUnionCheckUO.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
10#include "PointInUnionCheckUO.h"
11#include "UserObjectBase.h"
12#include "SurfaceSide.h"
13
15
18{
20 params.addClassDescription("Classifies a point against the union of several geometries, each "
21 "supplied by a user object that implements the point-in-surface check "
22 "interface (a meshed surface, a signed function, or another union).");
23 params.addRequiredParam<std::vector<UserObjectName>>(
24 "providers",
25 "User objects, each implementing the point-in-surface check interface, whose geometries are "
26 "unioned. A point is inside the union if it is inside any one of them.");
27 return params;
28}
29
31 : ThreadedGeneralUserObject(parameters)
32{
33 const auto & names = getParam<std::vector<UserObjectName>>("providers");
34 if (names.empty())
35 paramError("providers",
36 "must list at least one provider; an empty list would classify every point as "
37 "outside.");
38
39 _providers.reserve(names.size());
40 for (const auto & name : names)
41 {
42 // Fetch the base (registering the user-object dependency) and cast to the
43 // interface ourselves so a mismatch produces a providers-scoped error naming
44 // the offending object, rather than a generic type error.
46 const auto * provider = dynamic_cast<const PointInSurfaceCheckInterface *>(&base);
47 if (!provider)
48 paramError("providers",
49 "'",
50 name,
51 "' (type ",
52 base.type(),
53 ") does not implement the point-in-surface check interface.");
54 _providers.push_back(provider);
55 }
56}
57
59PointInUnionCheckUO::sideness(const Point & p) const
60{
61 // Fold the provider queries incrementally and stop at the first provider that
62 // reports INSIDE (the maximal union result). This avoids the remaining, possibly
63 // expensive (e.g. mesh ray-casting) provider queries once membership is decided.
65 for (const auto * provider : _providers)
66 {
67 result = SurfaceGeometry::unionSideness(result, provider->sideness(p));
69 return result;
70 }
71
72 return result;
73}
registerMooseObject("MooseApp", PointInUnionCheckUO)
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.
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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
Mixin interface implemented by user objects that can classify a query point against a closed surface ...
Classifies a point against the union of several geometries, each supplied by a user object implementi...
std::vector< const PointInSurfaceCheckInterface * > _providers
The geometries whose union is tested (non-owning; owned by the warehouse).
virtual SurfaceGeometry::SurfaceSide sideness(const Point &p) const override
static InputParameters validParams()
PointInUnionCheckUO(const InputParameters &parameters)
An instance of this object type has one copy per thread that runs on each thread.
static InputParameters validParams()
const UserObjectBase & getUserObjectBaseByName(const UserObjectName &object_name, bool is_dependency=true) const
Get an user object with the name object_name.
SurfaceSide unionSideness(SurfaceSide a, SurfaceSide b)
Combine two classifications for a union: INSIDE if either is INSIDE, otherwise ON if either is ON,...
Definition SurfaceSide.C:36
SurfaceSide
The side of a closed surface where a query point is located.
Definition SurfaceSide.h:21
@ INSIDE
The point lies strictly in the interior of the closed surface.
@ OUTSIDE
The point lies strictly in the exterior of the closed surface.