Line data Source code
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"); 20 : registerActionComponent("MooseApp", CylinderComponent); 21 : 22 : InputParameters 23 353 : CylinderComponent::validParams() 24 : { 25 353 : InputParameters params = ActionComponent::validParams(); 26 353 : params += ComponentPhysicsInterface::validParams(); 27 353 : params += ComponentMaterialPropertyInterface::validParams(); 28 353 : params += ComponentInitialConditionInterface::validParams(); 29 353 : params += ComponentBoundaryConditionInterface::validParams(); 30 353 : params += ComponentMeshTransformHelper::validParams(); 31 353 : params.addClassDescription("Cylindrical component."); 32 353 : MooseEnum dims("0 1 2 3"); 33 353 : 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 353 : params.addRequiredRangeCheckedParam<Real>("radius", "radius>0", "Radius of the cylinder"); 39 353 : params.addRequiredRangeCheckedParam<Real>("length", "length>0", "Length/Height of the cylinder"); 40 : 41 353 : params.addRequiredParam<unsigned int>("n_axial", "Number of axial elements of the cylinder"); 42 353 : params.addParam<unsigned int>("n_radial", "Number of radial elements of the cylinder"); 43 353 : params.addParam<unsigned int>("n_azimuthal", "Number of azimuthal elements of the cylinder"); 44 : 45 353 : params.addParam<SubdomainName>("block", "Block name for the cylinder"); 46 : 47 706 : return params; 48 353 : } 49 : 50 162 : CylinderComponent::CylinderComponent(const InputParameters & params) 51 : : ActionComponent(params), 52 : ComponentPhysicsInterface(params), 53 : ComponentMaterialPropertyInterface(params), 54 : ComponentInitialConditionInterface(params), 55 : ComponentBoundaryConditionInterface(params), 56 : ComponentMeshTransformHelper(params), 57 154 : _radius(getParam<Real>("radius")), 58 316 : _height(getParam<Real>("length")) 59 : { 60 154 : _dimension = getParam<MooseEnum>("dimension"); 61 154 : addRequiredTask("add_mesh_generator"); 62 154 : } 63 : 64 : void 65 154 : CylinderComponent::addMeshGenerators() 66 : { 67 : // Create the base mesh for the component using a mesh generator 68 154 : if (_dimension == 0) 69 0 : paramError("dimension", "0D cylinder not implemented"); 70 154 : else if (_dimension == 1 || _dimension == 2) 71 : { 72 154 : InputParameters params = _factory.getValidParams("GeneratedMeshGenerator"); 73 154 : params.set<MooseEnum>("dim") = _dimension; 74 154 : params.set<Real>("xmax") = {getParam<Real>("length")}; 75 154 : params.set<unsigned int>("nx") = {getParam<unsigned int>("n_axial")}; 76 154 : params.set<std::string>("boundary_name_prefix") = name(); 77 154 : if (_dimension == 2) 78 : { 79 154 : params.set<Real>("ymax") = {getParam<Real>("radius")}; 80 154 : if (!isParamValid("n_radial")) 81 0 : paramError("n_radial", "Should be provided for a 2D cylinder"); 82 154 : params.set<unsigned int>("ny") = {getParam<unsigned int>("n_radial")}; 83 : } 84 0 : else if (isParamValid("n_radial")) 85 0 : paramError("n_radial", "Should not be provided for a 1D cylinder"); 86 154 : if (isParamValid("block")) 87 : { 88 128 : const auto block_name = getParam<SubdomainName>("block"); 89 128 : params.set<SubdomainName>("subdomain_name") = block_name; 90 128 : _blocks.push_back(block_name); 91 128 : } 92 308 : _app.getMeshGeneratorSystem().addMeshGenerator( 93 308 : "GeneratedMeshGenerator", name() + "_base", params); 94 154 : _mg_names.push_back(name() + "_base"); 95 154 : } 96 : else 97 : { 98 0 : 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 : 105 154 : ComponentMeshTransformHelper::addMeshGenerators(); 106 154 : } 107 : 108 : void 109 0 : CylinderComponent::setupComponent() 110 : { 111 0 : if (_dimension == 2) 112 0 : _awh.getMesh()->setCoordSystem(_blocks, MultiMooseEnum("COORD_RZ")); 113 0 : } 114 : 115 : void 116 138 : CylinderComponent::checkIntegrity() 117 : { 118 138 : ComponentInitialConditionInterface::checkIntegrity(); 119 134 : ComponentBoundaryConditionInterface::checkIntegrity(); 120 130 : }