https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PINSFVFunctorBC.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//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "PINSFVFunctorBC.h"
11#include "NS.h"
13#include "Function.h"
14#include "SystemBase.h"
15
16registerMooseObject("NavierStokesTestApp", PINSFVFunctorBC);
17
20{
22 params += INSFVFlowBC::validParams();
24 params.makeParamNotRequired<MooseEnum>("momentum_component");
25 params.addClassDescription("Computes the residual of the advective and pressure term (the latter "
26 "when this object is added for the momentum equation) on a boundary.");
27 params.addParam<MaterialPropertyName>(NS::density, NS::density, "The density material property");
28 MooseEnum eqn("mass momentum");
29 params.addRequiredParam<MooseEnum>("eqn", eqn, "The equation you're solving.");
31 "The x-component of the superficial velocity");
32 params.addCoupledVar(NS::superficial_velocity_y, "The y-component of the superficial velocity");
33 params.addCoupledVar(NS::superficial_velocity_z, "The z-component of the superficial velocity");
34 params.addRequiredCoupledVar(NS::pressure, "The pressure");
35 params.addRequiredCoupledVar(NS::porosity, "The porosity");
36 MooseEnum advected_interp_method("average upwind", "upwind");
37 params.addParam<MooseEnum>("advected_interp_method",
38 advected_interp_method,
39 "The interpolation to use for the advected quantity. Options are "
40 "'upwind' and 'average', with the default being 'upwind'.");
41 return params;
42}
43
45 : FVFluxBC(params),
46 INSFVFlowBC(params),
48 _sup_vel_x(getFunctor<ADReal>(NS::superficial_velocity_x)),
49 _sup_vel_y(isParamValid(NS::superficial_velocity_y)
50 ? &getFunctor<ADReal>(NS::superficial_velocity_y)
51 : nullptr),
52 _sup_vel_z(isParamValid(NS::superficial_velocity_z)
53 ? &getFunctor<ADReal>(NS::superficial_velocity_z)
54 : nullptr),
55 _pressure(getFunctor<ADReal>(NS::pressure)),
56 _rho(getFunctor<ADReal>(NS::density)),
57 _eps(getFunctor<ADReal>(NS::porosity)),
58 _eqn(getParam<MooseEnum>("eqn")),
59 _index(getParam<MooseEnum>("momentum_component"))
60{
61 if ((_eqn == "momentum") && !isParamValid("momentum_component"))
62 paramError("eqn",
63 "If 'momentum' is specified for 'eqn', then you must provide a parameter "
64 "value for 'momentum_component'");
65 if ((_eqn != "momentum") && isParamValid("momentum_component"))
66 paramError("momentum_component",
67 "'momentum_component' should not be specified when the 'eqn' is not 'momentum'");
68
69 using namespace Moose::FV;
70
71 const auto & advected_interp_method = getParam<MooseEnum>("advected_interp_method");
72 if (advected_interp_method == "average")
73 _advected_interp_method = InterpMethod::Average;
74 else if (advected_interp_method == "upwind")
75 _advected_interp_method = InterpMethod::Upwind;
76 else
77 mooseError("Unrecognized interpolation type ",
78 static_cast<std::string>(advected_interp_method));
79}
80
83{
84 const auto ft = _face_info->faceType(std::make_pair(_var.number(), _var.sys().number()));
85 const bool out_of_elem = (ft == FaceInfo::VarFaceNeighbors::ELEM);
86 const auto normal = out_of_elem ? _face_info->normal() : Point(-_face_info->normal());
87 const auto & elem = out_of_elem ? _face_info->elem() : _face_info->neighbor();
88
89 // No interpolation on a boundary so argument values to fi_elem_is_upwind do not
90 // matter
91 const auto boundary_face = singleSidedFaceArg();
92 const auto state = determineState();
93
94 const VectorValue<ADReal> sup_vel(_sup_vel_x(boundary_face, state),
95 _sup_vel_y ? (*_sup_vel_y)(boundary_face, state) : ADReal(0),
96 _sup_vel_z ? (*_sup_vel_z)(boundary_face, state) : ADReal(0));
97 const auto rho = _rho(boundary_face, state);
98
99 if (_eqn == "mass")
100 return rho * sup_vel * normal;
101 else if (_eqn == "momentum")
102 {
103 const auto eps = _eps(boundary_face, state);
104 // the value of our variable on the boundary could be a function of multiple degrees of freedom
105 // (think two term boundary expansion), as opposed to just a function of the degree of freedom
106 // at the adjoining cell centroid.
108 {
109 const auto dof_number = elem.dof_number(_sys.number(), _var.number(), 0);
110 _a = sup_vel(_index).derivatives()[dof_number];
111 _a *= rho / eps * sup_vel * normal;
112 }
113 const auto rhou = sup_vel(_index) / eps * rho;
114 return rhou * sup_vel * normal + eps * _pressure(boundary_face, state) * normal(_index);
115 }
116 else
117 mooseError("Unrecognized equation type ", _eqn);
118}
119
120void
122{
123 _face_info = &fi;
124 _face_type = fi.faceType(std::make_pair(_var.number(), _var.sys().number()));
125
126 _computing_rc_data = true;
127 // Fill-in the coefficient _a (but without multiplication by A)
129 _computing_rc_data = false;
130
131 _rc_uo.addToA((_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? &fi.elem() : fi.neighborPtr(),
132 _index,
133 _a * (fi.faceArea() * fi.faceCoord()));
134}
DualNumber< Real, DNDerivativeType, true > ADReal
const double rho
registerMooseObject("NavierStokesTestApp", PINSFVFunctorBC)
SystemBase & _sys
MooseVariableFV< Real > & _var
const FaceInfo * _face_info
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
FaceInfo::VarFaceNeighbors _face_type
const ADRealVectorValue & normal() const
static InputParameters validParams()
const Point & normal() const
VarFaceNeighbors faceType(const std::pair< unsigned int, unsigned int > &var_sys) const
const Elem & elem() const
const Elem * neighborPtr() const
Real faceArea() const
Real & faceCoord()
const Elem & neighbor() const
A parent class for INSFV flow boundary conditions.
Definition INSFVFlowBC.h:18
static InputParameters validParams()
Definition INSFVFlowBC.C:14
All objects that contribute to pressure-based (e.g.
RhieChowInterpolatorBase & _rc_uo
The Rhie Chow user object that is responsible for generating face velocities for advection terms.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
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)
void addClassDescription(const std::string &doc_string)
void makeParamNotRequired(const std::string &name)
void addCoupledVar(const std::string &name, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
bool isParamValid(const std::string &name) const
SystemBase & sys()
unsigned int number() const
Evaluates boundary mass or momentum fluxes through functor evaluation of the superficial velocities,...
const Moose::Functor< ADReal > *const _sup_vel_y
The y component of the superficial velocity.
const MooseEnum _eqn
Denotes the equation we're computing the boundary fluxes for. Options are either "mass" or "momentum"...
const Moose::Functor< ADReal > & _pressure
The pressure.
PINSFVFunctorBC(const InputParameters &params)
const Moose::Functor< ADReal > & _rho
The density.
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
const Moose::Functor< ADReal > *const _sup_vel_z
The z component of the superficial velocity.
const Moose::Functor< ADReal > & _sup_vel_x
The x component of the superficial velocity.
bool _computing_rc_data
Whether we are computing Rhie-Chow data.
static InputParameters validParams()
ADReal _a
Local variable to hold this object's contribution to the Rhie-Chow 'a' coefficient.
const Moose::Functor< ADReal > & _eps
The porosity.
const unsigned int _index
If computing the boundary fluxes for the momentum equation, this denotes the component of the momentu...
virtual ADReal computeQpResidual() override
void gatherRCData(const Elem &) override final
Should be a non-empty implementation if the residual object is a FVElementalKernel and introduces res...
virtual void addToA(const libMesh::Elem *elem, unsigned int component, const ADReal &value)=0
API for momentum residual objects that have on-diagonals for velocity call.
unsigned int number() const
Moose::StateArg determineState() const
static const std::string superficial_velocity_y
Definition NS.h:52
static const std::string density
Definition NS.h:34
static const std::string superficial_velocity_z
Definition NS.h:53
static const std::string porosity
Definition NS.h:108
static const std::string superficial_velocity_x
Definition NS.h:51
static const std::string pressure
Definition NS.h:57