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 "JunctionOneToOne1Phase.h" 11 : #include "FlowChannel1Phase.h" 12 : #include "FlowModelSinglePhase.h" 13 : #include "THMMesh.h" 14 : #include "SlopeReconstruction1DInterface.h" 15 : 16 : registerMooseObject("ThermalHydraulicsApp", JunctionOneToOne1Phase); 17 : 18 : InputParameters 19 206 : JunctionOneToOne1Phase::validParams() 20 : { 21 206 : InputParameters params = FlowJunction1Phase::validParams(); 22 : 23 206 : params.addClassDescription( 24 : "Junction connecting one flow channel to one other flow channel for 1-phase flow"); 25 : 26 206 : return params; 27 0 : } 28 : 29 103 : JunctionOneToOne1Phase::JunctionOneToOne1Phase(const InputParameters & params) 30 : : FlowJunction1Phase(params), 31 206 : _slope_reconstruction( 32 103 : SlopeReconstruction1DInterface<true>::getSlopeReconstructionMooseEnum("None")) 33 : { 34 103 : } 35 : 36 : void 37 103 : JunctionOneToOne1Phase::setupMesh() 38 : { 39 103 : FlowJunction1Phase::setupMesh(); 40 : 41 : const auto & connected_elems = getConnectedElementIDs(); 42 103 : if (connected_elems.size() == 2) 43 103 : getTHMProblem().augmentSparsity(connected_elems[0], connected_elems[1]); 44 103 : } 45 : 46 : void 47 103 : JunctionOneToOne1Phase::init() 48 : { 49 103 : FlowJunction1Phase::init(); 50 : 51 : // Get slope reconstruction option used 52 309 : for (const auto & connection : getConnections()) 53 : { 54 206 : const std::string & comp_name = connection._component_name; 55 : if (hasComponentByName<FlowChannel1Phase>(comp_name)) 56 : { 57 : const FlowChannel1Phase & comp = getComponentByName<FlowChannel1Phase>(comp_name); 58 206 : _slope_reconstruction = comp.getSlopeReconstruction(); 59 : } 60 : } 61 103 : } 62 : 63 : void 64 103 : JunctionOneToOne1Phase::check() const 65 : { 66 103 : FlowJunction1Phase::check(); 67 : 68 : // Check that there are exactly 2 connections 69 103 : checkNumberOfConnections(2); 70 103 : } 71 : 72 : void 73 103 : JunctionOneToOne1Phase::addMooseObjects() 74 : { 75 103 : ExecFlagEnum execute_on(MooseUtils::getDefaultExecFlagEnum()); 76 515 : execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR}; 77 : 78 : // Add user object for computing and storing the fluxes 79 : { 80 103 : const std::string class_name = "ADJunctionOneToOne1PhaseUserObject"; 81 103 : InputParameters params = _factory.getValidParams(class_name); 82 103 : params.set<std::vector<BoundaryName>>("boundary") = _boundary_names; 83 206 : params.set<std::vector<Real>>("normals") = _normals; 84 103 : params.set<std::vector<processor_id_type>>("processor_ids") = getConnectedProcessorIDs(); 85 206 : params.set<UserObjectName>("fluid_properties") = _fp_name; 86 : // It is assumed that each channel should have the same numerical flux, so 87 : // just use the first one. 88 206 : params.set<UserObjectName>("numerical_flux") = _numerical_flux_names[0]; 89 309 : params.set<std::vector<VariableName>>("A_elem") = {FlowModel::AREA}; 90 309 : params.set<std::vector<VariableName>>("A_linear") = {FlowModel::AREA_LINEAR}; 91 309 : params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA}; 92 309 : params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA}; 93 309 : params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA}; 94 103 : params.set<std::string>("junction_name") = name(); 95 103 : params.set<MooseEnum>("scheme") = _slope_reconstruction; 96 103 : params.set<ExecFlagEnum>("execute_on") = execute_on; 97 103 : getTHMProblem().addUserObject(class_name, _junction_uo_name, params); 98 103 : } 99 : 100 : const std::vector<NonlinearVariableName> var_names = { 101 412 : FlowModelSinglePhase::RHOA, FlowModelSinglePhase::RHOUA, FlowModelSinglePhase::RHOEA}; 102 : 103 : // Add BC to each of the connected flow channels 104 309 : for (std::size_t i = 0; i < _boundary_names.size(); i++) 105 824 : for (std::size_t j = 0; j < var_names.size(); j++) 106 : { 107 618 : const std::string class_name = "ADJunctionOneToOne1PhaseBC"; 108 618 : InputParameters params = _factory.getValidParams(class_name); 109 1854 : params.set<std::vector<BoundaryName>>("boundary") = {_boundary_names[i]}; 110 618 : params.set<Real>("normal") = _normals[i]; 111 1236 : params.set<NonlinearVariableName>("variable") = var_names[j]; 112 1236 : params.set<UserObjectName>("junction_uo") = _junction_uo_name; 113 618 : params.set<unsigned int>("connection_index") = i; 114 1854 : params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA}; 115 1854 : params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA}; 116 1854 : params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA}; 117 618 : params.set<bool>("implicit") = getTHMProblem().getImplicitTimeIntegrationFlag(); 118 1236 : getTHMProblem().addBoundaryCondition( 119 618 : class_name, genName(name(), i, var_names[j] + ":" + class_name), params); 120 618 : } 121 309 : }