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 "PorousFlowBasicTHM.h" 11 : 12 : #include "FEProblem.h" 13 : #include "Conversion.h" 14 : #include "libmesh/string_to_enum.h" 15 : 16 : registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_user_object"); 17 : 18 : registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_kernel"); 19 : 20 : registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_material"); 21 : 22 : registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_aux_variable"); 23 : 24 : registerMooseAction("PorousFlowApp", PorousFlowBasicTHM, "add_aux_kernel"); 25 : 26 : InputParameters 27 1910 : PorousFlowBasicTHM::validParams() 28 : { 29 1910 : InputParameters params = PorousFlowSinglePhaseBase::validParams(); 30 3820 : params.addParam<bool>("multiply_by_density", 31 3820 : false, 32 : "If true, then the Kernels for fluid flow are multiplied by " 33 : "the fluid density. If false, this multiplication is not " 34 : "performed, which means the problem linearises, but that care " 35 : "must be taken when using other PorousFlow objects."); 36 1910 : params.addClassDescription("Adds Kernels and fluid-property Materials necessary to simulate a " 37 : "single-phase, single-component fully-saturated flow problem. No " 38 : "upwinding and no mass lumping of the fluid mass are used (the " 39 : "stabilization input parameter is ignored). The " 40 : "fluid-mass time derivative is close to linear, and is perfectly " 41 : "linear if multiply_by_density=false. These features mean the " 42 : "results may differ slightly from the " 43 : "Unsaturated Action case. To run a simulation " 44 : "you will also need to provide various other Materials for each mesh " 45 : "block, depending on your simulation type, viz: permeability, " 46 : "constant Biot modulus, constant thermal expansion coefficient, " 47 : "porosity, elasticity tensor, strain calculator, stress calculator, " 48 : "matrix internal energy, thermal conductivity, diffusivity"); 49 1910 : return params; 50 0 : } 51 : 52 1910 : PorousFlowBasicTHM::PorousFlowBasicTHM(const InputParameters & params) 53 3820 : : PorousFlowSinglePhaseBase(params), _multiply_by_density(getParam<bool>("multiply_by_density")) 54 : { 55 1910 : if (_num_mass_fraction_vars != 0) 56 0 : mooseError("PorousFlowBasicTHM can only be used for a single-component fluid, so that no " 57 : "mass-fraction variables should be provided"); 58 1910 : } 59 : 60 : void 61 1876 : PorousFlowBasicTHM::addMaterialDependencies() 62 : { 63 1876 : PorousFlowSinglePhaseBase::addMaterialDependencies(); 64 : 65 : // Add necessary objects to list of PorousFlow objects added by this action 66 1876 : _included_objects.push_back("PorousFlowFullySaturatedDarcyBase"); 67 : 68 1876 : if (_transient) 69 3182 : _included_objects.push_back("PorousFlowFullySaturatedMassTimeDerivative"); 70 : 71 1876 : if (_thermal) 72 1060 : _included_objects.push_back("PorousFlowFullySaturatedHeatAdvection"); 73 1876 : } 74 : 75 : void 76 364 : PorousFlowBasicTHM::addKernels() 77 : { 78 364 : PorousFlowSinglePhaseBase::addKernels(); 79 : 80 364 : std::string kernel_name = "PorousFlowBasicTHM_DarcyFlow"; 81 364 : std::string kernel_type = "PorousFlowFullySaturatedDarcyBase"; 82 364 : InputParameters params = _factory.getValidParams(kernel_type); 83 364 : if (_subdomain_names_set) 84 228 : params.set<std::vector<SubdomainName>>("block") = _subdomain_names; 85 728 : params.set<UserObjectName>("PorousFlowDictator") = _dictator_name; 86 364 : params.set<RealVectorValue>("gravity") = _gravity; 87 364 : params.set<bool>("multiply_by_density") = _multiply_by_density; 88 728 : params.set<NonlinearVariableName>("variable") = _pp_var; 89 364 : _problem->addKernel(kernel_type, kernel_name, params); 90 : 91 364 : if (_transient) 92 : { 93 307 : std::string kernel_name = "PorousFlowBasicTHM_MassTimeDerivative"; 94 307 : std::string kernel_type = "PorousFlowFullySaturatedMassTimeDerivative"; 95 307 : InputParameters params = _factory.getValidParams(kernel_type); 96 307 : if (_subdomain_names_set) 97 228 : params.set<std::vector<SubdomainName>>("block") = _subdomain_names; 98 614 : params.set<UserObjectName>("PorousFlowDictator") = _dictator_name; 99 614 : params.set<NonlinearVariableName>("variable") = _pp_var; 100 307 : params.set<Real>("biot_coefficient") = _biot_coefficient; 101 307 : params.set<bool>("multiply_by_density") = _multiply_by_density; 102 614 : params.set<MooseEnum>("coupling_type") = parameters().get<MooseEnum>("coupling_type"); 103 307 : if (_save_component_rate_in.size() != 0) 104 38 : params.set<std::vector<AuxVariableName>>("save_in") = _save_component_rate_in; 105 614 : params.set<NonlinearVariableName>("variable") = _pp_var; 106 307 : _problem->addKernel(kernel_type, kernel_name, params); 107 307 : } 108 : 109 364 : if (_thermal) 110 : { 111 106 : std::string kernel_name = "PorousFlowBasicTHM_HeatAdvection"; 112 106 : std::string kernel_type = "PorousFlowFullySaturatedHeatAdvection"; 113 106 : InputParameters params = _factory.getValidParams(kernel_type); 114 106 : if (_subdomain_names_set) 115 0 : params.set<std::vector<SubdomainName>>("block") = _subdomain_names; 116 212 : params.set<NonlinearVariableName>("variable") = _temperature_var[0]; 117 212 : params.set<UserObjectName>("PorousFlowDictator") = _dictator_name; 118 106 : params.set<RealVectorValue>("gravity") = _gravity; 119 106 : _problem->addKernel(kernel_type, kernel_name, params); 120 106 : } 121 728 : } 122 : 123 : void 124 382 : PorousFlowBasicTHM::addMaterials() 125 : { 126 382 : PorousFlowSinglePhaseBase::addMaterials(); 127 : 128 764 : if (_deps.dependsOn(_included_objects, "pressure_saturation_qp")) 129 : { 130 382 : std::string material_type = "PorousFlow1PhaseFullySaturated"; 131 382 : std::string material_name = "PorousFlowBasicTHM_1PhaseP_qp"; 132 382 : InputParameters params = _factory.getValidParams(material_type); 133 382 : if (_subdomain_names_set) 134 228 : params.set<std::vector<SubdomainName>>("block") = _subdomain_names; 135 764 : params.set<UserObjectName>("PorousFlowDictator") = _dictator_name; 136 1146 : params.set<std::vector<VariableName>>("porepressure") = {_pp_var}; 137 382 : params.set<bool>("at_nodes") = false; 138 382 : _problem->addMaterial(material_type, material_name, params); 139 382 : } 140 : 141 764 : if (_deps.dependsOn(_included_objects, "pressure_saturation_nodal")) 142 : { 143 144 : std::string material_type = "PorousFlow1PhaseFullySaturated"; 144 144 : std::string material_name = "PorousFlowBasicTHM_1PhaseP"; 145 144 : InputParameters params = _factory.getValidParams(material_type); 146 144 : if (_subdomain_names_set) 147 0 : params.set<std::vector<SubdomainName>>("block") = _subdomain_names; 148 288 : params.set<UserObjectName>("PorousFlowDictator") = _dictator_name; 149 432 : params.set<std::vector<VariableName>>("porepressure") = {_pp_var}; 150 144 : params.set<bool>("at_nodes") = true; 151 144 : _problem->addMaterial(material_type, material_name, params); 152 144 : } 153 : 154 821 : if ((_deps.dependsOn(_included_objects, "volumetric_strain_qp") || 155 821 : _deps.dependsOn(_included_objects, "volumetric_strain_nodal")) && 156 325 : _mechanical) 157 171 : addVolumetricStrainMaterial(_coupled_displacements, _base_name); 158 : 159 : // Relative permeability might be needed by Darcy-velocity Aux, so add a material 160 : // setting kr=1 161 764 : if (_deps.dependsOn(_included_objects, "relative_permeability_qp")) 162 363 : addRelativePermeabilityConst(false, 0, 1.0); 163 : 164 : // Some obects not added by this action might have a use_mobility = true param, 165 : // which needs a nodal relative permeability 166 764 : if (_deps.dependsOn(_included_objects, "relative_permeability_nodal")) 167 133 : addRelativePermeabilityConst(true, 0, 1.0); 168 382 : }