www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ScalarCoupleable Class Reference

Interface for objects that needs scalar coupling capabilities. More...

#include <ScalarCoupleable.h>

Inheritance diagram for ScalarCoupleable:
[legend]

Public Member Functions

 ScalarCoupleable (const MooseObject *moose_object)
 Constructing the object. More...
 
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars ()
 Get the list of coupled scalar variables. More...
 
const std::set< TagID > & getScalarVariableCoupleableVectorTags () const
 
const std::set< TagID > & getScalarVariableCoupleableMatrixTags () const
 

Protected Member Functions

bool isCoupledScalar (const std::string &var_name, unsigned int i=0) const
 Returns true if a variables has been coupled_as name. More...
 
unsigned int coupledScalarComponents (const std::string &var_name) const
 Return the number of components to the coupled scalar variable. More...
 
unsigned int coupledScalar (const std::string &var_name, unsigned int comp=0) const
 Returns the index for a scalar coupled variable by name. More...
 
Order coupledScalarOrder (const std::string &var_name, unsigned int comp=0) const
 Returns the order for a scalar coupled variable by name. More...
 
const VariableValuecoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 Returns value of a scalar coupled variable. More...
 
const ADVariableValueadCoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 Returns AD value of a scalar coupled variable. More...
 
template<bool is_ad>
const GenericVariableValue< is_ad > & coupledGenericScalarValue (const std::string &var_name, unsigned int comp=0) const
 Returns value of a coupled scalar variable for use in templated automatic differentiation classes. More...
 
const VariableValuecoupledVectorTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 Returns value of a scalar coupled variable. More...
 
const VariableValuecoupledMatrixTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 Returns value of a scalar coupled variable. More...
 
const VariableValuecoupledScalarValueOld (const std::string &var_name, unsigned int comp=0) const
 Returns the old (previous time step) value of a scalar coupled variable. More...
 
const VariableValuecoupledScalarValueOlder (const std::string &var_name, unsigned int comp=0) const
 Returns the older (two time steps previous) value of a scalar coupled variable. More...
 
const VariableValuecoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 Returns the time derivative of a scalar coupled variable. More...
 
const ADVariableValueadCoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 Returns the time derivative of a scalar coupled variable, including its dependence on the nonlinear degrees of freedom through automatic differentiation. More...
 
const VariableValuecoupledScalarDotDot (const std::string &var_name, unsigned int comp=0) const
 Returns the second time derivative of a scalar coupled variable. More...
 
const VariableValuecoupledScalarDotOld (const std::string &var_name, unsigned int comp=0) const
 Returns the old time derivative of a scalar coupled variable. More...
 
const VariableValuecoupledScalarDotDotOld (const std::string &var_name, unsigned int comp=0) const
 Returns the old second time derivative of a scalar coupled variable. More...
 
const VariableValuecoupledScalarDotDu (const std::string &var_name, unsigned int comp=0) const
 Time derivative of a scalar coupled variable with respect to the coefficients. More...
 
const VariableValuecoupledScalarDotDotDu (const std::string &var_name, unsigned int comp=0) const
 Second time derivative of a scalar coupled variable with respect to the coefficients. More...
 
const MooseVariableScalargetScalarVar (const std::string &var_name, unsigned int comp) const
 Extract pointer to a scalar coupled variable. More...
 
template<>
const GenericVariableValue< false > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
template<>
const GenericVariableValue< true > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 

Protected Attributes

FEProblemBase_sc_fe_problem
 
const THREAD_ID _sc_tid
 Thread ID of the thread using this object. More...
 
const Real_real_zero
 Scalar zero. More...
 
const VariableValue_scalar_zero
 Zero value of a scalar variable. More...
 
const Point & _point_zero
 Zero point. More...
 

Private Member Functions

const VariableValuegetDefaultValue (const std::string &var_name) const
 Helper method to return (and insert if necessary) the default value for an uncoupled variable. More...
 
const ADVariableValuegetADDefaultValue (const std::string &var_name) const
 Helper method to return (and insert if necessary) the AD default value for an uncoupled variable. More...
 
void checkVar (const std::string &var_name) const
 Check that the right kind of variable is being coupled in. More...
 
void validateExecutionerType (const std::string &name, const std::string &fn_name) const
 Checks to make sure that the current Executioner has set "_is_transient" when old/older values are coupled in. More...
 

Private Attributes

const InputParameters_sc_parameters
 
