www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
MooseVariableScalar Class Reference

Class for scalar variables (they are different). More...

#include <MooseVariableScalar.h>

Inheritance diagram for MooseVariableScalar:
[legend]

Public Member Functions

 MooseVariableScalar (unsigned int var_num, const FEType &fe_type, SystemBase &sys, Assembly &assembly, Moose::VarKindType var_kind)
 
virtual ~MooseVariableScalar ()
 
void reinit ()
 
virtual bool isNodal () const override
 Is this variable nodal. More...
 
VariableValuesln ()
 
VariableValueslnOld ()
 
VariableValueslnOlder ()
 
VariableValueuDot ()
 
VariableValueduDotDu ()
 
void setValue (unsigned int i, Number value)
 Set the nodal value for this variable (to keep everything up to date. More...
 
void setValues (Number value)
 Set all of the values of this scalar variable to the same value. More...
 
void insert (NumericVector< Number > &soln)
 
unsigned int number () const
 Get variable number coming from libMesh. More...
 
const FEType & feType () const
 Get the type of finite element object. More...
 
SystemBasesys ()
 Get the system this variable is part of. More...
 
const std::string & name () const
 Get the variable name. More...
 
const std::vector< dof_id_type > & allDofIndices () const
 Get all global dofindices for the variable. More...
 
unsigned int totalVarDofs ()
 
Moose::VarKindType kind () const
 Kind of the variable (Nonlinear, Auxiliary, ...) More...
 
void scalingFactor (Real factor)
 Set the scaling factor for this variable. More...
 
Real scalingFactor () const
 Get the scaling factor for this variable. More...
 
Order order () const
 Get the order of this variable Note: Order enum can be implicitly converted to unsigned int. More...
 
const DofMap & dofMap () const
 The DofMap associated with the system this variable is in. More...
 
std::vector< dof_id_type > & dofIndices ()
 
const std::vector< dof_id_type > & dofIndices () const
 
unsigned int numberOfDofs ()
 

Protected Attributes

VariableValue _u
 The value of scalar variable. More...
 
VariableValue _u_old
 The old value of scalar variable. More...
 
VariableValue _u_older
 The older value of scalar variable. More...
 
VariableValue _u_dot
 
VariableValue _du_dot_du
 
unsigned int _var_num
 variable number (from libMesh) More...
 
FEType _fe_type
 The FEType associated with this variable. More...
 
unsigned int _index
 variable number within MOOSE More...
 
Moose::VarKindType _var_kind
 
SubProblem_subproblem
 Problem this variable is part of. More...
 
SystemBase_sys
 System this variable is part of. More...
 
const Variable & _variable
 libMesh variable object for this variable More...
 
Assembly_assembly
 Assembly data. More...
 
const DofMap & _dof_map
 DOF map. More...
 
std::vector< dof_id_type > _dof_indices
 DOF indices. More...
 
MooseMesh_mesh
 mesh the variable is active in More...
 
Real _scaling_factor
 scaling factor for this variable More...
 

Detailed Description

Class for scalar variables (they are different).

Definition at line 30 of file MooseVariableScalar.h.

Constructor & Destructor Documentation

MooseVariableScalar::MooseVariableScalar ( unsigned int  var_num,
const FEType &  fe_type,
SystemBase sys,
Assembly assembly,
Moose::VarKindType  var_kind 
)

Definition at line 28 of file MooseVariableScalar.C.

33  : MooseVariableBase(var_num, fe_type, sys, assembly, var_kind)
34 {
35 }
MooseVariableBase(unsigned int var_num, const FEType &fe_type, SystemBase &sys, Assembly &assembly, Moose::VarKindType var_kind)
MooseVariableScalar::~MooseVariableScalar ( )
virtual

Definition at line 37 of file MooseVariableScalar.C.

38 {
39  _u.release();
40  _u_old.release();
41  _u_older.release();
42 
43  _u_dot.release();
45 }
VariableValue _u
The value of scalar variable.
VariableValue _u_older
The older value of scalar variable.
void release()
Manually deallocates the data pointer.
Definition: MooseArray.h:56
VariableValue _u_old
The old value of scalar variable.

Member Function Documentation

const std::vector< dof_id_type > & MooseVariableBase::allDofIndices ( ) const
inherited

Get all global dofindices for the variable.

Definition at line 51 of file MooseVariableBase.C.

Referenced by FEProblemBase::addJacobianBlock(), NonlocalIntegratedBC::computeNonlocalJacobian(), NonlocalKernel::computeNonlocalJacobian(), NonlocalKernel::computeNonlocalOffDiagJacobian(), NonlocalIntegratedBC::computeNonlocalOffDiagJacobian(), FEProblemBase::prepare(), Assembly::prepareNonlocal(), and Assembly::prepareVariableNonlocal().

52 {
53  const auto it = _sys.subproblem()._var_dof_map.find(name());
54  if (it != _sys.subproblem()._var_dof_map.end())
55  return it->second;
56  else
57  mooseError("VariableAllDoFMap not prepared for ",
58  name(),
59  " . Check nonlocal coupling requirement for the variable.");
60 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
const std::string & name() const
Get the variable name.
std::map< std::string, std::vector< dof_id_type > > _var_dof_map
Definition: SubProblem.h:413
SystemBase & _sys
System this variable is part of.
virtual SubProblem & subproblem()
Definition: SystemBase.h:103
std::vector<dof_id_type>& MooseVariableBase::dofIndices ( )
inlineinherited
const std::vector<dof_id_type>& MooseVariableBase::dofIndices ( ) const
inlineinherited

Definition at line 114 of file MooseVariableBase.h.

114 { return _dof_indices; }
std::vector< dof_id_type > _dof_indices
DOF indices.
const DofMap& MooseVariableBase::dofMap ( ) const
inlineinherited

The DofMap associated with the system this variable is in.

Definition at line 110 of file MooseVariableBase.h.

Referenced by AuxScalarKernel::compute(), and ScalarVariable::getValue().

110 { return _dof_map; }
const DofMap & _dof_map
DOF map.
VariableValue& MooseVariableScalar::duDotDu ( )
inline

Definition at line 50 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDu().

50 { return _du_dot_du; }
const FEType& MooseVariableBase::feType ( ) const
inlineinherited
void MooseVariableScalar::insert ( NumericVector< Number > &  soln)

Definition at line 155 of file MooseVariableScalar.C.

Referenced by MultiAppPostprocessorToAuxScalarTransfer::execute().

156 {
157  // We may have redundantly computed this value on many different
158  // processors, but only the processor which actually owns it should
159  // be saving it to the solution vector, to avoid O(N_scalar_vars)
160  // unnecessary communication.
161 
162  const dof_id_type first_dof = _dof_map.first_dof();
163  const dof_id_type end_dof = _dof_map.end_dof();
164  if (_dof_indices.size() > 0 && first_dof <= _dof_indices[0] && _dof_indices[0] < end_dof)
165  soln.insert(&_u[0], _dof_indices);
166 }
const DofMap & _dof_map
DOF map.
VariableValue _u
The value of scalar variable.
std::vector< dof_id_type > _dof_indices
DOF indices.
bool MooseVariableScalar::isNodal ( ) const
overridevirtual

Is this variable nodal.

Returns
true if it nodal, otherwise false

Implements MooseVariableBase.

Definition at line 118 of file MooseVariableScalar.C.

119 {
120  // scalar variables are never nodal ;-)
121  return false;
122 }
Moose::VarKindType MooseVariableBase::kind ( ) const
inlineinherited

Kind of the variable (Nonlinear, Auxiliary, ...)

Definition at line 89 of file MooseVariableBase.h.

Referenced by ShapeUserObject< T >::coupled(), Coupleable::coupled(), AuxKernel::coupledDot(), AuxKernel::coupledDotDu(), and VariableResidual::VariableResidual().

89 { return _var_kind; }
Moose::VarKindType _var_kind
const std::string & MooseVariableBase::name ( ) const
inherited

Get the variable name.

Definition at line 45 of file MooseVariableBase.C.

Referenced by SetupResidualDebugAction::act(), InitialConditionWarehouse::addObject(), MooseVariableBase::allDofIndices(), BlockRestrictable::checkVariable(), MultiAppNearestNodeTransfer::execute(), MultiAppInterpolationTransfer::execute(), MultiAppUserObjectTransfer::execute(), MultiAppProjectionTransfer::execute(), MultiAppDTKUserObjectTransfer::execute(), GapValueAux::GapValueAux(), AuxKernel::getMaterialProperty(), AuxKernel::getMaterialPropertyOld(), AuxKernel::getMaterialPropertyOlder(), DerivativeMaterialInterface< T >::isNotKernelVariable(), MooseVariable::nodalValue(), MooseVariable::nodalValueDot(), MooseVariable::nodalValueDotNeighbor(), MooseVariable::nodalValueNeighbor(), MooseVariable::nodalValueOld(), MooseVariable::nodalValueOlder(), MooseVariable::nodalValueOlderNeighbor(), MooseVariable::nodalValueOldNeighbor(), MooseVariable::nodalValuePreviousNL(), MooseVariable::nodalValuePreviousNLNeighbor(), ParsedAux::ParsedAux(), ParsedODEKernel::ParsedODEKernel(), PiecewiseLinearInterpolationMaterial::PiecewiseLinearInterpolationMaterial(), MooseVariable::setNodalValueNeighbor(), ConstraintWarehouse::subdomainsCovered(), and MultiAppMeshFunctionTransfer::transferVariable().

46 {
47  return _sys.system().variable(_var_num).name();
48 }
SystemBase & _sys
System this variable is part of.
virtual System & system()=0
Get the reference to the libMesh system.
unsigned int _var_num
variable number (from libMesh)
unsigned int MooseVariableBase::number ( ) const
inlineinherited

Get variable number coming from libMesh.

Returns
the libmesh variable number

Definition at line 63 of file MooseVariableBase.h.

Referenced by AdaptivityAction::act(), Assembly::addJacobianOffDiagScalar(), Assembly::cacheJacobian(), InterfaceKernel::computeElementOffDiagJacobian(), ElemElemConstraint::computeElemNeighJacobian(), InterfaceKernel::computeElemNeighJacobian(), DGKernel::computeElemNeighJacobian(), ElemElemConstraint::computeElemNeighResidual(), InterfaceKernel::computeElemNeighResidual(), DGKernel::computeElemNeighResidual(), ComputeFullJacobianThread::computeFaceJacobian(), ComputeFullJacobianThread::computeInternalFaceJacobian(), FDKernel::computeJacobian(), MassLumpedTimeDerivative::computeJacobian(), TimeDerivative::computeJacobian(), Kernel::computeJacobian(), ODEKernel::computeJacobian(), EigenKernel::computeJacobian(), NodalEqualValueConstraint::computeJacobian(), ComputeFullJacobianThread::computeJacobian(), IntegratedBC::computeJacobian(), NonlocalKernel::computeJacobian(), NonlocalIntegratedBC::computeJacobian(), KernelValue::computeJacobian(), KernelGrad::computeJacobian(), NodeFaceConstraint::computeJacobian(), FaceFaceConstraint::computeJacobian(), DiracKernel::computeJacobian(), NonlocalIntegratedBC::computeJacobianBlock(), IntegratedBC::computeJacobianBlock(), IntegratedBC::computeJacobianBlockScalar(), FaceFaceConstraint::computeJacobianSide(), InterfaceKernel::computeNeighborOffDiagJacobian(), NonlocalKernel::computeNonlocalJacobian(), NonlocalIntegratedBC::computeNonlocalJacobian(), NonlocalKernel::computeNonlocalOffDiagJacobian(), NonlocalIntegratedBC::computeNonlocalOffDiagJacobian(), InterfaceKernel::computeOffDiagElemNeighJacobian(), DGKernel::computeOffDiagElemNeighJacobian(), Kernel::computeOffDiagJacobian(), FDKernel::computeOffDiagJacobian(), ODEKernel::computeOffDiagJacobian(), NodalScalarKernel::computeOffDiagJacobian(), EigenKernel::computeOffDiagJacobian(), NonlocalKernel::computeOffDiagJacobian(), NodalBC::computeOffDiagJacobian(), KernelGrad::computeOffDiagJacobian(), KernelValue::computeOffDiagJacobian(), NodeFaceConstraint::computeOffDiagJacobian(), DiracKernel::computeOffDiagJacobian(), NodalKernel::computeOffDiagJacobian(), DGKernel::computeOffDiagJacobian(), Kernel::computeOffDiagJacobianScalar(), TiedValueConstraint::computeQpJacobian(), CoupledTiedValueConstraint::computeQpJacobian(), TiedValueConstraint::computeQpResidual(), CoupledTiedValueConstraint::computeQpResidual(), Kernel::computeResidual(), ODETimeKernel::computeResidual(), TimeKernel::computeResidual(), ODEKernel::computeResidual(), EigenKernel::computeResidual(), NodalEqualValueConstraint::computeResidual(), IntegratedBC::computeResidual(), KernelValue::computeResidual(), KernelGrad::computeResidual(), NodeFaceConstraint::computeResidual(), FaceFaceConstraint::computeResidual(), DiracKernel::computeResidual(), FaceFaceConstraint::computeResidualSide(), DebugResidualAux::computeValue(), Coupleable::coupled(), ScalarCoupleable::coupledScalar(), VariableResidual::execute(), NodalNormalsEvaluator::execute(), NodalNormalsCorner::execute(), NodalNormalsPreprocessor::execute(), FieldSplitPreconditioner::FieldSplitPreconditioner(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), NodalNormalsPreprocessor::initialize(), ComputeDiracThread::onElement(), ComputeNodalKernelBCJacobiansThread::onNode(), ComputeNodalKernelJacobiansThread::onNode(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), Assembly::prepare(), Assembly::prepareNeighbor(), Assembly::prepareNonlocal(), Assembly::prepareVariable(), Assembly::prepareVariableNonlocal(), MultiAppProjectionTransfer::projectSolution(), AddPeriodicBCAction::setPeriodicVars(), SingleMatrixPreconditioner::SingleMatrixPreconditioner(), MultiAppCopyTransfer::transferDofObject(), and UpdateErrorVectorsThread::UpdateErrorVectorsThread().

63 { return _var_num; }
unsigned int _var_num
variable number (from libMesh)
unsigned int MooseVariableBase::numberOfDofs ( )
inlineinherited

Definition at line 116 of file MooseVariableBase.h.

Referenced by AuxKernel::compute(), and ComputeDiracThread::onElement().

116 { return _dof_indices.size(); }
std::vector< dof_id_type > _dof_indices
DOF indices.
Order MooseVariableBase::order ( ) const
inherited
void MooseVariableScalar::reinit ( )

Definition at line 48 of file MooseVariableScalar.C.

Referenced by MultiAppPostprocessorToAuxScalarTransfer::execute(), MultiAppScalarToAuxScalarTransfer::execute(), ScalarVariable::getValue(), ScalarL2Error::getValue(), TableOutput::outputScalarVariables(), Nemesis::outputScalarVariables(), Exodus::outputScalarVariables(), and FEProblemBase::projectSolution().

49 {
50  const NumericVector<Real> & current_solution = *_sys.currentSolution();
51  const NumericVector<Real> & solution_old = _sys.solutionOld();
52  const NumericVector<Real> & solution_older = _sys.solutionOlder();
53  const NumericVector<Real> & u_dot = _sys.solutionUDot();
54  const Real & du_dot_du = _sys.duDotDu();
55 
56  _dof_map.SCALAR_dof_indices(_dof_indices, _var_num);
57 
58  unsigned int n = _dof_indices.size();
59  _u.resize(n);
60  _u_old.resize(n);
61  _u_older.resize(n);
62  _u_dot.resize(n);
63 
64  _du_dot_du.clear();
65  _du_dot_du.resize(n, du_dot_du);
66 
67  // If we have an empty partition, or if we have a partition which
68  // does not include any of the subdomains of a subdomain-restricted
69  // variable, then we do not have access to that variable! Hopefully
70  // we won't need the indices we lack.
71  if (_dof_map.all_semilocal_indices(_dof_indices))
72  {
73  current_solution.get(_dof_indices, &_u[0]);
74  solution_old.get(_dof_indices, &_u_old[0]);
75  solution_older.get(_dof_indices, &_u_older[0]);
76  u_dot.get(_dof_indices, &_u_dot[0]);
77  }
78  else
79  {
80  for (std::size_t i = 0; i != n; ++i)
81  {
82  const dof_id_type dof_index = _dof_indices[i];
83  std::vector<dof_id_type> one_dof_index(1, dof_index);
84  if (_dof_map.all_semilocal_indices(one_dof_index))
85  {
86  libmesh_assert_less(i, _u.size());
87 
88  current_solution.get(one_dof_index, &_u[i]);
89  solution_old.get(one_dof_index, &_u_old[i]);
90  solution_older.get(one_dof_index, &_u_older[i]);
91  u_dot.get(one_dof_index, &_u_dot[i]);
92  }
93  else
94  {
95 #ifdef _GLIBCXX_DEBUG
96  // Let's make it possible to catch invalid accesses to these
97  // variables immediately via a thrown exception, if our
98  // libstdc++ compiler flags allow for that.
99  _u.resize(i);
100  _u_old.resize(i);
101  _u_older.resize(i);
102  _u_dot.resize(i);
103 #else
104  // If we can't catch errors at run-time, we can at least
105  // propagate NaN values rather than invalid values, so that
106  // users won't trust the result.
107  _u[i] = std::numeric_limits<Real>::quiet_NaN();
108  _u_old[i] = std::numeric_limits<Real>::quiet_NaN();
109  _u_older[i] = std::numeric_limits<Real>::quiet_NaN();
110  _u_dot[i] = std::numeric_limits<Real>::quiet_NaN();
111 #endif
112  }
113  }
114  }
115 }
const DofMap & _dof_map
DOF map.
void resize(const unsigned int size)
Change the number of elements the array can store.
Definition: MooseArray.h:205
virtual NumericVector< Number > & solutionOld()=0
VariableValue _u
The value of scalar variable.
VariableValue _u_older
The older value of scalar variable.
std::vector< dof_id_type > _dof_indices
DOF indices.
virtual Number & duDotDu()
Definition: SystemBase.h:156
virtual NumericVector< Number > & solutionUDot()
Definition: SystemBase.h:157
SystemBase & _sys
System this variable is part of.
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition: MooseArray.h:250
PetscInt n
unsigned int _var_num
variable number (from libMesh)
virtual NumericVector< Number > & solutionOlder()=0
void clear()
Change the number of elements the array can store to zero.
Definition: MooseArray.h:198
VariableValue _u_old
The old value of scalar variable.
virtual const NumericVector< Number > *& currentSolution()=0
The solution vector that is currently being operated on.
void MooseVariableBase::scalingFactor ( Real  factor)
inlineinherited
Real MooseVariableBase::scalingFactor ( ) const
inlineinherited

Get the scaling factor for this variable.

Definition at line 99 of file MooseVariableBase.h.

99 { return _scaling_factor; }
Real _scaling_factor
scaling factor for this variable
void MooseVariableScalar::setValue ( unsigned int  i,
Number  value 
)

Set the nodal value for this variable (to keep everything up to date.

Definition at line 125 of file MooseVariableScalar.C.

Referenced by AuxScalarKernel::compute(), and FEProblemBase::projectSolution().

126 {
127 // In debug modes, we might have set a "trap" to catch reads of
128 // uninitialized values, but this trap shouldn't prevent setting
129 // values.
130 #ifdef DEBUG
131  if (i >= _u.size())
132  {
133  libmesh_assert_less(i, _dof_indices.size());
134  _u.resize(i + 1);
135  }
136 #endif
137  _u[i] = value; // update variable value
138 }
void resize(const unsigned int size)
Change the number of elements the array can store.
Definition: MooseArray.h:205
VariableValue _u
The value of scalar variable.
std::vector< dof_id_type > _dof_indices
DOF indices.
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition: MooseArray.h:250
void MooseVariableScalar::setValues ( Number  value)

Set all of the values of this scalar variable to the same value.

Definition at line 141 of file MooseVariableScalar.C.

Referenced by MultiAppPostprocessorToAuxScalarTransfer::execute().

142 {
143  unsigned int n = _dof_indices.size();
144 // In debug modes, we might have set a "trap" to catch reads of
145 // uninitialized values, but this trap shouldn't prevent setting
146 // values.
147 #ifdef DEBUG
148  _u.resize(n);
149 #endif
150  for (unsigned int i = 0; i < n; i++)
151  _u[i] = value;
152 }
void resize(const unsigned int size)
Change the number of elements the array can store.
Definition: MooseArray.h:205
VariableValue _u
The value of scalar variable.
std::vector< dof_id_type > _dof_indices
DOF indices.
PetscInt n
VariableValue& MooseVariableScalar::sln ( )
inline
VariableValue& MooseVariableScalar::slnOld ( )
inline

Definition at line 46 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarValue(), and ScalarCoupleable::coupledScalarValueOld().

46 { return _u_old; }
VariableValue _u_old
The old value of scalar variable.
VariableValue& MooseVariableScalar::slnOlder ( )
inline

Definition at line 47 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarValueOld(), and ScalarCoupleable::coupledScalarValueOlder().

47 { return _u_older; }
VariableValue _u_older
The older value of scalar variable.
SystemBase& MooseVariableBase::sys ( )
inlineinherited
unsigned int MooseVariableBase::totalVarDofs ( )
inlineinherited

Definition at line 84 of file MooseVariableBase.h.

84 { return allDofIndices().size(); }
const std::vector< dof_id_type > & allDofIndices() const
Get all global dofindices for the variable.
VariableValue& MooseVariableScalar::uDot ( )
inline

Definition at line 49 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDot().

49 { return _u_dot; }

Member Data Documentation

Assembly& MooseVariableBase::_assembly
protectedinherited
std::vector<dof_id_type> MooseVariableBase::_dof_indices
protectedinherited
const DofMap& MooseVariableBase::_dof_map
protectedinherited
VariableValue MooseVariableScalar::_du_dot_du
protected

Definition at line 73 of file MooseVariableScalar.h.

Referenced by reinit(), and ~MooseVariableScalar().

FEType MooseVariableBase::_fe_type
protectedinherited
unsigned int MooseVariableBase::_index
protectedinherited

variable number within MOOSE

Definition at line 130 of file MooseVariableBase.h.

MooseMesh& MooseVariableBase::_mesh
protectedinherited

mesh the variable is active in

Definition at line 148 of file MooseVariableBase.h.

Real MooseVariableBase::_scaling_factor
protectedinherited

scaling factor for this variable

Definition at line 151 of file MooseVariableBase.h.

SubProblem& MooseVariableBase::_subproblem
protectedinherited
SystemBase& MooseVariableBase::_sys
protectedinherited
VariableValue MooseVariableScalar::_u
protected

The value of scalar variable.

Definition at line 66 of file MooseVariableScalar.h.

Referenced by insert(), reinit(), setValue(), setValues(), and ~MooseVariableScalar().

VariableValue MooseVariableScalar::_u_dot
protected

Definition at line 72 of file MooseVariableScalar.h.

Referenced by reinit(), and ~MooseVariableScalar().

VariableValue MooseVariableScalar::_u_old
protected

The old value of scalar variable.

Definition at line 68 of file MooseVariableScalar.h.

Referenced by reinit(), and ~MooseVariableScalar().

VariableValue MooseVariableScalar::_u_older
protected

The older value of scalar variable.

Definition at line 70 of file MooseVariableScalar.h.

Referenced by reinit(), and ~MooseVariableScalar().

Moose::VarKindType MooseVariableBase::_var_kind
protectedinherited

Definition at line 131 of file MooseVariableBase.h.

unsigned int MooseVariableBase::_var_num
protectedinherited
const Variable& MooseVariableBase::_variable
protectedinherited

libMesh variable object for this variable

Definition at line 138 of file MooseVariableBase.h.


The documentation for this class was generated from the following files: