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 "HSBoundaryExternalAppHeatFlux.h" 11 : #include "HeatStructureCylindricalBase.h" 12 : #include "HeatConductionModel.h" 13 : 14 : registerMooseObject("ThermalHydraulicsApp", HSBoundaryExternalAppHeatFlux); 15 : 16 : InputParameters 17 16 : HSBoundaryExternalAppHeatFlux::validParams() 18 : { 19 16 : InputParameters params = HSBoundary::validParams(); 20 : 21 32 : params.addRequiredParam<VariableName>( 22 : "heat_flux_name", 23 : "Name to give the heat flux variable transferred from the external application"); 24 32 : params.addParam<bool>( 25 : "heat_flux_is_monomial", 26 32 : true, 27 : "If true, makes the heat flux variable transferred from the external application to have the " 28 : "FE type 'CONSTANT MONOMIAL'. Else, the FE type is 'FIRST LAGRANGE'."); 29 32 : params.addRequiredParam<PostprocessorName>( 30 : "perimeter_ext", "Name to give the external application perimeter post-processor"); 31 32 : params.addRequiredParam<bool>( 32 : "heat_flux_is_inward", 33 : "Set to true if the transferred heat flux corresponds to the inward direction on the heat " 34 : "structure boundary; else the outward direction"); 35 : 36 16 : params.addClassDescription("Heat structure boundary condition to apply a heat flux transferred " 37 : "from another application."); 38 : 39 16 : return params; 40 0 : } 41 : 42 8 : HSBoundaryExternalAppHeatFlux::HSBoundaryExternalAppHeatFlux(const InputParameters & params) 43 : : HSBoundary(params), 44 8 : _heat_flux_name(getParam<VariableName>("heat_flux_name")), 45 24 : _perimeter_ext_pp_name(getParam<PostprocessorName>("perimeter_ext")) 46 : { 47 8 : } 48 : 49 : void 50 8 : HSBoundaryExternalAppHeatFlux::check() const 51 : { 52 8 : HSBoundary::check(); 53 : 54 : // HeatStructurePlate and HeatStructureFromFile3D are not yet supported 55 8 : checkComponentOfTypeExistsByName<HeatStructureCylindricalBase>(_hs_name); 56 : 57 : // Check that all boundaries are of type INNER or OUTER 58 8 : if (hasComponentByName<Component2D>(_hs_name)) 59 : { 60 8 : checkAllComponent2DBoundariesAreExternal(); 61 8 : if (allComponent2DBoundariesAreExternal()) 62 8 : if (hasCommonComponent2DExternalBoundaryType()) 63 : { 64 8 : const auto boundary_type = getCommonComponent2DExternalBoundaryType(); 65 8 : if (boundary_type != Component2D::ExternalBoundaryType::INNER && 66 : boundary_type != Component2D::ExternalBoundaryType::OUTER) 67 2 : logError("The boundaries in 'boundary' must be of an inner/outer type, not of a " 68 : "start/end type."); 69 : } 70 : } 71 8 : } 72 : 73 : void 74 4 : HSBoundaryExternalAppHeatFlux::addVariables() 75 : { 76 4 : const HeatStructureInterface & hs = getComponentByName<HeatStructureInterface>(_hs_name); 77 : const std::vector<SubdomainName> & subdomain_names = 78 4 : hs.getGeometricalComponent().getSubdomainNames(); 79 : 80 8 : const auto fe_type = getParam<bool>("heat_flux_is_monomial") ? libMesh::FEType(CONSTANT, MONOMIAL) 81 : : libMesh::FEType(FIRST, LAGRANGE); 82 4 : getTHMProblem().addSimVariable(false, _heat_flux_name, fe_type, subdomain_names); 83 4 : } 84 : 85 : void 86 4 : HSBoundaryExternalAppHeatFlux::addMooseObjects() 87 : { 88 : // Add external perimeter PP 89 : { 90 4 : const std::string class_name = "Receiver"; 91 4 : InputParameters params = _factory.getValidParams(class_name); 92 4 : getTHMProblem().addPostprocessor(class_name, _perimeter_ext_pp_name, params); 93 4 : } 94 : 95 : // Add BC 96 : { 97 4 : const std::string class_name = "FunctorNeumannBC"; 98 4 : InputParameters params = _factory.getValidParams(class_name); 99 8 : params.set<std::vector<BoundaryName>>("boundary") = _boundary; 100 8 : params.set<NonlinearVariableName>("variable") = HeatConductionModel::TEMPERATURE; 101 8 : params.set<MooseFunctorName>("functor") = _heat_flux_name; 102 8 : params.set<MooseFunctorName>("coefficient") = _perimeter_ext_pp_name; 103 8 : params.set<bool>("flux_is_inward") = getParam<bool>("heat_flux_is_inward"); 104 8 : getTHMProblem().addBoundaryCondition(class_name, genName(name(), "bc"), params); 105 4 : } 106 : 107 : // Add scale function to use as 'prefactor' in heat rate PP 108 8 : const FunctionName scale_fn_name = genName(name(), "scale_fn"); 109 : { 110 4 : const std::string class_name = "ParsedFunction"; 111 4 : InputParameters params = _factory.getValidParams(class_name); 112 4 : params.set<std::string>("expression") = "sign * P"; 113 16 : params.set<std::vector<std::string>>("symbol_names") = {"sign", "P"}; 114 4 : if (getParam<bool>("heat_flux_is_inward")) 115 16 : params.set<std::vector<std::string>>("symbol_values") = {"1", _perimeter_ext_pp_name}; 116 : else 117 0 : params.set<std::vector<std::string>>("symbol_values") = {"-1", _perimeter_ext_pp_name}; 118 4 : getTHMProblem().addFunction(class_name, scale_fn_name, params); 119 4 : } 120 : 121 : // Add heat rate PP 122 : { 123 4 : const std::string class_name = "SideIntegralFunctorPostprocessor"; 124 4 : InputParameters params = _factory.getValidParams(class_name); 125 4 : params.set<std::vector<BoundaryName>>("boundary") = _boundary; 126 8 : params.set<MooseFunctorName>("functor") = _heat_flux_name; 127 8 : params.set<MooseFunctorName>("prefactor") = scale_fn_name; 128 8 : params.set<MooseEnum>("functor_argument") = "qp"; 129 16 : params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 130 8 : getTHMProblem().addPostprocessor(class_name, genSafeName(name(), "integral"), params); 131 4 : } 132 24 : }