https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ScalarCoupleable.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#ifdef MOOSE_KOKKOS_SCOPE
13#include "KokkosScalar.h"
14#include "KokkosVariableValue.h"
15#endif
16
17#include "Moose.h"
18
19// MOOSE includes
20#include "MooseVariableBase.h"
21
22// C++ includes
23#include <unordered_map>
24#include <string>
25#include <vector>
26
27// Forward declarations
28class FEProblemBase;
29class InputParameters;
30class MooseObject;
32
38{
39public:
44 ScalarCoupleable(const MooseObject * moose_object);
45
46#ifdef MOOSE_KOKKOS_ENABLED
51#endif
52
57 const std::vector<MooseVariableScalar *> & getCoupledMooseScalarVars()
58 {
60 }
61
62 const std::set<TagID> & getScalarVariableCoupleableVectorTags() const
63 {
65 }
66
67 const std::set<TagID> & getScalarVariableCoupleableMatrixTags() const
68 {
70 }
71
72protected:
78 bool isCoupledScalar(const std::string & var_name, unsigned int i = 0) const;
79
84 unsigned int coupledScalarComponents(const std::string & var_name) const;
85
92 unsigned int coupledScalar(const std::string & var_name, unsigned int comp = 0) const;
93
100 libMesh::Order coupledScalarOrder(const std::string & var_name, unsigned int comp = 0) const;
101
108 const VariableValue & coupledScalarValue(const std::string & var_name,
109 unsigned int comp = 0) const;
110
117 const ADVariableValue & adCoupledScalarValue(const std::string & var_name,
118 unsigned int comp = 0) const;
119
127 template <bool is_ad>
128 const GenericVariableValue<is_ad> & coupledGenericScalarValue(const std::string & var_name,
129 unsigned int comp = 0) const;
130
138 const VariableValue & coupledVectorTagScalarValue(const std::string & var_name,
139 const std::string & tag_param_name,
140 unsigned int comp = 0) const;
141
149 const VariableValue & coupledMatrixTagScalarValue(const std::string & var_name,
150 const std::string & tag_param_name,
151 unsigned int comp = 0) const;
152
159 const VariableValue & coupledScalarValueOld(const std::string & var_name,
160 unsigned int comp = 0) const;
161
168 const VariableValue & coupledScalarValueOlder(const std::string & var_name,
169 unsigned int comp = 0) const;
176 const VariableValue & coupledScalarDot(const std::string & var_name, unsigned int comp = 0) const;
177
186 const ADVariableValue & adCoupledScalarDot(const std::string & var_name,
187 unsigned int comp = 0) const;
188
195 const VariableValue & coupledScalarDotDot(const std::string & var_name,
196 unsigned int comp = 0) const;
197
204 const VariableValue & coupledScalarDotOld(const std::string & var_name,
205 unsigned int comp = 0) const;
206
213 const VariableValue & coupledScalarDotDotOld(const std::string & var_name,
214 unsigned int comp = 0) const;
215
223 const VariableValue & coupledScalarDotDu(const std::string & var_name,
224 unsigned int comp = 0) const;
225
233 const VariableValue & coupledScalarDotDotDu(const std::string & var_name,
234 unsigned int comp = 0) const;
235
236#ifdef MOOSE_KOKKOS_SCOPE
238 const std::string & tag_name,
239 unsigned int comp = 0) const;
241 const std::string & tag_param_name,
242 unsigned int comp = 0) const;
243
245 unsigned int comp = 0) const;
247 unsigned int comp = 0) const;
249 unsigned int comp = 0) const;
251 unsigned int comp = 0) const;
253 unsigned int comp = 0) const;
254#endif
255
262 const MooseVariableScalar * getScalarVar(const std::string & var_name, unsigned int comp) const;
263
264protected:
265 // Reference to FEProblemBase
267
270
272 const Real & _real_zero;
273
276
278 const Point & _point_zero;
279
280private:
287 const VariableValue * getDefaultValue(const std::string & var_name) const;
288
295 const ADVariableValue * getADDefaultValue(const std::string & var_name) const;
296
302 void checkVar(const std::string & var_name) const;
303
310 void validateExecutionerType(const std::string & name, const std::string & fn_name) const;
311
312#ifdef MOOSE_KOKKOS_SCOPE
314 const std::string & tag_name,
315 unsigned int comp) const;
316#endif
317
318 // Reference to the interface's input parameters
320
322 const std::string & _sc_name;
323
325 const bool _sc_is_implicit;
326
328 std::unordered_map<std::string, std::vector<MooseVariableScalar *>> _coupled_scalar_vars;
329
331 mutable std::unordered_map<std::string, std::unique_ptr<VariableValue>> _default_value;
332
334 mutable std::unordered_map<std::string, std::unique_ptr<ADVariableValue>> _dual_default_value;
335
337 std::vector<MooseVariableScalar *> _coupled_moose_scalar_vars;
338
340 std::unordered_map<std::string, std::vector<MooseVariableFieldBase *>> _sc_coupled_vars;
341
343 mutable std::set<TagID> _sc_coupleable_vector_tags;
345 mutable std::set<TagID> _sc_coupleable_matrix_tags;
346};
Moose::GenericType< VariableValue, is_ad > GenericVariableValue
Definition MooseTypes.h:712
OutputTools< Real >::VariableValue VariableValue
Definition MooseTypes.h:348
unsigned int THREAD_ID
Definition MooseTypes.h:237
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
Class for scalar variables (they are different).
The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable.
The Kokkos wrapper classes for MOOSE-like variable value access.
The Kokkos variable object that carries the coupled variable and tag information.
Interface for objects that needs scalar coupling capabilities.
const VariableValue & coupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Returns value of a scalar coupled variable.
const VariableValue & coupledMatrixTagScalarValue(const std::string &var_name, const std::string &tag_param_name, unsigned int comp=0) const
Returns value of a scalar coupled variable.
const std::string & _sc_name
The name of the object this interface is part of.
const VariableValue & _scalar_zero
Zero value of a scalar variable.
std::unordered_map< std::string, std::unique_ptr< VariableValue > > _default_value
Will hold the default value for optional coupled scalar variables.
const std::set< TagID > & getScalarVariableCoupleableVectorTags() const
const VariableValue & coupledScalarDotDot(const std::string &var_name, unsigned int comp=0) const
Returns the second time derivative of a scalar coupled variable.
void checkVar(const std::string &var_name) const
Check that the right kind of variable is being coupled in.
std::vector< MooseVariableScalar * > _coupled_moose_scalar_vars
Vector of coupled variables.
unsigned int coupledScalarComponents(const std::string &var_name) const
Return the number of components to the coupled scalar variable.
Moose::Kokkos::VariableValue kokkosCoupledScalarValueOld(const std::string &var_name, unsigned int comp=0) const
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...
std::unordered_map< std::string, std::vector< MooseVariableFieldBase * > > _sc_coupled_vars
Field variables coupled into this object (for error checking)
Moose::Kokkos::VariableValue kokkosCoupledVectorTagScalarValue(const std::string &var_name, const std::string &tag_param_name, unsigned int comp=0) const
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars()
Get the list of coupled scalar variables.
std::set< TagID > _sc_coupleable_vector_tags
The scalar coupleable vector tags.
const InputParameters & _sc_parameters
std::set< TagID > _sc_coupleable_matrix_tags
The scalar coupleable matrix tags.
const Real & _real_zero
Scalar zero.
const VariableValue & coupledScalarValueOld(const std::string &var_name, unsigned int comp=0) const
Returns the old (previous time step) value of a scalar coupled variable.
const VariableValue & coupledScalarDotDotDu(const std::string &var_name, unsigned int comp=0) const
Second time derivative of a scalar coupled variable with respect to the coefficients.
const VariableValue & coupledVectorTagScalarValue(const std::string &var_name, const std::string &tag_param_name, unsigned int comp=0) const
Returns value of a scalar coupled variable.
const VariableValue & coupledScalarValueOlder(const std::string &var_name, unsigned int comp=0) const
Returns the older (two time steps previous) value of a scalar coupled variable.
const ADVariableValue & adCoupledScalarDot(const std::string &var_name, unsigned int comp=0) const
Returns the time derivative of a scalar coupled variable, including its dependence on the nonlinear d...
Moose::Kokkos::VariableValue kokkosCoupledScalarValueOlder(const std::string &var_name, unsigned int comp=0) const
const VariableValue & coupledScalarDotOld(const std::string &var_name, unsigned int comp=0) const
Returns the old time derivative of a scalar coupled variable.
Moose::Kokkos::VariableValue kokkosCoupledVectorTagScalarValueByName(const std::string &var_name, const std::string &tag_name, unsigned int comp=0) const
const VariableValue & coupledScalarDotDotOld(const std::string &var_name, unsigned int comp=0) const
Returns the old second time derivative of a scalar coupled variable.
const VariableValue * getDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the default value for an uncoupled variable.
Moose::Kokkos::Scalar< const Real > kokkosCoupledScalarDotDu(const std::string &var_name, unsigned int comp=0) const
std::unordered_map< std::string, std::unique_ptr< ADVariableValue > > _dual_default_value
Will hold the default AD value for optional coupled scalar variables.
Moose::Kokkos::VariableValue kokkosCoupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Moose::Kokkos::Variable kokkosCoupledVectorTagScalarVariable(const std::string &var_name, const std::string &tag_name, unsigned int comp) const
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
const std::set< TagID > & getScalarVariableCoupleableMatrixTags() const
std::unordered_map< std::string, std::vector< MooseVariableScalar * > > _coupled_scalar_vars
Coupled vars whose values we provide.
unsigned int coupledScalar(const std::string &var_name, unsigned int comp=0) const
Returns the index for a scalar coupled variable by name.
FEProblemBase & _sc_fe_problem
libMesh::Order coupledScalarOrder(const std::string &var_name, unsigned int comp=0) const
Returns the order for a scalar coupled variable by name.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
const ADVariableValue & adCoupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Returns AD value of a scalar coupled variable.
const GenericVariableValue< is_ad > & coupledGenericScalarValue(const std::string &var_name, unsigned int comp=0) const
Returns value of a coupled scalar variable for use in templated automatic differentiation classes.
const VariableValue & coupledScalarDot(const std::string &var_name, unsigned int comp=0) const
Returns the time derivative of a scalar coupled variable.
Moose::Kokkos::VariableValue kokkosCoupledScalarDot(const std::string &var_name, unsigned int comp=0) const
const THREAD_ID _sc_tid
Thread ID of the thread using this object.
const VariableValue & coupledScalarDotDu(const std::string &var_name, unsigned int comp=0) const
Time derivative of a scalar coupled variable with respect to the coefficients.
const Point & _point_zero
Zero point.
const bool _sc_is_implicit
True if implicit value is required.
const ADVariableValue * getADDefaultValue(const std::string &var_name) const
Helper method to return (and insert if necessary) the AD default value for an uncoupled variable.