https://mooseframework.inl.gov
CylinderComponent.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 
10 // MOOSE includes
11 #include "CylinderComponent.h"
12 
13 registerMooseAction("MooseApp", CylinderComponent, "add_mesh_generator");
14 // CylinderComponent is an example of ComponentPhysicsInterface
15 registerMooseAction("MooseApp", CylinderComponent, "init_component_physics");
16 // CylinderComponent is an example of ComponentMaterialPropertyInterface
17 registerMooseAction("MooseApp", CylinderComponent, "add_material");
18 // CylinderComponent is an example of ComponentInitialConditionInterface
19 registerMooseAction("MooseApp", CylinderComponent, "check_integrity");
21 
24 {
31  params.addClassDescription("Cylindrical component.");
32  MooseEnum dims("0 1 2 3");
33  params.addRequiredParam<MooseEnum>("dimension",
34  dims,
35  "Dimension of the cylinder. 0 for a point (not implemented), "
36  "1 for an (axial) 1D line, 2 for a 2D-RZ cylinder, and 3 for "
37  "a 3D cylinder (not implemented)");
38  params.addRequiredRangeCheckedParam<Real>("radius", "radius>0", "Radius of the cylinder");
39  params.addRequiredRangeCheckedParam<Real>("length", "length>0", "Length/Height of the cylinder");
40 
41  params.addRequiredParam<unsigned int>("n_axial", "Number of axial elements of the cylinder");
42  params.addParam<unsigned int>("n_radial", "Number of radial elements of the cylinder");
43  params.addParam<unsigned int>("n_azimuthal", "Number of azimuthal elements of the cylinder");
44 
45  params.addParam<SubdomainName>("block", "Block name for the cylinder");
46 
47  return params;
48 }
49 
51  : ActionComponent(params),
57  _radius(getParam<Real>("radius")),
58  _height(getParam<Real>("length"))
59 {
60  _dimension = getParam<MooseEnum>("dimension");
61  addRequiredTask("add_mesh_generator");
62 }
63 
64 void
66 {
67  // Create the base mesh for the component using a mesh generator
68  if (_dimension == 0)
69  paramError("dimension", "0D cylinder not implemented");
70  else if (_dimension == 1 || _dimension == 2)
71  {
72  InputParameters params = _factory.getValidParams("GeneratedMeshGenerator");
73  params.set<MooseEnum>("dim") = _dimension;
74  params.set<Real>("xmax") = {getParam<Real>("length")};
75  params.set<unsigned int>("nx") = {getParam<unsigned int>("n_axial")};
76  params.set<std::string>("boundary_name_prefix") = name();
77  if (_dimension == 2)
78  {
79  params.set<Real>("ymax") = {getParam<Real>("radius")};
80  if (!isParamValid("n_radial"))
81  paramError("n_radial", "Should be provided for a 2D cylinder");
82  params.set<unsigned int>("ny") = {getParam<unsigned int>("n_radial")};
83  }
84  else if (isParamValid("n_radial"))
85  paramError("n_radial", "Should not be provided for a 1D cylinder");
86  if (isParamValid("block"))
87  {
88  const auto block_name = getParam<SubdomainName>("block");
89  params.set<SubdomainName>("subdomain_name") = block_name;
90  _blocks.push_back(block_name);
91  }
93  "GeneratedMeshGenerator", name() + "_base", params);
94  _mg_names.push_back(name() + "_base");
95  }
96  else
97  {
98  paramError("dimension", "3D cylinder is not implemented");
99  if (!isParamValid("n_radial"))
100  paramError("n_radial", "Should be provided for a 3D cylinder");
101  if (!isParamValid("n_azimuthal"))
102  paramError("n_azimuthal", "Should be provided in 3D");
103  }
104 
106 }
107 
108 void
110 {
111  if (_dimension == 2)
112  _awh.getMesh()->setCoordSystem(_blocks, MultiMooseEnum("COORD_RZ"));
113 }
114 
115 void
117 {
120 }
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
These methods add an range checked parameters.
virtual void setupComponent() override
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:159
Cylinder on which one can define a Physics.
const std::shared_ptr< MooseMesh > & getMesh() const
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
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...
std::vector< MeshGeneratorName > _mg_names
Name(s) of the final mesh generator(s) creating the mesh for the component.
unsigned int _dimension
Maximum dimension of the component.
Base class for components that are defined using an action.
Helper class to help Components be located with the orientation and position we want.
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
static InputParameters validParams()
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 addMeshGenerator(const std::string &type, const std::string &name, const InputParameters &params)
Add a mesh generator that will act on the meshes in the system.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Factory & _factory
The Factory associated with the MooseApp.
virtual void checkIntegrity() override
Used for various checks notably:
static InputParameters validParams()
virtual void addMeshGenerators() override
Helper class to help creating an entire physics Note: Trying out virtual inheritance.
CylinderComponent(const InputParameters &params)
std::vector< SubdomainName > _blocks
Names of the blocks the component is comprised of.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
Helper class to help Components define the material properties the Physics may need from the paramete...
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
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 ...
void addRequiredTask(const std::string &task)
Add a new required task for all physics deriving from this class NOTE: This does not register the tas...
virtual void checkIntegrity() override
Used for various checks notably:
static InputParameters validParams()
Helper class to help Components accept boundary condition parameters that the Physics may use to gene...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void checkIntegrity() override
Used for various checks notably:
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...
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...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
MeshGeneratorSystem & getMeshGeneratorSystem()
Gets the system that manages the MeshGenerators.
Definition: MooseApp.h:863
Helper class to help Components define the initial conditions the Physics may need from the parameter...
registerMooseAction("MooseApp", CylinderComponent, "add_mesh_generator")
registerActionComponent("MooseApp", CylinderComponent)