https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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.
 
 ScalarCoupleable (const ScalarCoupleable &object, const Moose::Kokkos::FunctorCopy &key)
 Special constructor used for Kokkos functor copy during parallel dispatch.
 
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars ()
 Get the list of coupled scalar variables.
 
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.
 
unsigned int coupledScalarComponents (const std::string &var_name) const
 Return the number of components to the coupled scalar variable.
 
unsigned int coupledScalar (const std::string &var_name, unsigned int comp=0) const
 Returns the index for a scalar coupled variable by name.
 
libMesh::Order coupledScalarOrder (const std::string &var_name, unsigned int comp=0) const
 Returns the order for a scalar coupled variable by name.
 
const VariableValue & coupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 Returns value of a scalar coupled variable.
 
const ADVariableValue & adCoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 Returns AD value of a scalar coupled variable.
 
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.
 
const VariableValue & coupledVectorTagScalarValue (const std::string &var_name, const std::string &tag_param_name, unsigned int comp=0) const
 Returns value of a scalar coupled variable.
 
const VariableValue & coupledMatrixTagScalarValue (const std::string &var_name, const std::string &tag_param_name, unsigned int comp=0) const
 Returns value of a scalar coupled variable.
 
const VariableValue & coupledScalarValueOld (const std::string &var_name, unsigned int comp=0) const
 Returns the old (previous time step) value of a scalar coupled variable.
 
const VariableValue & coupledScalarValueOlder (const std::string &var_name, unsigned int comp=0) const
 Returns the older (two time steps previous) value of a scalar coupled variable.
 
const VariableValue & coupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 Returns the time derivative of a scalar coupled variable.
 
const ADVariableValue & adCoupledScalarDot (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.
 
const VariableValue & coupledScalarDotDot (const std::string &var_name, unsigned int comp=0) const
 Returns the second time derivative of a scalar coupled variable.
 
const VariableValue & coupledScalarDotOld (const std::string &var_name, unsigned int comp=0) const
 Returns the old time derivative of a scalar coupled variable.
 
const VariableValue & coupledScalarDotDotOld (const std::string &var_name, unsigned int comp=0) const
 Returns the old second time derivative of a scalar coupled variable.
 
const VariableValue & coupledScalarDotDu (const std::string &var_name, unsigned int comp=0) const
 Time derivative of a scalar coupled variable with respect to the coefficients.
 
const VariableValue & coupledScalarDotDotDu (const std::string &var_name, unsigned int comp=0) const
 Second time derivative of a scalar coupled variable with respect to the coefficients.
 
Moose::Kokkos::VariableValue kokkosCoupledVectorTagScalarValueByName (const std::string &var_name, const std::string &tag_name, unsigned int comp=0) const
 
Moose::Kokkos::VariableValue kokkosCoupledVectorTagScalarValue (const std::string &var_name, const std::string &tag_param_name, unsigned int comp=0) const
 
Moose::Kokkos::VariableValue kokkosCoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
Moose::Kokkos::VariableValue kokkosCoupledScalarValueOld (const std::string &var_name, unsigned int comp=0) const
 
Moose::Kokkos::VariableValue kokkosCoupledScalarValueOlder (const std::string &var_name, unsigned int comp=0) const
 
Moose::Kokkos::VariableValue kokkosCoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
Moose::Kokkos::Scalar< const Real > kokkosCoupledScalarDotDu (const std::string &var_name, unsigned int comp=0) const
 
const MooseVariableScalar * getScalarVar (const std::string &var_name, unsigned int comp) const
 Extract pointer to a scalar coupled variable.
 
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.
 
const Real & _real_zero
 Scalar zero.
 
const VariableValue & _scalar_zero
 Zero value of a scalar variable.
 
const Point & _point_zero
 Zero point.
 

Private Member Functions

const VariableValue * getDefaultValue (const std::string &var_name) const
 Helper method to return (and insert if necessary) the default value for an uncoupled 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.
 
void checkVar (const std::string &var_name) const
 Check that the right kind of variable is being coupled in.
 
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.
 
Moose::Kokkos::Variable kokkosCoupledVectorTagScalarVariable (const std::string &var_name, const std::string &tag_name, unsigned int comp) const
 

Private Attributes

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

Detailed Description

Interface for objects that needs scalar coupling capabilities.

Definition at line 37 of file ScalarCoupleable.h.

Constructor & Destructor Documentation

◆ ScalarCoupleable() [1/2]

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.getObjectName()),
30 _sc_is_implicit(_sc_parameters.have_parameter<bool>("implicit")
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}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int THREAD_ID
Definition MooseTypes.h:237
char ** vars
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::vector< std::string > getVecMooseType(const std::string &name) const
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.
std::set< std::string >::const_iterator coupledVarsEnd() const
std::set< std::string >::const_iterator coupledVarsBegin() const
Methods returning iterators to the coupled variables names stored in this InputParameters object.
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.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
This class provides an interface for common operations on field variables of both FE and FV types wit...
Class for scalar variables (they are different).
const std::string & _sc_name
The name of the object this interface is part of.
const VariableValue & _scalar_zero
Zero value of a scalar variable.
std::vector< MooseVariableScalar * > _coupled_moose_scalar_vars
Vector of coupled variables.
std::unordered_map< std::string, std::vector< MooseVariableFieldBase * > > _sc_coupled_vars
Field variables coupled into this object (for error checking)
const InputParameters & _sc_parameters
const Real & _real_zero
Scalar zero.
std::unordered_map< std::string, std::vector< MooseVariableScalar * > > _coupled_scalar_vars
Coupled vars whose values we provide.
FEProblemBase & _sc_fe_problem
const THREAD_ID _sc_tid
Thread ID of the thread using this object.
const Point & _point_zero
Zero point.
const bool _sc_is_implicit
True if implicit value is required.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
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 hasScalarVariable(const std::string &var_name) const =0
Returns a Boolean indicating whether any system contains a variable with the name provided.
virtual bool hasVariable(const std::string &var_name) const =0
Whether or not this problem has the variable.
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the scalar variable reference from whichever system contains it.
@ VAR_FIELD_ANY
Definition MooseTypes.h:781
@ VAR_ANY
Definition MooseTypes.h:772
std::string name(const ElemQuality q)
const Elem & get(const ElemType type_in)

