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 ()
 
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 ()
 Get a writable reference of local DoF indices. More...
 
const std::vector< dof_id_type > & dofIndices () const
 Get local DoF indices. More...
 
unsigned int numberOfDofs ()
 Get the number of local DoFs. More...
 

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...
 
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:122
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:105
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:157

◆ ~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();
55  _u_dotdot.release();
56  _u_dot_old.release();
57  _u_dotdot_old.release();
58  _du_dot_du.release();
59  _du_dotdot_du.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.
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:507
SystemBase & _sys
System this variable is part of.
virtual SubProblem & subproblem()
Definition: SystemBase.h:105
const std::string & name() const
Get the variable name.

◆ dofIndices() [1/2]

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

◆ dofIndices() [2/2]

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

Get local DoF indices.

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 90 of file MooseVariableBase.h.

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

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

◆ duDotDotDu()

VariableValue& MooseVariableScalar::duDotDotDu ( )
inline

Definition at line 113 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDotDu().

114  {
115  _need_du_dotdot_du = true;
116  return _du_dotdot_du;
117  }

◆ duDotDu()

VariableValue& MooseVariableScalar::duDotDu ( )
inline

Definition at line 107 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDu().

108  {
109  _need_du_dot_du = true;
110  return _du_dot_du;
111  }

◆ feType()

const FEType& MooseVariableBase::feType ( ) const
inlineinherited

◆ insert()

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

Definition at line 307 of file MooseVariableScalar.C.

Referenced by MultiAppPostprocessorToAuxScalarTransfer::execute().

308 {
309  // We may have redundantly computed this value on many different
310  // processors, but only the processor which actually owns it should
311  // be saving it to the solution vector, to avoid O(N_scalar_vars)
312  // unnecessary communication.
313 
314  const dof_id_type first_dof = _dof_map.first_dof();
315  const dof_id_type end_dof = _dof_map.end_dof();
316  if (_dof_indices.size() > 0 && first_dof <= _dof_indices[0] && _dof_indices[0] < end_dof)
317  soln.insert(&_u[0], _dof_indices);
318 }
const DofMap & _dof_map
DOF map.
VariableValue _u
The value of scalar variable.
std::vector< dof_id_type > _dof_indices
DOF indices.

◆ kind()

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

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

Definition at line 69 of file MooseVariableBase.h.

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

69 { return _var_kind; }
Moose::VarKindType _var_kind

◆ matrixTagSln()

VariableValue& MooseVariableScalar::matrixTagSln ( TagID  tag)
inline

Definition at line 50 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledMatrixTagScalarValue().

51  {
52  _need_matrix_tag_u[tag] = true;
53  return _matrix_tag_u[tag];
54  }
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 43 of file MooseVariableBase.h.

Referenced by Assembly::addJacobianCoupledVarPair(), Assembly::cacheJacobianCoupledVarPair(), ADKernelGradTempl< T, compute_stage >::computeADOffDiagJacobian(), ADKernelStabilizedTempl< T, compute_stage >::computeADOffDiagJacobian(), ADKernelValueTempl< T, compute_stage >::computeADOffDiagJacobian(), ADKernelTempl< T, compute_stage >::computeADOffDiagJacobian(), InterfaceKernel::computeElementOffDiagJacobian(), DGKernel::computeElemNeighJacobian(), ElemElemConstraint::computeElemNeighJacobian(), InterfaceKernel::computeElemNeighJacobian(), DGKernel::computeElemNeighResidual(), ElemElemConstraint::computeElemNeighResidual(), InterfaceKernel::computeElemNeighResidual(), ComputeFullJacobianThread::computeFaceJacobian(), ComputeFullJacobianThread::computeInternalFaceJacobian(), MassLumpedTimeDerivative::computeJacobian(), TimeDerivative::computeJacobian(), Kernel::computeJacobian(), VectorKernel::computeJacobian(), ODEKernel::computeJacobian(), EigenKernel::computeJacobian(), ComputeFullJacobianThread::computeJacobian(), IntegratedBC::computeJacobian(), NodalEqualValueConstraint::computeJacobian(), EqualValueEmbeddedConstraint::computeJacobian(), VectorIntegratedBC::computeJacobian(), NonlocalIntegratedBC::computeJacobian(), NonlocalKernel::computeJacobian(), KernelGrad::computeJacobian(), KernelValue::computeJacobian(), NodeElemConstraint::computeJacobian(), NodeFaceConstraint::computeJacobian(), MortarConstraint::computeJacobian(), DiracKernel::computeJacobian(), ADIntegratedBCTempl< T, compute_stage >::computeJacobianBlock(), 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(), DGKernel::computeOffDiagElemNeighJacobian(), InterfaceKernel::computeOffDiagElemNeighJacobian(), ODEKernel::computeOffDiagJacobian(), Kernel::computeOffDiagJacobian(), NodalScalarKernel::computeOffDiagJacobian(), VectorKernel::computeOffDiagJacobian(), EigenKernel::computeOffDiagJacobian(), JvarMapKernelInterface< Kernel >::computeOffDiagJacobian(), EqualValueEmbeddedConstraint::computeOffDiagJacobian(), VectorNodalBC::computeOffDiagJacobian(), NodalBC::computeOffDiagJacobian(), NonlocalKernel::computeOffDiagJacobian(), KernelGrad::computeOffDiagJacobian(), KernelValue::computeOffDiagJacobian(), NodeElemConstraint::computeOffDiagJacobian(), NodeFaceConstraint::computeOffDiagJacobian(), DiracKernel::computeOffDiagJacobian(), NodalKernel::computeOffDiagJacobian(), DGKernelBase::computeOffDiagJacobian(), VectorKernel::computeOffDiagJacobianScalar(), Kernel::computeOffDiagJacobianScalar(), TiedValueConstraint::computeQpJacobian(), CoupledTiedValueConstraint::computeQpJacobian(), EqualValueEmbeddedConstraint::computeQpJacobian(), EqualValueEmbeddedConstraint::computeQpOffDiagJacobian(), TiedValueConstraint::computeQpResidual(), CoupledTiedValueConstraint::computeQpResidual(), Kernel::computeResidual(), VectorKernel::computeResidual(), ODETimeKernel::computeResidual(), TimeKernel::computeResidual(), ODEKernel::computeResidual(), EigenKernel::computeResidual(), IntegratedBC::computeResidual(), NodalEqualValueConstraint::computeResidual(), VectorIntegratedBC::computeResidual(), KernelGrad::computeResidual(), KernelValue::computeResidual(), NodeElemConstraint::computeResidual(), NodeFaceConstraint::computeResidual(), MortarConstraint::computeResidual(), DiracKernel::computeResidual(), MortarConstraint::computeResidualSide(), DebugResidualAux::computeValue(), Coupleable::coupled(), CoupledForce::CoupledForce(), ScalarCoupleable::coupledScalar(), VariableResidual::execute(), NodalNormalsEvaluator::execute(), NodalNormalsCorner::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().

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

