https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ActionComponent.h
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#pragma once
11
12// MOOSE includes
13#include "Action.h"
14#include "ActionWarehouse.h"
16
17class PhysicsBase;
18class FEProblemBase;
19
20#define registerActionComponent(app_name, component_name) \
21 registerMooseAction(app_name, component_name, "list_component")
22
26class ActionComponent : public Action, public InputParametersChecksUtils<ActionComponent>
27{
28public:
30
31 ActionComponent(const InputParameters & params);
32
33 virtual void act() override final;
34
38 const std::vector<MeshGeneratorName> & meshGeneratorNames() const { return _mg_names; }
42 MeshGeneratorName getCurrentTopLevelMeshGeneratorName() const { return _top_mg_name; }
44 void setCurrentTopLevelMeshGeneratorName(const MeshGeneratorName & mg_name)
45 {
46 _top_mg_name = mg_name;
47 }
48
50 const std::vector<SubdomainName> & blocks() const { return _blocks; }
51
53 virtual const std::vector<BoundaryName> & outerSurfaceBoundaries() const
54 {
55 mooseError("Not implemented");
56 };
57
59 virtual Real volume() const { mooseError("Volume routine is not implemented"); }
60
62 virtual Real outerSurfaceArea() const { mooseError("Outer surface area is not implemented"); }
63
65 unsigned int dimension() const { return _dimension; }
66
69 void addConnectedComponent(ActionComponent & component);
71 const std::set<ActionComponent *> & getConnectedComponents() const
72 {
74 }
75
76protected:
77 // The default implementation of these routines will do nothing as we do not expect all Components
78 // to be defining an object of every type
79 // These routines are to help define a strictly geometrical component
80 virtual void addMeshGenerators() {}
81 virtual void addPositionsObject() {}
82 virtual void addUserObjects() {}
83 virtual void setupComponent() {}
84
85 // These routines can help define a component that also defines a Physics
87 virtual void addSolverVariables() {}
90 virtual void addPhysics() {}
92 virtual void addMaterials() {}
95 virtual void checkIntegrity() {}
96
98 virtual void actOnAdditionalTasks() {}
99
102 void addRequiredTask(const std::string & task) { _required_tasks.insert(task); }
103
105 void checkRequiredTasks() const;
106
109 {
110 mooseAssert(_awh.problemBase().get(), "There should be a problem");
111 return *_awh.problemBase().get();
112 }
113
115 Factory & getFactory() const { return _factory; }
116
118 unsigned int _dimension;
119
121 std::vector<MeshGeneratorName> _mg_names;
123 MeshGeneratorName _top_mg_name;
124
126 std::vector<SubdomainName> _blocks;
127
129 std::vector<BoundaryName> _outer_boundaries;
130
132 const bool _verbose;
133
135 std::set<std::string> _required_tasks;
136
139 std::shared_ptr<std::set<ActionComponent *>> _connected_components;
140};
Base class for components that are defined using an action.
std::vector< BoundaryName > _outer_boundaries
Names of the boundaries on the component outer surface.
FEProblemBase & getProblem()
Get problem from action warehouse.
virtual void actOnAdditionalTasks()
Use this if registering a new task to the derived ActionComponent.
const std::vector< MeshGeneratorName > & meshGeneratorNames() const
Get the name(s) of the mesh generator(s) created by this component that generates the mesh for it.
Factory & getFactory() const
Get the factory to build (often physics-related but not always) objects (for example a Positions)
virtual Real outerSurfaceArea() const
Return the component outer boundary area.
virtual void addPhysics()
Used to add one or more Physics to be active on the component.
virtual void addMaterials()
Used to add materials or functor materials on a component.
const std::vector< SubdomainName > & blocks() const
Returns the subdomains for the component mesh, if any.
virtual Real volume() const
Return the component volume.
void checkRequiredTasks() const
Checks that tasks marked required by parent classes are indeed registered to derived classes.
std::vector< MeshGeneratorName > _mg_names
Name(s) of the final mesh generator(s) creating the mesh for the component.
virtual void act() override final
Method to add objects to the simulation or perform other setup tasks.
void addConnectedComponent(ActionComponent &component)
Merge another component's group into this component's group.
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.
virtual void addUserObjects()
std::set< std::string > _required_tasks
Manually keeps track of the tasks required by each component as tasks cannot be inherited.
virtual void addPositionsObject()
std::shared_ptr< std::set< ActionComponent * > > _connected_components
Group of components that share a common mesh after junctioning.
const std::set< ActionComponent * > & getConnectedComponents() const
Get all components connected to the component group of this component (including itself)
const bool _verbose
Whether the component setup should be verbose.
virtual void checkIntegrity()
Used for various checks notably:
virtual void setupComponent()
MeshGeneratorName _top_mg_name
Name of the top-most mesh generator in the hierarchy of MGs on top of the ones generating this compon...
virtual const std::vector< BoundaryName > & outerSurfaceBoundaries() const
Return the outer surface boundaries.
static InputParameters validParams()
unsigned int _dimension
Maximum dimension of the component.
void setCurrentTopLevelMeshGeneratorName(const MeshGeneratorName &mg_name)
Set the name of the final mesh generator that contains this component.
virtual void addMeshGenerators()
virtual void addSolverVariables()
Used to add variables on a component.
MeshGeneratorName getCurrentTopLevelMeshGeneratorName() const
Return the name of the final mesh generator that contains this component This may not be one of the m...
unsigned int dimension() const
Return the dimension of the component.
std::shared_ptr< FEProblemBase > & problemBase()
Base class for actions.
Definition Action.h:38
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition Action.h:169
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Generic factory class for build all sorts of objects.
Definition Factory.h:29
Utility class to help check parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
Factory & _factory
The Factory associated with the MooseApp.
Base class to help creating an entire physics.
Definition PhysicsBase.h:31