https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
20
21#include "libmesh/fe_type.h"
22#include "libmesh/enum_fe_family.h"
23
24// libMesh forward declarations
25namespace libMesh
26{
27class DofMap;
28class Variable;
29}
30
31class Assembly;
32class SubProblem;
33class SystemBase;
34class MooseMesh;
35
44 public BlockRestrictable,
45 public OutputInterface,
46 public SetupInterface
47{
48public:
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 const std::set<SubdomainID> & activeSubdomains() const;
81
87 bool activeOnSubdomain(SubdomainID subdomain) const;
88
94 bool activeOnSubdomains(const std::set<SubdomainID> & subdomains) const;
95
99 bool useDual() const { return _use_dual; }
100
104 const std::vector<dof_id_type> & allDofIndices() const;
105 unsigned int totalVarDofs() { return allDofIndices().size(); }
106
111
115 void scalingFactor(const std::vector<Real> & factor);
116
120 Real scalingFactor() const { return _scaling_factor[0]; }
121 const std::vector<Real> & arrayScalingFactor() const { return _scaling_factor; }
122
127 libMesh::Order order() const;
128
133 unsigned int count() const { return _count; }
134
139 virtual bool isNodal() const { mooseError("Base class cannot determine this"); }
140
145 virtual bool hasDoFsOnNodes() const { mooseError("Base class cannot determine this"); };
146
151 virtual bool supportsQpBasedLoops() const;
152
157 virtual bool supportsGeometricInfoBasedLoops() const;
158
163 {
164 mooseError("Base class cannot determine this");
165 };
166
170 const libMesh::DofMap & dofMap() const { return _dof_map; }
171
172 virtual void getDofIndices(const Elem * /*elem*/,
173 std::vector<dof_id_type> & /*dof_indices*/) const
174 {
175 mooseError("not implemented");
176 };
177
181 virtual const std::vector<dof_id_type> & dofIndices() const { return _dof_indices; }
182
186 std::vector<dof_id_type> componentDofIndices(const std::vector<dof_id_type> & dof_indices,
187 unsigned int component) const;
188
192 virtual unsigned int numberOfDofs() const { return _dof_indices.size(); }
193
197 bool eigen() const { return _is_eigen; }
198
202 void eigen(bool eigen) { _is_eigen = eigen; }
203
204 void initialSetup() override;
205
206 virtual void clearAllDofIndices() { _dof_indices.clear(); }
207
213 virtual void setActiveTags(const std::set<TagID> & vtags);
214
218 virtual bool isArray() const { return !_array_var_component_names.empty(); }
219
223 virtual void sizeMatrixTagData() { mooseError("Derived class must implement this method"); }
224
225protected:
230
234 bool doDerivatives() const;
235
238
241
243 unsigned int _var_num;
244
246 unsigned int _index;
247
250
253
256
259
262
265
267 std::vector<dof_id_type> _dof_indices;
268
271
274
276 const unsigned int _count;
277
279 std::vector<Real> _scaling_factor;
280
283
286
288 std::vector<std::string> _array_var_component_names;
289};
290
291inline void
292MooseVariableBase::setActiveTags(const std::set<TagID> &)
293{
294 mooseError("setActiveTags must be overridden in derived classes.");
295}
296
297#define usingMooseVariableBaseMembers \
298 using MooseVariableBase::_sys; \
299 using MooseVariableBase::_fe_type; \
300 using MooseVariableBase::_var_num; \
301 using MooseVariableBase::_index; \
302 using MooseVariableBase::_var_kind; \
303 using MooseVariableBase::_subproblem; \
304 using MooseVariableBase::_variable; \
305 using MooseVariableBase::_assembly; \
306 using MooseVariableBase::_dof_map; \
307 using MooseVariableBase::_dof_indices; \
308 using MooseVariableBase::_mesh; \
309 using MooseVariableBase::_tid; \
310 using MooseVariableBase::_count; \
311 using MooseVariableBase::_scaling_factor
subdomain_id_type SubdomainID
unsigned int THREAD_ID
Definition MooseTypes.h:237
Keeps track of stuff related to assembling.
Definition Assembly.h:101
An interface that restricts an object to subdomains via the 'blocks' input parameter.
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
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
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
Base variable class.
Moose::VarKindType _var_kind
Variable type (see MooseTypes.h)
virtual bool supportsGeometricInfoBasedLoops() const
Whether this variable supports geometric-info-based loops, such as ElemInfo/FaceInfo loops.
unsigned int _var_num
variable number (from libMesh)
const libMesh::Variable & _variable
libMesh variable object for this variable
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.
unsigned int _index
variable number within MOOSE
bool activeOnSubdomains(const std::set< SubdomainID > &subdomains) const
Is the variable active on the subdomains?
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
const libMesh::DofMap & dofMap() const
The DofMap associated with the system this variable is in.
virtual bool hasDoFsOnNodes() const
Does this variable have DoFs on nodes.
const libMesh::FEType & feType() const
Get the type of finite element object.
unsigned int totalVarDofs()
bool _use_dual
If dual mortar approach is used.
std::vector< std::string > _array_var_component_names
Array variable names when the variable is an array variable.
const std::vector< Real > & arrayScalingFactor() const
Real scalingFactor() const
Get the scaling factor for this variable.
virtual bool isArray() const
SubProblem & _subproblem
Problem this variable is part of.
libMesh::FEType _fe_type
The FEType associated with this variable.
bool useDual() const
Get dual mortar option.
bool eigen() const
Whether or not this variable operates on an eigen kernel.
static InputParameters validParams()
THREAD_ID _tid
Thread ID.
virtual bool isNodal() const
Is this variable nodal.
MooseMesh & _mesh
mesh the variable is active in
const std::set< SubdomainID > & activeSubdomains() const
The subdomains the variable is active on.
bool doDerivatives() const
virtual libMesh::FEContinuity getContinuity() const
Return the continuity of this variable.
bool _is_eigen
Whether or not this variable operates on eigen kernels.
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
bool _is_lower_d
Whether this variable lives on lower dimensional blocks.
const SystemBase & sys() const
Get the system this variable is part of.
const libMesh::NumericVector< libMesh::Number > & getSolution(const Moose::StateArg &state) const
Get the solution corresponding to the provided state.
virtual void sizeMatrixTagData()
Size data structures related to matrix tagging.
virtual unsigned int numberOfDofs() const
Get the number of local DoFs.
virtual void setActiveTags(const std::set< TagID > &vtags)
Set the active vector tags.
SystemBase & sys()
Get the system this variable is part of.
const std::string & arrayVariableComponent(const unsigned int i) const
Returns the variable name of a component of an array variable.
const std::vector< dof_id_type > & allDofIndices() const
Get all global dofindices for the variable.
std::vector< Real > _scaling_factor
scaling factor for this variable
const unsigned int _count
Number of variables in the array.
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int.
virtual void clearAllDofIndices()
Assembly & _assembly
Assembly data.
virtual void getDofIndices(const Elem *, std::vector< dof_id_type > &) const
const libMesh::DofMap & _dof_map
DOF map.
std::vector< dof_id_type > _dof_indices
DOF indices.
Moose::VarKindType kind() const
Kind of the variable (Nonlinear, Auxiliary, ...)
void eigen(bool eigen)
Mark this variable as an eigen var or non-eigen var.
SystemBase & _sys
System this variable is part of.
unsigned int number() const
Get variable number coming from libMesh.
bool activeOnSubdomain(SubdomainID subdomain) const
Is the variable active on the subdomain?
virtual bool supportsQpBasedLoops() const
Whether this variable supports QP-indexed loops.
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.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
Base class for a system (of equations)
Definition SystemBase.h:87
VarKindType
Framework-wide stuff.
Definition MooseTypes.h:769
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
State argument for evaluating functors.