https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SubdomainGrainIDGenerator Class Reference

Assigns grain subdomain IDs to a volume mesh based on watertight closed boundaries in an external boundary mesh, using ray casting accelerated by a k-d tree. More...

#include <SubdomainGrainIDGenerator.h>

Inheritance diagram for SubdomainGrainIDGenerator:
[legend]

Classes

struct  SubdomainCheckerEntry
 Cache of bounding box and checker pointers for fast spatial queries. More...
 

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 SubdomainGrainIDGenerator (const InputParameters &parameters)
 
std::unique_ptr< libMesh::MeshBase > generate () override
 
std::unique_ptr< CSG::CSGBase > generateInternalCSG ()
 
std::unique_ptr< MeshBase > generateInternal ()
 
const std::set< MeshGeneratorName > & getRequestedMeshGenerators () const
 
const std::set< MeshGeneratorName > & getRequestedMeshGeneratorsForSub () const
 
void addParentMeshGenerator (const MeshGenerator &mg, const AddParentChildKey)
 
void addChildMeshGenerator (const MeshGenerator &mg, const AddParentChildKey)
 
const std::set< const MeshGenerator *, Comparator > & getParentMeshGenerators () const
 
const std::set< const MeshGenerator *, Comparator > & getChildMeshGenerators () const
 
const std::set< const MeshGenerator *, Comparator > & getSubMeshGenerators () const
 
bool isParentMeshGenerator (const MeshGeneratorName &name, const bool direct=true) const
 
bool isChildMeshGenerator (const MeshGeneratorName &name, const bool direct=true) const
 
bool isNullMeshName (const MeshGeneratorName &name) const
 
bool hasSaveMesh () const
 
bool hasOutput () const
 
const std::string & getSavedMeshName () const
 
bool hasGenerateData () const
 
bool hasGenerateCSG () const
 
bool isDataOnly () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObject > getSharedPtr ()
 
std::shared_ptr< const MooseObject > getSharedPtr () const
 
bool isKokkosObject () const
 
MooseApp & getMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParameters & parameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static bool hasGenerateData (const InputParameters &params)
 
static bool hasGenerateCSG (const InputParameters &params)
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 
static void setHasGenerateData (InputParameters &params)
 
static void setHasGenerateCSG (InputParameters &params)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string data_only_param
 
static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 
static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

void buildSubdomainGroupedData ()
 build the data structure grouping by different subdomains
 
void buildInOutTesters ()
 Build the IN-OUT testers for each subdomain.
 
virtual void generateData ()
 
virtual std::unique_ptr< CSG::CSGBase > generateCSG ()
 
T & copyMeshProperty (const std::string &target_data_name, const std::string &source_data_name, const std::string &source_mesh)
 
T & copyMeshProperty (const std::string &source_data_name, const std::string &source_mesh)
 
std::unique_ptr< MeshBase > & getMesh (const std::string &param_name, const bool allow_invalid=false)
 
std::vector< std::unique_ptr< MeshBase > * > getMeshes (const std::string &param_name)
 
std::unique_ptr< MeshBase > & getMeshByName (const MeshGeneratorName &mesh_generator_name)
 
std::vector< std::unique_ptr< MeshBase > * > getMeshesByName (const std::vector< MeshGeneratorName > &mesh_generator_names)
 
std::unique_ptr< CSG::CSGBase > & getCSGBase (const std::string &param_name)
 
std::unique_ptr< CSG::CSGBase > & getCSGBaseByName (const MeshGeneratorName &mesh_generator_name)
 
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBases (const std::string &param_name)
 
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBasesByName (const std::vector< MeshGeneratorName > &mesh_generator_names)
 
void declareMeshForSub (const std::string &param_name)
 
void declareMeshesForSub (const std::string &param_name)
 
void declareMeshForSubByName (const MeshGeneratorName &mesh_generator_name)
 
void declareMeshesForSubByName (const std::vector< MeshGeneratorName > &mesh_generator_names)
 
std::unique_ptr< MeshBase > buildMeshBaseObject (unsigned int dim=libMesh::invalid_uint)
 
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh (unsigned int dim=libMesh::invalid_uint)
 
std::unique_ptr< DistributedMesh > buildDistributedMesh (unsigned int dim=libMesh::invalid_uint)
 
void addMeshSubgenerator (const std::string &type, const std::string &name, Ts... extra_input_parameters)
 
void addMeshSubgenerator (const std::string &type, const std::string &name, InputParameters params)
 
