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{
21 "Constructs boundary elements and a centroid KDTree from a pre-existing surface mesh. "
22 "The surface mesh is specified in the Mesh block via `save_with_name`.");
23
25 params.addParam<int>(
26 "leaf_max_size",
27 10,
28 "Maximum number of points allowed in a leaf node of the KDTree. "
29 "Smaller values yield deeper trees with faster queries but slower build times; "
30 "larger values result in shallower trees with faster builds but slower queries. "
31 "Benchmarking is recommended to find an optimal tradeoff for your use case.");
32
34 params.addParam<bool>(
35 "build_kd_tree",
36 true,
37 "Whether to build a kd-tree or not. If false, the kd-tree will not be built, "
38 "and the mesh will be used directly for queries.");
39
40 return params;
41}
42
44 : BoundaryMeshBuilder(parameters),
45 _leaf_max_size(getParam<int>("leaf_max_size")),
46 _build_kd_tree(getParam<bool>("build_kd_tree"))
47{
48}
49
50void
52{
53 // Build the mesh + whole-mesh SurfaceElementSet (and run shared validation).
55
56 // The centroid KD-tree is aligned index-for-index with surfaceElementSet().elements().
58 _kd_tree = std::make_unique<KDTree>(surfaceElementSet().centroids(), _leaf_max_size);
59}
60
61KDTree &
63{
64 mooseAssert(_kd_tree, "KDTree not built; callers must guard with hasKDTree() first.");
65 return *_kd_tree;
66}
registerMooseObject("ShiftedBoundaryMethodApp", SBMSurfaceMeshBuilder)
void ErrorVector unsigned int
static InputParameters validParams()
virtual void initialSetup() override
const SurfaceElementSet & surfaceElementSet() const
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 KD-tree over the whole-mesh Su...
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 KD-tree.
static InputParameters validParams()
SBMSurfaceMeshBuilder(const InputParameters &parameters)
std::unique_ptr< KDTree > _kd_tree
The KDTree is constructed using the centroids of the elements in the boundary mesh.
const int _leaf_max_size
Configures KDTree leaf node size for performance tuning.