https://mooseframework.inl.gov
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)
60  paramError(
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 
69  paramError(
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("_moose_app", &_app);
83  diri_params.set<Real>("value") = _pp_value;
84  _fv_problem.addFVBC("FVDirichletBC", name() + "_diri", diri_params);
86  }
87 }
88 
89 ADReal
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 }
const ADMaterialProperty< std::vector< Real > > & _pressure_neighbor
static InputParameters validParams()
const RealVectorValue & _gravity
Gravity vector.
const FaceInfo * _face_info
FaceInfo::VarFaceNeighbors _face_type
const ADMaterialProperty< std::vector< Real > > & _pressure
Fluid pressure.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
const ADMaterialProperty< RealTensorValue > & _permeability
Permeability.
const unsigned int _num_phases
Number of fluid phases present.
const unsigned int _fluid_component
Index of the fluid component this BC applies to.
unsigned int numComponents() const
The number of fluid components.
Flux boundary condition where an advective flux is applied.
const ADMaterialProperty< std::vector< std::vector< Real > > > & _mass_fractions_neighbor
DualNumber< Real, DNDerivativeType, true > ADReal
virtual const std::string & name() const
const ADMaterialProperty< std::vector< Real > > & _relperm_neighbor
void addRequiredParam(const std::string &name, const std::string &doc_string)
const ADMaterialProperty< RealTensorValue > & _permeability_neighbor
const ADMaterialProperty< std::vector< std::vector< Real > > > & _mass_fractions
Mass fraction of fluid components in fluid phases.
const unsigned int _qp
TensorValue< Real > RealTensorValue
const ADMaterialProperty< std::vector< Real > > & _viscosity
Fluid viscosity.
const ADMaterialProperty< std::vector< Real > > & _density_neighbor
const ADMaterialProperty< std::vector< Real > > & _relperm
Relative permeability.
const Real _pp_value
The porepressure value at the boundary.
bool fvBCsIntegrityCheck() const
ADRealVectorValue _normal
FEProblemBase & _fv_problem
void paramError(const std::string &param, Args... args) const
Real dCNMag() const
virtual ADReal computeQpResidual() override
THREAD_ID _tid
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Point & eCN() const
MooseApp & _app
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
registerADMooseObject("PorousFlowApp", FVPorousFlowAdvectiveFluxBC)
const ADMaterialProperty< std::vector< Real > > & _viscosity_neighbor
const PorousFlowDictator & _dictator
UserObject that holds information (number of phases, components, etc)
const InputParameters & _pars
void addClassDescription(const std::string &doc_string)
FVPorousFlowAdvectiveFluxBC(const InputParameters &params)
static InputParameters validParams()
virtual void addFVBC(const std::string &fv_bc_name, const std::string &name, InputParameters &parameters)
const ADMaterialProperty< std::vector< Real > > & _density
Fluid density.
void ErrorVector unsigned int
const unsigned int _phase
Index of the fluid phase this BC applies to.