https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TestRhieChowMassFluxSequence.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
11#include "RhieChowMassFlux.h"
12
14
17{
19 params.addRequiredParam<UserObjectName>("rhie_chow_user_object", "The Rhie-Chow user object.");
21 "operation",
22 MooseEnum("skip_face_flux_iteration zero_Ainv init_pressure_gradients"),
23 "The reconstruction sequence to test.");
24 params.addParam<VariableName>("pressure", "The pressure variable whose gradient is tested.");
25 params.addParam<GradientMethodName>("gradient_method", "The additional gradient method to test.");
26 return params;
27}
28
30 : GeneralUserObject(parameters),
31 _rhie_chow(
32 const_cast<RhieChowMassFlux &>(getUserObject<RhieChowMassFlux>("rhie_chow_user_object"))),
33 _operation(getParam<MooseEnum>("operation")),
34 _gradient_reader(nullptr)
35{
36 if (_operation == "init_pressure_gradients")
37 {
38 if (!isParamValid("pressure"))
39 paramError("pressure", "This parameter is required for init_pressure_gradients.");
40 if (!isParamValid("gradient_method"))
41 paramError("gradient_method", "This parameter is required for init_pressure_gradients.");
42
43 auto * const pressure = dynamic_cast<MooseLinearVariableFVReal *>(
44 &_subproblem.getVariable(0, getParam<VariableName>("pressure")));
45 if (!pressure)
46 paramError("pressure", "The pressure must be a MooseLinearVariableFVReal.");
47
49 &pressure->requestCellGradients(getParam<GradientMethodName>("gradient_method"));
50 }
51}
52
53void
55{
56 if (_operation == "init_pressure_gradients")
57 {
58 mooseAssert(_gradient_reader, "The additional pressure gradient reader must be linked.");
59
60 for (auto * const component : _gradient_reader->components())
61 {
62 component->zero();
63 component->close();
64 }
65
67
68 bool gradient_is_zero = true;
69 for (const auto * const component : _gradient_reader->components())
70 gradient_is_zero = gradient_is_zero && component->l2_norm() == 0.0;
71
72 if (gradient_is_zero)
73 mooseError("RhieChowMassFlux::initPressureGradient() did not refresh the additional pressure "
74 "gradient reader.");
75 return;
76 }
77
80
81 if (_operation == "skip_face_flux_iteration")
83 else
84 for (auto & Ainv : _rhie_chow.AinvComponents())
85 {
86 Ainv->zero();
87 Ainv->close();
88 }
89
91}
registerMooseObject("NavierStokesTestApp", TestRhieChowMassFluxSequence)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const GradientContainer & components() const
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
void preparePISOCorrector()
Capture the lagged velocity gradient for another corrector using the current predictor.
void computeFaceMassFlux()
Update the values of the face velocities in the containers.
void initPressureGradient()
Compute every registered pressure gradient once, before the first momentum predictor of a SIMPLE iter...
void preparePressureRelaxation()
Before pressure relaxation, form the conservative reconstructed candidate from the corrected face flu...
const std::vector< std::unique_ptr< NumericVector< Number > > > & AinvComponents() const
Get the momentum-layout 1/A component vectors.
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const=0
Exercises Rhie-Chow reconstruction sequencing for validation tests.
const LinearFVGradientReader * _gradient_reader
TestRhieChowMassFluxSequence(const InputParameters &parameters)
SubProblem & _subproblem