https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
17namespace libMesh
18{
19template <typename T>
20class NumericVector;
21}
22
23class Assembly;
24class TimeIntegrator;
25
30{
31public:
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
96protected:
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
142private:
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};
unsigned int TagID
Definition MooseTypes.h:238
OutputTools< Real >::VariableValue VariableValue
Definition MooseTypes.h:348
Keeps track of stuff related to assembling.
Definition Assembly.h:110
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Base variable class.
Class for scalar variables (they are different).
const VariableValue & uDotOld() const
ADVariableValue _ad_u_dot
The first derivative of the scalar solution with derivative information.
const VariableValue & uDot() const
bool _need_ad_u_dot
whether ad_u_dot is needed
ADVariableValue _ad_u
The scalar solution with derivative information.
std::vector< bool > _need_vector_tag_u
Only cache data when need it.
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
const VariableValue & duDotDotDu() const
static InputParameters validParams()
bool supportsQpBasedLoops() const override
Whether this variable supports QP-indexed loops.
const VariableValue & uDotDotOld() const
const ADVariableValue & adUDot() const
Return the first derivative of the solution with derivative information.
const VariableValue & duDotDu() const
const VariableValue & uDotDot() const
const VariableValue & matrixTagSln(TagID tag) const
std::set< TagID > _required_vector_tags
The set of vector tags we need to evaluate.
const VariableValue & sln() const
VariableValue _u_older
The older value of scalar variable.
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
std::vector< bool > _need_matrix_tag_u
Only cache data when need it.
const VariableValue & slnOld() const
void setValue(unsigned int i, Number value)
Set the nodal value for this variable (to keep everything up to date.
std::vector< VariableValue > _matrix_tag_u
Tagged matrices.
std::vector< VariableValue > _vector_tag_u
Tagged vectors.
bool _need_u_old
Whether or not the old solution is needed.
unsigned int oldestSolutionStateRequested() const
The oldest solution state that is requested for this variable (0 = current, 1 = old,...
bool _need_ad_u
whether ad_u is needed
GradientType evaluateGradient(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor gradient with a given element.
void insert(NumericVector< Number > &soln)
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
const VariableValue & slnOlder() const
virtual void sizeMatrixTagData() override
Size data structures related to matrix tagging.
bool _need_u_older
Whether or not the older solution is needed.
VariableValue _u_old
The old value of scalar variable.
void setActiveTags(const std::set< TagID > &vtags) override
Set the active vector tags.
void computeAD(bool nodal_ordering)
Adds derivative information to the scalar variable value arrays.
const ADVariableValue & adSln() const
Return the solution with derivative information.
bool supportsGeometricInfoBasedLoops() const override
Whether this variable supports geometric-info-based loops, such as ElemInfo/FaceInfo loops.
VariableValue _u
The value of scalar variable.
ValueType evaluate(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor with a given element.
bool _need_ad
Whether any AD calculations are needed.
const VariableValue & vectorTagSln(TagID tag) const
void setValues(Number value)
Set all of the values of this scalar variable to the same value.
Base class template for functor objects.
typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector,...
Base class for time integrators.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
A structure that is used to evaluate Moose functors logically at an element/cell center.
A structure that is used to evaluate Moose functors at an arbitrary physical point contained within a...
Argument for requesting functor evaluation at a quadrature point location in an element.
Argument for requesting functor evaluation at quadrature point locations on an element side.
A structure defining a "face" evaluation calling argument for Moose functors.
State argument for evaluating functors.