https://mooseframework.inl.gov
MooseVariableScalar.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 "MooseVariableBase.h"
13 #include "MooseFunctor.h"
14 #include "SystemBase.h"
15 
16 // libMesh forward declarations
17 namespace libMesh
18 {
19 template <typename T>
20 class NumericVector;
21 }
22 
23 class Assembly;
24 class TimeIntegrator;
25 
30 {
31 public:
33 
35  virtual ~MooseVariableScalar();
36 
37  bool supportsQpBasedLoops() const override { return false; }
38  bool supportsGeometricInfoBasedLoops() const override { return false; }
39 
45  void reinit(bool reinit_for_derivative_reordering = false);
46 
47  const VariableValue & sln() const { return _u; }
48 
52  const ADVariableValue & adSln() const;
53 
54  const VariableValue & slnOld() const;
55  const VariableValue & slnOlder() const;
56  const VariableValue & vectorTagSln(TagID tag) const;
57  const VariableValue & matrixTagSln(TagID tag) const;
58 
59  const VariableValue & uDot() const;
60  const VariableValue & uDotDot() const;
61  const VariableValue & uDotOld() const;
62  const VariableValue & uDotDotOld() const;
63  const VariableValue & duDotDu() const;
64  const VariableValue & duDotDotDu() const;
65 
69  const ADVariableValue & adUDot() const;
70 
74  void setValue(unsigned int i, Number value);
75 
79  void setValues(Number value);
80 
81  void insert(NumericVector<Number> & soln);
82 
87  unsigned int oldestSolutionStateRequested() const;
88 
89  void setActiveTags(const std::set<TagID> & vtags) override { _required_vector_tags = vtags; }
90 
91  virtual void sizeMatrixTagData() override;
92 
93  bool supportsFaceArg() const override final { return true; }
94  bool supportsElemSideQpArg() const override final { return true; }
95 
96 protected:
104  std::vector<VariableValue> _vector_tag_u;
106  mutable std::vector<bool> _need_vector_tag_u;
108  std::vector<VariableValue> _matrix_tag_u;
110  mutable std::vector<bool> _need_matrix_tag_u;
111 
118 
119  mutable bool _need_u_dot;
120  mutable bool _need_u_dotdot;
121  mutable bool _need_u_dot_old;
122  mutable bool _need_u_dotdot_old;
123  mutable bool _need_du_dot_du;
124  mutable bool _need_du_dotdot_du;
125 
127  mutable bool _need_u_old;
129  mutable bool _need_u_older;
130 
132  mutable bool _need_ad;
134  mutable bool _need_ad_u;
136  mutable bool _need_ad_u_dot;
141 
142 private:
146 
153 
154  ValueType evaluate(const ElemArg & elem, const Moose::StateArg & state) const override final;
155  ValueType evaluate(const FaceArg & face, const Moose::StateArg & state) const override final;
156  ValueType evaluate(const ElemQpArg & qp, const Moose::StateArg & state) const override final;
157  ValueType evaluate(const ElemSideQpArg & elem_side_qp,
158  const Moose::StateArg & state) const override final;
159  ValueType evaluate(const ElemPointArg & elem_point,
160  const Moose::StateArg & state) const override final;
161  ValueType evaluate(const NodeArg & node, const Moose::StateArg & state) const override final;
162  ValueType evaluate(const Moose::StateArg & state) const;
163 
165  const Moose::StateArg & state) const override final;
167  const Moose::StateArg & state) const override final;
169  const Moose::StateArg & state) const override final;
170  GradientType evaluateGradient(const ElemSideQpArg & elem_side_qp,
171  const Moose::StateArg & state) const override final;
172  GradientType evaluateGradient(const ElemPointArg & elem_point,
173  const Moose::StateArg & state) const override final;
175  const Moose::StateArg & state) const override final;
176 
183  void computeAD(bool nodal_ordering);
184 
186  std::set<TagID> _required_vector_tags;
187 };
std::set< TagID > _required_vector_tags
The set of vector tags we need to evaluate.
const VariableValue & uDotOld() const
const VariableValue & uDotDot() const
const ADVariableValue & adUDot() const
Return the first derivative of the solution with derivative information.
Base class template for functor objects.
Definition: MooseFunctor.h:137
void computeAD(bool nodal_ordering)
Adds derivative information to the scalar variable value arrays.
ADVariableValue _ad_u_dot
The first derivative of the scalar solution with derivative information.
Keeps track of stuff related to assembling.
Definition: Assembly.h:109
unsigned int TagID
Definition: MooseTypes.h:238
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
bool _need_u_older
Whether or not the older solution is needed.
VariableValue _u
The value of scalar variable.
MooseVariableScalar(const InputParameters &parameters)
const VariableValue & slnOlder() const
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
bool _need_ad_u
whether ad_u is needed
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
ADVariableValue _ad_u
The scalar solution with derivative information.
virtual void sizeMatrixTagData() override
Size data structures related to matrix tagging.
const VariableValue & duDotDotDu() const
VariableValue _u_older
The older value of scalar variable.
A structure that is used to evaluate Moose functors at an arbitrary physical point contained within a...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const VariableValue & uDotDotOld() const
void setActiveTags(const std::set< TagID > &vtags) override
Set the active vector tags.
typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector...
Definition: MooseFunctor.h:149
std::vector< VariableValue > _vector_tag_u
Tagged vectors.
GradientType evaluateGradient(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor gradient with a given element.
std::vector< bool > _need_vector_tag_u
Only cache data when need it.
const VariableValue & slnOld() const
const VariableValue & uDot() const
const VariableValue & vectorTagSln(TagID tag) const
bool _need_ad
Whether any AD calculations are needed.
A structure defining a "face" evaluation calling argument for Moose functors.
unsigned int oldestSolutionStateRequested() const
The oldest solution state that is requested for this variable (0 = current, 1 = old, 2 = older, etc).
static InputParameters validParams()
void setValue(unsigned int i, Number value)
Set the nodal value for this variable (to keep everything up to date.
A structure that is used to evaluate Moose functors logically at an element/cell center.
void setValues(Number value)
Set all of the values of this scalar variable to the same value.
Argument for requesting functor evaluation at a quadrature point location in an element.
std::vector< bool > _need_matrix_tag_u
Only cache data when need it.
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
const VariableValue & matrixTagSln(TagID tag) const
std::vector< VariableValue > _matrix_tag_u
Tagged matrices.
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:343
bool _need_ad_u_dot
whether ad_u_dot is needed
Base class for time integrators.
const VariableValue & duDotDu() const
bool _need_u_old
Whether or not the old solution is needed.
Class for scalar variables (they are different).
void insert(NumericVector< Number > &soln)
State argument for evaluating functors.
const ADVariableValue & adSln() const
Return the solution with derivative information.
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
bool supportsQpBasedLoops() const override
Whether this variable supports QP-indexed loops.
Real Number
bool supportsGeometricInfoBasedLoops() const override
Whether this variable supports geometric-info-based loops, such as ElemInfo/FaceInfo loops...
const VariableValue & sln() const
Argument for requesting functor evaluation at quadrature point locations on an element side...
Base variable class.
ValueType evaluate(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor with a given element.
VariableValue _u_old
The old value of scalar variable.