https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowFullySaturatedAdvectiveFlux.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
14
15template <bool is_ad>
18{
20 params.addParam<unsigned int>(
21 "fluid_component", 0, "The index corresponding to the fluid component for this kernel");
22 params.addParam<bool>("multiply_by_density",
23 true,
24 "If true, then this Kernel is the fluid mass "
25 "flux. If false, then this Kernel is the "
26 "fluid volume flux (which is common in "
27 "poro-mechanics)");
28 params.addClassDescription("Fully-upwinded advective flux of the fluid component given by "
29 "fluid_component, in a single-phase fluid");
30 return params;
31}
32
33template <bool is_ad>
35 const InputParameters & parameters)
36 : PorousFlowDarcyBaseTempl<is_ad>(parameters),
37 _mass_fractions(
38 this->template getGenericMaterialProperty<std::vector<std::vector<Real>>, is_ad>(
39 "PorousFlow_mass_frac_nodal")),
40 _dmass_fractions_dvar(
41 is_ad ? nullptr
42 : &this->template getMaterialProperty<std::vector<std::vector<std::vector<Real>>>>(
43 "dPorousFlow_mass_frac_nodal_dvar")),
44 _fluid_component(this->template getParam<unsigned int>("fluid_component")),
45 _multiply_by_density(this->template getParam<bool>("multiply_by_density"))
46{
47 if (_dictator.numPhases() != 1)
49 "PorousFlowFullySaturatedAdvectiveFlux should not be used for multi-phase scenarios as "
50 "it does not include relative-permeability effects");
51}
52
53template <bool is_ad>
56{
57 if (_multiply_by_density == false)
58 return _mass_fractions[nodenum][phase][_fluid_component] / _fluid_viscosity[nodenum][phase];
59 return _mass_fractions[nodenum][phase][_fluid_component] * _fluid_density_node[nodenum][phase] /
60 _fluid_viscosity[nodenum][phase];
61}
62
63template <bool is_ad>
64Real
66 unsigned phase,
67 unsigned pvar) const
68{
69 if constexpr (!is_ad)
70 {
71 if (_multiply_by_density == false)
72 return (*_dmass_fractions_dvar)[nodenum][phase][_fluid_component][pvar] /
73 _fluid_viscosity[nodenum][phase] -
74 _mass_fractions[nodenum][phase][_fluid_component] *
75 (*_dfluid_viscosity_dvar)[nodenum][phase][pvar] /
76 Utility::pow<2>(_fluid_viscosity[nodenum][phase]);
77 Real dm = (*_dmass_fractions_dvar)[nodenum][phase][_fluid_component][pvar] *
78 _fluid_density_node[nodenum][phase] / _fluid_viscosity[nodenum][phase];
79 dm += _mass_fractions[nodenum][phase][_fluid_component] *
80 (*_dfluid_density_node_dvar)[nodenum][phase][pvar] / _fluid_viscosity[nodenum][phase];
81 dm -= _mass_fractions[nodenum][phase][_fluid_component] * _fluid_density_node[nodenum][phase] *
82 (*_dfluid_viscosity_dvar)[nodenum][phase][pvar] /
83 Utility::pow<2>(_fluid_viscosity[nodenum][phase]);
84 return dm;
85 }
86 else
87 libmesh_ignore(nodenum, phase, pvar);
88 return 0.0;
89}
90
Moose::GenericType< Real, is_ad > GenericReal
PetscErrorCode PetscOptionItems *PetscErrorCode DM dm
registerMooseObject("PorousFlowApp", PorousFlowFullySaturatedAdvectiveFlux)
void ErrorVector unsigned int
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 mooseError(Args &&... args) const
Darcy advective flux.
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
static InputParameters validParams()
unsigned int numPhases() const
The number of fluid phases.
Convective flux of component k in a single-phase fluid.
virtual Real dmobility(unsigned nodenum, unsigned phase, unsigned pvar) const override
The derivative of mobility with respect to PorousFlow variable pvar – non-AD path only.
virtual GenericReal< is_ad > mobility(unsigned nodenum, unsigned phase) const override
The mobility of the fluid.
PorousFlowFullySaturatedAdvectiveFluxTempl(const InputParameters &parameters)