16 #include "libmesh/mesh_serializer.h" 17 #include "libmesh/elem.h" 27 MooseEnum location(
"INSIDE OUTSIDE",
"INSIDE");
30 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The mesh we want to modify.");
31 params.
addRequiredParam<MeshGeneratorName>(
"manifold",
"The mesh defining a closed manifold.");
33 params.
addParam<SubdomainName>(
"block_name",
"Optional subdomain name to assign.");
35 "location", location,
"Control whether the manifold interior or exterior is tagged.");
36 params.
addParam<std::vector<SubdomainName>>(
"restricted_subdomains",
37 "Only reset subdomain ID for given subdomains.");
41 "surface_tolerance>0",
42 "Absolute geometric tolerance used for manifold validation and near-surface classification. " 43 "Choose this relative to the STL length scale and expected coordinate noise.");
45 "Changes the subdomain ID of elements whose vertex-average point lies inside or outside a " 46 "closed manifold defined by surface mesh.");
52 _input(getMesh(
"input")),
53 _manifold(getMesh(
"manifold")),
56 _has_restriction(isParamValid(
"restricted_subdomains")),
57 _surface_tolerance(getParam<
Real>(
"surface_tolerance"))
59 #if LIBMESH_DOF_ID_BYTES != 8 61 "moose", 32898,
"ManifoldSubdomainGenerator currently only works with 64-bit DoF IDs");
65 std::unique_ptr<MeshBase>
68 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
69 std::unique_ptr<MeshBase> manifold_mesh = std::move(
_manifold);
72 if (
mesh->mesh_dimension() != 3)
73 paramError(
"input",
"Only 3D meshes are supported.");
76 if (!manifold_mesh->is_prepared())
77 manifold_mesh->prepare_for_use();
81 if (*(manifold_mesh->elem_dimensions().begin()) != 2 ||
82 *(manifold_mesh->elem_dimensions().rbegin()) != 2)
83 paramError(
"manifold",
"Only 2D meshes are supported.");
85 std::set<SubdomainID> restricted_ids;
89 const auto & names = getParam<std::vector<SubdomainName>>(
"restricted_subdomains");
90 for (
const auto &
name : names)
93 paramError(
"restricted_subdomains",
"The block '",
name,
"' was not found in the mesh");
102 " already exists on the input mesh. Elements outside the closed manifold that are " 103 "already assigned to this block will remain unchanged.");
111 for (
const auto & elem :
mesh->active_element_ptr_range())
125 mesh->subdomain_name(
_block_id) = getParam<SubdomainName>(
"block_name");
128 mesh->unset_has_cached_elem_data();
void mooseInfo(Args &&... args) const
const Real _surface_tolerance
Absolute tolerance used by the manifold classifier; choose relative to geometry scale/noise.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
const MooseEnum _location
Whether to tag the interior or exterior of the STL manifold.
MeshGenerator for defining a subdomain based on whether element vertex averages lie within a closed m...
const subdomain_id_type _block_id
Target subdomain identifier to assign.
void mooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
ManifoldSubdomainGenerator(const InputParameters ¶meters)
Construct the mesh generator from user input.
registerMooseObject("MooseApp", ManifoldSubdomainGenerator)
SubdomainID getSubdomainID(const SubdomainName &subdomain_name, const MeshBase &mesh)
Gets the subdomain ID associated with the given SubdomainName.
bool hasSubdomainID(const MeshBase &input_mesh, const SubdomainID &id)
Whether a particular subdomain ID exists in the mesh.
std::unique_ptr< MeshBase > & _input
Input mesh to modify in place.
static InputParameters validParams()
Declare the input parameters for STL-based subdomain assignment.
const std::string & name() const
Get the name of the class.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
bool contains(std::string_view superstring, std::string_view substring)
const bool _has_restriction
Whether retagging is limited to a subset of existing subdomains.
static InputParameters validParams()
bool hasSubdomainName(const MeshBase &input_mesh, const SubdomainName &name)
Whether a particular subdomain name exists in the mesh.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::unique_ptr< MeshBase > & _manifold
Surface mesh that defines the closed manifold.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Utility for querying point containment against a closed triangulated surface mesh.
std::unique_ptr< MeshBase > generate() override
Apply STL-based subdomain tagging using element vertex averages as the query points.
MeshGenerators are objects that can modify or add to an existing mesh.
const Elem & get(const ElemType type_in)
bool contains(const Point &point) const