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 
42  void reinit(bool reinit_for_derivative_reordering = false);
43 
44  const VariableValue & sln() const { return _u; }
45 
49  const ADVariableValue & adSln() const;
50 
51  const VariableValue & slnOld() const;
52  const VariableValue & slnOlder() const;
53  const VariableValue & vectorTagSln(TagID tag) const;
54  const VariableValue & matrixTagSln(TagID tag) const;
55 
56  const VariableValue & uDot() const;
57  const VariableValue & uDotDot() const;
58  const VariableValue & uDotOld() const;
59  const VariableValue & uDotDotOld() const;
60  const VariableValue & duDotDu() const;
61  const VariableValue & duDotDotDu() const;
62 
66  const ADVariableValue & adUDot() const;
67 
71  void setValue(unsigned int i, Number value);
72 
76  void setValues(Number value);
77 
78  void insert(NumericVector<Number> & soln);
79 
84  unsigned int oldestSolutionStateRequested() const;
85 
86  void setActiveTags(const std::set<TagID> & vtags) override { _required_vector_tags = vtags; }
87 
88  virtual void sizeMatrixTagData() override;
89 
90  bool supportsFaceArg() const override final { return true; }
91  bool supportsElemSideQpArg() const override final { return true; }
92 
93 protected:
101  std::vector<VariableValue> _vector_tag_u;
103  mutable std::vector<bool> _need_vector_tag_u;
105  std::vector<VariableValue> _matrix_tag_u;
107  mutable std::vector<bool> _need_matrix_tag_u;
108 
115 
116  mutable bool _need_u_dot;
117  mutable bool _need_u_dotdot;
118  mutable bool _need_u_dot_old;
119  mutable bool _need_u_dotdot_old;
120  mutable bool _need_du_dot_du;
121  mutable bool _need_du_dotdot_du;
122 
124  mutable bool _need_u_old;
126  mutable bool _need_u_older;
127 
129  mutable bool _need_ad;
131  mutable bool _need_ad_u;
133  mutable bool _need_ad_u_dot;
138 
139 private:
143 
150 
151  ValueType evaluate(const ElemArg & elem, const Moose::StateArg & state) const override final;
152  ValueType evaluate(const FaceArg & face, const Moose::StateArg & state) const override final;
153  ValueType evaluate(const ElemQpArg & qp, const Moose::StateArg & state) const override final;
154  ValueType evaluate(const ElemSideQpArg & elem_side_qp,
155  const Moose::StateArg & state) const override final;
156  ValueType evaluate(const ElemPointArg & elem_point,
157  const Moose::StateArg & state) const override final;
158  ValueType evaluate(const NodeArg & node, const Moose::StateArg & state) const override final;
159  ValueType evaluate(const Moose::StateArg & state) const;
160 
162  const Moose::StateArg & state) const override final;
164  const Moose::StateArg & state) const override final;
166  const Moose::StateArg & state) const override final;
167  GradientType evaluateGradient(const ElemSideQpArg & elem_side_qp,
168  const Moose::StateArg & state) const override final;
169  GradientType evaluateGradient(const ElemPointArg & elem_point,
170  const Moose::StateArg & state) const override final;
172  const Moose::StateArg & state) const override final;
173 
180  void computeAD(bool nodal_ordering);
181 
183  std::set<TagID> _required_vector_tags;
184 };
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:210
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:315
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.
Real Number
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.