https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVPorousFlowAdvectiveFluxBC.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
11#include "PorousFlowDictator.h"
12#include "FVDirichletBC.h"
13
15
18{
20 RealVectorValue g(0, 0, -9.81);
21 params.addParam<RealVectorValue>("gravity", g, "Gravity vector. Defaults to (0, 0, -9.81)");
22 params.addRequiredParam<UserObjectName>("PorousFlowDictator",
23 "The PorousFlowDictator UserObject");
24 params.addParam<unsigned int>("phase", 0, "The fluid phase for this BC");
25 params.addParam<unsigned int>("fluid_component", 0, "The fluid component for this BC");
26 params.addClassDescription("Advective Darcy flux boundary condition");
27 params.addRequiredParam<Real>("porepressure_value", "The porepressure value on the boundary");
28 return params;
29}
30
32 : FVFluxBC(params),
33 _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
34 _num_phases(_dictator.numPhases()),
35 _phase(getParam<unsigned int>("phase")),
36 _fluid_component(getParam<unsigned int>("fluid_component")),
37 _density(getADMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
38 _density_neighbor(
39 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
40 _viscosity(getADMaterialProperty<std::vector<Real>>("PorousFlow_viscosity_qp")),
41 _viscosity_neighbor(
42 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_viscosity_qp")),
43 _relperm(getADMaterialProperty<std::vector<Real>>("PorousFlow_relative_permeability_qp")),
44 _relperm_neighbor(
45 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_relative_permeability_qp")),
46 _mass_fractions(
47 getADMaterialProperty<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_qp")),
48 _mass_fractions_neighbor(
49 getNeighborADMaterialProperty<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_qp")),
50 _permeability(getADMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")),
51 _permeability_neighbor(
52 getNeighborADMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")),
53 _pressure(getADMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_qp")),
54 _pressure_neighbor(
55 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_qp")),
56 _gravity(getParam<RealVectorValue>("gravity")),
57 _pp_value(getParam<Real>("porepressure_value"))
58{
59 if (_phase >= _num_phases)
61 "phase",
62 "The Dictator proclaims that the maximum fluid phase index in this simulation is ",
63 _num_phases - 1,
64 " whereas you have used ",
65 _phase,
66 ". Remember that indexing starts at 0. The Dictator does not take such mistakes lightly.");
67
70 "fluid_component",
71 "The Dictator proclaims that the maximum fluid component index in this simulation is ",
73 " whereas you have used ",
75 ". Remember that indexing starts at 0.");
76
77 // Add a FVDirichletBC to boundary for cell gradient computation
78 if (_tid == 0)
79 {
80 auto diri_params = FVDirichletBC::validParams();
81 diri_params.applySpecificParameters(_pars, {"variable", "boundary"});
82 diri_params.addPrivateParam(MooseBase::app_param, &_app);
83 diri_params.set<Real>("value") = _pp_value;
84 _fv_problem.addFVBC("FVDirichletBC", name() + "_diri", diri_params);
86 }
87}
88
91{
92 const bool out_of_elem = (_face_type == FaceInfo::VarFaceNeighbors::ELEM);
93
94 const auto p_interior = out_of_elem ? _pressure[_qp][_phase] : _pressure_neighbor[_qp][_phase];
95 const auto delta_p = out_of_elem ? p_interior - _pp_value : _pp_value - p_interior;
96 const auto gradp = delta_p * _face_info->eCN() / _face_info->dCNMag();
97
98 const auto mobility =
104
105 const auto pressure_grad = gradp + _density[_qp][_phase] * _gravity;
106
107 return mobility * pressure_grad * _normal;
108}
DualNumber< Real, DNDerivativeType, true > ADReal
registerADMooseObject("PorousFlowApp", FVPorousFlowAdvectiveFluxBC)
void ErrorVector unsigned int
virtual void addFVBC(const std::string &fv_bc_name, const std::string &name, InputParameters &parameters)
bool fvBCsIntegrityCheck() const
FEProblemBase & _fv_problem
THREAD_ID _tid
const FaceInfo * _face_info
static InputParameters validParams()
ADRealVectorValue _normal
FaceInfo::VarFaceNeighbors _face_type
const unsigned int _qp
static InputParameters validParams()
Flux boundary condition where an advective flux is applied.
const ADMaterialProperty< std::vector< std::vector< Real > > > & _mass_fractions
Mass fraction of fluid components in fluid phases.
const ADMaterialProperty< std::vector< Real > > & _pressure
Fluid pressure.
const unsigned int _fluid_component
Index of the fluid component this BC applies to.
const ADMaterialProperty< RealTensorValue > & _permeability
Permeability.
const ADMaterialProperty< std::vector< Real > > & _density_neighbor
const PorousFlowDictator & _dictator
UserObject that holds information (number of phases, components, etc)
const ADMaterialProperty< std::vector< Real > > & _relperm
Relative permeability.
const ADMaterialProperty< std::vector< Real > > & _relperm_neighbor
const ADMaterialProperty< std::vector< Real > > & _viscosity_neighbor
FVPorousFlowAdvectiveFluxBC(const InputParameters &params)
const unsigned int _num_phases
Number of fluid phases present.
const ADMaterialProperty< std::vector< std::vector< Real > > > & _mass_fractions_neighbor
const ADMaterialProperty< std::vector< Real > > & _density
Fluid density.
const ADMaterialProperty< std::vector< Real > > & _pressure_neighbor
const ADMaterialProperty< RealTensorValue > & _permeability_neighbor
const ADMaterialProperty< std::vector< Real > > & _viscosity
Fluid viscosity.
const Real _pp_value
The porepressure value at the boundary.
const RealVectorValue & _gravity
Gravity vector.
virtual ADReal computeQpResidual() override
const unsigned int _phase
Index of the fluid phase this BC applies to.
const Point & eCN() const
Real dCNMag() const
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)
const std::string & name() const
void paramError(const std::string &param, Args... args) const
const InputParameters & _pars
static const std::string app_param
MooseApp & _app
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
unsigned int numComponents() const
The number of fluid components.