https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ScalarInitialCondition.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
11#include "MooseVariableScalar.h"
12#include "FEProblem.h"
13#include "SystemBase.h"
14
17{
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 InitialConditionInterface(parameters),
31 ScalarCoupleable(this),
35 _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
36 _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
37 _tid(parameters.get<THREAD_ID>("_tid")),
38 _t(_fe_problem.time()),
39 _var(_sys.getScalarVariable(_tid, getParam<VariableName>("variable"))),
40 _assembly(
41 _fe_problem.assembly(_tid, _var.kind() == Moose::VAR_SOLVER ? _var.sys().number() : 0))
42{
43 _supplied_vars.insert(getParam<VariableName>("variable"));
44
45 const std::vector<MooseVariableScalar *> & coupled_vars = getCoupledMooseScalarVars();
46 for (const auto & var : coupled_vars)
47 _depend_vars.insert(var->name());
48}
49
51
52const std::set<std::string> &
57
58const std::set<std::string> &
63
64void
65ScalarInitialCondition::compute(DenseVector<Number> & vals)
66{
67 for (_i = 0; _i < _var.order(); ++_i)
68 vals(_i) = value();
69}
unsigned int THREAD_ID
Definition MooseTypes.h:237
Interface for sorting dependent vectors of objects.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Interface for objects that need to use functions.
InitialConditionInterface serves as the abstract class for InitialConditions, FVInitialConditions,...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
static InputParameters validParams()
Definition MooseObject.C:25
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int.
Interface for objects that needs scalar coupling capabilities.
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars()
Get the list of coupled scalar variables.
std::set< std::string > _depend_vars
virtual const std::set< std::string > & getRequestedItems()
Return a set containing the names of items requested by the object.
virtual Real value()=0
The value of the variable.
static InputParameters validParams()
virtual const std::set< std::string > & getSuppliedItems()
Return a set containing the names of items owned by the object.
virtual void compute(DenseVector< Number > &vals)
Compute the initial condition.
std::set< std::string > _supplied_vars
MooseVariableScalar & _var
Scalar variable this initial condition works on.
ScalarInitialCondition(const InputParameters &parameters)
Constructor.
Base class for a system (of equations)
Definition SystemBase.h:87
Interface for objects that need to use UserObjects.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...