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 "VolumeJunctionCoupledFlux1Phase.h" 11 : #include "VolumeJunction1Phase.h" 12 : 13 : registerMooseObject("ThermalHydraulicsApp", VolumeJunctionCoupledFlux1Phase); 14 : 15 : InputParameters 16 90 : VolumeJunctionCoupledFlux1Phase::validParams() 17 : { 18 90 : InputParameters params = Component::validParams(); 19 : 20 180 : params.addRequiredParam<std::string>("volume_junction", 21 : "Name of volume junction component on which to apply flux"); 22 180 : params.addRequiredParam<RealVectorValue>("normal_from_junction", 23 : "Direction vector pointing from the junction to the " 24 : "coupled volume. This vector will be normalized."); 25 180 : params.addRequiredParam<Real>("A_coupled", "Area of the coupled surface [m^2]"); 26 180 : params.addParam<MultiAppName>( 27 : "multi_app", 28 : "If provided, transfers occur with this MultiApp. The following would be transferred: mass " 29 : "flow rate, energy flow rate, temperature, and pressure at the junction."); 30 180 : params.addRequiredParam<std::string>("pp_suffix", "Suffix to append to post-processor names"); 31 : 32 90 : params.addClassDescription( 33 : "Applies a flux between a VolumeJunction1Phase component and an external application."); 34 : 35 90 : return params; 36 0 : } 37 : 38 45 : VolumeJunctionCoupledFlux1Phase::VolumeJunctionCoupledFlux1Phase(const InputParameters & params) 39 : : Component(params), 40 45 : _volume_junction_name(getParam<std::string>("volume_junction")), 41 90 : _normal_from_junction_unnormalized(getParam<RealVectorValue>("normal_from_junction")), 42 45 : _normal_from_junction(_normal_from_junction_unnormalized.unit()), 43 135 : _pp_suffix(getParam<std::string>("pp_suffix")) 44 : { 45 45 : } 46 : 47 : void 48 45 : VolumeJunctionCoupledFlux1Phase::check() const 49 : { 50 45 : checkComponentOfTypeExistsByName<VolumeJunction1Phase>(_volume_junction_name); 51 45 : } 52 : 53 : void 54 45 : VolumeJunctionCoupledFlux1Phase::addMooseObjects() 55 : { 56 45 : const std::vector<NonlinearVariableName> vars = {"rhoV", "rhouV", "rhovV", "rhowV", "rhoEV"}; 57 270 : for (const auto i : index_range(vars)) 58 225 : addVolumeJunctionKernel(vars[i], i); 59 : 60 45 : const std::vector<std::string> equations = {"mass", "energy"}; 61 135 : for (const auto i : index_range(equations)) 62 : { 63 90 : addFluxPostprocessor(equations[i]); 64 180 : if (isParamValid("multi_app")) 65 90 : addFluxTransfer(equations[i]); 66 : } 67 : 68 45 : const std::vector<std::string> properties = {"p", "T"}; 69 135 : for (const auto i : index_range(properties)) 70 : { 71 90 : addPropertyPostprocessor(properties[i]); 72 180 : if (isParamValid("multi_app")) 73 90 : addPropertyTransfer(properties[i]); 74 : } 75 45 : } 76 : 77 : void 78 225 : VolumeJunctionCoupledFlux1Phase::addVolumeJunctionKernel(const std::string & var, unsigned int i) 79 : { 80 : const auto & volume_junction = 81 225 : getTHMProblem().getComponentByName<VolumeJunction1Phase>(_volume_junction_name); 82 : 83 225 : const std::string class_name = "VolumeJunctionCoupledFlux1PhaseKernel"; 84 225 : InputParameters params = _factory.getValidParams(class_name); 85 450 : params.set<NonlinearVariableName>("variable") = var; 86 675 : params.set<std::vector<SubdomainName>>("block") = {_volume_junction_name}; 87 225 : params.set<unsigned int>("equation_index") = i; 88 450 : params.set<PostprocessorName>("pressure") = addPostprocessorSuffix("p"); 89 450 : params.set<PostprocessorName>("temperature") = addPostprocessorSuffix("T"); 90 450 : params.set<Real>("A_coupled") = getParam<Real>("A_coupled"); 91 225 : params.set<RealVectorValue>("normal_from_junction") = _normal_from_junction; 92 450 : params.set<UserObjectName>("volume_junction_uo") = 93 225 : volume_junction.getVolumeJunctionUserObjectName(); 94 450 : params.set<UserObjectName>("numerical_flux_uo") = volume_junction.getNumericalFluxName(0); 95 225 : params.set<UserObjectName>("fluid_properties") = volume_junction.getFluidPropertiesName(); 96 450 : const std::string obj_name = genName(name(), var + "_kernel"); 97 225 : getTHMProblem().addKernel(class_name, obj_name, params); 98 675 : } 99 : 100 : void 101 90 : VolumeJunctionCoupledFlux1Phase::addFluxPostprocessor(const std::string & equation) 102 : { 103 : const auto & volume_junction = 104 90 : getTHMProblem().getComponentByName<VolumeJunction1Phase>(_volume_junction_name); 105 : 106 90 : const std::string quantity = equation + "_rate"; 107 90 : const std::string class_name = "VolumeJunctionCoupledFlux1PhasePostprocessor"; 108 90 : InputParameters params = _factory.getValidParams(class_name); 109 90 : params.set<MooseEnum>("equation") = equation; 110 180 : params.set<PostprocessorName>("pressure") = addPostprocessorSuffix("p"); 111 180 : params.set<PostprocessorName>("temperature") = addPostprocessorSuffix("T"); 112 180 : params.set<Real>("A_coupled") = getParam<Real>("A_coupled"); 113 90 : params.set<RealVectorValue>("normal_from_junction") = _normal_from_junction; 114 180 : params.set<UserObjectName>("volume_junction_uo") = 115 90 : volume_junction.getVolumeJunctionUserObjectName(); 116 180 : params.set<UserObjectName>("numerical_flux_uo") = volume_junction.getNumericalFluxName(0); 117 90 : params.set<UserObjectName>("fluid_properties") = volume_junction.getFluidPropertiesName(); 118 90 : const std::string obj_name = addPostprocessorSuffix(quantity); 119 90 : getTHMProblem().addPostprocessor(class_name, obj_name, params); 120 180 : } 121 : 122 : void 123 90 : VolumeJunctionCoupledFlux1Phase::addPropertyPostprocessor(const std::string & property) 124 : { 125 90 : const std::string class_name = "Receiver"; 126 90 : InputParameters params = _factory.getValidParams(class_name); 127 90 : const PostprocessorName obj_name = addPostprocessorSuffix(property); 128 90 : getTHMProblem().addPostprocessor(class_name, obj_name, params); 129 180 : } 130 : 131 : void 132 90 : VolumeJunctionCoupledFlux1Phase::addFluxTransfer(const std::string & equation) 133 : { 134 90 : const std::string quantity = equation + "_rate"; 135 90 : const std::string class_name = "MultiAppPostprocessorTransfer"; 136 90 : InputParameters params = _factory.getValidParams(class_name); 137 270 : params.set<MultiAppName>("to_multi_app") = getParam<MultiAppName>("multi_app"); 138 180 : params.set<PostprocessorName>("from_postprocessor") = addPostprocessorSuffix(quantity); 139 180 : params.set<PostprocessorName>("to_postprocessor") = addPostprocessorSuffix(quantity); 140 360 : params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 141 180 : const PostprocessorName obj_name = genName(name(), quantity + "_transfer"); 142 90 : getTHMProblem().addTransfer(class_name, obj_name, params); 143 270 : } 144 : 145 : void 146 90 : VolumeJunctionCoupledFlux1Phase::addPropertyTransfer(const std::string & property) 147 : { 148 90 : const std::string class_name = "MultiAppPostprocessorTransfer"; 149 90 : InputParameters params = _factory.getValidParams(class_name); 150 270 : params.set<MultiAppName>("from_multi_app") = getParam<MultiAppName>("multi_app"); 151 180 : params.set<PostprocessorName>("from_postprocessor") = addPostprocessorSuffix(property); 152 180 : params.set<PostprocessorName>("to_postprocessor") = addPostprocessorSuffix(property); 153 180 : params.set<MooseEnum>("reduction_type") = "average"; 154 360 : params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END}; 155 180 : const PostprocessorName obj_name = genName(name(), property + "_transfer"); 156 90 : getTHMProblem().addTransfer(class_name, obj_name, params); 157 270 : } 158 : 159 : PostprocessorName 160 1170 : VolumeJunctionCoupledFlux1Phase::addPostprocessorSuffix(const std::string & base_name) const 161 : { 162 2340 : return base_name + "_" + _pp_suffix; 163 : }