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, THREAD_ID tid)
 
virtual ~MooseVariableScalar ()
 
void reinit ()
 
virtual bool isNodal () const override
 Is this variable nodal. More...
 
virtual bool isVector () const override
 
VariableValuesln ()
 
VariableValueslnOld ()
 
VariableValueslnOlder ()
 
VariableValuevectorTagSln (TagID tag)
 
VariableValuematrixTagSln (TagID tag)
 
VariableValueuDot ()
 
VariableValueuDotDot ()
 
VariableValueuDotOld ()
 
VariableValueuDotDotOld ()
 
VariableValueduDotDu ()
 
VariableValueduDotDotDu ()
 
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 ()
 
void computingJacobian (bool computing_jacobian)
 

Protected Attributes

Assembly_assembly
 The assembly. More...
 
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...
 
std::vector< VariableValue_vector_tag_u
 Tagged vectors. More...
 
std::vector< bool > _need_vector_tag_u
 Only cache data when need it. More...
 
std::vector< VariableValue_matrix_tag_u
 Tagged matrices. More...
 
std::vector< bool > _need_matrix_tag_u
 Only cache data when need it. More...
 
VariableValue _u_dot
 
VariableValue _u_dotdot
 
VariableValue _u_dot_old
 
VariableValue _u_dotdot_old
 
VariableValue _du_dot_du
 
VariableValue _du_dotdot_du
 
bool _need_u_dot
 
bool _need_u_dotdot
 
bool _need_u_dot_old
 
bool _need_u_dotdot_old
 
bool _need_du_dot_du
 
bool _need_du_dotdot_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...
 
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...
 
bool _computing_jacobian
 
THREAD_ID _tid
 Thread ID. More...
 

Detailed Description

Class for scalar variables (they are different).

Definition at line 28 of file MooseVariableScalar.h.

Constructor & Destructor Documentation

◆ MooseVariableScalar()

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

Definition at line 22 of file MooseVariableScalar.C.

28  : MooseVariableBase(var_num, fe_type, sys, var_kind, tid),
29  _assembly(assembly),
30  _need_u_dot(false),
31  _need_u_dotdot(false),
32  _need_u_dot_old(false),
33  _need_u_dotdot_old(false),
34  _need_du_dot_du(false),
35  _need_du_dotdot_du(false)
36 {
37  auto num_vector_tags = _sys.subproblem().numVectorTags();
38 
39  _vector_tag_u.resize(num_vector_tags);
40  _need_vector_tag_u.resize(num_vector_tags);
41 
42  auto num_matrix_tags = _sys.subproblem().numMatrixTags();
43 
44  _matrix_tag_u.resize(num_matrix_tags);
45  _need_matrix_tag_u.resize(num_matrix_tags);
46 }
virtual unsigned int numVectorTags()
The total number of tags.
Definition: SubProblem.h:110
std::vector< VariableValue > _vector_tag_u
Tagged vectors.
std::vector< bool > _need_vector_tag_u
Only cache data when need it.
SystemBase & _sys
System this variable is part of.
virtual SubProblem & subproblem()
Definition: SystemBase.h:103
std::vector< bool > _need_matrix_tag_u
Only cache data when need it.
std::vector< VariableValue > _matrix_tag_u
Tagged matrices.
MooseVariableBase(unsigned int var_num, const FEType &fe_type, SystemBase &sys, Moose::VarKindType var_kind, THREAD_ID tid)
Assembly & _assembly
The assembly.
SystemBase & sys()
Get the system this variable is part of.
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:145

◆ ~MooseVariableScalar()

MooseVariableScalar::~MooseVariableScalar ( )
virtual

Definition at line 48 of file MooseVariableScalar.C.

49 {
50  _u.release();
51  _u_old.release();
52  _u_older.release();
53 
54  _u_dot.release();
60 
61  for (auto & _tag_u : _vector_tag_u)
62  _tag_u.release();
63 
64  _vector_tag_u.clear();
65 
66  for (auto & _tag_u : _matrix_tag_u)
67  _tag_u.release();
68 
69  _matrix_tag_u.clear();
70 }
VariableValue _u
The value of scalar variable.
VariableValue _u_older
The older value of scalar variable.
std::vector< VariableValue > _vector_tag_u
Tagged vectors.
std::vector< VariableValue > _matrix_tag_u
Tagged matrices.
void release()
Manually deallocates the data pointer.
Definition: MooseArray.h:51
VariableValue _u_old
The old value of scalar variable.

Member Function Documentation

◆ allDofIndices()

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

Get all global dofindices for the variable.