◆ numberOfDofs()

unsigned int MooseVariableBase::numberOfDofs ( )
inlineinherited

Get the number of local DoFs.

Definition at line 99 of file MooseVariableBase.h.

Referenced by ComputeDiracThread::onElement().

99 { 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)
114  _u_dot_old.resize(n);
115 
116  if (_need_u_dotdot_old)
117  _u_dotdot_old.resize(n);
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  {
127  _du_dotdot_du.clear();
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)
242  _u_dotdot_old.resize(i);
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:229
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:685
const DofMap & _dof_map
DOF map.
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:781
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:158
virtual Number & duDotDotDu()
Definition: SystemBase.h:159
SystemBase & _sys
System this variable is part of.
virtual SubProblem & subproblem()
Definition: SystemBase.h:105
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:524
std::set< TagID > & getActiveScalarVariableCoupleableMatrixTags(THREAD_ID tid)
Definition: SubProblem.C:223
PetscInt n
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:787
unsigned int _var_num
variable number (from libMesh)
virtual NumericVector< Number > & solutionOlder()=0
virtual NumericVector< Number > * solutionUDotOld()=0
virtual NumericVector< Number > * solutionUDotDot()=0
bool safeAccessTaggedVectors()
Is it safe to access the tagged vectors.
Definition: SubProblem.h:527
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:735
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 79 of file MooseVariableBase.h.

