https://mooseframework.inl.gov
MeshGeneratorComponent.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 "MeshGeneratorComponent.h"
12 #include "RotationMatrix.h"
13 
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 
25 {
31  params.addRequiredParam<MeshGeneratorName>("mesh_generator", "Mesh generator providing the mesh");
32  MooseEnum mesh_generator_type("saved_mesh final_generator");
33  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  params.addParam<std::string>("saved_mesh_name", "Name used to generate the mesh");
38  params.addClassDescription("Component with a mesh coming from a mesh generator.");
39 
40  return params;
41 }
42 
44  : ActionComponent(params),
49  _mesh_generator_type(getParam<MooseEnum>("mesh_generator_type"))
50 {
51  if (_mesh_generator_type == "saved_mesh" && !isParamValid("saved_mesh_name"))
52  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  addRequiredTask("add_mesh_generator");
57 }
58 
59 void
61 {
62  // The mesh generator will end up as an input to the final combiner generator
63  _mg_names.push_back(getParam<MeshGeneratorName>("mesh_generator"));
64 }
65 
66 void
68 {
69  const auto saved_mesh =
70  (_mesh_generator_type == "saved_mesh")
71  ? _app.getMeshGeneratorSystem().getSavedMesh(getParam<std::string>("saved_mesh_name"))
72  : nullptr;
73  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  std::set<subdomain_id_type> blocks;
78  component_mesh->subdomain_ids(blocks);
79  for (const auto bid : blocks)
80  _blocks.push_back(component_mesh->subdomain_name(bid));
81 }
82 
83 void
85 {
88 }
registerActionComponent("MooseApp", MeshGeneratorComponent)
std::unique_ptr< libMesh::MeshBase > getSavedMesh(const std::string &name)
Get the saved mesh by name.
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.
Base class for components that are defined using an action.
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...
const MooseEnum _mesh_generator_type
Whether the component uses a saved mesh or the final mesh.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
registerMooseAction("MooseApp", MeshGeneratorComponent, "add_mesh_generator")
virtual void checkIntegrity() override
Used for various checks notably:
static InputParameters validParams()
Helper class to help creating an entire physics Note: Trying out virtual inheritance.
std::vector< SubdomainName > _blocks
Names of the blocks the component is comprised of.
Component whose mesh is generated in the [Mesh] block on which one can define a Physics.
void checkIntegrity() override
Used for various checks notably:
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
static InputParameters validParams()
Class constructor.
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 setupComponent() override
virtual void addMeshGenerators() override
virtual void checkIntegrity() override
Used for various checks notably:
Helper class to help Components accept boundary condition parameters that the Physics may use to gene...
MeshGeneratorComponent(const InputParameters &params)
std::shared_ptr< MooseMesh > & _mesh
Definition: Action.h:164
const std::vector< SubdomainName > & blocks() const
Returns the subdomains for the component mesh, if any.
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...
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...