Definition at line 46 of file MooseVariableBase.C.

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

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 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::map< std::string, std::vector< dof_id_type > > _var_dof_map
Definition: SubProblem.h:495
SystemBase & _sys
System this variable is part of.
virtual SubProblem & subproblem()
Definition: SystemBase.h:103
const std::string & name() const
Get the variable name.

◆ computingJacobian()

void MooseVariableBase::computingJacobian ( bool  computing_jacobian)
inlineinherited

Definition at line 111 of file MooseVariableBase.h.

111 { _computing_jacobian = computing_jacobian; }

◆ dofIndices() [1/2]

std::vector<dof_id_type>& MooseVariableBase::dofIndices ( )
inlineinherited

◆ dofIndices() [2/2]

const std::vector<dof_id_type>& MooseVariableBase::dofIndices ( ) const
inlineinherited

Definition at line 96 of file MooseVariableBase.h.

96 { return _dof_indices; }
std::vector< dof_id_type > _dof_indices
DOF indices.

◆ dofMap()

const DofMap& MooseVariableBase::dofMap ( ) const
inlineinherited

The DofMap associated with the system this variable is in.

Definition at line 92 of file MooseVariableBase.h.

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

92 { return _dof_map; }
const DofMap & _dof_map
DOF map.

◆ duDotDotDu()

VariableValue& MooseVariableScalar::duDotDotDu ( )
inline

Definition at line 116 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDotDu().

117  {
118  _need_du_dotdot_du = true;
119  return _du_dotdot_du;
120  }

◆ duDotDu()

VariableValue& MooseVariableScalar::duDotDu ( )
inline

Definition at line 110 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDu().

111  {
112  _need_du_dot_du = true;
113  return _du_dot_du;
114  }

◆ feType()

const FEType& MooseVariableBase::feType ( ) const
inlineinherited

◆ insert()

void MooseVariableScalar::insert ( NumericVector< Number > &  soln)

Definition at line 320 of file MooseVariableScalar.C.

Referenced by MultiAppPostprocessorToAuxScalarTransfer::execute().

321 {
322  // We may have redundantly computed this value on many different
323  // processors, but only the processor which actually owns it should
324  // be saving it to the solution vector, to avoid O(N_scalar_vars)
325  // unnecessary communication.
326 
327  const dof_id_type first_dof = _dof_map.first_dof();
328  const dof_id_type end_dof = _dof_map.end_dof();
329  if (_dof_indices.size() > 0 && first_dof <= _dof_indices[0] && _dof_indices[0] < end_dof)
330  soln.insert(&_u[0], _dof_indices);
331 }
const DofMap & _dof_map
DOF map.
VariableValue _u
The value of scalar variable.
std::vector< dof_id_type > _dof_indices
DOF indices.

◆ isNodal()

bool MooseVariableScalar::isNodal ( ) const
overridevirtual

Is this variable nodal.

Returns
true if it nodal, otherwise false

Implements MooseVariableBase.

Definition at line 277 of file MooseVariableScalar.C.

278 {
279  // scalar variables are never nodal ;-)
280  return false;
281 }

◆ isVector()

bool MooseVariableScalar::isVector ( ) const
overridevirtual
Returns
true if this is a vector-valued element, false otherwise.

Implements MooseVariableBase.

Definition at line 284 of file MooseVariableScalar.C.

285 {
286  return false;
287 }

◆ kind()

Moose::VarKindType MooseVariableBase::kind ( ) const
inlineinherited

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

Definition at line 71 of file MooseVariableBase.h.

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

71 { return _var_kind; }
Moose::VarKindType _var_kind

◆ matrixTagSln()

VariableValue& MooseVariableScalar::matrixTagSln ( TagID  tag)
inline

Definition at line 53 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledMatrixTagScalarValue().

54  {
55  _need_matrix_tag_u[tag] = true;
56  return _matrix_tag_u[tag];
57  }
std::vector< bool > _need_matrix_tag_u
Only cache data when need it.
std::vector< VariableValue > _matrix_tag_u
Tagged matrices.

◆ name()

const std::string & MooseVariableBase::name ( ) const
inherited

◆ number()

unsigned int MooseVariableBase::number ( ) const
inlineinherited

Get variable number coming from libMesh.

Returns
the libmesh variable number

Definition at line 45 of file MooseVariableBase.h.

