https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowBasicAdvection.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.addRequiredParam<UserObjectName>(
21 "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
22 params.addParam<unsigned int>("phase", 0, "Use the Darcy velocity of this fluid phase");
24 "Advective flux of a Variable using the Darcy velocity of the fluid phase");
25 return params;
26}
27
28template <bool is_ad>
30 const InputParameters & parameters)
31 : GenericKernel<is_ad>(parameters),
32 _dictator(this->template getUserObject<PorousFlowDictator>("PorousFlowDictator")),
33 _ph(this->template getParam<unsigned int>("phase")),
34 _darcy_velocity(this->template getGenericMaterialProperty<std::vector<RealVectorValue>, is_ad>(
35 "PorousFlow_darcy_velocity_qp")),
36 _ddarcy_velocity_dvar(
37 is_ad ? nullptr
38 : &this->template getMaterialProperty<std::vector<std::vector<RealVectorValue>>>(
39 "dPorousFlow_darcy_velocity_qp_dvar")),
40 _ddarcy_velocity_dgradvar(is_ad ? nullptr
41 : &this->template getMaterialProperty<
42 std::vector<std::vector<std::vector<RealVectorValue>>>>(
43 "dPorousFlow_darcy_velocity_qp_dgradvar"))
44{
45 if (_ph >= _dictator.numPhases())
46 paramError("phase",
47 "The Dictator proclaims that the maximum phase index in this simulation is ",
48 _dictator.numPhases() - 1,
49 " whereas you have used ",
50 _ph,
51 ". Remember that indexing starts at 0. The Dictator is watching you, to "
52 "ensure your wellbeing.");
53}
54
55template <bool is_ad>
58{
59 return -_grad_test[_i][_qp] * _darcy_velocity[_qp][_ph] * _u[_qp];
60}
61
62template <bool is_ad>
63Real
65{
66 if constexpr (!is_ad)
67 {
68 const Real result = -_grad_test[_i][_qp] * _darcy_velocity[_qp][_ph] * _phi[_j][_qp];
69 return result + computeQpOffDiagJacobian(_var.number());
70 }
71 return 0.0;
72}
73
74template <bool is_ad>
75Real
77{
78 if constexpr (!is_ad)
79 {
80 if (_dictator.notPorousFlowVariable(jvar))
81 return 0.0;
82
83 const unsigned pvar = _dictator.porousFlowVariableNum(jvar);
84 Real result =
85 -_grad_test[_i][_qp] * (*_ddarcy_velocity_dvar)[_qp][_ph][pvar] * _phi[_j][_qp] * _u[_qp];
86 for (unsigned j = 0; j < LIBMESH_DIM; ++j)
87 result -= _grad_test[_i][_qp] *
88 ((*_ddarcy_velocity_dgradvar)[_qp][_ph][j][pvar] * _grad_phi[_j][_qp](j)) * _u[_qp];
89
90 return result;
91 }
92 else
93 {
94 libmesh_ignore(jvar);
95 return 0.0;
96 }
97}
98
Moose::GenericType< Real, is_ad > GenericReal
registerMooseObject("PorousFlowApp", PorousFlowBasicAdvection)
void ErrorVector unsigned int
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)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
Kernel = grad(test) * darcy_velocity * u.
const unsigned _ph
Phase of Darcy velocity.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
virtual Real computeQpJacobian() override
PorousFlowBasicAdvectionTempl(const InputParameters &parameters)
const PorousFlowDictator & _dictator
Holds info on the Porous Flow variables.
virtual GenericReal< is_ad > computeQpResidual() override
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
unsigned int numPhases() const
The number of fluid phases.