https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVPressureJumpGreenGaussGradient.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8
10
12#include "LinearSystem.h"
13#include "MathFVUtils.h"
16
18
21{
23 params.suppressParameter<MooseEnum>("limiter");
25 "Computes a Green-Gauss pressure gradient that excludes the pressure jump across baffles, "
26 "using a one-sided face pressure for each cell, so the zero-thickness jump does not appear "
27 "as a mesh-dependent gradient in the adjacent cells.");
28 return params;
29}
30
35
36void
38 const LinearFVGradientReader & pressure_gradient)
39{
40 if (&pressure_gradient.method() != this)
41 mooseError("Must be linked using a gradient field produced by that method.");
42
43 if (pressure_gradient.system().number() != rc.pressureSystem().number() ||
44 pressure_gradient.variableNumber() != rc.pressureVariableNumber())
45 mooseError("Must be linked to the pressure variable owned by PorousRhieChowMassFlux '",
46 rc.name(),
47 "'.");
48
49 if (_rhie_chow && _rhie_chow != &rc)
50 mooseError("Already linked to PorousRhieChowMassFlux '",
52 "'. Use a separate gradient method for each flow system.");
53
54 _rhie_chow = &rc;
55 _pressure_gradient = &pressure_gradient;
56 _pressure_system = &pressure_gradient.system();
57 _pressure_variable_number = pressure_gradient.variableNumber();
58}
59
60void
62 SystemBase & system,
63 GradientContainer & gradient,
64 const std::unordered_set<unsigned int> & variable_numbers) const
65{
66 if (variable_numbers.size() != 1)
67 mooseError("must be used by exactly one pressure variable, but it is used by ",
68 variable_numbers.size(),
69 ".");
70
72 {
73 mooseAssert(_pressure_system == &system,
74 "FVPressureJumpGreenGaussGradient can only compute gradients for its linked "
75 "pressure system.");
76 mooseAssert(_pressure_variable_number == *variable_numbers.begin(),
77 "FVPressureJumpGreenGaussGradient can only compute the linked pressure variable.");
78 }
79
80 FVGreenGaussGradient::computeGradientWithoutLimiter(system, gradient, variable_numbers);
81}
82
85 const ElemInfo & elem_info,
86 const ElemInfo & neighbor_info,
87 const MooseLinearVariableFV<Real> & variable,
88 const Real elem_value,
89 const Real neighbor_value) const
90{
93 fi, elem_info, neighbor_info, variable, elem_value, neighbor_value);
94
95 mooseAssert(_pressure_gradient, "A linked pressure gradient is required on pressure-jump faces.");
96
97 const Real jump = _rhie_chow->getSignedBaffleJump(fi, /*elem_side=*/true);
99 {
100 // Gradient history is initialized before the pressure-diffusion coefficients exist.
101 // Preserve the jump during this startup pass using jump-adjusted interpolation.
102 return {Moose::FV::linearInterpolation(elem_value, neighbor_value + jump, fi, true),
103 Moose::FV::linearInterpolation(elem_value - jump, neighbor_value, fi, true)};
104 }
105
106 // Use the published geometric pressure gradient to match the deferred correction in the
107 // pressure equation. The reconstructed coupling gradient must not enter this correction.
108 const auto face_operator =
110 _pressure_gradient->gradient(elem_info),
111 _pressure_gradient->gradient(neighbor_info),
112 fi.faceArea() * fi.faceCoord());
113
114 // Eliminate the interface pressures to obtain one conservative mass flux, then recover the
115 // one-sided face value used in each cell's Green-Gauss surface sum. Each side's H/A flux enters
116 // its face value, so the face pressure carries the body force, e.g. the hydrostatic slope.
117 const Real mass_flux = NS::FV::pressureJumpFlux(face_operator, elem_value, neighbor_value) -
118 NS::FV::pressureJumpHbyAFlux(face_operator);
120 face_operator, elem_value, mass_flux, /*elem_side=*/true),
122 face_operator, neighbor_value, mass_flux, /*elem_side=*/false)};
123}
registerMooseObject("NavierStokesApp", FVPressureJumpGreenGaussGradient)
std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > GradientContainer
static InputParameters validParams()
virtual InternalFaceValues internalFaceValues(const FaceInfo &fi, const ElemInfo &elem_info, const ElemInfo &neighbor_info, const MooseLinearVariableFV< Real > &variable, Real elem_value, Real neighbor_value) const
void computeGradientWithoutLimiter(SystemBase &system, GradientContainer &gradient, const std::unordered_set< unsigned int > &variable_numbers) const override
std::pair< Real, Real > InternalFaceValues
Green-Gauss pressure gradient that removes prescribed jumps before interpolating across baffles.
InternalFaceValues internalFaceValues(const FaceInfo &fi, const ElemInfo &elem_info, const ElemInfo &neighbor_info, const MooseLinearVariableFV< Real > &variable, Real elem_value, Real neighbor_value) const override
void linkFlowSystem(PorousRhieChowMassFlux &rc, const LinearFVGradientReader &pressure_gradient)
Link this method to the porous Rhie-Chow object that supplies pressure jumps.
const PorousRhieChowMassFlux * _rhie_chow
Porous Rhie-Chow object supplying baffle locations and signed pressure jumps after linkage.
const SystemBase * _pressure_system
Pressure system to which this method is linked.
void computeGradientWithoutLimiter(SystemBase &system, GradientContainer &gradient, const std::unordered_set< unsigned int > &variable_numbers) const override
const LinearFVGradientReader * _pressure_gradient
Published gradient used to lag the explicit half-cell correction during reconstruction.
FVPressureJumpGreenGaussGradient(const InputParameters &params)
unsigned int _pressure_variable_number
Pressure variable number within the linked system.
Real faceArea() const
Real & faceCoord()
void suppressParameter(const std::string &name)
void addClassDescription(const std::string &doc_string)
const FVGradientMethod & method() const
const SystemBase & system() const
unsigned int variableNumber() const
RealVectorValue gradient(const ElemInfo &elem_info) const
const std::string & name() const
void mooseError(Args &&... args) const
Computes Rhie-Chow face mass fluxes for porous flow with optional internal pressure jumps.
bool pressureDiffusionDataReady() const
Whether the pressure-diffusion kernel and cell coefficients are ready for interface use.
bool faceIsBaffle(const FaceInfo &fi) const
Whether a face is governed by a pressure-jump model.
NS::FV::PressureJumpInterfaceData pressureJumpInterfaceData(const FaceInfo &fi, const RealVectorValue &elem_gradient, const RealVectorValue &neighbor_gradient, Real face_area) const
Construct the complete pressure-jump operator for a face.
Real getSignedBaffleJump(const FaceInfo &fi, bool elem_side) const
Return the pressure jump seen from one side of a baffle face.
const LinearSystem & pressureSystem() const
Pressure linear system.
unsigned int pressureVariableNumber() const
Variable number of the pressure variable reconstructed by this object.
unsigned int number() 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)
Real pressureJumpOneSidedFaceValue(const PressureJumpInterfaceData &data, const Real cell_pressure, const Real mass_flux, const bool elem_side)
Recover one side's face pressure from the common oriented face mass flux.
Real pressureJumpHbyAFlux(const PressureJumpInterfaceData &data)
Compute the H/A part of the face mass flux after eliminating the interface pressures.
Real pressureJumpFlux(const PressureJumpInterfaceData &data, const Real elem_pressure, const Real neighbor_pressure)
Compute the pressure part of the element-to-neighbor flux after eliminating the interface pressures.