Referenced by Assembly::addJacobianCoupledVarPair(), Assembly::cacheJacobianCoupledVarPair(), InterfaceKernel::computeElementOffDiagJacobian(), ElemElemConstraint::computeElemNeighJacobian(), InterfaceKernel::computeElemNeighJacobian(), DGKernel::computeElemNeighJacobian(), ElemElemConstraint::computeElemNeighResidual(), InterfaceKernel::computeElemNeighResidual(), DGKernel::computeElemNeighResidual(), ComputeFullJacobianThread::computeFaceJacobian(), ComputeFullJacobianThread::computeInternalFaceJacobian(), MassLumpedTimeDerivative::computeJacobian(), TimeDerivative::computeJacobian(), Kernel::computeJacobian(), ODEKernel::computeJacobian(), EigenKernel::computeJacobian(), ComputeFullJacobianThread::computeJacobian(), IntegratedBC::computeJacobian(), NodalEqualValueConstraint::computeJacobian(), EqualValueEmbeddedConstraint::computeJacobian(), VectorKernel::computeJacobian(), VectorIntegratedBC::computeJacobian(), NonlocalIntegratedBC::computeJacobian(), NonlocalKernel::computeJacobian(), KernelGrad::computeJacobian(), KernelValue::computeJacobian(), NodeElemConstraint::computeJacobian(), NodeFaceConstraint::computeJacobian(), MortarConstraint::computeJacobian(), DiracKernel::computeJacobian(), IntegratedBC::computeJacobianBlock(), NonlocalIntegratedBC::computeJacobianBlock(), VectorIntegratedBC::computeJacobianBlock(), JvarMapIntegratedBCInterface< T >::computeJacobianBlock(), IntegratedBC::computeJacobianBlockScalar(), VectorIntegratedBC::computeJacobianBlockScalar(), MortarConstraint::computeJacobianSide(), InterfaceKernel::computeNeighborOffDiagJacobian(), NonlocalIntegratedBC::computeNonlocalJacobian(), NonlocalKernel::computeNonlocalJacobian(), NonlocalIntegratedBC::computeNonlocalOffDiagJacobian(), NonlocalKernel::computeNonlocalOffDiagJacobian(), InterfaceKernel::computeOffDiagElemNeighJacobian(), DGKernel::computeOffDiagElemNeighJacobian(), ODEKernel::computeOffDiagJacobian(), Kernel::computeOffDiagJacobian(), NodalScalarKernel::computeOffDiagJacobian(), EigenKernel::computeOffDiagJacobian(), JvarMapKernelInterface< Kernel >::computeOffDiagJacobian(), EqualValueEmbeddedConstraint::computeOffDiagJacobian(), VectorNodalBC::computeOffDiagJacobian(), VectorKernel::computeOffDiagJacobian(), NodalBC::computeOffDiagJacobian(), ADKernel< compute_stage >::computeOffDiagJacobian(), NonlocalKernel::computeOffDiagJacobian(), KernelGrad::computeOffDiagJacobian(), KernelValue::computeOffDiagJacobian(), NodeElemConstraint::computeOffDiagJacobian(), NodeFaceConstraint::computeOffDiagJacobian(), DiracKernel::computeOffDiagJacobian(), DGKernel::computeOffDiagJacobian(), NodalKernel::computeOffDiagJacobian(), Kernel::computeOffDiagJacobianScalar(), VectorKernel::computeOffDiagJacobianScalar(), TiedValueConstraint::computeQpJacobian(), CoupledTiedValueConstraint::computeQpJacobian(), EqualValueEmbeddedConstraint::computeQpJacobian(), EqualValueEmbeddedConstraint::computeQpOffDiagJacobian(), TiedValueConstraint::computeQpResidual(), CoupledTiedValueConstraint::computeQpResidual(), Kernel::computeResidual(), TimeKernel::computeResidual(), ODEKernel::computeResidual(), ODETimeKernel::computeResidual(), VectorKernel::computeResidual(), IntegratedBC::computeResidual(), EigenKernel::computeResidual(), NodalEqualValueConstraint::computeResidual(), VectorIntegratedBC::computeResidual(), KernelValue::computeResidual(), KernelGrad::computeResidual(), NodeElemConstraint::computeResidual(), NodeFaceConstraint::computeResidual(), MortarConstraint::computeResidual(), DiracKernel::computeResidual(), MortarConstraint::computeResidualSide(), DebugResidualAux::computeValue(), Coupleable::coupled(), CoupledForce::CoupledForce(), ScalarCoupleable::coupledScalar(), VariableResidual::execute(), NodalNormalsCorner::execute(), NodalNormalsEvaluator::execute(), NodalNormalsPreprocessor::execute(), FieldSplitPreconditioner::FieldSplitPreconditioner(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), ConservativeAdvection::fullUpwind(), LazyCoupleable::init(), NodalNormalsPreprocessor::initialize(), ComputeDiracThread::onElement(), ComputeNodalKernelBCJacobiansThread::onNode(), ComputeNodalKernelJacobiansThread::onNode(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), Assembly::prepareJacobianBlock(), Assembly::prepareNeighbor(), Assembly::prepareNonlocal(), Assembly::prepareVariable(), Assembly::prepareVariableNonlocal(), MultiAppProjectionTransfer::projectSolution(), EqualValueEmbeddedConstraint::reinitConstraint(), AddPeriodicBCAction::setPeriodicVars(), SingleMatrixPreconditioner::SingleMatrixPreconditioner(), MultiAppCopyTransfer::transferDofObject(), and UpdateErrorVectorsThread::UpdateErrorVectorsThread().

