www.mooseframework.org
MooseVariableBase.C
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 #include "MooseVariableBase.h"
11 #include "SubProblem.h"
12 #include "SystemBase.h"
13 #include "MooseMesh.h"
14 
15 #include "libmesh/variable.h"
16 #include "libmesh/dof_map.h"
17 #include "libmesh/system.h"
18 
20  const FEType & fe_type,
21  SystemBase & sys,
22  Moose::VarKindType var_kind,
23  THREAD_ID tid)
24  : _var_num(var_num),
25  _fe_type(fe_type),
26  _var_kind(var_kind),
27  _subproblem(sys.subproblem()),
28  _sys(sys),
29  _variable(sys.system().variable(_var_num)),
30  _dof_map(sys.dofMap()),
31  _mesh(_subproblem.mesh()),
32  _scaling_factor(1.0),
33  _tid(tid)
34 {
35 }
36 
38 
39 const std::string &
41 {
42  return _sys.system().variable(_var_num).name();
43 }
44 
45 const std::vector<dof_id_type> &
47 {
48  const auto it = _sys.subproblem()._var_dof_map.find(name());
49  if (it != _sys.subproblem()._var_dof_map.end())
50  return it->second;
51  else
52  mooseError("VariableAllDoFMap not prepared for ",
53  name(),
54  " . Check nonlocal coupling requirement for the variable.");
55 }
56 
57 Order
59 {
60  return _fe_type.order;
61 }
FEType _fe_type
The FEType associated with this variable.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
Base class for a system (of equations)
Definition: SystemBase.h:92
std::map< std::string, std::vector< dof_id_type > > _var_dof_map
Definition: SubProblem.h:563
virtual ~MooseVariableBase()
nl system()
SystemBase & _sys
System this variable is part of.
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:481
virtual SubProblem & subproblem()
Definition: SystemBase.h:105
virtual System & system()=0
Get the reference to the libMesh system.
Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
MooseVariableBase(unsigned int var_num, const FEType &fe_type, SystemBase &sys, Moose::VarKindType var_kind, THREAD_ID tid)
const std::string & name() const
Get the variable name.
const std::vector< dof_id_type > & allDofIndices() const
Get all global dofindices for the variable.
unsigned int _var_num
variable number (from libMesh)
unsigned int THREAD_ID
Definition: MooseTypes.h:161