https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SBMSurfaceMeshBuilder.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 "InputParameters.h"
12
13// Register object
14registerMooseObject("ShiftedBoundaryMethodApp", SBMSurfaceMeshBuilder);
15
18{
20 params.renameParam(
21 "boundary_mesh", "interface_mesh", "The saved mesh representing one interface surface.");
23 "Constructs boundary elements and a centroid k-d tree from a pre-existing surface mesh. "
24 "The surface mesh is specified in the Mesh block via `save_with_name`.");
25
27 params.addParam<int>(
28 "leaf_max_size",
29 10,
30 "Maximum number of points allowed in a leaf node of the k-d tree. "
31 "Smaller values yield deeper trees with faster queries but slower build times; "
32 "larger values result in shallower trees with faster builds but slower queries. "
33 "Benchmarking is recommended to find an optimal tradeoff for your use case.");
34
36 params.addParam<bool>(
37 "build_kd_tree",
38 true,
39 "Whether to build a k-d tree or not. If false, the k-d tree will not be built, "
40 "and the mesh will be used directly for queries.");
41
42 return params;
43}
44
46 : BoundaryMeshBuilder(parameters),
47 _leaf_max_size(getParam<int>("leaf_max_size")),
48 _build_kd_tree(getParam<bool>("build_kd_tree"))
49{
50}
51
52void
54{
55 // Build the mesh + whole-mesh SurfaceElementSet (and run shared validation).
57
58 // The centroid k-d tree is aligned index-for-index with surfaceElementSet().elements().
60 _kd_tree = std::make_unique<KDTree>(surfaceElementSet().centroids(), _leaf_max_size);
61}
62
63KDTree &
65{
66 mooseAssert(_kd_tree, "KDTree not built; callers must guard with hasKDTree() first.");
67 return *_kd_tree;
68}
registerMooseObject("ShiftedBoundaryMethodApp", SBMSurfaceMeshBuilder)
void ErrorVector unsigned int
static InputParameters validParams()
virtual void initialSetup() override
const SurfaceElementSet & surfaceElementSet() const
void renameParam(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
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)
BoundaryMeshBuilder specialization that additionally builds a centroid k-d tree over the whole-mesh S...
virtual void initialSetup() override
KDTree & getKDTree() const
Returns a mutable reference because KDTree::neighborSearch is non-const (nanoflann's knnSearch thread...
const bool _build_kd_tree
Whether to build the centroid k-d tree.
static InputParameters validParams()
SBMSurfaceMeshBuilder(const InputParameters &parameters)
std::unique_ptr< KDTree > _kd_tree
The k-d tree is constructed using the centroids of the elements in the boundary mesh.
const int _leaf_max_size
Configures k-d tree leaf node size for performance tuning.