45 { return _var_num; }
unsigned int _var_num
variable number (from libMesh)

◆ numberOfDofs()

unsigned int MooseVariableBase::numberOfDofs ( )
inlineinherited

Definition at line 98 of file MooseVariableBase.h.

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

98 { return _dof_indices.size(); }
std::vector< dof_id_type > _dof_indices
DOF indices.

◆ order()

Order MooseVariableBase::order ( ) const
inherited

◆ reinit()

void MooseVariableScalar::reinit ( )

Definition at line 73 of file MooseVariableScalar.C.

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

74 {
75  const NumericVector<Real> & current_solution = *_sys.currentSolution();
76  const NumericVector<Real> & solution_old = _sys.solutionOld();
77  const NumericVector<Real> & solution_older = _sys.solutionOlder();
78  const NumericVector<Real> * u_dot = _sys.solutionUDot();
79  const NumericVector<Real> * u_dotdot = _sys.solutionUDotDot();
80  const NumericVector<Real> * u_dot_old = _sys.solutionUDotOld();
81  const NumericVector<Real> * u_dotdot_old = _sys.solutionUDotDotOld();
82  const Real & du_dot_du = _sys.duDotDu();
83  const Real & du_dotdot_du = _sys.duDotDotDu();
84  auto safe_access_tagged_vectors = _sys.subproblem().safeAccessTaggedVectors();
85  auto safe_access_tagged_matrices = _sys.subproblem().safeAccessTaggedMatrices();
86  auto & active_coupleable_matrix_tags =
88  auto & active_coupleable_vector_tags =
90 
91  _dof_map.SCALAR_dof_indices(_dof_indices, _var_num);
92 
93  unsigned int n = _dof_indices.size();
94  _u.resize(n);
95  _u_old.resize(n);
96  _u_older.resize(n);
97 
98  for (auto & _tag_u : _vector_tag_u)
99  _tag_u.resize(n);
100 
101  for (auto & _tag_u : _matrix_tag_u)
102  _tag_u.resize(n);
103 
104  _du_dot_du.clear();
105  _du_dot_du.resize(n, du_dot_du);
106 
107  if (_need_u_dot)
108  _u_dot.resize(n);
109 
110  if (_need_u_dotdot)
111  _u_dotdot.resize(n);
112 
113  if (_need_u_dot_old)
115 
116  if (_need_u_dotdot_old)
118 
119  if (_need_du_dot_du)
120  {
121  _du_dot_du.clear();
122  _du_dot_du.resize(n, du_dot_du);
123  }
124 
125  if (_need_du_dotdot_du)
126  {
128  _du_dotdot_du.resize(n, du_dotdot_du);
129  }
130 
131  // If we have an empty partition, or if we have a partition which
132  // does not include any of the subdomains of a subdomain-restricted
133  // variable, then we do not have access to that variable! Hopefully
134  // we won't need the indices we lack.
135  if (_dof_map.all_semilocal_indices(_dof_indices))
136  {
137  current_solution.get(_dof_indices, &_u[0]);
138  solution_old.get(_dof_indices, &_u_old[0]);
139  solution_older.get(_dof_indices, &_u_older[0]);
140 
141  if (safe_access_tagged_vectors)
142  {
143  for (auto tag : active_coupleable_vector_tags)
144  if (_sys.hasVector(tag) && _need_vector_tag_u[tag])
145  _sys.getVector(tag).get(_dof_indices, &_vector_tag_u[tag][0]);
146  }
147 
148  if (safe_access_tagged_matrices)
149  {
150  for (auto tag : active_coupleable_matrix_tags)
151  if (_sys.hasMatrix(tag) && _sys.getMatrix(tag).closed() && _need_matrix_tag_u[tag])
152  for (std::size_t i = 0; i != n; ++i)
153  {
154  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
155  _matrix_tag_u[tag][i] = _sys.getMatrix(tag)(_dof_indices[i], _dof_indices[i]);
156  }
157  }
158 
159  if (_need_u_dot)
160  (*u_dot).get(_dof_indices, &_u_dot[0]);
161 
162  if (_need_u_dotdot)
163  (*u_dotdot).get(_dof_indices, &_u_dotdot[0]);
164 
165  if (_need_u_dot_old)
166  (*u_dot_old).get(_dof_indices, &_u_dot_old[0]);
167 
168  if (_need_u_dotdot_old)
169  (*u_dotdot_old).get(_dof_indices, &_u_dotdot_old[0]);
170  }
171  else
172  {
173  for (std::size_t i = 0; i != n; ++i)
174  {
175  const dof_id_type dof_index = _dof_indices[i];
176  std::vector<dof_id_type> one_dof_index(1, dof_index);
177  if (_dof_map.all_semilocal_indices(one_dof_index))
178  {
179  libmesh_assert_less(i, _u.size());
180 
181  current_solution.get(one_dof_index, &_u[i]);
182  solution_old.get(one_dof_index, &_u_old[i]);
183  solution_older.get(one_dof_index, &_u_older[i]);
184 
185  if (safe_access_tagged_vectors)
186  {
187  for (auto tag : active_coupleable_vector_tags)
188  if (_sys.hasVector(tag) && _need_vector_tag_u[tag])
189  _sys.getVector(tag).get(one_dof_index, &_vector_tag_u[tag][i]);
190  }
191 
192  if (safe_access_tagged_matrices)
193  {
194  for (auto tag : active_coupleable_matrix_tags)
195  if (_sys.hasMatrix(tag) && _sys.getMatrix(tag).closed() && _need_matrix_tag_u[tag])
196  {
197  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
198  _matrix_tag_u[tag][i] = _sys.getMatrix(tag)(dof_index, dof_index);
199  }
200  }
201 
202  if (_need_u_dot)
203  (*u_dot).get(one_dof_index, &_u_dot[i]);
204 
205  if (_need_u_dotdot)
206  (*u_dotdot).get(one_dof_index, &_u_dotdot[i]);
207 
208  if (_need_u_dot_old)
209  (*u_dot_old).get(one_dof_index, &_u_dot_old[i]);
210 
211  if (_need_u_dotdot_old)
212  (*u_dotdot_old).get(one_dof_index, &_u_dotdot_old[i]);
213  }
214  else
215  {
216 #ifdef _GLIBCXX_DEBUG
217  // Let's make it possible to catch invalid accesses to these
218  // variables immediately via a thrown exception, if our
219  // libstdc++ compiler flags allow for that.
220  _u.resize(i);
221  _u_old.resize(i);
222  _u_older.resize(i);
223 
224  for (auto tag : active_coupleable_vector_tags)
225  if (_sys.hasVector(tag) && _need_vector_tag_u[tag])
226  _vector_tag_u[tag].resize(i);
227 
228  for (auto tag : active_coupleable_matrix_tags)
229  if (_sys.hasMatrix(tag) && _sys.getMatrix(tag).closed() && _need_matrix_tag_u[tag])
230  _matrix_tag_u[tag].resize(i);
231 
232  if (_need_u_dot)
233  _u_dot.resize(i);
234 
235  if (_need_u_dotdot)
236  _u_dotdot.resize(i);
237 
238  if (_need_u_dot_old)
239  _u_dot_old.resize(i);
240 
241  if (_need_u_dotdot_old)
243 #else
244  // If we can't catch errors at run-time, we can at least
245  // propagate NaN values rather than invalid values, so that
246  // users won't trust the result.
247  _u[i] = std::numeric_limits<Real>::quiet_NaN();
248  _u_old[i] = std::numeric_limits<Real>::quiet_NaN();
249  _u_older[i] = std::numeric_limits<Real>::quiet_NaN();
250 
251  for (auto tag : active_coupleable_vector_tags)
252  if (_sys.hasVector(tag) && _need_vector_tag_u[tag])
253  _vector_tag_u[tag][i] = std::numeric_limits<Real>::quiet_NaN();
254 
255  for (auto tag : active_coupleable_matrix_tags)
256  if (_sys.hasMatrix(tag) && _sys.getMatrix(tag).closed() && _need_matrix_tag_u[tag])
257  _matrix_tag_u[tag][i] = std::numeric_limits<Real>::quiet_NaN();
258 
259  if (_need_u_dot)
260  _u_dot[i] = std::numeric_limits<Real>::quiet_NaN();
261 
262  if (_need_u_dotdot)
263  _u_dotdot[i] = std::numeric_limits<Real>::quiet_NaN();
264 
265  if (_need_u_dot_old)
266  _u_dot_old[i] = std::numeric_limits<Real>::quiet_NaN();
267 
268  if (_need_u_dotdot_old)
269  _u_dotdot_old[i] = std::numeric_limits<Real>::quiet_NaN();
270 #endif
271  }
272  }
273  }
274 }
std::set< TagID > & getActiveScalarVariableCoupleableVectorTags(THREAD_ID tid)
Definition: SubProblem.C:219
virtual NumericVector< Number > * solutionUDot()=0
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:670
const DofMap & _dof_map
DOF map.
void resize(const unsigned int size)
Change the number of elements the array can store.
Definition: MooseArray.h:200
virtual NumericVector< Number > & solutionOld()=0
VariableValue _u
The value of scalar variable.
virtual NumericVector< Number > * solutionUDotDotOld()=0
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:766
VariableValue _u_older
The older value of scalar variable.
THREAD_ID _tid
Thread ID.
std::vector< dof_id_type > _dof_indices
DOF indices.
std::vector< VariableValue > _vector_tag_u
Tagged vectors.
std::vector< bool > _need_vector_tag_u
Only cache data when need it.
virtual Number & duDotDu()
Definition: SystemBase.h:156
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition: MooseArray.h:245
virtual Number & duDotDotDu()
Definition: SystemBase.h:157
SystemBase & _sys
System this variable is part of.
virtual SubProblem & subproblem()
Definition: SystemBase.h:103
std::vector< bool > _need_matrix_tag_u
Only cache data when need it.
std::vector< VariableValue > _matrix_tag_u
Tagged matrices.
bool safeAccessTaggedMatrices()
Is it safe to access the tagged matrices.
Definition: SubProblem.h:507
std::set< TagID > & getActiveScalarVariableCoupleableMatrixTags(THREAD_ID tid)
Definition: SubProblem.C:213
PetscInt n
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:772
unsigned int _var_num
variable number (from libMesh)
virtual NumericVector< Number > & solutionOlder()=0
virtual NumericVector< Number > * solutionUDotOld()=0
virtual NumericVector< Number > * solutionUDotDot()=0
void clear()
Change the number of elements the array can store to zero.
Definition: MooseArray.h:193
bool safeAccessTaggedVectors()
Is it safe to access the tagged vectors.
Definition: SubProblem.h:510
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:720
VariableValue _u_old
The old value of scalar variable.
virtual const NumericVector< Number > *& currentSolution()=0
The solution vector that is currently being operated on.

