https://mooseframework.inl.gov
MooseVariableBase.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 "MooseObject.h"
13 #include "BlockRestrictable.h"
14 #include "OutputInterface.h"
15 #include "SetupInterface.h"
16 #include "MooseTypes.h"
17 #include "MooseArray.h"
18 #include "MooseError.h"
19 #include "MooseFunctorArguments.h"
20 
21 #include "libmesh/fe_type.h"
22 #include "libmesh/enum_fe_family.h"
23 
24 // libMesh forward declarations
25 namespace libMesh
26 {
27 class DofMap;
28 class Variable;
29 }
30 
31 class Assembly;
32 class SubProblem;
33 class SystemBase;
34 class MooseMesh;
35 
44  public BlockRestrictable,
45  public OutputInterface,
46  public SetupInterface
47 {
48 public:
50 
52 
54  const std::string & arrayVariableComponent(const unsigned int i) const;
55 
60  unsigned int number() const { return _var_num; }
61 
65  const libMesh::FEType & feType() const { return _fe_type; }
66 
70  SystemBase & sys() { return _sys; }
71 
75  const SystemBase & sys() const { return _sys; }
76 
80  bool useDual() const { return _use_dual; }
81 
85  const std::vector<dof_id_type> & allDofIndices() const;
86  unsigned int totalVarDofs() { return allDofIndices().size(); }
87 
91  Moose::VarKindType kind() const { return _var_kind; }
92 
96  void scalingFactor(const std::vector<Real> & factor);
97 
101  Real scalingFactor() const { return _scaling_factor[0]; }
102  const std::vector<Real> & arrayScalingFactor() const { return _scaling_factor; }
103 
108  libMesh::Order order() const;
109 
114  unsigned int count() const { return _count; }
115 
120  virtual bool isNodal() const { mooseError("Base class cannot determine this"); }
121 
126  virtual bool hasDoFsOnNodes() const { mooseError("Base class cannot determine this"); };
127 
132  {
133  mooseError("Base class cannot determine this");
134  };
135 
139  const libMesh::DofMap & dofMap() const { return _dof_map; }
140 
141  virtual void getDofIndices(const Elem * /*elem*/,
142  std::vector<dof_id_type> & /*dof_indices*/) const
143  {
144  mooseError("not implemented");
145  };
146 
150  virtual const std::vector<dof_id_type> & dofIndices() const { return _dof_indices; }
151 
155  std::vector<dof_id_type> componentDofIndices(const std::vector<dof_id_type> & dof_indices,
156  unsigned int component) const;
157 
161  virtual unsigned int numberOfDofs() const { return _dof_indices.size(); }
162 
166  bool eigen() const { return _is_eigen; }
167 
171  void eigen(bool eigen) { _is_eigen = eigen; }
172 
173  void initialSetup() override;
174 
175  virtual void clearAllDofIndices() { _dof_indices.clear(); }
176 
182  virtual void setActiveTags(const std::set<TagID> & vtags);
183 
187  virtual bool isArray() const { return !_array_var_component_names.empty(); }
188 
192  bool isLowerD() const { return _is_lower_d; }
193 
197  virtual void sizeMatrixTagData() { mooseError("Derived class must implement this method"); }
198 
199 protected:
204 
208  bool doDerivatives() const;
209 
212 
215 
217  unsigned int _var_num;
218 
220  unsigned int _index;
221 
223  bool _is_eigen;
224 
227 
230 
233 
236 
239 
241  std::vector<dof_id_type> _dof_indices;
242 
245 
248 
250  const unsigned int _count;
251 
253  std::vector<Real> _scaling_factor;
254 
256  bool _use_dual;
257 
260 
262  std::vector<std::string> _array_var_component_names;
263 };
264 
265 inline void
266 MooseVariableBase::setActiveTags(const std::set<TagID> &)
267 {
268  mooseError("setActiveTags must be overridden in derived classes.");
269 }
270 
271 #define usingMooseVariableBaseMembers \
272  using MooseVariableBase::_sys; \
273  using MooseVariableBase::_fe_type; \
274  using MooseVariableBase::_var_num; \
275  using MooseVariableBase::_index; \
276  using MooseVariableBase::_var_kind; \
277  using MooseVariableBase::_subproblem; \
278  using MooseVariableBase::_variable; \
279  using MooseVariableBase::_assembly; \
280  using MooseVariableBase::_dof_map; \
281  using MooseVariableBase::_dof_indices; \
282  using MooseVariableBase::_mesh; \
283  using MooseVariableBase::_tid; \
284  using MooseVariableBase::_count; \
285  using MooseVariableBase::_scaling_factor
bool _use_dual
If dual mortar approach is used.
static InputParameters validParams()
const libMesh::NumericVector< libMesh::Number > & getSolution(const Moose::StateArg &state) const
Get the solution corresponding to the provided state.
virtual bool isNodal() const
Is this variable nodal.
std::vector< dof_id_type > componentDofIndices(const std::vector< dof_id_type > &dof_indices, unsigned int component) const
Obtain DoF indices of a component with the indices of the 0th component.
virtual void clearAllDofIndices()
const libMesh::FEType & feType() const
Get the type of finite element object.
virtual unsigned int numberOfDofs() const
Get the number of local DoFs.
Keeps track of stuff related to assembling.
Definition: Assembly.h:109
const std::vector< Real > & arrayScalingFactor() const
unsigned int number() const
Get variable number coming from libMesh.
virtual libMesh::FEContinuity getContinuity() const
Return the continuity of this variable.
const libMesh::DofMap & dofMap() const
The DofMap associated with the system this variable is in.
std::vector< std::string > _array_var_component_names
Array variable names when the variable is an array variable.
bool _is_lower_d
Whether this variable lives on lower dimensional blocks.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
const SystemBase & sys() const
Get the system this variable is part of.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one...
A class to provide an common interface to objects requiring "outputs" option.
virtual void sizeMatrixTagData()
Size data structures related to matrix tagging.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void getDofIndices(const Elem *, std::vector< dof_id_type > &) const
void eigen(bool eigen)
Mark this variable as an eigen var or non-eigen var.
unsigned int _index
variable number within MOOSE
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Base class for a system (of equations)
Definition: SystemBase.h:84
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
THREAD_ID _tid
Thread ID.
std::vector< dof_id_type > _dof_indices
DOF indices.
bool eigen() const
Whether or not this variable operates on an eigen kernel.
virtual bool hasDoFsOnNodes() const
Does this variable have DoFs on nodes.
bool _is_eigen
Whether or not this variable operates on eigen kernels.
const libMesh::DofMap & _dof_map
DOF map.
bool useDual() const
Get dual mortar option.
SubProblem & _subproblem
Problem this variable is part of.
libMesh::FEType _fe_type
The FEType associated with this variable.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:27
SystemBase & _sys
System this variable is part of.
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:715
std::vector< Real > _scaling_factor
scaling factor for this variable
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
virtual bool isArray() const
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
Moose::VarKindType _var_kind
Variable type (see MooseTypes.h)
Real scalingFactor() const
Get the scaling factor for this variable.
const unsigned int _count
Number of variables in the array.
MooseMesh & _mesh
mesh the variable is active in
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
Assembly & _assembly
Assembly data.
const libMesh::Variable & _variable
libMesh variable object for this variable
const std::vector< dof_id_type > & allDofIndices() const
Get all global dofindices for the variable.
unsigned int _var_num
variable number (from libMesh)
Moose::VarKindType kind() const
Kind of the variable (Nonlinear, Auxiliary, ...)
const std::string & arrayVariableComponent(const unsigned int i) const
Returns the variable name of a component of an array variable.
unsigned int totalVarDofs()
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:271
State argument for evaluating functors.
bool doDerivatives() const
SystemBase & sys()
Get the system this variable is part of.
MooseVariableBase(const InputParameters &parameters)
Base variable class.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
virtual void setActiveTags(const std::set< TagID > &vtags)
Set the active vector tags.