◆ ScalarCoupleable() [2/2]

ScalarCoupleable::ScalarCoupleable ( const ScalarCoupleable &  object,
const Moose::Kokkos::FunctorCopy &  key 
)

Special constructor used for Kokkos functor copy during parallel dispatch.

Definition at line 70 of file ScalarCoupleable.C.

73 _sc_tid(object._sc_tid),
74 _real_zero(object._real_zero),
78 _sc_name(object._sc_name),
80{
81}

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 288 of file ScalarCoupleable.C.

289{
290 checkVar(var_name);
291 validateExecutionerType(var_name, "adCoupledScalarDot");
292 return getScalarVar(var_name, comp)->adUDot();
293}
const ADVariableValue & adUDot() const
Return the first derivative of the solution with derivative information.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
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 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 150 of file ScalarCoupleable.C.

151{
152 checkVar(var_name);
153 if (!isCoupledScalar(var_name, comp))
154 return *getADDefaultValue(var_name);
155
156 auto var = getScalarVar(var_name, comp);
157
158 if (_sc_is_implicit)
159 return var->adSln();
160 else
161 mooseError("adCoupledValue for non-implicit calculations is not currently supported. Use "
162 "coupledValue instead for non-implicit");
163}
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
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.

Referenced by coupledGenericScalarValue().

◆ 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 336 of file ScalarCoupleable.C.

337{
338 const auto & var_name = _sc_parameters.checkForRename(var_name_in);
339
340 auto it = _sc_coupled_vars.find(var_name);
341 if (it != _sc_coupled_vars.end())
342 {
343 std::string cvars;
344 for (auto jt : it->second)
345 cvars += " " + jt->name();
347 ": Trying to couple a field variable where scalar variable is expected, '",
348 var_name,
349 " =",
350 cvars,
351 "'");
352 }
353 // NOTE: non-existent variables are handled in the constructor
354}
const std::string & checkForRename(const std::string &name) const
Checks whether the provided name is a renamed parameter name.

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

