www.mooseframework.org
ScalarInitialCondition.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "ScalarInitialCondition.h"
16 #include "MooseVariableScalar.h"
17 #include "FEProblem.h"
18 #include "SystemBase.h"
19 
20 template <>
23 {
25  params.addParam<VariableName>(
26  "variable", "The variable this initial condition is supposed to provide values for.");
27 
28  params.registerBase("ScalarInitialCondition");
29 
30  return params;
31 }
32 
34  : MooseObject(parameters),
35  ScalarCoupleable(this),
36  FunctionInterface(this),
38  _fe_problem(*parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
39  _sys(*parameters.getCheckedPointerParam<SystemBase *>("_sys")),
40  _tid(parameters.get<THREAD_ID>("_tid")),
41  _assembly(_fe_problem.assembly(_tid)),
42  _t(_fe_problem.time()),
43  _var(_sys.getScalarVariable(_tid, getParam<VariableName>("variable")))
44 {
45  _supplied_vars.insert(getParam<VariableName>("variable"));
46 
47  const std::vector<MooseVariableScalar *> & coupled_vars = getCoupledMooseScalarVars();
48  for (const auto & var : coupled_vars)
49  _depend_vars.insert(var->name());
50 }
51 
53 
54 const std::set<std::string> &
56 {
57  return _depend_vars;
58 }
59 
60 const std::set<std::string> &
62 {
63  return _supplied_vars;
64 }
65 
66 void
67 ScalarInitialCondition::compute(DenseVector<Number> & vals)
68 {
69  for (_i = 0; _i < _var.order(); ++_i)
70  vals(_i) = value();
71 }
InputParameters validParams< ScalarInitialCondition >()
virtual const std::set< std::string > & getSuppliedItems()
Return a set containing the names of items owned by the object.
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars()
Get the list of coupled scalar variables.
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:91
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.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:22
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...
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
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:79