www.mooseframework.org
ScalarInitialCondition.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 "ScalarInitialCondition.h"
11 #include "MooseVariableScalar.h"
12 #include "FEProblem.h"
13 #include "SystemBase.h"
14 
17 {
19  params.addParam<VariableName>(
20  "variable", "The variable this initial condition is supposed to provide values for.");
21 
22  params.registerBase("ScalarInitialCondition");
23 
24  return params;
25 }
26 
28  : MooseObject(parameters),
29  ScalarCoupleable(this),
30  FunctionInterface(this),
31  UserObjectInterface(this),
33  _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
34  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
35  _tid(parameters.get<THREAD_ID>("_tid")),
36  _t(_fe_problem.time()),
37  _var(_sys.getScalarVariable(_tid, getParam<VariableName>("variable"))),
38  _assembly(
39  _fe_problem.assembly(_tid, _var.kind() == Moose::VAR_NONLINEAR ? _var.sys().number() : 0))
40 {
41  _supplied_vars.insert(getParam<VariableName>("variable"));
42 
43  const std::vector<MooseVariableScalar *> & coupled_vars = getCoupledMooseScalarVars();
44  for (const auto & var : coupled_vars)
45  _depend_vars.insert(var->name());
46 }
47 
49 
50 const std::set<std::string> &
52 {
53  return _depend_vars;
54 }
55 
56 const std::set<std::string> &
58 {
59  return _supplied_vars;
60 }
61 
62 void
64 {
65  for (_i = 0; _i < _var.order(); ++_i)
66  vals(_i) = value();
67 }
virtual const std::set< std::string > & getSuppliedItems()
Return a set containing the names of items owned by the object.
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...
Base class for a system (of equations)
Definition: SystemBase.h:84
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
std::set< std::string > _depend_vars
virtual Real value()=0
The value of the variable.
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars()
Get the list of coupled scalar variables.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
Interface for objects that need to use UserObjects.
static InputParameters validParams()
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
MooseVariableScalar & _var
Scalar variable this initial condition works on.
Interface for sorting dependent vectors of objects.
Interface for objects that needs scalar coupling capabilities.
ScalarInitialCondition(const InputParameters &parameters)
Constructor.
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...
virtual const std::set< std::string > & getRequestedItems()
Return a set containing the names of items requested by the object.
std::set< std::string > _supplied_vars
static InputParameters validParams()
Definition: MooseObject.C:24
virtual void compute(DenseVector< Number > &vals)
Compute the initial condition.
Interface for objects that need to use functions.
unsigned int THREAD_ID
Definition: MooseTypes.h:198