https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public 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< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > >
 One vector per spatial component of the cell-centered gradient.
 

Public Member Functions

 LinearFVGradientReader (const SystemBase &sys, const GradientContainer &components, const FVGradientMethod &method, unsigned int variable_number)
 
const GradientContainercomponents () const
 Access the underlying component vectors keyed by spatial direction.
 
const SystemBasesystem () const
 System whose DOF map indexes the stored values.
 
const FVGradientMethodmethod () 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.
 
RealVectorValue gradient (const ElemInfo &elem_info) const
 Read the full gradient at an element.
 
RealVectorValue gradient (const FaceInfo &fi) const
 Read the full gradient interpolated to a face.
 

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 GradientContainer_components
 Component vectors keyed by spatial direction.
 
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.

Constructor & Destructor Documentation

◆ LinearFVGradientReader()

LinearFVGradientReader::LinearFVGradientReader ( const SystemBase sys,
const GradientContainer components,
const FVGradientMethod method,
unsigned int  variable_number 
)
Parameters
sysSystem that owns the variables and gradient values.
componentsComponent vectors that store the gradient values.
methodGradient method that produces the values read by this object.
variable_numberVariable number whose gradient this object reads.

Definition at line 22 of file LinearFVGradientReader.C.

26 : _sys(sys),
30 _variable_number(variable_number)
31{
32}
const FVGradientMethod & method() const
Method object that produces the stored values.
const GradientContainer & _components
Component vectors keyed by spatial direction.
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).
const GradientContainer & components() const
Access the underlying component vectors keyed by spatial direction.
unsigned int number() const
Gets the number of this system.

Member Function Documentation

◆ component()

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 35 of file LinearFVGradientReader.C.

36{
37 mooseAssert(index < _components.size(), "Gradient component index out of range.");
38
39 return (*_components[index])(elem_info.dofIndices()[_system_number][_variable_number]);
40}
const std::vector< std::vector< dof_id_type > > & dofIndices() const
Definition ElemInfo.h:39

Referenced by gradient().

◆ components()

const GradientContainer & LinearFVGradientReader::components ( ) const
inline

Access the underlying component vectors keyed by spatial direction.

Definition at line 50 of file LinearFVGradientReader.h.

50{ return _components; }

◆ gradient() [1/2]

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 43 of file LinearFVGradientReader.C.

44{
46
47 for (const auto component_index : make_range(elem_info.elem()->dim()))
48 value(component_index) = component(elem_info, component_index);
49
50 return value;
51}
unsigned int dim
Real component(const ElemInfo &elem_info, unsigned int index) const
Read one gradient component at an element.
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)

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

◆ gradient() [2/2]

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 54 of file LinearFVGradientReader.C.

55{
56 const auto face_type = fi.faceType(std::make_pair(_variable_number, _system_number));
57 mooseAssert(face_type != FaceInfo::VarFaceNeighbors::NEITHER,
58 "Gradient requested on a face where the variable is defined on neither side.");
59
60 const bool var_defined_on_elem = (face_type == FaceInfo::VarFaceNeighbors::BOTH) ||
62 const auto * const elem_one = var_defined_on_elem ? fi.elemInfo() : fi.neighborInfo();
63 const auto * const elem_two = var_defined_on_elem ? fi.neighborInfo() : fi.elemInfo();
64
65 const auto elem_one_grad = gradient(*elem_one);
66
67 if (face_type == FaceInfo::VarFaceNeighbors::BOTH)
68 {
69 mooseAssert(elem_two, "Face type indicates BOTH but neighbor information is missing.");
70 const auto elem_two_grad = gradient(*elem_two);
71 return Moose::FV::linearInterpolation(elem_one_grad, elem_two_grad, fi, var_defined_on_elem);
72 }
73 else
74 return elem_one_grad;
75}
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
RealVectorValue gradient(const ElemInfo &elem_info) const
Read the full gradient at an element.
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 56 of file LinearFVGradientReader.h.

56{ return _method; }

Referenced by LinearFVGradientInterface::updateFVGradient().

◆ system()

const SystemBase & LinearFVGradientReader::system ( ) const
inline

System whose DOF map indexes the stored values.

Definition at line 53 of file LinearFVGradientReader.h.

53{ return _sys; }

Referenced by LinearFVGradientInterface::updateFVGradient().

Member Data Documentation

◆ _components

const GradientContainer& LinearFVGradientReader::_components
private

Component vectors keyed by spatial direction.

Definition at line 85 of file LinearFVGradientReader.h.

Referenced by component(), and components().

◆ _method

const FVGradientMethod& LinearFVGradientReader::_method
private

Method object that produces the stored values.

Definition at line 88 of file LinearFVGradientReader.h.

Referenced by method().

◆ _sys

const SystemBase& LinearFVGradientReader::_sys
private

System the variable belongs to.

Definition at line 79 of file LinearFVGradientReader.h.

Referenced by system().

◆ _system_number

const unsigned int LinearFVGradientReader::_system_number
private

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

Definition at line 82 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 91 of file LinearFVGradientReader.h.

Referenced by component(), and gradient().


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