22 #define registerPhysicsBaseTasks(app_name, derived_name) \ 23 registerMooseAction(app_name, derived_name, "init_physics"); \ 24 registerMooseAction(app_name, derived_name, "copy_vars_physics"); \ 25 registerMooseAction(app_name, derived_name, "check_integrity_early_physics") 46 virtual void act() override final;
57 void addBlocksById(
const std::vector<SubdomainID> & block_ids);
69 const std::vector<SubdomainName> &
blocks,
70 const bool error_if_not_identical =
true)
const;
85 const T *
getCoupledPhysics(
const PhysicsName & phys_name,
const bool allow_fail =
false)
const;
120 mooseAssert(
_problem,
"Requesting the problem too early");
125 mooseAssert(
_problem,
"Requesting the problem too early");
138 bool are_nonlinear =
true);
152 bool variableExists(
const VariableName & var_name,
bool error_if_aux)
const;
158 const SolverSystemName &
getSolverSystem(
unsigned int variable_index)
const;
160 const SolverSystemName &
getSolverSystem(
const VariableName & variable_name)
const;
189 const std::vector<std::pair<MooseEnumItem, std::string>> & petsc_pair_options);
206 const std::vector<SubdomainName> &
blocks,
207 const bool error_if_aux);
223 const std::vector<SubdomainName> &
blocks,
224 const bool ic_is_default_ic,
225 const bool error_if_already_defined)
const;
238 const std::vector<SubdomainName> &
blocks,
239 const bool error_if_already_defined)
const;
253 const std::string & object_type,
254 const std::string & object_name =
"")
const;
343 template <
typename T>
347 constexpr
bool is_physics = std::is_base_of<PhysicsBase, T>::value;
349 mooseAssert(is_physics,
"Must be a PhysicsBase to be retrieved by getCoupledPhysics");
351 for (
const auto *
const physics : all_T_physics)
353 if (physics->name() == phys_name)
359 "' does not exist or is not of type '",
360 MooseUtils::prettyCppType<T>(),
366 template <
typename T>
367 const std::vector<T *>
370 constexpr
bool is_physics = std::is_base_of<PhysicsBase, T>::value;
372 mooseAssert(is_physics,
"Must be a PhysicsBase to be retrieved by getCoupledPhysics");
374 if (!allow_fail && all_T_physics.empty())
375 mooseError(
"No Physics of requested type '", MooseUtils::prettyCppType<T>(),
"'");
377 return all_T_physics;
380 template <
typename T>
384 if (!dynamic_cast<const T *>(&component))
385 mooseError(
"Component '" + component.
name() +
"' must be of type '" +
386 MooseUtils::prettyCppType<T>() +
"'.\nIt is currently of type '" + component.
type() +
std::string prefix() const
Use prefix() to disambiguate names.
const std::vector< VariableName > & auxVariableNames() const
Return the list of aux variables in this physics.
virtual void act() override final
Forwards from the action tasks to the implemented addXYZ() in the derived classes If you need more th...
virtual InputParameters getAdditionalRMParams() const
Provide additional parameters for the relationship managers.
virtual void addInitialConditions()
void assignBlocks(InputParameters ¶ms, const std::vector< SubdomainName > &blocks) const
Set the blocks parameter to the input parameters of an object this Physics will create.
bool shouldCreateVariable(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_aux)
Returns whether this Physics should create the variable.
std::vector< VariableName > _aux_var_names
Vector of the aux variables in the Physics.
Factory & getFactory()
Get the factory for this physics The factory lets you get the parameters for objects.
virtual void addFVInterfaceKernels()
virtual void addPreconditioning()
MooseEnum _is_transient
Whether the physics is to be solved as a transient.
const unsigned int invalid_uint
RelationshipManagerType
Main types of Relationship Managers.
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
void initializePhysics()
Process some parameters that require the problem to be created. Executed on init_physics.
void addRequiredPhysicsTask(const std::string &task)
Add a new required task for all physics deriving from this class NOTE: This does not register the tas...
void addPetscPairsToPetscOptions(const std::vector< std::pair< MooseEnumItem, std::string >> &petsc_pair_options)
Process the given petsc option pairs into the system solver settings.
Generic factory class for build all sorts of objects.
Factory & _factory
The Factory associated with the MooseApp.
virtual void checkIntegrity() const
Additional checks performed near the end of the setup phase.
virtual const FEProblemBase & getProblem() const
Base class to help creating an entire physics.
const InputParameters & parameters() const
Get the parameters of the object.
virtual void checkIntegrityEarly() const
Additional checks performed once the executioner / executor has been created.
virtual void addMultiApps()
virtual void addAuxiliaryKernels()
const T * getCoupledPhysics(const PhysicsName &phys_name, const bool allow_fail=false) const
Get a Physics from the ActionWarehouse with the requested type and name.
virtual void addPeriodicBCs()
const std::vector< SubdomainName > & blocks() const
Return the blocks this physics is defined on.
void reportPotentiallyMissedParameters(const std::vector< std::string > ¶m_names, const std::string &object_type, const std::string &object_name="") const
When this is called, we are knowingly not using the value of these parameters.
const MooseEnum & _preconditioning
Whether to add a default preconditioning.
bool solverVariableExists(const VariableName &var_name) const
Check whether a variable already exists and is a solver variable.
const bool _verbose
Whether to output additional information.
Base class for components that are defined using an action.
bool shouldCreateIC(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool ic_is_default_ic, const bool error_if_already_defined) const
Returns whether this Physics should create the variable.
bool shouldCreateTimeDerivative(const VariableName &var_name, const std::vector< SubdomainName > &blocks, const bool error_if_already_defined) const
Returns whether this Physics should create the variable.
bool allMeshBlocks(const std::vector< SubdomainName > &blocks) const
Check if a vector contains all the mesh blocks.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::vector< SubdomainName > _blocks
Keep track of the subdomains the Physics is defined on.
unsigned int dimension() const
Return the maximum dimension of the blocks the Physics is active on.
void checkComponentType(const ActionComponent &component) const
Check that the component is of the desired type.
void addBlocks(const std::vector< SubdomainName > &blocks)
Add new blocks to the Physics.
void saveAuxVariableName(const VariableName &var_name)
Keep track of the name of an aux variable defined in the Physics.
virtual FEProblemBase & getProblem()
Get the problem for this physics Useful to add objects to the simulation.
void libmesh_ignore(const Args &...)
const std::string & name() const
Get the name of the class.
virtual void addNodalBCs()
const SolverSystemName & getSolverSystem(unsigned int variable_index) const
Get the solver system for this variable index.
virtual void addNodalKernels()
virtual void addDGKernels()
virtual void addMaterials()
std::set< std::string > _required_tasks
Manually keeps track of the tasks required by each physics as tasks cannot be inherited.
bool isVariableScalar(const VariableName &var_name) const
Whether the variable is a scalar variable (global single scalar, not a field)
PhysicsBase(const InputParameters ¶meters)
void copyVariablesFromMesh(const std::vector< VariableName > &variables_to_copy, bool are_nonlinear=true)
Copy nonlinear or aux variables from the mesh file.
unsigned int _dim
Dimension of the physics, which we expect for now to be the dimension of the mesh NOTE: this is not k...
virtual void addReporters()
bool isVariableFV(const VariableName &var_name) const
Whether the variable is a finite volume variable.
std::vector< std::string > getSubdomainNamesAndIDs(const std::set< SubdomainID > &blocks) const
Get the vector of subdomain names and ids for the incoming set of subdomain IDs.
const std::string & type() const
Get the type of this class.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual void addPostprocessors()
Factory & getFactory() const
virtual void addFunctions()
virtual void addSolverVariables()
The default implementation of these routines will do nothing as we do not expect all Physics to be de...
virtual void addExecutioner()
bool hasBlocks(const std::vector< SubdomainName > &blocks) const
Whether the Physics is defined on those blocks.
const std::vector< VariableName > & solverVariableNames() const
Return the list of solver (nonlinear + linear) variables in this physics.
bool variableExists(const VariableName &var_name, bool error_if_aux) const
Check whether a variable already exists.
bool checkBlockRestrictionIdentical(const std::string &object_name, const std::vector< SubdomainName > &blocks, const bool error_if_not_identical=true) const
Check if an external object has the same block restriction.
virtual void addFVKernels()
static InputParameters validParams()
std::vector< VariableName > _solver_var_names
Vector of the solver variables (nonlinear and linear) in the Physics.
std::set< SubdomainID > getSubdomainIDs(const std::set< SubdomainName > &blocks) const
Get the set of subdomain ids for the incoming vector of subdomain names.
virtual void addComponent(const ActionComponent &component)
Most basic way of adding a component: simply adding the blocks to the block restriction of the Physic...
virtual void addFEKernels()
virtual void addUserObjects()
virtual void addRelationshipManagers(Moose::RelationshipManagerType input_rm_type) override
Method to add a relationship manager for the objects being added to the system.
virtual void actOnAdditionalTasks()
Routine to add additional setup work on additional registered tasks to a Physics. ...
void addBlocksById(const std::vector< SubdomainID > &block_ids)
void prepareCopyVariablesFromMesh() const
Tell the app if we want to use Exodus restart.
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...
virtual void addOutputs()
bool addRelationshipManagers(Moose::RelationshipManagerType when_type, const InputParameters &moose_object_pars)
Method to add a relationship manager for the objects being added to the system.
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
virtual void addDiracKernels()
virtual void addVectorPostprocessors()
virtual void addExecutors()
virtual void addInterfaceKernels()
virtual void addFunctorMaterials()
const ActionComponent & getActionComponent(const ComponentName &comp_name) const
Get a component with the requested name.
std::vector< const T * > getActions()
Retrieve all actions in a specific type ordered by their names.
std::vector< unsigned int > _system_numbers
System numbers for the system(s) owning the solver variables.
virtual void addTransfers()
virtual void addCorrectors()
void saveSolverVariableName(const VariableName &var_name)
Keep track of the name of the solver variable defined in the Physics.
std::vector< SolverSystemName > _system_names
System names for the system(s) owning the solver variables.
bool isTransient() const
Return whether the Physics is solved using a transient.
virtual void addAuxiliaryVariables()
virtual void initializePhysicsAdditional()
Additional initialization work that should happen very early, as soon as the problem is created...
virtual void addScalarKernels()
void checkRequiredTasks() const
Check the list of required tasks for missing tasks.