www.mooseframework.org
PorousFlowMatrixInternalEnergy.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
15 template <bool is_ad>
18 {
20  params.addRequiredParam<Real>("specific_heat_capacity",
21  "Specific heat capacity of the rock grains (J/kg/K).");
22  params.addRequiredParam<Real>("density", "Density of the rock grains");
23  params.set<bool>("at_nodes") = is_ad ? false : true;
24  params.addPrivateParam<std::string>("pf_material_type", "matrix_internal_energy");
25  params.addClassDescription("This Material calculates the internal energy of solid rock grains, "
26  "which is specific_heat_capacity * density * temperature. Kernels "
27  "multiply this by (1 - porosity) to find the energy density of the "
28  "porous rock in a rock-fluid system");
29  return params;
30 }
31 
32 template <bool is_ad>
34  const InputParameters & parameters)
35  : PorousFlowMaterialVectorBase(parameters),
36  _cp(getParam<Real>("specific_heat_capacity")),
37  _density(getParam<Real>("density")),
38  _heat_cap(_cp * _density),
39  _temperature(is_ad ? getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_qp")
40  : getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_nodal")),
41  _dtemperature_dvar(
42  is_ad ? nullptr
43  : &getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_nodal_dvar")),
44  _energy(declareGenericProperty<Real, is_ad>("PorousFlow_matrix_internal_energy_nodal")),
45  _denergy_dvar(is_ad ? nullptr
46  : &declareProperty<std::vector<Real>>(
47  "dPorousFlow_matrix_internal_energy_nodal_dvar"))
48 {
49  if (!is_ad && _nodal_material != true)
50  mooseError("PorousFlowMatrixInternalEnergy classes are only defined for at_nodes = true");
51 }
52 
53 template <bool is_ad>
54 void
56 {
57  _energy[_qp] = _heat_cap * _temperature[_qp];
58 }
59 
60 template <bool is_ad>
61 void
63 {
64  _energy[_qp] = _heat_cap * _temperature[_qp];
65 
66  if constexpr (!is_ad)
67  {
68  (*_denergy_dvar)[_qp].assign(_num_var, 0.0);
69  for (unsigned v = 0; v < _num_var; ++v)
70  (*_denergy_dvar)[_qp][v] = _heat_cap * (*_dtemperature_dvar)[_qp][v];
71  }
72 }
73 
This material computes internal energy (J/m^3) for a rock matrix assuming constant grain density...
PorousFlowMatrixInternalEnergyTempl(const InputParameters &parameters)
void addPrivateParam(const std::string &name, const T &value)
void mooseError(Args &&... args)
T & set(const std::string &name, bool quiet_mode=false)
void addRequiredParam(const std::string &name, const std::string &doc_string)
Base class for all PorousFlow vector materials.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:82
registerMooseObject("PorousFlowApp", PorousFlowMatrixInternalEnergy)
void addClassDescription(const std::string &doc_string)