https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SolutionScalarAux.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
10#include "MooseError.h"
11#include "SolutionScalarAux.h"
13
15
18{
21 "Sets scalar variable by using information from a SolutionUserObject.");
22 params.addRequiredParam<UserObjectName>("solution", "The name of the SolutionUserObject");
23 params.addParam<std::string>("from_variable",
24 "The name of the variable to extract from the file");
25 params.addParam<Real>(
26 "scale_factor",
27 1.0,
28 "Scale factor (a) to be applied to the solution (x): ax+b, where b is the 'add_factor'");
29 params.addParam<Real>(
30 "add_factor",
31 0.0,
32 "Add this value (b) to the solution (x): ax+b, where a is the 'scale_factor'");
33 return params;
34}
35
37 : AuxScalarKernel(parameters),
38 _solution_object(getUserObject<SolutionUserObjectBase>("solution")),
39 _scale_factor(getParam<Real>("scale_factor")),
40 _add_factor(getParam<Real>("add_factor"))
41{
42}
43
44void
46{
47 if (isParamValid("from_variable"))
48 _var_name = getParam<std::string>("from_variable");
49 else
50 {
51 const std::vector<std::string> & vars = _solution_object.variableNames();
52 if (vars.size() > 1)
54 ": The SolutionUserObject contains multiple variables, please specifiy the "
55 "desired variable in the input file using the 'from_variable' parameter.");
56
57 _var_name = vars[0];
58 }
59}
60
61Real
char ** vars
registerMooseObject("MooseApp", SolutionScalarAux)
Base class for making kernels that work on auxiliary scalar variables.
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 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...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition MooseBase.h:271
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
AuxScalarKernel for reading a solution from file.
std::string _var_name
The variable name of interest.
SolutionScalarAux(const InputParameters &parameters)
static InputParameters validParams()
virtual Real computeValue() override
Compute the value of this kernel.
const Real _scale_factor
Multiplier for the solution, the a of ax+b.
const SolutionUserObjectBase & _solution_object
Reference to the SolutionUserObject storing the solution.
const Real _add_factor
Additional factor added to the solution, the b of ax+b.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
User object that reads an existing solution from an input file and uses it in the current simulation.
Real scalarValue(Real t, const std::string &var_name) const
Returns a value of a global variable.
const std::vector< std::string > & variableNames() const