www.mooseframework.org
ScalarCoupleable.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "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
23 class FEProblemBase;
24 class InputParameters;
25 class MooseObject;
27 
33 {
34 public:
39  ScalarCoupleable(const MooseObject * moose_object);
40 
45  const std::vector<MooseVariableScalar *> & getCoupledMooseScalarVars()
46  {
48  }
49 
50  const std::set<TagID> & getScalarVariableCoupleableVectorTags() const
51  {
53  }
54 
55  const std::set<TagID> & getScalarVariableCoupleableMatrixTags() const
56  {
58  }
59 
60 protected:
66  bool isCoupledScalar(const std::string & var_name, unsigned int i = 0) const;
67 
72  unsigned int coupledScalarComponents(const std::string & var_name) const;
73 
80  unsigned int coupledScalar(const std::string & var_name, unsigned int comp = 0) const;
81 
88  Order coupledScalarOrder(const std::string & var_name, unsigned int comp = 0) const;
89 
96  const VariableValue & coupledScalarValue(const std::string & var_name,
97  unsigned int comp = 0) const;
98 
105  const ADVariableValue & adCoupledScalarValue(const std::string & var_name,
106  unsigned int comp = 0) const;
107 
115  template <bool is_ad>
116  const GenericVariableValue<is_ad> & coupledGenericScalarValue(const std::string & var_name,
117  unsigned int comp = 0) const;
118 
126  const VariableValue &
127  coupledVectorTagScalarValue(const std::string & var_name, TagID tag, unsigned int comp = 0) const;
128 
136  const VariableValue &
137  coupledMatrixTagScalarValue(const std::string & var_name, TagID tag, unsigned int comp = 0) const;
138 
145  const VariableValue & coupledScalarValueOld(const std::string & var_name,
146  unsigned int comp = 0) const;
147 
154  const VariableValue & coupledScalarValueOlder(const std::string & var_name,
155  unsigned int comp = 0) const;
162  const VariableValue & coupledScalarDot(const std::string & var_name, unsigned int comp = 0) const;
163 
172  const ADVariableValue & adCoupledScalarDot(const std::string & var_name,
173  unsigned int comp = 0) const;
174 
181  const VariableValue & coupledScalarDotDot(const std::string & var_name,
182  unsigned int comp = 0) const;
183 
190  const VariableValue & coupledScalarDotOld(const std::string & var_name,
191  unsigned int comp = 0) const;
192 
199  const VariableValue & coupledScalarDotDotOld(const std::string & var_name,
200  unsigned int comp = 0) const;
201 
209  const VariableValue & coupledScalarDotDu(const std::string & var_name,
210  unsigned int comp = 0) const;
211 
219  const VariableValue & coupledScalarDotDotDu(const std::string & var_name,
220  unsigned int comp = 0) const;
221 
228  const MooseVariableScalar * getScalarVar(const std::string & var_name, unsigned int comp) const;
229 
230 protected:
231  // Reference to FEProblemBase
233 
236 
238  const Real & _real_zero;
239 
242 
244  const Point & _point_zero;
245 
246 private:
253  const VariableValue * getDefaultValue(const std::string & var_name) const;
254 
261  const ADVariableValue * getADDefaultValue(const std::string & var_name) const;
262 
268  void checkVar(const std::string & var_name) const;
269 
276  void validateExecutionerType(const std::string & name, const std::string & fn_name) const;
277 
278  // Reference to the interface's input parameters
280 
282  const std::string & _sc_name;
283 
285  const bool _sc_is_implicit;
286 
288  std::unordered_map<std::string, std::vector<MooseVariableScalar *>> _coupled_scalar_vars;
289 
291  mutable std::unordered_map<std::string, std::unique_ptr<VariableValue>> _default_value;
292 
294  mutable std::unordered_map<std::string, std::unique_ptr<ADVariableValue>> _dual_default_value;
295 
297  std::vector<MooseVariableScalar *> _coupled_moose_scalar_vars;
298 
300  std::unordered_map<std::string, std::vector<MooseVariableFieldBase *>> _sc_coupled_vars;
301 
303  mutable std::set<TagID> _sc_coupleable_vector_tags;
305  mutable std::set<TagID> _sc_coupleable_matrix_tags;
306 };
const std::set< TagID > & getScalarVariableCoupleableMatrixTags() const
Order
std::unordered_map< std::string, std::vector< MooseVariableFieldBase * > > _sc_coupled_vars
Field variables coupled into this object (for error checking)
const Point & _point_zero
Zero point.
std::set< TagID > _sc_coupleable_matrix_tags
The scalar coupleable matrix tags.
typename Moose::GenericType< VariableValue, is_ad > GenericVariableValue
Definition: MooseTypes.h:573
const THREAD_ID _sc_tid
Thread ID of the thread using this object.
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.
unsigned int TagID
Definition: MooseTypes.h:199
std::set< TagID > _sc_coupleable_vector_tags
The scalar coupleable vector tags.
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 & coupledScalarDot(const std::string &var_name, unsigned int comp=0) const
Returns the time derivative of a scalar coupled variable.
const bool _sc_is_implicit
True if implicit value is required.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const VariableValue & coupledScalarDotOld(const std::string &var_name, unsigned int comp=0) const
Returns the old time derivative of a scalar coupled variable.
const std::string & _sc_name
The name of the object this interface is part of.
FEProblemBase & _sc_fe_problem
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...
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.
bool isCoupledScalar(const std::string &var_name, unsigned int i=0) const
Returns true if a variables has been coupled_as name.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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 & coupledVectorTagScalarValue(const std::string &var_name, TagID tag, unsigned int comp=0) const
Returns value of a scalar coupled variable.
const std::vector< MooseVariableScalar * > & getCoupledMooseScalarVars()
Get the list of coupled scalar variables.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
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 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.
const VariableValue & coupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Returns value of a scalar coupled variable.
const MooseVariableScalar * getScalarVar(const std::string &var_name, unsigned int comp) const
Extract pointer to a scalar coupled variable.
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.
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 InputParameters & _sc_parameters
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:302
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...
const ADVariableValue & adCoupledScalarValue(const std::string &var_name, unsigned int comp=0) const
Returns AD value of a scalar coupled variable.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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 std::set< TagID > & getScalarVariableCoupleableVectorTags() const
ScalarCoupleable(const MooseObject *moose_object)
Constructing the object.
std::vector< MooseVariableScalar * > _coupled_moose_scalar_vars
Vector of coupled variables.
const Real & _real_zero
Scalar zero.
unsigned int coupledScalarComponents(const std::string &var_name) const
Return the number of components to the coupled scalar variable.
Class for scalar variables (they are different).
Interface for objects that needs scalar coupling capabilities.
std::unordered_map< std::string, std::unique_ptr< VariableValue > > _default_value
Will hold the default value for optional coupled scalar variables.
std::unordered_map< std::string, std::unique_ptr< ADVariableValue > > _dual_default_value
Will hold the default AD value for optional coupled scalar variables.
const VariableValue & _scalar_zero
Zero value of a scalar variable.
const VariableValue & coupledMatrixTagScalarValue(const std::string &var_name, TagID tag, unsigned int comp=0) const
Returns value 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.
Order coupledScalarOrder(const std::string &var_name, unsigned int comp=0) const
Returns the order for a scalar coupled variable by name.
unsigned int THREAD_ID
Definition: MooseTypes.h:198