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 "HeatConductionPhysicsBase.h" 11 : 12 : InputParameters 13 230 : HeatConductionPhysicsBase::validParams() 14 : { 15 230 : InputParameters params = PhysicsBase::validParams(); 16 230 : params.addClassDescription("Add the heat conduction physics"); 17 : 18 460 : params.addParam<VariableName>("temperature_name", "T", "Variable name for the temperature"); 19 460 : params.addParam<VariableName>("heat_source_var", "Variable providing the heat source"); 20 460 : params.addParam<std::vector<SubdomainName>>("heat_source_blocks", 21 : "Block restriction of the heat source"); 22 460 : params.addParam<MooseFunctorName>("heat_source_functor", "Functor providing the heat source"); 23 : 24 460 : params.addParam<FunctionName>( 25 460 : "initial_temperature", 300, "Initial value of the temperature variable"); 26 : 27 : // Boundary conditions 28 460 : params.addParam<std::vector<BoundaryName>>( 29 : "heat_flux_boundaries", {}, "Boundaries on which to apply a heat flux"); 30 460 : params.addParam<std::vector<MooseFunctorName>>( 31 : "boundary_heat_fluxes", 32 : {}, 33 : "Functors to compute the heat flux on each boundary in 'heat_flux_boundaries'"); 34 460 : params.addParam<std::vector<BoundaryName>>( 35 : "insulated_boundaries", {}, "Boundaries on which to apply a zero heat flux"); 36 460 : params.addParam<std::vector<BoundaryName>>( 37 : "fixed_temperature_boundaries", {}, "Boundaries on which to apply a fixed temperature"); 38 460 : params.addParam<std::vector<MooseFunctorName>>( 39 : "boundary_temperatures", 40 : {}, 41 : "Functors to compute the heat flux on each boundary in 'fixed_temperature_boundaries'"); 42 460 : params.addParam<std::vector<BoundaryName>>( 43 : "fixed_convection_boundaries", 44 : {}, 45 : "Boundaries on which to apply convection with a neighboring fluid"); 46 460 : params.addParam<std::vector<MooseFunctorName>>( 47 : "fixed_convection_T_fluid", 48 : {}, 49 : "Temperature of the convecting fluid. The user should note that numerous heat transfer " 50 : "coefficient correlation will require this fluid temperature to be the bulk fluid " 51 : "temperature / fluid temperature at an infinite distance."); 52 460 : params.addParam<std::vector<MooseFunctorName>>( 53 : "fixed_convection_htc", {}, "Heat transfer coefficient for convection with a fluid"); 54 460 : params.addParamNamesToGroup( 55 : "heat_flux_boundaries insulated_boundaries fixed_temperature_boundaries boundary_heat_fluxes " 56 : "boundary_temperatures", 57 : "Thermal boundaries"); 58 : 59 : // Preconditioning is implemented so let's use it by default 60 460 : MooseEnum pc_options("default defer", "default"); 61 460 : params.addParam<MooseEnum>( 62 : "preconditioning", pc_options, "Which preconditioning to use for this Physics"); 63 : 64 230 : return params; 65 230 : } 66 : 67 230 : HeatConductionPhysicsBase::HeatConductionPhysicsBase(const InputParameters & parameters) 68 460 : : PhysicsBase(parameters), _temperature_name(getParam<VariableName>("temperature_name")) 69 : { 70 : // Save variables (for initialization from file for example) 71 230 : saveSolverVariableName(_temperature_name); 72 : 73 : // Parameter checking 74 460 : checkVectorParamsSameLength<BoundaryName, MooseFunctorName>("heat_flux_boundaries", 75 : "boundary_heat_fluxes"); 76 460 : checkVectorParamsSameLength<BoundaryName, MooseFunctorName>("fixed_temperature_boundaries", 77 : "boundary_temperatures"); 78 230 : checkVectorParamsNoOverlap<BoundaryName>({"heat_flux_boundaries", 79 : "insulated_boundaries", 80 : "fixed_temperature_boundaries", 81 : "fixed_convection_boundaries"}); 82 : 83 230 : addRequiredPhysicsTask("add_preconditioning"); 84 230 : } 85 : 86 : void 87 230 : HeatConductionPhysicsBase::addInitialConditions() 88 : { 89 : // error on inconsistent user selections 90 690 : if (getParam<bool>("initialize_variables_from_mesh_file") && 91 272 : isParamSetByUser("initial_temperature")) 92 2 : paramError("initial_temperature", 93 : "Initial temperature should not be set if the variables should be initialized from " 94 : "the mesh file"); 95 : // do not set initial conditions if we load from file 96 456 : if (getParam<bool>("initialize_variables_from_mesh_file")) 97 : return; 98 : 99 : // Always obey the user, but dont set a hidden default when restarting 100 836 : if (shouldCreateIC(_temperature_name, 101 209 : _blocks, 102 627 : /*whether IC is a default*/ !isParamSetByUser("initial_temperature"), 103 418 : /*error if already an IC*/ isParamSetByUser("initial_temperature"))) 104 : { 105 204 : InputParameters params = getFactory().getValidParams("FunctionIC"); 106 204 : assignBlocks(params, _blocks); 107 204 : params.set<VariableName>("variable") = _temperature_name; 108 612 : params.set<FunctionName>("function") = getParam<FunctionName>("initial_temperature"); 109 612 : getProblem().addInitialCondition("FunctionIC", prefix() + _temperature_name + "_ic", params); 110 204 : } 111 : } 112 : 113 : void 114 230 : HeatConductionPhysicsBase::addPreconditioning() 115 : { 116 : // Use a multigrid method, known to work for elliptic problems such as diffusion 117 230 : if (_preconditioning == "default") 118 : { 119 : // We only pass petsc options as that's all that's needed to set up the preconditioner 120 : const auto option_pair1 = 121 460 : std::make_pair<MooseEnumItem, std::string>(MooseEnumItem("-pc_type"), "hypre"); 122 : const auto option_pair2 = 123 460 : std::make_pair<MooseEnumItem, std::string>(MooseEnumItem("-pc_hypre_type"), "boomeramg"); 124 690 : addPetscPairsToPetscOptions({option_pair1, option_pair2}); 125 230 : } 126 460 : }