void declareNullMeshName (const MeshGeneratorName &name)
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
T & declareMeshProperty (const std::string &data_name, Args &&... args)
 
T & declareMeshProperty (const std::string &data_name, const T &data_value)
 
T & declareMeshProperty (const std::string &data_name, Args &&... args)
 
T & declareMeshProperty (const std::string &data_name, const T &data_value)
 
T & setMeshProperty (const std::string &data_name, Args &&... args)
 
T & setMeshProperty (const std::string &data_name, const T &data_value)
 
T & setMeshProperty (const std::string &data_name, Args &&... args)
 
T & setMeshProperty (const std::string &data_name, const T &data_value)
 

Static Protected Member Functions

static bool boundingBoxesIntersect (const BoundingBox &lhs, const BoundingBox &rhs, const Real tolerance)
 Check whether two bounding boxes overlap within a small tolerance.
 
static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

std::unique_ptr< libMesh::MeshBase > & _boundary_mesh
 Reference to the external boundary mesh defining grain boundaries.
 
std::unordered_map< SubdomainID, std::vector< Point > > _centroids_by_subdomain
 The centroids of the boundary elements grouped by subdomains.
 
std::unordered_map< SubdomainID, std::vector< std::unique_ptr< SurfaceElement > > > _boundary_elements_by_subdomain
 The boundary elements grouped by subdomains.
 
std::unordered_map< SubdomainID, BoundingBox > _bboxes_by_subdomain
 The bounding boxes of the boundary elements grouped by subdomains.
 
std::unordered_map< SubdomainID, std::unique_ptr< AdaptiveRayContainmentCheck > > _subdomain_id_checkers
 The IN-OUT testers for each subdomain.
 
std::vector< SubdomainCheckerEntry > _checker_entries
 Cache contiguous checker metadata for faster per-element scans.
 
Point _ray_direction
 Ray shooting direction in Point format.
 
Real _eps
 eps for intersection or on surface checking
 
unsigned int _leaf_max_size
 Maximum number of boundary-element centroids in a leaf node of the k-d tree.
 
std::unique_ptr< libMesh::MeshBase > _boundary_owned
 The boundary mesh to use for identifying grain IDs.
 
std::unique_ptr< libMesh::MeshBase > & _input
 The input mesh to modify.
 
MooseMesh *const _mesh
 
const bool & _enabled
 
MooseApp & _app
 
Factory & _factory
 
ActionFactory & _action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters & _pars
 
const Parallel::Communicator & _communicator
 
const Real _lambda
 Threshold applied to the fraction outside the retained domain for a partial element.
 
const Order _qrule_order
 Quadrature order used to estimate the retained-domain fraction.
 
const SBMUtils::InterceptedSubdomainPolicy _intercepted_subdomain_policy
 Policy for assigning partial elements to a dedicated intercepted subdomain.
 

Private Member Functions

virtual std::string meshPropertyPrefix (const std::string &) const override final
 
void checkGetMesh (const MeshGeneratorName &mesh_generator_name, const std::string &param_name) const
 
const MeshGeneratorName * getMeshGeneratorNameFromParam (const std::string &param_name, const bool allow_invalid) const
 
const std::vector< MeshGeneratorName > & getMeshGeneratorNamesFromParam (const std::string &param_name) const
 
RestartableDataValue & setMeshPropertyHelper (const std::string &data_name)
 
const RestartableDataValue & getMeshPropertyInternal (const std::string &data_name, const std::string &prefix) const
 
void mooseErrorInternal (Args &&... args) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

std::set< MeshGeneratorName > _requested_mesh_generators
 
std::set< MeshGeneratorName > _requested_mesh_generators_for_sub
 
std::vector< std::pair< std::string, std::unique_ptr< MeshBase > * > > _requested_meshes
 
std::vector< std::pair< std::string, std::unique_ptr< CSG::CSGBase > * > > _requested_csg_bases
 
std::unique_ptr< MeshBase > _null_mesh
 
std::unique_ptr< CSG::CSGBase > _null_csg_base
 
std::set< const MeshGenerator *, Comparator > _parent_mesh_generators
 
std::set< const MeshGenerator *, Comparator > _child_mesh_generators
 
std::set< const MeshGenerator *, Comparator > _sub_mesh_generators
 
std::set< std::string > _null_mesh_names
 
const std::string & _save_with_name
 
const bool _data_only
 
const ParallelParamObject & _parent
 
const MooseBase & _si_moose_base
 
const FEProblemBase * _si_problem
 
