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 
15 template <>
18 {
20  params.addParam<VariableName>(
21  "variable", "The variable this initial condition is supposed to provide values for.");
22 
23  params.registerBase("ScalarInitialCondition");
24 
25  return params;
26 }
27 
29  : MooseObject(parameters),
30  ScalarCoupleable(this),
31  FunctionInterface(this),
32  UserObjectInterface(this),
34  _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
35  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
36  _tid(parameters.get<THREAD_ID>("_tid")),
37  _assembly(_fe_problem.assembly(_tid)),
38  _t(_fe_problem.time()),
39  _var(_sys.getScalarVariable(_tid, getParam<VariableName>("variable")))
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
63 ScalarInitialCondition::compute(DenseVector<Number> & vals)
64 {
65  for (_i = 0; _i < _var.order(); ++_i)
66  vals(_i) = value();
67 }
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:92
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:42
Interface for objects that need to use UserObjects.
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:25
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...
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:161