https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
LinearFVGradientReader Class Reference

Read-only view of one variable's cell-centered linear finite-volume gradient values. More...

#include <LinearFVGradientReader.h>

Public Types

using GradientContainer = std::vector< libMesh::NumericVector< libMesh::Number > * >
 One vector per spatial component of the cell-centered gradient.
 
using GradientStateContainer = std::vector< GradientContainer >
 Gradient fields indexed by solution time state.
 

Public Member Functions

 LinearFVGradientReader (const SystemBase &sys, const GradientStateContainer &state_values, const FVGradientMethod &method, unsigned int variable_number)
 
const GradientContainer & components () const
 Access the underlying component vectors keyed by spatial direction.
 
const GradientContainer & components (const Moose::StateArg &state) const
 Access the component vectors for a solution state.
 
const SystemBase & system () const
 System whose DOF map indexes the stored values.
 
const FVGradientMethod & method () const
 Method object that produces the stored values.
 
Real component (const ElemInfo &elem_info, unsigned int index) const
 Read one gradient component at an element.
 
Real component (const ElemInfo &elem_info, unsigned int index, const Moose::StateArg &state) const
 Read one gradient component at an element and solution state.
 
RealVectorValue gradient (const ElemInfo &elem_info) const
 Read the full gradient at an element.
 
RealVectorValue gradient (const ElemInfo &elem_info, const Moose::StateArg &state) const
 Read the full gradient at an element and solution state.
 
RealVectorValue gradient (const FaceInfo &fi) const
 Read the full gradient interpolated to a face.
 
RealVectorValue gradient (const FaceInfo &fi, const Moose::StateArg &state) const
 Read the full gradient interpolated to a face at a solution state.
 

Private Member Functions

const GradientContainer & stateComponents (const Moose::StateArg &state) const
 Validate and select the component vectors for a solution state.
 

Private Attributes

const SystemBase & _sys
 System the variable belongs to.
 
const unsigned int _system_number
 System number cached for hot lookups (from faces to dofs).
 
const GradientStateContainer & _state_values
 Gradient fields indexed by solution time state.
 
const FVGradientMethod & _method
 Method object that produces the stored values.
 
const unsigned int _variable_number
 Variable number whose gradients are read by this object.
 

Detailed Description

Read-only view of one variable's cell-centered linear finite-volume gradient values.

Definition at line 32 of file LinearFVGradientReader.h.

Member Typedef Documentation

◆ GradientContainer

One vector per spatial component of the cell-centered gradient.

Definition at line 36 of file LinearFVGradientReader.h.

◆ GradientStateContainer

Gradient fields indexed by solution time state.

Definition at line 39 of file LinearFVGradientReader.h.

Constructor & Destructor Documentation

◆ LinearFVGradientReader()

LinearFVGradientReader::LinearFVGradientReader ( const SystemBase &  sys,
const GradientStateContainer &  state_values,
const FVGradientMethod &  method,
unsigned int  variable_number 
)
Parameters
sysSystem that owns the variables and gradient values.
state_valuesGradient fields indexed by solution time state.
methodGradient method that produces the values read by this object.
variable_numberVariable number whose gradient this object reads.

Definition at line 23 of file LinearFVGradientReader.C.

27 : _sys(sys),
29 _state_values(state_values),
31 _variable_number(variable_number)
32{
33 mooseAssert(!_state_values.empty(), "Gradient state storage must contain a current state.");
34}
const GradientStateContainer & _state_values
Gradient fields indexed by solution time state.
const FVGradientMethod & method() const
Method object that produces the stored values.
const FVGradientMethod & _method
Method object that produces the stored values.
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).
unsigned int number() const
Gets the number of this system.

Member Function Documentation

◆ component() [1/2]

Real LinearFVGradientReader::component ( const ElemInfo &  elem_info,
unsigned int  index 
) const

Read one gradient component at an element.

Parameters
elem_infoElement whose cell-centered gradient should be read.
indexIndex of the spatial component of the gradient.

Definition at line 37 of file LinearFVGradientReader.C.