MooseApp & _meta_data_app
 
const MooseObject *const _meta_data_object
 

Detailed Description

Assigns grain subdomain IDs to a volume mesh based on watertight closed boundaries in an external boundary mesh, using ray casting accelerated by a k-d tree.

Definition at line 23 of file SubdomainGrainIDGenerator.h.

Constructor & Destructor Documentation

◆ SubdomainGrainIDGenerator()

SubdomainGrainIDGenerator::SubdomainGrainIDGenerator ( const InputParameters &  parameters)

Definition at line 52 of file SubdomainGrainIDGenerator.C.

54 _boundary_mesh(getMesh("boundary_mesh")),
55 _ray_direction(getParam<Point>("ray_direction")),
56 _eps(getParam<Real>("eps")),
57 _leaf_max_size(getParam<unsigned int>("leaf_max_size"))
58{
59}
std::unique_ptr< MeshBase > & getMesh(const std::string &param_name, const bool allow_invalid=false)
const InputParameters & parameters() const
Common parameters and members for shifted boundary subdomain mesh generators that classify volume ele...
Point _ray_direction
Ray shooting direction in Point format.
std::unique_ptr< libMesh::MeshBase > & _boundary_mesh
Reference to the external boundary mesh defining grain boundaries.
unsigned int _leaf_max_size
Maximum number of boundary-element centroids in a leaf node of the k-d tree.
Real _eps
eps for intersection or on surface checking

Member Function Documentation

◆ boundingBoxesIntersect()

bool SubdomainGrainIDGenerator::boundingBoxesIntersect ( const BoundingBox &  lhs,
const BoundingBox &  rhs,
const Real  tolerance 
)
staticprotected

Check whether two bounding boxes overlap within a small tolerance.

Definition at line 234 of file SubdomainGrainIDGenerator.C.

237{
238 const Point lhs_min = lhs.min();
239 const Point lhs_max = lhs.max();
240 const Point rhs_min = rhs.min();
241 const Point rhs_max = rhs.max();
242
243 for (const auto d : make_range(LIBMESH_DIM))
244 if (lhs_max(d) + tolerance < rhs_min(d) || rhs_max(d) + tolerance < lhs_min(d))
245 return false;
246
247 return true;
248}
if(subdm)
IntRange< T > make_range(T beg, T end)

Referenced by generate().

◆ buildInOutTesters()

void SubdomainGrainIDGenerator::buildInOutTesters ( )
protected

Build the IN-OUT testers for each subdomain.

Definition at line 210 of file SubdomainGrainIDGenerator.C.

