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