◆ coupledGenericScalarValue() [1/3]

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

Definition at line 166 of file ScalarCoupleable.C.

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

◆ coupledGenericScalarValue() [2/3]

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

Definition at line 174 of file ScalarCoupleable.C.

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

◆ coupledGenericScalarValue() [3/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

◆ coupledMatrixTagScalarValue()

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

Returns value of a scalar coupled variable.

Parameters
var_nameName of coupled variable
tag_param_nameName of parameter containing matrix tag name
compComponent number for vector of coupled variables
Returns
Reference to a VariableValue for the coupled variable

Definition at line 224 of file ScalarCoupleable.C.

227{
228 checkVar(var_name);
229 if (!isCoupledScalar(var_name, comp))
230 return *getDefaultValue(var_name);
231
232 if (!_sc_parameters.isParamValid(tag_param_name))
233 mooseError("Tag name parameter '", tag_param_name, "' is invalid");
234
235 const auto & tag_name = _sc_parameters.get<TagName>(tag_param_name);
236
237 if (!_sc_fe_problem.matrixTagExists(tag_name))
238 mooseError("Attempting to couple to matrx tag scalar with name ",
239 tag_name,
240 "in ",
241 _sc_name,
242 ", but a matrx tag with that name does not exist");
243
244 const auto tag = _sc_fe_problem.getMatrixTagID(tag_name);
245
246 _sc_coupleable_matrix_tags.insert(tag);
247
248 return getScalarVar(var_name, comp)->matrixTagSln(tag);
249}
const VariableValue & matrixTagSln(TagID tag) const
std::set< TagID > _sc_coupleable_matrix_tags
The scalar coupleable matrix tags.
const VariableValue * getDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the default value for an uncoupled variable.
virtual TagID getMatrixTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition SubProblem.C:331
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition SubProblem.C:317

◆ 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 108 of file ScalarCoupleable.C.

109{
110 checkVar(var_name);
111 return getScalarVar(var_name, comp)->number();
112}
unsigned int number() const
Get variable number coming from libMesh.

Referenced by ParsedODEKernel::ParsedODEKernel().

◆ 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 name of the coupled variable

Definition at line 389 of file ScalarCoupleable.C.

390{
391 const auto & var_name = _sc_parameters.checkForRename(var_name_in);
392
393 const auto it = _coupled_scalar_vars.find(var_name);
394 if (it != _coupled_scalar_vars.end())
395 return it->second.size();
396
397 mooseError(_sc_name, ": Trying to get a non-existent variable '", var_name, "'");
398}

◆ 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 280 of file ScalarCoupleable.C.

281{
282 checkVar(var_name);
283 validateExecutionerType(var_name, "coupledScalarDot");
284 return getScalarVar(var_name, comp)->uDot();
285}
const VariableValue & uDot() const

◆ 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 296 of file ScalarCoupleable.C.

297{
298 checkVar(var_name);
299 validateExecutionerType(var_name, "coupledScalarDotDot");
300 return getScalarVar(var_name, comp)->uDotDot();
301}
const VariableValue & uDotDot() const

◆ 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 328 of file ScalarCoupleable.C.

329{
330 checkVar(var_name);
331 validateExecutionerType(var_name, "coupledScalarDotDotDu");
332 return getScalarVar(var_name, comp)->duDotDotDu();
333}
const VariableValue & duDotDotDu() const

◆ 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 312 of file ScalarCoupleable.C.

314{
315 checkVar(var_name);
316 validateExecutionerType(var_name, "coupledScalarDotDotOld");
317 return getScalarVar(var_name, comp)->uDotDotOld();
318}
const VariableValue & uDotDotOld() const

◆ 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 320 of file ScalarCoupleable.C.

321{
322 checkVar(var_name);
323 validateExecutionerType(var_name, "coupledScalarDotDu");
324 return getScalarVar(var_name, comp)->duDotDu();
325}
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 304 of file ScalarCoupleable.C.

305{
306 checkVar(var_name);
307 validateExecutionerType(var_name, "coupledScalarDotOld");
308 return getScalarVar(var_name, comp)->uDotOld();
309}
const VariableValue & uDotOld() const

◆ 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 115 of file ScalarCoupleable.C.

116{
117 checkVar(var_name);
118 if (!isCoupledScalar(var_name, comp))
120
121 return getScalarVar(var_name, comp)->order();
122}
libMesh::Order getMaxScalarOrder() const
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int.

◆ 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 139 of file ScalarCoupleable.C.

140{
141 checkVar(var_name);
142 if (!isCoupledScalar(var_name, comp))
143 return *getDefaultValue(var_name);
144
145 auto var = getScalarVar(var_name, comp);
146 return _sc_is_implicit ? var->sln() : var->slnOld();
147}

Referenced by coupledGenericScalarValue(), and ParsedODEKernel::ParsedODEKernel().

◆ 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 252 of file ScalarCoupleable.C.

253{
254 checkVar(var_name);
255 if (!isCoupledScalar(var_name, comp))
256 return *getDefaultValue(var_name);
257
258 validateExecutionerType(var_name, "coupledScalarValueOld");
259 auto var = getScalarVar(var_name, comp);
260 return _sc_is_implicit ? var->slnOld() : var->slnOlder();
261}

◆ 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 264 of file ScalarCoupleable.C.

266{
267 checkVar(var_name);
268 if (!isCoupledScalar(var_name, comp))
269 return *getDefaultValue(var_name);
270
271 validateExecutionerType(var_name, "coupledScalarValueOlder");
272 auto var = getScalarVar(var_name, comp);
273 if (_sc_is_implicit)
274 return var->slnOlder();
275 else
276 mooseError("Older values not available for explicit schemes");
277}

◆ coupledVectorTagScalarValue()

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

Returns value of a scalar coupled variable.

Parameters
var_nameName of coupled variable
tag_param_nameName of parameter containing vector tag name
compComponent number for vector of coupled variables
Returns
Reference to a VariableValue for the coupled variable

Definition at line 196 of file ScalarCoupleable.C.

199{
200 checkVar(var_name);
201 if (!isCoupledScalar(var_name, comp))
202 return *getDefaultValue(var_name);
203
204 if (!_sc_parameters.isParamValid(tag_param_name))
205 mooseError("Tag name parameter '", tag_param_name, "' is invalid");
206
207 const auto & tag_name = _sc_parameters.get<TagName>(tag_param_name);
208
209 if (!_sc_fe_problem.vectorTagExists(tag_name))
210 mooseError("Attempting to couple to vector tag scalar with name ",
211 tag_name,
212 "in ",
213 _sc_name,
214 ", but a vector tag with that name does not exist");
215
216 const auto tag = _sc_fe_problem.getVectorTagID(tag_name);
217
218 _sc_coupleable_vector_tags.insert(tag);
219
220 return getScalarVar(var_name, comp)->vectorTagSln(tag);
221}
const VariableValue & vectorTagSln(TagID tag) const
std::set< TagID > _sc_coupleable_vector_tags
The scalar coupleable vector tags.
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition SubProblem.C:192
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition SubProblem.h:201

◆ 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 182 of file ScalarCoupleable.C.

183{
184 auto default_value_it = _dual_default_value.find(var_name);
185 if (default_value_it == _dual_default_value.end())
186 {
187 auto value = std::make_unique<ADVariableValue>(_sc_fe_problem.getMaxScalarOrder(),
189 default_value_it = _dual_default_value.insert(std::make_pair(var_name, std::move(value))).first;
190 }
191
192 return default_value_it->second.get();
193}
Real defaultCoupledValue(const std::string &coupling_name, unsigned int i=0) const
Get the default value for an optionally coupled variable.
std::unordered_map< std::string, std::unique_ptr< ADVariableValue > > _dual_default_value
Will hold the default AD value for optional coupled scalar variables.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

Referenced by adCoupledScalarValue().

◆ getCoupledMooseScalarVars()

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

◆ 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 VariableValue.

Definition at line 125 of file ScalarCoupleable.C.

126{
127 auto default_value_it = _default_value.find(var_name);
128 if (default_value_it == _default_value.end())
129 {
130 auto value = std::make_unique<VariableValue>(_sc_fe_problem.getMaxScalarOrder(),
132 default_value_it = _default_value.insert(std::make_pair(var_name, std::move(value))).first;
133 }
134
135 return default_value_it->second.get();
136}
std::unordered_map< std::string, std::unique_ptr< VariableValue > > _default_value
Will hold the default value for optional coupled scalar variables.

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

◆ 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 357 of file ScalarCoupleable.C.

358{
359 const auto & var_name = _sc_parameters.checkForRename(var_name_in);
360
361 const auto it = _coupled_scalar_vars.find(var_name);
362 if (it != _coupled_scalar_vars.end())
363 {
364 const auto & entry = it->second;
365 if (comp < entry.size())
366 return entry[comp];
367 else
368 mooseError(_sc_name, ": Trying to get a non-existent component of variable '", var_name, "'");
369 }
370 else
371 mooseError(_sc_name, ": Trying to get a non-existent variable '", var_name, "'");
372}

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

◆ getScalarVariableCoupleableMatrixTags()

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

Definition at line 67 of file ScalarCoupleable.h.

68 {
70 }

◆ getScalarVariableCoupleableVectorTags()

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

Definition at line 62 of file ScalarCoupleable.h.

63 {
65 }

◆ 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 85 of file ScalarCoupleable.C.

86{
87 const auto & var_name = _sc_parameters.checkForRename(var_name_in);
88
89 auto it = _coupled_scalar_vars.find(var_name);
90 if (it != _coupled_scalar_vars.end())
91 return (i < it->second.size());
92 else
93 {
94 // Make sure the user originally requested this value in the InputParameter syntax
95 if (!_sc_parameters.hasCoupledVar(var_name))
97 ": The coupled scalar variable \"",
98 var_name,
99 "\" was never added to this object's "
100 "InputParameters, please double-check "
101 "your spelling");
102
103 return false;
104 }
105}
bool hasCoupledVar(const std::string &coupling_name) const
Return whether or not the coupled variable exists.

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

◆ kokkosCoupledScalarDot()

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

◆ kokkosCoupledScalarDotDu()

Moose::Kokkos::Scalar< const Real > ScalarCoupleable::kokkosCoupledScalarDotDu ( const std::string &  var_name,
unsigned int  comp = 0 
) const
protected

◆ kokkosCoupledScalarValue()

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

◆ kokkosCoupledScalarValueOld()

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

◆ kokkosCoupledScalarValueOlder()

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

◆ kokkosCoupledVectorTagScalarValue()

Moose::Kokkos::VariableValue ScalarCoupleable::kokkosCoupledVectorTagScalarValue ( const std::string &  var_name,
const std::string &  tag_param_name,
unsigned int  comp = 0 
) const
protected

◆ kokkosCoupledVectorTagScalarValueByName()

Moose::Kokkos::VariableValue ScalarCoupleable::kokkosCoupledVectorTagScalarValueByName ( const std::string &  var_name,
const std::string &  tag_name,
unsigned int  comp = 0 
) const
protected

◆ kokkosCoupledVectorTagScalarVariable()

Moose::Kokkos::Variable ScalarCoupleable::kokkosCoupledVectorTagScalarVariable ( const std::string &  var_name,
const std::string &  tag_name,
unsigned int  comp 
) const
private

◆ 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 375 of file ScalarCoupleable.C.

377{
380 ": Calling '",
381 fn_name,
382 "' on variable \"",
383 name,
384 "\" when using a \"Steady\" executioner is not allowed. This value is available "
385 "only in transient simulations.");
386}
virtual bool isTransient() const override

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

Member Data Documentation

◆ _coupled_moose_scalar_vars

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

Vector of coupled variables.

Definition at line 337 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 328 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 331 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 334 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 272 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 345 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 343 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 340 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 325 of file ScalarCoupleable.h.

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

◆ _sc_name

const std::string& ScalarCoupleable::_sc_name
private

◆ _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 269 of file ScalarCoupleable.h.

Referenced by ScalarCoupleable().

◆ _scalar_zero

const VariableValue& ScalarCoupleable::_scalar_zero
protected

Zero value of a scalar variable.

Definition at line 275 of file ScalarCoupleable.h.


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