https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SideSetsFromNodeSetsGenerator.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 "CastUniquePointer.h"
13#include "libmesh/boundary_info.h"
14#include "libmesh/elem_side_builder.h"
15
17
20{
22
23 params.addClassDescription("Mesh generator which constructs side sets from node sets");
24 params.addRequiredParam<MeshGeneratorName>("input",
25 "Input mesh the operation will be applied to");
26 params.addParam<std::vector<BoundaryName>>(
27 "nodesets_to_convert",
28 "If specified, list of nodesets to convert. If not specified, all nodesets are converted");
29 return params;
30}
31
33 : MeshGenerator(parameters), _input(getMesh("input"))
34{
35}
36
37std::unique_ptr<MeshBase>
39{
40 if (!isParamValid("nodesets_to_convert"))
41 _input->get_boundary_info().build_side_list_from_node_list();
42 else
43 {
44 const auto & nodeset_names = getParam<std::vector<BoundaryName>>("nodesets_to_convert");
45 auto & binfo = _input->get_boundary_info();
46
47 std::set<BoundaryID> nodeset_ids;
48 for (const auto & nodeset_name : nodeset_names)
49 {
50 // Look through the nodeset map.
51 BoundaryID nodeset_id = std::numeric_limits<BoundaryID>::max();
52 for (const auto & [id, name] : binfo.get_nodeset_name_map())
53 if (name == nodeset_name)
54 nodeset_id = id;
55 if (MooseUtils::isDigits(nodeset_name))
56 nodeset_id = std::stoi(nodeset_name);
57 if (nodeset_id == std::numeric_limits<BoundaryID>::max())
58 paramError("nodesets_to_convert",
59 "Nodeset '" + nodeset_name + "' does not exist in the input mesh");
60 nodeset_ids.insert(nodeset_id);
61 }
62 _input->get_boundary_info().build_side_list_from_node_list(nodeset_ids);
63 }
64
65 return dynamic_pointer_cast<MeshBase>(_input);
66}
boundary_id_type BoundaryID
registerMooseObject("MooseApp", SideSetsFromNodeSetsGenerator)
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...
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.
MeshGenerators are objects that can modify or add to an existing mesh.
static InputParameters validParams()
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
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
MeshGenerator for constructing side Sets from node sets.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
std::unique_ptr< MeshBase > & _input
Input mesh the operation will be applied to.
SideSetsFromNodeSetsGenerator(const InputParameters &parameters)