◆ scalingFactor() [1/2]

void MooseVariableBase::scalingFactor ( Real  factor)
inlineinherited

◆ scalingFactor() [2/2]

Real MooseVariableBase::scalingFactor ( ) const
inlineinherited

Get the scaling factor for this variable.

Definition at line 81 of file MooseVariableBase.h.

81 { return _scaling_factor; }
Real _scaling_factor
scaling factor for this variable

◆ setValue()

void MooseVariableScalar::setValue ( unsigned int  i,
Number  value 
)

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

Definition at line 290 of file MooseVariableScalar.C.

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

291 {
292 // In debug modes, we might have set a "trap" to catch reads of
293 // uninitialized values, but this trap shouldn't prevent setting
294 // values.
295 #ifdef DEBUG
296  if (i >= _u.size())
297  {
298  libmesh_assert_less(i, _dof_indices.size());
299  _u.resize(i + 1);
300  }
301 #endif
302  _u[i] = value; // update variable value
303 }
void resize(const unsigned int size)
Change the number of elements the array can store.
Definition: MooseArray.h:200
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:245

◆ setValues()

void MooseVariableScalar::setValues ( Number  value)

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

Definition at line 306 of file MooseVariableScalar.C.

Referenced by MultiAppPostprocessorToAuxScalarTransfer::execute().

