https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SideSetExtruderGenerator.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
14
17{
19
20 params.addClassDescription("Takes a 1D or 2D mesh and extrudes a selected sideset along the "
21 "specified axis.");
22
23 params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
24 params.addRequiredParam<RealVectorValue>("extrusion_vector",
25 "The direction and length of the extrusion as a vector");
26 params.addParam<unsigned int>("num_layers", 1, "The number of layers in the extruded mesh");
27 params.addRequiredParam<BoundaryName>("sideset", "The sideset (boundary) that will be extruded");
28
29 return params;
30}
31
33 : MeshGenerator(parameters),
34 _original_input(getParam<MeshGeneratorName>("input")),
35 _extrusion_vector(getParam<RealVectorValue>("extrusion_vector")),
36 _num_layers(getParam<unsigned int>("num_layers")),
37 _sideset_name(getParam<BoundaryName>("sideset"))
38{
39 // The input "input" is used by the first sub generator; this allows us to declare
40 // that this dependency is not a dependency of SideSetExtruderGenerator but instead
41 // the LowerDBlockFromSidesetGenerator below
42 declareMeshForSub("input");
43
44 const SubdomainName extruded_block_name = "extruded_block_" + name();
45 const BoundaryName sideset_to_stitch = "to_be_stitched_" + name();
46
47 // sub generators
48 {
49 auto params = _app.getFactory().getValidParams("LowerDBlockFromSidesetGenerator");
50
51 params.set<MeshGeneratorName>("input") = _original_input;
52 params.set<SubdomainName>("new_block_name") = extruded_block_name;
53 params.set<std::vector<BoundaryName>>("sidesets") = {_sideset_name};
54
55 // generate lower dimensional mesh from the given sideset
56 addMeshSubgenerator("LowerDBlockFromSidesetGenerator", name() + "_lowerDgeneration", params);
57 }
58
59 {
60 auto params = _app.getFactory().getValidParams("BlockToMeshConverterGenerator");
61
62 params.set<MeshGeneratorName>("input") = name() + "_lowerDgeneration";
63 params.set<std::vector<SubdomainName>>("target_blocks") = {extruded_block_name};
64
65 // convert lower dimensional block to a separate mesh
66 addMeshSubgenerator("BlockToMeshConverterGenerator", name() + "_blockToMesh", params);
67 }
68
69 {
70 auto params = _app.getFactory().getValidParams("MeshExtruderGenerator");
71
72 params.set<MeshGeneratorName>("input") = name() + "_blockToMesh";
73 params.set<RealVectorValue>("extrusion_vector") = _extrusion_vector;
74 params.set<unsigned int>("num_layers") = _num_layers;
75 params.set<std::vector<BoundaryName>>("bottom_sideset") = {sideset_to_stitch};
76
77 // extrude the new, separate mesh into a higher dimension
78 addMeshSubgenerator("MeshExtruderGenerator", name() + "_extruder", params);
79 }
80
81 {
82 auto params = _app.getFactory().getValidParams("StitchMeshGenerator");
83
84 // order of vector elements matters for this generator
85 // here order by: original mesh first, our custom mesh second
86 params.set<std::vector<MeshGeneratorName>>("inputs") = {_original_input, name() + "_extruder"};
87
88 params.set<std::vector<std::vector<std::string>>>("stitch_boundaries_pairs") = {
89 {_sideset_name, sideset_to_stitch}};
90
91 // stitch the newly made high-dimensional mesh back to the original mesh
92 addMeshSubgenerator("StitchMeshGenerator", name() + "_stitched", params);
93 _build_mesh = &getMeshByName(name() + "_stitched");
94 }
95}
96
97std::unique_ptr<MeshBase>
99{
100 return std::move(*_build_mesh);
101}
registerMooseObject("MooseApp", SideSetExtruderGenerator)
void ErrorVector unsigned int
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition Factory.C:68
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
MeshGenerators are objects that can modify or add to an existing mesh.
void declareMeshForSub(const std::string &param_name)
Declares that a MeshGenerator referenced in the InputParameters is to be used as a dependency of a su...
void addMeshSubgenerator(const std::string &type, const std::string &name, Ts... extra_input_parameters)
Construct a "subgenerator", a different MeshGenerator subclass that will be added to the same MooseAp...
std::unique_ptr< MeshBase > & getMeshByName(const MeshGeneratorName &mesh_generator_name)
Like getMesh(), but takes the name of another MeshGenerator directly.
static InputParameters validParams()
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
Definition MooseApp.h:407
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
Extrude a sideset from a mesh in a given direction.
const BoundaryName _sideset_name
Name of the sideset to extrude.
static InputParameters validParams()
const unsigned int _num_layers
Number of element layers in the direction of the extrusion when extruding.
const RealVectorValue _extrusion_vector
Extrusion vector containing both the direction and the magnitude of the sideset extrusion.
const MeshGeneratorName _original_input
Name of the base mesh containing the sideset to extruded.
SideSetExtruderGenerator(const InputParameters &parameters)
std::unique_ptr< MeshBase > * _build_mesh
Mesh generated from each sub-generator.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.