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