https://mooseframework.inl.gov
StitchBoundaryMeshGenerator.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 "CastUniquePointer.h"
12 #include "MooseUtils.h"
13 #include "libmesh/unstructured_mesh.h"
14 
16 
19 {
21 
22  MooseEnum algorithm("BINARY EXHAUSTIVE", "BINARY");
23 
24  params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
25  params.addParam<bool>(
26  "clear_stitched_boundary_ids", true, "Whether or not to clear the stitched boundary IDs");
27  params.addParam<MooseEnum>(
28  "algorithm",
29  algorithm,
30  "Control the use of binary search for the nodes of the stitched surfaces.");
31  params.addRequiredParam<std::vector<boundary_id_type>>(
32  "stitch_boundaries_pair", "Pair of boundaries to be stitched together.");
33  params.addClassDescription("Allows a pair of boundaries to be stitched together.");
34 
35  return params;
36 }
37 
39  : MeshGenerator(parameters),
40  _input(getMesh("input")),
41  _clear_stitched_boundary_ids(getParam<bool>("clear_stitched_boundary_ids")),
42  _stitch_boundaries_pair(getParam<std::vector<boundary_id_type>>("stitch_boundaries_pair")),
43  _algorithm(parameters.get<MooseEnum>("algorithm"))
44 {
45 }
46 
47 std::unique_ptr<MeshBase>
49 {
50  std::unique_ptr<UnstructuredMesh> mesh =
51  dynamic_pointer_cast<UnstructuredMesh>(std::move(_input));
52 
53  const bool use_binary_search = (_algorithm == "BINARY");
54 
55  // stitch_surfaces only recognizes node_set boundaries
56  mesh->get_boundary_info().build_node_list_from_side_list();
57 
58  mesh->stitch_surfaces(_stitch_boundaries_pair[0],
60  TOLERANCE,
62  /*verbose = */ true,
63  use_binary_search);
64 
65  mesh->set_isnt_prepared();
66  return dynamic_pointer_cast<MeshBase>(mesh);
67 }
Allows a pair of boundaries to be "stitched" together.
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
const bool & _clear_stitched_boundary_ids
Whether or not to clear (remove) the stitched boundary IDs.
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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.
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...
static InputParameters validParams()
int8_t boundary_id_type
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
std::vector< boundary_id_type > _stitch_boundaries_pair
Pair of stitch boundaries.
static InputParameters validParams()
Definition: MeshGenerator.C:23
StitchBoundaryMeshGenerator(const InputParameters &parameters)
std::unique_ptr< MeshBase > & _input
the input mesh
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
registerMooseObject("MooseApp", StitchBoundaryMeshGenerator)
MooseEnum _algorithm
Type of algorithm used to find matching nodes (binary or exhaustive)
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:32