211{
214 _checker_entries.clear();
216
217 const SurfaceGeometry::RayDirectionOptions ray_options{
218 _ray_direction.norm_sq() == 0 ? SurfaceGeometry::RayDirectionMode::AUTO_PCA
219 : SurfaceGeometry::RayDirectionMode::USER_SPECIFIED,
221
222 for (const auto & [subdomain_id, elements] : _boundary_elements_by_subdomain)
223 {
224 auto checker = std::make_unique<AdaptiveRayContainmentCheck>(
225 elements, _centroids_by_subdomain.at(subdomain_id), ray_options, _eps, _leaf_max_size);
226
227 auto * checker_ptr = checker.get();
228 _subdomain_id_checkers[subdomain_id] = std::move(checker);
229 _checker_entries.push_back({subdomain_id, _bboxes_by_subdomain.at(subdomain_id), checker_ptr});
230 }
231}
std::unordered_map< SubdomainID, BoundingBox > _bboxes_by_subdomain
The bounding boxes of the boundary elements grouped by subdomains.
std::unordered_map< SubdomainID, std::unique_ptr< AdaptiveRayContainmentCheck > > _subdomain_id_checkers
The IN-OUT testers for each subdomain.
std::unordered_map< SubdomainID, std::vector< std::unique_ptr< SurfaceElement > > > _boundary_elements_by_subdomain
The boundary elements grouped by subdomains.
std::unordered_map< SubdomainID, std::vector< Point > > _centroids_by_subdomain
The centroids of the boundary elements grouped by subdomains.
std::vector< SubdomainCheckerEntry > _checker_entries
Cache contiguous checker metadata for faster per-element scans.

Referenced by generate().

◆ buildSubdomainGroupedData()

void SubdomainGrainIDGenerator::buildSubdomainGroupedData ( )
protected

build the data structure grouping by different subdomains

Definition at line 122 of file SubdomainGrainIDGenerator.C.

123{
124 struct SubdomainBuildBucket
125 {
126 SubdomainID subdomain_id;
127 std::size_t count = 0;
128 BoundingBox bbox;
129 bool has_bbox = false;
130 std::vector<Point> centroids;
131 std::vector<std::unique_ptr<SurfaceElement>> boundary_elements;
132 };
133
134 _boundary_owned = std::move(_boundary_mesh);
137 _bboxes_by_subdomain.clear();
138
139 libMesh::MeshBase * boundary_mesh = _boundary_owned.get();
140 const auto estimated_subdomains = boundary_mesh->n_subdomains();
141
142 std::unordered_map<SubdomainID, std::size_t> bucket_index_by_subdomain;
143 bucket_index_by_subdomain.reserve(estimated_subdomains);
144
145 std::vector<SubdomainBuildBucket> buckets;
146 buckets.reserve(estimated_subdomains);
147
148 auto get_or_create_bucket = [&](const SubdomainID sid) -> SubdomainBuildBucket &
149 {
150 const auto [it, inserted] = bucket_index_by_subdomain.emplace(sid, buckets.size());
151 if (inserted)
152 buckets.push_back({sid, 0, {}, false, {}, {}});
153 return buckets[it->second];
154 };
155
156 for (const auto & elem : boundary_mesh->active_element_ptr_range())
157 {
158 const auto sid = elem->subdomain_id();
159 auto & bucket = get_or_create_bucket(sid);
160 ++bucket.count;
161
162 const auto elem_bbox = elem->loose_bounding_box();
163 if (!bucket.has_bbox)
164 {
165 bucket.bbox = elem_bbox;
166 bucket.has_bbox = true;
167 }
168 else
169 bucket.bbox.union_with(elem_bbox);
170 }
171
172 _centroids_by_subdomain.reserve(buckets.size());
173 _boundary_elements_by_subdomain.reserve(buckets.size());
174 _bboxes_by_subdomain.reserve(buckets.size());
175
176 for (auto & bucket : buckets)
177 {
178 bucket.centroids.reserve(bucket.count);
179 bucket.boundary_elements.reserve(bucket.count);
180 _bboxes_by_subdomain.emplace(bucket.subdomain_id, bucket.bbox);
181 }
182
183 for (const auto & elem : boundary_mesh->active_element_ptr_range())
184 {
185 const auto sid = elem->subdomain_id();
186 auto & bucket = buckets[bucket_index_by_subdomain.at(sid)];
187
188 bucket.centroids.emplace_back(elem->vertex_average());
189
190 std::unique_ptr<SurfaceElement> bnd_elem;
191 if (elem->type() == EDGE2)
192 bnd_elem = std::make_unique<SurfaceEdge2>(elem);
193 else if (elem->type() == TRI3)
194 bnd_elem = std::make_unique<SurfaceTri3>(elem);
195 else
196 mooseError("Unsupported element type in SubdomainGrainIDGenerator");
197
198 bucket.boundary_elements.emplace_back(std::move(bnd_elem));
199 }
200
201 for (auto & bucket : buckets)
202 {
203 _centroids_by_subdomain.emplace(bucket.subdomain_id, std::move(bucket.centroids));
204 _boundary_elements_by_subdomain.emplace(bucket.subdomain_id,
205 std::move(bucket.boundary_elements));
206 }
207}
unsigned int count
void mooseError(Args &&... args) const
std::unique_ptr< libMesh::MeshBase > _boundary_owned
The boundary mesh to use for identifying grain IDs.
subdomain_id_type n_subdomains() const

Referenced by generate().

◆ generate()

std::unique_ptr< libMesh::MeshBase > SubdomainGrainIDGenerator::generate ( )
overridevirtual

Implements MeshGenerator.

Definition at line 62 of file SubdomainGrainIDGenerator.C.

63{
64 // Take ownership of the input mesh (already cloned by getMesh()).
65 std::unique_ptr<libMesh::MeshBase> mesh = std::move(_input);
66
67 std::set<SubdomainID> boundary_subdomain_ids;
68 // Bind a const reference so that we call the non-deprecated const subdomain_name() overload.
69 const libMesh::MeshBase & boundary_mesh = *_boundary_mesh;
70 boundary_mesh.subdomain_ids(boundary_subdomain_ids);
71 for (const auto subdomain_id : boundary_subdomain_ids)
72 mesh->set_subdomain_name(subdomain_id, boundary_mesh.subdomain_name(subdomain_id));
73
74 // (a) read the boundary mesh to be our own data structure
76
77 // (b) build the point-containment checker for each subdomain
79
80 std::vector<const SubdomainCheckerEntry *> candidate_entries;
81 candidate_entries.reserve(_checker_entries.size());
82
83 std::vector<SBMUtils::SubdomainOccupancy> candidate_occupancies;
84 candidate_occupancies.reserve(_checker_entries.size());
85
86 for (const auto & elem : mesh->active_element_ptr_range() /*gen only run rank = 0*/)
87 {
88 const auto elem_bbox = elem->loose_bounding_box();
89 candidate_entries.clear();
90 candidate_occupancies.clear();
91
92 for (const auto & entry : _checker_entries)
93 if (boundingBoxesIntersect(elem_bbox, entry.bbox, _eps))
94 candidate_entries.push_back(&entry);
95
96 if (candidate_entries.empty())
97 for (const auto & entry : _checker_entries)
98 candidate_entries.push_back(&entry);
99
100 for (const auto * entry : candidate_entries)
101 {
102 const auto * const checker = entry->checker;
103 const auto is_in_domain = [checker](const Point & point)
104 { return checker->sideness(point) != SurfaceGeometry::SurfaceSide::OUTSIDE; };
105 candidate_occupancies.push_back(
106 {entry->subdomain_id,
107 SBMUtils::elementDomainOccupancy(*elem, _qrule_order, is_in_domain)});
108 }
109
110 const auto subdomain = SBMUtils::selectSubdomainFromOccupancies(
111 candidate_occupancies, _intercepted_subdomain_policy, _lambda);
112 if (subdomain)
113 elem->subdomain_id() = *subdomain;
114 }
115
116 // Signal that the mesh has been modified and needs preparation.
117 mesh->unset_is_prepared();
118 return mesh;
119}
const SBMUtils::InterceptedSubdomainPolicy _intercepted_subdomain_policy
Policy for assigning partial elements to a dedicated intercepted subdomain.
const Order _qrule_order
Quadrature order used to estimate the retained-domain fraction.
const Real _lambda
Threshold applied to the fraction outside the retained domain for a partial element.
std::unique_ptr< libMesh::MeshBase > & _input
The input mesh to modify.
void buildInOutTesters()
Build the IN-OUT testers for each subdomain.
void buildSubdomainGroupedData()
build the data structure grouping by different subdomains
static bool boundingBoxesIntersect(const BoundingBox &lhs, const BoundingBox &rhs, const Real tolerance)
Check whether two bounding boxes overlap within a small tolerance.
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
MeshBase & mesh
std::optional< SubdomainID > selectSubdomainFromOccupancies(const std::vector< SubdomainOccupancy > &candidate_occupancies, const InterceptedSubdomainPolicy &intercepted_policy, Real lambda)
Select a subdomain based on how multiple candidate domains occupy an element.
Definition SBMUtils.C:92
ElementDomainOccupancy elementDomainOccupancy(const Elem &elem, Order qrule_order, const std::function< bool(const libMesh::Point &)> &is_in_domain)
Test an element against the domain defined by is_in_domain.
Definition SBMUtils.C:51

◆ validParams()

InputParameters SubdomainGrainIDGenerator::validParams ( )
static

Definition at line 16 of file SubdomainGrainIDGenerator.C.

17{
19
20 params.addRequiredParam<MeshGeneratorName>("boundary_mesh",
21 "The boundary mesh to use for identifying grain IDs");
22
23 // --- Point-In-Polyhedron checks ---
24
25 params.addParam<Point>(
26 "ray_direction", Point(0, 0, 0), "The direction of the ray for in-out testing.");
27
28 params.addParam<Real>("eps",
30 "Tolerance value used for intersection or surface proximity checks. "
31 "This parameter determines whether a point is considered on the geometry "
32 "or on the in/out sides of the geometry.");
33
34 params.addRangeCheckedParam<unsigned int>(
35 "leaf_max_size",
36 10,
37 "leaf_max_size > 0",
38 "Maximum number of boundary-element centroids per leaf node in the k-d tree "
39 "used to accelerate ray-casting point-in-grain checks. Tuning this parameter "
40 "only affects search performance, not the assigned subdomain IDs.");
41
43 "Based on the boundary_mesh, which contains distinct grain boundaries as separate "
44 "watertight regions, this generator assigns grain IDs (subdomain IDs) to the volume mesh. "
45 "Even if the mesh does not perfectly align with the grain boundaries, each element is "
46 "assigned the selected grain ID, or retains its input subdomain ID when no grain is "
47 "selected.");
48
49 return params;
50}
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
static InputParameters validParams()
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Member Data Documentation

