https://mooseframework.inl.gov
InitialConditionBase.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 #include "InitialConditionBase.h"
11 #include "SystemBase.h"
12 #include "MooseVariableFE.h"
13 #include "UserObject.h"
14 
17 {
23 
24  params.addRequiredParam<VariableName>("variable",
25  "The variable this initial condition is "
26  "supposed to provide values for.");
27  params.addParam<bool>("ignore_uo_dependency",
28  false,
29  "When set to true, a UserObject retrieved "
30  "by this IC will not be executed before the "
31  "this IC");
32 
33  params.addParamNamesToGroup("ignore_uo_dependency", "Advanced");
34 
35  params.registerBase("InitialCondition");
36 
37  return params;
38 }
39 
41  : MooseObject(parameters),
42  InitialConditionInterface(parameters),
43  BlockRestrictable(this),
44  Coupleable(this,
45  getParam<SystemBase *>("_sys")
46  ->getVariable(parameters.get<THREAD_ID>("_tid"),
47  parameters.get<VariableName>("variable"))
48  .isNodal()),
50  FunctionInterface(this),
51  UserObjectInterface(this),
53  BoundaryRestrictable(this, _c_nodal),
55  Restartable(this, "InitialConditionBases"),
56  ElementIDInterface(this),
57  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
58  _ignore_uo_dependency(getParam<bool>("ignore_uo_dependency"))
59 {
60  _supplied_vars.insert(getParam<VariableName>("variable"));
61 
62  const auto & coupled_vars = getCoupledVars();
63  for (const auto & it : coupled_vars)
64  for (const auto & var : it.second)
65  _depend_vars.insert(var->name());
66 }
67 
69 
70 const std::set<std::string> &
72 {
73  return _depend_vars;
74 }
75 
76 const std::set<std::string> &
78 {
79  return _supplied_vars;
80 }
81 
82 void
84 {
86  _depend_uo.insert(uo.name());
87 }
88 
89 void
90 InitialConditionBase::addPostprocessorDependencyHelper(const PostprocessorName & name) const
91 {
93  _depend_uo.insert(name);
94 }
A class for creating restricted objects.
Definition: Restartable.h:28
virtual const std::set< std::string > & getRequestedItems() override
Return a set containing the names of items requested by the object.
void addUserObjectDependencyHelper(const UserObject &uo) const override final
Helper for deriving classes to override to add dependencies when a UserObject is requested.
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
static InputParameters validParams()
std::set< UserObjectName > _depend_uo
Depend UserObjects. Mutable so that the getters can be const and still add dependencies.
Base class for a system (of equations)
Definition: SystemBase.h:84
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
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...
static InputParameters validParams()
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
static InputParameters validParams()
void addPostprocessorDependencyHelper(const PostprocessorName &name) const override final
Helper for deriving classes to override to add dependencies when a Postprocessor is requested...
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
const bool _ignore_uo_dependency
If set, UOs retrieved by this IC will not be executed before this IC.
Interface for objects that need to use UserObjects.
InitialConditionBase(const InputParameters &parameters)
Constructor.
InitialConditionInterface serves as the abstract class for InitialConditions, FVInitialConditions, and ScalarInitialConditions.
static InputParameters validParams()
std::set< std::string > _depend_vars
Dependent variables.
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:45
An interface for accessing Materials.
const std::set< BoundaryID > EMPTY_BOUNDARY_IDS
Definition: MooseTypes.h:684
std::set< std::string > _supplied_vars
Supplied variables.
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
Interface for sorting dependent vectors of objects.
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...
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
static InputParameters validParams()
Definition: MooseObject.C:25
static InputParameters validParams()
virtual const std::set< std::string > & getSuppliedItems() override
Return a set containing the names of items owned by the object.
const std::unordered_map< std::string, std::vector< MooseVariableFieldBase * > > & getCoupledVars() const
Get the list of coupled variables.
Definition: Coupleable.h:61
Interface for objects that need to use functions.
Base class for user-specific data.
Definition: UserObject.h:40
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...