https://mooseframework.inl.gov
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 
17 class PhysicsBase;
18 class FEProblemBase;
19 
20 #define registerActionComponent(app_name, component_name) \
21  registerMooseAction(app_name, component_name, "list_component")
22 
26 class ActionComponent : public Action, public InputParametersChecksUtils<ActionComponent>
27 {
28 public:
30 
31  ActionComponent(const InputParameters & params);
32 
33  virtual void act() override final;
34 
38  const std::vector<MeshGeneratorName> & meshGeneratorNames() const { return _mg_names; }
39 
41  const std::vector<SubdomainName> & blocks() const { return _blocks; }
42 
44  virtual const std::vector<BoundaryName> & outerSurfaceBoundaries() const
45  {
46  mooseError("Not implemented");
47  };
48 
50  virtual Real volume() const { mooseError("Volume routine is not implemented"); }
51 
53  virtual Real outerSurfaceArea() const { mooseError("Outer surface area is not implemented"); }
54 
56  unsigned int dimension() const { return _dimension; }
57 
58 protected:
59  // The default implementation of these routines will do nothing as we do not expect all Components
60  // to be defining an object of every type
61  // These routines are to help define a strictly geometrical component
62  virtual void addMeshGenerators() {}
63  virtual void addPositionsObject() {}
64  virtual void addUserObjects() {}
65  virtual void setupComponent() {}
66 
67  // These routines can help define a component that also defines a Physics
69  virtual void addSolverVariables() {}
72  virtual void addPhysics() {}
74  virtual void addMaterials() {}
77  virtual void checkIntegrity() {}
78 
80  virtual void actOnAdditionalTasks() {}
81 
84  void addRequiredTask(const std::string & task) { _required_tasks.insert(task); }
85 
87  void checkRequiredTasks() const;
88 
91  {
92  mooseAssert(_awh.problemBase().get(), "There should be a problem");
93  return *_awh.problemBase().get();
94  }
95 
97  Factory & getFactory() const { return _factory; }
98 
100  unsigned int _dimension;
101 
103  std::vector<MeshGeneratorName> _mg_names;
104 
106  std::vector<SubdomainName> _blocks;
107 
109  std::vector<BoundaryName> _outer_boundaries;
110 
112  const bool _verbose;
113 
115  std::set<std::string> _required_tasks;
116 };
virtual void checkIntegrity()
Used for various checks notably:
virtual const std::vector< BoundaryName > & outerSurfaceBoundaries() const
Return the outer surface boundaries.
std::set< std::string > _required_tasks
Manually keeps track of the tasks required by each component as tasks cannot be inherited.
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Definition: Action.h:159
Generic factory class for build all sorts of objects.
Definition: Factory.h:28
Base class to help creating an entire physics.
Definition: PhysicsBase.h:30
virtual void addSolverVariables()
Used to add variables on a component.
virtual void actOnAdditionalTasks()
Use this if registering a new task to the derived ActionComponent.
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.
unsigned int _dimension
Maximum dimension of the component.
Base class for components that are defined using an action.
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...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
static InputParameters validParams()
Base class for actions.
Definition: Action.h:33
std::shared_ptr< FEProblemBase > & problemBase()
void checkRequiredTasks() const
Checks that tasks marked required by parent classes are indeed registered to derived classes...
virtual void act() override final
Method to add objects to the simulation or perform other setup tasks.
Factory & _factory
The Factory associated with the MooseApp.
Utility class to help check parameters.
FEProblemBase & getProblem()
Get problem from action warehouse.
unsigned int dimension() const
Return the dimension of the component.
virtual Real volume() const
Return the component volume.
std::vector< SubdomainName > _blocks
Names of the blocks the component is comprised of.
virtual void setupComponent()
virtual void addMeshGenerators()
virtual void addMaterials()
Used to add materials or functor materials on a component.
const bool _verbose
Whether the component setup should be verbose.
Factory & getFactory() const
Get the factory to build (often physics-related but not always) objects (for example a Positions) ...
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...
ActionComponent(const InputParameters &params)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< BoundaryName > _outer_boundaries
Names of the boundaries on the component outer surface.
virtual Real outerSurfaceArea() const
Return the component outer boundary area.
virtual void addPositionsObject()
const std::vector< SubdomainName > & blocks() const
Returns the subdomains for the component mesh, if any.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual void addPhysics()
Used to add one or more Physics to be active on the component.
virtual void addUserObjects()