307 {
308  unsigned int n = _dof_indices.size();
309 // In debug modes, we might have set a "trap" to catch reads of
310 // uninitialized values, but this trap shouldn't prevent setting
311 // values.
312 #ifdef DEBUG
313  _u.resize(n);
314 #endif
315  for (unsigned int i = 0; i < n; i++)
316  _u[i] = value;
317 }
void resize(const unsigned int size)
Change the number of elements the array can store.
Definition: MooseArray.h:200
VariableValue _u
The value of scalar variable.
std::vector< dof_id_type > _dof_indices
DOF indices.
PetscInt n

◆ sln()

VariableValue& MooseVariableScalar::sln ( )
inline

◆ slnOld()

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.

◆ slnOlder()

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.

◆ sys()

SystemBase& MooseVariableBase::sys ( )
inlineinherited

◆ totalVarDofs()

unsigned int MooseVariableBase::totalVarDofs ( )
inlineinherited

Definition at line 66 of file MooseVariableBase.h.

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

◆ uDot()

VariableValue& MooseVariableScalar::uDot ( )
inline

Definition at line 59 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDot().

60  {
61  if (_sys.solutionUDot())
62  {
63  _need_u_dot = true;
64  return _u_dot;
65  }
66  else
67  mooseError("MooseVariableScalar: Time derivative of solution (`u_dot`) is not stored. Please "
68  "set uDotRequested() to true in FEProblemBase before requesting `u_dot`.");
69  }
virtual NumericVector< Number > * solutionUDot()=0
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
SystemBase & _sys
System this variable is part of.

