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 "PorousFlowVariableBase.h" 11 : 12 : template <bool is_ad> 13 : InputParameters 14 33357 : PorousFlowVariableBaseTempl<is_ad>::validParams() 15 : { 16 33357 : InputParameters params = PorousFlowMaterial::validParams(); 17 66714 : params.addPrivateParam<std::string>("pf_material_type", "pressure_saturation"); 18 33357 : params.addClassDescription("Base class for thermophysical variable materials. Provides pressure " 19 : "and saturation material properties for all phases as required"); 20 33357 : return params; 21 0 : } 22 : 23 : template <bool is_ad> 24 25853 : PorousFlowVariableBaseTempl<is_ad>::PorousFlowVariableBaseTempl(const InputParameters & parameters) 25 : : DerivativeMaterialInterface<PorousFlowMaterial>(parameters), 26 : 27 51706 : _num_phases(_dictator.numPhases()), 28 25853 : _num_components(_dictator.numComponents()), 29 25853 : _num_pf_vars(_dictator.numVariables()), 30 : 31 51706 : _porepressure( 32 25853 : _nodal_material 33 10174 : ? declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_nodal") 34 57211 : : declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_qp")), 35 50902 : _dporepressure_dvar(is_ad ? nullptr 36 25049 : : _nodal_material ? &declareProperty<std::vector<std::vector<Real>>>( 37 : "dPorousFlow_porepressure_nodal_dvar") 38 39924 : : &declareProperty<std::vector<std::vector<Real>>>( 39 : "dPorousFlow_porepressure_qp_dvar")), 40 25853 : _gradp_qp(_nodal_material ? nullptr 41 41532 : : &declareGenericProperty<std::vector<RealGradient>, is_ad>( 42 : "PorousFlow_grad_porepressure_qp")), 43 50902 : _dgradp_qp_dgradv((_nodal_material || is_ad) 44 25049 : ? nullptr 45 25049 : : &declareProperty<std::vector<std::vector<Real>>>( 46 : "dPorousFlow_grad_porepressure_qp_dgradvar")), 47 50902 : _dgradp_qp_dv((_nodal_material || is_ad) 48 25049 : ? nullptr 49 25049 : : &declareProperty<std::vector<std::vector<RealGradient>>>( 50 : "dPorousFlow_grad_porepressure_qp_dvar")), 51 : 52 51706 : _saturation( 53 25853 : _nodal_material 54 10174 : ? declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_nodal") 55 57211 : : declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_saturation_qp")), 56 25853 : _dsaturation_dvar( 57 25049 : is_ad ? nullptr 58 25049 : : _nodal_material 59 10174 : ? &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_nodal_dvar") 60 39924 : : &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_qp_dvar")), 61 25853 : _grads_qp(_nodal_material ? nullptr 62 41532 : : &declareGenericProperty<std::vector<RealGradient>, is_ad>( 63 : "PorousFlow_grad_saturation_qp")), 64 25853 : _dgrads_qp_dgradv((_nodal_material || is_ad) ? nullptr 65 25049 : : &declareProperty<std::vector<std::vector<Real>>>( 66 : "dPorousFlow_grad_saturation_qp_dgradvar")), 67 50902 : _dgrads_qp_dv((_nodal_material || is_ad) 68 25049 : ? nullptr 69 25049 : : &declareProperty<std::vector<std::vector<RealGradient>>>( 70 25853 : "dPorousFlow_grad_saturation_qp_dvar")) 71 : { 72 25853 : } 73 : 74 : template <bool is_ad> 75 : void 76 3301812 : PorousFlowVariableBaseTempl<is_ad>::initQpStatefulProperties() 77 : { 78 3301812 : _porepressure[_qp].resize(_num_phases); 79 3301812 : _saturation[_qp].resize(_num_phases); 80 : // the porepressure and saturation values get set by derived classes 81 3301812 : } 82 : 83 : template <bool is_ad> 84 : void 85 64204144 : PorousFlowVariableBaseTempl<is_ad>::computeQpProperties() 86 : { 87 : // do we really need this stuff here? it seems very inefficient to keep resizing everything! 88 64204144 : _porepressure[_qp].resize(_num_phases); 89 64204144 : _saturation[_qp].resize(_num_phases); 90 : 91 : if (!is_ad) 92 : { 93 63675239 : (*_dporepressure_dvar)[_qp].resize(_num_phases); 94 63675239 : (*_dsaturation_dvar)[_qp].resize(_num_phases); 95 : } 96 : 97 64204144 : if (!_nodal_material) 98 : { 99 35152772 : (*_gradp_qp)[_qp].resize(_num_phases); 100 35152772 : (*_grads_qp)[_qp].resize(_num_phases); 101 : 102 : if (!is_ad) 103 : { 104 34623867 : (*_dgradp_qp_dgradv)[_qp].resize(_num_phases); 105 34623867 : (*_dgradp_qp_dv)[_qp].resize(_num_phases); 106 : 107 34623867 : (*_dgrads_qp_dgradv)[_qp].resize(_num_phases); 108 34623867 : (*_dgrads_qp_dv)[_qp].resize(_num_phases); 109 : } 110 : } 111 : 112 : // Prepare the derivative matrices with zeroes 113 : if (!is_ad) 114 132361428 : for (unsigned phase = 0; phase < _num_phases; ++phase) 115 : { 116 : 117 68686189 : (*_dporepressure_dvar)[_qp][phase].assign(_num_pf_vars, 0.0); 118 68686189 : (*_dsaturation_dvar)[_qp][phase].assign(_num_pf_vars, 0.0); 119 68686189 : if (!_nodal_material) 120 : { 121 37132351 : (*_dgradp_qp_dgradv)[_qp][phase].assign(_num_pf_vars, 0.0); 122 37132351 : (*_dgradp_qp_dv)[_qp][phase].assign(_num_pf_vars, RealGradient()); 123 37132351 : (*_dgrads_qp_dgradv)[_qp][phase].assign(_num_pf_vars, 0.0); 124 37132351 : (*_dgrads_qp_dv)[_qp][phase].assign(_num_pf_vars, RealGradient()); 125 : } 126 : } 127 64204144 : } 128 : 129 : template class PorousFlowVariableBaseTempl<false>; 130 : template class PorousFlowVariableBaseTempl<true>;