https://mooseframework.inl.gov
PorousFlowHeatMassTransfer.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 
12 #include "MooseVariable.h"
13 
16 
17 template <bool is_ad>
20 {
22 
23  params.addClassDescription(
24  "Calculate heat or mass transfer from a coupled variable v to the variable u. "
25  "No mass lumping is performed here.");
26  params.addRequiredCoupledVar(
27  "v", "The variable which is tranfsered to u using a transfer coefficient");
28  params.addCoupledVar("transfer_coefficient",
29  1.0,
30  "Transfer coefficient for heat or mass transferred between variables");
31 
32  return params;
33 }
34 
35 template <bool is_ad>
37  const InputParameters & parameters)
38  : GenericKernel<is_ad>(parameters),
39  _v_var(coupled("v")),
40  _v(this->template coupledGenericValue<is_ad>("v")),
41  _coef_var(this->template coupledGenericValue<is_ad>("transfer_coefficient"))
42 {
43 }
44 
45 template <bool is_ad>
48 {
49  return _coef_var[_qp] * (_u[_qp] - _v[_qp]) * _test[_i][_qp];
50 }
51 
52 template <bool is_ad>
53 Real
55 {
56  return jac(_var.number());
57 }
58 
59 template <bool is_ad>
60 Real
62 {
63  return jac(jvar);
64 }
65 
66 template <bool is_ad>
67 Real
69 {
70  if constexpr (!is_ad)
71  {
72  if (jvar == _var.number())
73  return _coef_var[_qp] * _phi[_j][_qp] * _test[_i][_qp];
74  else if (jvar == _v_var)
75  return -_coef_var[_qp] * _phi[_j][_qp] * _test[_i][_qp];
76  return 0.0;
77  }
78  else
79  libmesh_ignore(jvar);
80  return 0.0;
81 }
82 
Moose::GenericType< Real, is_ad > GenericReal
static InputParameters validParams()
Calculate heat or mass transfer from a coupled variable to u.
void libmesh_ignore(const Args &...)
virtual Real jac(unsigned int jvar) const
registerMooseObject("PorousFlowApp", PorousFlowHeatMassTransfer)
PorousFlowHeatMassTransferTempl(const InputParameters &parameters)
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
virtual GenericReal< is_ad > computeQpResidual() override