79 { 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 277 of file MooseVariableScalar.C.

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

278 {
279 // In debug modes, we might have set a "trap" to catch reads of
280 // uninitialized values, but this trap shouldn't prevent setting
281 // values.
282 #ifdef DEBUG
283  if (i >= _u.size())
284  {
285  libmesh_assert_less(i, _dof_indices.size());
286  _u.resize(i + 1);
287  }
288 #endif
289  _u[i] = value; // update variable value
290 }
VariableValue _u
The value of scalar variable.
std::vector< dof_id_type > _dof_indices
DOF indices.

◆ setValues()

void MooseVariableScalar::setValues ( Number  value)

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

Definition at line 293 of file MooseVariableScalar.C.

Referenced by MultiAppPostprocessorToAuxScalarTransfer::execute().

294 {
295  unsigned int n = _dof_indices.size();
296 // In debug modes, we might have set a "trap" to catch reads of
297 // uninitialized values, but this trap shouldn't prevent setting
298 // values.
299 #ifdef DEBUG
300  _u.resize(n);
301 #endif
302  for (unsigned int i = 0; i < n; i++)
303  _u[i] = value;
304 }
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 43 of file MooseVariableScalar.h.

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

43 { return _u_old; }
VariableValue _u_old
The old value of scalar variable.

◆ slnOlder()

VariableValue& MooseVariableScalar::slnOlder ( )
inline

Definition at line 44 of file MooseVariableScalar.h.

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

44 { 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 64 of file MooseVariableBase.h.

64 { 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 56 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDot().

57  {
58  if (_sys.solutionUDot())
59  {
60  _need_u_dot = true;
61  return _u_dot;
62  }
63  else
64  mooseError("MooseVariableScalar: Time derivative of solution (`u_dot`) is not stored. Please "
65  "set uDotRequested() to true in FEProblemBase before requesting `u_dot`.");
66  }
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 68 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDot().

69  {
70  if (_sys.solutionUDotDot())
71  {
72  _need_u_dotdot = true;
73  return _u_dotdot;
74  }
75  else
76  mooseError("MooseVariableScalar: Second time derivative of solution (`u_dotdot`) is not "
77  "stored. Please set uDotDotRequested() to true in FEProblemBase before requesting "
78  "`u_dotdot`.");
79  }
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 94 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotDotOld().

95  {
97  {
98  _need_u_dotdot_old = true;
99  return _u_dotdot_old;
100  }
101  else
102  mooseError("MooseVariableScalar: Old second time derivative of solution (`u_dotdot_old`) is "
103  "not stored. Please set uDotDotOldRequested() to true in FEProblemBase before "
104  "requesting `u_dotdot_old`.");
105  }
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 81 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledScalarDotOld().

82  {
83  if (_sys.solutionUDotOld())
84  {
85  _need_u_dot_old = true;
86  return _u_dot_old;
87  }
88  else
89  mooseError("MooseVariableScalar: Old time derivative of solution (`u_dot_old`) is not "
90  "stored. Please set uDotOldRequested() to true in FEProblemBase before requesting "
91  "`u_dot_old`.");
92  }
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 45 of file MooseVariableScalar.h.

Referenced by ScalarCoupleable::coupledVectorTagScalarValue().

46  {
47  _need_vector_tag_u[tag] = true;
48  return _vector_tag_u[tag];
49  }
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 133 of file MooseVariableScalar.h.

◆ _dof_indices

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

◆ _dof_map

const DofMap& MooseVariableBase::_dof_map
protectedinherited

DOF map.

Definition at line 118 of file MooseVariableBase.h.

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

◆ _du_dot_du

VariableValue MooseVariableScalar::_du_dot_du
protected

Definition at line 154 of file MooseVariableScalar.h.

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

◆ _du_dotdot_du

VariableValue MooseVariableScalar::_du_dotdot_du
protected

Definition at line 155 of file MooseVariableScalar.h.

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

◆ _fe_type

FEType MooseVariableBase::_fe_type
protectedinherited

The FEType associated with this variable.

Definition at line 105 of file MooseVariableBase.h.

Referenced by MooseVariableBase::feType(), MooseVariableFE< Real >::MooseVariableFE(), and MooseVariableBase::order().

◆ _index

unsigned int MooseVariableBase::_index
protectedinherited

variable number within MOOSE

Definition at line 107 of file MooseVariableBase.h.

◆ _matrix_tag_u

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

Tagged matrices.

Definition at line 146 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 123 of file MooseVariableBase.h.

◆ _need_du_dot_du

bool MooseVariableScalar::_need_du_dot_du
protected

Definition at line 161 of file MooseVariableScalar.h.

Referenced by duDotDu(), and reinit().

◆ _need_du_dotdot_du

bool MooseVariableScalar::_need_du_dotdot_du
protected

Definition at line 162 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 148 of file MooseVariableScalar.h.

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

◆ _need_u_dot

bool MooseVariableScalar::_need_u_dot
protected

Definition at line 157 of file MooseVariableScalar.h.

Referenced by reinit(), and uDot().

◆ _need_u_dot_old

bool MooseVariableScalar::_need_u_dot_old
protected

Definition at line 159 of file MooseVariableScalar.h.

Referenced by reinit(), and uDotOld().

◆ _need_u_dotdot

bool MooseVariableScalar::_need_u_dotdot
protected

Definition at line 158 of file MooseVariableScalar.h.

Referenced by reinit(), and uDotDot().

◆ _need_u_dotdot_old

bool MooseVariableScalar::_need_u_dotdot_old
protected

Definition at line 160 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 144 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 126 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 129 of file MooseVariableBase.h.

Referenced by reinit().

◆ _u

VariableValue MooseVariableScalar::_u
protected

The value of scalar variable.

Definition at line 136 of file MooseVariableScalar.h.

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

◆ _u_dot

VariableValue MooseVariableScalar::_u_dot
protected

Definition at line 150 of file MooseVariableScalar.h.

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

◆ _u_dot_old

VariableValue MooseVariableScalar::_u_dot_old
protected

Definition at line 152 of file MooseVariableScalar.h.

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

◆ _u_dotdot

VariableValue MooseVariableScalar::_u_dotdot
protected

Definition at line 151 of file MooseVariableScalar.h.

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

◆ _u_dotdot_old

VariableValue MooseVariableScalar::_u_dotdot_old
protected

Definition at line 153 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 138 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 140 of file MooseVariableScalar.h.

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

◆ _var_kind

Moose::VarKindType MooseVariableBase::_var_kind
protectedinherited

Definition at line 108 of file MooseVariableBase.h.

Referenced by MooseVariableBase::kind().

◆ _var_num

unsigned int MooseVariableBase::_var_num
protectedinherited

variable number (from libMesh)

Definition at line 103 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 115 of file MooseVariableBase.h.

◆ _vector_tag_u

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

Tagged vectors.

Definition at line 142 of file MooseVariableScalar.h.

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


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