21#include "libmesh/numeric_vector.h"
26 const unsigned int variable_number)
28 _system_number(sys.number()),
29 _state_values(state_values),
31 _variable_number(variable_number)
33 mooseAssert(!
_state_values.empty(),
"Gradient state storage must contain a current state.");
57 mooseAssert(!
_state_values.empty(),
"Gradient state storage must contain a current state.");
62 " with iteration type '",
64 "' was requested for variable '",
69 "' using gradient method '",
71 "'. Only time iteration states are supported for non-current gradients.");
76 " with iteration type '",
78 "' was requested for variable '",
83 "' using gradient method '",
85 "', but the maximum allocated state is ",
94 const unsigned int index,
98 mooseAssert(index <
components.size(),
"Gradient component index out of range.");
99 mooseAssert(
components[index],
"Gradient component vector must be initialized.");
113 RealVectorValue value;
115 for (
const auto component_index : make_range(elem_info.
elem()->dim()))
116 value(component_index) =
component(elem_info, component_index, state);
132 "Gradient requested on a face where the variable is defined on neither side.");
139 const auto elem_one_grad =
gradient(*elem_one, state);
143 mooseAssert(elem_two,
"Face type indicates BOTH but neighbor information is missing.");
144 const auto elem_two_grad =
gradient(*elem_two, state);
148 return elem_one_grad;
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Class used for caching additional information for elements such as the volume and centroid.
const Elem * elem() const
const std::vector< std::vector< dof_id_type > > & dofIndices() const
Base class for linear finite-volume cell-gradient methods.
This data structure is used to store geometric and variable related metadata about each cell face in ...
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
Returns which side(s) the given variable-system number pair is defined on for this face.
const ElemInfo * elemInfo() const
const ElemInfo * neighborInfo() const
const GradientContainer & stateComponents(const Moose::StateArg &state) const
Validate and select the component vectors for a solution state.
const GradientContainer & components() const
Access the underlying component vectors keyed by spatial direction.
const GradientStateContainer & _state_values
Gradient fields indexed by solution time state.
Real component(const ElemInfo &elem_info, unsigned int index) const
Read one gradient component at an element.
std::vector< GradientContainer > GradientStateContainer
Gradient fields indexed by solution time state.
const FVGradientMethod & _method
Method object that produces the stored values.
LinearFVGradientReader(const SystemBase &sys, const GradientStateContainer &state_values, const FVGradientMethod &method, unsigned int variable_number)
std::vector< libMesh::NumericVector< libMesh::Number > * > GradientContainer
One vector per spatial component of the cell-centered gradient.
RealVectorValue gradient(const ElemInfo &elem_info) const
Read the full gradient at an element.
const SystemBase & _sys
System the variable belongs to.
const unsigned int _variable_number
Variable number whose gradients are read by this object.
const unsigned int _system_number
System number cached for hot lookups (from faces to dofs).
const std::string & name() const
Get the name of the class.
Base class for a system (of equations)
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
virtual const std::string & name() const
libMesh::CompareTypes< T, T2 >::supertype linearInterpolation(const T &value1, const T2 &value2, const FaceInfo &fi, const bool one_is_elem, const InterpMethod interp_method=InterpMethod::Average)
A simple linear interpolation of values between cell centers to a cell face.
std::string stringify(const T &t)
conversion to string
State argument for evaluating functors.
SolutionIterationType iteration_type
The solution iteration type, e.g. time or nonlinear.
unsigned int state
The state.