www.mooseframework.org
PorousFlowDiffusivityBase.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 
12 template <bool is_ad>
15 {
17  params.addRequiredParam<std::vector<Real>>(
18  "diffusion_coeff",
19  "List of diffusion coefficients. Order is i) component 0 in phase 0; ii) "
20  "component 1 in phase 0 ...; component 0 in phase 1; ... component k in "
21  "phase n (m^2/s");
22  params.addClassDescription("Base class for effective diffusivity for each phase");
23  params.set<bool>("at_nodes") = false;
24  params.addPrivateParam<std::string>("pf_material_type", "diffusivity");
25  return params;
26 }
27 
28 template <bool is_ad>
30  const InputParameters & parameters)
31  : PorousFlowMaterialVectorBase(parameters),
32 
33  _tortuosity(declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_tortuosity_qp")),
34  _dtortuosity_dvar(
35  is_ad ? nullptr
36  : &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_tortuosity_qp_dvar")),
37  _diffusion_coeff(
38  declareProperty<std::vector<std::vector<Real>>>("PorousFlow_diffusion_coeff_qp")),
39  _ddiffusion_coeff_dvar(is_ad ? nullptr
40  : &declareProperty<std::vector<std::vector<std::vector<Real>>>>(
41  "dPorousFlow_diffusion_coeff_qp_dvar")),
42  _input_diffusion_coeff(getParam<std::vector<Real>>("diffusion_coeff"))
43 {
44  // Also, the number of diffusion coefficients must be equal to the num_phases * num_components
46  this->template paramError(
47  "diffusion_coeff",
48  "The number of diffusion coefficients entered is not equal to the number of phases "
49  "multiplied by the number of fluid components");
50 
51  if (_nodal_material == true)
52  mooseError("PorousFlowRelativeDiffusivity classes are only defined for at_nodes = false");
53 }
54 
55 template <bool is_ad>
56 void
58 {
59  _diffusion_coeff[_qp].resize(_num_phases);
60  _tortuosity[_qp].resize(_num_phases);
61 
62  if (!is_ad)
63  {
64  (*_ddiffusion_coeff_dvar)[_qp].resize(_num_phases);
65  (*_dtortuosity_dvar)[_qp].resize(_num_phases);
66  }
67 
68  for (unsigned int ph = 0; ph < _num_phases; ++ph)
69  {
70  _diffusion_coeff[_qp][ph].resize(_num_components);
71 
72  if (!is_ad)
73  {
74  (*_ddiffusion_coeff_dvar)[_qp][ph].resize(_num_components);
75  (*_dtortuosity_dvar)[_qp][ph].assign(_num_var, 0.0);
76  }
77 
78  for (unsigned int comp = 0; comp < _num_components; ++comp)
79  {
80  _diffusion_coeff[_qp][ph][comp] = _input_diffusion_coeff[ph + comp];
81 
82  if (!is_ad)
83  (*_ddiffusion_coeff_dvar)[_qp][ph][comp].assign(_num_var, 0.0);
84  }
85  }
86 }
87 
const unsigned int _num_phases
Number of phases.
void addPrivateParam(const std::string &name, const T &value)
void mooseError(Args &&... args)
PorousFlowDiffusivityBaseTempl(const InputParameters &parameters)
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.
Base class Material designed to provide the tortuosity and diffusion coefficents. ...
const unsigned int _num_components
Number of fluid components.
const std::vector< Real > _input_diffusion_coeff
Input diffusion coefficients.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
virtual void computeQpProperties() override