https://mooseframework.inl.gov
StitchMeshGeneratorBase.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 
12 #include "MooseUtils.h"
13 #include "MooseMeshUtils.h"
14 
15 #include "libmesh/unstructured_mesh.h"
16 
19 {
21 
22  MooseEnum algorithm("BINARY EXHAUSTIVE", "BINARY");
23 
24  params.addParam<Real>(
25  "stitching_hmin_tolerance_factor",
26  TOLERANCE,
27  "Factor multiplied by the elements hmin to form a tolerance to use when stitching nodes");
28  params.addParam<bool>(
29  "clear_stitched_boundary_ids", true, "Whether or not to clear the stitched boundary IDs");
30  params.addRequiredParam<std::vector<std::vector<std::string>>>(
31  "stitch_boundaries_pairs",
32  "Pairs of boundaries to be stitched together between the 1st mesh in inputs and each "
33  "consecutive mesh");
34  params.addParam<MooseEnum>(
35  "algorithm",
36  algorithm,
37  "Control the use of binary search for the nodes of the stitched surfaces.");
38  params.addParam<bool>(
39  "verbose_stitching", false, "Whether mesh stitching should have verbose output.");
40 
41  return params;
42 }
43 
45  : MeshGenerator(parameters),
46  _clear_stitched_boundary_ids(getParam<bool>("clear_stitched_boundary_ids")),
47  _stitch_boundaries_pairs(
48  getParam<std::vector<std::vector<std::string>>>("stitch_boundaries_pairs")),
49  _algorithm(parameters.get<MooseEnum>("algorithm"))
50 {
51 }
52 
55  const std::string & input_mg_name,
56  const BoundaryName & bname) const
57 {
58  boundary_id_type bid;
59  try
60  {
61  bid = MooseUtils::convert<boundary_id_type>(bname, true);
62  }
63  catch (...)
64  {
65  bid = mesh.get_boundary_info().get_id_by_name(bname);
66 
67  if (bid == BoundaryInfo::invalid_id)
68  errorMissingBoundary(mesh, input_mg_name, bname);
69  }
70  return bid;
71 }
72 
73 void
75  const std::string & input_mg_name,
76  const BoundaryName & bname) const
77 {
78  std::stringstream error;
79 
80  error << "Boundary " << bname << " doesn't exist on mesh '" << input_mg_name << "'\n";
81  error << "Boundary (sideset) names that do exist: \n";
82  error << " ID : Name\n";
83 
84  auto & sideset_id_name_map = mesh.get_boundary_info().get_sideset_name_map();
85 
86  for (auto & ss_name_map_pair : sideset_id_name_map)
87  error << " " << ss_name_map_pair.first << " : " << ss_name_map_pair.second << "\n";
88 
89  error << "\nBoundary (nodeset) names that do exist: \n";
90  error << " ID : Name\n";
91 
92  auto & nodeset_id_name_map = mesh.get_boundary_info().get_nodeset_name_map();
93 
94  for (auto & ns_name_map_pair : nodeset_id_name_map)
95  error << " " << ns_name_map_pair.first << " : " << ns_name_map_pair.second << "\n";
96 
97  paramError("stitch_boundaries_pairs", error.str());
98 }
boundary_id_type getBoundaryIdToStitch(const MeshBase &mesh, const std::string &input_mg_name, const BoundaryName &bname) const
Get the boundary id from the name of a boundary to stitch.
void errorMissingBoundary(const MeshBase &mesh, const std::string &input_mg_name, const BoundaryName &bname) const
Returns an error if the boundary to be stitched does not exist.
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
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
static InputParameters validParams()
Definition: MeshGenerator.C:23
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
StitchMeshGeneratorBase(const InputParameters &parameters)
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:32