https://mooseframework.inl.gov
MooseVariableDataBase.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 "MooseArray.h"
13 #include "MooseTypes.h"
14 
15 #include "libmesh/tensor_tools.h"
16 #include "libmesh/vector_value.h"
17 #include "libmesh/tensor_value.h"
18 #include "libmesh/type_n_tensor.h"
19 #include "libmesh/enum_fe_family.h"
20 
21 #include <vector>
22 
23 template <typename>
24 class MooseVariableField;
25 class SubProblem;
26 class SystemBase;
27 namespace libMesh
28 {
29 class DofMap;
30 }
31 
32 template <typename OutputType>
34 {
35 public:
36  // type for gradient, second and divergence of template class OutputType
40 
41  // shortcut for types storing values on quadrature points
44 
45  // DoF value type for the template class OutputType
48 
50  SystemBase & sys,
51  THREAD_ID tid);
52 
53  virtual ~MooseVariableDataBase() = default;
54 
58  virtual bool isNodal() const = 0;
59 
63  virtual bool hasDoFsOnNodes() const = 0;
64 
68  virtual libMesh::FEContinuity getContinuity() const = 0;
69 
74  const FieldVariableValue & sln(Moose::SolutionState state) const;
75 
81 
86  unsigned int oldestSolutionStateRequested() const;
87 
91  void setNodalValue(const OutputType & value, unsigned int idx = 0);
92 
97 
102 
106  void prepareIC();
107 
109 
110  const DoFValue & dofValues() const;
111  const DoFValue & dofValuesOld() const;
112  const DoFValue & dofValuesOlder() const;
113  const DoFValue & dofValuesPreviousNL() const;
114 
116 
117  const OutputType & nodalValue(Moose::SolutionState state) const;
119 
121 
122  const FieldVariableValue & vectorTagValue(TagID tag) const;
123  const FieldVariableGradient & vectorTagGradient(TagID tag) const;
124  const FieldVariableValue & matrixTagValue(TagID tag) const;
125  const DoFValue & nodalVectorTagValue(TagID tag) const;
126  const DoFValue & nodalMatrixTagValue(TagID tag) const;
127  const DoFValue & vectorTagDofValue(TagID tag) const;
128  const DoFValue & vectorTagDofValue(Moose::SolutionState state) const;
129 
135  void setActiveTags(const std::set<TagID> & vtags);
136 
140  void prepareAux() { _has_dof_values = false; }
141 
145  void sizeMatrixTagData();
146 
147 protected:
151  virtual const MooseVariableField<OutputType> & var() const { return _var; }
152 
156  void insertSolutionTag(TagID tag_id);
157 
161  void needSolutionState(unsigned int state);
162 
166  void fetchDoFValues();
167  void zeroSizeDofValues();
169  unsigned int n,
170  MooseArray<RealEigenVector> & dof_values) const;
171  void assignNodalValue();
172 
178  template <typename ReturnType, typename Functor>
179  const ReturnType & stateToTagHelper(Moose::SolutionState state, Functor functor);
180 
184  void resizeVectorTagData(TagID tag);
185 
189 
192 
195 
198 
200  unsigned int _count;
201 
205 
207  unsigned int _max_state;
208 
211 
214 
217 
220 
222  std::vector<dof_id_type> _dof_indices;
223 
224  mutable std::vector<bool> _need_vector_tag_dof_u;
225  mutable std::vector<bool> _need_matrix_tag_dof_u;
226 
227  // Dof values of tagged vectors
228  std::vector<DoFValue> _vector_tags_dof_u;
229  // Dof values of the diagonal of tagged matrices
230  std::vector<DoFValue> _matrix_tags_dof_u;
231 
232  std::vector<FieldVariableValue> _vector_tag_u;
233  mutable std::vector<bool> _need_vector_tag_u;
234  std::vector<FieldVariableGradient> _vector_tag_grad;
235  mutable std::vector<bool> _need_vector_tag_grad;
236  std::vector<FieldVariableValue> _matrix_tag_u;
237  mutable std::vector<bool> _need_matrix_tag_u;
238 
240  OutputType _nodal_value;
241  OutputType _nodal_value_old;
242  OutputType _nodal_value_older;
244 
249 
251  mutable bool _need_u_dot;
252  mutable bool _need_u_dotdot;
253  mutable bool _need_u_dot_old;
254  mutable bool _need_u_dotdot_old;
255  mutable bool _need_du_dot_du;
256  mutable bool _need_du_dotdot_du;
257 
259  mutable bool _need_grad_dot;
260  mutable bool _need_grad_dotdot;
261 
263  mutable bool _need_dof_values_dot;
267  mutable bool _need_dof_du_dot_du;
269 
283 
285  OutputType _nodal_value_dot;
292 
294  std::set<TagID> _required_vector_tags;
295 
297  std::set<TagID> _solution_tags;
298 
299 private:
302 };
303 
304 template <>
306 
307 template <>
309 
310 template <typename OutputType>
311 void
313 {
314  _required_vector_tags = _solution_tags;
315  for (const auto tag : vtags)
316  _required_vector_tags.insert(tag);
317 
318  if (!_required_vector_tags.empty())
319  {
320  const auto largest_tag_id = *_required_vector_tags.rbegin();
321  if (largest_tag_id >= _need_vector_tag_dof_u.size())
322  resizeVectorTagData(largest_tag_id);
323  }
324 }
325 
326 template <typename OutputType>
327 void
329 {
330  _solution_tags.insert(tag_id);
331  _required_vector_tags.insert(tag_id);
332 }
Moose::DOFType< OutputType >::type OutputData
std::vector< DoFValue > _matrix_tags_dof_u
bool _need_grad_dot
gradient dot flags
const libMesh::DofMap & _dof_map
The degree of freedom map from libMesh.
DoFValue _dof_values_dotdot
second time derivative of the solution values
unsigned int TagID
Definition: MooseTypes.h:210
void resizeVectorTagData(TagID tag)
resize the vector tag need flags and data containers to accomodate this tag index ...
const FieldVariableValue & matrixTagValue(TagID tag) const
void prepareIC()
prepare the initial condition
std::vector< FieldVariableValue > _matrix_tag_u
Class for stuff related to variables.
const ReturnType & stateToTagHelper(Moose::SolutionState state, Functor functor)
Helper method that converts a SolutionState argument into a corresponding tag ID, potentially request...
void sizeMatrixTagData()
size matrix tag data
void prepareAux()
Clear aux state.
const FieldVariableGradient & vectorTagGradient(TagID tag) const
OutputType type
Definition: MooseTypes.h:269
MooseArray< OutputData > DoFValue
void fetchDoFValues()
Helper methods for assigning dof values from their corresponding solution values. ...
const MooseArray< OutputType > & nodalValueArray(Moose::SolutionState state) const
std::vector< bool > _need_vector_tag_u
MooseArray< OutputGradient > FieldVariableGradient
void getArrayDoFValues(const libMesh::NumericVector< libMesh::Number > &sol, unsigned int n, MooseArray< RealEigenVector > &dof_values) const
virtual ~MooseVariableDataBase()=default
DoFValue _dof_values_dotdot_old
the previous time step&#39;s solution value second time derivative
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const SubProblem & _subproblem
The subproblem which we can query for information related to tagged vectors and matrices.
void setActiveTags(const std::set< TagID > &vtags)
Set the active vector tags.
Base class for a system (of equations)
Definition: SystemBase.h:84
const DoFValue & nodalVectorTagValue(TagID tag) const
std::vector< bool > _need_vector_tag_grad
libMesh::TensorTools::DecrementRank< OutputType >::type OutputDivergence
std::vector< bool > _need_vector_tag_dof_u
DoFValue _dof_values_dot
time derivative of the solution values
MooseArray< libMesh::Number > _dof_du_dot_du
derivatives of the solution value time derivative with respect to the degrees of freedom ...
void add(libMesh::NumericVector< libMesh::Number > &residual)
Add the current local DOF values to the input vector.
OutputType _nodal_value
Nodal values.
const DoFValue & dofValues() const
void setNodalValue(const OutputType &value, unsigned int idx=0)
Set nodal value.
MooseArray< libMesh::Number > _dof_du_dotdot_du
derivatives of the solution value second time derivative with respect to the degrees of freedom ...
std::set< TagID > _solution_tags
The set of solution tags we need to evaluate.
void insert(libMesh::NumericVector< libMesh::Number > &residual)
Set the current local DOF values to the input vector.
const FieldVariableGradient & gradSln(Moose::SolutionState state) const
Local solution gradient getter.
DoFValue _dof_values_dot_old
the previous time step&#39;s solution value time derivative
FunctorEnvelope< T > Functor
MooseArray< OutputType > _nodal_value_array
Nodal values as MooseArrays for use with AuxKernels.
virtual const MooseVariableField< OutputType > & var() const
std::vector< DoFValue > _vector_tags_dof_u
TagID _older_solution_tag
The vector tag ID corresponding to the older solution vector.
const OutputType & nodalValue(Moose::SolutionState state) const
std::set< TagID > _required_vector_tags
The set of vector tags (residual + solution) we need to evaluate.
void insertSolutionTag(TagID tag_id)
insert a solution tag into our tag containers
bool _has_dof_values
Whether we currently have degree of freedom values stored in our local containers (corresponding to t...
OutputType _nodal_value_dotdot
nodal values of u_dotdot
MooseArray< OutputType > FieldVariableValue
MooseVariableDataBase(const MooseVariableField< OutputType > &var, SystemBase &sys, THREAD_ID tid)
TagID _solution_tag
The vector tag ID corresponding to the solution vector.
OutputType _nodal_value_dot_old
nodal values of u_dot_old
const DoFValue & dofValuesOlder() const
MooseArray< OutputType > _nodal_value_old_array
std::vector< bool > _need_matrix_tag_u
OutputType _nodal_value_dotdot_old
nodal values of u_dotdot_old
libMesh::TensorTools::IncrementRank< OutputType >::type OutputGradient
const FieldVariableValue & vectorTagValue(TagID tag) const
virtual bool isNodal() const =0
TagID _old_solution_tag
The vector tag ID corresponding to the old solution vector.
const DoFValue & dofValuesPreviousNL() const
virtual libMesh::FEContinuity getContinuity() const =0
Return the variable continuity.
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
std::vector< bool > _need_matrix_tag_dof_u
const DoFValue & nodalMatrixTagValue(TagID tag) const
OutputType _nodal_value_dot
nodal values of u_dot
SolutionState
Definition: MooseTypes.h:233
std::vector< FieldVariableGradient > _vector_tag_grad
SystemBase & _sys
The MOOSE system which ultimately holds the vectors and matrices relevant to this variable data...
unsigned int _count
Number of components of the associated variable.
const FieldVariableValue & sln(Moose::SolutionState state) const
Local solution getter.
const DoFValue & dofValuesOld() const
TagID _previous_nl_solution_tag
The vector tag ID corresponding to the previous nonlinear iteration&#39;s solution vector.
bool _need_dof_values_dot
local solution flags
const THREAD_ID _tid
The thread ID that this object is on.
MooseArray< OutputType > _nodal_value_older_array
libMesh::TensorTools::IncrementRank< OutputGradient >::type OutputSecond
void needSolutionState(unsigned int state)
Request that we have at least state number of older solution states/vectors.
std::vector< FieldVariableValue > _vector_tag_u
std::vector< dof_id_type > _dof_indices
The dof indices for the current element.
const MooseVariableField< OutputType > & _var
A const reference to the owning MooseVariableField object.
unsigned int _max_state
The maximum number of older solution states our variable needs.
virtual bool hasDoFsOnNodes() const =0
Whether this data is associated with a variable that has DoFs on nodes.
unsigned int oldestSolutionStateRequested() const
The oldest solution state that is requested for this variable (0 = current, 1 = old, 2 = older, etc).
const DoFValue & vectorTagDofValue(TagID tag) const
unsigned int THREAD_ID
Definition: MooseTypes.h:209