https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
23template <typename>
25class SubProblem;
26class SystemBase;
27namespace libMesh
28{
29class DofMap;
30}
31
32template <typename OutputType>
34{
35public:
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
50
52 SystemBase & sys,
53 THREAD_ID tid);
54
55 virtual ~MooseVariableDataBase() = default;
56
60 virtual bool isNodal() const = 0;
61
65 virtual bool hasDoFsOnNodes() const = 0;
66
71
76 const FieldVariableValue & sln(Moose::SolutionState state) const;
77
83
88 unsigned int oldestSolutionStateRequested() const;
89
93 void setNodalValue(const OutputType & value, unsigned int idx = 0);
94
99
104
108 void prepareIC();
109
111
112 const DofValues & dofValues() const;
113 const DofValues & dofValuesOld() const;
114 const DofValues & dofValuesOlder() const;
115 const DofValues & dofValuesPreviousNL() const;
116
118
119 const OutputType & nodalValue(Moose::SolutionState state) const;
121
123
124 const FieldVariableValue & vectorTagValue(TagID tag) const;
126 const FieldVariableValue & matrixTagValue(TagID tag) const;
127 const DofValues & nodalVectorTagValue(TagID tag) const;
128 const DofValues & nodalMatrixTagValue(TagID tag) const;
129 const DofValues & vectorTagDofValue(TagID tag) const;
131
137 void setActiveTags(const std::set<TagID> & vtags);
138
142 void prepareAux() { _has_dof_values = false; }
143
147 void sizeMatrixTagData();
148
149protected:
153 virtual const MooseVariableField<OutputType> & var() const { return _var; }
154
158 void insertSolutionTag(TagID tag_id);
159
163 void needSolutionState(unsigned int state);
164
168 void fetchDofValues();
169 void zeroSizeDofValues();
171 unsigned int n,
172 MooseArray<RealEigenVector> & dof_values) const;
173 void assignNodalValue();
174
180 template <typename ReturnType, typename Functor>
181 const ReturnType & stateToTagHelper(Moose::SolutionState state, Functor functor);
182
186 void resizeVectorTagData(TagID tag);
187
191
194
197
200
202 unsigned int _count;
203
207
209 unsigned int _max_state;
210
213
216
219
222
224 std::vector<dof_id_type> _dof_indices;
225
226 mutable std::vector<bool> _need_vector_tag_dof_u;
227 mutable std::vector<bool> _need_matrix_tag_dof_u;
228
229 // Dof values of tagged vectors
230 std::vector<DofValues> _vector_tags_dof_u;
231 // Dof values of the diagonal of tagged matrices
232 std::vector<DofValues> _matrix_tags_dof_u;
233
234 std::vector<FieldVariableValue> _vector_tag_u;
235 mutable std::vector<bool> _need_vector_tag_u;
236 std::vector<FieldVariableGradient> _vector_tag_grad;
237 mutable std::vector<bool> _need_vector_tag_grad;
238 std::vector<FieldVariableValue> _matrix_tag_u;
239 mutable std::vector<bool> _need_matrix_tag_u;
240
242 OutputType _nodal_value;
246
251
253 mutable bool _need_u_dot;
254 mutable bool _need_u_dotdot;
255 mutable bool _need_u_dot_old;
256 mutable bool _need_u_dotdot_old;
257 mutable bool _need_du_dot_du;
258 mutable bool _need_du_dotdot_du;
259
261 mutable bool _need_grad_dot;
262 mutable bool _need_grad_dotdot;
263
271
285
294
296 std::set<TagID> _required_vector_tags;
297
299 std::set<TagID> _solution_tags;
300
301private:
304};
305
306template <>
308
309template <>
311
312template <typename OutputType>
313void
315{
316 _required_vector_tags = _solution_tags;
317 for (const auto tag : vtags)
318 _required_vector_tags.insert(tag);
319
320 if (!_required_vector_tags.empty())
321 {
322 const auto largest_tag_id = *_required_vector_tags.rbegin();
323 if (largest_tag_id >= _need_vector_tag_dof_u.size())
324 resizeVectorTagData(largest_tag_id);
325 }
326}
327
328template <typename OutputType>
329void
331{
332 _solution_tags.insert(tag_id);
333 _required_vector_tags.insert(tag_id);
334}
unsigned int TagID
Definition MooseTypes.h:238
unsigned int THREAD_ID
Definition MooseTypes.h:237
forward declarations
Definition MooseArray.h:18
OutputType _nodal_value_dotdot
nodal values of u_dotdot
MooseArray< OutputGradient > FieldVariableGradient
libMesh::TensorTools::IncrementRank< OutputType >::type OutputGradient
std::vector< dof_id_type > _dof_indices
The dof indices for the current element.
OutputType _nodal_value_dot_old
nodal values of u_dot_old
bool _need_dof_values_dot
local solution flags
void resizeVectorTagData(TagID tag)
resize the vector tag need flags and data containers to accomodate this tag index
std::vector< FieldVariableValue > _vector_tag_u
TagID _previous_nl_solution_tag
The vector tag ID corresponding to the previous nonlinear iteration's solution vector.
const FieldVariableValue & vectorTagValue(TagID tag) const
DofValues _dof_values_dotdot
second time derivative of the solution values
TagID _old_solution_tag
The vector tag ID corresponding to the old solution vector.
SystemBase & _sys
The MOOSE system which ultimately holds the vectors and matrices relevant to this variable data.
void insert(libMesh::NumericVector< libMesh::Number > &residual)
Set the current local DOF values to the input vector.
std::vector< FieldVariableValue > _matrix_tag_u
void prepareAux()
Clear aux state.
const DofValues & nodalMatrixTagValue(TagID tag) const
void setActiveTags(const std::set< TagID > &vtags)
Set the active vector tags.
std::vector< bool > _need_matrix_tag_u
Moose::DOFType< OutputType >::type DofValue
const DofValues & dofValuesOlder() const
virtual ~MooseVariableDataBase()=default
void fetchDofValues()
Helper methods for assigning dof values from their corresponding solution values.
libMesh::TensorTools::IncrementRank< OutputGradient >::type OutputSecond
unsigned int _max_state
The maximum number of older solution states our variable needs.
unsigned int oldestSolutionStateRequested() const
The oldest solution state that is requested for this variable (0 = current, 1 = old,...
const libMesh::DofMap & _dof_map
The degree of freedom map from libMesh.
const OutputType & nodalValue(Moose::SolutionState state) const
OutputType _nodal_value_dotdot_old
nodal values of u_dotdot_old
std::vector< DofValues > _vector_tags_dof_u
const MooseArray< OutputType > & nodalValueArray(Moose::SolutionState state) const
const MooseVariableField< OutputType > & _var
A const reference to the owning MooseVariableField object.
libMesh::TensorTools::DecrementRank< OutputType >::type OutputDivergence
const FieldVariableValue & sln(Moose::SolutionState state) const
Local solution getter.
TagID _solution_tag
The vector tag ID corresponding to the solution vector.
const DofValues & nodalVectorTagValue(TagID tag) const
void setNodalValue(const OutputType &value, unsigned int idx=0)
Set nodal value.
std::vector< bool > _need_matrix_tag_dof_u
const DofValues & dofValuesPreviousNL() const
std::vector< DofValues > _matrix_tags_dof_u
const FieldVariableGradient & gradSln(Moose::SolutionState state) const
Local solution gradient getter.
TagID _older_solution_tag
The vector tag ID corresponding to the older solution vector.
std::vector< bool > _need_vector_tag_u
const FieldVariableGradient & vectorTagGradient(TagID tag) const
DofValues _dof_values_dot_old
the previous time step's solution value time derivative
MooseArray< OutputType > FieldVariableValue
DofValues _dof_values_dot
time derivative of the solution values
MooseArray< OutputType > _nodal_value_old_array
MooseArray< libMesh::Number > _dof_du_dotdot_du
derivatives of the solution value second time derivative with respect to the degrees of freedom
std::vector< FieldVariableGradient > _vector_tag_grad
Moose::ADType< DofValue >::type ADDofValue
std::set< TagID > _solution_tags
The set of solution tags we need to evaluate.
const DofValues & vectorTagDofValue(TagID tag) const
MooseArray< DofValue > DofValues
const DofValues & dofValuesOld() const
DofValues _dof_values_dotdot_old
the previous time step's solution value second time derivative
void getArrayDofValues(const libMesh::NumericVector< libMesh::Number > &sol, unsigned int n, MooseArray< RealEigenVector > &dof_values) const
void insertSolutionTag(TagID tag_id)
insert a solution tag into our tag containers
virtual const MooseVariableField< OutputType > & var() const
MooseArray< OutputType > _nodal_value_array
Nodal values as MooseArrays for use with AuxKernels.
void needSolutionState(unsigned int state)
Request that we have at least state number of older solution states/vectors.
MooseArray< ADDofValue > ADDofValues
const DofValues & dofValues() const
OutputType _nodal_value
Nodal values.
std::set< TagID > _required_vector_tags
The set of vector tags (residual + solution) we need to evaluate.
virtual bool isNodal() const =0
void sizeMatrixTagData()
size matrix tag data
const THREAD_ID _tid
The thread ID that this object is on.
std::vector< bool > _need_vector_tag_dof_u
void prepareIC()
prepare the initial condition
const FieldVariableValue & matrixTagValue(TagID tag) const
bool _need_grad_dot
gradient dot flags
virtual libMesh::FEContinuity getContinuity() const =0
Return the variable continuity.
unsigned int _count
Number of components of the associated variable.
OutputType _nodal_value_dot
nodal values of u_dot
const SubProblem & _subproblem
The subproblem which we can query for information related to tagged vectors and matrices.
MooseArray< OutputType > _nodal_value_older_array
void add(libMesh::NumericVector< libMesh::Number > &residual)
Add the current local DOF values to the input vector.
const ReturnType & stateToTagHelper(Moose::SolutionState state, Functor functor)
Helper method that converts a SolutionState argument into a corresponding tag ID, potentially request...
virtual bool hasDoFsOnNodes() const =0
Whether this data is associated with a variable that has DoFs on nodes.
bool _has_dof_values
Whether we currently have degree of freedom values stored in our local containers (corresponding to t...
MooseArray< libMesh::Number > _dof_du_dot_du
derivatives of the solution value time derivative with respect to the degrees of freedom
std::vector< bool > _need_vector_tag_grad
Class for stuff related to variables.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
Base class for a system (of equations)
Definition SystemBase.h:87
SolutionState
Definition MooseTypes.h:262
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
OutputType type
Definition MooseTypes.h:302