38{
39 return component(elem_info, index, Moose::currentState());
40}
Real component(const ElemInfo &elem_info, unsigned int index) const
Read one gradient component at an element.
StateArg currentState()

Referenced by component(), and gradient().

◆ component() [2/2]

Real LinearFVGradientReader::component ( const ElemInfo &  elem_info,
unsigned int  index,
const Moose::StateArg &  state 
) const

Read one gradient component at an element and solution state.

Parameters
elem_infoElement whose cell-centered gradient should be read.
indexIndex of the spatial component of the gradient.
stateState whose gradient should be read.

Definition at line 93 of file LinearFVGradientReader.C.

96{
97 const auto & components = stateComponents(state);
98 mooseAssert(index < components.size(), "Gradient component index out of range.");
99 mooseAssert(components[index], "Gradient component vector must be initialized.");
100
101 return (*components[index])(elem_info.dofIndices()[_system_number][_variable_number]);
102}
const std::vector< std::vector< dof_id_type > > & dofIndices() const
Definition ElemInfo.h:39
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.

◆ components() [1/2]

const LinearFVGradientReader::GradientContainer & LinearFVGradientReader::components ( ) const

Access the underlying component vectors keyed by spatial direction.

Definition at line 43 of file LinearFVGradientReader.C.

44{
46}

Referenced by component(), and components().

◆ components() [2/2]

const LinearFVGradientReader::GradientContainer & LinearFVGradientReader::components ( const Moose::StateArg &  state) const

Access the component vectors for a solution state.

Parameters
stateState whose gradient components should be accessed.

Definition at line 49 of file LinearFVGradientReader.C.

50{
51 return stateComponents(state);
52}

◆ gradient() [1/4]

RealVectorValue LinearFVGradientReader::gradient ( const ElemInfo &  elem_info) const

Read the full gradient at an element.

Parameters
elem_infoElement whose cell-centered gradient should be read.

Definition at line 105 of file LinearFVGradientReader.C.

106{
107 return gradient(elem_info, Moose::currentState());
108}
RealVectorValue gradient(const ElemInfo &elem_info) const
Read the full gradient at an element.

Referenced by LinearFVAnisotropicDiffusion::computeBoundaryRHSContribution(), LinearFVDiffusion::computeBoundaryRHSContribution(), LinearFVAnisotropicDiffusion::computeFluxRHSContribution(), LinearFVDiffusion::computeFluxRHSContribution(), gradient(), gradient(), gradient(), and LinearFVAdvection::setupFaceData().

◆ gradient() [2/4]

RealVectorValue LinearFVGradientReader::gradient ( const ElemInfo &  elem_info,
const Moose::StateArg &  state 
) const

Read the full gradient at an element and solution state.

Parameters
elem_infoElement whose cell-centered gradient should be read.
stateState whose gradient should be read.

Definition at line 111 of file LinearFVGradientReader.C.

112{
114
115 for (const auto component_index : make_range(elem_info.elem()->dim()))
116 value(component_index) = component(elem_info, component_index, state);
117
118 return value;
119}
unsigned int dim
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
VectorValue< Real > RealVectorValue
Definition SubProblem.h:34
IntRange< T > make_range(T beg, T end)

◆ gradient() [3/4]

RealVectorValue LinearFVGradientReader::gradient ( const FaceInfo &  fi) const

Read the full gradient interpolated to a face.

Parameters
fiFace whose interpolated gradient should be read.

Definition at line 122 of file LinearFVGradientReader.C.

123{
124 return gradient(fi, Moose::currentState());
125}

◆ gradient() [4/4]

RealVectorValue LinearFVGradientReader::gradient ( const FaceInfo &  fi,
const Moose::StateArg &  state 
) const

Read the full gradient interpolated to a face at a solution state.

Parameters
fiFace whose interpolated gradient should be read.
stateState whose gradient should be read.

Definition at line 128 of file LinearFVGradientReader.C.