◆ uDotDot()

VariableValue& MooseVariableScalar::uDotDot ( )
inline

Definition at line 71 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDot().

72  {
73  if (_sys.solutionUDotDot())
74  {
75  _need_u_dotdot = true;
76  return _u_dotdot;
77  }
78  else
79  mooseError("MooseVariableScalar: Second time derivative of solution (`u_dotdot`) is not "
80  "stored. Please set uDotDotRequested() to true in FEProblemBase before requesting "
81  "`u_dotdot`.");
82  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
SystemBase & _sys
System this variable is part of.
virtual NumericVector< Number > * solutionUDotDot()=0

◆ uDotDotOld()

VariableValue& MooseVariableScalar::uDotDotOld ( )
inline

Definition at line 97 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDotOld().

98  {
100  {
101  _need_u_dotdot_old = true;
102  return _u_dotdot_old;
103  }
104  else
105  mooseError("MooseVariableScalar: Old second time derivative of solution (`u_dotdot_old`) is "
106  "not stored. Please set uDotDotOldRequested() to true in FEProblemBase before "
107  "requesting `u_dotdot_old`.");
108  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
virtual NumericVector< Number > * solutionUDotDotOld()=0
SystemBase & _sys
System this variable is part of.

◆ uDotOld()

VariableValue& MooseVariableScalar::uDotOld ( )
inline

Definition at line 84 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotOld().

85  {
86  if (_sys.solutionUDotOld())
87  {
88  _need_u_dot_old = true;
89  return _u_dot_old;
90  }
91  else
92  mooseError("MooseVariableScalar: Old time derivative of solution (`u_dot_old`) is not "
93  "stored. Please set uDotOldRequested() to true in FEProblemBase before requesting "
94  "`u_dot_old`.");
95  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
SystemBase & _sys
System this variable is part of.
virtual NumericVector< Number > * solutionUDotOld()=0

◆ vectorTagSln()

VariableValue& MooseVariableScalar::vectorTagSln ( TagID  tag)
inline

Definition at line 48 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledVectorTagScalarValue().

49  {
50  _need_vector_tag_u[tag] = true;
51  return _vector_tag_u[tag];
52  }
std::vector< VariableValue > _vector_tag_u
Tagged vectors.
std::vector< bool > _need_vector_tag_u
Only cache data when need it.

Member Data Documentation

◆ _assembly

Assembly& MooseVariableScalar::_assembly
protected

The assembly.

Definition at line 136 of file MooseVariableScalar.h.

◆ _computing_jacobian

bool MooseVariableBase::_computing_jacobian
protectedinherited

Definition at line 140 of file MooseVariableBase.h.

Referenced by MooseVariableBase::computingJacobian().

◆ _dof_indices

std::vector<dof_id_type> MooseVariableBase::_dof_indices
protectedinherited

◆ _dof_map

const DofMap& MooseVariableBase::_dof_map
protectedinherited

DOF map.

Definition at line 130 of file MooseVariableBase.h.

Referenced by MooseVariableBase::dofMap(), insert(), and reinit().

◆ _du_dot_du

VariableValue MooseVariableScalar::_du_dot_du
protected

Definition at line 157 of file MooseVariableScalar.h.

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

◆ _du_dotdot_du

VariableValue MooseVariableScalar::_du_dotdot_du
protected

Definition at line 158 of file MooseVariableScalar.h.

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

◆ _fe_type

FEType MooseVariableBase::_fe_type
protectedinherited

◆ _index

unsigned int MooseVariableBase::_index
protectedinherited

variable number within MOOSE

Definition at line 119 of file MooseVariableBase.h.

◆ _matrix_tag_u

std::vector<VariableValue> MooseVariableScalar::_matrix_tag_u
protected

Tagged matrices.

Definition at line 149 of file MooseVariableScalar.h.

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

◆ _mesh

MooseMesh& MooseVariableBase::_mesh
protectedinherited

mesh the variable is active in

Definition at line 135 of file MooseVariableBase.h.

◆ _need_du_dot_du

bool MooseVariableScalar::_need_du_dot_du
protected

Definition at line 164 of file MooseVariableScalar.h.

Referenced by duDotDu(), and reinit().

◆ _need_du_dotdot_du

bool MooseVariableScalar::_need_du_dotdot_du
protected

Definition at line 165 of file MooseVariableScalar.h.

Referenced by duDotDotDu(), and reinit().

◆ _need_matrix_tag_u

std::vector<bool> MooseVariableScalar::_need_matrix_tag_u
protected

Only cache data when need it.

Definition at line 151 of file MooseVariableScalar.h.

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

◆ _need_u_dot

bool MooseVariableScalar::_need_u_dot
protected

Definition at line 160 of file MooseVariableScalar.h.

Referenced by reinit(), and uDot().

◆ _need_u_dot_old

bool MooseVariableScalar::_need_u_dot_old
protected

Definition at line 162 of file MooseVariableScalar.h.

Referenced by reinit(), and uDotOld().

◆ _need_u_dotdot

bool MooseVariableScalar::_need_u_dotdot
protected

Definition at line 161 of file MooseVariableScalar.h.

Referenced by reinit(), and uDotDot().

◆ _need_u_dotdot_old

bool MooseVariableScalar::_need_u_dotdot_old
protected

Definition at line 163 of file MooseVariableScalar.h.

Referenced by reinit(), and uDotDotOld().

◆ _need_vector_tag_u

std::vector<bool> MooseVariableScalar::_need_vector_tag_u
protected

Only cache data when need it.

Definition at line 147 of file MooseVariableScalar.h.

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

◆ _scaling_factor

Real MooseVariableBase::_scaling_factor
protectedinherited

scaling factor for this variable

Definition at line 138 of file MooseVariableBase.h.

Referenced by MooseVariableBase::scalingFactor().

◆ _subproblem

SubProblem& MooseVariableBase::_subproblem
protectedinherited

◆ _sys

SystemBase& MooseVariableBase::_sys
protectedinherited

◆ _tid

THREAD_ID MooseVariableBase::_tid
protectedinherited

Thread ID.

Definition at line 143 of file MooseVariableBase.h.

Referenced by reinit().

◆ _u

VariableValue MooseVariableScalar::_u
protected

The value of scalar variable.

Definition at line 139 of file MooseVariableScalar.h.

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

◆ _u_dot

VariableValue MooseVariableScalar::_u_dot
protected

Definition at line 153 of file MooseVariableScalar.h.

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

◆ _u_dot_old

VariableValue MooseVariableScalar::_u_dot_old
protected

Definition at line 155 of file MooseVariableScalar.h.

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

◆ _u_dotdot

VariableValue MooseVariableScalar::_u_dotdot
protected

Definition at line 154 of file MooseVariableScalar.h.

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

◆ _u_dotdot_old

VariableValue MooseVariableScalar::_u_dotdot_old
protected

Definition at line 156 of file MooseVariableScalar.h.

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

◆ _u_old

VariableValue MooseVariableScalar::_u_old
protected

The old value of scalar variable.

Definition at line 141 of file MooseVariableScalar.h.

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

◆ _u_older

VariableValue MooseVariableScalar::_u_older
protected

The older value of scalar variable.

Definition at line 143 of file MooseVariableScalar.h.

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

◆ _var_kind

Moose::VarKindType MooseVariableBase::_var_kind
protectedinherited

Definition at line 120 of file MooseVariableBase.h.

Referenced by MooseVariableBase::kind().

◆ _var_num

unsigned int MooseVariableBase::_var_num
protectedinherited

variable number (from libMesh)

Definition at line 115 of file MooseVariableBase.h.

Referenced by MooseVariableBase::name(), MooseVariableBase::number(), and reinit().

◆ _variable

const Variable& MooseVariableBase::_variable
protectedinherited

libMesh variable object for this variable

Definition at line 127 of file MooseVariableBase.h.

◆ _vector_tag_u

std::vector<VariableValue> MooseVariableScalar::_vector_tag_u
protected

Tagged vectors.

Definition at line 145 of file MooseVariableScalar.h.

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


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