Line data Source code
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 : 10 : #include "PorousFlowDiffusivityBase.h" 11 : 12 : template <bool is_ad> 13 : InputParameters 14 1632 : PorousFlowDiffusivityBaseTempl<is_ad>::validParams() 15 : { 16 1632 : InputParameters params = PorousFlowMaterialVectorBase::validParams(); 17 3264 : 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 1632 : params.addClassDescription("Base class for effective diffusivity for each phase"); 23 1632 : params.set<bool>("at_nodes") = false; 24 3264 : params.addPrivateParam<std::string>("pf_material_type", "diffusivity"); 25 1632 : return params; 26 0 : } 27 : 28 : template <bool is_ad> 29 1278 : PorousFlowDiffusivityBaseTempl<is_ad>::PorousFlowDiffusivityBaseTempl( 30 : const InputParameters & parameters) 31 : : PorousFlowMaterialVectorBase(parameters), 32 : 33 1278 : _tortuosity(declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_tortuosity_qp")), 34 1278 : _dtortuosity_dvar( 35 : is_ad ? nullptr 36 1080 : : &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_tortuosity_qp_dvar")), 37 1278 : _diffusion_coeff( 38 1278 : declareProperty<std::vector<std::vector<Real>>>("PorousFlow_diffusion_coeff_qp")), 39 1278 : _ddiffusion_coeff_dvar(is_ad ? nullptr 40 1080 : : &declareProperty<std::vector<std::vector<std::vector<Real>>>>( 41 : "dPorousFlow_diffusion_coeff_qp_dvar")), 42 5112 : _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 45 1278 : if (_input_diffusion_coeff.size() != _num_phases * _num_components) 46 0 : this->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 1278 : if (_nodal_material == true) 52 0 : mooseError("PorousFlowRelativeDiffusivity classes are only defined for at_nodes = false"); 53 1278 : } 54 : 55 : template <bool is_ad> 56 : void 57 2066380 : PorousFlowDiffusivityBaseTempl<is_ad>::computeQpProperties() 58 : { 59 2066380 : _diffusion_coeff[_qp].resize(_num_phases); 60 2066380 : _tortuosity[_qp].resize(_num_phases); 61 : 62 : if (!is_ad) 63 : { 64 1695860 : (*_ddiffusion_coeff_dvar)[_qp].resize(_num_phases); 65 1695860 : (*_dtortuosity_dvar)[_qp].resize(_num_phases); 66 : } 67 : 68 4465640 : for (unsigned int ph = 0; ph < _num_phases; ++ph) 69 : { 70 2399260 : _diffusion_coeff[_qp][ph].resize(_num_components); 71 : 72 : if (!is_ad) 73 : { 74 1786820 : (*_ddiffusion_coeff_dvar)[_qp][ph].resize(_num_components); 75 1786820 : (*_dtortuosity_dvar)[_qp][ph].assign(_num_var, 0.0); 76 : } 77 : 78 7754340 : for (unsigned int comp = 0; comp < _num_components; ++comp) 79 : { 80 5355080 : _diffusion_coeff[_qp][ph][comp] = _input_diffusion_coeff[ph + comp]; 81 : 82 : if (!is_ad) 83 4130200 : (*_ddiffusion_coeff_dvar)[_qp][ph][comp].assign(_num_var, 0.0); 84 : } 85 : } 86 2066380 : } 87 : 88 : template class PorousFlowDiffusivityBaseTempl<false>; 89 : template class PorousFlowDiffusivityBaseTempl<true>;