129{
130 const auto face_type = fi.faceType(std::make_pair(_variable_number, _system_number));
131 mooseAssert(face_type != FaceInfo::VarFaceNeighbors::NEITHER,
132 "Gradient requested on a face where the variable is defined on neither side.");
133
134 const bool var_defined_on_elem = (face_type == FaceInfo::VarFaceNeighbors::BOTH) ||
136 const auto * const elem_one = var_defined_on_elem ? fi.elemInfo() : fi.neighborInfo();
137 const auto * const elem_two = var_defined_on_elem ? fi.neighborInfo() : fi.elemInfo();
138
139 const auto elem_one_grad = gradient(*elem_one, state);
140
141 if (face_type == FaceInfo::VarFaceNeighbors::BOTH)
142 {
143 mooseAssert(elem_two, "Face type indicates BOTH but neighbor information is missing.");
144 const auto elem_two_grad = gradient(*elem_two, state);
145 return Moose::FV::linearInterpolation(elem_one_grad, elem_two_grad, fi, var_defined_on_elem);
146 }
147 else
148 return elem_one_grad;
149}
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.
Definition FaceInfo.h:229
const ElemInfo * elemInfo() const
Definition FaceInfo.h:89
const ElemInfo * neighborInfo() const
Definition FaceInfo.h:90
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.

◆ method()

const FVGradientMethod & LinearFVGradientReader::method ( ) const
inline

Method object that produces the stored values.

Definition at line 65 of file LinearFVGradientReader.h.

65{ return _method; }

Referenced by LinearFVGradientManager::updateFVGradient().

◆ stateComponents()

const LinearFVGradientReader::GradientContainer & LinearFVGradientReader::stateComponents ( const Moose::StateArg &  state) const
private

Validate and select the component vectors for a solution state.

Definition at line 55 of file LinearFVGradientReader.C.

56{
57 mooseAssert(!_state_values.empty(), "Gradient state storage must contain a current state.");
58
60 mooseError("Linear FV gradient state ",
61 state.state,
62 " with iteration type '",
64 "' was requested for variable '",
66 "'",
67 " on system '",
68 _sys.name(),
69 "' using gradient method '",
70 _method.name(),
71 "'. Only time iteration states are supported for non-current gradients.");
72
73 if (state.state >= _state_values.size())
74 mooseError("Linear FV gradient state ",
75 state.state,
76 " with iteration type '",
78 "' was requested for variable '",
80 "'",
81 " on system '",
82 _sys.name(),
83 "' using gradient method '",
84 _method.name(),
85 "', but the maximum allocated state is ",
86 _state_values.size() - 1,
87 ".");
88
89 return _state_values[state.state];
90}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition SystemBase.C:89
virtual const std::string & name() const
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:65
SolutionIterationType iteration_type
The solution iteration type, e.g. time or nonlinear.
unsigned int state
The state.

Referenced by component(), and components().

◆ system()

const SystemBase & LinearFVGradientReader::system ( ) const
inline

System whose DOF map indexes the stored values.

Definition at line 62 of file LinearFVGradientReader.h.

62{ return _sys; }

Referenced by LinearFVGradientManager::updateFVGradient().

Member Data Documentation

◆ _method

const FVGradientMethod& LinearFVGradientReader::_method
private

Method object that produces the stored values.

Definition at line 123 of file LinearFVGradientReader.h.

Referenced by method(), and stateComponents().

◆ _state_values

const GradientStateContainer& LinearFVGradientReader::_state_values
private

Gradient fields indexed by solution time state.

Definition at line 120 of file LinearFVGradientReader.h.

Referenced by LinearFVGradientReader(), and stateComponents().

◆ _sys

const SystemBase& LinearFVGradientReader::_sys
private

System the variable belongs to.

Definition at line 114 of file LinearFVGradientReader.h.

Referenced by stateComponents(), and system().

◆ _system_number

const unsigned int LinearFVGradientReader::_system_number
private

System number cached for hot lookups (from faces to dofs).

Definition at line 117 of file LinearFVGradientReader.h.

Referenced by component(), and gradient().

◆ _variable_number

const unsigned int LinearFVGradientReader::_variable_number
private

Variable number whose gradients are read by this object.

Definition at line 126 of file LinearFVGradientReader.h.

Referenced by component(), gradient(), and stateComponents().


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