◆ _bboxes_by_subdomain

std::unordered_map<SubdomainID, BoundingBox> SubdomainGrainIDGenerator::_bboxes_by_subdomain
protected

The bounding boxes of the boundary elements grouped by subdomains.

Definition at line 53 of file SubdomainGrainIDGenerator.h.

Referenced by buildInOutTesters(), and buildSubdomainGroupedData().

◆ _boundary_elements_by_subdomain

std::unordered_map<SubdomainID, std::vector<std::unique_ptr<SurfaceElement> > > SubdomainGrainIDGenerator::_boundary_elements_by_subdomain
protected

The boundary elements grouped by subdomains.

Definition at line 51 of file SubdomainGrainIDGenerator.h.

Referenced by buildInOutTesters(), and buildSubdomainGroupedData().

◆ _boundary_mesh

std::unique_ptr<libMesh::MeshBase>& SubdomainGrainIDGenerator::_boundary_mesh
protected

Reference to the external boundary mesh defining grain boundaries.

Definition at line 44 of file SubdomainGrainIDGenerator.h.

Referenced by buildSubdomainGroupedData(), and generate().

◆ _boundary_owned

std::unique_ptr<libMesh::MeshBase> SubdomainGrainIDGenerator::_boundary_owned
protected

The boundary mesh to use for identifying grain IDs.