const std::string & _sc_name
 The name of the object this interface is part of. More...
 
const bool _sc_is_implicit
 True if implicit value is required. More...
 
std::unordered_map< std::string, std::vector< MooseVariableScalar * > > _coupled_scalar_vars
 Coupled vars whose values we provide. More...
 
std::unordered_map< std::string, std::unique_ptr< VariableValue > > _default_value
 Will hold the default value for optional coupled scalar variables. More...
 
std::unordered_map< std::string, std::unique_ptr< ADVariableValue > > _dual_default_value
 Will hold the default AD value for optional coupled scalar variables. More...
 
std::vector< MooseVariableScalar * > _coupled_moose_scalar_vars
 Vector of coupled variables. More...
 
std::unordered_map< std::string, std::vector< MooseVariableFieldBase * > > _sc_coupled_vars
 Field variables coupled into this object (for error checking) More...
 
std::set< TagID_sc_coupleable_vector_tags
 The scalar coupleable vector tags. More...
 
std::set< TagID_sc_coupleable_matrix_tags
 The scalar coupleable matrix tags. More...
 

Detailed Description

Interface for objects that needs scalar coupling capabilities.

Definition at line 32 of file ScalarCoupleable.h.

Constructor & Destructor Documentation

◆ ScalarCoupleable()

ScalarCoupleable::ScalarCoupleable ( const MooseObject moose_object)

Constructing the object.

Parameters
parametersParameters that come from constructing the object

Definition at line 19 of file ScalarCoupleable.C.

