www.mooseframework.org
MooseVariableScalar.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 "MooseVariableBase.h"
13 #include "SystemBase.h"
14 
15 // libMesh forward declarations
16 namespace libMesh
17 {
18 template <typename T>
19 class NumericVector;
20 }
21 
22 class Assembly;
23 
28 {
29 public:
30  MooseVariableScalar(unsigned int var_num,
31  const FEType & fe_type,
32  SystemBase & sys,
33  Assembly & assembly,
34  Moose::VarKindType var_kind,
35  THREAD_ID tid);
36  virtual ~MooseVariableScalar();
37 
38  void reinit();
39 
40  //
41  VariableValue & sln() { return _u; }
42  VariableValue & slnOld() { return _u_old; }
45  {
46  _need_vector_tag_u[tag] = true;
47  return _vector_tag_u[tag];
48  }
50  {
51  _need_matrix_tag_u[tag] = true;
52  return _matrix_tag_u[tag];
53  }
54 
56  {
57  if (_sys.solutionUDot())
58  {
59  _need_u_dot = true;
60  return _u_dot;
61  }
62  else
63  mooseError("MooseVariableScalar: Time derivative of solution (`u_dot`) is not stored. Please "
64  "set uDotRequested() to true in FEProblemBase before requesting `u_dot`.");
65  }
66 
68  {
69  if (_sys.solutionUDotDot())
70  {
71  _need_u_dotdot = true;
72  return _u_dotdot;
73  }
74  else
75  mooseError("MooseVariableScalar: Second time derivative of solution (`u_dotdot`) is not "
76  "stored. Please set uDotDotRequested() to true in FEProblemBase before requesting "
77  "`u_dotdot`.");
78  }
79 
81  {
82  if (_sys.solutionUDotOld())
83  {
84  _need_u_dot_old = true;
85  return _u_dot_old;
86  }
87  else
88  mooseError("MooseVariableScalar: Old time derivative of solution (`u_dot_old`) is not "
89  "stored. Please set uDotOldRequested() to true in FEProblemBase before requesting "
90  "`u_dot_old`.");
91  }
92 
94  {
96  {
97  _need_u_dotdot_old = true;
98  return _u_dotdot_old;
99  }
100  else
101  mooseError("MooseVariableScalar: Old second time derivative of solution (`u_dotdot_old`) is "
102  "not stored. Please set uDotDotOldRequested() to true in FEProblemBase before "
103  "requesting `u_dotdot_old`.");
104  }
105 
107  {
108  _need_du_dot_du = true;
109  return _du_dot_du;
110  }
111 
113  {
114  _need_du_dotdot_du = true;
115  return _du_dotdot_du;
116  }
117 
121  void setValue(unsigned int i, Number value);
122 
126  void setValues(Number value);
127 
128  void insert(NumericVector<Number> & soln);
129 
130 protected:
133 
141  std::vector<VariableValue> _vector_tag_u;
143  std::vector<bool> _need_vector_tag_u;
145  std::vector<VariableValue> _matrix_tag_u;
147  std::vector<bool> _need_matrix_tag_u;
148 
155 
162 };
163 
virtual NumericVector< Number > * solutionUDot()=0
VariableValue & sln()
Keeps track of stuff related to assembling.
Definition: Assembly.h:62
unsigned int TagID
Definition: MooseTypes.h:162
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
VariableValue _u
The value of scalar variable.
virtual NumericVector< Number > * solutionUDotDotOld()=0
VariableValue _u_older
The older value of scalar variable.
VariableValue & uDot()
VariableValue & duDotDotDu()
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Base class for a system (of equations)
Definition: SystemBase.h:92
MooseVariableScalar(unsigned int var_num, const FEType &fe_type, SystemBase &sys, Assembly &assembly, Moose::VarKindType var_kind, THREAD_ID tid)
std::vector< VariableValue > _vector_tag_u
Tagged vectors.
std::vector< bool > _need_vector_tag_u
Only cache data when need it.
VariableValue & duDotDu()
SystemBase & _sys
System this variable is part of.
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:481
void setValue(unsigned int i, Number value)
Set the nodal value for this variable (to keep everything up to date.
void setValues(Number value)
Set all of the values of this scalar variable to the same value.
std::vector< bool > _need_matrix_tag_u
Only cache data when need it.
VariableValue & matrixTagSln(TagID tag)
std::vector< VariableValue > _matrix_tag_u
Tagged matrices.
forward declarations
Definition: MooseArray.h:16
VariableValue & uDotDotOld()
Class for scalar variables (they are different).
void insert(NumericVector< Number > &soln)
Assembly & _assembly
The assembly.
virtual NumericVector< Number > * solutionUDotOld()=0
virtual NumericVector< Number > * solutionUDotDot()=0
VariableValue & uDotDot()
VariableValue & slnOlder()
VariableValue & vectorTagSln(TagID tag)
SystemBase & sys()
Get the system this variable is part of.
VariableValue & uDotOld()
VariableValue & slnOld()
unsigned int THREAD_ID
Definition: MooseTypes.h:161
VariableValue _u_old
The old value of scalar variable.