Definition at line 70 of file SubdomainGrainIDGenerator.h.

Referenced by buildSubdomainGroupedData().

◆ _centroids_by_subdomain

std::unordered_map<SubdomainID, std::vector<Point> > SubdomainGrainIDGenerator::_centroids_by_subdomain
protected

The centroids of the boundary elements grouped by subdomains.

Definition at line 48 of file SubdomainGrainIDGenerator.h.

Referenced by buildInOutTesters(), and buildSubdomainGroupedData().

◆ _checker_entries

std::vector<SubdomainCheckerEntry> SubdomainGrainIDGenerator::_checker_entries
protected

Cache contiguous checker metadata for faster per-element scans.

Definition at line 59 of file SubdomainGrainIDGenerator.h.

Referenced by buildInOutTesters(), and generate().

◆ _eps

Real SubdomainGrainIDGenerator::_eps
protected

eps for intersection or on surface checking

Definition at line 65 of file SubdomainGrainIDGenerator.h.

Referenced by buildInOutTesters(), and generate().

◆ _input

std::unique_ptr<libMesh::MeshBase>& SBMSubdomainGeneratorBase::_input
protectedinherited

The input mesh to modify.

Definition at line 27 of file SBMSubdomainGeneratorBase.h.

Referenced by generate(), and SubdomainInterceptedGenerator::generate().

◆ _intercepted_subdomain_policy

const SBMUtils::InterceptedSubdomainPolicy SBMElementClassificationInterface::_intercepted_subdomain_policy
protectedinherited

◆ _lambda

const Real SBMElementClassificationInterface::_lambda
protectedinherited

Threshold applied to the fraction outside the retained domain for a partial element.

Definition at line 30 of file SBMElementClassificationInterface.h.

Referenced by InterceptedElementModifier::computeSubdomainID(), SubdomainElementModifier::computeSubdomainID(), generate(), and SubdomainInterceptedGenerator::generate().

◆ _leaf_max_size

unsigned int SubdomainGrainIDGenerator::_leaf_max_size
protected

Maximum number of boundary-element centroids in a leaf node of the k-d tree.

Definition at line 67 of file SubdomainGrainIDGenerator.h.

Referenced by buildInOutTesters().

◆ _qrule_order

const Order SBMElementClassificationInterface::_qrule_order
protectedinherited

◆ _ray_direction

Point SubdomainGrainIDGenerator::_ray_direction
protected

Ray shooting direction in Point format.

Definition at line 62 of file SubdomainGrainIDGenerator.h.

Referenced by buildInOutTesters().

◆ _subdomain_id_checkers

std::unordered_map<SubdomainID, std::unique_ptr<AdaptiveRayContainmentCheck> > SubdomainGrainIDGenerator::_subdomain_id_checkers
protected

The IN-OUT testers for each subdomain.

Definition at line 57 of file SubdomainGrainIDGenerator.h.

Referenced by buildInOutTesters().


The documentation for this class was generated from the following files: