https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
53boundary_id_type
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
73void
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}
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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...
MeshGenerators are objects that can modify or add to an existing mesh.
static InputParameters validParams()
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 ...
Definition MooseBase.h:457
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
static InputParameters validParams()
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.
StitchMeshGeneratorBase(const InputParameters &parameters)
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.
MeshBase & mesh