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 "MeshGeneratorComponent.h" 12 : #include "RotationMatrix.h" 13 : 14 : registerActionComponent("MooseApp", MeshGeneratorComponent); 15 : registerMooseAction("MooseApp", MeshGeneratorComponent, "add_mesh_generator"); 16 : // MeshGeneratorComponent is an exmaple of ComponentPhysicsInterface 17 : registerMooseAction("MooseApp", MeshGeneratorComponent, "init_component_physics"); 18 : // MeshGeneratorComponent is an example of ComponentMaterialPropertyInterface 19 : registerMooseAction("MooseApp", MeshGeneratorComponent, "add_material"); 20 : // MeshGeneratorComponent is an example of ComponentInitialConditionInterface 21 : registerMooseAction("MooseApp", MeshGeneratorComponent, "check_integrity"); 22 : 23 : InputParameters 24 207 : MeshGeneratorComponent::validParams() 25 : { 26 207 : InputParameters params = ActionComponent::validParams(); 27 207 : params += ComponentPhysicsInterface::validParams(); 28 207 : params += ComponentMaterialPropertyInterface::validParams(); 29 207 : params += ComponentInitialConditionInterface::validParams(); 30 207 : params += ComponentBoundaryConditionInterface::validParams(); 31 207 : params.addRequiredParam<MeshGeneratorName>("mesh_generator", "Mesh generator providing the mesh"); 32 207 : MooseEnum mesh_generator_type("saved_mesh final_generator"); 33 207 : params.addRequiredParam<MooseEnum>("mesh_generator_type", 34 : mesh_generator_type, 35 : "Whether the mesh generator providing the mesh is the final " 36 : "mesh generator, or simply provides a 'saved_mesh'"); 37 207 : params.addParam<std::string>("saved_mesh_name", "Name used to generate the mesh"); 38 207 : params.addClassDescription("Component with a mesh coming from a mesh generator."); 39 : 40 414 : return params; 41 207 : } 42 : 43 24 : MeshGeneratorComponent::MeshGeneratorComponent(const InputParameters & params) 44 : : ActionComponent(params), 45 : ComponentPhysicsInterface(params), 46 : ComponentMaterialPropertyInterface(params), 47 : ComponentInitialConditionInterface(params), 48 : ComponentBoundaryConditionInterface(params), 49 24 : _mesh_generator_type(getParam<MooseEnum>("mesh_generator_type")) 50 : { 51 24 : if (_mesh_generator_type == "saved_mesh" && !isParamValid("saved_mesh_name")) 52 0 : paramError("saved_mesh_name", 53 : "The name of the saved mesh must be provided if using a mesh generator that saves " 54 : "the mesh for the component to use"); 55 : 56 24 : addRequiredTask("add_mesh_generator"); 57 24 : } 58 : 59 : void 60 24 : MeshGeneratorComponent::addMeshGenerators() 61 : { 62 : // The mesh generator will end up as an input to the final combiner generator 63 24 : _mg_names.push_back(getParam<MeshGeneratorName>("mesh_generator")); 64 24 : } 65 : 66 : void 67 0 : MeshGeneratorComponent::setupComponent() 68 : { 69 : const auto saved_mesh = 70 0 : (_mesh_generator_type == "saved_mesh") 71 0 : ? _app.getMeshGeneratorSystem().getSavedMesh(getParam<std::string>("saved_mesh_name")) 72 0 : : nullptr; 73 0 : const auto component_mesh = saved_mesh ? saved_mesh.get() : _mesh->getMeshPtr(); 74 : mooseAssert(component_mesh, "Should have a mesh"); 75 : 76 : // Get list of blocks from the saved mesh 77 0 : std::set<subdomain_id_type> blocks; 78 0 : component_mesh->subdomain_ids(blocks); 79 0 : for (const auto bid : blocks) 80 0 : _blocks.push_back(component_mesh->subdomain_name(bid)); 81 0 : } 82 : 83 : void 84 24 : MeshGeneratorComponent::checkIntegrity() 85 : { 86 24 : ComponentInitialConditionInterface::checkIntegrity(); 87 24 : ComponentBoundaryConditionInterface::checkIntegrity(); 88 24 : }