21  *moose_object->parameters().getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
22  _sc_tid(moose_object->parameters().isParamValid("_tid")
23  ? moose_object->parameters().get<THREAD_ID>("_tid")
24  : 0),
28  _sc_parameters(moose_object->parameters()),
29  _sc_name(_sc_parameters.get<std::string>("_object_name")),
31  ? _sc_parameters.get<bool>("implicit")
32  : true)
33 {
34  SubProblem & problem = *_sc_parameters.getCheckedPointerParam<SubProblem *>("_subproblem");
35 
36  // Coupling
37  for (std::set<std::string>::const_iterator iter = _sc_parameters.coupledVarsBegin();
39  ++iter)
40  {
41  std::string name = *iter;
42  if (_sc_parameters.getVecMooseType(*iter) != std::vector<std::string>())
43  {
44  std::vector<std::string> vars = _sc_parameters.getVecMooseType(*iter);
45  for (const auto & coupled_var_name : vars)
46  {
47  if (problem.hasScalarVariable(coupled_var_name))
48  {
49  MooseVariableScalar * scalar_var = &problem.getScalarVariable(_sc_tid, coupled_var_name);
50  _coupled_scalar_vars[name].push_back(scalar_var);
51  _coupled_moose_scalar_vars.push_back(scalar_var);
52  }
53  else if (problem.hasVariable(coupled_var_name))
54  {
55  MooseVariableFEBase * moose_var =
56  &problem.getVariable(_sc_tid,
57  coupled_var_name,
60  _sc_coupled_vars[name].push_back(moose_var);
61  }
62  else
63  mooseError(_sc_name, ": Coupled variable '", coupled_var_name, "' was not found");
64  }
65  }
66  }
67 }
std::string name(const ElemQuality q)
std::vector< Point > _point_zero
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the scalar variable reference from whichever system contains it.
std::unordered_map< std::string, std::vector< MooseVariableFieldBase * > > _sc_coupled_vars
Field variables coupled into this object (for error checking)
const Point & _point_zero
Zero point.
const THREAD_ID _sc_tid
Thread ID of the thread using this object.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
const bool _sc_is_implicit
True if implicit value is required.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
std::set< std::string >::const_iterator coupledVarsBegin() const
Methods returning iterators to the coupled variables names stored in this InputParameters object...
const std::string & _sc_name
The name of the object this interface is part of.
FEProblemBase & _sc_fe_problem
This class provides an interface for common operations on field variables of both FE and FV types wit...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::set< std::string >::const_iterator coupledVarsEnd() const
virtual bool hasScalarVariable(const std::string &var_name) const =0
Returns a Boolean indicating whether any system contains a variable with the name provided...
std::unordered_map< std::string, std::vector< MooseVariableScalar * > > _coupled_scalar_vars
Coupled vars whose values we provide.
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
virtual bool hasVariable(const std::string &var_name) const =0
Whether or not this problem has the variable.
const InputParameters & _sc_parameters
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
std::vector< MooseVariableScalar * > _coupled_moose_scalar_vars
Vector of coupled variables.
const Real & _real_zero
Scalar zero.
std::vector< VariableValue > _scalar_zero
Class for scalar variables (they are different).
const InputParameters & parameters() const
Get the parameters of the object.
const VariableValue & _scalar_zero
Zero value of a scalar variable.
std::vector< std::string > getVecMooseType(const std::string &name) const
unsigned int THREAD_ID
Definition: MooseTypes.h:198
std::vector< Real > _real_zero
Convenience zeros.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

Member Function Documentation

◆ adCoupledScalarDot()

const ADVariableValue & ScalarCoupleable::adCoupledScalarDot ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the time derivative of a scalar coupled variable, including its dependence on the nonlinear degrees of freedom through automatic differentiation.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to the time derivative at quadrature points for the coupled variable, including automatic differentiation information

Definition at line 252 of file ScalarCoupleable.C.

253 {
254  checkVar(var_name);
255  validateExecutionerType(var_name, "adCoupledScalarDot");
256  return getScalarVar(var_name, comp)->adUDot();
257 }
const ADVariableValue & adUDot() const
Return the first derivative of the solution with derivative information.
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.

◆ adCoupledScalarValue()

const ADVariableValue & ScalarCoupleable::adCoupledScalarValue ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns AD value of a scalar coupled variable.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a ADVariableValue for the coupled variable

Definition at line 135 of file ScalarCoupleable.C.

136 {
137  checkVar(var_name);
138  if (!isCoupledScalar(var_name, comp))
139  return *getADDefaultValue(var_name);
140 
141  auto var = getScalarVar(var_name, comp);
142 
143  if (_sc_is_implicit)
144  return var->adSln();
145  else
146  mooseError("adCoupledValue for non-implicit calculations is not currently supported. Use "
147  "coupledValue instead for non-implicit");
148 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const bool _sc_is_implicit
True if implicit value is required.
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
const ADVariableValue * getADDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the AD default value for an uncoupled variable...

◆ checkVar()

void ScalarCoupleable::checkVar ( const std::string &  var_name) const
private

Check that the right kind of variable is being coupled in.

Parameters
var_nameThe name of the coupled variable

Definition at line 300 of file ScalarCoupleable.C.

Referenced by adCoupledScalarDot(), adCoupledScalarValue(), coupledMatrixTagScalarValue(), coupledScalar(), coupledScalarDot(), coupledScalarDotDot(), coupledScalarDotDotDu(), coupledScalarDotDotOld(), coupledScalarDotDu(), coupledScalarDotOld(), coupledScalarOrder(), coupledScalarValue(), coupledScalarValueOld(), coupledScalarValueOlder(), and coupledVectorTagScalarValue().

301 {
302  const auto var_name = _sc_parameters.checkForRename(var_name_in);
303 
304  auto it = _sc_coupled_vars.find(var_name);
305  if (it != _sc_coupled_vars.end())
306  {
307  std::string cvars;
308  for (auto jt : it->second)
309  cvars += " " + jt->name();
311  ": Trying to couple a field variable where scalar variable is expected, '",
312  var_name,
313  " =",
314  cvars,
315  "'");
316  }
317  // NOTE: non-existent variables are handled in the constructor
318 }
std::unordered_map< std::string, std::vector< MooseVariableFieldBase * > > _sc_coupled_vars
Field variables coupled into this object (for error checking)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const std::string & _sc_name
The name of the object this interface is part of.
const InputParameters & _sc_parameters
std::string checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.

◆ coupledGenericScalarValue() [1/3]

template<bool is_ad>
const GenericVariableValue<is_ad>& ScalarCoupleable::coupledGenericScalarValue ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns value of a coupled scalar variable for use in templated automatic differentiation classes.

Parameters
var_nameName of coupled scalar variable
compComponent number for vector of coupled scalar variables
Returns
Reference to a GenericVariableValue for the coupled scalar variable

◆ coupledGenericScalarValue() [2/3]

template<>
const GenericVariableValue<false>& ScalarCoupleable::coupledGenericScalarValue ( const std::string &  var_name,
const unsigned int  comp 
) const
protected

Definition at line 152 of file ScalarCoupleable.C.

154 {
155  return coupledScalarValue(var_name, comp);
156 }
const VariableValue & coupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Returns value of a scalar coupled variable.

◆ coupledGenericScalarValue() [3/3]

template<>
const GenericVariableValue<true>& ScalarCoupleable::coupledGenericScalarValue ( const std::string &  var_name,
const unsigned int  comp 
) const
protected

Definition at line 160 of file ScalarCoupleable.C.

162 {
163  return adCoupledScalarValue(var_name, comp);
164 }
const ADVariableValue & adCoupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Returns AD value of a scalar coupled variable.

◆ coupledMatrixTagScalarValue()

const VariableValue & ScalarCoupleable::coupledMatrixTagScalarValue ( const std::string &  var_name,
TagID  tag,
unsigned int  comp = 0 
) const
protected

Returns value of a scalar coupled variable.

Parameters
var_nameName of coupled variable
tagTag ID of coupled matrix;
compComponent number for vector of coupled variables
Returns
Reference to a VariableValue for the coupled variable

Definition at line 202 of file ScalarCoupleable.C.

205 {
206  checkVar(var_name);
207  if (!isCoupledScalar(var_name, comp))
208  return *getDefaultValue(var_name);
209 
210  _sc_coupleable_matrix_tags.insert(tag);
211 
212  return getScalarVar(var_name, comp)->matrixTagSln(tag);
213 }
std::set< TagID > _sc_coupleable_matrix_tags
The scalar coupleable matrix tags.
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
const VariableValue & matrixTagSln(TagID tag) const
const VariableValue * getDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the default value for an uncoupled variable...

◆ coupledScalar()

unsigned int ScalarCoupleable::coupledScalar ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the index for a scalar coupled variable by name.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Index of coupled variable

Definition at line 93 of file ScalarCoupleable.C.

Referenced by ParsedODEKernel::ParsedODEKernel().

94 {
95  checkVar(var_name);
96  return getScalarVar(var_name, comp)->number();
97 }
unsigned int number() const
Get variable number coming from libMesh.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.

◆ coupledScalarComponents()

unsigned int ScalarCoupleable::coupledScalarComponents ( const std::string &  var_name) const
protected

Return the number of components to the coupled scalar variable.

Parameters
var_nameThe of the coupled variable

Definition at line 353 of file ScalarCoupleable.C.

354 {
355  const auto var_name = _sc_parameters.checkForRename(var_name_in);
356 
357  const auto it = _coupled_scalar_vars.find(var_name);
358  if (it != _coupled_scalar_vars.end())
359  return it->second.size();
360 
361  mooseError(_sc_name, ": Trying to get a non-existent variable '", var_name, "'");
362 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const std::string & _sc_name
The name of the object this interface is part of.
std::unordered_map< std::string, std::vector< MooseVariableScalar * > > _coupled_scalar_vars
Coupled vars whose values we provide.
const InputParameters & _sc_parameters
std::string checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.

◆ coupledScalarDot()

const VariableValue & ScalarCoupleable::coupledScalarDot ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the time derivative of a scalar coupled variable.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a time derivative VariableValue for the coupled variable

Definition at line 244 of file ScalarCoupleable.C.

245 {
246  checkVar(var_name);
247  validateExecutionerType(var_name, "coupledScalarDot");
248  return getScalarVar(var_name, comp)->uDot();
249 }
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
const VariableValue & uDot() const
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.

◆ coupledScalarDotDot()

const VariableValue & ScalarCoupleable::coupledScalarDotDot ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the second time derivative of a scalar coupled variable.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a time derivative VariableValue for the coupled variable

Definition at line 260 of file ScalarCoupleable.C.

261 {
262  checkVar(var_name);
263  validateExecutionerType(var_name, "coupledScalarDotDot");
264  return getScalarVar(var_name, comp)->uDotDot();
265 }
const VariableValue & uDotDot() const
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.

◆ coupledScalarDotDotDu()

const VariableValue & ScalarCoupleable::coupledScalarDotDotDu ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Second time derivative of a scalar coupled variable with respect to the coefficients.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a VariableValue containing the time derivative of the coupled variable with respect to the coefficients

Definition at line 292 of file ScalarCoupleable.C.

293 {
294  checkVar(var_name);
295  validateExecutionerType(var_name, "coupledScalarDotDotDu");
296  return getScalarVar(var_name, comp)->duDotDotDu();
297 }
const VariableValue & duDotDotDu() const
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.

◆ coupledScalarDotDotOld()

const VariableValue & ScalarCoupleable::coupledScalarDotDotOld ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the old second time derivative of a scalar coupled variable.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a time derivative VariableValue for the coupled variable

Definition at line 276 of file ScalarCoupleable.C.

278 {
279  checkVar(var_name);
280  validateExecutionerType(var_name, "coupledScalarDotDotOld");
281  return getScalarVar(var_name, comp)->uDotDotOld();
282 }
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
const VariableValue & uDotDotOld() const
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.

◆ coupledScalarDotDu()

const VariableValue & ScalarCoupleable::coupledScalarDotDu ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Time derivative of a scalar coupled variable with respect to the coefficients.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a VariableValue containing the time derivative of the coupled variable with respect to the coefficients

Definition at line 284 of file ScalarCoupleable.C.

285 {
286  checkVar(var_name);
287  validateExecutionerType(var_name, "coupledScalarDotDu");
288  return getScalarVar(var_name, comp)->duDotDu();
289 }
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
const VariableValue & duDotDu() const

◆ coupledScalarDotOld()

const VariableValue & ScalarCoupleable::coupledScalarDotOld ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the old time derivative of a scalar coupled variable.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a time derivative VariableValue for the coupled variable

Definition at line 268 of file ScalarCoupleable.C.

269 {
270  checkVar(var_name);
271  validateExecutionerType(var_name, "coupledScalarDotOld");
272  return getScalarVar(var_name, comp)->uDotOld();
273 }
const VariableValue & uDotOld() const
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.

◆ coupledScalarOrder()

Order ScalarCoupleable::coupledScalarOrder ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the order for a scalar coupled variable by name.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Order of coupled variable

Definition at line 100 of file ScalarCoupleable.C.

101 {
102  checkVar(var_name);
103  if (!isCoupledScalar(var_name, comp))
105 
106  return getScalarVar(var_name, comp)->order();
107 }
FEProblemBase & _sc_fe_problem
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
Order getMaxScalarOrder() const

◆ coupledScalarValue()

const VariableValue & ScalarCoupleable::coupledScalarValue ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns value of a scalar coupled variable.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a VariableValue for the coupled variable

Definition at line 124 of file ScalarCoupleable.C.

Referenced by ParsedODEKernel::ParsedODEKernel().

125 {
126  checkVar(var_name);
127  if (!isCoupledScalar(var_name, comp))
128  return *getDefaultValue(var_name);
129 
130  auto var = getScalarVar(var_name, comp);
131  return _sc_is_implicit ? var->sln() : var->slnOld();
132 }
const bool _sc_is_implicit
True if implicit value is required.
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
const VariableValue * getDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the default value for an uncoupled variable...

◆ coupledScalarValueOld()

const VariableValue & ScalarCoupleable::coupledScalarValueOld ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the old (previous time step) value of a scalar coupled variable.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a old VariableValue for the coupled variable

Definition at line 216 of file ScalarCoupleable.C.

217 {
218  checkVar(var_name);
219  if (!isCoupledScalar(var_name, comp))
220  return *getDefaultValue(var_name);
221 
222  validateExecutionerType(var_name, "coupledScalarValueOld");
223  auto var = getScalarVar(var_name, comp);
224  return _sc_is_implicit ? var->slnOld() : var->slnOlder();
225 }
const bool _sc_is_implicit
True if implicit value is required.
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
const VariableValue * getDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the default value for an uncoupled variable...

◆ coupledScalarValueOlder()

const VariableValue & ScalarCoupleable::coupledScalarValueOlder ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

Returns the older (two time steps previous) value of a scalar coupled variable.

Parameters
var_nameName of coupled variable
compComponent number for vector of coupled variables
Returns
Reference to a older VariableValue for the coupled variable

Definition at line 228 of file ScalarCoupleable.C.

230 {
231  checkVar(var_name);
232  if (!isCoupledScalar(var_name, comp))
233  return *getDefaultValue(var_name);
234 
235  validateExecutionerType(var_name, "coupledScalarValueOlder");
236  auto var = getScalarVar(var_name, comp);
237  if (_sc_is_implicit)
238  return var->slnOlder();
239  else
240  mooseError("Older values not available for explicit schemes");
241 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const bool _sc_is_implicit
True if implicit value is required.
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
const VariableValue * getDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the default value for an uncoupled variable...

◆ coupledVectorTagScalarValue()

const VariableValue & ScalarCoupleable::coupledVectorTagScalarValue ( const std::string &  var_name,
TagID  tag,
unsigned int  comp = 0 
) const
protected

Returns value of a scalar coupled variable.

Parameters
var_nameName of coupled variable
tagTag ID of coupled vector ;
compComponent number for vector of coupled variables
Returns
Reference to a VariableValue for the coupled variable

Definition at line 181 of file ScalarCoupleable.C.

184 {
185  checkVar(var_name);
186  if (!isCoupledScalar(var_name, comp))
187  return *getDefaultValue(var_name);
188 
190  mooseError("Attempting to couple to vector tag scalar with ID ",
191  tag,
192  "in ",
193  _sc_name,
194  ", but a vector tag with that ID does not exist");
195 
196  _sc_coupleable_vector_tags.insert(tag);
197 
198  return getScalarVar(var_name, comp)->vectorTagSln(tag);
199 }
std::set< TagID > _sc_coupleable_vector_tags
The scalar coupleable vector tags.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const std::string & _sc_name
The name of the object this interface is part of.
FEProblemBase & _sc_fe_problem
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
const VariableValue & vectorTagSln(TagID tag) const
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:163
const VariableValue * getDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the default value for an uncoupled variable...

◆ getADDefaultValue()

const ADVariableValue * ScalarCoupleable::getADDefaultValue ( const std::string &  var_name) const
private

Helper method to return (and insert if necessary) the AD default value for an uncoupled variable.

Parameters
var_namethe name of the variable for which to retrieve a default value
Returns
ADVariableValue * a pointer to the associated ADVariableValue.

Definition at line 167 of file ScalarCoupleable.C.

Referenced by adCoupledScalarValue().

168 {
169  auto default_value_it = _dual_default_value.find(var_name);
170  if (default_value_it == _dual_default_value.end())
171  {
172  auto value = std::make_unique<ADVariableValue>(_sc_fe_problem.getMaxScalarOrder(),
174  default_value_it = _dual_default_value.insert(std::make_pair(var_name, std::move(value))).first;
175  }
176 
177  return default_value_it->second.get();
178 }
FEProblemBase & _sc_fe_problem
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Real defaultCoupledValue(const std::string &coupling_name, unsigned int i=0) const
Get the default value for an optionally coupled variable.
const InputParameters & _sc_parameters
std::unordered_map< std::string, std::unique_ptr< ADVariableValue > > _dual_default_value
Will hold the default AD value for optional coupled scalar variables.
Order getMaxScalarOrder() const

◆ getCoupledMooseScalarVars()

const std::vector<MooseVariableScalar *>& ScalarCoupleable::getCoupledMooseScalarVars ( )
inline

Get the list of coupled scalar variables.

Returns
The list of coupled variables

Definition at line 45 of file ScalarCoupleable.h.

Referenced by AuxScalarKernel::AuxScalarKernel(), MortarScalarBase::computeJacobian(), and ScalarInitialCondition::ScalarInitialCondition().

46  {
48  }
std::vector< MooseVariableScalar * > _coupled_moose_scalar_vars
Vector of coupled variables.

◆ getDefaultValue()

const VariableValue * ScalarCoupleable::getDefaultValue ( const std::string &  var_name) const
private

Helper method to return (and insert if necessary) the default value for an uncoupled variable.

Parameters
var_namethe name of the variable for which to retrieve a default value
Returns
VariableValue * a pointer to the associated VarirableValue.

Definition at line 110 of file ScalarCoupleable.C.

Referenced by coupledMatrixTagScalarValue(), coupledScalarValue(), coupledScalarValueOld(), coupledScalarValueOlder(), and coupledVectorTagScalarValue().

111 {
112  auto default_value_it = _default_value.find(var_name);
113  if (default_value_it == _default_value.end())
114  {
115  auto value = std::make_unique<VariableValue>(_sc_fe_problem.getMaxScalarOrder(),
117  default_value_it = _default_value.insert(std::make_pair(var_name, std::move(value))).first;
118  }
119 
120  return default_value_it->second.get();
121 }
FEProblemBase & _sc_fe_problem
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Real defaultCoupledValue(const std::string &coupling_name, unsigned int i=0) const
Get the default value for an optionally coupled variable.
const InputParameters & _sc_parameters
std::unordered_map< std::string, std::unique_ptr< VariableValue > > _default_value
Will hold the default value for optional coupled scalar variables.
Order getMaxScalarOrder() const

◆ getScalarVar()

const MooseVariableScalar * ScalarCoupleable::getScalarVar ( const std::string &  var_name,
unsigned int  comp 
) const
protected

Extract pointer to a scalar coupled variable.

Parameters
var_nameName of parameter desired
compComponent number of multiple coupled variables
Returns
Pointer to the desired variable

Definition at line 321 of file ScalarCoupleable.C.

Referenced by adCoupledScalarDot(), adCoupledScalarValue(), coupledMatrixTagScalarValue(), coupledScalar(), coupledScalarDot(), coupledScalarDotDot(), coupledScalarDotDotDu(), coupledScalarDotDotOld(), coupledScalarDotDu(), coupledScalarDotOld(), coupledScalarOrder(), coupledScalarValue(), coupledScalarValueOld(), coupledScalarValueOlder(), coupledVectorTagScalarValue(), and ParsedODEKernel::ParsedODEKernel().

322 {
323  const auto var_name = _sc_parameters.checkForRename(var_name_in);
324 
325  const auto it = _coupled_scalar_vars.find(var_name);
326  if (it != _coupled_scalar_vars.end())
327  {
328  const auto & entry = it->second;
329  if (comp < entry.size())
330  return entry[comp];
331  else
332  mooseError(_sc_name, ": Trying to get a non-existent component of variable '", var_name, "'");
333  }
334  else
335  mooseError(_sc_name, ": Trying to get a non-existent variable '", var_name, "'");
336 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const std::string & _sc_name
The name of the object this interface is part of.
std::unordered_map< std::string, std::vector< MooseVariableScalar * > > _coupled_scalar_vars
Coupled vars whose values we provide.
const InputParameters & _sc_parameters
std::string checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.

◆ getScalarVariableCoupleableMatrixTags()

const std::set<TagID>& ScalarCoupleable::getScalarVariableCoupleableMatrixTags ( ) const
inline

Definition at line 55 of file ScalarCoupleable.h.

56  {
58  }
std::set< TagID > _sc_coupleable_matrix_tags
The scalar coupleable matrix tags.

◆ getScalarVariableCoupleableVectorTags()

const std::set<TagID>& ScalarCoupleable::getScalarVariableCoupleableVectorTags ( ) const
inline

Definition at line 50 of file ScalarCoupleable.h.

51  {
53  }
std::set< TagID > _sc_coupleable_vector_tags
The scalar coupleable vector tags.

◆ isCoupledScalar()

bool ScalarCoupleable::isCoupledScalar ( const std::string &  var_name,
unsigned int  i = 0 
) const
protected

Returns true if a variables has been coupled_as name.

Parameters
var_nameThe of the coupled variable
iBy default 0, in general the index to test in a vector of MooseVariable pointers.

Definition at line 70 of file ScalarCoupleable.C.

Referenced by adCoupledScalarValue(), coupledMatrixTagScalarValue(), coupledScalarOrder(), coupledScalarValue(), coupledScalarValueOld(), coupledScalarValueOlder(), and coupledVectorTagScalarValue().

71 {
72  const auto var_name = _sc_parameters.checkForRename(var_name_in);
73 
74  auto it = _coupled_scalar_vars.find(var_name);
75  if (it != _coupled_scalar_vars.end())
76  return (i < it->second.size());
77  else
78  {
79  // Make sure the user originally requested this value in the InputParameter syntax
80  if (!_sc_parameters.hasCoupledValue(var_name))
82  ": The coupled scalar variable \"",
83  var_name,
84  "\" was never added to this object's "
85  "InputParameters, please double-check "
86  "your spelling");
87 
88  return false;
89  }
90 }
bool hasCoupledValue(const std::string &coupling_name) const
Return whether or not the coupled variable exists.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const std::string & _sc_name
The name of the object this interface is part of.
std::unordered_map< std::string, std::vector< MooseVariableScalar * > > _coupled_scalar_vars
Coupled vars whose values we provide.
const InputParameters & _sc_parameters
std::string checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.

◆ validateExecutionerType()

void ScalarCoupleable::validateExecutionerType ( const std::string &  name,
const std::string &  fn_name 
) const
private

Checks to make sure that the current Executioner has set "_is_transient" when old/older values are coupled in.

Parameters
namethe name of the variable
fn_nameThe name of the function that called this method - used in the error message

Definition at line 339 of file ScalarCoupleable.C.

Referenced by adCoupledScalarDot(), coupledScalarDot(), coupledScalarDotDot(), coupledScalarDotDotDu(), coupledScalarDotDotOld(), coupledScalarDotDu(), coupledScalarDotOld(), coupledScalarValueOld(), and coupledScalarValueOlder().

341 {
344  ": Calling '",
345  fn_name,
346  "' on variable \"",
347  name,
348  "\" when using a \"Steady\" executioner is not allowed. This value is available "
349  "only in transient simulations.");
350 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
const std::string & _sc_name
The name of the object this interface is part of.
FEProblemBase & _sc_fe_problem
virtual bool isTransient() const override

Member Data Documentation

◆ _coupled_moose_scalar_vars

std::vector<MooseVariableScalar *> ScalarCoupleable::_coupled_moose_scalar_vars
private

Vector of coupled variables.

Definition at line 297 of file ScalarCoupleable.h.

Referenced by getCoupledMooseScalarVars(), and ScalarCoupleable().

◆ _coupled_scalar_vars

std::unordered_map<std::string, std::vector<MooseVariableScalar *> > ScalarCoupleable::_coupled_scalar_vars
private

Coupled vars whose values we provide.

Definition at line 288 of file ScalarCoupleable.h.

Referenced by coupledScalarComponents(), getScalarVar(), isCoupledScalar(), and ScalarCoupleable().

◆ _default_value

std::unordered_map<std::string, std::unique_ptr<VariableValue> > ScalarCoupleable::_default_value
mutableprivate

Will hold the default value for optional coupled scalar variables.

Definition at line 291 of file ScalarCoupleable.h.

Referenced by getDefaultValue().

◆ _dual_default_value

std::unordered_map<std::string, std::unique_ptr<ADVariableValue> > ScalarCoupleable::_dual_default_value
mutableprivate

Will hold the default AD value for optional coupled scalar variables.

Definition at line 294 of file ScalarCoupleable.h.

Referenced by getADDefaultValue().

◆ _point_zero

const Point& ScalarCoupleable::_point_zero
protected

◆ _real_zero

const Real& ScalarCoupleable::_real_zero
protected

Scalar zero.

Definition at line 238 of file ScalarCoupleable.h.

◆ _sc_coupleable_matrix_tags

std::set<TagID> ScalarCoupleable::_sc_coupleable_matrix_tags
mutableprivate

The scalar coupleable matrix tags.

Definition at line 305 of file ScalarCoupleable.h.

Referenced by coupledMatrixTagScalarValue(), and getScalarVariableCoupleableMatrixTags().

◆ _sc_coupleable_vector_tags

std::set<TagID> ScalarCoupleable::_sc_coupleable_vector_tags
mutableprivate

The scalar coupleable vector tags.

Definition at line 303 of file ScalarCoupleable.h.

Referenced by coupledVectorTagScalarValue(), and getScalarVariableCoupleableVectorTags().

◆ _sc_coupled_vars

std::unordered_map<std::string, std::vector<MooseVariableFieldBase *> > ScalarCoupleable::_sc_coupled_vars
private

Field variables coupled into this object (for error checking)

Definition at line 300 of file ScalarCoupleable.h.

Referenced by checkVar(), and ScalarCoupleable().

◆ _sc_fe_problem

FEProblemBase& ScalarCoupleable::_sc_fe_problem
protected

◆ _sc_is_implicit

const bool ScalarCoupleable::_sc_is_implicit
private

True if implicit value is required.

Definition at line 285 of file ScalarCoupleable.h.

Referenced by adCoupledScalarValue(), coupledScalarValue(), coupledScalarValueOld(), and coupledScalarValueOlder().

◆ _sc_name

const std::string& ScalarCoupleable::_sc_name
private

The name of the object this interface is part of.

Definition at line 282 of file ScalarCoupleable.h.

Referenced by checkVar(), coupledScalarComponents(), coupledVectorTagScalarValue(), getScalarVar(), isCoupledScalar(), ScalarCoupleable(), and validateExecutionerType().

◆ _sc_parameters

const InputParameters& ScalarCoupleable::_sc_parameters
private

◆ _sc_tid

const THREAD_ID ScalarCoupleable::_sc_tid
protected

Thread ID of the thread using this object.

Definition at line 235 of file ScalarCoupleable.h.

Referenced by ScalarCoupleable().

◆ _scalar_zero

const VariableValue& ScalarCoupleable::_scalar_zero
protected

Zero value of a scalar variable.

Definition at line 241 of file ScalarCoupleable.h.


The documentation for this class was generated from the following files: