www.mooseframework.org
Coupleable.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include <map>
13 #include "MooseTypes.h"
14 #include "MooseArray.h"
15 #include "MooseVariableFE.h"
16 #include "InputParameters.h"
17 
18 #define usingCoupleableMembers \
19  using Coupleable::_zero; \
20  using Coupleable::_grad_zero; \
21  using Coupleable::_coupled_standard_moose_vars; \
22  using Coupleable::isCoupled; \
23  using Coupleable::coupledComponents; \
24  using Coupleable::coupled; \
25  using Coupleable::coupledValue; \
26  using Coupleable::coupledValueOld; \
27  using Coupleable::coupledValueOlder; \
28  using Coupleable::coupledGradient; \
29  using Coupleable::coupledGradientOld; \
30  using Coupleable::coupledGradientOlder; \
31  using Coupleable::getVar
32 
33 // Forward declarations
35 class MooseObject;
36 
37 namespace libMesh
38 {
39 template <typename T>
40 class DenseVector;
41 }
42 
43 #define adCoupledValue this->template adCoupledValueTemplate<compute_stage>
44 #define adCoupledGradient this->template adCoupledGradientTemplate<compute_stage>
45 #define adCoupledSecond this->template adCoupledSecondTemplate<compute_stage>
46 #define adCoupledDot this->template adCoupledDotTemplate<compute_stage>
47 #define adCoupledVectorDot this->template adCoupledVectorDotTemplate<compute_stage>
48 #define adCoupledVectorValue this->template adCoupledVectorValueTemplate<compute_stage>
49 #define adCoupledVectorGradient this->template adCoupledVectorGradientTemplate<compute_stage>
50 #define adCoupledVectorSecond this->template adCoupledVectorSecondTemplate<compute_stage>
51 #define adZeroValue this->template adZeroValueTemplate<compute_stage>
52 #define adZeroGradient this->template adZeroGradientTemplate<compute_stage>
53 #define adZeroSecond this->template adZeroSecondTemplate<compute_stage>
54 #define adCoupledNodalValue this->template adCoupledNodalValueTemplate<Real, compute_stage>
55 #define adCoupledNodalVectorValue \
56  this->template adCoupledNodalValueTemplate<RealVectorValue, compute_stage>
57 
63 {
64 public:
70  Coupleable(const MooseObject * moose_object, bool nodal);
71 
75  virtual ~Coupleable();
76 
81  const std::map<std::string, std::vector<MooseVariableFEBase *>> & getCoupledVars()
82  {
83  return _coupled_vars;
84  }
85 
90  const std::vector<MooseVariableFEBase *> & getCoupledMooseVars() const
91  {
92  return _coupled_moose_vars;
93  }
94 
99  const std::vector<MooseVariable *> & getCoupledStandardMooseVars() const
100  {
102  }
103 
108  const std::vector<VectorMooseVariable *> & getCoupledVectorMooseVars() const
109  {
111  }
112 
114 
116 
118 
120 
121 protected:
128  virtual bool isCoupled(const std::string & var_name, unsigned int i = 0);
129 
135  unsigned int coupledComponents(const std::string & var_name);
136 
137  virtual void coupledCallback(const std::string & var_name, bool is_old);
138 
146  virtual unsigned int coupled(const std::string & var_name, unsigned int comp = 0);
147 
155  virtual const VariableValue & coupledValue(const std::string & var_name, unsigned int comp = 0);
156 
164  template <ComputeStage compute_stage>
165  const ADVariableValue & adCoupledValueTemplate(const std::string & var_name,
166  unsigned int comp = 0);
167 
175  template <ComputeStage compute_stage>
176  const ADVectorVariableValue & adCoupledVectorValueTemplate(const std::string & var_name,
177  unsigned int comp = 0);
178 
187  virtual const VariableValue &
188  coupledVectorTagValue(const std::string & var_name, TagID tag, unsigned int comp = 0);
189 
198  virtual const VariableValue &
199  coupledMatrixTagValue(const std::string & var_name, TagID tag, unsigned int comp = 0);
200 
208  virtual const VectorVariableValue & coupledVectorValue(const std::string & var_name,
209  unsigned int comp = 0);
210 
221  virtual VariableValue & writableCoupledValue(const std::string & var_name, unsigned int comp = 0);
222 
230  virtual const VariableValue & coupledValueOld(const std::string & var_name,
231  unsigned int comp = 0);
232 
240  virtual const VariableValue & coupledValueOlder(const std::string & var_name,
241  unsigned int comp = 0);
242 
249  virtual const VariableValue & coupledValuePreviousNL(const std::string & var_name,
250  unsigned int comp = 0);
251 
259  virtual const VectorVariableValue & coupledVectorValueOld(const std::string & var_name,
260  unsigned int comp = 0);
261 
269  virtual const VectorVariableValue & coupledVectorValueOlder(const std::string & var_name,
270  unsigned int comp = 0);
271 
279  virtual const VariableGradient & coupledGradient(const std::string & var_name,
280  unsigned int comp = 0);
281 
289  template <ComputeStage compute_stage>
290  const ADVariableGradient & adCoupledGradientTemplate(const std::string & var_name,
291  unsigned int comp = 0);
292 
300  template <ComputeStage compute_stage>
301  const ADVectorVariableGradient & adCoupledVectorGradientTemplate(const std::string & var_name,
302  unsigned int comp = 0);
303 
310  template <ComputeStage compute_stage>
311  const ADVariableSecond & adCoupledSecondTemplate(const std::string & var_name,
312  unsigned int comp = 0);
313 
321  template <ComputeStage compute_stage>
322  const ADVectorVariableSecond & adCoupledVectorSecondTemplate(const std::string & var_name,
323  unsigned int comp = 0);
324 
332  virtual const VariableGradient & coupledGradientOld(const std::string & var_name,
333  unsigned int comp = 0);
334 
342  virtual const VariableGradient & coupledGradientOlder(const std::string & var_name,
343  unsigned int comp = 0);
344 
351  virtual const VariableGradient & coupledGradientPreviousNL(const std::string & var_name,
352  unsigned int comp = 0);
353 
361  virtual const VariableGradient & coupledGradientDot(const std::string & var_name,
362  unsigned int comp = 0);
363 
371  virtual const VariableGradient & coupledGradientDotDot(const std::string & var_name,
372  unsigned int comp = 0);
373 
381  virtual const VectorVariableGradient & coupledVectorGradient(const std::string & var_name,
382  unsigned int comp = 0);
383 
391  virtual const VectorVariableGradient & coupledVectorGradientOld(const std::string & var_name,
392  unsigned int comp = 0);
393 
401  virtual const VectorVariableGradient & coupledVectorGradientOlder(const std::string & var_name,
402  unsigned int comp = 0);
403 
411  virtual const VectorVariableCurl & coupledCurl(const std::string & var_name,
412  unsigned int comp = 0);
413 
421  virtual const VectorVariableCurl & coupledCurlOld(const std::string & var_name,
422  unsigned int comp = 0);
423 
431  virtual const VectorVariableCurl & coupledCurlOlder(const std::string & var_name,
432  unsigned int comp = 0);
433 
441  virtual const VariableSecond & coupledSecond(const std::string & var_name, unsigned int comp = 0);
442 
451  virtual const VariableSecond & coupledSecondOld(const std::string & var_name,
452  unsigned int comp = 0);
453 
462  virtual const VariableSecond & coupledSecondOlder(const std::string & var_name,
463  unsigned int comp = 0);
464 
471  virtual const VariableSecond & coupledSecondPreviousNL(const std::string & var_name,
472  unsigned int comp = 0);
473 
480  virtual const VariableValue & coupledDot(const std::string & var_name, unsigned int comp = 0);
481 
488  virtual const VariableValue & coupledDotDot(const std::string & var_name, unsigned int comp = 0);
489 
496  virtual const VariableValue & coupledDotOld(const std::string & var_name, unsigned int comp = 0);
497 
504  virtual const VariableValue & coupledDotDotOld(const std::string & var_name,
505  unsigned int comp = 0);
506 
514  template <ComputeStage compute_stage>
515  const ADVariableValue & adCoupledDotTemplate(const std::string & var_name, unsigned int comp = 0);
516 
525  template <ComputeStage compute_stage>
526  const ADVectorVariableValue & adCoupledVectorDotTemplate(const std::string & var_name,
527  unsigned int comp = 0);
528 
536  virtual const VectorVariableValue & coupledVectorDot(const std::string & var_name,
537  unsigned int comp = 0);
538 
546  virtual const VectorVariableValue & coupledVectorDotDot(const std::string & var_name,
547  unsigned int comp = 0);
548 
556  virtual const VectorVariableValue & coupledVectorDotOld(const std::string & var_name,
557  unsigned int comp = 0);
558 
566  virtual const VectorVariableValue & coupledVectorDotDotOld(const std::string & var_name,
567  unsigned int comp = 0);
568 
576  virtual const VariableValue & coupledDotDu(const std::string & var_name, unsigned int comp = 0);
577 
585  virtual const VariableValue & coupledDotDotDu(const std::string & var_name,
586  unsigned int comp = 0);
587 
594  template <typename T>
595  const T & coupledNodalValue(const std::string & var_name, unsigned int comp = 0);
596 
603  template <typename T, ComputeStage compute_stage>
605  adCoupledNodalValueTemplate(const std::string & var_name, unsigned int comp = 0);
606 
613  template <typename T>
614  const T & coupledNodalValueOld(const std::string & var_name, unsigned int comp = 0);
615 
622  template <typename T>
623  const T & coupledNodalValueOlder(const std::string & var_name, unsigned int comp = 0);
624 
631  template <typename T>
632  const T & coupledNodalValuePreviousNL(const std::string & var_name, unsigned int comp = 0);
633 
641  template <typename T>
642  const T & coupledNodalDot(const std::string & var_name, unsigned int comp = 0);
643 
647  template <typename T>
648  const T & getNodalDefaultValue(const std::string & var_name, unsigned int comp = 0);
649 
657  virtual const VariableValue & coupledNodalDotDot(const std::string & var_name,
658  unsigned int comp = 0);
659 
667  virtual const VariableValue & coupledNodalDotOld(const std::string & var_name,
668  unsigned int comp = 0);
669 
677  virtual const VariableValue & coupledNodalDotDotOld(const std::string & var_name,
678  unsigned int comp = 0);
685  virtual const VariableValue & coupledDofValues(const std::string & var_name,
686  unsigned int comp = 0);
687 
694  virtual const VariableValue & coupledDofValuesOld(const std::string & var_name,
695  unsigned int comp = 0);
696 
703  virtual const VariableValue & coupledDofValuesOlder(const std::string & var_name,
704  unsigned int comp = 0);
705 
710  template <ComputeStage compute_stage>
711  const ADVariableValue & adZeroValueTemplate();
712 
717  template <ComputeStage compute_stage>
718  const ADVariableGradient & adZeroGradientTemplate();
719 
723  template <ComputeStage compute_stage>
724  const ADVariableSecond & adZeroSecondTemplate();
725 
726 protected:
727  // Reference to the interface's input parameters
729 
731  const std::string & _c_name;
732 
733  // Reference to FEProblemBase
735 
737  std::map<std::string, std::vector<MooseVariableFEBase *>> _coupled_vars;
738 
740  std::vector<MooseVariableFEBase *> _coupled_moose_vars;
741 
743  std::vector<MooseVariable *> _coupled_standard_moose_vars;
744 
746  std::vector<VectorMooseVariable *> _coupled_vector_moose_vars;
747 
749  bool _c_nodal;
750 
753 
756 
758  std::map<std::string, std::vector<VariableValue *>> _default_value;
759 
761  std::map<std::string, MooseArray<DualReal> *> _ad_default_value;
762 
764  std::map<std::string, VectorVariableValue *> _default_vector_value;
765 
767  std::map<std::string, MooseArray<DualRealVectorValue> *> _ad_default_vector_value;
768 
774 
777 
780 
783 
786 
789 
793 
797 
807 
813 
816 
819 
825  void checkVar(const std::string & var_name);
826 
833  MooseVariableFEBase * getFEVar(const std::string & var_name, unsigned int comp);
834 
838  template <typename T>
839  MooseVariableFE<T> * getVarHelper(const std::string & var_name, unsigned int comp);
840 
847  MooseVariable * getVar(const std::string & var_name, unsigned int comp);
848 
855  VectorMooseVariable * getVectorVar(const std::string & var_name, unsigned int comp);
856 
863  void validateExecutionerType(const std::string & name, const std::string & fn_name) const;
864 
867 
868 private:
875  VariableValue * getDefaultValue(const std::string & var_name, unsigned int comp);
876 
877 public:
884  template <ComputeStage compute_stage>
885  ADVariableValue * getADDefaultValue(const std::string & var_name);
886 
893  template <ComputeStage compute_stage>
894  ADVectorVariableValue * getADDefaultVectorValue(const std::string & var_name);
895 
902  template <ComputeStage compute_stage>
903  ADVariableGradient & getADDefaultGradient();
904 
911  template <ComputeStage compute_stage>
912  ADVectorVariableGradient & getADDefaultVectorGradient();
913 
920  template <ComputeStage compute_stage>
921  ADVariableSecond & getADDefaultSecond();
922 
923 private:
930  VectorVariableValue * getDefaultVectorValue(const std::string & var_name);
931 
933  unsigned int _coupleable_max_qps;
934 
936  std::map<std::string, std::vector<unsigned int>> _optional_var_index;
937 
939  std::map<std::string, std::vector<MooseVariableScalar *>> _c_coupled_scalar_vars;
940 
941  std::set<TagID> _fe_coupleable_vector_tags;
942 
943  std::set<TagID> _fe_coupleable_matrix_tags;
944 };
945 
946 template <ComputeStage compute_stage>
947 const ADVariableValue &
948 Coupleable::adCoupledValueTemplate(const std::string & var_name, unsigned int comp)
949 {
950  if (!isCoupled(var_name))
951  return *getADDefaultValue<compute_stage>(var_name);
952 
953  coupledCallback(var_name, false);
954  MooseVariable * var = getVar(var_name, comp);
955 
957  {
958  if (_c_nodal)
959  mooseError("Not implemented");
960  else
961  {
962  if (_c_is_implicit)
963  return var->adSln<compute_stage>();
964  else
965  mooseError("Not implemented");
966  }
967  }
968  else
969  {
970  if (_c_nodal)
971  mooseError("Not implemented");
972  else
973  {
974  if (_c_is_implicit)
975  return var->adSlnNeighbor<compute_stage>();
976  else
977  mooseError("Not implemented");
978  }
979  }
980 }
981 
982 template <ComputeStage compute_stage>
983 const ADVariableGradient &
984 Coupleable::adCoupledGradientTemplate(const std::string & var_name, unsigned int comp)
985 {
986  if (!isCoupled(var_name)) // Return default 0
987  return getADDefaultGradient<compute_stage>();
988 
989  coupledCallback(var_name, false);
990  if (_c_nodal)
991  mooseError("Nodal variables do not have gradients");
992 
993  MooseVariable * var = getVar(var_name, comp);
994 
996  {
997  if (_c_is_implicit)
998  return var->adGradSln<compute_stage>();
999  else
1000  mooseError("Not implemented");
1001  }
1002  else
1003  {
1004  if (_c_is_implicit)
1005  return var->adGradSlnNeighbor<compute_stage>();
1006  else
1007  mooseError("Not implemented");
1008  }
1009 }
1010 
1011 template <ComputeStage compute_stage>
1012 const ADVariableSecond &
1013 Coupleable::adCoupledSecondTemplate(const std::string & var_name, unsigned int comp)
1014 {
1015  if (!isCoupled(var_name)) // Return default 0
1016  return getADDefaultSecond<compute_stage>();
1017 
1018  coupledCallback(var_name, false);
1019  if (_c_nodal)
1020  mooseError("Nodal variables do not have second derivatives");
1021 
1022  MooseVariable * var = getVar(var_name, comp);
1023 
1024  if (!_coupleable_neighbor)
1025  {
1026  if (_c_is_implicit)
1027  return var->adSecondSln<compute_stage>();
1028  else
1029  mooseError("Not implemented");
1030  }
1031  else
1032  {
1033  if (_c_is_implicit)
1034  return var->adSecondSlnNeighbor<compute_stage>();
1035  else
1036  mooseError("Not implemented");
1037  }
1038 }
1039 
1040 template <ComputeStage compute_stage>
1041 const ADVectorVariableSecond &
1042 adCoupledVectorSecondTemplate(const std::string & /*var_name*/, unsigned int /*comp = 0*/)
1043 {
1044  mooseError(
1045  "Automatic differentiation using second derivatives of vector variables is not implemented.");
1046 }
1047 
1048 template <ComputeStage compute_stage>
1049 const ADVariableValue &
1050 Coupleable::adCoupledDotTemplate(const std::string & var_name, unsigned int comp)
1051 {
1052  checkVar(var_name);
1053  if (!isCoupled(var_name)) // Return default 0
1054  return *getADDefaultValue<compute_stage>(var_name);
1055 
1056  MooseVariable * var = getVar(var_name, comp);
1057  if (var == nullptr)
1058  mooseError("Call corresponding vector variable method");
1059 
1060  if (!_coupleable_neighbor)
1061  {
1062  if (_c_nodal)
1063  mooseError("Not implemented");
1064  else
1065  return var->adUDot<compute_stage>();
1066  }
1067  else
1068  {
1069  if (_c_nodal)
1070  mooseError("Not implemented");
1071  else
1072  return var->adUDotNeighbor<compute_stage>();
1073  }
1074 }
1075 
1076 template <ComputeStage compute_stage>
1077 const ADVectorVariableValue &
1078 Coupleable::adCoupledVectorDotTemplate(const std::string & var_name, unsigned int comp)
1079 {
1080  checkVar(var_name);
1081  if (!isCoupled(var_name)) // Return default 0
1082  return *getADDefaultVectorValue<compute_stage>(var_name);
1083 
1084  VectorMooseVariable * var = getVectorVar(var_name, comp);
1085  if (var == nullptr)
1086  mooseError("Try calling corresponding standard variable method");
1087 
1088  if (!_coupleable_neighbor)
1089  {
1090  if (_c_nodal)
1091  mooseError("Not implemented");
1092  else
1093  return var->adUDot<compute_stage>();
1094  }
1095  else
1096  {
1097  if (_c_nodal)
1098  mooseError("Not implemented");
1099  else
1100  return var->adUDotNeighbor<compute_stage>();
1101  }
1102 }
1103 
1104 template <ComputeStage compute_stage>
1105 const ADVectorVariableValue &
1106 Coupleable::adCoupledVectorValueTemplate(const std::string & var_name, unsigned int comp)
1107 {
1108  if (!isCoupled(var_name))
1109  return *getADDefaultVectorValue<compute_stage>(var_name);
1110 
1111  coupledCallback(var_name, false);
1112  VectorMooseVariable * var = getVectorVar(var_name, comp);
1113 
1114  if (!_coupleable_neighbor)
1115  {
1116  if (_c_nodal)
1117  mooseError("Not implemented");
1118  else
1119  {
1120  if (_c_is_implicit)
1121  return var->adSln<compute_stage>();
1122  else
1123  mooseError("Not implemented");
1124  }
1125  }
1126  else
1127  {
1128  if (_c_nodal)
1129  mooseError("Not implemented");
1130  else
1131  {
1132  if (_c_is_implicit)
1133  return var->adSlnNeighbor<compute_stage>();
1134  else
1135  mooseError("Not implemented");
1136  }
1137  }
1138 }
1139 
1140 template <ComputeStage compute_stage>
1141 const ADVectorVariableGradient &
1142 Coupleable::adCoupledVectorGradientTemplate(const std::string & var_name, unsigned int comp)
1143 {
1144 
1145  if (!isCoupled(var_name)) // Return default 0
1146  return getADDefaultVectorGradient<compute_stage>();
1147 
1148  coupledCallback(var_name, false);
1149  if (_c_nodal)
1150  mooseError("Nodal variables do not have gradients");
1151 
1152  VectorMooseVariable * var = getVectorVar(var_name, comp);
1153 
1154  if (!_coupleable_neighbor)
1155  {
1156  if (_c_is_implicit)
1157  return var->adGradSln<compute_stage>();
1158  else
1159  mooseError("Not implemented");
1160  }
1161  else
1162  {
1163  if (_c_is_implicit)
1164  return var->adGradSlnNeighbor<compute_stage>();
1165  else
1166  mooseError("Not implemented");
1167  }
1168 }
1169 
1170 template <ComputeStage compute_stage>
1171 ADVariableValue *
1172 Coupleable::getADDefaultValue(const std::string & var_name)
1173 {
1174  std::map<std::string, MooseArray<DualReal> *>::iterator default_value_it =
1175  _ad_default_value.find(var_name);
1176  if (default_value_it == _ad_default_value.end())
1177  {
1178  ADVariableValue * value =
1179  new ADVariableValue(_coupleable_max_qps, _c_parameters.defaultCoupledValue(var_name));
1180  default_value_it = _ad_default_value.insert(std::make_pair(var_name, value)).first;
1181  }
1182 
1183  return default_value_it->second;
1184 }
1185 
1186 template <>
1187 VariableValue * Coupleable::getADDefaultValue<RESIDUAL>(const std::string & var_name);
1188 
1189 template <ComputeStage compute_stage>
1190 ADVectorVariableValue *
1191 Coupleable::getADDefaultVectorValue(const std::string & var_name)
1192 {
1193  std::map<std::string, MooseArray<DualRealVectorValue> *>::iterator default_value_it =
1194  _ad_default_vector_value.find(var_name);
1195  if (default_value_it == _ad_default_vector_value.end())
1196  {
1197  RealVectorValue default_vec;
1198  for (unsigned int i = 0; i < _c_parameters.numberDefaultCoupledValues(var_name); ++i)
1199  default_vec(i) = _c_parameters.defaultCoupledValue(var_name, i);
1200  ADVectorVariableValue * value = new ADVectorVariableValue(_coupleable_max_qps, default_vec);
1201  default_value_it = _ad_default_vector_value.insert(std::make_pair(var_name, value)).first;
1202  }
1203 
1204  return default_value_it->second;
1205 }
1206 
1207 template <>
1208 VectorVariableValue * Coupleable::getADDefaultVectorValue<RESIDUAL>(const std::string & var_name);
1209 
1210 template <ComputeStage compute_stage>
1211 ADVariableGradient &
1213 {
1214  return _ad_default_gradient;
1215 }
1216 
1217 template <>
1218 VariableGradient & Coupleable::getADDefaultGradient<RESIDUAL>();
1219 
1220 template <ComputeStage compute_stage>
1221 ADVectorVariableGradient &
1223 {
1225 }
1226 
1227 template <>
1228 VectorVariableGradient & Coupleable::getADDefaultVectorGradient<RESIDUAL>();
1229 
1230 template <ComputeStage compute_stage>
1231 ADVariableSecond &
1233 {
1234  return _ad_default_second;
1235 }
1236 
1237 template <>
1238 VariableSecond & Coupleable::getADDefaultSecond<RESIDUAL>();
1239 
1240 template <ComputeStage compute_stage>
1241 const ADVariableValue &
1243 {
1244  return _ad_zero;
1245 }
1246 
1247 template <ComputeStage compute_stage>
1248 const ADVariableGradient &
1250 {
1251  return _ad_grad_zero;
1252 }
1253 
1254 template <ComputeStage compute_stage>
1255 const ADVariableSecond &
1257 {
1258  return _ad_second_zero;
1259 }
1260 
1261 template <>
1262 const VariableValue & Coupleable::adZeroValueTemplate<RESIDUAL>();
1263 template <>
1264 const VariableGradient & Coupleable::adZeroGradientTemplate<RESIDUAL>();
1265 template <>
1266 const VariableSecond & Coupleable::adZeroSecondTemplate<RESIDUAL>();
1267 
OutputTools< Real >::VariableGradient VariableGradient
Definition: MooseTypes.h:198
ADVectorVariableGradient & getADDefaultVectorGradient()
Helper method to return (and insert if necessary) the default gradient for Automatic Differentiation ...
Definition: Coupleable.h:1222
void validateExecutionerType(const std::string &name, const std::string &fn_name) const
Checks to make sure that the current Executioner has set "_is_transient" when old/older values are co...
Definition: Coupleable.C:1467
const ADVariableValue & adCoupledValueTemplate(const std::string &var_name, unsigned int comp=0)
Returns value of a coupled variable for use in Automatic Differentiation.
Definition: Coupleable.h:948
virtual const VariableValue & coupledDotDotDu(const std::string &var_name, unsigned int comp=0)
Second time derivative of a coupled variable with respect to the coefficients.
Definition: Coupleable.C:866
bool _c_nodal
True if we provide coupling to nodal values.
Definition: Coupleable.h:749
const std::vector< VectorMooseVariable * > & getCoupledVectorMooseVars() const
Get the list of vector coupled variables.
Definition: Coupleable.h:108
VectorVariableCurl _default_vector_curl
This will always be zero because the default values for optionally coupled variables is always consta...
Definition: Coupleable.h:818
const ADVariableValue & adZeroValueTemplate()
Template method that returns _zero to RESIDUAL computing objects and _ad_zero to JACOBIAN computing o...
Definition: Coupleable.h:1242
VectorMooseVariable * getVectorVar(const std::string &var_name, unsigned int comp)
Extract pointer to a coupled vector variable.
Definition: Coupleable.C:247
const VariableValue & _zero
Zero value of a variable.
Definition: Coupleable.h:791
const VariablePhiSecond & _second_phi_zero
Zero second derivative of a test function.
Definition: Coupleable.h:802
const T & coupledNodalValueOld(const std::string &var_name, unsigned int comp=0)
Returns an old nodal value from previous time step of a coupled variable.
Definition: Coupleable.C:1259
MooseVariableFE< T > * getVarHelper(const std::string &var_name, unsigned int comp)
Helper that segues off to either getVar of getVectorVar depending on template paramter.
Definition: Coupleable.C:214
virtual const VariableValue & coupledMatrixTagValue(const std::string &var_name, TagID tag, unsigned int comp=0)
Returns value of a coupled variable for a given tag.
Definition: Coupleable.C:406
unsigned int coupledComponents(const std::string &var_name)
Number of coupled components.
Definition: Coupleable.C:166
virtual const VariableValue & coupledDotOld(const std::string &var_name, unsigned int comp=0)
Old time derivative of a coupled variable.
Definition: Coupleable.C:676
MooseArray< DualRealTensorValue > _ad_default_second
This will always be zero because the default values for optionally coupled variables is always consta...
Definition: Coupleable.h:788
virtual const VariableValue & coupledVectorTagValue(const std::string &var_name, TagID tag, unsigned int comp=0)
Returns value of a coupled variable for a given tag.
Definition: Coupleable.C:388
unsigned int TagID
Definition: MooseTypes.h:162
const ADVariableSecond & adCoupledSecondTemplate(const std::string &var_name, unsigned int comp=0)
Returns second derivatives of a coupled variable for use in Automatic Differentation.
Definition: Coupleable.h:1013
const VectorVariableValue & _vector_zero
Zero value of a vector variable.
Definition: Coupleable.h:804
const VariableGradient & _grad_zero
Zero gradient of a variable.
Definition: Coupleable.h:795
std::set< TagID > _fe_coupleable_matrix_tags
Definition: Coupleable.h:943
VectorValue< Real > RealVectorValue
Definition: Assembly.h:31
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
MooseArray< DualRealTensorValue > _ad_default_vector_gradient
This will always be zero because the default values for optionally coupled vector variables is always...
Definition: Coupleable.h:782
const VariableSecond & _second_zero
Zero second derivative of a variable.
Definition: Coupleable.h:799
virtual const VariableValue & coupledNodalDotDotOld(const std::string &var_name, unsigned int comp=0)
Nodal values of old second time derivative of a coupled variable.
Definition: Coupleable.C:1391
virtual const VectorVariableValue & coupledVectorDot(const std::string &var_name, unsigned int comp=0)
Time derivative of a coupled vector variable.
Definition: Coupleable.C:728
virtual const VariableValue & coupledDotDotOld(const std::string &var_name, unsigned int comp=0)
Old second time derivative of a coupled variable.
Definition: Coupleable.C:702
const ADVectorVariableSecond & adCoupledVectorSecondTemplate(const std::string &var_name, unsigned int comp=0)
Returns second derivatives of a coupled vector variable for use in Automatic Differentation.
OutputTools< RealVectorValue >::VariableValue VectorVariableValue
Definition: MooseTypes.h:211
std::set< TagID > _fe_coupleable_vector_tags
Definition: Coupleable.h:941
THREAD_ID _c_tid
Thread ID of the thread using this object.
Definition: Coupleable.h:755
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const T & coupledNodalValueOlder(const std::string &var_name, unsigned int comp=0)
Returns an old nodal value from two time steps previous of a coupled variable.
Definition: Coupleable.C:1284
const ADVariableSecond & adZeroSecondTemplate()
Retrieve a zero second for automatic differentiation.
Definition: Coupleable.h:1256
VariableValue _default_value_zero
This will always be zero because the default values for optionally coupled variables is always consta...
Definition: Coupleable.h:773
virtual const VariableValue & coupledDofValuesOld(const std::string &var_name, unsigned int comp=0)
Returns DoFs in the old solution vector of a coupled variable for the local element.
Definition: Coupleable.C:1427
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
Extract pointer to a coupled variable.
Definition: Coupleable.C:241
OutputTools< RealVectorValue >::VariableCurl VectorVariableCurl
Definition: MooseTypes.h:214
virtual const VariableValue & coupledValuePreviousNL(const std::string &var_name, unsigned int comp=0)
Returns value of previous Newton iterate of a coupled variable.
Definition: Coupleable.C:531
virtual const VariableValue & coupledNodalDotOld(const std::string &var_name, unsigned int comp=0)
Nodal values of old time derivative of a coupled variable.
Definition: Coupleable.C:1372
virtual const VariableGradient & coupledGradientDotDot(const std::string &var_name, unsigned int comp=0)
Second time derivative of the gradient of a coupled variable.
Definition: Coupleable.C:995
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
VectorVariableValue * getDefaultVectorValue(const std::string &var_name)
Helper method to return (and insert if necessary) the default value for an uncoupled vector variable...
Definition: Coupleable.C:310
std::map< std::string, MooseArray< DualRealVectorValue > * > _ad_default_vector_value
Will hold the default value for optional vector coupled variables for automatic differentiation.
Definition: Coupleable.h:767
virtual VariableValue & writableCoupledValue(const std::string &var_name, unsigned int comp=0)
Returns a writable reference to a coupled variable.
Definition: Coupleable.C:451
virtual const VariableSecond & coupledSecondOlder(const std::string &var_name, unsigned int comp=0)
Returns an old second derivative from two time steps previous of a coupled variable.
Definition: Coupleable.C:1187
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
VariableValue * getDefaultValue(const std::string &var_name, unsigned int comp)
Helper method to return (and insert if necessary) the default value for an uncoupled variable...
Definition: Coupleable.C:283
OutputTools< Real >::VariablePhiSecond VariablePhiSecond
Definition: MooseTypes.h:203
virtual const VectorVariableCurl & coupledCurlOlder(const std::string &var_name, unsigned int comp=0)
Returns an old curl from two time steps previous of a coupled variable.
Definition: Coupleable.C:1119
std::vector< MooseVariable * > _coupled_standard_moose_vars
Vector of standard coupled variables.
Definition: Coupleable.h:743
unsigned int numberDefaultCoupledValues(const std::string &coupling_name) const
Get the number of defaulted coupled value entries.
const std::vector< MooseVariable * > & getCoupledStandardMooseVars() const
Get the list of standard coupled variables.
Definition: Coupleable.h:99
Coupleable(const MooseObject *moose_object, bool nodal)
Constructing the object.
Definition: Coupleable.C:19
const ADVectorVariableSecond & adCoupledVectorSecondTemplate(const std::string &, unsigned int)
Definition: Coupleable.h:1042
FEProblemBase & _c_fe_problem
Definition: Coupleable.h:734
const MooseArray< DualReal > & _ad_zero
Definition: Coupleable.h:792
bool _c_is_implicit
True if implicit value is required.
Definition: Coupleable.h:752
const T & coupledNodalDot(const std::string &var_name, unsigned int comp=0)
Nodal values of time derivative of a coupled variable.
Definition: Coupleable.C:1333
virtual bool isCoupled(const std::string &var_name, unsigned int i=0)
Returns true if a variables has been coupled as name.
Definition: Coupleable.C:144
ADVariableValue * getADDefaultValue(const std::string &var_name)
Helper method to return (and insert if necessary) the default value for Automatic Differentiation for...
Definition: Coupleable.h:1172
const MooseArray< DualRealTensorValue > & _ad_second_zero
Definition: Coupleable.h:800
virtual const VectorVariableCurl & coupledCurlOld(const std::string &var_name, unsigned int comp=0)
Returns an old curl from previous time step of a coupled variable.
Definition: Coupleable.C:1098
std::vector< VectorMooseVariable * > _coupled_vector_moose_vars
Vector of vector coupled variables.
Definition: Coupleable.h:746
const T & coupledNodalValue(const std::string &var_name, unsigned int comp=0)
Returns nodal values of a coupled variable.
Definition: Coupleable.C:1235
std::map< std::string, std::vector< VariableValue * > > _default_value
Will hold the default value for optional coupled variables.
Definition: Coupleable.h:758
virtual void coupledCallback(const std::string &var_name, bool is_old)
Definition: Coupleable.C:139
const VariableValueType< OutputType, compute_stage >::type & adSln() const
AD.
std::map< std::string, std::vector< MooseVariableScalar * > > _c_coupled_scalar_vars
Scalar variables coupled into this object (for error checking)
Definition: Coupleable.h:939
void addFEVariableCoupleableVectorTag(TagID tag)
Definition: Coupleable.h:113
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
const Moose::ValueType< T, compute_stage >::type & adCoupledNodalValueTemplate(const std::string &var_name, unsigned int comp=0)
Returns AD nodal values of a coupled variable.
Definition: Coupleable.C:1537
VariableGradient _default_gradient
This will always be zero because the default values for optionally coupled variables is always consta...
Definition: Coupleable.h:776
std::map< std::string, VectorVariableValue * > _default_vector_value
Will hold the default value for optional vector coupled variables.
Definition: Coupleable.h:764
Real defaultCoupledValue(const std::string &coupling_name, unsigned int i=0) const
Get the default value for an optionally coupled variable.
VariableSecond _default_second
This will always be zero because the default values for optionally coupled variables is always consta...
Definition: Coupleable.h:785
virtual const VectorVariableCurl & coupledCurl(const std::string &var_name, unsigned int comp=0)
Returns curl of a coupled variable.
Definition: Coupleable.C:1078
virtual const VariableGradient & coupledGradientOlder(const std::string &var_name, unsigned int comp=0)
Returns an old gradient from two time steps previous of a coupled variable.
Definition: Coupleable.C:931
MooseArray< DualRealVectorValue > _ad_default_gradient
This will always be zero because the default values for optionally coupled variables is always consta...
Definition: Coupleable.h:779
virtual ~Coupleable()
Destructor for object.
Definition: Coupleable.C:103
const VariableGradientType< OutputType, compute_stage >::type & adGradSlnNeighbor() const
std::map< std::string, std::vector< MooseVariableFEBase * > > _coupled_vars
Coupled vars whose values we provide.
Definition: Coupleable.h:737
const std::string & _c_name
The name of the object this interface is part of.
Definition: Coupleable.h:731
virtual const VariableValue & coupledDofValues(const std::string &var_name, unsigned int comp=0)
Returns DoFs in the current solution vector of a coupled variable for the local element.
Definition: Coupleable.C:1410
virtual const VectorVariableGradient & coupledVectorGradientOlder(const std::string &var_name, unsigned int comp=0)
Returns an old gradient from two time steps previous of a coupled vector variable.
Definition: Coupleable.C:1053
const ADVariableValue & adCoupledDotTemplate(const std::string &var_name, unsigned int comp=0)
Time derivative of a coupled variable for ad simulations.
Definition: Coupleable.h:1050
const VariableSecondType< OutputType, compute_stage >::type & adSecondSln() const
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0)
Returns value of a coupled variable.
Definition: Coupleable.C:361
const VariableGradientType< OutputType, compute_stage >::type & adGradSln() const
const VectorVariableCurl & _vector_curl_zero
Zero value of the curl of a vector variable.
Definition: Coupleable.h:806
const ADVariableGradient & adCoupledGradientTemplate(const std::string &var_name, unsigned int comp=0)
Returns gradient of a coupled variable for use in Automatic Differentation.
Definition: Coupleable.h:984
const T & coupledNodalValuePreviousNL(const std::string &var_name, unsigned int comp=0)
Returns nodal values of a coupled variable for previous Newton iterate.
Definition: Coupleable.C:1313
VectorVariableGradient _default_vector_gradient
This will always be zero because the default values for optionally coupled variables is always consta...
Definition: Coupleable.h:815
const T & getNodalDefaultValue(const std::string &var_name, unsigned int comp=0)
Get nodal default value.
Definition: Coupleable.C:346
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:197
std::set< TagID > & getFEVariableCoupleableMatrixTags()
Definition: Coupleable.h:119
const VariableValueType< OutputType, compute_stage >::type & adSlnNeighbor() const
neighbor AD
bool _coupleable_neighbor
Whether or not this object is a "neighbor" object: ie all of it&#39;s coupled values should be neighbor v...
Definition: Coupleable.h:866
std::map< std::string, MooseArray< DualReal > * > _ad_default_value
Will hold the default value for optional coupled variables for automatic differentiation.
Definition: Coupleable.h:761
virtual const VariableValue & coupledValueOld(const std::string &var_name, unsigned int comp=0)
Returns an old value from previous time step of a coupled variable.
Definition: Coupleable.C:457
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:62
VectorVariableValue _default_vector_value_zero
This will always be zero because the default values for optionally coupled variables is always consta...
Definition: Coupleable.h:812
virtual const VariableValue & coupledDofValuesOlder(const std::string &var_name, unsigned int comp=0)
Returns DoFs in the older solution vector of a coupled variable for the local element.
Definition: Coupleable.C:1445
const std::vector< MooseVariableFEBase * > & getCoupledMooseVars() const
Get the list of all coupled variables.
Definition: Coupleable.h:90
virtual const VariableValue & coupledDotDot(const std::string &var_name, unsigned int comp=0)
Second time derivative of a coupled variable.
Definition: Coupleable.C:650
virtual const VectorVariableValue & coupledVectorDotOld(const std::string &var_name, unsigned int comp=0)
Old time derivative of a coupled vector variable.
Definition: Coupleable.C:784
const ADVectorVariableValue & adCoupledVectorDotTemplate(const std::string &var_name, unsigned int comp=0)
Time derivative of a vector coupled variable for ad simulations.
Definition: Coupleable.h:1078
virtual const VariableGradient & coupledGradient(const std::string &var_name, unsigned int comp=0)
Returns gradient of a coupled variable.
Definition: Coupleable.C:892
std::vector< MooseVariableFEBase * > _coupled_moose_vars
Vector of all coupled variables.
Definition: Coupleable.h:740
virtual const VectorVariableValue & coupledVectorValue(const std::string &var_name, unsigned int comp=0)
Returns value of a coupled vector variable.
Definition: Coupleable.C:424
virtual const VariableSecond & coupledSecond(const std::string &var_name, unsigned int comp=0)
Returns second derivative of a coupled variable.
Definition: Coupleable.C:1145
virtual const VectorVariableValue & coupledVectorDotDot(const std::string &var_name, unsigned int comp=0)
Second time derivative of a coupled vector variable.
Definition: Coupleable.C:756
Class for scalar variables (they are different).
virtual const VectorVariableValue & coupledVectorValueOld(const std::string &var_name, unsigned int comp=0)
Returns an old value from previous time step of a coupled vector variable.
Definition: Coupleable.C:558
virtual const VariableGradient & coupledGradientPreviousNL(const std::string &var_name, unsigned int comp=0)
Returns gradient of a coupled variable for previous Newton iterate.
Definition: Coupleable.C:956
const InputParameters & _c_parameters
Definition: Coupleable.h:728
const MooseArray< DualRealVectorValue > & _ad_grad_zero
Definition: Coupleable.h:796
OutputTools< Real >::VariableSecond VariableSecond
Definition: MooseTypes.h:199
std::map< std::string, std::vector< unsigned int > > _optional_var_index
Unique indices for optionally coupled vars that weren&#39;t provided.
Definition: Coupleable.h:936
OutputTools< RealVectorValue >::VariableGradient VectorVariableGradient
Definition: MooseTypes.h:212
ADVariableSecond & getADDefaultSecond()
Helper method to return (and insert if necessary) the default second derivatives for Automatic Differ...
Definition: Coupleable.h:1232
virtual const VariableSecond & coupledSecondOld(const std::string &var_name, unsigned int comp=0)
Returns an old second derivative from previous time step of a coupled variable.
Definition: Coupleable.C:1166
virtual const VariableSecond & coupledSecondPreviousNL(const std::string &var_name, unsigned int comp=0)
Returns second derivative of a coupled variable for the previous Newton iterate.
Definition: Coupleable.C:1213
const ADVectorVariableValue & adCoupledVectorValueTemplate(const std::string &var_name, unsigned int comp=0)
Returns value of a coupled vector variable for use in Automatic Differentiation.
Definition: Coupleable.h:1106
virtual const VariableValue & coupledDotDu(const std::string &var_name, unsigned int comp=0)
Time derivative of a coupled variable with respect to the coefficients.
Definition: Coupleable.C:840
virtual const VectorVariableValue & coupledVectorDotDotOld(const std::string &var_name, unsigned int comp=0)
Old second time derivative of a coupled vector variable.
Definition: Coupleable.C:812
virtual const VariableGradient & coupledGradientDot(const std::string &var_name, unsigned int comp=0)
Time derivative of the gradient of a coupled variable.
Definition: Coupleable.C:976
const ADVectorVariableGradient & adCoupledVectorGradientTemplate(const std::string &var_name, unsigned int comp=0)
Returns gradient of a coupled vector variable for use in Automatic Differentation.
Definition: Coupleable.h:1142
unsigned int _coupleable_max_qps
Maximum qps for any element in this system.
Definition: Coupleable.h:933
virtual const VariableValue & coupledDot(const std::string &var_name, unsigned int comp=0)
Time derivative of a coupled variable.
Definition: Coupleable.C:624
void addFEVariableCoupleableMatrixTag(TagID tag)
Definition: Coupleable.h:115
void checkVar(const std::string &var_name)
Check that the right kind of variable is being coupled in.
Definition: Coupleable.C:180
virtual const VectorVariableGradient & coupledVectorGradient(const std::string &var_name, unsigned int comp=0)
Returns gradient of a coupled vector variable.
Definition: Coupleable.C:1014
virtual const VectorVariableGradient & coupledVectorGradientOld(const std::string &var_name, unsigned int comp=0)
Returns an old gradient from previous time step of a coupled vector variable.
Definition: Coupleable.C:1033
virtual const VariableValue & coupledNodalDotDot(const std::string &var_name, unsigned int comp=0)
Nodal values of second time derivative of a coupled variable.
Definition: Coupleable.C:1353
std::set< TagID > & getFEVariableCoupleableVectorTags()
Definition: Coupleable.h:117
const VariableSecondType< OutputType, compute_stage >::type & adSecondSlnNeighbor() const
virtual const VariableGradient & coupledGradientOld(const std::string &var_name, unsigned int comp=0)
Returns an old gradient from previous time step of a coupled variable.
Definition: Coupleable.C:911
const std::map< std::string, std::vector< MooseVariableFEBase * > > & getCoupledVars()
Get the list of coupled variables.
Definition: Coupleable.h:81
virtual unsigned int coupled(const std::string &var_name, unsigned int comp=0)
Returns the index for a coupled variable by name.
Definition: Coupleable.C:253
virtual const VariableValue & coupledValueOlder(const std::string &var_name, unsigned int comp=0)
Returns an old value from two time steps previous of a coupled variable.
Definition: Coupleable.C:484
virtual const VectorVariableValue & coupledVectorValueOlder(const std::string &var_name, unsigned int comp=0)
Returns an old value from two time steps previous of a coupled vector variable.
Definition: Coupleable.C:586
const ADVariableGradient & adZeroGradientTemplate()
Template method that returns _grad_zero to RESIDUAL computing objects and _ad_grad_zero to JACOBIAN c...
Definition: Coupleable.h:1249
MooseVariableFEBase * getFEVar(const std::string &var_name, unsigned int comp)
Extract pointer to a base finite element coupled variable.
Definition: Coupleable.C:199
unsigned int THREAD_ID
Definition: MooseTypes.h:161
ADVariableGradient & getADDefaultGradient()
Helper method to return (and insert if necessary) the default gradient for Automatic Differentiation ...
Definition: Coupleable.h:1212
ADVectorVariableValue * getADDefaultVectorValue(const std::string &var_name)
Helper method to return (and insert if necessary) the default vector value for Automatic Differentiat...
Definition: Coupleable.h:1191