LCOV - code coverage report
Current view: top level - include/interfaces - Coupleable.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 99787a Lines: 32 51 62.7 %
Date: 2025-10-14 20:01:24 Functions: 36 60 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #pragma once
      11             : 
      12             : #ifdef MOOSE_KOKKOS_SCOPE
      13             : #include "KokkosVariableValue.h"
      14             : #endif
      15             : 
      16             : #include <unordered_map>
      17             : #include "MooseTypes.h"
      18             : #include "MooseArray.h"
      19             : #include "MooseVariableFE.h"
      20             : #include "MooseVariableFV.h"
      21             : #include "MooseLinearVariableFV.h"
      22             : #include "InputParameters.h"
      23             : #include "HasMembers.h"
      24             : 
      25             : #define usingCoupleableMembers                                                                     \
      26             :   using Coupleable::_zero;                                                                         \
      27             :   using Coupleable::_grad_zero;                                                                    \
      28             :   using Coupleable::_ad_zero;                                                                      \
      29             :   using Coupleable::_ad_grad_zero
      30             : 
      31             : // Forward declarations
      32             : class MooseVariableScalar;
      33             : class MooseObject;
      34             : 
      35             : namespace libMesh
      36             : {
      37             : template <typename T>
      38             : class DenseVector;
      39             : }
      40             : 
      41             : template <typename>
      42             : class MooseVariableField;
      43             : typedef MooseVariableField<Real> MooseWritableVariable;
      44             : 
      45             : /**
      46             :  * Interface for objects that needs coupling capabilities
      47             :  *
      48             :  */
      49             : class Coupleable
      50             : {
      51             : public:
      52             :   /**
      53             :    * Constructing the object
      54             :    * @param parameters Parameters that come from constructing the object
      55             :    * @param nodal true if we need to couple with nodal values, otherwise false
      56             :    * @param is_fv Whether the \p MooseObject is a finite volume object
      57             :    */
      58             :   Coupleable(const MooseObject * moose_object, bool nodal, bool is_fv = false);
      59             : 
      60             : #ifdef MOOSE_KOKKOS_ENABLED
      61             :   /**
      62             :    * Special constructor used for Kokkos functor copy during parallel dispatch
      63             :    */
      64             :   Coupleable(const Coupleable & object, const Moose::Kokkos::FunctorCopy & key);
      65             : #endif
      66             : 
      67             :   /**
      68             :    * Get the list of coupled variables
      69             :    * @return The list of coupled variables
      70             :    */
      71             :   const std::unordered_map<std::string, std::vector<MooseVariableFieldBase *>> &
      72      118013 :   getCoupledVars() const
      73             :   {
      74      118013 :     return _coupled_vars;
      75             :   }
      76             : 
      77             :   /**
      78             :    * Get the list of all coupled variables
      79             :    * @return The list of all coupled variables
      80             :    */
      81     2866971 :   const std::vector<MooseVariableFieldBase *> & getCoupledMooseVars() const
      82             :   {
      83     2866971 :     return _coupled_moose_vars;
      84             :   }
      85             : 
      86             :   /**
      87             :    * Get the list of standard coupled variables
      88             :    * @return The list of standard coupled variables
      89             :    */
      90             :   const std::vector<MooseVariable *> & getCoupledStandardMooseVars() const
      91             :   {
      92             :     return _coupled_standard_moose_vars;
      93             :   }
      94             : 
      95             :   /**
      96             :    * Get the list of vector coupled variables
      97             :    * @return The list of vector coupled variables
      98             :    */
      99             :   const std::vector<VectorMooseVariable *> & getCoupledVectorMooseVars() const
     100             :   {
     101             :     return _coupled_vector_moose_vars;
     102             :   }
     103             : 
     104             :   /**
     105             :    * Get the list of array coupled variables
     106             :    * @return The list of array coupled variables
     107             :    */
     108             :   const std::vector<ArrayMooseVariable *> & getCoupledArrayMooseVars() const
     109             :   {
     110             :     return _coupled_array_moose_vars;
     111             :   }
     112             : 
     113        1900 :   void addFEVariableCoupleableVectorTag(TagID tag) { _fe_coupleable_vector_tags.insert(tag); }
     114             : 
     115         259 :   void addFEVariableCoupleableMatrixTag(TagID tag) { _fe_coupleable_matrix_tags.insert(tag); }
     116             : 
     117     1392473 :   std::set<TagID> & getFEVariableCoupleableVectorTags() { return _fe_coupleable_vector_tags; }
     118             : 
     119      794044 :   std::set<TagID> & getFEVariableCoupleableMatrixTags() { return _fe_coupleable_matrix_tags; }
     120             : 
     121    15537807 :   const std::set<TagID> & getFEVariableCoupleableVectorTags() const
     122             :   {
     123    15537807 :     return _fe_coupleable_vector_tags;
     124             :   }
     125             : 
     126             :   const std::set<TagID> & getFEVariableCoupleableMatrixTags() const
     127             :   {
     128             :     return _fe_coupleable_matrix_tags;
     129             :   }
     130             : 
     131             :   /**
     132             :    * returns a reference to the set of writable coupled variables
     133             :    */
     134    65836796 :   auto & getWritableCoupledVariables() const { return _writable_coupled_variables[_c_tid]; }
     135             : 
     136             :   /**
     137             :    * Checks whether the object has any writable coupled variables
     138             :    */
     139    65806134 :   bool hasWritableCoupledVariables() const { return !getWritableCoupledVariables().empty(); }
     140             : 
     141             : protected:
     142             :   /**
     143             :    * A call-back function provided by the derived object for actions before coupling a variable
     144             :    * with functions such as coupledValue.
     145             :    */
     146      126183 :   virtual void coupledCallback(const std::string & /*var_name*/, bool /*is_old*/) const {}
     147             : 
     148             :   /**
     149             :    * Returns true if a variables has been coupled as name.
     150             :    * @param var_name The name the kernel wants to refer to the variable as.
     151             :    * @param i By default 0, in general the index to test in a vector of MooseVariable pointers.
     152             :    * @return True if a coupled variable has the supplied name
     153             :    */
     154             :   virtual bool isCoupled(const std::string & var_name, unsigned int i = 0) const;
     155             : 
     156             :   /**
     157             :    * Returns true if a variable passed as a coupled value is really a constant
     158             :    * @param var_name The name the kernel wants to refer to the variable as.
     159             :    * @return True if the variable is actually a constant
     160             :    */
     161             :   virtual bool isCoupledConstant(const std::string & var_name) const;
     162             : 
     163             :   /**
     164             :    * Number of coupled components
     165             :    * @param var_name Name of the variable
     166             :    * @return number of components this variable has (usually 1)
     167             :    */
     168             :   unsigned int coupledComponents(const std::string & var_name) const;
     169             : 
     170             :   /**
     171             :    * Names of the variable in the Coupleable interface
     172             :    * @param var_name Name of the variable
     173             :    * @param comp the component of the variable
     174             :    * @return name the variable has been coupled as. For constants, returns the constant
     175             :    */
     176             :   VariableName coupledName(const std::string & var_name, unsigned int comp = 0) const;
     177             : 
     178             :   /**
     179             :    * Names of the variables in the Coupleable interface
     180             :    * @param var_name Names of the variables
     181             :    * @return names the variables have been coupled as
     182             :    */
     183             :   std::vector<VariableName> coupledNames(const std::string & var_name) const;
     184             : 
     185             :   /**
     186             :    * Returns the index for a coupled variable by name
     187             :    * @param var_name Name of coupled variable
     188             :    * @param comp Component number for vector of coupled variables
     189             :    * @return Index of coupled variable, if this is an optionally coupled variable that wasn't
     190             :    * provided this will return a unique "invalid" index.
     191             :    */
     192             :   virtual unsigned int coupled(const std::string & var_name, unsigned int comp = 0) const;
     193             : 
     194             :   /**
     195             :    * Returns the indices for a coupled variable's components
     196             :    * @param var_name Name of coupled variable
     197             :    * @return Vector of the indices for all components of the coupled variable \p var_name.
     198             :    */
     199             :   std::vector<unsigned int> coupledIndices(const std::string & var_name) const;
     200             : 
     201             :   /**
     202             :    * Returns value of a coupled variable
     203             :    * @param var_name Name of coupled variable
     204             :    * @param comp Component number for vector of coupled variables
     205             :    * @return Reference to a VariableValue for the coupled variable
     206             :    * @see Kernel::_u
     207             :    */
     208             :   virtual const VariableValue & coupledValue(const std::string & var_name,
     209             :                                              unsigned int comp = 0) const;
     210             : 
     211             :   /**
     212             :    * Returns the values for all of a coupled variable components
     213             :    * @param var_name Name of coupled variable
     214             :    * @return Vector of VariableValue pointers for each component of \p var_name
     215             :    */
     216             :   std::vector<const VariableValue *> coupledValues(const std::string & var_name) const;
     217             : 
     218             :   /**
     219             :    * Returns the values for all of a coupled vector variable's components
     220             :    * @param var_name Name of coupled variable
     221             :    * @return Vector of VectorVariableValue pointers for each component of \p var_name
     222             :    */
     223             :   std::vector<const VectorVariableValue *> coupledVectorValues(const std::string & var_name) const;
     224             : 
     225             :   /**
     226             :    * Returns value of a coupled variable for use in templated automatic differentiation classes
     227             :    * @param var_name Name of coupled variable
     228             :    * @param comp Component number for vector of coupled variables
     229             :    * @return Reference to a GenericVariableValue for the coupled variable
     230             :    */
     231             :   template <bool is_ad>
     232             :   const GenericVariableValue<is_ad> & coupledGenericValue(const std::string & var_name,
     233             :                                                           unsigned int comp = 0) const;
     234             : 
     235             :   /**
     236             :    * Returns value of a coupled vector variable for use in templated automatic differentiation
     237             :    * classes
     238             :    * @param var_name Name of coupled variable
     239             :    * @param comp Component number for vector of coupled variables
     240             :    * @return Reference to a GenericVariableVectorValue for the coupled variable
     241             :    */
     242             :   template <bool is_ad>
     243             :   const GenericVectorVariableValue<is_ad> & coupledGenericVectorValue(const std::string & var_name,
     244             :                                                                       unsigned int comp = 0) const;
     245             : 
     246             :   /**
     247             :    * Returns the values for all of a coupled variable's components for use in templated automatic
     248             :    * differentiation classes
     249             :    * @param var_name Name of coupled variable
     250             :    * @return Vector of GenericVariableValue pointers for each component of \p var_name
     251             :    */
     252             :   template <bool is_ad>
     253             :   std::vector<const GenericVariableValue<is_ad> *>
     254             :   coupledGenericValues(const std::string & var_name) const;
     255             : 
     256             :   /**
     257             :    * Returns DOF value of a coupled variable for use in templated automatic differentiation classes
     258             :    * @param var_name Name of coupled variable
     259             :    * @param comp Component number for vector of coupled variables
     260             :    * @return Reference to a GenericVariableValue for the coupled variable
     261             :    */
     262             :   template <bool is_ad>
     263             :   const GenericVariableValue<is_ad> & coupledGenericDofValue(const std::string & var_name,
     264             :                                                              unsigned int comp = 0) const;
     265             : 
     266             :   /**
     267             :    * Returns time derivative of a coupled variable for use in templated automatic differentiation
     268             :    * classes
     269             :    * @param var_name Name of coupled variable
     270             :    * @param comp Component number for vector of coupled variables
     271             :    * @return Reference to a GenericVariableValue for the coupled variable time derivative
     272             :    */
     273             :   template <bool is_ad>
     274             :   const GenericVariableValue<is_ad> & coupledGenericDot(const std::string & var_name,
     275             :                                                         unsigned int comp = 0) const;
     276             : 
     277             :   /**
     278             :    * Returns the second time derivative of a coupled variable for use in templated automatic
     279             :    * differentiation classes
     280             :    * @param var_name Name of coupled variable
     281             :    * @param comp Component number for vector of coupled variables
     282             :    * @return Reference to a GenericVariableValue for the coupled variable second time derivative
     283             :    */
     284             :   template <bool is_ad>
     285             :   const GenericVariableValue<is_ad> & coupledGenericDotDot(const std::string & var_name,
     286             :                                                            unsigned int comp = 0) const;
     287             : 
     288             :   /**
     289             :    * Returns value of a coupled lower-dimensional variable
     290             :    * @param var_name Name of coupled variable
     291             :    * @param comp Component number for vector of coupled variables
     292             :    * @return Reference to a VariableValue for the coupled variable
     293             :    */
     294             :   virtual const VariableValue & coupledValueLower(const std::string & var_name,
     295             :                                                   unsigned int comp = 0) const;
     296             : 
     297             :   /**
     298             :    * Returns value of a coupled variable for use in Automatic Differentiation
     299             :    * @param var_name Name of coupled variable
     300             :    * @param comp Component number for vector of coupled variables
     301             :    * @return Reference to a ADVariableValue for the coupled variable
     302             :    */
     303             :   const ADVariableValue & adCoupledValue(const std::string & var_name, unsigned int comp = 0) const;
     304             : 
     305             :   /**
     306             :    * Returns the values for all of a coupled variable's components for use in Automatic
     307             :    * Differentiation
     308             :    * @param var_name Name of coupled variable
     309             :    * @return Vector of ADVariableValue pointers for each component of \p var_name
     310             :    */
     311             :   std::vector<const ADVariableValue *> adCoupledValues(const std::string & var_name) const;
     312             : 
     313             :   /**
     314             :    * Returns value of a coupled lower-dimensional variable for use in Automatic Differentiation
     315             :    * @param var_name Name of coupled variable
     316             :    * @param comp Component number for vector of coupled variables
     317             :    * @return Reference to a ADVariableValue for the coupled variable
     318             :    */
     319             :   const ADVariableValue & adCoupledLowerValue(const std::string & var_name,
     320             :                                               unsigned int comp = 0) const;
     321             : 
     322             :   /**
     323             :    * Returns value of a coupled vector variable for use in Automatic Differentiation
     324             :    * @param var_name Name of coupled vector variable
     325             :    * @param comp Component number for vector of coupled variables
     326             :    * @return Reference to a VariableValue for the coupled variable
     327             :    * @see Kernel::value
     328             :    */
     329             :   const ADVectorVariableValue & adCoupledVectorValue(const std::string & var_name,
     330             :                                                      unsigned int comp = 0) const;
     331             : 
     332             :   /**
     333             :    * Returns the values for all of a coupled vector variable's components for use in
     334             :    * Automatic Differentiation
     335             :    * @param var_name Name of coupled variable
     336             :    * @return Vector of ADVariableValue pointers for each component of \p var_name
     337             :    */
     338             :   std::vector<const ADVectorVariableValue *>
     339             :   adCoupledVectorValues(const std::string & var_name) const;
     340             : 
     341             :   /**
     342             :    * Returns value of a coupled variable for a given tag
     343             :    * @param var_names Name(s) of coupled variable(s)
     344             :    * @param tag vector tag ID
     345             :    * @param index Index of the desired variable in the vector of coupled variables
     346             :    * @return Reference to a VariableValue for the coupled variable
     347             :    * @see Kernel::_u
     348             :    */
     349             :   virtual const VariableValue &
     350             :   coupledVectorTagValue(const std::string & var_names, TagID tag, unsigned int index = 0) const;
     351             : 
     352             :   virtual const VariableValue & coupledVectorTagValue(const std::string & var_names,
     353             :                                                       const std::string & tag_name,
     354             :                                                       unsigned int index = 0) const;
     355             : 
     356             :   /**
     357             :    * Returns the values for all the coupled variables desired for a given tag
     358             :    * @param var_names Name(s) of coupled variable(s)
     359             :    * @param tag vector tag ID
     360             :    * @return Vector of VariableValue pointers for each variable in \p var_names
     361             :    */
     362             :   std::vector<const VariableValue *> coupledVectorTagValues(const std::string & var_names,
     363             :                                                             TagID tag) const;
     364             : 
     365             :   std::vector<const VariableValue *> coupledVectorTagValues(const std::string & var_names,
     366             :                                                             const std::string & tag_name) const;
     367             : 
     368             :   /**
     369             :    * Returns value of a coupled array variable for a given tag
     370             :    * @param var_names Name(s) of coupled array variable(s)
     371             :    * @param tag vector tag ID
     372             :    * @param index Index of the desired variable in the vector of coupled variables
     373             :    * @return Reference to a VariableValue for the coupled array variable
     374             :    * @see Kernel::_u
     375             :    */
     376             :   virtual const ArrayVariableValue & coupledVectorTagArrayValue(const std::string & var_names,
     377             :                                                                 TagID tag,
     378             :                                                                 unsigned int index = 0) const;
     379             : 
     380             :   virtual const ArrayVariableValue & coupledVectorTagArrayValue(const std::string & var_names,
     381             :                                                                 const std::string & tag_name,
     382             :                                                                 unsigned int index = 0) const;
     383             : 
     384             :   /**
     385             :    * Returns the values for all the coupled variables desired for a given tag
     386             :    * @param var_name Name of array coupled variable
     387             :    * @param tag vector tag ID
     388             :    * @return Vector of ArrayVariableValue pointers for each variable in \p var_names
     389             :    */
     390             :   std::vector<const ArrayVariableValue *> coupledVectorTagArrayValues(const std::string & var_names,
     391             :                                                                       TagID tag) const;
     392             : 
     393             :   std::vector<const ArrayVariableValue *>
     394             :   coupledVectorTagArrayValues(const std::string & var_names, const std::string & tag_name) const;
     395             : 
     396             :   /**
     397             :    * Returns gradient of a coupled variable for a given tag
     398             :    * @param var_names Name(s) of coupled variable(s)
     399             :    * @param tag vector tag ID
     400             :    * @param index Index of the desired variable in the vector of coupled variables
     401             :    * @return Reference to a VariableGradient containing the gradient of the coupled variable
     402             :    * @see Kernel::gradient
     403             :    */
     404             :   virtual const VariableGradient &
     405             :   coupledVectorTagGradient(const std::string & var_names, TagID tag, unsigned int index = 0) const;
     406             : 
     407             :   virtual const VariableGradient & coupledVectorTagGradient(const std::string & var_names,
     408             :                                                             const std::string & tag_name,
     409             :                                                             unsigned int index = 0) const;
     410             : 
     411             :   /**
     412             :    * Returns gradients for all the coupled variables desired for a given tag
     413             :    * @param var_names Name(s) of coupled array variable(s)
     414             :    * @param tag vector tag ID
     415             :    * @return Vector of VariableGradient pointers for each variables in \p var_name
     416             :    */
     417             :   std::vector<const VariableGradient *> coupledVectorTagGradients(const std::string & var_names,
     418             :                                                                   TagID tag) const;
     419             : 
     420             :   std::vector<const VariableGradient *>
     421             :   coupledVectorTagGradients(const std::string & var_names, const std::string & tag_name) const;
     422             : 
     423             :   /**
     424             :    * Returns gradient of a coupled array variable for a given tag
     425             :    * @param var_names Name(s) of coupled array variable(s)
     426             :    * @param tag vector tag ID
     427             :    * @param index Index of the desired variable in the vector of coupled variables
     428             :    * @return Reference to a ArrayVariableGradient containing the gradient of the coupled array
     429             :    * variable
     430             :    * @see Kernel::gradient
     431             :    */
     432             :   virtual const ArrayVariableGradient & coupledVectorTagArrayGradient(const std::string & var_names,
     433             :                                                                       TagID tag,
     434             :                                                                       unsigned int index = 0) const;
     435             : 
     436             :   virtual const ArrayVariableGradient & coupledVectorTagArrayGradient(const std::string & var_names,
     437             :                                                                       const std::string & tag_name,
     438             :                                                                       unsigned int index = 0) const;
     439             : 
     440             :   /**
     441             :    * Returns gradients for all the coupled variables desired for a given tag
     442             :    * @param var_names Name(s) of coupled array variable(s)
     443             :    * @param tag vector tag ID
     444             :    * @return Vector of ArrayVariableGradient pointers for each variable in \p var_name
     445             :    */
     446             :   std::vector<const ArrayVariableGradient *>
     447             :   coupledVectorTagArrayGradients(const std::string & var_names, TagID tag) const;
     448             : 
     449             :   std::vector<const ArrayVariableGradient *>
     450             :   coupledVectorTagArrayGradients(const std::string & var_names, const std::string & tag_name) const;
     451             : 
     452             :   /**
     453             :    * Returns dof value of a coupled variable for a given tag
     454             :    * @param var_names Name(s) of coupled variable(s)
     455             :    * @param tag vector tag ID
     456             :    * @param index Index of the desired variable in the vector of coupled variables
     457             :    * @return Reference to a DofValue for the coupled variable
     458             :    */
     459             :   virtual const VariableValue &
     460             :   coupledVectorTagDofValue(const std::string & var_name, TagID tag, unsigned int index = 0) const;
     461             : 
     462             :   virtual const VariableValue & coupledVectorTagDofValue(const std::string & var_names,
     463             :                                                          const std::string & tag_name,
     464             :                                                          unsigned int index = 0) const;
     465             : 
     466             :   /**
     467             :    * Returns evaluations of a tagged vector at the requested variable's degree of freedom indices
     468             :    * @param var_name Name of coupled variable
     469             :    * @param tag_name vector tag name
     470             :    * @return Reference to a ArrayVariableValue for the coupled variable
     471             :    */
     472             :   const ArrayVariableValue & coupledVectorTagArrayDofValue(const std::string & var_name,
     473             :                                                            const std::string & tag_name,
     474             :                                                            unsigned int comp = 0) const;
     475             : 
     476             :   /**
     477             :    * Returns the dof values for all the coupled variables desired for a given tag
     478             :    * @param var_names Name(s) of coupled variable(s)
     479             :    * @param tag vector tag ID
     480             :    * @return Vector of VariableValue pointers for each variable in \p var_name
     481             :    */
     482             :   std::vector<const VariableValue *> coupledVectorTagDofValues(const std::string & var_names,
     483             :                                                                TagID tag) const;
     484             : 
     485             :   std::vector<const VariableValue *> coupledVectorTagDofValues(const std::string & var_names,
     486             :                                                                const std::string & tag_name) const;
     487             : 
     488             :   /**
     489             :    * Returns value of a coupled variable for a given tag. This couples the diag vector of matrix
     490             :    * @param var_names Name(s) of coupled variable(s)
     491             :    * @param tag matrix tag ID
     492             :    * @param index Index of the desired variable in the vector of coupled variables
     493             :    * @return Reference to a VariableValue for the coupled variable
     494             :    * @see Kernel::_u
     495             :    */
     496             :   virtual const VariableValue &
     497             :   coupledMatrixTagValue(const std::string & var_names, TagID tag, unsigned int index = 0) const;
     498             : 
     499             :   virtual const VariableValue & coupledMatrixTagValue(const std::string & var_names,
     500             :                                                       const std::string & tag_name,
     501             :                                                       unsigned int index = 0) const;
     502             : 
     503             :   /**
     504             :    * Returns the diagonal matrix values for all the coupled variables desired for a given tag
     505             :    * @param var_names Name(s) of coupled variable(s)
     506             :    * @param tag matrix tag ID
     507             :    * @return Vector of VariableValue pointers for each variable in \p var_name
     508             :    */
     509             :   std::vector<const VariableValue *> coupledMatrixTagValues(const std::string & var_names,
     510             :                                                             TagID tag) const;
     511             : 
     512             :   std::vector<const VariableValue *> coupledMatrixTagValues(const std::string & var_names,
     513             :                                                             const std::string & tag_name) const;
     514             : 
     515             :   /**
     516             :    * Returns value of a coupled vector variable
     517             :    * @param var_name Name of coupled vector variable
     518             :    * @param comp Component number for vector of coupled vector variables
     519             :    * @return Reference to a VectorVariableValue for the coupled vector variable
     520             :    * @see VectorKernel::_u
     521             :    */
     522             :   virtual const VectorVariableValue & coupledVectorValue(const std::string & var_name,
     523             :                                                          unsigned int comp = 0) const;
     524             : 
     525             :   /**
     526             :    * Returns value of a coupled array variable
     527             :    * @param var_name Name of coupled array variable
     528             :    * @param comp Component number for vector of coupled array variables
     529             :    * @return Reference to a ArrayVariableValue for the coupled vector variable
     530             :    * @see ArrayKernel::_u
     531             :    */
     532             :   virtual const ArrayVariableValue & coupledArrayValue(const std::string & var_name,
     533             :                                                        unsigned int comp = 0) const;
     534             : 
     535             :   /**
     536             :    * Returns the values for all of a coupled array variable's components
     537             :    * @param var_name Name of coupled array variable
     538             :    * @return Vector of ArrayVariableValue pointers for each component of \p var_name
     539             :    */
     540             :   std::vector<const ArrayVariableValue *> coupledArrayValues(const std::string & var_name) const;
     541             : 
     542             :   /**
     543             :    * Returns a *writable* MooseVariable object for a nodal or elemental variable. Use
     544             :    * var.setNodalValue(val[, idx]) in both cases (!) to set the solution DOF values. Only one
     545             :    * object can obtain a writable reference in a simulation. Note that the written values will
     546             :    * not ba available in the same system loop! E.g. values written using this API by a nodal
     547             :    * AuxKernel will not be updated for other nodal AuxKernels during the same iteration over all
     548             :    * nodes.
     549             :    * @param var_name Name of coupled variable
     550             :    * @param comp Component number for vector of coupled variables
     551             :    * @return Reference to a MooseWritableVariable for the coupled variable
     552             :    * @see Kernel::value
     553             :    */
     554             :   MooseWritableVariable & writableVariable(const std::string & var_name, unsigned int comp = 0);
     555             : 
     556             :   /**
     557             :    * Returns a *writable* reference to a coupled variable for writing to multiple
     558             :    * AuxVariables from a single AuxKernel or a UserObject. Only one object can obtain
     559             :    * a writable reference in a simulation.
     560             :    * @param var_name Name of coupled variable
     561             :    * @param comp Component number for vector of coupled variables
     562             :    * @return Reference to a VariableValue for the coupled variable
     563             :    * @see Kernel::value
     564             :    */
     565             :   virtual VariableValue & writableCoupledValue(const std::string & var_name, unsigned int comp = 0);
     566             : 
     567             :   /**
     568             :    * Checks that the passed in variable is only accessed writable by one object in a given subdomain
     569             :    */
     570             :   void checkWritableVar(MooseWritableVariable * var);
     571             : 
     572             :   /**
     573             :    * Returns an old value from previous time step  of a coupled variable
     574             :    * @param var_name Name of coupled variable
     575             :    * @param comp Component number for vector of coupled variables
     576             :    * @return Reference to a VariableValue containing the old value of the coupled variable
     577             :    * @see Kernel::valueOld
     578             :    */
     579             :   virtual const VariableValue & coupledValueOld(const std::string & var_name,
     580             :                                                 unsigned int comp = 0) const;
     581             : 
     582             :   /**
     583             :    * Returns the old values for all of a coupled variable's components
     584             :    * @param var_name Name of coupled variable
     585             :    * @return Vector of VariableValue pointers for each component of \p var_name
     586             :    */
     587             :   std::vector<const VariableValue *> coupledValuesOld(const std::string & var_name) const;
     588             : 
     589             :   /**
     590             :    * Returns the old values for all of a coupled vector variable's components
     591             :    * @param var_name Name of coupled vector variable
     592             :    * @return Vector of VectorVariableValue pointers for each component of \p var_name
     593             :    */
     594             :   std::vector<const VectorVariableValue *>
     595             :   coupledVectorValuesOld(const std::string & var_name) const;
     596             : 
     597             :   /**
     598             :    * Returns an old value from two time steps previous of a coupled variable
     599             :    * @param var_name Name of coupled variable
     600             :    * @param comp Component number for vector of coupled variables
     601             :    * @return Reference to a VariableValue containing the older value of the coupled variable
     602             :    * @see Kernel::valueOlder
     603             :    */
     604             :   virtual const VariableValue & coupledValueOlder(const std::string & var_name,
     605             :                                                   unsigned int comp = 0) const;
     606             : 
     607             :   /**
     608             :    * Returns the older values for all of a coupled variable's components
     609             :    * @param var_name Name of coupled variable
     610             :    * @return Vector of VariableValue pointers for each component of \p var_name
     611             :    */
     612             :   std::vector<const VariableValue *> coupledValuesOlder(const std::string & var_name) const;
     613             : 
     614             :   /**
     615             :    * Returns value of previous Newton iterate of a coupled variable
     616             :    * @param var_name Name of coupled variable
     617             :    * @param comp Component number for vector of coupled variables
     618             :    * @return Reference to a VariableValue containing the older value of the coupled variable
     619             :    */
     620             :   virtual const VariableValue & coupledValuePreviousNL(const std::string & var_name,
     621             :                                                        unsigned int comp = 0) const;
     622             : 
     623             :   /**
     624             :    * Returns an old value from previous time step  of a coupled vector variable
     625             :    * @param var_name Name of coupled variable
     626             :    * @param comp Component number for vector of coupled variables
     627             :    * @return Reference to a VectorVariableValue containing the old value of the coupled variable
     628             :    * @see VectorKernel::_u_old
     629             :    */
     630             :   virtual const VectorVariableValue & coupledVectorValueOld(const std::string & var_name,
     631             :                                                             unsigned int comp = 0) const;
     632             : 
     633             :   /**
     634             :    * Returns an old value from two time steps previous of a coupled vector variable
     635             :    * @param var_name Name of coupled variable
     636             :    * @param comp Component number for vector of coupled variables
     637             :    * @return Reference to a VectorVariableValue containing the older value of the coupled variable
     638             :    * @see VectorKernel::_u_older
     639             :    */
     640             :   virtual const VectorVariableValue & coupledVectorValueOlder(const std::string & var_name,
     641             :                                                               unsigned int comp = 0) const;
     642             : 
     643             :   /**
     644             :    * Returns an old value from previous time step of a coupled array variable
     645             :    * @param var_name Name of coupled array variable
     646             :    * @param comp Component number for vector of coupled array variables
     647             :    * @return Reference to a ArrayVariableValue containing the old value of the coupled variable
     648             :    * @see ArrayKernel::_u_old
     649             :    */
     650             :   virtual const ArrayVariableValue & coupledArrayValueOld(const std::string & var_name,
     651             :                                                           unsigned int comp = 0) const;
     652             : 
     653             :   /**
     654             :    * Returns an old value from two time steps previous of a coupled array variable
     655             :    * @param var_name Name of coupled array variable
     656             :    * @param comp Component number for vector of coupled array variables
     657             :    * @return Reference to a ArrayVariableValue containing the older value of the coupled variable
     658             :    * @see ArrayKernel::_u_older
     659             :    */
     660             :   virtual const ArrayVariableValue & coupledArrayValueOlder(const std::string & var_name,
     661             :                                                             unsigned int comp = 0) const;
     662             : 
     663             :   /**
     664             :    * Returns gradient of a coupled variable
     665             :    * @param var_name Name of coupled variable
     666             :    * @param comp Component number for vector of coupled variables
     667             :    * @return Reference to a VariableGradient containing the gradient of the coupled variable
     668             :    * @see Kernel::gradient
     669             :    */
     670             :   virtual const VariableGradient & coupledGradient(const std::string & var_name,
     671             :                                                    unsigned int comp = 0) const;
     672             : 
     673             :   /**
     674             :    * Returns the gradients for all of a coupled variable's components
     675             :    * @param var_name Name of coupled variable
     676             :    * @return Vector of VariableGradient pointers for each component of \p var_name
     677             :    */
     678             :   std::vector<const VariableGradient *> coupledGradients(const std::string & var_name) const;
     679             : 
     680             :   /**
     681             :    * Returns gradient of a coupled variable for use in Automatic Differentiation
     682             :    * @param var_name Name of coupled variable
     683             :    * @param comp Component number for vector of coupled variables
     684             :    * @return Reference to an ADVariableGradient containing the gradient of the coupled variable
     685             :    * @see Kernel::gradient
     686             :    */
     687             :   const ADVariableGradient & adCoupledGradient(const std::string & var_name,
     688             :                                                unsigned int comp = 0) const;
     689             : 
     690             :   /**
     691             :    * Returns gradient of a coupled variable's time derivative for use in Automatic Differentiation
     692             :    * @param var_name Name of coupled variable
     693             :    * @param comp Component number for vector of coupled variables
     694             :    * @return Reference to an ADVariableGradient containing the gradient of the coupled variable's
     695             :    * time derivative
     696             :    */
     697             :   const ADVariableGradient & adCoupledGradientDot(const std::string & var_name,
     698             :                                                   unsigned int comp = 0) const;
     699             : 
     700             :   /**
     701             :    * Returns the gradients for all of a coupled variable's components for use in Automatic
     702             :    * Differentiation
     703             :    * @param var_name Name of coupled variable
     704             :    * @return Vector of ADVariableGradient pointers for each component of \p var_name
     705             :    */
     706             :   std::vector<const ADVariableGradient *> adCoupledGradients(const std::string & var_name) const;
     707             : 
     708             :   /**
     709             :    * Returns gradient of a coupled variable for use in templated automatic differentiation
     710             :    * @param var_name Name of coupled variable
     711             :    * @param comp Component number for vector of coupled variables
     712             :    * @return Reference to a VariableGradient containing the gradient of the coupled variable
     713             :    * @see Kernel::gradient
     714             :    */
     715             :   template <bool is_ad>
     716             :   const GenericVariableGradient<is_ad> & coupledGenericGradient(const std::string & var_name,
     717             :                                                                 unsigned int comp = 0) const;
     718             : 
     719             :   /**
     720             :    * Returns the gradients for all of a coupled variable's components for use in templated automatic
     721             :    * differentiation
     722             :    * @param var_name Name of coupled variable
     723             :    * @return Vector of VariableGradient pointers for each component of \p var_name
     724             :    */
     725             :   template <bool is_ad>
     726             :   std::vector<const GenericVariableGradient<is_ad> *>
     727             :   coupledGenericGradients(const std::string & var_name) const;
     728             : 
     729             :   /**
     730             :    * Returns gradient of a coupled vector variable for use in Automatic Differentiation
     731             :    * @param var_name Name of coupled vector variable
     732             :    * @param comp Component number for vector of coupled vector variables
     733             :    * @return Reference to a VectorVariableGradient containing the gradient of the coupled variable
     734             :    * @see Kernel::gradient
     735             :    */
     736             :   const ADVectorVariableGradient & adCoupledVectorGradient(const std::string & var_name,
     737             :                                                            unsigned int comp = 0) const;
     738             : 
     739             :   /**
     740             :    * Returns second derivatives of a coupled variable for use in Automatic Differentiation
     741             :    * @param var_name Name of coupled variable
     742             :    * @param comp Component number for vector of coupled variables
     743             :    * @return Reference to a VariableSecond containing the second derivatives of the coupled variable
     744             :    */
     745             :   const ADVariableSecond & adCoupledSecond(const std::string & var_name,
     746             :                                            unsigned int comp = 0) const;
     747             : 
     748             :   /**
     749             :    * Returns second derivatives of a coupled vector variable for use in Automatic Differentiation
     750             :    * @param var_name Name of coupled vector variable
     751             :    * @param comp Component number for vector of coupled vector variables
     752             :    * @return Reference to a VectorVariableSecond containing the second derivatives of the coupled
     753             :    * variable
     754             :    */
     755             :   const ADVectorVariableSecond & adCoupledVectorSecond(const std::string & var_name,
     756             :                                                        unsigned int comp = 0) const;
     757             : 
     758             :   /**
     759             :    * Returns an old gradient from previous time step of a coupled variable
     760             :    * @param var_name Name of coupled variable
     761             :    * @param comp Component number for vector of coupled variables
     762             :    * @return Reference to a VariableGradient containing the old gradient of the coupled variable
     763             :    * @see Kernel::gradientOld
     764             :    */
     765             :   virtual const VariableGradient & coupledGradientOld(const std::string & var_name,
     766             :                                                       unsigned int comp = 0) const;
     767             : 
     768             :   /**
     769             :    * Returns the old gradients for all of a coupled variable's components
     770             :    * @param var_name Name of coupled variable
     771             :    * @return Vector of VariableGradient pointers for each component of \p var_name
     772             :    */
     773             :   std::vector<const VariableGradient *> coupledGradientsOld(const std::string & var_name) const;
     774             : 
     775             :   /**
     776             :    * Returns an old gradient from two time steps previous of a coupled variable
     777             :    * @param var_name Name of coupled variable
     778             :    * @param comp Component number for vector of coupled variables
     779             :    * @return Reference to a VariableGradient containing the older gradient of the coupled variable
     780             :    * @see Kernel::gradientOlder
     781             :    */
     782             :   virtual const VariableGradient & coupledGradientOlder(const std::string & var_name,
     783             :                                                         unsigned int comp = 0) const;
     784             : 
     785             :   /**
     786             :    * Returns gradient of a coupled variable for previous Newton iterate
     787             :    * @param var_name Name of coupled variable
     788             :    * @param comp Component number for vector of coupled variables
     789             :    * @return Reference to a VariableGradient containing the gradient of the coupled variable
     790             :    */
     791             :   virtual const VariableGradient & coupledGradientPreviousNL(const std::string & var_name,
     792             :                                                              unsigned int comp = 0) const;
     793             : 
     794             :   /**
     795             :    * Time derivative of the gradient of a coupled variable
     796             :    * @param var_name Name of coupled variable
     797             :    * @param comp Component number for vector of coupled variables
     798             :    * @return Reference to a VariableGradient containing the time derivative of the gradient of a
     799             :    * coupled variable
     800             :    */
     801             :   virtual const VariableGradient & coupledGradientDot(const std::string & var_name,
     802             :                                                       unsigned int comp = 0) const;
     803             : 
     804             :   /**
     805             :    * Second time derivative of the gradient of a coupled variable
     806             :    * @param var_name Name of coupled variable
     807             :    * @param comp Component number for vector of coupled variables
     808             :    * @return Reference to a VariableGradient containing the time derivative of the gradient of a
     809             :    * coupled variable
     810             :    */
     811             :   virtual const VariableGradient & coupledGradientDotDot(const std::string & var_name,
     812             :                                                          unsigned int comp = 0) const;
     813             : 
     814             :   /**
     815             :    * Returns gradient of a coupled vector variable
     816             :    * @param var_name Name of coupled vector variable
     817             :    * @param comp Component number for vector of coupled vector variables
     818             :    * @return Reference to a VectorVariableGradient containing the gradient of the coupled vector
     819             :    * variable
     820             :    */
     821             :   virtual const VectorVariableGradient & coupledVectorGradient(const std::string & var_name,
     822             :                                                                unsigned int comp = 0) const;
     823             : 
     824             :   /**
     825             :    * Returns an old gradient from previous time step of a coupled vector variable
     826             :    * @param var_name Name of coupled vector variable
     827             :    * @param comp Component number for vector of coupled vector variables
     828             :    * @return Reference to a VectorVariableGradient containing the old gradient of the coupled vector
     829             :    * variable
     830             :    */
     831             :   virtual const VectorVariableGradient & coupledVectorGradientOld(const std::string & var_name,
     832             :                                                                   unsigned int comp = 0) const;
     833             : 
     834             :   /**
     835             :    * Returns an old gradient from two time steps previous of a coupled vector variable
     836             :    * @param var_name Name of coupled vector variable
     837             :    * @param comp Component number for vector of coupled vector variables
     838             :    * @return Reference to a VectorVariableGradient containing the older gradient of the coupled
     839             :    * vector variable
     840             :    */
     841             :   virtual const VectorVariableGradient & coupledVectorGradientOlder(const std::string & var_name,
     842             :                                                                     unsigned int comp = 0) const;
     843             : 
     844             :   /**
     845             :    * Returns gradient of a coupled array variable
     846             :    * @param var_name Name of coupled array variable
     847             :    * @param comp Component number for vector of coupled array variables
     848             :    * @return Reference to a VectorVariableGradient containing the gradient of the coupled array
     849             :    * variable
     850             :    */
     851             :   virtual const ArrayVariableGradient & coupledArrayGradient(const std::string & var_name,
     852             :                                                              unsigned int comp = 0) const;
     853             : 
     854             :   /**
     855             :    * Returns an old gradient from previous time step of a coupled array variable
     856             :    * @param var_name Name of coupled array variable
     857             :    * @param comp Component number for vector of coupled array variables
     858             :    * @return Reference to a VectorVariableGradient containing the old gradient of the coupled array
     859             :    * variable
     860             :    */
     861             :   virtual const ArrayVariableGradient & coupledArrayGradientOld(const std::string & var_name,
     862             :                                                                 unsigned int comp = 0) const;
     863             : 
     864             :   /**
     865             :    * Returns an old gradient from two time steps previous of a coupled array variable
     866             :    * @param var_name Name of coupled array variable
     867             :    * @param comp Component number for vector of coupled array variables
     868             :    * @return Reference to a ArrayVariableGradient containing the older gradient of the coupled
     869             :    * array variable
     870             :    */
     871             :   virtual const ArrayVariableGradient & coupledArrayGradientOlder(const std::string & var_name,
     872             :                                                                   unsigned int comp = 0) const;
     873             : 
     874             :   /**
     875             :    * Retun a gradient of a coupled array variable's time derivative
     876             :    * @param var_name Name of coupled array variable
     877             :    * @param comp Component number for vector of coupled array variables
     878             :    * @return Reference to a ArrayVariableGradient containing the gradient of the time derivative
     879             :    * the coupled array variable
     880             :    */
     881             :   virtual const ArrayVariableGradient & coupledArrayGradientDot(const std::string & var_name,
     882             :                                                                 unsigned int comp = 0) const;
     883             : 
     884             :   /**
     885             :    * Returns curl of a coupled variable
     886             :    * @param var_name Name of coupled variable
     887             :    * @param comp Component number for vector of coupled variables
     888             :    * @return Reference to a VectorVariableCurl containing the curl of the coupled variable
     889             :    * @see Kernel::_curl_u
     890             :    */
     891             :   virtual const VectorVariableCurl & coupledCurl(const std::string & var_name,
     892             :                                                  unsigned int comp = 0) const;
     893             : 
     894             :   /**
     895             :    * Returns an old curl from previous time step of a coupled variable
     896             :    * @param var_name Name of coupled variable
     897             :    * @param comp Component number for vector of coupled variables
     898             :    * @return Reference to a VectorVariableCurl containing the old curl of the coupled variable
     899             :    * @see Kernel::_curl_u_old
     900             :    */
     901             :   virtual const VectorVariableCurl & coupledCurlOld(const std::string & var_name,
     902             :                                                     unsigned int comp = 0) const;
     903             : 
     904             :   /**
     905             :    * Returns an old curl from two time steps previous of a coupled variable
     906             :    * @param var_name Name of coupled variable
     907             :    * @param comp Component number for vector of coupled variables
     908             :    * @return Reference to a VectorVariableCurl containing the older curl of the coupled variable
     909             :    * @see Kernel::_curl_u_older
     910             :    */
     911             :   virtual const VectorVariableCurl & coupledCurlOlder(const std::string & var_name,
     912             :                                                       unsigned int comp = 0) const;
     913             : 
     914             :   /**
     915             :    * Returns curl of a coupled variable for use in objects utilizing Automatic Differentiation
     916             :    * @param var_name Name of coupled variable
     917             :    * @param comp Component number for vector of coupled variables
     918             :    * @return Reference to an ADVectorVariableCurl containing the curl of the coupled variable
     919             :    * @see Kernel::_curl_u
     920             :    */
     921             :   const ADVectorVariableCurl & adCoupledCurl(const std::string & var_name,
     922             :                                              unsigned int comp = 0) const;
     923             : 
     924             :   /**
     925             :    * Returns divergence of a coupled variable
     926             :    * @param var_name Name of coupled variable
     927             :    * @param comp Component number for vector of coupled variables
     928             :    * @return Reference to a VectorVariableDivergence containing the divergence of the coupled
     929             :    * variable
     930             :    * @see Kernel::_div_u
     931             :    */
     932             :   virtual const VectorVariableDivergence & coupledDiv(const std::string & var_name,
     933             :                                                       unsigned int comp = 0) const;
     934             : 
     935             :   /**
     936             :    * Returns an old divergence from previous time step of a coupled variable
     937             :    * @param var_name Name of coupled variable
     938             :    * @param comp Component number for vector of coupled variables
     939             :    * @return Reference to a VectorVariableDivergence containing the old divergence of the coupled
     940             :    * variable
     941             :    * @see Kernel::_div_u_old
     942             :    */
     943             :   virtual const VectorVariableDivergence & coupledDivOld(const std::string & var_name,
     944             :                                                          unsigned int comp = 0) const;
     945             : 
     946             :   /**
     947             :    * Returns an old divergence from two time steps previous of a coupled variable
     948             :    * @param var_name Name of coupled variable
     949             :    * @param comp Component number for vector of coupled variables
     950             :    * @return Reference to a VectorVariableDivergence containing the older divergence of the coupled
     951             :    * variable
     952             :    * @see Kernel::_div_u_older
     953             :    */
     954             :   virtual const VectorVariableDivergence & coupledDivOlder(const std::string & var_name,
     955             :                                                            unsigned int comp = 0) const;
     956             : 
     957             :   /**
     958             :    * Returns second spatial derivatives of a coupled variable
     959             :    * @param var_name Name of coupled variable
     960             :    * @param comp Component number for vector of coupled variables
     961             :    * @return Reference to a VariableSecond containing the second derivative of the coupled variable
     962             :    * @see Kernel::second
     963             :    */
     964             :   virtual const VariableSecond & coupledSecond(const std::string & var_name,
     965             :                                                unsigned int comp = 0) const;
     966             : 
     967             :   /**
     968             :    * Returns an old second spatial derivatives from previous time step of a coupled variable
     969             :    * @param var_name Name of coupled variable
     970             :    * @param comp Component number for vector of coupled variables
     971             :    * @return Reference to a VariableSecond containing the old second derivative of the coupled
     972             :    * variable
     973             :    * @see Kernel::secondOld
     974             :    */
     975             :   virtual const VariableSecond & coupledSecondOld(const std::string & var_name,
     976             :                                                   unsigned int comp = 0) const;
     977             : 
     978             :   /**
     979             :    * Returns an old second derivative from two time steps previous of a coupled variable
     980             :    * @param var_name Name of coupled variable
     981             :    * @param comp Component number for vector of coupled variables
     982             :    * @return Reference to a VariableSecond containing the older second derivative of the coupled
     983             :    * variable
     984             :    * @see Kernel::secondOlder
     985             :    */
     986             :   virtual const VariableSecond & coupledSecondOlder(const std::string & var_name,
     987             :                                                     unsigned int comp = 0) const;
     988             : 
     989             :   /**
     990             :    * Returns second derivative of a coupled variable for the previous Newton iterate
     991             :    * @param var_name Name of coupled variable
     992             :    * @param comp Component number for vector of coupled variables
     993             :    * @return Reference to a VariableSecond containing the second derivative of the coupled variable
     994             :    */
     995             :   virtual const VariableSecond & coupledSecondPreviousNL(const std::string & var_name,
     996             :                                                          unsigned int comp = 0) const;
     997             : 
     998             :   /**
     999             :    * Time derivative of a coupled variable
    1000             :    * @param var_name Name of coupled variable
    1001             :    * @param comp Component number for vector of coupled variables
    1002             :    * @return Reference to a VariableValue containing the time derivative of the coupled variable
    1003             :    */
    1004             :   virtual const VariableValue & coupledDot(const std::string & var_name,
    1005             :                                            unsigned int comp = 0) const;
    1006             : 
    1007             :   /**
    1008             :    * Returns the time derivatives for all of a coupled variable's components
    1009             :    * @param var_name Name of coupled variable
    1010             :    * @return Vector of VariableValue pointers for each component of \p var_name
    1011             :    */
    1012             :   std::vector<const VariableValue *> coupledDots(const std::string & var_name) const;
    1013             : 
    1014             :   /**
    1015             :    * Second time derivative of a coupled variable
    1016             :    * @param var_name Name of coupled variable
    1017             :    * @param comp Component number for vector of coupled variables
    1018             :    * @return Reference to a VariableValue containing the second time derivative of the coupled
    1019             :    * variable
    1020             :    */
    1021             :   virtual const VariableValue & coupledDotDot(const std::string & var_name,
    1022             :                                               unsigned int comp = 0) const;
    1023             : 
    1024             :   /**
    1025             :    * Old time derivative of a coupled variable
    1026             :    * @param var_name Name of coupled variable
    1027             :    * @param comp Component number for vector of coupled variables
    1028             :    * @return Reference to a VariableValue containing the old time derivative of the coupled variable
    1029             :    */
    1030             :   virtual const VariableValue & coupledDotOld(const std::string & var_name,
    1031             :                                               unsigned int comp = 0) const;
    1032             : 
    1033             :   /**
    1034             :    * Old second time derivative of a coupled variable
    1035             :    * @param var_name Name of coupled variable
    1036             :    * @param comp Component number for vector of coupled variables
    1037             :    * @return Reference to a VariableValue containing the old second time derivative of the coupled
    1038             :    * variable
    1039             :    */
    1040             :   virtual const VariableValue & coupledDotDotOld(const std::string & var_name,
    1041             :                                                  unsigned int comp = 0) const;
    1042             : 
    1043             :   /**
    1044             :    * Time derivative of a coupled variable for ad simulations
    1045             :    * @param var_name Name of coupled variable
    1046             :    * @param comp Component number for vector of coupled variables
    1047             :    * @return Reference to a VariableValue containing the time derivative of the coupled variable
    1048             :    * @see Kernel::dot
    1049             :    */
    1050             :   const ADVariableValue & adCoupledDot(const std::string & var_name, unsigned int comp = 0) const;
    1051             : 
    1052             :   /**
    1053             :    * Returns the time derivatives for all of a coupled variable's components for ad simulations
    1054             :    * @param var_name Name of coupled variable
    1055             :    * @return Vector of VariableValue pointers for each component of \p var_name
    1056             :    */
    1057             :   std::vector<const ADVariableValue *> adCoupledDots(const std::string & var_name) const;
    1058             : 
    1059             :   /**
    1060             :    * Second time derivative of a coupled variable for ad simulations
    1061             :    * @param var_name Name of coupled variable
    1062             :    * @param comp Component number for vector of coupled variables
    1063             :    * @return Reference to an ADVariableValue containing the second time derivative of the coupled
    1064             :    * variable
    1065             :    */
    1066             :   const ADVariableValue & adCoupledDotDot(const std::string & var_name,
    1067             :                                           unsigned int comp = 0) const;
    1068             : 
    1069             :   /**
    1070             :    * Time derivative of a vector coupled variable for ad simulations
    1071             :    * @param var_name Name of vector coupled variable
    1072             :    * @param comp Component number
    1073             :    * @return Reference to a VectorVariableValue containing the time derivative of the coupled
    1074             :    * variable
    1075             :    * @see Kernel::dot
    1076             :    */
    1077             :   const ADVectorVariableValue & adCoupledVectorDot(const std::string & var_name,
    1078             :                                                    unsigned int comp = 0) const;
    1079             : 
    1080             :   /**
    1081             :    * Time derivative of a coupled vector variable
    1082             :    * @param var_name Name of coupled vector variable
    1083             :    * @param comp Component number for vector of coupled vector variables
    1084             :    * @return Reference to a VectorVariableValue containing the time derivative of the coupled
    1085             :    * variable
    1086             :    */
    1087             :   virtual const VectorVariableValue & coupledVectorDot(const std::string & var_name,
    1088             :                                                        unsigned int comp = 0) const;
    1089             : 
    1090             :   /**
    1091             :    * Second time derivative of a coupled vector variable
    1092             :    * @param var_name Name of coupled vector variable
    1093             :    * @param comp Component number for vector of coupled vector variables
    1094             :    * @return Reference to a VectorVariableValue containing the time derivative of the coupled
    1095             :    * variable
    1096             :    */
    1097             :   virtual const VectorVariableValue & coupledVectorDotDot(const std::string & var_name,
    1098             :                                                           unsigned int comp = 0) const;
    1099             : 
    1100             :   /**
    1101             :    * Old time derivative of a coupled vector variable
    1102             :    * @param var_name Name of coupled vector variable
    1103             :    * @param comp Component number for vector of coupled vector variables
    1104             :    * @return Reference to a VectorVariableValue containing the time derivative of the coupled
    1105             :    * variable
    1106             :    */
    1107             :   virtual const VectorVariableValue & coupledVectorDotOld(const std::string & var_name,
    1108             :                                                           unsigned int comp = 0) const;
    1109             : 
    1110             :   /**
    1111             :    * Old second time derivative of a coupled vector variable
    1112             :    * @param var_name Name of coupled vector variable
    1113             :    * @param comp Component number for vector of coupled vector variables
    1114             :    * @return Reference to a VectorVariableValue containing the time derivative of the coupled
    1115             :    * variable
    1116             :    */
    1117             :   virtual const VectorVariableValue & coupledVectorDotDotOld(const std::string & var_name,
    1118             :                                                              unsigned int comp = 0) const;
    1119             : 
    1120             :   /**
    1121             :    * Time derivative of a coupled vector variable with respect to the coefficients
    1122             :    * @param var_name Name of coupled vector variable
    1123             :    * @param comp Component number for vector of coupled vector variables
    1124             :    * @return Reference to a VariableValue containing the time derivative of the coupled
    1125             :    * vector variable with respect to the coefficients
    1126             :    */
    1127             :   virtual const VariableValue & coupledVectorDotDu(const std::string & var_name,
    1128             :                                                    unsigned int comp = 0) const;
    1129             : 
    1130             :   /**
    1131             :    * Second time derivative of a coupled vector variable with respect to the coefficients
    1132             :    * @param var_name Name of coupled vector variable
    1133             :    * @param comp Component number for vector of coupled vector variables
    1134             :    * @return Reference to a VariableValue containing the time derivative of the coupled vector
    1135             :    * variable with respect to the coefficients
    1136             :    */
    1137             :   virtual const VariableValue & coupledVectorDotDotDu(const std::string & var_name,
    1138             :                                                       unsigned int comp = 0) const;
    1139             : 
    1140             :   /**
    1141             :    * Time derivative of a coupled array variable
    1142             :    * @param var_name Name of coupled array variable
    1143             :    * @param comp Component number for vector of coupled array variables
    1144             :    * @return Reference to a ArrayVariableValue containing the time derivative of the coupled
    1145             :    * variable
    1146             :    */
    1147             :   virtual const ArrayVariableValue & coupledArrayDot(const std::string & var_name,
    1148             :                                                      unsigned int comp = 0) const;
    1149             : 
    1150             :   /**
    1151             :    * Second time derivative of a coupled array variable
    1152             :    * @param var_name Name of coupled array variable
    1153             :    * @param comp Component number for vector of coupled array variables
    1154             :    * @return Reference to a ArrayVariableValue containing the time derivative of the coupled
    1155             :    * variable
    1156             :    */
    1157             :   virtual const ArrayVariableValue & coupledArrayDotDot(const std::string & var_name,
    1158             :                                                         unsigned int comp = 0) const;
    1159             : 
    1160             :   /**
    1161             :    * Old time derivative of a coupled array variable
    1162             :    * @param var_name Name of coupled array variable
    1163             :    * @param comp Component number for vector of coupled array variables
    1164             :    * @return Reference to a ArrayVariableValue containing the time derivative of the coupled
    1165             :    * variable
    1166             :    */
    1167             :   virtual const ArrayVariableValue & coupledArrayDotOld(const std::string & var_name,
    1168             :                                                         unsigned int comp = 0) const;
    1169             : 
    1170             :   /**
    1171             :    * Old second time derivative of a coupled array variable
    1172             :    * @param var_name Name of coupled array variable
    1173             :    * @param comp Component number for vector of coupled array variables
    1174             :    * @return Reference to a ArrayVariableValue containing the time derivative of the coupled
    1175             :    * variable
    1176             :    */
    1177             :   virtual const ArrayVariableValue & coupledArrayDotDotOld(const std::string & var_name,
    1178             :                                                            unsigned int comp = 0) const;
    1179             : 
    1180             :   /**
    1181             :    * Time derivative of a coupled variable with respect to the coefficients
    1182             :    * @param var_name Name of coupled variable
    1183             :    * @param comp Component number for vector of coupled variables
    1184             :    * @return Reference to a VariableValue containing the time derivative of the coupled variable
    1185             :    * with respect to the coefficients
    1186             :    */
    1187             :   virtual const VariableValue & coupledDotDu(const std::string & var_name,
    1188             :                                              unsigned int comp = 0) const;
    1189             : 
    1190             :   /**
    1191             :    * Second time derivative of a coupled variable with respect to the coefficients
    1192             :    * @param var_name Name of coupled variable
    1193             :    * @param comp Component number for vector of coupled variables
    1194             :    * @return Reference to a VariableValue containing the time derivative of the coupled variable
    1195             :    * with respect to the coefficients
    1196             :    */
    1197             :   virtual const VariableValue & coupledDotDotDu(const std::string & var_name,
    1198             :                                                 unsigned int comp = 0) const;
    1199             : 
    1200             :   /**
    1201             :    * Time derivative of a coupled array variable with respect to the coefficients
    1202             :    * @param var_name Name of coupled array variable
    1203             :    * @param comp Component number for vector of coupled array variables
    1204             :    * @return Reference to a ArrayVariableValue containing the time derivative of the coupled
    1205             :    * variable
    1206             :    */
    1207             :   const VariableValue & coupledArrayDotDu(const std::string & var_name,
    1208             :                                           unsigned int comp = 0) const;
    1209             : 
    1210             :   /**
    1211             :    * Returns nodal values of a coupled variable
    1212             :    * @param var_name Name of coupled variable
    1213             :    * @param comp Component number for vector of coupled variables
    1214             :    * @return Reference to a VariableValue for the coupled variable
    1215             :    */
    1216             :   template <typename T>
    1217             :   const T & coupledNodalValue(const std::string & var_name, unsigned int comp = 0) const;
    1218             : 
    1219             :   /**
    1220             :    * Returns AD nodal values of a coupled variable
    1221             :    * @param var_name Name of coupled variable
    1222             :    * @param comp Component number for vector of coupled variables
    1223             :    * @return Reference to a VariableValue for the coupled variable
    1224             :    */
    1225             :   template <typename T>
    1226             :   const typename Moose::ADType<T>::type & adCoupledNodalValue(const std::string & var_name,
    1227             :                                                               unsigned int comp = 0) const;
    1228             : 
    1229             :   /**
    1230             :    * Returns an old nodal value from previous time step  of a coupled variable
    1231             :    * @param var_name Name of coupled variable
    1232             :    * @param comp Component number for vector of coupled variables
    1233             :    * @return Reference to a VariableValue containing the old value of the coupled variable
    1234             :    */
    1235             :   template <typename T>
    1236             :   const T & coupledNodalValueOld(const std::string & var_name, unsigned int comp = 0) const;
    1237             : 
    1238             :   /**
    1239             :    * Returns an old nodal value from two time steps previous of a coupled variable
    1240             :    * @param var_name Name of coupled variable
    1241             :    * @param comp Component number for vector of coupled variables
    1242             :    * @return Reference to a VariableValue containing the older value of the coupled variable
    1243             :    */
    1244             :   template <typename T>
    1245             :   const T & coupledNodalValueOlder(const std::string & var_name, unsigned int comp = 0) const;
    1246             : 
    1247             :   /**
    1248             :    * Returns nodal values of a coupled variable for previous Newton iterate
    1249             :    * @param var_name Name of coupled variable
    1250             :    * @param comp Component number for vector of coupled variables
    1251             :    * @return Reference to a VariableValue for the coupled variable
    1252             :    */
    1253             :   template <typename T>
    1254             :   const T & coupledNodalValuePreviousNL(const std::string & var_name, unsigned int comp = 0) const;
    1255             : 
    1256             :   /**
    1257             :    * Nodal values of time derivative of a coupled variable
    1258             :    * @param var_name Name of coupled variable
    1259             :    * @param comp Component number for vector of coupled variables
    1260             :    * @return Reference to a VariableValue containing the nodal values of time derivative of the
    1261             :    * coupled variable
    1262             :    */
    1263             :   template <typename T>
    1264             :   const T & coupledNodalDot(const std::string & var_name, unsigned int comp = 0) const;
    1265             : 
    1266             :   /**
    1267             :    * Nodal values of second time derivative of a coupled variable
    1268             :    * @param var_name Name of coupled variable
    1269             :    * @param comp Component number for vector of coupled variables
    1270             :    * @return Reference to a VariableValue containing the nodal values of second time derivative of
    1271             :    * the coupled variable
    1272             :    */
    1273             :   virtual const VariableValue & coupledNodalDotDot(const std::string & var_name,
    1274             :                                                    unsigned int comp = 0) const;
    1275             : 
    1276             :   /**
    1277             :    * Nodal values of old time derivative of a coupled variable
    1278             :    * @param var_name Name of coupled variable
    1279             :    * @param comp Component number for vector of coupled variables
    1280             :    * @return Reference to a VariableValue containing the nodal values of time derivative of the
    1281             :    * coupled variable
    1282             :    */
    1283             :   virtual const VariableValue & coupledNodalDotOld(const std::string & var_name,
    1284             :                                                    unsigned int comp = 0) const;
    1285             : 
    1286             :   /**
    1287             :    * Nodal values of old second time derivative of a coupled variable
    1288             :    * @param var_name Name of coupled variable
    1289             :    * @param comp Component number for vector of coupled variables
    1290             :    * @return Reference to a VariableValue containing the nodal values of second time derivative of
    1291             :    * the coupled variable
    1292             :    */
    1293             :   virtual const VariableValue & coupledNodalDotDotOld(const std::string & var_name,
    1294             :                                                       unsigned int comp = 0) const;
    1295             :   // coupled-dof-values-begin
    1296             :   /**
    1297             :    * Returns DoFs in the current solution vector of a coupled variable for the local element
    1298             :    * @param var_name Name of coupled variable
    1299             :    * @param comp Component number for vector of coupled variables
    1300             :    * @return Reference to a VariableValue for the DoFs of the coupled variable
    1301             :    */
    1302             :   virtual const VariableValue & coupledDofValues(const std::string & var_name,
    1303             :                                                  unsigned int comp = 0) const;
    1304             : 
    1305             :   /**
    1306             :    * Returns DoFs in the current solution vector of all of a coupled variable's components for the
    1307             :    * local element
    1308             :    * @param var_name Name of coupled variable
    1309             :    * @return Vector of VariableValue pointers for each component of the coupled variable
    1310             :    */
    1311             :   std::vector<const VariableValue *> coupledAllDofValues(const std::string & var_name) const;
    1312             : 
    1313             :   /**
    1314             :    * Returns DoFs in the old solution vector of a coupled variable for the local element
    1315             :    * @param var_name Name of coupled variable
    1316             :    * @param comp Component number for vector of coupled variables
    1317             :    * @return Reference to a VariableValue for the old DoFs of the coupled variable
    1318             :    */
    1319             :   virtual const VariableValue & coupledDofValuesOld(const std::string & var_name,
    1320             :                                                     unsigned int comp = 0) const;
    1321             : 
    1322             :   /**
    1323             :    * Returns DoFs in the old solution vector of all of a coupled variable's components for the local
    1324             :    * element
    1325             :    * @param var_name Name of coupled variable
    1326             :    * @return Vector of VariableValue pointers for each compontnet of the coupled variable
    1327             :    */
    1328             :   std::vector<const VariableValue *> coupledAllDofValuesOld(const std::string & var_name) const;
    1329             : 
    1330             :   /**
    1331             :    * Returns DoFs in the older solution vector of a coupled variable for the local element
    1332             :    * @param var_name Name of coupled variable
    1333             :    * @param comp Component number for vector of coupled variables
    1334             :    * @return Reference to a VariableValue for the older DoFs of the coupled variable
    1335             :    */
    1336             :   virtual const VariableValue & coupledDofValuesOlder(const std::string & var_name,
    1337             :                                                       unsigned int comp = 0) const;
    1338             : 
    1339             :   /**
    1340             :    * Returns DoFs in the older solution vector of all of a coupled variable's components for the
    1341             :    * local element
    1342             :    * @param var_name Name of coupled variable
    1343             :    * @return Vector of VariableValue pointers for each component of the coupled variable
    1344             :    */
    1345             :   std::vector<const VariableValue *> coupledAllDofValuesOlder(const std::string & var_name) const;
    1346             : 
    1347             :   /**
    1348             :    * Returns DoFs in the current solution vector of a coupled array variable for the local element
    1349             :    * @param var_name Name of coupled array variable
    1350             :    * @param comp Component number for vector of coupled array variables
    1351             :    * @return Reference to a VariableValue for the DoFs of the coupled variable
    1352             :    */
    1353             :   virtual const ArrayVariableValue & coupledArrayDofValues(const std::string & var_name,
    1354             :                                                            unsigned int comp = 0) const;
    1355             :   // coupled-dof-values-end
    1356             : 
    1357             :   /**
    1358             :    * Returns DOF value of a coupled variable for use in Automatic Differentiation
    1359             :    * @param var_name Name of coupled variable
    1360             :    * @param comp Component number for vector of coupled variables
    1361             :    * @return Reference to an ADVariableValue for the DoFs of the coupled variable
    1362             :    */
    1363             :   virtual const ADVariableValue & adCoupledDofValues(const std::string & var_name,
    1364             :                                                      unsigned int comp = 0) const;
    1365             : 
    1366             :   /**
    1367             :    * method that returns _zero to RESIDUAL computing objects and _ad_zero to JACOBIAN
    1368             :    * computing objects
    1369             :    */
    1370             :   const ADVariableValue & adZeroValue() const;
    1371             : 
    1372             :   /**
    1373             :    *  method that returns _grad_zero to RESIDUAL computing objects and _ad_grad_zero to
    1374             :    * JACOBIAN computing objects
    1375             :    */
    1376             :   const ADVariableGradient & adZeroGradient() const;
    1377             : 
    1378             :   /**
    1379             :    * Retrieve a zero second for automatic differentiation
    1380             :    */
    1381             :   const ADVariableSecond & adZeroSecond() const;
    1382             : 
    1383             :   /**
    1384             :    * Returns zero value templated with automatic differentiation boolean
    1385             :    * @return Reference to a const GenericVariableValue
    1386             :    */
    1387             :   template <bool is_ad>
    1388             :   const GenericVariableValue<is_ad> & genericZeroValue();
    1389             : 
    1390             :   /**
    1391             :    * Returns zero gradient templated with automatic differentiation boolean
    1392             :    * @return Reference to a const GenericVariableValue
    1393             :    */
    1394             :   template <bool is_ad>
    1395             :   const GenericVariableGradient<is_ad> & genericZeroGradient();
    1396             : 
    1397             :   /**
    1398             :    * Returns zero second derivative templated with automatic differentiation boolean
    1399             :    * @return Reference to a const GenericVariableValue
    1400             :    */
    1401             :   template <bool is_ad>
    1402             :   const GenericVariableSecond<is_ad> & genericZeroSecond();
    1403             : 
    1404             : protected:
    1405             :   // Reference to the interface's input parameters
    1406             :   const InputParameters & _c_parameters;
    1407             : 
    1408             :   /// The name of the object this interface is part of
    1409             :   const std::string & _c_name;
    1410             :   /// The type of the object this interface is part of
    1411             :   const std::string & _c_type;
    1412             : 
    1413             :   // Reference to FEProblemBase
    1414             :   FEProblemBase & _c_fe_problem;
    1415             : 
    1416             :   /// Pointer to the system object if the moose object this is an interface for has one
    1417             :   const SystemBase * const _c_sys;
    1418             : 
    1419             :   /// Coupled vars whose values we provide
    1420             :   std::unordered_map<std::string, std::vector<MooseVariableFieldBase *>> _coupled_vars;
    1421             : 
    1422             :   /// Vector of all coupled variables
    1423             :   std::vector<MooseVariableFieldBase *> _coupled_moose_vars;
    1424             : 
    1425             :   /// Vector of standard coupled variables
    1426             :   std::vector<MooseVariable *> _coupled_standard_moose_vars;
    1427             : 
    1428             :   /// Vector of vector coupled variables
    1429             :   std::vector<VectorMooseVariable *> _coupled_vector_moose_vars;
    1430             : 
    1431             :   /// Vector of array coupled variables
    1432             :   std::vector<ArrayMooseVariable *> _coupled_array_moose_vars;
    1433             : 
    1434             :   /// Vector of all finite volume coupled variables
    1435             :   std::vector<MooseVariableField<Real> *> _coupled_fv_moose_vars;
    1436             : 
    1437             :   /// map from new to deprecated variable names
    1438             :   const std::unordered_map<std::string, std::string> & _new_to_deprecated_coupled_vars;
    1439             : 
    1440             :   /// True if we provide coupling to nodal values
    1441             :   bool _c_nodal;
    1442             : 
    1443             :   /// True if implicit value is required
    1444             :   bool _c_is_implicit;
    1445             : 
    1446             :   // Argument to allow element-to-nodal coupling
    1447             :   const bool _c_allow_element_to_nodal_coupling;
    1448             : 
    1449             :   /// Thread ID of the thread using this object
    1450             :   THREAD_ID _c_tid;
    1451             : 
    1452             :   /// Will hold the default value for optional coupled variables.
    1453             :   mutable std::unordered_map<std::string, std::vector<std::unique_ptr<VariableValue>>>
    1454             :       _default_value;
    1455             : 
    1456             :   /// Will hold the default value for optional coupled variables for automatic differentiation.
    1457             :   mutable std::unordered_map<std::string, std::unique_ptr<MooseArray<ADReal>>> _ad_default_value;
    1458             : 
    1459             :   /// Will hold the default value for optional vector coupled variables.
    1460             :   mutable std::unordered_map<std::string, std::unique_ptr<VectorVariableValue>>
    1461             :       _default_vector_value;
    1462             : 
    1463             :   /// Will hold the default value for optional array coupled variables.
    1464             :   mutable std::unordered_map<std::string, std::unique_ptr<ArrayVariableValue>> _default_array_value;
    1465             : 
    1466             :   /// Will hold the default value for optional vector coupled variables for automatic differentiation.
    1467             :   mutable std::unordered_map<std::string, std::unique_ptr<MooseArray<ADRealVectorValue>>>
    1468             :       _ad_default_vector_value;
    1469             : 
    1470             :   /**
    1471             :    * This will always be zero because the default values for optionally coupled variables is always
    1472             :    * constant and this is used for time derivative info
    1473             :    */
    1474             :   mutable VariableValue _default_value_zero;
    1475             : 
    1476             :   /// This will always be zero because the default values for optionally coupled variables is always constant
    1477             :   mutable VariableGradient _default_gradient;
    1478             : 
    1479             :   /// This will always be zero because the default values for optionally coupled variables is always constant
    1480             :   mutable MooseArray<ADRealVectorValue> _ad_default_gradient;
    1481             : 
    1482             :   /// This will always be zero because the default values for optionally coupled vector variables is always constant
    1483             :   mutable MooseArray<ADRealTensorValue> _ad_default_vector_gradient;
    1484             : 
    1485             :   /// This will always be zero because the default values for optionally coupled variables is always constant
    1486             :   mutable VariableSecond _default_second;
    1487             : 
    1488             :   /// This will always be zero because the default values for optionally coupled variables is always constant
    1489             :   mutable MooseArray<ADRealTensorValue> _ad_default_second;
    1490             : 
    1491             :   /// This will always be zero because the default values for optionally coupled vector variables is always constant
    1492             :   mutable MooseArray<ADRealVectorValue> _ad_default_curl;
    1493             : 
    1494             :   /// Zero value of a variable
    1495             :   const VariableValue & _zero;
    1496             :   const VariablePhiValue & _phi_zero;
    1497             :   const MooseArray<ADReal> & _ad_zero;
    1498             : 
    1499             :   /// Zero gradient of a variable
    1500             :   const VariableGradient & _grad_zero;
    1501             :   const MooseArray<ADRealVectorValue> & _ad_grad_zero;
    1502             : 
    1503             :   /// Zero gradient of trial function
    1504             :   const VariablePhiGradient & _grad_phi_zero;
    1505             : 
    1506             :   /// Zero second derivative of a variable
    1507             :   const VariableSecond & _second_zero;
    1508             :   const MooseArray<ADRealTensorValue> & _ad_second_zero;
    1509             :   /// Zero second derivative of a test function
    1510             :   const VariablePhiSecond & _second_phi_zero;
    1511             :   /// Zero value of a vector variable
    1512             :   const VectorVariableValue & _vector_zero;
    1513             :   /// Zero value of the curl of a vector variable
    1514             :   const VectorVariableCurl & _vector_curl_zero;
    1515             : 
    1516             :   /**
    1517             :    * This will always be zero because the default values for optionally coupled variables is always
    1518             :    * constant and this is used for time derivative info
    1519             :    */
    1520             :   mutable VectorVariableValue _default_vector_value_zero;
    1521             : 
    1522             :   /// This will always be zero because the default values for optionally coupled variables is always constant
    1523             :   mutable VectorVariableGradient _default_vector_gradient;
    1524             : 
    1525             :   /// This will always be zero because the default values for optionally coupled variables is always constant
    1526             :   mutable VectorVariableCurl _default_vector_curl;
    1527             : 
    1528             :   /// This will always be zero because the default values for optionally coupled variables is always constant
    1529             :   mutable VectorVariableDivergence _default_div;
    1530             : 
    1531             :   /**
    1532             :    * This will always be zero because the default values for optionally coupled variables is always
    1533             :    * constant and this is used for time derivative info
    1534             :    */
    1535             :   ArrayVariableValue _default_array_value_zero;
    1536             : 
    1537             :   /// This will always be zero because the default values for optionally coupled variables is always constant
    1538             :   ArrayVariableGradient _default_array_gradient;
    1539             : 
    1540             :   /**
    1541             :    * Check that the right kind of variable is being coupled in
    1542             :    *
    1543             :    * @param var_name The name of the coupled variable
    1544             :    */
    1545             :   bool
    1546             :   checkVar(const std::string & var_name, unsigned int comp = 0, unsigned int comp_bound = 0) const;
    1547             : 
    1548             : private:
    1549             :   /**
    1550             :    * Generic helper method to get vector tag values based on tag ID
    1551             :    */
    1552             :   template <typename T>
    1553             :   const typename OutputTools<T>::VariableValue &
    1554             :   vectorTagValueHelper(const std::string & var_names, TagID tag, unsigned int index = 0) const;
    1555             : 
    1556             :   /**
    1557             :    * Generic helper method to get vector tag values based on tag name
    1558             :    */
    1559             :   template <typename T>
    1560             :   const typename OutputTools<T>::VariableValue & vectorTagValueHelper(const std::string & var_names,
    1561             :                                                                       const std::string & tag_name,
    1562             :                                                                       unsigned int index = 0) const;
    1563             : 
    1564             :   /**
    1565             :    * Generic helper method to get vector tag degree of freedom values based on tag ID
    1566             :    */
    1567             :   template <typename T>
    1568             :   const typename OutputTools<T>::VariableValue &
    1569             :   vectorTagDofValueHelper(const std::string & var_name, TagID tag, unsigned int comp = 0) const;
    1570             : 
    1571             :   /**
    1572             :    * Generic helper method to get vector tag degree of freedom values based on tag name
    1573             :    */
    1574             :   template <typename T>
    1575             :   const typename OutputTools<T>::VariableValue & vectorTagDofValueHelper(
    1576             :       const std::string & var_name, const std::string & tag_name, unsigned int comp = 0) const;
    1577             : 
    1578             :   /**
    1579             :    * Method that may request additional solution states from the variable's system depending on the
    1580             :    * value of \p tag_name. E.g. if the tag name corresponds to old or older variable solution
    1581             :    * values, then we must request more states
    1582             :    */
    1583             :   template <typename T>
    1584             :   void
    1585             :   requestStates(const std::string & var_name, const TagName & tag_name, const unsigned int comp);
    1586             : 
    1587             :   enum class FuncAge
    1588             :   {
    1589             :     Curr,
    1590             :     Old,
    1591             :     Older,
    1592             :   };
    1593             : 
    1594             :   enum class VarType
    1595             :   {
    1596             :     Ignore,
    1597             :     Gradient,
    1598             :     Second,
    1599             :     GradientDot,
    1600             :     Dot,
    1601             :   };
    1602             : 
    1603             :   void checkFuncType(const std::string var_name, VarType t, FuncAge age) const;
    1604             : 
    1605             : protected:
    1606             :   /**
    1607             :    * Deprecated method. Use \p getFieldVar instead
    1608             :    * Extract pointer to a base coupled field variable. Could be either a finite volume or finite
    1609             :    * element variable
    1610             :    * @param var_name Name of parameter desired
    1611             :    * @param comp Component number of multiple coupled variables
    1612             :    * @return Pointer to the desired variable
    1613             :    */
    1614             :   const MooseVariableFieldBase * getFEVar(const std::string & var_name, unsigned int comp) const;
    1615             : 
    1616             :   /*
    1617             :    * Extract pointer to a base coupled field variable. Could be either a finite volume or finite
    1618             :    * element variable
    1619             :    * @param var_name Name of parameter desired
    1620             :    * @param comp Component number of multiple coupled variables
    1621             :    * @return Pointer to the desired variable
    1622             :    */
    1623             :   const MooseVariableFieldBase * getFieldVar(const std::string & var_name, unsigned int comp) const;
    1624             : 
    1625             :   /*
    1626             :    * Extract pointer to a base coupled field variable. Could be either a finite volume or finite
    1627             :    * element variable
    1628             :    * @param var_name Name of variable desired
    1629             :    * @param comp Component number of multiple coupled variables
    1630             :    * @return Pointer to the desired variable
    1631             :    */
    1632             :   MooseVariableFieldBase * getFieldVar(const std::string & var_name, unsigned int comp);
    1633             : 
    1634             :   /**
    1635             :    * Helper that that be used to retrieve a variable of arbitrary type \p T
    1636             :    */
    1637             :   template <typename T>
    1638             :   const T * getVarHelper(const std::string & var_name, unsigned int comp) const;
    1639             : 
    1640             :   /**
    1641             :    * Helper that can be used to retrieve a variable of arbitrary type \p T
    1642             :    */
    1643             :   template <typename T>
    1644             :   T * getVarHelper(const std::string & var_name, unsigned int comp);
    1645             : 
    1646             :   /**
    1647             :    * Extract pointer to a coupled variable
    1648             :    * @param var_name Name of parameter desired
    1649             :    * @param comp Component number of multiple coupled variables
    1650             :    * @return Pointer to the desired variable
    1651             :    */
    1652             :   MooseVariable * getVar(const std::string & var_name, unsigned int comp);
    1653             : 
    1654             :   /**
    1655             :    * Extract pointer to a coupled vector variable
    1656             :    * @param var_name Name of parameter desired
    1657             :    * @param comp Component number of multiple coupled variables
    1658             :    * @return Pointer to the desired variable
    1659             :    */
    1660             :   VectorMooseVariable * getVectorVar(const std::string & var_name, unsigned int comp);
    1661             : 
    1662             :   /**
    1663             :    * Extract pointer to a coupled array variable
    1664             :    * @param var_name Name of parameter desired
    1665             :    * @param comp Component number of multiple coupled variables
    1666             :    * @return Pointer to the desired variable
    1667             :    */
    1668             :   ArrayMooseVariable * getArrayVar(const std::string & var_name, unsigned int comp);
    1669             : 
    1670             :   /**
    1671             :    * Extract pointer to a coupled variable
    1672             :    * @param var_name Name of parameter desired
    1673             :    * @param comp Component number of multiple coupled variables
    1674             :    * @return Pointer to the desired variable
    1675             :    */
    1676             :   const MooseVariable * getVar(const std::string & var_name, unsigned int comp) const;
    1677             : 
    1678             :   /**
    1679             :    * Extract pointer to a coupled vector variable
    1680             :    * @param var_name Name of parameter desired
    1681             :    * @param comp Component number of multiple coupled variables
    1682             :    * @return Pointer to the desired variable
    1683             :    */
    1684             :   const VectorMooseVariable * getVectorVar(const std::string & var_name, unsigned int comp) const;
    1685             : 
    1686             :   /**
    1687             :    * Extract pointer to a coupled array variable
    1688             :    * @param var_name Name of parameter desired
    1689             :    * @param comp Component number of multiple coupled variables
    1690             :    * @return Pointer to the desired variable
    1691             :    */
    1692             :   const ArrayMooseVariable * getArrayVar(const std::string & var_name, unsigned int comp) const;
    1693             : 
    1694             :   /**
    1695             :    * Checks to make sure that the current Executioner has set "_is_transient" when old/older values
    1696             :    * are coupled in.
    1697             :    * @param name the name of the variable
    1698             :    * @param fn_name The name of the function that called this method - used in the error message
    1699             :    */
    1700             :   void validateExecutionerType(const std::string & name, const std::string & fn_name) const;
    1701             : 
    1702             :   template <typename T, typename Func>
    1703        3276 :   std::vector<T> coupledVectorHelper(const std::string & var_name, const Func & func) const
    1704             :   {
    1705        3276 :     const auto components = coupledComponents(var_name);
    1706        3276 :     std::vector<T> vals(components);
    1707       28859 :     for (MooseIndex(components) comp = 0; comp < components; ++comp)
    1708       25583 :       vals[comp] = func(comp);
    1709        3276 :     return vals;
    1710           0 :   }
    1711             : 
    1712             :   /// Whether or not this object is a "neighbor" object: ie all of it's coupled values should be neighbor values
    1713             :   bool _coupleable_neighbor;
    1714             : 
    1715             : public:
    1716             :   /**
    1717             :    * Helper method to return (and insert if necessary) the default value for Automatic
    1718             :    * Differentiation for an uncoupled variable.
    1719             :    * @param var_name the name of the variable for which to retrieve a default value
    1720             :    * @return VariableValue * a pointer to the associated VariableValue.
    1721             :    */
    1722             :   const ADVariableValue * getADDefaultValue(const std::string & var_name) const;
    1723             : 
    1724             :   /**
    1725             :    * Helper method to return (and insert if necessary) the default vector value for Automatic
    1726             :    * Differentiation for an uncoupled variable.
    1727             :    * @param var_name the name of the vector variable for which to retrieve a default value
    1728             :    * @return VectorVariableValue * a pointer to the associated VectorVariableValue.
    1729             :    */
    1730             :   const ADVectorVariableValue * getADDefaultVectorValue(const std::string & var_name) const;
    1731             : 
    1732             :   /**
    1733             :    * Helper method to return (and insert if necessary) the default gradient for Automatic
    1734             :    * Differentiation for an uncoupled variable.
    1735             :    * @param var_name the name of the variable for which to retrieve a default gradient
    1736             :    * @return Reference to a ADVariableGradient containing zero entries for the default values
    1737             :    */
    1738             :   const ADVariableGradient & getADDefaultGradient() const;
    1739             : 
    1740             :   /**
    1741             :    * Helper method to return (and insert if necessary) the default gradient for Automatic
    1742             :    * Differentiation for an uncoupled vector variable.
    1743             :    * @param var_name the name of the vector variable for which to retrieve a default gradient
    1744             :    * @return Reference to a ADVectorVariableGradient containing zero entries for the default values
    1745             :    */
    1746             :   const ADVectorVariableGradient & getADDefaultVectorGradient() const;
    1747             : 
    1748             :   /**
    1749             :    * Helper method to return (and insert if necessary) the default second derivatives for Automatic
    1750             :    * Differentiation for an uncoupled variable.
    1751             :    * @param var_name the name of the variable for which to retrieve a default second derivative
    1752             :    * @return Reference to a ADVariableSecond containing zero entries for the default values
    1753             :    */
    1754             :   const ADVariableSecond & getADDefaultSecond() const;
    1755             : 
    1756             :   /**
    1757             :    * Helper method to return (and insert if necessary) the default curl value for Automatic
    1758             :    * Differentiation for an uncoupled variable.
    1759             :    * @param var_name the name of the vector variable for which to retrieve a default value
    1760             :    * @return Reference to a ADVectorVariableCurl containing zero entries for the default values
    1761             :    */
    1762             :   const ADVectorVariableCurl & getADDefaultCurl() const;
    1763             : 
    1764             : private:
    1765             :   /**
    1766             :    * Helper method to return (and insert if necessary) the default value
    1767             :    * for an uncoupled variable.
    1768             :    * @param var_name the name of the variable for which to retrieve a default value
    1769             :    * @return a pointer to the associated VariableValue.
    1770             :    */
    1771             :   const VariableValue * getDefaultValue(const std::string & var_name, unsigned int comp) const;
    1772             : 
    1773             :   /**
    1774             :    * Helper method to return (and insert if necessary) the default value
    1775             :    * for an uncoupled vector variable.
    1776             :    * @param var_name the name of the vector variable for which to retrieve a default value
    1777             :    * @return a pointer to the associated VectorVariableValue.
    1778             :    */
    1779             :   const VectorVariableValue * getDefaultVectorValue(const std::string & var_name) const;
    1780             : 
    1781             :   /**
    1782             :    * Helper method to return (and insert if necessary) the default value
    1783             :    * for an uncoupled array variable.
    1784             :    * @param var_name the name of the vector variable for which to retrieve a default value
    1785             :    * @return a pointer to the associated VectorVariableValue.
    1786             :    */
    1787             :   const ArrayVariableValue * getDefaultArrayValue(const std::string & var_name) const;
    1788             : 
    1789             :   /**
    1790             :    * Get nodal default value
    1791             :    */
    1792             :   template <typename T>
    1793             :   const T & getDefaultNodalValue(const std::string & var_name, unsigned int comp = 0) const;
    1794             : 
    1795             :   template <typename T>
    1796             :   const Moose::Functor<T> & getDefaultFunctor(const std::string & var_name) const;
    1797             : 
    1798             :   /// Maximum qps for any element in this system
    1799             :   unsigned int _coupleable_max_qps;
    1800             : 
    1801             :   /// Unique indices for optionally coupled vars that weren't provided
    1802             :   std::unordered_map<std::string, std::vector<unsigned int>> _optional_var_index;
    1803             : 
    1804             :   /// Scalar variables coupled into this object (for error checking)
    1805             :   std::unordered_map<std::string, std::vector<MooseVariableScalar *>> _c_coupled_scalar_vars;
    1806             : 
    1807             :   std::set<TagID> _fe_coupleable_vector_tags;
    1808             : 
    1809             :   std::set<TagID> _fe_coupleable_matrix_tags;
    1810             : 
    1811             :   /// Whether the MooseObject is a finite volume object
    1812             :   const bool _is_fv;
    1813             : 
    1814             :   const MooseObject * const _obj;
    1815             : 
    1816             :   /// vector tag names for which we need to request older solution states from the system
    1817             :   const std::set<std::string> _older_state_tags = {Moose::OLD_SOLUTION_TAG,
    1818             :                                                    Moose::OLDER_SOLUTION_TAG};
    1819             : 
    1820             :   /// keep a set of allocated writable variable references to make sure only one object can obtain them per thread
    1821             :   std::vector<std::set<MooseWritableVariable *>> _writable_coupled_variables;
    1822             : 
    1823             :   /**
    1824             :    * kokkos-related variables and methods
    1825             :    */
    1826             : private:
    1827             :   const Real _kokkos_default_value_zero = 0;
    1828             : 
    1829             : #ifdef MOOSE_KOKKOS_SCOPE
    1830             :   Moose::Kokkos::Variable kokkosCoupledVectorTagVariable(const std::string & var_name,
    1831             :                                                          const std::string & tag_name,
    1832             :                                                          unsigned int comp);
    1833             :   Moose::Kokkos::Variable kokkosCoupledVectorTagVariables(const std::string & var_name,
    1834             :                                                           const std::string & tag_name);
    1835             :   Moose::Kokkos::Variable kokkosZeroVariable();
    1836             : 
    1837             : public:
    1838             :   Moose::Kokkos::VariableValue kokkosCoupledVectorTagValueByName(const std::string & var_name,
    1839             :                                                                  const std::string & tag_name,
    1840             :                                                                  unsigned int comp = 0);
    1841             :   Moose::Kokkos::VariableValue kokkosCoupledVectorTagValuesByName(const std::string & var_name,
    1842             :                                                                   const std::string & tag_name);
    1843             :   Moose::Kokkos::VariableGradient kokkosCoupledVectorTagGradientByName(const std::string & var_name,
    1844             :                                                                        const std::string & tag_name,
    1845             :                                                                        unsigned int comp = 0);
    1846             :   Moose::Kokkos::VariableGradient
    1847             :   kokkosCoupledVectorTagGradientsByName(const std::string & var_name, const std::string & tag_name);
    1848             :   Moose::Kokkos::VariableValue kokkosCoupledVectorTagNodalValueByName(const std::string & var_name,
    1849             :                                                                       const std::string & tag_name,
    1850             :                                                                       unsigned int comp = 0);
    1851             :   Moose::Kokkos::VariableValue
    1852             :   kokkosCoupledVectorTagNodalValuesByName(const std::string & var_name,
    1853             :                                           const std::string & tag_name);
    1854             : 
    1855             :   Moose::Kokkos::VariableValue kokkosCoupledVectorTagValue(const std::string & var_name,
    1856             :                                                            const std::string & tag_param_name,
    1857             :                                                            unsigned int comp = 0);
    1858             :   Moose::Kokkos::VariableValue kokkosCoupledVectorTagValues(const std::string & var_name,
    1859             :                                                             const std::string & tag_param_name);
    1860             :   Moose::Kokkos::VariableGradient kokkosCoupledVectorTagGradient(const std::string & var_name,
    1861             :                                                                  const std::string & tag_param_name,
    1862             :                                                                  unsigned int comp = 0);
    1863             :   Moose::Kokkos::VariableGradient
    1864             :   kokkosCoupledVectorTagGradients(const std::string & var_name, const std::string & tag_param_name);
    1865             :   Moose::Kokkos::VariableValue kokkosCoupledVectorTagNodalValue(const std::string & var_name,
    1866             :                                                                 const std::string & tag_param_name,
    1867             :                                                                 unsigned int comp = 0);
    1868             :   Moose::Kokkos::VariableValue
    1869             :   kokkosCoupledVectorTagNodalValues(const std::string & var_name,
    1870             :                                     const std::string & tag_param_name);
    1871             : 
    1872             :   Moose::Kokkos::VariableValue kokkosCoupledValue(const std::string & var_name,
    1873             :                                                   unsigned int comp = 0);
    1874             :   Moose::Kokkos::VariableValue kokkosCoupledValues(const std::string & var_name);
    1875             :   Moose::Kokkos::VariableGradient kokkosCoupledGradient(const std::string & var_name,
    1876             :                                                         unsigned int comp = 0);
    1877             :   Moose::Kokkos::VariableGradient kokkosCoupledGradients(const std::string & var_name);
    1878             :   Moose::Kokkos::VariableValue kokkosCoupledNodalValue(const std::string & var_name,
    1879             :                                                        unsigned int comp = 0);
    1880             :   Moose::Kokkos::VariableValue kokkosCoupledNodalValues(const std::string & var_name);
    1881             : 
    1882             :   Moose::Kokkos::VariableValue kokkosCoupledValueOld(const std::string & var_name,
    1883             :                                                      unsigned int comp = 0);
    1884             :   Moose::Kokkos::VariableValue kokkosCoupledValuesOld(const std::string & var_name);
    1885             :   Moose::Kokkos::VariableGradient kokkosCoupledGradientOld(const std::string & var_name,
    1886             :                                                            unsigned int comp = 0);
    1887             :   Moose::Kokkos::VariableGradient kokkosCoupledGradientsOld(const std::string & var_name);
    1888             :   Moose::Kokkos::VariableValue kokkosCoupledNodalValueOld(const std::string & var_name,
    1889             :                                                           unsigned int comp = 0);
    1890             :   Moose::Kokkos::VariableValue kokkosCoupledNodalValuesOld(const std::string & var_name);
    1891             : 
    1892             :   Moose::Kokkos::VariableValue kokkosCoupledValueOlder(const std::string & var_name,
    1893             :                                                        unsigned int comp = 0);
    1894             :   Moose::Kokkos::VariableValue kokkosCoupledValuesOlder(const std::string & var_name);
    1895             :   Moose::Kokkos::VariableGradient kokkosCoupledGradientOlder(const std::string & var_name,
    1896             :                                                              unsigned int comp = 0);
    1897             :   Moose::Kokkos::VariableGradient kokkosCoupledGradientsOlder(const std::string & var_name);
    1898             :   Moose::Kokkos::VariableValue kokkosCoupledNodalValueOlder(const std::string & var_name,
    1899             :                                                             unsigned int comp = 0);
    1900             :   Moose::Kokkos::VariableValue kokkosCoupledNodalValuesOlder(const std::string & var_name);
    1901             : 
    1902             :   Moose::Kokkos::VariableValue kokkosCoupledDot(const std::string & var_name,
    1903             :                                                 unsigned int comp = 0);
    1904             :   Moose::Kokkos::VariableValue kokkosCoupledDots(const std::string & var_name);
    1905             :   Moose::Kokkos::VariableValue kokkosCoupledNodalDot(const std::string & var_name,
    1906             :                                                      unsigned int comp = 0);
    1907             :   Moose::Kokkos::VariableValue kokkosCoupledNodalDots(const std::string & var_name);
    1908             : 
    1909             :   Moose::Kokkos::Scalar<const Real> kokkosCoupledDotDu(const std::string & var_name,
    1910             :                                                        unsigned int comp = 0);
    1911             : 
    1912             :   Moose::Kokkos::VariableValue kokkosZeroValue();
    1913             :   Moose::Kokkos::VariableGradient kokkosZeroGradient();
    1914             :   Moose::Kokkos::VariableValue kokkosZeroNodalValue();
    1915             : #endif
    1916             : };
    1917             : 
    1918             : template <typename T>
    1919             : T *
    1920      165333 : Coupleable::getVarHelper(const std::string & var_name_in, unsigned int comp)
    1921             : {
    1922      165333 :   const auto var_name = _c_parameters.checkForRename(var_name_in);
    1923      165333 :   auto name_to_use = var_name;
    1924             : 
    1925             :   // First check for supplied name
    1926      165333 :   if (!checkVar(var_name, comp, 0))
    1927             :   {
    1928             :     // See if there is an associated deprecated name that the user may have used instead
    1929        2302 :     auto it = _new_to_deprecated_coupled_vars.find(var_name);
    1930        2302 :     if (it == _new_to_deprecated_coupled_vars.end())
    1931        2302 :       return nullptr;
    1932             :     else
    1933             :     {
    1934           0 :       auto deprecated_name = it->second;
    1935           0 :       if (checkVar(deprecated_name, comp, 0))
    1936           0 :         name_to_use = deprecated_name;
    1937             :       else
    1938           0 :         return nullptr;
    1939           0 :     }
    1940             :   }
    1941             : 
    1942      163015 :   auto coupled_vars_it = _coupled_vars.find(name_to_use);
    1943             : 
    1944             :   mooseAssert(coupled_vars_it != _coupled_vars.end(),
    1945             :               "Trying to get a coupled var " << name_to_use << " that doesn't exist");
    1946             : 
    1947      163015 :   if (auto coupled_var = dynamic_cast<T *>(coupled_vars_it->second[comp]))
    1948      163015 :     return coupled_var;
    1949             :   else
    1950             :   {
    1951           0 :     for (auto & var : _coupled_standard_moose_vars)
    1952           0 :       if (var->name() == name_to_use)
    1953           0 :         mooseError("The named variable is a standard variable, try a "
    1954             :                    "'coupled[Value/Gradient/Dot/etc]...' function instead");
    1955           0 :     for (auto & var : _coupled_vector_moose_vars)
    1956           0 :       if (var->name() == name_to_use)
    1957           0 :         mooseError("The named variable is a vector variable, try a "
    1958             :                    "'coupledVector[Value/Gradient/Dot/etc]...' function instead");
    1959           0 :     for (auto & var : _coupled_array_moose_vars)
    1960           0 :       if (var->name() == name_to_use)
    1961           0 :         mooseError("The named variable is an array variable, try a "
    1962             :                    "'coupledArray[Value/Gradient/Dot/etc]...' function instead");
    1963           0 :     for (auto & var : _coupled_fv_moose_vars)
    1964           0 :       if (var->name() == name_to_use)
    1965           0 :         mooseError("The named variable is a finite volume variable, which the coupled[...] routine "
    1966             :                    "used does not support. Try using the functor system routines instead.");
    1967           0 :     mooseError(
    1968             :         "Variable '", name_to_use, "' is of a different C++ type than you tried to fetch it as.");
    1969             :   }
    1970      165317 : }
    1971             : 
    1972             : template <typename T>
    1973             : const T *
    1974      151663 : Coupleable::getVarHelper(const std::string & var_name, unsigned int comp) const
    1975             : {
    1976      151663 :   return const_cast<Coupleable *>(this)->getVarHelper<T>(var_name, comp);
    1977             : }

Generated by: LCOV version 1.14