https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
12#include "RotationMatrix.h"
13
15registerMooseAction("MooseApp", MeshGeneratorComponent, "add_mesh_generator");
16// MeshGeneratorComponent is an exmaple of ComponentPhysicsInterface
17registerMooseAction("MooseApp", MeshGeneratorComponent, "init_component_physics");
18// MeshGeneratorComponent is an example of ComponentMaterialPropertyInterface
19registerMooseAction("MooseApp", MeshGeneratorComponent, "add_material");
20// MeshGeneratorComponent is an example of ComponentInitialConditionInterface
21registerMooseAction("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
59void
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
66void
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
83void
registerActionComponent("MooseApp", MeshGeneratorComponent)
registerMooseAction("MooseApp", MeshGeneratorComponent, "add_mesh_generator")
Base class for components that are defined using an action.
const std::vector< SubdomainName > & blocks() const
Returns the subdomains for the component mesh, if any.
std::vector< MeshGeneratorName > _mg_names
Name(s) of the final mesh generator(s) creating the mesh for the component.
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...
std::vector< SubdomainName > _blocks
Names of the blocks the component is comprised of.
static InputParameters validParams()
std::shared_ptr< MooseMesh > & _mesh
Definition Action.h:174
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
Helper class to help Components accept boundary condition parameters that the Physics may use to gene...
virtual void checkIntegrity() override
Used for various checks notably:
Helper class to help Components define the initial conditions the Physics may need from the parameter...
virtual void checkIntegrity() override
Used for various checks notably:
Helper class to help Components define the material properties the Physics may need from the paramete...
Helper class to help creating an entire physics Note: Trying out virtual inheritance.
static InputParameters validParams()
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.
Component whose mesh is generated in the [Mesh] block on which one can define a Physics.
virtual void setupComponent() override
const MooseEnum _mesh_generator_type
Whether the component uses a saved mesh or the final mesh.
virtual void addMeshGenerators() override
static InputParameters validParams()
Class constructor.
MeshGeneratorComponent(const InputParameters &params)
void checkIntegrity() override
Used for various checks notably:
std::unique_ptr< libMesh::MeshBase > getSavedMesh(const std::string &name)
Get the saved mesh by name.
MeshGeneratorSystem & getMeshGeneratorSystem()
Gets the system that manages the MeshGenerators.
Definition MooseApp.h:886
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 ...
Definition MooseBase.h:457
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55