Skip to content

Commit

Permalink
Merge pull request idaholab#15659 from hugary1995/adcoupledgenericsca…
Browse files Browse the repository at this point in the history
…larvalue

add coupledGenericScalarValue interface
  • Loading branch information
loganharbour authored Jul 23, 2020
2 parents 0a9fb29 + 14bc25e commit e97564c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions framework/include/interfaces/ScalarCoupleable.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ class ScalarCoupleable
*/
const ADVariableValue & adCoupledScalarValue(const std::string & var_name, unsigned int comp = 0);

/**
* Returns value of a coupled scalar variable for use in templated automatic differentiation
* classes
* @param var_name Name of coupled scalar variable
* @param comp Component number for vector of coupled scalar variables
* @return Reference to a GenericVariableValue for the coupled scalar variable
*/
template <bool is_ad>
const GenericVariableValue<is_ad> & coupledGenericScalarValue(const std::string & var_name,
unsigned int comp = 0);

/**
* Returns value of a scalar coupled variable
* @param var_name Name of coupled variable
Expand Down
14 changes: 14 additions & 0 deletions framework/src/interfaces/ScalarCoupleable.C
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ ScalarCoupleable::adCoupledScalarValue(const std::string & var_name, unsigned in
"coupledValue instead for non-implicit");
}

template <>
const GenericVariableValue<false> &
ScalarCoupleable::coupledGenericScalarValue<false>(const std::string & var_name, unsigned int comp)
{
return coupledScalarValue(var_name, comp);
}

template <>
const GenericVariableValue<true> &
ScalarCoupleable::coupledGenericScalarValue<true>(const std::string & var_name, unsigned int comp)
{
return adCoupledScalarValue(var_name, comp);
}

ADVariableValue *
ScalarCoupleable::getADDefaultValue(const std::string & var_name)
{
Expand Down

0 comments on commit e97564c

Please sign in to comment.