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#include "Moose.h"
13
14// MOOSE includes
15#include "MooseVariableBase.h"
16
17// C++ includes
18#include <unordered_map>
19#include <string>
20#include <vector>
21
22// Forward declarations
23class FEProblemBase;
24class InputParameters;
25class MooseObject;
27
33{
34public:
39 ScalarCoupleable(const MooseObject * moose_object);
40
41#ifdef MOOSE_KOKKOS_ENABLED
46#endif
47
52 const std::vector<MooseVariableScalar *> & getCoupledMooseScalarVars()
53 {
55 }
56
57 const std::set<TagID> & getScalarVariableCoupleableVectorTags() const
58 {
60 }
61
62 const std::set<TagID> & getScalarVariableCoupleableMatrixTags() const
63 {
65 }
66
67protected:
73 bool isCoupledScalar(const std::string & var_name, unsigned int i = 0) const;
74
79 unsigned int coupledScalarComponents(const std::string & var_name) const;
80
87 unsigned int coupledScalar(const std::string & var_name, unsigned int comp = 0) const;
88
95 libMesh::Order coupledScalarOrder(const std::string & var_name, unsigned int comp = 0) const;
96
103 const VariableValue & coupledScalarValue(const std::string & var_name,
104 unsigned int comp = 0) const;
105
112 const ADVariableValue & adCoupledScalarValue(const std::string & var_name,
113 unsigned int comp = 0) const;
114
122 template <bool is_ad>
123 const GenericVariableValue<is_ad> & coupledGenericScalarValue(const std::string & var_name,
124 unsigned int comp = 0) const;
125
133 const VariableValue &
134 coupledVectorTagScalarValue(const std::string & var_name, TagID tag, unsigned int comp = 0) const;
135
143 const VariableValue &
144 coupledMatrixTagScalarValue(const std::string & var_name, TagID tag, unsigned int comp = 0) const;
145
152 const VariableValue & coupledScalarValueOld(const std::string & var_name,
153 unsigned int comp = 0) const;
154
161 const VariableValue & coupledScalarValueOlder(const std::string & var_name,
162 unsigned int comp = 0) const;
169 const VariableValue & coupledScalarDot(const std::string & var_name, unsigned int comp = 0) const;
170
179 const ADVariableValue & adCoupledScalarDot(const std::string & var_name,
180 unsigned int comp = 0) const;
181
188 const VariableValue & coupledScalarDotDot(const std::string & var_name,
189 unsigned int comp = 0) const;
190
197 const VariableValue & coupledScalarDotOld(const std::string & var_name,
198 unsigned int comp = 0) const;
199
206 const VariableValue & coupledScalarDotDotOld(const std::string & var_name,
207 unsigned int comp = 0) const;
208
216 const VariableValue & coupledScalarDotDu(const std::string & var_name,
217 unsigned int comp = 0) const;
218
226 const VariableValue & coupledScalarDotDotDu(const std::string & var_name,
227 unsigned int comp = 0) const;
228
235 const MooseVariableScalar * getScalarVar(const std::string & var_name, unsigned int comp) const;
236
237protected:
238 // Reference to FEProblemBase
240
243
245 const Real & _real_zero;
246
249
251 const Point & _point_zero;
252
253private:
260 const VariableValue * getDefaultValue(const std::string & var_name) const;
261
268 const ADVariableValue * getADDefaultValue(const std::string & var_name) const;
269
275 void checkVar(const std::string & var_name) const;
276
283 void validateExecutionerType(const std::string & name, const std::string & fn_name) const;
284
285 // Reference to the interface's input parameters
287
289 const std::string & _sc_name;
290
292 const bool _sc_is_implicit;
293
295 std::unordered_map<std::string, std::vector<MooseVariableScalar *>> _coupled_scalar_vars;
296
298 mutable std::unordered_map<std::string, std::unique_ptr<VariableValue>> _default_value;
299
301 mutable std::unordered_map<std::string, std::unique_ptr<ADVariableValue>> _dual_default_value;
302
304 std::vector<MooseVariableScalar *> _coupled_moose_scalar_vars;
305
307 std::unordered_map<std::string, std::vector<MooseVariableFieldBase *>> _sc_coupled_vars;
308
310 mutable std::set<TagID> _sc_coupleable_vector_tags;
312 mutable std::set<TagID> _sc_coupleable_matrix_tags;
313};
unsigned int TagID
Definition MooseTypes.h:238
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).
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 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 VariableValue & coupledMatrixTagScalarValue(const std::string &var_name, TagID tag, unsigned int comp=0) const
Returns value of a scalar coupled variable.
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.
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)
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 & 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...
const VariableValue & coupledScalarDotOld(const std::string &var_name, unsigned int comp=0) const
Returns the old time derivative of a scalar coupled variable.
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.
const VariableValue & coupledVectorTagScalarValue(const std::string &var_name, TagID tag, unsigned int comp=0) const
Returns value of a scalar coupled variable.
std::unordered_map< std::string, std::unique_ptr< ADVariableValue > > _dual_default_value
Will hold the default AD value for optional coupled scalar variables.
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.
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.