https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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 params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
22 params.renameParam("stitch_boundaries_pairs",
23 "stitch_boundaries_pair",
24 "Pair of boundaries to be stitched together.");
25 params.addClassDescription("Allows a pair of boundaries to be stitched together.");
26
27 return params;
28}
29
31 : StitchMeshGeneratorBase(parameters), _input(getMesh("input"))
32{
33 if (_stitch_boundaries_pairs.size() != 1 && _stitch_boundaries_pairs[0].size() != 2)
34 paramError("stitch_boundaries_pair", "Can only stitch two boundaries together.");
35}
36
37std::unique_ptr<MeshBase>
39{
40 std::unique_ptr<UnstructuredMesh> mesh =
41 dynamic_pointer_cast<UnstructuredMesh>(std::move(_input));
42
43 const bool use_binary_search = (_algorithm == "BINARY");
44
45 // stitch_surfaces only recognizes node_set boundaries
46 mesh->get_boundary_info().build_node_list_from_side_list();
47
48 // Check that boundaries exist
49 const auto first_bid = getBoundaryIdToStitch(*mesh, name(), _stitch_boundaries_pairs[0][0]);
50 const auto second_bid = getBoundaryIdToStitch(*mesh, name(), _stitch_boundaries_pairs[0][1]);
51
52 // Stitch the boundaries
53 mesh->stitch_surfaces(first_bid,
54 second_bid,
55 TOLERANCE,
57 getParam<bool>("verbose_stitching"),
58 use_binary_search,
59 getParam<Real>("stitching_hmin_tolerance_factor"));
60
61 mesh->unset_is_prepared();
62 return dynamic_pointer_cast<MeshBase>(mesh);
63}
registerMooseObject("MooseApp", StitchBoundaryMeshGenerator)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void renameParam(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
Rename a parameter and provide a new documentation string.
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...
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.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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
Allows a pair of boundaries to be "stitched" together.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
StitchBoundaryMeshGenerator(const InputParameters &parameters)
std::unique_ptr< MeshBase > & _input
the input mesh
A base class for mesh generators that stitch boundaries together.
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.
const bool _clear_stitched_boundary_ids
Whether or not to clear (remove) the stitched boundary IDs.
const std::vector< std::vector< std::string > > _stitch_boundaries_pairs
A transformed version of _stitch_boundaries into a more logical "pairwise" structure.
const MooseEnum _algorithm
Type of algorithm used to find matching nodes (binary or exhaustive)
MeshBase & mesh