www.mooseframework.org
InitialConditionBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 {
22 
23  params.addRequiredParam<VariableName>("variable",
24  "The variable this initial condition is "
25  "supposed to provide values for.");
26  params.addParam<bool>("ignore_uo_dependency",
27  false,
28  "When set to true, a UserObject retrieved "
29  "by this IC will not be executed before the "
30  "this IC");
31 
32  params.addParamNamesToGroup("ignore_uo_dependency", "Advanced");
33 
34  params.registerBase("InitialCondition");
35 
36  return params;
37 }
38 
40  : MooseObject(parameters),
41  BlockRestrictable(this),
42  Coupleable(this,
43  getParam<SystemBase *>("_sys")
44  ->getVariable(parameters.get<THREAD_ID>("_tid"),
45  parameters.get<VariableName>("variable"))
46  .isNodal()),
48  FunctionInterface(this),
49  UserObjectInterface(this),
51  BoundaryRestrictable(this, _c_nodal),
53  Restartable(this, "InitialConditionBases"),
54  ElementIDInterface(this),
55  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
56  _ignore_uo_dependency(getParam<bool>("ignore_uo_dependency"))
57 {
58  _supplied_vars.insert(getParam<VariableName>("variable"));
59 
60  const auto & coupled_vars = getCoupledVars();
61  for (const auto & it : coupled_vars)
62  for (const auto & var : it.second)
63  _depend_vars.insert(var->name());
64 }
65 
67 
68 const std::set<std::string> &
70 {
71  return _depend_vars;
72 }
73 
74 const std::set<std::string> &
76 {
77  return _supplied_vars;
78 }
79 
80 void
82 {
84  _depend_uo.insert(uo.name());
85 }
86 
87 void
88 InitialConditionBase::addPostprocessorDependencyHelper(const PostprocessorName & name) const
89 {
91  _depend_uo.insert(name);
92 }
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:1147
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:56
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:33
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.
static InputParameters validParams()
std::set< std::string > _depend_vars
Dependent variables.
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:44
An interface for accessing Materials.
const std::set< BoundaryID > EMPTY_BOUNDARY_IDS
Definition: MooseTypes.h:597
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 option 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:24
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:60
Interface for objects that need to use functions.
Base class for user-specific data.
Definition: UserObject.h:39
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:198
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...