LCOV - code coverage report
Current view: top level - EnergyPlus - BranchNodeConnections.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 82.7 % 941 778
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 17 17

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // ObjexxFCL Headers
      49              : #include <ObjexxFCL/Array.functions.hh>
      50              : #include <ObjexxFCL/member.functions.hh>
      51              : #include <ObjexxFCL/string.functions.hh>
      52              : 
      53              : // EnergyPlus Headers
      54              : #include <EnergyPlus/BranchNodeConnections.hh>
      55              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      56              : #include <EnergyPlus/DataBranchNodeConnections.hh>
      57              : #include <EnergyPlus/DataLoopNode.hh>
      58              : #include <EnergyPlus/NodeInputManager.hh>
      59              : #include <EnergyPlus/UtilityRoutines.hh>
      60              : 
      61              : namespace EnergyPlus::BranchNodeConnections {
      62              : 
      63              : // Module containing the routines dealing with the Branch/Node Connections (CompSets, etc)
      64              : 
      65              : // MODULE INFORMATION:
      66              : //       AUTHOR         Linda Lawrie
      67              : //       DATE WRITTEN   May 2005
      68              : 
      69              : // PURPOSE OF THIS MODULE:
      70              : // This module encapsulates the connection data necessary for some of the checks
      71              : // needed in the branch-node data
      72              : 
      73              : // Using/Aliasing
      74              : using namespace DataLoopNode;
      75              : using namespace DataBranchNodeConnections;
      76              : 
      77              : static constexpr std::string_view undefined("UNDEFINED");
      78              : 
      79              : constexpr std::array<std::string_view, static_cast<int>(DataLoopNode::ConnectionObjectType::Num)> ConnectionObjectTypeNames = {
      80              :     "Undefined",
      81              :     "AirConditioner:VariableRefrigerantFlow",
      82              :     "AirLoopHVAC",
      83              :     "AirLoopHVAC:DedicatedOutdoorAirSystem",
      84              :     "AirLoopHVAC:ExhaustSystem",
      85              :     "AirLoopHVAC:Mixer",
      86              :     "AirLoopHVAC:OutdoorAirSystem",
      87              :     "AirLoopHVAC:ReturnPath",
      88              :     "AirLoopHVAC:ReturnPlenum",
      89              :     "AirLoopHVAC:Splitter",
      90              :     "AirLoopHVAC:SupplyPath",
      91              :     "AirLoopHVAC:SupplyPlenum",
      92              :     "AirLoopHVAC:Unitary:Furnace:HeatCool",
      93              :     "AirLoopHVAC:Unitary:Furnace:HeatOnly",
      94              :     "AirLoopHVAC:UnitaryHeatCool",
      95              :     "AirLoopHVAC:UnitaryHeatCool:VAVChangeoverBypass",
      96              :     "AirLoopHVAC:UnitaryHeatOnly",
      97              :     "AirLoopHVAC:UnitaryHeatPump:AirToAir",
      98              :     "AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed",
      99              :     "AirLoopHVAC:UnitaryHeatPump:WaterToAir",
     100              :     "AirLoopHVAC:UnitarySystem",
     101              :     "AirLoopHVAC:ZoneMixer",
     102              :     "AirLoopHVAC:ZoneSplitter",
     103              :     "AirTerminal:DualDuct:ConstantVolume",
     104              :     "AirTerminal:DualDuct:ConstantVolume:Cool",
     105              :     "AirTerminal:DualDuct:ConstantVolume:Heat",
     106              :     "AirTerminal:DualDuct:VAV",
     107              :     "AirTerminal:DualDuct:VAV:Cool",
     108              :     "AirTerminal:DualDuct:VAV:Heat",
     109              :     "AirTerminal:DualDuct:VAV:OutdoorAir",
     110              :     "AirTerminal:DualDuct:VAV:OutdoorAir:OutdoorAir",
     111              :     "AirTerminal:DualDuct:VAV:OutdoorAir:RecirculatedAir",
     112              :     "AirTerminal:SingleDuct:ConstantVolume:CooledBeam",
     113              :     "AirTerminal:SingleDuct:ConstantVolume:FourPipeBeam",
     114              :     "AirTerminal:SingleDuct:ConstantVolume:FourPipeInduction",
     115              :     "AirTerminal:SingleDuct:ConstantVolume:NoReheat",
     116              :     "AirTerminal:SingleDuct:ConstantVolume:Reheat",
     117              :     "AirTerminal:SingleDuct:Mixer",
     118              :     "AirTerminal:SingleDuct:ParallelPIU:Reheat",
     119              :     "AirTerminal:SingleDuct:SeriesPIU:Reheat",
     120              :     "AirTerminal:SingleDuct:UserDefined",
     121              :     "AirTerminal:SingleDuct:VAV:HeatAndCool:NoReheat",
     122              :     "AirTerminal:SingleDuct:VAV:HeatAndCool:Reheat",
     123              :     "AirTerminal:SingleDuct:VAV:NoReheat",
     124              :     "AirTerminal:SingleDuct:VAV:Reheat",
     125              :     "AirTerminal:SingleDuct:VAV:Reheat:VariableSpeedFan",
     126              :     "AvailabilityManager:DifferentialThermostat",
     127              :     "AvailabilityManager:HighTemperatureTurnOff",
     128              :     "AvailabilityManager:HighTemperatureTurnOn",
     129              :     "AvailabilityManager:LowTemperatureTurnOff",
     130              :     "AvailabilityManager:LowTemperatureTurnOn",
     131              :     "Boiler:HotWater",
     132              :     "Boiler:Steam",
     133              :     "Branch",
     134              :     "CentralHeatPumpSystem",
     135              :     "Chiller:Absorption",
     136              :     "Chiller:Absorption:Indirect",
     137              :     "Chiller:CombustionTurbine",
     138              :     "Chiller:ConstantCOP",
     139              :     "Chiller:Electric",
     140              :     "Chiller:Electric:EIR",
     141              :     "Chiller:Electric:ReformulatedEIR",
     142              :     "Chiller:Electric:ASHRAE205",
     143              :     "Chiller:EngineDriven",
     144              :     "ChillerHeater:Absorption:DirectFired",
     145              :     "ChillerHeater:Absorption:DoubleEffect",
     146              :     "Coil:Cooling:DX",
     147              :     "Coil:Cooling:DX:CurveFit:Speed",
     148              :     "Coil:Cooling:DX:MultiSpeed",
     149              :     "Coil:Cooling:DX:SingleSpeed",
     150              :     "Coil:Cooling:DX:SingleSpeed:ThermalStorage",
     151              :     "Coil:Cooling:DX:SubcoolReheat",
     152              :     "Coil:Cooling:DX:TwoSpeed",
     153              :     "Coil:Cooling:DX:TwoStageWithHumidityControlMode",
     154              :     "Coil:Cooling:DX:VariableRefrigerantFlow",
     155              :     "Coil:Cooling:DX:VariableRefrigerantFlow:FluidTemperatureControl",
     156              :     "Coil:Cooling:DX:VariableSpeed",
     157              :     "Coil:Cooling:Water",
     158              :     "Coil:Cooling:Water:DetailedGeometry",
     159              :     "Coil:Cooling:WaterToAirHeatPump:EquationFit",
     160              :     "Coil:Cooling:WaterToAirHeatPump:ParameterEstimation",
     161              :     "Coil:Cooling:WaterToAirHeatPump:VariableSpeedEquationFit",
     162              :     "Coil:Heating:DX:MultiSpeed",
     163              :     "Coil:Heating:DX:SingleSpeed",
     164              :     "Coil:Heating:DX:VariableRefrigerantFlow",
     165              :     "Coil:Heating:DX:VariableRefrigerantFlow:FluidTemperatureControl",
     166              :     "Coil:Heating:DX:VariableSpeed",
     167              :     "Coil:Heating:Desuperheater",
     168              :     "Coil:Heating:Electric",
     169              :     "Coil:Heating:Electric:MultiStage",
     170              :     "Coil:Heating:Fuel",
     171              :     "Coil:Heating:Gas:MultiStage",
     172              :     "Coil:Heating:Steam",
     173              :     "Coil:Heating:Water",
     174              :     "Coil:Heating:WaterToAirHeatPump:EquationFit",
     175              :     "Coil:Heating:WaterToAirHeatPump:ParameterEstimation",
     176              :     "Coil:Heating:WaterToAirHeatPump:VariableSpeedEquationFit",
     177              :     "Coil:UserDefined",
     178              :     "Coil:WaterHeating:AirToWaterHeatPump:Pumped",
     179              :     "Coil:WaterHeating:AirToWaterHeatPump:VariableSpeed",
     180              :     "Coil:WaterHeating:AirToWaterHeatPump:Wrapped",
     181              :     "Coil:WaterHeating:Desuperheater",
     182              :     "CoilSystem:Cooling:DX",
     183              :     "CoilSystem:Cooling:DX:HeatExchangerAssisted",
     184              :     "CoilSystem:Cooling:Water",
     185              :     "CoilSystem:Cooling:Water:HeatExchangerAssisted",
     186              :     "CoilSystem:Heating:DX",
     187              :     "CoilSystem:IntegratedHeatPump:AirSource",
     188              :     "Condenser",
     189              :     "CondenserLoop",
     190              :     "Connector:Mixer",
     191              :     "Connector:Splitter",
     192              :     "Controller:OutdoorAir",
     193              :     "Controller:WaterCoil",
     194              :     "CoolingTower:SingleSpeed",
     195              :     "CoolingTower:TwoSpeed",
     196              :     "CoolingTower:VariableSpeed",
     197              :     "CoolingTower:VariableSpeed:Merkel",
     198              :     "Dehumidifier:Desiccant:NoFans",
     199              :     "Dehumidifier:Desiccant:System",
     200              :     "DistrictCooling",
     201              :     "DistrictHeating:Water",
     202              :     "DistrictHeating:Steam",
     203              :     "Duct",
     204              :     "ElectricEquipment:ITE:AirCooled",
     205              :     "EvaporativeCooler:Direct:CelDekPad",
     206              :     "EvaporativeCooler:Direct:ResearchSpecial",
     207              :     "EvaporativeCooler:Indirect:CelDekPad",
     208              :     "EvaporativeCooler:Indirect:ResearchSpecial",
     209              :     "EvaporativeCooler:Indirect:WetCoil",
     210              :     "EvaporativeFluidCooler:SingleSpeed",
     211              :     "EvaporativeFluidCooler:TwoSpeed",
     212              :     "Fan:ComponentModel",
     213              :     "Fan:ConstantVolume",
     214              :     "Fan:OnOff",
     215              :     "Fan:SystemModel",
     216              :     "Fan:VariableVolume",
     217              :     "Fan:ZoneExhaust",
     218              :     "FluidCooler:SingleSpeed",
     219              :     "FluidCooler:TwoSpeed",
     220              :     "Generator:CombustionTurbine",
     221              :     "Generator:FuelCell:AirSupply",
     222              :     "Generator:FuelCell:ExhaustGasToWaterHeatExchanger",
     223              :     "Generator:FuelCell:PowerModule",
     224              :     "Generator:FuelCell:StackCooler",
     225              :     "Generator:FuelCell:WaterSupply",
     226              :     "Generator:FuelSupply",
     227              :     "Generator:InternalCombustionEngine",
     228              :     "Generator:MicroCHP",
     229              :     "Generator:MicroTurbine",
     230              :     "GroundHeatExchanger:HorizontalTrench",
     231              :     "GroundHeatExchanger:Pond",
     232              :     "GroundHeatExchanger:Slinky",
     233              :     "GroundHeatExchanger:Surface",
     234              :     "GroundHeatExchanger:System",
     235              :     "HeaderedPumps:ConstantSpeed",
     236              :     "HeaderedPumps:VariableSpeed",
     237              :     "HeatExchanger:AirToAir:FlatPlate",
     238              :     "HeatExchanger:AirToAir:SensibleAndLatent",
     239              :     "HeatExchanger:Desiccant:BalancedFlow",
     240              :     "HeatExchanger:FluidToFluid",
     241              :     "HeatPump:AirToWater:FuelFired:Cooling",
     242              :     "HeatPump:AirToWater:FuelFired:Heating",
     243              :     "HeatPump:PlantLoop:EIR:Cooling",
     244              :     "HeatPump:PlantLoop:EIR:Heating",
     245              :     "HeatPump:WaterToWater:EquationFit:Cooling",
     246              :     "HeatPump:WaterToWater:EquationFit:Heating",
     247              :     "HeatPump:WaterToWater:ParameterEstimation:Cooling",
     248              :     "HeatPump:WaterToWater:ParameterEstimation:Heating",
     249              :     "Humidifier:Steam:Electric",
     250              :     "Humidifier:Steam:Gas",
     251              :     "Lights",
     252              :     "LoadProfile:Plant",
     253              :     "OutdoorAir:Mixer",
     254              :     "OutdoorAir:Node",
     255              :     "OutdoorAir:NodeList",
     256              :     "Pipe:Adiabatic",
     257              :     "Pipe:Adiabatic:Steam",
     258              :     "Pipe:Indoor",
     259              :     "Pipe:Outdoor",
     260              :     "Pipe:Underground",
     261              :     "PipingSystem:Underground:PipeCircuit",
     262              :     "PlantComponent:TemperatureSource",
     263              :     "PlantComponent:UserDefined",
     264              :     "PlantEquipmentOperation:ChillerHeaterChangeover",
     265              :     "PlantEquipmentOperation:ComponentSetpoint",
     266              :     "PlantEquipmentOperation:OutdoorDewpointDifference",
     267              :     "PlantEquipmentOperation:OutdoorDrybulbDifference",
     268              :     "PlantEquipmentOperation:OutdoorWetbulbDifference",
     269              :     "PlantEquipmentOperation:ThermalEnergyStorage",
     270              :     "PlantLoop",
     271              :     "Pump:ConstantSpeed",
     272              :     "Pump:ConstantVolume",
     273              :     "Pump:VariableSpeed",
     274              :     "Pump:VariableSpeed:Condensate",
     275              :     "Refrigeration:CompressorRack",
     276              :     "Refrigeration:Condenser:AirCooled",
     277              :     "Refrigeration:Condenser:EvaporativeCooled",
     278              :     "Refrigeration:Condenser:WaterCooled",
     279              :     "Refrigeration:GasCooler:AirCooled",
     280              :     "SetpointManager:Coldest",
     281              :     "SetpointManager:CondenserEnteringReset",
     282              :     "SetpointManager:CondenserEnteringReset:Ideal",
     283              :     "SetpointManager:FollowGroundTemperature",
     284              :     "SetpointManager:FollowOutdoorAirTemperature",
     285              :     "SetpointManager:FollowSystemNodeTemperature",
     286              :     "SetpointManager:MixedAir",
     287              :     "SetpointManager:MultiZone:Cooling:Average",
     288              :     "SetpointManager:MultiZone:Heating:Average",
     289              :     "SetpointManager:MultiZone:Humidity:Maximum",
     290              :     "SetpointManager:MultiZone:Humidity:Minimum",
     291              :     "SetpointManager:MultiZone:MaximumHumidity:Average",
     292              :     "SetpointManager:MultiZone:MinimumHumidity:Average",
     293              :     "SetpointManager:OutdoorAirPretreat",
     294              :     "SetpointManager:OutdoorAirReset",
     295              :     "SetpointManager:ReturnTemperature:ChilledWater",
     296              :     "SetpointManager:ReturnTemperature:HotWater",
     297              :     "SetpointManager:Scheduled",
     298              :     "SetpointManager:Scheduled:DualSetpoint",
     299              :     "SetpointManager:SingleZone:Cooling",
     300              :     "SetpointManager:SingleZone:Heating",
     301              :     "SetpointManager:SingleZone:Humidity:Maximum",
     302              :     "SetpointManager:SingleZone:Humidity:Minimum",
     303              :     "SetpointManager:SingleZone:OneStageCooling",
     304              :     "SetpointManager:SingleZone:OneStageHeating",
     305              :     "SetpointManager:SingleZone:Reheat",
     306              :     "SetpointManager:SystemNodeReset:Temperature",
     307              :     "SetpointManager:SystemNodeReset:Humidity",
     308              :     "SetpointManager:Warmest",
     309              :     "SetpointManager:WarmestTemperatureFlow",
     310              :     "SolarCollector:FlatPlate:PhotovoltaicThermal",
     311              :     "SolarCollector:FlatPlate:Water",
     312              :     "SolarCollector:IntegralCollectorStorage",
     313              :     "SolarCollector:UnglazedTranspired",
     314              :     "SurfaceProperty:LocalEnvironment",
     315              :     "SwimmingPool:Indoor",
     316              :     "TemperingValve",
     317              :     "ThermalStorage:ChilledWater:Mixed",
     318              :     "ThermalStorage:ChilledWater:Stratified",
     319              :     "ThermalStorage:Ice:Detailed",
     320              :     "ThermalStorage:Ice:Simple",
     321              :     "WaterHeater:HeatPump",
     322              :     "WaterHeater:HeatPump:PumpedCondenser",
     323              :     "WaterHeater:HeatPump:WrappedCondenser",
     324              :     "WaterHeater:Mixed",
     325              :     "WaterHeater:Stratified",
     326              :     "WaterUse:Connections",
     327              :     "ZoneHVAC:AirDistributionUnit",
     328              :     "ZoneHVAC:Baseboard:Convective:Electric",
     329              :     "ZoneHVAC:Baseboard:Convective:Water",
     330              :     "ZoneHVAC:Baseboard:RadiantConvective:Electric",
     331              :     "ZoneHVAC:Baseboard:RadiantConvective:Steam",
     332              :     "ZoneHVAC:Baseboard:RadiantConvective:Water",
     333              :     "ZoneHVAC:CoolingPanel:RadiantConvective:Water",
     334              :     "ZoneHVAC:Dehumidifier:DX",
     335              :     "ZoneHVAC:EnergyRecoveryVentilator",
     336              :     "ZoneHVAC:EquipmentConnections",
     337              :     "ZoneHVAC:EvaporativeCoolerUnit",
     338              :     "ZoneHVAC:ExhaustControl",
     339              :     "ZoneHVAC:ForcedAir:UserDefined",
     340              :     "ZoneHVAC:FourPipeFanCoil",
     341              :     "ZoneHVAC:HighTemperatureRadiant",
     342              :     "ZoneHVAC:HybridUnitaryHVAC",
     343              :     "ZoneHVAC:IdealLoadsAirSystem",
     344              :     "ZoneHVAC:LowTemperatureRadiant:ConstantFlow",
     345              :     "ZoneHVAC:LowTemperatureRadiant:VariableFlow",
     346              :     "ZoneHVAC:OutdoorAirUnit",
     347              :     "ZoneHVAC:PackagedTerminalAirConditioner",
     348              :     "ZoneHVAC:PackagedTerminalHeatPump",
     349              :     "ZoneHVAC:RefrigerationChillerSet",
     350              :     "ZoneHVAC:TerminalUnit:VariableRefrigerantFlow",
     351              :     "ZoneHVAC:UnitHeater",
     352              :     "ZoneHVAC:UnitVentilator",
     353              :     "ZoneHVAC:VentilatedSlab",
     354              :     "ZoneHVAC:WaterToAirHeatPump",
     355              :     "ZoneHVAC:WindowAirConditioner",
     356              :     "ZoneProperty:LocalEnvironment",
     357              :     "SpaceHVAC:EquipmentConnections",
     358              :     "SpaceHVAC:ZoneEquipmentSplitter",
     359              :     "SpaceHVAC:ZoneEquipmentMixer"};
     360              : 
     361              : constexpr std::array<std::string_view, static_cast<int>(DataLoopNode::ConnectionObjectType::Num)> ConnectionObjectTypeNamesUC = {
     362              :     undefined,
     363              :     "AIRCONDITIONER:VARIABLEREFRIGERANTFLOW",
     364              :     "AIRLOOPHVAC",
     365              :     "AIRLOOPHVAC:DEDICATEDOUTDOORAIRSYSTEM",
     366              :     "AIRLOOPHVAC:EXHAUSTSYSTEM",
     367              :     "AIRLOOPHVAC:MIXER",
     368              :     "AIRLOOPHVAC:OUTDOORAIRSYSTEM",
     369              :     "AIRLOOPHVAC:RETURNPATH",
     370              :     "AIRLOOPHVAC:RETURNPLENUM",
     371              :     "AIALOOPHVAC:SPLITTER",
     372              :     "AIRLOOPHVAC:SUPPLYPATH",
     373              :     "AIRLOOPHVAC:SUPPLYPLENUM",
     374              :     "AIRLOOPHVAC:UNITARY:FURNACE:HEATCOOL",
     375              :     "AIRLOOPHVAC:UNITARY:FURNACE:HEATONLY",
     376              :     "AIRLOOPHVAC:UNITARYHEATCOOL",
     377              :     "AIRLOOPHVAC:UNITARYHEATCOOL:VAVCHANGEOVERBYPASS",
     378              :     "AIRLOOPHVAC:UNITARYHEATONLY",
     379              :     "AIRLOOPHVAC:UNITARYHEATPUMP:AIRTOAIR",
     380              :     "AIRLOOPHVAC:UNITARYHEATPUMP:AIRTOAIR:MULTISPEED",
     381              :     "AIRLOOPHVAC:UNITARYHEATPUMP:WATERTOAIR",
     382              :     "AIRLOOPHVAC:UNITARYSYSTEM",
     383              :     "AIRLOOPHVAC:ZONEMIXER",
     384              :     "AIRLOOPHVAC:ZONESPLITTER",
     385              :     "AIRTERMINAL:DUALDUCT:CONSTANTVOLUME",
     386              :     "AIRTERMINAL:DUALDUCT:CONSTANTVOLUME:COOL",
     387              :     "AIRTERMINAL:DUALDUCT:CONSTANTVOLUME:HEAT",
     388              :     "AIRTERMINAL:DUALDUCT:VAV",
     389              :     "AIRTERMINAL:DUALDUCT:VAV:COOL",
     390              :     "AIRTERMINAL:DUALDUCT:VAV:HEAT",
     391              :     "AIRTERMINAL:DUALDUCT:VAV:OUTDOORAIR",
     392              :     "AIRTERMINAL:DUALDUCT:VAV:OUTDOORAIR:OUTDOORAIR",
     393              :     "AIRTERMINAL:DUALDUCT:VAV:OUTDOORAIR:RECIRCULATEDAIR",
     394              :     "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:COOLEDBEAM",
     395              :     "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:FOURPIPEBEAM",
     396              :     "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:FOURPIPEINDUCTION",
     397              :     "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:NOREHEAT",
     398              :     "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:REHEAT",
     399              :     "AIRTERMINAL:SINGLEDUCT:MIXER",
     400              :     "AIRTERMINAL:SINGLEDUCT:PARALLELPIU:REHEAT",
     401              :     "AIRTERMINAL:SINGLEDUCT:SERIESPIU:REHEAT",
     402              :     "AIRTERMINAL:SINGLEDUCT:USERDEFINED",
     403              :     "AIRTERMINAL:SINGLEDUCT:VAV:HEATANDCOOL:NOREHEAT",
     404              :     "AIRTERMINAL:SINGLEDUCT:VAV:HEATANDCOOL:REHEAT",
     405              :     "AIRTERMINAL:SINGLEDUCT:VAV:NOREHEAT",
     406              :     "AIRTERMINAL:SINGLEDUCT:VAV:REHEAT",
     407              :     "AIRTERMINAL:SINGLEDUCT:VAV:REHEAT:VARIABLESPEEDFAN",
     408              :     "AVAILABILITYMANAGER:DIFFERENTIALTHERMOSTAT",
     409              :     "AVAILABILITYMANAGER:HIGHTEMPERATURETURNOFF",
     410              :     "AVAILABILITYMANAGER:HIGHTEMPERATURETURNON",
     411              :     "AVAILABILITYMANAGER:LOWTEMPERATURETURNOFF",
     412              :     "AVAILABILITYMANAGER:LOWTEMPERATURETURNON",
     413              :     "BOILER:HOTWATER",
     414              :     "BOILER:STEAM",
     415              :     "BRANCH",
     416              :     "CENTRALHEATPUMPSYSTEM",
     417              :     "CHILLER:ABSORPTION",
     418              :     "CHILLER:ABSORPTION:INDIRECT",
     419              :     "CHILLER:COMBUSTIONTURBINE",
     420              :     "CHILLER:CONSTANTCOP",
     421              :     "CHILLER:ELECTRIC",
     422              :     "CHILLER:ELECTRIC:EIR",
     423              :     "CHILLER:ELECTRIC:REFORMULATEDEIR",
     424              :     "CHILLER:ELECTRIC:ASHRAE205",
     425              :     "CHILLER:ENGINEDRIVEN",
     426              :     "CHILLERHEATER:ABSORPTION:DIRECTFIRED",
     427              :     "CHILLERHEATER:ABSORPTION:DOUBLEEFFECT",
     428              :     "COIL:COOLING:DX",
     429              :     "COIL:COOLING:DX:CURVEFIT:SPEED",
     430              :     "COIL:COOLING:DX:MULTISPEED",
     431              :     "COIL:COOLING:DX:SINGLESPEED",
     432              :     "COIL:COOLING:DX:SINGLESPEED:THERMALSTORAGE",
     433              :     "COIL:COOLING:DX:SUBCOOLREHEAT",
     434              :     "COIL:COOLING:DX:TWOSPEED",
     435              :     "COIL:COOLING:DX:TWOSTAGEWITHHUMIDITYCONTROLMODE",
     436              :     "COIL:COOLING:DX:VARIABLEREFRIGERANTFLOW",
     437              :     "COIL:COOLING:DX:VARIABLEREFRIGERANTFLOW:FLUIDTEMPERATURECONTROL",
     438              :     "COIL:COOLING:DX:VARIABLESPEED",
     439              :     "COIL:COOLING:WATER",
     440              :     "COIL:COOLING:WATER:DETAILEDGEOMETRY",
     441              :     "COIL:COOLING:WATERTOAIRHEATPUMP:EQUATIONFIT",
     442              :     "COIL:COOLING:WATERTOAIRHEATPUMP:PARAMETERESTIMATION",
     443              :     "COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT",
     444              :     "COIL:HEATING:DX:MULTISPEED",
     445              :     "COIL:HEATING:DX:SINGLESPEED",
     446              :     "COIL:HEATING:DX:VARIABLEREFRIGERANTFLOW",
     447              :     "COIL:HEATING:DX:VARIABLEREFRIGERANTFLOW:FLUIDTEMPERATURECONTROL",
     448              :     "COIL:HEATING:DX:VARIABLESPEED",
     449              :     "COIL:HEATING:DESUPERHEATER",
     450              :     "COIL:HEATING:ELECTRIC",
     451              :     "COIL:HEATING:ELECTRIC:MULTISTAGE",
     452              :     "COIL:HEATING:FUEL",
     453              :     "COIL:HEATING:GAS:MULTISTAGE",
     454              :     "COIL:HEATING:STEAM",
     455              :     "COIL:HEATING:WATER",
     456              :     "COIL:HEATING:WATERTOAIRHEATPUMP:EQUATIONFIT",
     457              :     "COIL:HEATING:WATERTOAIRHEATPUMP:PARAMETERESTIMATION",
     458              :     "COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT",
     459              :     "COIL:USERDEFINED",
     460              :     "COIL:WATERHEATING:AIRTOWATERHEATPUMP:PUMPED",
     461              :     "COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED",
     462              :     "COIL:WATERHEATING:AIRTOWATERHEATPUMP:WRAPPED",
     463              :     "COIL:WATERHEATING:DESUPERHEATER",
     464              :     "COILSYSTEM:COOLING:DX",
     465              :     "COILSYSTEM:COOLING:DX:HEATEXCHANGERASSISTED",
     466              :     "COILSYSTEM:COOLING:WATER",
     467              :     "COILSYSTEM:COOLING:WATER:HEATEXCHANGERASSISTED",
     468              :     "COILSYSTEM:HEATING:DX",
     469              :     "COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE",
     470              :     "CONDENSER",
     471              :     "CONDENSERLOOP",
     472              :     "CONNECTOR:MIXER",
     473              :     "CONNECTOR:SPLITTER",
     474              :     "CONTROLLER:OUTDOORAIR",
     475              :     "CONTROLLER:WATERCOIL",
     476              :     "COOLINGTOWER:SINGLESPEED",
     477              :     "COOLINGTOWER:TWOSPEED",
     478              :     "COOLINGTOWER:VARIABLESPEED",
     479              :     "COOLINGTOWER:VARIABLESPEED:MERKEL",
     480              :     "DEHUMIDIFIER:DESICCANT:NOFANS",
     481              :     "DEHUMIDIFIER:DESICCANT:SYSTEM",
     482              :     "DISTRICTCOOLING",
     483              :     "DISTRICTHEATING:WATER",
     484              :     "DISTRICTHEATING:STEAM",
     485              :     "DUCT",
     486              :     "ELECTRICEQUIPMENT:ITE:AIRCOOLED",
     487              :     "EVAPORATIVECOOLER:DIRECT:CELDEKPAD",
     488              :     "EVAPORATIVECOOLER:DIRECT:RESEARCHSPECIAL",
     489              :     "EVAPORATIVECOOLER:INDIRECT:CELDEKPAD",
     490              :     "EVAPORATIVECOOLER:INDIRECT:RESEARCHSPECIAL",
     491              :     "EVAPORATIVECOOLER:INDIRECT:WETCOIL",
     492              :     "EVAPORATIVEFLUIDCOOLER:SINGLESPEED",
     493              :     "EVAPORATIVEFLUIDCOOLER:TWOSPEED",
     494              :     "FAN:COMPONENTMODEL",
     495              :     "FAN:CONSTANTVOLUME",
     496              :     "FAN:ONOFF",
     497              :     "FAN:SYSTEMMODEL",
     498              :     "FAN:VARIABLEVOLUME",
     499              :     "FAN:ZONEEXHAUST",
     500              :     "FLUIDCOOLER:SINGLESPEED",
     501              :     "FLUIDCOOLER:TWOSPEED",
     502              :     "GENERATOR:COMBUSTIONTURBINE",
     503              :     "GENERATOR:FUELCELL:AIRSUPPLY",
     504              :     "GENERATOR:FUELCELL:EXHAUSTGASTOWATERHEATEXCHANGER",
     505              :     "GENERATOR:FUELCELL:POWERMODULE",
     506              :     "GENERATOR:FUELCELL:STACKCOOLER",
     507              :     "GENERATOR:FUELCELL:WATERSUPPLY",
     508              :     "GENERATOR:FUELSUPPLY",
     509              :     "GENERATOR:INTERNALCOMBUSTIONENGINE",
     510              :     "GENERATOR:MICROCHP",
     511              :     "GENERATOR:MICROTURBINE",
     512              :     "GROUNDHEATEXCHANGER:HORIZONTALTRENCH",
     513              :     "GROUNDHEATEXCHANGER:POND",
     514              :     "GROUNDHEATEXCHANGER:SLINKY",
     515              :     "GROUNDHEATEXCHANGER:SURFACE",
     516              :     "GROUNDHEATEXCHANGER:SYSTEM",
     517              :     "HEADEREDPUMPS:CONSTANTSPEED",
     518              :     "HEADEREDPUMPS:VARIABLESPEED",
     519              :     "HEATEXCHANGER:AIRTOAIR:FLATPLATE",
     520              :     "HEATEXCHANGER:AIRTOAIR:SENSIBLEANDLATENT",
     521              :     "HEATEXCHANGER:DESICCANT:BALANCEDFLOW",
     522              :     "HEATEXCHANGER:FLUIDTOFLUID",
     523              :     "HEATPUMP:AIRTOWATER:FUELFIRED:COOLING",
     524              :     "HEATPUMP:AIRTOWATER:FUELFIRED:HEATING",
     525              :     "HEATPUMP:PLANTLOOP:EIR:COOLING",
     526              :     "HEATPUMP:PLANTLOOP:EIR:HEATING",
     527              :     "HEATPUMP:WATERTOWATER:EQUATIONFIT:COOLING",
     528              :     "HEATPUMP:WATERTOWATER:EQUATIONFIT:HEATING",
     529              :     "HEATPUMP:WATERTOWATER:PARAMETERESTIMATION:COOLING",
     530              :     "HEATPUMP:WATERTOWATER:PARAMETERESTIMATION:HEATING",
     531              :     "HUMIDIFIER:STEAM:ELECTRIC",
     532              :     "HUMIDIFIER:STEAM:GAS",
     533              :     "LIGHTS",
     534              :     "LOADPROFILE:PLANT",
     535              :     "OUTDOORAIR:MIXER",
     536              :     "OUTDOORAIR:NODE",
     537              :     "OUTDOORAIR:NODELIST",
     538              :     "PIPE:ADIABATIC",
     539              :     "PIPE:ADIABATIC:STEAM",
     540              :     "PIPE:INDOOR",
     541              :     "PIPE:OUTDOOR",
     542              :     "PIPE:UNDERGROUND",
     543              :     "PIPINGSYSTEM:UNDERGROUND:PIPECIRCUIT",
     544              :     "PLANTCOMPONENT:TEMPERATURESOURCE",
     545              :     "PLANTCOMPONENT:USERDEFINED",
     546              :     "PLANTEQUIPMENTOPERATION:CHILLERHEATERCHANGEOVER",
     547              :     "PLANTEQUIPMENTOPERATION:COMPONENTSETPOINT",
     548              :     "PLANTEQUIPMENTOPERATION:OUTDOORDEWPOINTDIFFERENCE",
     549              :     "PLANTEQUIPMENTOPERATION:OUTDOORDRYBULBDIFFERENCE",
     550              :     "PLANTEQUIPMENTOPERATION:OUTDOORWETBULBDIFFERENCE",
     551              :     "PLANTEQUIPMENTOPERATION:THERMALENERGYSTORAGE",
     552              :     "PLANTLOOP",
     553              :     "PUMP:CONSTANTSPEED",
     554              :     "PUMP:CONSTANTVOLUME",
     555              :     "PUMP:VARIABLESPEED",
     556              :     "PUMP:VARIABLESPEED:CONDENSATE",
     557              :     "REFRIGERATION:COMPRESSORRACK",
     558              :     "REFRIGERATION:CONDENSER:AIRCOOLED",
     559              :     "REFRIGERATION:CONDENSER:EVAPORATIVECOOLED",
     560              :     "REFRIGERATION:CONDENSER:WATERCOOLED",
     561              :     "REFRIGERATION:GASCOOLER:AIRCOOLED",
     562              :     "SETPOINTMANAGER:COLDEST",
     563              :     "SETPOINTMANAGER:CONDENSERENTERINGRESET",
     564              :     "SETPOINTMANAGER:CONDENSERENTERINGRESET:IDEAL",
     565              :     "SETPOINTMANAGER:FOLLOWGROUNDTEMPERATURE",
     566              :     "SETPOINTMANAGER:FOLLOWOUTDOORAIRTEMPERATURE",
     567              :     "SETPOINTMANAGER:FOLLOWSYSTEMNODETEMPERATURE",
     568              :     "SETPOINTMANAGER:MIXEDAIR",
     569              :     "SETPOINTMANAGER:MULTIZONE:COOLING:AVERAGE",
     570              :     "SETPOINTMANAGER:MULTIZONE:HEATING:AVERAGE",
     571              :     "SETPOINTMANAGER:MULTIZONE:HUMIDITY:MAXIMUM",
     572              :     "SETPOINTMANAGER:MULTIZONE:HUMIDITY:MINIMUM",
     573              :     "SETPOINTMANAGER:MULTIZONE:MAXIMUMHUMIDITY:AVERAGE",
     574              :     "SETPOINTMANAGER:MULTIZONE:MINIMUMHUMIDITY:AVERAGE",
     575              :     "SETPOINTMANAGER:OUTDOORAIRPRETREAT",
     576              :     "SETPOINTMANAGER:OUTDOORAIRRESET",
     577              :     "SETPOINTMANAGER:RETURNTEMPERATURE:CHILLEDWATER",
     578              :     "SETPOINTMANAGER:RETURNTEMPERATURE:HOTWATER",
     579              :     "SETPOINTMANAGER:SCHEDULED",
     580              :     "SETPOINTMANAGER:SCHEDULED:DUALSETPOINT",
     581              :     "SETPOINTMANAGER:SINGLEZONE:COOLING",
     582              :     "SETPOINTMANAGER:SINGLEZONE:HEATING",
     583              :     "SETPOINTMANAGER:SINGLEZONE:HUMIDITY:MAXIMUM",
     584              :     "SETPOINTMANAGER:SINGLEZONE:HUMIDITY:MINIMUM",
     585              :     "SETPOINTMANAGER:SINGLEZONE:ONESTAGECOOLING",
     586              :     "SETPOINTMANAGER:SINGLEZONE:ONESTAGEHEATING",
     587              :     "SETPOINTMANAGER:SINGLEZONE:REHEAT",
     588              :     "SETPOINTMANAGER:SYSTEMNODERESET:TEMPERATURE",
     589              :     "SETPOINTMANAGER:SYSTEMNODERESET:HUMIDITY",
     590              :     "SETPOINTMANAGER:WARMEST",
     591              :     "SETPOINTMANAGER:WARMESTTEMPERATUREFLOW",
     592              :     "SOLARCOLLECTOR:FLATPLATE:PHOTOVOLTAICTHERMAL",
     593              :     "SOLARCOLLECTOR:FLATPLATE:WATER",
     594              :     "SOLARCOLLECTOR:INTEGRALCOLLECTORSTORAGE",
     595              :     "SOLARCOLLECTOR:UNGLAZEDTRANSPIRED",
     596              :     "SURFACEPROPERTY:LOCALENVIRONMENT",
     597              :     "SWIMMINGPOOL:INDOOR",
     598              :     "TEMPERINGVALVE",
     599              :     "THERMALSTORAGE:CHILLEDWATER:MIXED",
     600              :     "THERMALSTORAGE:CHILLEDWATER:STRATIFIED",
     601              :     "THERMALSTORAGE:ICE:DETAILED",
     602              :     "THERMALSTORAGE:ICE:SIMPLE",
     603              :     "WATERHEATER:HEATPUMP",
     604              :     "WATERHEATER:HEATPUMP:PUMPEDCONDENSER",
     605              :     "WATERHEATER:HEATPUMP:WRAPPEDCONDENSER",
     606              :     "WATERHEATER:MIXED",
     607              :     "WATERHEATER:STRATIFIED",
     608              :     "WATERUSE:CONNECTIONS",
     609              :     "ZONEHVAC:AIRDISTRIBUTIONUNIT",
     610              :     "ZONEHVAC:BASEBOARD:CONVECTIVE:ELECTRIC",
     611              :     "ZONEHVAC:BASEBOARD:CONVECTIVE:WATER",
     612              :     "ZONEHVAC:BASEBOARD:RADIANTCONVECTIVE:ELECTRIC",
     613              :     "ZONEHVAC:BASEBOARD:RADIANTCONVECTIVE:STEAM",
     614              :     "ZONEHVAC:BASEBOARD:RADIANTCONVECTIVE:WATER",
     615              :     "ZONEHVAC:COOLINGPANEL:RADIANTCONVECTIVE:WATER",
     616              :     "ZONEHVAC:DEHUMIDIFIER:DX",
     617              :     "ZONEHVAC:ENERGYRECOVERYVENTILATOR",
     618              :     "ZONEHVAC:EQUIPMENTCONNECTIONS",
     619              :     "ZONEHVAC:EVAPORATIVECOOLERUNIT",
     620              :     "ZONEHVAC:EXHAUSTCONTROL",
     621              :     "ZONEHVAC:FORCEDAIR:USERDEFINED",
     622              :     "ZONEHVAC:FOURPIPEFANCOIL",
     623              :     "ZONEHVAC:HIGHTEMPERATURERADIANT",
     624              :     "ZONEHVAC:HYBRIDUNITARYHVAC",
     625              :     "ZONEHVAC:IDEALLOADSAIRSYSTEM",
     626              :     "ZONEHVAC:LOWTEMPERATURERADIANT:CONSTANTFLOW",
     627              :     "ZONEHVAC:LOWTEMPERATURERADIANT:VARIABLEFLOW",
     628              :     "ZONEHVAC:OUTDOORAIRUNIT",
     629              :     "ZONEHVAC:PACKAGEDTERMINALAIRCONDITIONER",
     630              :     "ZONEHVAC:PACKAGEDTERMINALHEATPUMP",
     631              :     "ZONEHVAC:REFRIGERATIONCHILLERSET",
     632              :     "ZONEHVAC:TERMINALUNIT:VARIABLEREFRIGERANTFLOW",
     633              :     "ZONEHVAC:UNITHEATER",
     634              :     "ZONEHVAC:UNITVENTILATOR",
     635              :     "ZONEHVAC:VENTILATEDSLAB",
     636              :     "ZONEHVAC:WATERTOAIRHEATPUMP",
     637              :     "ZONEHVAC:WINDOWAIRCONDITIONER",
     638              :     "ZONEPROPERTY:LOCALENVIRONMENT",
     639              :     "SPACEHVAC:EQUIPMENTCONNECTIONS",
     640              :     "SPACEHVAC:ZONEEQUIPMENTSPLITTER",
     641              :     "SPACEHVAC:ZONEEQUIPMENTMIXER"};
     642              : 
     643        11020 : void RegisterNodeConnection(EnergyPlusData &state,
     644              :                             int const NodeNumber,                                // Number for this Node
     645              :                             std::string_view const NodeName,                     // Name of this Node
     646              :                             DataLoopNode::ConnectionObjectType const ObjectType, // Type of object this Node is connected to (e.g. Chiller:Electric)
     647              :                             std::string_view const ObjectName,                   // Name of object this Node is connected to (e.g. MyChiller)
     648              :                             DataLoopNode::ConnectionType const ConnectionType,   // Connection Type for this Node (must be valid)
     649              :                             NodeInputManager::CompFluidStream const FluidStream, // Count on Fluid Streams
     650              :                             bool const IsParent,                                 // True when node is a parent node
     651              :                             bool &errFlag,                                       // Will be True if errors already detected or if errors found here
     652              :                             std::string_view const InputFieldName                // Input Field Name
     653              : )
     654              : {
     655              : 
     656              :     // SUBROUTINE INFORMATION:
     657              :     //       AUTHOR         Linda K. Lawrie
     658              :     //       DATE WRITTEN   February 2004
     659              :     //       MODIFIED       na
     660              :     //       RE-ENGINEERED  na
     661              : 
     662              :     // PURPOSE OF THIS SUBROUTINE:
     663              :     // This subroutine registers a node connection in the Node Connection data structure.  This
     664              :     // structure is intended to help with HVAC diagramming as well as validation of nodes.
     665              : 
     666              :     // SUBROUTINE PARAMETER DEFINITIONS:
     667              :     static constexpr std::string_view RoutineName = "RegisterNodeConnection: ";
     668              : 
     669        11020 :     bool ErrorsFoundHere = false;
     670              : 
     671        11020 :     if ((ObjectType == DataLoopNode::ConnectionObjectType::Invalid) || (ObjectType == DataLoopNode::ConnectionObjectType::Num)) {
     672            0 :         ShowSevereError(state, "Developer Error: Invalid ObjectType");
     673            0 :         ShowContinueError(state, format("Occurs for Node={}, ObjectName={}", std::string{NodeName}, std::string{ObjectName}));
     674            0 :         ErrorsFoundHere = true;
     675              :     }
     676              : 
     677        11020 :     std::string_view const objTypeStr = ConnectionObjectTypeNames[static_cast<int>(ObjectType)];
     678        11020 :     std::string_view const conTypeStr = ConnectionTypeNames[static_cast<int>(ConnectionType)];
     679              : 
     680        11020 :     if ((ConnectionType == DataLoopNode::ConnectionType::Invalid) || (ConnectionType == DataLoopNode::ConnectionType::Num)) {
     681            0 :         ShowSevereError(state, format("{}{}{}", RoutineName, "Invalid ConnectionType=", ConnectionType));
     682            0 :         ShowContinueError(state, format("Occurs for Node={}, ObjectType={}, ObjectName={}", NodeName, objTypeStr, ObjectName));
     683            0 :         ErrorsFoundHere = true;
     684              :     }
     685              : 
     686        11020 :     bool MakeNew = true;
     687       362720 :     for (int Count = 1; Count <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Count) {
     688       351700 :         if (state.dataBranchNodeConnections->NodeConnections(Count).NodeNumber != NodeNumber) continue;
     689         9385 :         if (state.dataBranchNodeConnections->NodeConnections(Count).ObjectType != ObjectType) continue;
     690          657 :         if (!Util::SameString(state.dataBranchNodeConnections->NodeConnections(Count).ObjectName, ObjectName)) continue;
     691          446 :         if (state.dataBranchNodeConnections->NodeConnections(Count).ConnectionType != ConnectionType) continue;
     692          271 :         if (state.dataBranchNodeConnections->NodeConnections(Count).FluidStream != FluidStream) continue;
     693          542 :         if ((state.dataBranchNodeConnections->NodeConnections(Count).ObjectIsParent && !IsParent) ||
     694          271 :             (!state.dataBranchNodeConnections->NodeConnections(Count).ObjectIsParent && IsParent)) {
     695            0 :             ShowSevereError(state, format("{}{}", RoutineName, "Node registered for both Parent and \"not\" Parent"));
     696            0 :             ShowContinueError(state, format("{}{}{}{}{}{}", "Occurs for Node=", NodeName, ", ObjectType=", ObjectType, ", ObjectName=", ObjectName));
     697            0 :             ErrorsFoundHere = true;
     698              :         }
     699          271 :         MakeNew = false;
     700              :     }
     701        11020 :     if (MakeNew) {
     702        10749 :         int constexpr NodeConnectionAlloc = 1000;
     703        10749 :         ++state.dataBranchNodeConnections->NumOfNodeConnections;
     704        20820 :         if (state.dataBranchNodeConnections->NumOfNodeConnections > 1 &&
     705        10071 :             state.dataBranchNodeConnections->NumOfNodeConnections > state.dataBranchNodeConnections->MaxNumOfNodeConnections) {
     706            0 :             state.dataBranchNodeConnections->NodeConnections.resize(state.dataBranchNodeConnections->MaxNumOfNodeConnections += NodeConnectionAlloc);
     707        10749 :         } else if (state.dataBranchNodeConnections->NumOfNodeConnections == 1) {
     708          678 :             state.dataBranchNodeConnections->NodeConnections.allocate(NodeConnectionAlloc);
     709          678 :             state.dataBranchNodeConnections->MaxNumOfNodeConnections = NodeConnectionAlloc;
     710              :         }
     711              : 
     712        10749 :         state.dataBranchNodeConnections->NodeConnections(state.dataBranchNodeConnections->NumOfNodeConnections).NodeNumber = NodeNumber;
     713        10749 :         state.dataBranchNodeConnections->NodeConnections(state.dataBranchNodeConnections->NumOfNodeConnections).NodeName = NodeName;
     714        10749 :         state.dataBranchNodeConnections->NodeConnections(state.dataBranchNodeConnections->NumOfNodeConnections).ObjectType = ObjectType;
     715        10749 :         state.dataBranchNodeConnections->NodeConnections(state.dataBranchNodeConnections->NumOfNodeConnections).ObjectName = ObjectName;
     716        10749 :         state.dataBranchNodeConnections->NodeConnections(state.dataBranchNodeConnections->NumOfNodeConnections).ConnectionType = ConnectionType;
     717        10749 :         state.dataBranchNodeConnections->NodeConnections(state.dataBranchNodeConnections->NumOfNodeConnections).FluidStream = FluidStream;
     718        10749 :         state.dataBranchNodeConnections->NodeConnections(state.dataBranchNodeConnections->NumOfNodeConnections).ObjectIsParent = IsParent;
     719              :     }
     720              : 
     721        11020 :     if (has_prefixi(objTypeStr, "AirTerminal:")) {
     722          389 :         if (!InputFieldName.empty()) {
     723          389 :             ++state.dataBranchNodeConnections->NumOfAirTerminalNodes;
     724          389 :             int constexpr EqNodeConnectionAlloc = 100;
     725          673 :             if (state.dataBranchNodeConnections->NumOfAirTerminalNodes > 1 &&
     726          284 :                 state.dataBranchNodeConnections->NumOfAirTerminalNodes > state.dataBranchNodeConnections->MaxNumOfAirTerminalNodes) {
     727            0 :                 state.dataBranchNodeConnections->AirTerminalNodeConnections.resize(state.dataBranchNodeConnections->MaxNumOfAirTerminalNodes +=
     728              :                                                                                    EqNodeConnectionAlloc);
     729          389 :             } else if (state.dataBranchNodeConnections->NumOfAirTerminalNodes == 1) {
     730          105 :                 state.dataBranchNodeConnections->AirTerminalNodeConnections.allocate(EqNodeConnectionAlloc);
     731          105 :                 state.dataBranchNodeConnections->MaxNumOfAirTerminalNodes = EqNodeConnectionAlloc;
     732              :             }
     733              : 
     734              :             // Check out AirTerminal inlet/outlet nodes
     735         1167 :             bool Found = Util::FindItemInList(NodeName,
     736          389 :                                               state.dataBranchNodeConnections->AirTerminalNodeConnections,
     737              :                                               &EqNodeConnectionDef::NodeName,
     738          389 :                                               state.dataBranchNodeConnections->NumOfAirTerminalNodes - 1);
     739          389 :             if (Found != 0) { // Nodename already used
     740            0 :                 ShowSevereError(state, fmt::format("{}{}=\"{}\" node name duplicated", RoutineName, ObjectType, ObjectName));
     741            0 :                 ShowContinueError(state, format("NodeName=\"{}\", entered as type={}", NodeName, conTypeStr));
     742            0 :                 ShowContinueError(state, fmt::format("In Field={}", InputFieldName));
     743            0 :                 ShowContinueError(state,
     744            0 :                                   format("NodeName=\"{}\", entered as type={}", NodeName, ConnectionTypeNamesUC[static_cast<int>(ConnectionType)]));
     745            0 :                 ShowContinueError(state, format("In Field={}", InputFieldName));
     746            0 :                 ShowContinueError(
     747              :                     state,
     748            0 :                     format("Already used in {}=\"{}\".", objTypeStr, state.dataBranchNodeConnections->AirTerminalNodeConnections(Found).ObjectName));
     749            0 :                 ShowContinueError(
     750              :                     state,
     751            0 :                     format(" as type={}, In Field={}",
     752            0 :                            ConnectionTypeNamesUC[static_cast<int>(state.dataBranchNodeConnections->AirTerminalNodeConnections(Found).ConnectionType)],
     753            0 :                            state.dataBranchNodeConnections->AirTerminalNodeConnections(Found).InputFieldName));
     754            0 :                 ErrorsFoundHere = true;
     755              :             } else {
     756          389 :                 state.dataBranchNodeConnections->AirTerminalNodeConnections(state.dataBranchNodeConnections->NumOfAirTerminalNodes).NodeName =
     757          389 :                     NodeName;
     758          389 :                 state.dataBranchNodeConnections->AirTerminalNodeConnections(state.dataBranchNodeConnections->NumOfAirTerminalNodes).ObjectType =
     759              :                     ObjectType;
     760          389 :                 state.dataBranchNodeConnections->AirTerminalNodeConnections(state.dataBranchNodeConnections->NumOfAirTerminalNodes).ObjectName =
     761          389 :                     ObjectName;
     762          389 :                 state.dataBranchNodeConnections->AirTerminalNodeConnections(state.dataBranchNodeConnections->NumOfAirTerminalNodes).ConnectionType =
     763              :                     ConnectionType;
     764          389 :                 state.dataBranchNodeConnections->AirTerminalNodeConnections(state.dataBranchNodeConnections->NumOfAirTerminalNodes).InputFieldName =
     765          389 :                     InputFieldName;
     766              :             }
     767              :         } else {
     768            0 :             ShowSevereError(state, fmt::format("{}{} , Developer Error: Input Field Name not included.", RoutineName, objTypeStr));
     769            0 :             ShowContinueError(state, "Node names not checked for duplication.");
     770              :         }
     771              :     }
     772              : 
     773        11020 :     if (ErrorsFoundHere) {
     774            0 :         errFlag = true;
     775              :     }
     776        11020 : }
     777              : 
     778           24 : void OverrideNodeConnectionType(
     779              :     EnergyPlusData &state,
     780              :     int const NodeNumber,                                // Number for this Node
     781              :     std::string const &NodeName,                         // Name of this Node
     782              :     DataLoopNode::ConnectionObjectType const ObjectType, // Type of object this Node is connected to (e.g. Chiller:Electric)
     783              :     std::string const &ObjectName,                       // Name of object this Node is connected to (e.g. MyChiller)
     784              :     DataLoopNode::ConnectionType const ConnectionType,   // Connection Type for this Node (must be valid)
     785              :     NodeInputManager::CompFluidStream const FluidStream, // Count on Fluid Streams
     786              :     bool const IsParent,                                 // True when node is a parent node
     787              :     bool &errFlag                                        // Will be True if errors already detected or if errors found here
     788              : )
     789              : {
     790              : 
     791              :     // SUBROUTINE INFORMATION:
     792              :     //       AUTHOR         M. J. Witte
     793              :     //       DATE WRITTEN   June 2016
     794              : 
     795              :     // PURPOSE:
     796              :     // This subroutine modifies an existing node connection in the Node Connection data structure.  This
     797              :     // structure is intended to help with HVAC diagramming as well as validation of nodes. This function
     798              :     // is a based on RegisterNodeConnection.
     799              : 
     800              :     static constexpr std::string_view RoutineName("ModifyNodeConnectionType: ");
     801              : 
     802           24 :     if ((ConnectionType == DataLoopNode::ConnectionType::Invalid) || (ConnectionType == DataLoopNode::ConnectionType::Num)) {
     803            0 :         ShowSevereError(state, format("{}{}{}", RoutineName, "Invalid ConnectionType=", ConnectionType));
     804            0 :         ShowContinueError(
     805              :             state,
     806            0 :             format("Occurs for Node={}, ObjectType={}, ObjectName={}", NodeName, ConnectionTypeNames[static_cast<int>(ObjectType)], ObjectName));
     807            0 :         errFlag = true;
     808              :     }
     809              : 
     810           24 :     int Found = 0;
     811          342 :     for (int Count = 1; Count <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Count) {
     812          342 :         if (state.dataBranchNodeConnections->NodeConnections(Count).NodeNumber != NodeNumber) continue;
     813           58 :         if (state.dataBranchNodeConnections->NodeConnections(Count).ObjectType != ObjectType) continue;
     814           46 :         if (!Util::SameString(state.dataBranchNodeConnections->NodeConnections(Count).ObjectName, ObjectName)) continue;
     815           24 :         if (state.dataBranchNodeConnections->NodeConnections(Count).FluidStream != FluidStream) continue;
     816           24 :         if ((state.dataBranchNodeConnections->NodeConnections(Count).ObjectIsParent != IsParent)) continue;
     817           24 :         Found = Count;
     818           24 :         break;
     819              :     }
     820              : 
     821           24 :     if (Found > 0) {
     822           24 :         state.dataBranchNodeConnections->NodeConnections(Found).ConnectionType = ConnectionType;
     823              :     } else {
     824            0 :         ShowSevereError(state, format("{}{}", RoutineName, "Existing node connection not found."));
     825            0 :         ShowContinueError(
     826              :             state,
     827            0 :             format("Occurs for Node={}, ObjectType={}, ObjectName={}", NodeName, ConnectionTypeNames[static_cast<int>(ObjectType)], ObjectName));
     828            0 :         errFlag = true;
     829              :     }
     830           24 : }
     831              : 
     832           79 : void CheckNodeConnections(EnergyPlusData &state, bool &ErrorsFound)
     833              : {
     834              : 
     835              :     // SUBROUTINE INFORMATION:
     836              :     //       AUTHOR         Linda Lawrie
     837              :     //       DATE WRITTEN   March 2004
     838              :     //       MODIFIED       na
     839              :     //       RE-ENGINEERED  na
     840              : 
     841              :     // PURPOSE OF THIS SUBROUTINE:
     842              :     // This subroutine processes the node connection data structure looking at:
     843              :     // 1.  In the NodeConnections list, for any node which appears as a sensor or an
     844              :     // actuator, the same node must also appear in the connections list at least once
     845              :     // as a node type which is not sensor or actuator or outsideair.
     846              :     // 2.  In the NodeConnections list, for any node which appears as a setpoint, the
     847              :     // same node must also appear in the connections list at least once as a node type
     848              :     // which is not a setpoint or outsideair.
     849              :     // 3.  Every ZoneInlet must appear as an outlet from something, otherwise it will
     850              :     // do nothing.
     851              :     // 4.  Every ZoneExhaust must appear as an inlet to something,
     852              :     // otherwise it will do nothing.
     853              :     // 5.  Every inlet node should match either an Outlet, ZoneReturn, ZoneExhaust, ReliefAir,
     854              :     // or OutsideAir node.
     855              :     //  With the current data structure, when checking inlets:
     856              :     //    a)  If an InletNode's object is AirLoopHVAC, CondenserLoop, or PlantLoop, then skip the test.
     857              :     //    b)  If an InletNode's object is not one of the above types, it is valid if the
     858              :     //        same node name appears as an INLET to an AirLoopHVAC, CondenserLoop, or PlantLoop.
     859              :     // 6.  Any given node can only be an inlet once in the list of Non-Parent Node Connections
     860              :     // 7.  Any given node can only be an outlet once in the list of Non-Parent Node Connections
     861              :     // 8.  non-parent outlet nodes -- must never be an outlet more than once
     862              :     // 9.  nodes of type OutsideAirReference must be registered as DataLoopNode::NodeConnectionType::OutsideAir
     863              :     // 10. fluid streams cannot have multiple inlet/outlet nodes on same component
     864              :     // 11. zone nodes may not be used as anything else except as a setpoint, sensor or actuator node
     865              : 
     866              :     // METHODOLOGY EMPLOYED:
     867              :     // Needs description, as appropriate.
     868              : 
     869              :     // Using/Aliasing
     870              : 
     871              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     872              :     bool IsValid;
     873              :     bool IsInlet;
     874              :     bool IsOutlet;
     875              :     bool MatchedAtLeastOne;
     876              :     int ErrorCounter;
     877           79 :     Array1D_int FluidStreamInletCount;
     878           79 :     Array1D_int FluidStreamOutletCount;
     879           79 :     Array1D_int NodeObjects;
     880           79 :     Array1D_bool FluidStreamCounts;
     881              : 
     882           79 :     ErrorCounter = 0;
     883              : 
     884              :     //  Check 1 -- check sensor and actuator nodes
     885         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
     886         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::Sensor) continue;
     887          172 :         IsValid = false;
     888        16979 :         for (int Loop2 = 1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
     889        16807 :             if (Loop1 == Loop2) continue;
     890        16635 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber !=
     891        16635 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber)
     892        15825 :                 continue;
     893         1620 :             if ((state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Actuator) ||
     894          810 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Sensor)) {
     895          154 :                 continue;
     896              :             }
     897              : 
     898          656 :             IsValid = true;
     899              :         }
     900          172 :         if (!IsValid) {
     901            4 :             ShowSevereError(state,
     902            4 :                             format("Node Connection Error, Node=\"{}\", Sensor node did not find a matching node of appropriate type (other than "
     903              :                                    "Actuator or Sensor).",
     904            2 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
     905              : 
     906            4 :             ShowContinueError(state,
     907            4 :                               format("Reference Object={}, Name={}",
     908            2 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
     909            2 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
     910            2 :             ++ErrorCounter;
     911            2 :             ErrorsFound = true;
     912              :         }
     913              :     }
     914              : 
     915         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
     916         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::Actuator) continue;
     917           48 :         IsValid = false;
     918         4652 :         for (int Loop2 = 1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
     919         4604 :             if (Loop1 == Loop2) continue;
     920         4556 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber !=
     921         4556 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber)
     922         4472 :                 continue;
     923              : 
     924           84 :             if ((state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Actuator) ||
     925          168 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Sensor) ||
     926           84 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::OutsideAir)) {
     927           20 :                 continue;
     928              :             }
     929              : 
     930           64 :             IsValid = true;
     931              :         }
     932           48 :         if (!IsValid) {
     933            4 :             ShowSevereError(state,
     934            4 :                             format("Node Connection Error, Node=\"{}\", Actuator node did not find a matching node of appropriate type (other than "
     935              :                                    "Actuator, Sensor, OutsideAir).",
     936            2 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
     937              : 
     938            4 :             ShowContinueError(state,
     939            4 :                               format("Reference Object={}, Name={}",
     940            2 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
     941            2 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
     942            2 :             ++ErrorCounter;
     943            2 :             ErrorsFound = true;
     944              :         }
     945              :     }
     946              : 
     947              :     // Check 2 -- setpoint nodes
     948              :     // Check 2a -- setpoint node must also be an inlet or an outlet (CR8212)
     949         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
     950         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::SetPoint) continue;
     951           96 :         IsValid = false;
     952           96 :         IsInlet = false;
     953           96 :         IsOutlet = false;
     954        10889 :         for (int Loop2 = 1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
     955        10793 :             if (Loop1 == Loop2) continue;
     956        10697 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber !=
     957        10697 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber)
     958        10264 :                 continue;
     959          866 :             if ((state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::SetPoint) ||
     960          433 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::OutsideAir)) {
     961            0 :                 continue;
     962              :             }
     963              : 
     964          433 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Inlet) {
     965           71 :                 IsInlet = true;
     966          362 :             } else if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Outlet) {
     967          181 :                 IsOutlet = true;
     968              :             }
     969          433 :             IsValid = true;
     970              :         }
     971           96 :         if (!IsValid) {
     972            0 :             ShowSevereError(state,
     973            0 :                             format("Node Connection Error, Node=\"{}\", Setpoint node did not find a matching node of appropriate type (other than "
     974              :                                    "Setpoint, OutsideAir).",
     975            0 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
     976              : 
     977            0 :             ShowContinueError(state,
     978            0 :                               format("Reference Object={}, Name={}",
     979            0 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
     980            0 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
     981            0 :             ++ErrorCounter;
     982            0 :             ErrorsFound = true;
     983              :         }
     984           96 :         if (!IsInlet && !IsOutlet) {
     985            4 :             ShowSevereError(state,
     986            4 :                             format("Node Connection Error, Node=\"{}\", Setpoint node did not find a matching node of type Inlet or Outlet.",
     987            2 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
     988            4 :             ShowContinueError(state, "It appears this node is not part of the HVAC system.");
     989              : 
     990            4 :             ShowContinueError(state,
     991            4 :                               format("Reference Object={}, Name={}",
     992            2 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
     993            2 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
     994            2 :             ++ErrorCounter;
     995              :         }
     996              :     }
     997              : 
     998              :     // Check 2a -- setpoint node must also be an inlet or an outlet (CR8212)
     999              : 
    1000              :     // Check 3 -- zone inlet nodes -- must be an outlet somewhere
    1001         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
    1002         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::ZoneInlet) continue;
    1003           59 :         IsValid = false;
    1004         6423 :         for (int Loop2 = 1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
    1005         6364 :             if (Loop1 == Loop2) continue;
    1006         6305 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber !=
    1007         6305 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber)
    1008         6180 :                 continue;
    1009          125 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType != DataLoopNode::ConnectionType::Outlet) continue;
    1010          121 :             IsValid = true;
    1011              :         }
    1012           59 :         if (!IsValid) {
    1013            0 :             ShowSevereError(state,
    1014            0 :                             format("Node Connection Error, Node=\"{}\", ZoneInlet node did not find an outlet node.",
    1015            0 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
    1016              : 
    1017            0 :             ShowContinueError(state,
    1018            0 :                               format("Reference Object={}, Name={}",
    1019            0 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1020            0 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1021            0 :             ++ErrorCounter;
    1022              :         }
    1023              :     }
    1024              : 
    1025              :     // Check 4 -- zone exhaust nodes -- must be an inlet somewhere
    1026         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
    1027         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::ZoneExhaust) continue;
    1028           33 :         IsValid = false;
    1029         3592 :         for (int Loop2 = 1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
    1030         3559 :             if (Loop1 == Loop2) continue;
    1031         3526 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber !=
    1032         3526 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber)
    1033         3485 :                 continue;
    1034           41 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType != DataLoopNode::ConnectionType::Inlet) continue;
    1035           41 :             IsValid = true;
    1036              :         }
    1037           33 :         if (!IsValid) {
    1038           18 :             ShowSevereError(state,
    1039           18 :                             format("Node Connection Error, Node=\"{}\", ZoneExhaust node did not find a matching inlet node.",
    1040            9 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
    1041              : 
    1042           18 :             ShowContinueError(state,
    1043           18 :                               format("Reference Object={}, Name={}",
    1044            9 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1045            9 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1046            9 :             ++ErrorCounter;
    1047              :         }
    1048              :     }
    1049              : 
    1050              :     // Check 5 -- return plenum induced air outlet nodes -- must be an inlet somewhere
    1051         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
    1052         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::InducedAir) continue;
    1053            0 :         IsValid = false;
    1054            0 :         for (int Loop2 = 1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
    1055            0 :             if (Loop1 == Loop2) continue;
    1056            0 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber !=
    1057            0 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber)
    1058            0 :                 continue;
    1059            0 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType != DataLoopNode::ConnectionType::Inlet) continue;
    1060            0 :             IsValid = true;
    1061              :         }
    1062            0 :         if (!IsValid) {
    1063            0 :             ShowSevereError(state,
    1064            0 :                             format("Node Connection Error, Node=\"{}\", Return plenum induced air outlet node did not find a matching inlet node.",
    1065            0 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
    1066              : 
    1067            0 :             ShowContinueError(state,
    1068            0 :                               format("Reference Object={}, Name={}",
    1069            0 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1070            0 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1071            0 :             ++ErrorCounter;
    1072            0 :             ErrorsFound = true;
    1073              :         }
    1074              :     }
    1075              : 
    1076              :     // Check 6 -- every inlet should have a matching outlet, zonereturn, zoneexhaust, induced air, reliefair or outsideair
    1077              :     //    a)  If an InletNode's object is AirLoopHVAC, CondenserLoop, or PlantLoop, then skip the test.
    1078              :     //    b)  If an InletNode's object is not one of the above types, it is valid if the
    1079              :     //        same node name appears as an INLET to an AirLoopHVAC, CondenserLoop, or PlantLoop.
    1080         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
    1081         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::Inlet) continue;
    1082          814 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType == DataLoopNode::ConnectionObjectType::AirLoopHVAC ||
    1083         1576 :             state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType == DataLoopNode::ConnectionObjectType::CondenserLoop ||
    1084          762 :             state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType == DataLoopNode::ConnectionObjectType::PlantLoop)
    1085           74 :             continue;
    1086          740 :         IsValid = false;
    1087          740 :         MatchedAtLeastOne = false;
    1088       103870 :         for (int Loop2 = 1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
    1089       103130 :             if (Loop1 == Loop2) continue;
    1090       102390 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber !=
    1091       102390 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber)
    1092       100796 :                 continue;
    1093              : 
    1094         1594 :             if ((state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Outlet) ||
    1095         1026 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::ZoneReturn) ||
    1096          987 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::ZoneExhaust) ||
    1097          946 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::InducedAir) ||
    1098         3562 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::ReliefAir) ||
    1099          942 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::OutsideAir)) {
    1100          693 :                 MatchedAtLeastOne = true;
    1101          693 :                 continue;
    1102              :             }
    1103              : 
    1104         1474 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Inlet &&
    1105          573 :                 (state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectType == DataLoopNode::ConnectionObjectType::AirLoopHVAC ||
    1106          476 :                  state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectType == DataLoopNode::ConnectionObjectType::CondenserLoop ||
    1107          468 :                  state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectType == DataLoopNode::ConnectionObjectType::PlantLoop)) {
    1108          149 :                 MatchedAtLeastOne = true;
    1109          149 :                 continue;
    1110              :             }
    1111          752 :             IsValid = false;
    1112              :         }
    1113          740 :         if (!IsValid && !MatchedAtLeastOne) {
    1114           16 :             ShowSevereError(state,
    1115           16 :                             format("{}{}{}",
    1116              :                                    "Node Connection Error, Node=\"",
    1117            8 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName,
    1118              :                                    R"(", Inlet node did not find an appropriate matching "outlet" node.)"));
    1119           16 :             ShowContinueError(state, "If this is an outdoor air inlet node, it must be listed in an OutdoorAir:Node or OutdoorAir:NodeList object.");
    1120              : 
    1121           16 :             ShowContinueError(state,
    1122           16 :                               format("Reference Object={}, Name={}",
    1123            8 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1124            8 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1125            8 :             ++ErrorCounter;
    1126              :         }
    1127              :     }
    1128              : 
    1129              :     // Check 7 -- non-parent inlet nodes -- must never be an inlet more than once
    1130         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
    1131              :         // Only non-parent node connections
    1132         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectIsParent) continue;
    1133         1640 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::Inlet) continue;
    1134        24448 :         for (int Loop2 = Loop1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
    1135        23923 :             if (Loop1 == Loop2) continue;
    1136        23398 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectIsParent) continue;
    1137        20094 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType != DataLoopNode::ConnectionType::Inlet) continue;
    1138         8999 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber ==
    1139         8999 :                 state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber) {
    1140            0 :                 ShowSevereError(state,
    1141            0 :                                 format("Node Connection Error, Node=\"{}\", The same node appears as a non-parent Inlet node more than once.",
    1142            0 :                                        state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
    1143              : 
    1144            0 :                 ShowContinueError(
    1145              :                     state,
    1146            0 :                     format("Reference Object={}, Name={}",
    1147            0 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1148            0 :                            state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1149              : 
    1150            0 :                 ShowContinueError(
    1151              :                     state,
    1152            0 :                     format("Reference Object={}, Name={}",
    1153            0 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectType)],
    1154            0 :                            state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectName));
    1155            0 :                 ++ErrorCounter;
    1156            0 :                 break;
    1157              :             }
    1158              :         }
    1159              :     }
    1160              : 
    1161              :     // Check 8 -- non-parent outlet nodes -- must never be an outlet more than once
    1162         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
    1163              :         // Only non-parent node connections
    1164         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectIsParent) continue;
    1165         1640 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::Outlet) continue;
    1166          493 :         IsValid = true;
    1167        23925 :         for (int Loop2 = Loop1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
    1168        23432 :             if (Loop1 == Loop2) continue;
    1169        22939 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectIsParent) continue;
    1170        19694 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType != DataLoopNode::ConnectionType::Outlet) continue;
    1171         8057 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber ==
    1172         8057 :                 state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber) {
    1173              :                 // Skip if one of the
    1174            0 :                 ShowSevereError(state,
    1175            0 :                                 format("Node Connection Error, Node=\"{}\", The same node appears as a non-parent Outlet node more than once.",
    1176            0 :                                        state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
    1177              : 
    1178            0 :                 ShowContinueError(
    1179              :                     state,
    1180            0 :                     format("Reference Object={}, Name={}",
    1181            0 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1182            0 :                            state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1183              : 
    1184            0 :                 ShowContinueError(
    1185              :                     state,
    1186            0 :                     format("Reference Object={}, Name={}",
    1187            0 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectType)],
    1188            0 :                            state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectName));
    1189              : 
    1190            0 :                 ++ErrorCounter;
    1191            0 :                 break;
    1192              :             }
    1193              :         }
    1194              :     }
    1195              : 
    1196              :     // Check 9 -- nodes of type OutsideAirReference must be registered as DataLoopNode::NodeConnectionType::OutsideAir
    1197         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
    1198         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::OutsideAirReference) continue;
    1199           11 :         IsValid = false;
    1200          193 :         for (int Loop2 = 1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
    1201          193 :             if (Loop1 == Loop2) continue;
    1202          193 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeNumber !=
    1203          193 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeNumber)
    1204          182 :                 continue;
    1205           11 :             if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType != DataLoopNode::ConnectionType::OutsideAir) continue;
    1206           11 :             IsValid = true;
    1207           11 :             break;
    1208              :         }
    1209           11 :         if (!IsValid) {
    1210            0 :             ShowSevereError(state,
    1211            0 :                             format("{}{}{}",
    1212              :                                    "Node Connection Error, Node=\"",
    1213            0 :                                    state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName,
    1214              :                                    R"(", Outdoor Air Reference did not find an appropriate "outdoor air" node.)"));
    1215            0 :             ShowContinueError(state, "This node must be listed in an OutdoorAir:Node or OutdoorAir:NodeList object in order to set its conditions.");
    1216              : 
    1217            0 :             ShowContinueError(state,
    1218            0 :                               format("Reference Object={}, Name={}",
    1219            0 :                                      ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1220            0 :                                      state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1221              : 
    1222            0 :             ++ErrorCounter;
    1223              :         }
    1224              :     }
    1225              : 
    1226              :     // Check 10 -- fluid streams cannot have multiple inlet/outlet nodes on same component
    1227              :     //  can have multiple inlets with one outlet or vice versa but cannot have multiple both inlet and outlet
    1228           79 :     if (state.dataBranchNodeConnections->NumOfNodeConnections > 0) {
    1229           43 :         int MaxFluidStream = static_cast<int>(maxval(state.dataBranchNodeConnections->NodeConnections, &NodeConnectionDef::FluidStream));
    1230           43 :         FluidStreamInletCount.allocate(MaxFluidStream);
    1231           43 :         FluidStreamOutletCount.allocate(MaxFluidStream);
    1232           43 :         FluidStreamCounts.allocate(MaxFluidStream);
    1233           43 :         NodeObjects.allocate(state.dataBranchNodeConnections->NumOfNodeConnections + 1);
    1234           43 :         FluidStreamInletCount = 0;
    1235           43 :         FluidStreamOutletCount = 0;
    1236           43 :         NodeObjects = 0;
    1237           43 :         FluidStreamCounts = false;
    1238              :         // Following code relies on node connections for single object type/name being grouped together
    1239           43 :         int Object = 1;
    1240           43 :         int EndConnect = 0;
    1241           43 :         int NumObjects = 2;
    1242           43 :         NodeObjects(1) = 1;
    1243         2344 :         while (Object < state.dataBranchNodeConnections->NumOfNodeConnections) {
    1244         2301 :             if (state.dataBranchNodeConnections->NodeConnections(Object).ObjectType !=
    1245         4018 :                     state.dataBranchNodeConnections->NodeConnections(Object + 1).ObjectType ||
    1246         1717 :                 state.dataBranchNodeConnections->NodeConnections(Object).ObjectName !=
    1247         1717 :                     state.dataBranchNodeConnections->NodeConnections(Object + 1).ObjectName) {
    1248          898 :                 EndConnect = Object + 1;
    1249          898 :                 NodeObjects(NumObjects) = EndConnect;
    1250              :                 // if (Object + 1 < state.dataBranchNodeConnections->NumOfNodeConnections) ++NumObjects;
    1251          898 :                 ++NumObjects;
    1252              :             }
    1253         2301 :             ++Object;
    1254              :         }
    1255           43 :         NodeObjects(NumObjects) = state.dataBranchNodeConnections->NumOfNodeConnections + 1;
    1256              :         // NodeObjects now contains each consecutive object...
    1257          984 :         for (Object = 1; Object <= NumObjects - 1; ++Object) {
    1258          941 :             IsValid = true;
    1259          941 :             FluidStreamInletCount = 0;
    1260          941 :             FluidStreamOutletCount = 0;
    1261          941 :             FluidStreamCounts = false;
    1262          941 :             int Loop1 = NodeObjects(Object);
    1263          941 :             if (state.dataBranchNodeConnections->NumOfNodeConnections < 2) continue;
    1264          939 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectIsParent) continue;
    1265          617 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType == DataLoopNode::ConnectionType::Inlet) {
    1266          286 :                 ++FluidStreamInletCount(static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).FluidStream));
    1267          331 :             } else if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType == DataLoopNode::ConnectionType::Outlet) {
    1268          119 :                 ++FluidStreamOutletCount(static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).FluidStream));
    1269              :             }
    1270         1643 :             for (int Loop2 = Loop1 + 1; Loop2 <= NodeObjects(Object + 1) - 1; ++Loop2) {
    1271         1026 :                 if (state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectIsParent) continue;
    1272         1021 :                 if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Inlet) {
    1273          239 :                     ++FluidStreamInletCount(static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop2).FluidStream));
    1274          782 :                 } else if (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Outlet) {
    1275          374 :                     ++FluidStreamOutletCount(static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop2).FluidStream));
    1276              :                 }
    1277              :             }
    1278         2304 :             for (int Loop2 = 1; Loop2 <= MaxFluidStream; ++Loop2) {
    1279         1687 :                 if (FluidStreamInletCount(Loop2) > 1 && FluidStreamOutletCount(Loop2) > 1) {
    1280            1 :                     IsValid = false;
    1281            1 :                     FluidStreamCounts(Loop2) = true;
    1282              :                 }
    1283              :             }
    1284          617 :             if (!IsValid) {
    1285              : 
    1286            2 :                 ShowSevereError(
    1287              :                     state,
    1288            2 :                     format("(Developer) Node Connection Error, Object={}:{}",
    1289            1 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1290            1 :                            state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1291              : 
    1292            2 :                 ShowContinueError(state, "Object has multiple connections on both inlet and outlet fluid streams.");
    1293            2 :                 for (int Loop2 = 1; Loop2 <= MaxFluidStream; ++Loop2) {
    1294            1 :                     if (FluidStreamCounts(Loop2)) ShowContinueError(state, format("...occurs in Fluid Stream [{}].", Loop2));
    1295              :                 }
    1296            1 :                 ++ErrorCounter;
    1297            1 :                 ErrorsFound = true;
    1298              :             }
    1299              :         }
    1300           43 :         FluidStreamInletCount.deallocate();
    1301           43 :         FluidStreamOutletCount.deallocate();
    1302           43 :         FluidStreamCounts.deallocate();
    1303           43 :         NodeObjects.deallocate();
    1304              :     }
    1305              : 
    1306              :     // Check 11 - zone nodes may not be used as anything else except as a setpoint, sensor or actuator node
    1307         2423 :     for (int Loop1 = 1; Loop1 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop1) {
    1308         2344 :         if (state.dataBranchNodeConnections->NodeConnections(Loop1).ConnectionType != DataLoopNode::ConnectionType::ZoneNode) continue;
    1309           84 :         IsValid = true;
    1310         3978 :         for (int Loop2 = Loop1; Loop2 <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop2) {
    1311         3894 :             if (Loop1 == Loop2) continue;
    1312         3810 :             if (state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName ==
    1313         3810 :                 state.dataBranchNodeConnections->NodeConnections(Loop2).NodeName) {
    1314              : 
    1315            6 :                 if ((state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Actuator) ||
    1316            8 :                     (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::Sensor) ||
    1317            2 :                     (state.dataBranchNodeConnections->NodeConnections(Loop2).ConnectionType == DataLoopNode::ConnectionType::SetPoint)) {
    1318            4 :                     continue;
    1319              :                 }
    1320              : 
    1321            4 :                 ShowSevereError(state,
    1322            4 :                                 format("Node Connection Error, Node Name=\"{}\", The same zone node appears more than once.",
    1323            2 :                                        state.dataBranchNodeConnections->NodeConnections(Loop1).NodeName));
    1324              : 
    1325            4 :                 ShowContinueError(
    1326              :                     state,
    1327            4 :                     format("Reference Object={}, Object Name={}",
    1328            2 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectType)],
    1329            2 :                            state.dataBranchNodeConnections->NodeConnections(Loop1).ObjectName));
    1330              : 
    1331            4 :                 ShowContinueError(
    1332              :                     state,
    1333            4 :                     format("Reference Object={}, Object Name={}",
    1334            2 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectType)],
    1335            2 :                            state.dataBranchNodeConnections->NodeConnections(Loop2).ObjectName));
    1336              : 
    1337            2 :                 ++ErrorCounter;
    1338            2 :                 ErrorsFound = true;
    1339              :             }
    1340              :         }
    1341              :     }
    1342              : 
    1343           79 :     state.dataBranchNodeConnections->NumNodeConnectionErrors += ErrorCounter;
    1344           79 : }
    1345              : 
    1346          734 : bool IsParentObject(EnergyPlusData &state, DataLoopNode::ConnectionObjectType const ComponentType, std::string const &ComponentName)
    1347              : {
    1348              : 
    1349              :     // FUNCTION INFORMATION:
    1350              :     //       AUTHOR         Linda Lawrie
    1351              :     //       DATE WRITTEN   May 2005
    1352              : 
    1353              :     // PURPOSE OF THIS FUNCTION:
    1354              :     // This routine determines if a component name is a parent node.
    1355              : 
    1356              :     // METHODOLOGY EMPLOYED:
    1357              :     // Traverses CompSet structure.
    1358              : 
    1359              :     // Return value
    1360          734 :     bool IsParent = false; // True if this combination is a parent
    1361              : 
    1362        58265 :     for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Loop) {
    1363        60050 :         if (state.dataBranchNodeConnections->NodeConnections(Loop).ObjectType == ComponentType &&
    1364         1870 :             state.dataBranchNodeConnections->NodeConnections(Loop).ObjectName == ComponentName) {
    1365          649 :             if (state.dataBranchNodeConnections->NodeConnections(Loop).ObjectIsParent) {
    1366          312 :                 IsParent = true;
    1367              :             }
    1368          649 :             break;
    1369              :         }
    1370              :     }
    1371          734 :     if (!IsParent) {
    1372          422 :         IsParent = IsParentObjectCompSet(state, ComponentType, ComponentName);
    1373              :     }
    1374              : 
    1375          734 :     return IsParent;
    1376              : }
    1377              : 
    1378          106 : int WhichParentSet(EnergyPlusData &state, DataLoopNode::ConnectionObjectType const ComponentType, std::string const &ComponentName)
    1379              : {
    1380              : 
    1381              :     // FUNCTION INFORMATION:
    1382              :     //       AUTHOR         Linda Lawrie
    1383              :     //       DATE WRITTEN   May 2005
    1384              : 
    1385              :     // PURPOSE OF THIS FUNCTION:
    1386              :     // This routine determines which parent node list (number) for a given component name
    1387              :     // and type.
    1388              : 
    1389              :     // Return value
    1390          106 :     int WhichOne = 0;
    1391              : 
    1392         1163 :     for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumOfActualParents; ++Loop) {
    1393         1242 :         if (state.dataBranchNodeConnections->ParentNodeList(Loop).ComponentType == ComponentType &&
    1394          110 :             state.dataBranchNodeConnections->ParentNodeList(Loop).ComponentName == ComponentName) {
    1395           75 :             WhichOne = Loop;
    1396           75 :             break;
    1397              :         }
    1398              :     }
    1399              : 
    1400          106 :     return WhichOne;
    1401              : }
    1402              : 
    1403          106 : void GetParentData(EnergyPlusData &state,
    1404              :                    DataLoopNode::ConnectionObjectType const ComponentType,
    1405              :                    std::string const &ComponentName,
    1406              :                    std::string &InletNodeName,
    1407              :                    int &InletNodeNum,
    1408              :                    std::string &OutletNodeName,
    1409              :                    int &OutletNodeNum,
    1410              :                    bool &ErrorsFound)
    1411              : {
    1412              : 
    1413              :     // SUBROUTINE INFORMATION:
    1414              :     //       AUTHOR         Linda Lawrie
    1415              :     //       DATE WRITTEN   May 2005
    1416              : 
    1417              :     // PURPOSE OF THIS SUBROUTINE:
    1418              :     // This routine gets node data for a given Parent Component Type and Name Name.
    1419              : 
    1420              :     // METHODOLOGY EMPLOYED:
    1421              :     // Traverses CompSet structure.
    1422              : 
    1423              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1424          106 :     bool ErrInObject = false;
    1425              : 
    1426          106 :     InletNodeName = std::string();
    1427          106 :     InletNodeNum = 0;
    1428          106 :     OutletNodeName = std::string();
    1429          106 :     OutletNodeNum = 0;
    1430          106 :     ErrInObject = false;
    1431              : 
    1432          106 :     int Which = WhichParentSet(state, ComponentType, ComponentName);
    1433          106 :     if (Which != 0) {
    1434           75 :         InletNodeName = state.dataBranchNodeConnections->ParentNodeList(Which).InletNodeName;
    1435           75 :         OutletNodeName = state.dataBranchNodeConnections->ParentNodeList(Which).OutletNodeName;
    1436              :         // Get Node Numbers
    1437           75 :         InletNodeNum =
    1438           75 :             Util::FindItemInList(InletNodeName, state.dataLoopNodes->NodeID({1, state.dataLoopNodes->NumOfNodes}), state.dataLoopNodes->NumOfNodes);
    1439           75 :         OutletNodeNum =
    1440           75 :             Util::FindItemInList(OutletNodeName, state.dataLoopNodes->NodeID({1, state.dataLoopNodes->NumOfNodes}), state.dataLoopNodes->NumOfNodes);
    1441           31 :     } else if (IsParentObjectCompSet(state, ComponentType, ComponentName)) {
    1442           31 :         Which = WhichCompSet(state, ComponentType, ComponentName);
    1443           31 :         if (Which != 0) {
    1444           31 :             InletNodeName = state.dataBranchNodeConnections->CompSets(Which).InletNodeName;
    1445           31 :             OutletNodeName = state.dataBranchNodeConnections->CompSets(Which).OutletNodeName;
    1446           31 :             InletNodeNum = Util::FindItemInList(
    1447           62 :                 InletNodeName, state.dataLoopNodes->NodeID({1, state.dataLoopNodes->NumOfNodes}), state.dataLoopNodes->NumOfNodes);
    1448           31 :             OutletNodeNum = Util::FindItemInList(
    1449           62 :                 OutletNodeName, state.dataLoopNodes->NodeID({1, state.dataLoopNodes->NumOfNodes}), state.dataLoopNodes->NumOfNodes);
    1450              :         } else {
    1451            0 :             ErrInObject = true;
    1452            0 :             ShowWarningError(state,
    1453            0 :                              format("GetParentData: Component Type={}, Component Name={} not found.",
    1454            0 :                                     ConnectionObjectTypeNames[static_cast<int>(ComponentType)],
    1455              :                                     ComponentName));
    1456              :         }
    1457              :     } else {
    1458            0 :         ErrInObject = true;
    1459            0 :         ShowWarningError(state,
    1460            0 :                          format("GetParentData: Component Type={}, Component Name={} not found.",
    1461            0 :                                 ConnectionObjectTypeNames[static_cast<int>(ComponentType)],
    1462              :                                 ComponentName));
    1463              :     }
    1464              : 
    1465          106 :     if (ErrInObject) ErrorsFound = true;
    1466          106 : }
    1467              : 
    1468          453 : bool IsParentObjectCompSet(EnergyPlusData &state, DataLoopNode::ConnectionObjectType const ComponentType, std::string const &ComponentName)
    1469              : {
    1470              : 
    1471              :     // FUNCTION INFORMATION:
    1472              :     //       AUTHOR         Linda Lawrie
    1473              :     //       DATE WRITTEN   May 2005
    1474              : 
    1475              :     // PURPOSE OF THIS FUNCTION:
    1476              :     // This routine determines if a component name is a parent node.
    1477              : 
    1478              :     // METHODOLOGY EMPLOYED:
    1479              :     // Traverses CompSet structure.
    1480              : 
    1481              :     // Return value
    1482          453 :     bool IsParent = false; // True if this combination is a parent
    1483              : 
    1484         8543 :     for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumCompSets; ++Loop) {
    1485         8384 :         if (state.dataBranchNodeConnections->CompSets(Loop).ParentObjectType == ComponentType &&
    1486          151 :             state.dataBranchNodeConnections->CompSets(Loop).ParentCName == ComponentName) {
    1487          143 :             IsParent = true;
    1488          143 :             break;
    1489              :         }
    1490              :     }
    1491              : 
    1492          453 :     return IsParent;
    1493              : }
    1494              : 
    1495           31 : int WhichCompSet(EnergyPlusData &state, DataLoopNode::ConnectionObjectType const ComponentType, std::string const &ComponentName)
    1496              : {
    1497              : 
    1498              :     // FUNCTION INFORMATION:
    1499              :     //       AUTHOR         Linda Lawrie
    1500              :     //       DATE WRITTEN   May 2005
    1501              : 
    1502              :     // PURPOSE OF THIS FUNCTION:
    1503              :     // This routine determines which comp set (number) for a given component name
    1504              :     // and type.
    1505              : 
    1506              :     // METHODOLOGY EMPLOYED:
    1507              :     // Traverses CompSet structure.
    1508              : 
    1509              :     // Return value
    1510           31 :     int WhichOne = 0;
    1511              : 
    1512           46 :     for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumCompSets; ++Loop) {
    1513           77 :         if (state.dataBranchNodeConnections->CompSets(Loop).ComponentObjectType == ComponentType &&
    1514           31 :             state.dataBranchNodeConnections->CompSets(Loop).CName == ComponentName) {
    1515           31 :             WhichOne = Loop;
    1516           31 :             break;
    1517              :         }
    1518              :     }
    1519              : 
    1520           31 :     return WhichOne;
    1521              : }
    1522              : 
    1523          212 : int GetNumChildren(EnergyPlusData &state, DataLoopNode::ConnectionObjectType const ComponentType, std::string const &ComponentName)
    1524              : {
    1525              : 
    1526              :     // FUNCTION INFORMATION:
    1527              :     //       AUTHOR         Linda Lawrie
    1528              :     //       DATE WRITTEN   May 2005
    1529              :     //       MODIFIED       na
    1530              :     //       RE-ENGINEERED  na
    1531              : 
    1532              :     // PURPOSE OF THIS FUNCTION:
    1533              :     // This routine counts the number of children for a parent Component Set.
    1534              : 
    1535              :     // METHODOLOGY EMPLOYED:
    1536              :     // Traverses CompSet structure.
    1537              : 
    1538              :     // Return value
    1539              :     int NumChildren;
    1540              : 
    1541          212 :     NumChildren = 0;
    1542          212 :     if (IsParentObject(state, ComponentType, ComponentName)) {
    1543         3540 :         for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumCompSets; ++Loop) {
    1544         3982 :             if (state.dataBranchNodeConnections->CompSets(Loop).ParentObjectType == ComponentType &&
    1545          654 :                 state.dataBranchNodeConnections->CompSets(Loop).ParentCName == ComponentName) {
    1546          366 :                 ++NumChildren;
    1547              :             }
    1548              :         }
    1549              :     }
    1550              : 
    1551          212 :     return NumChildren;
    1552              : }
    1553              : 
    1554           67 : void GetComponentData(EnergyPlusData &state,
    1555              :                       DataLoopNode::ConnectionObjectType const ComponentType,
    1556              :                       std::string const &ComponentName,
    1557              :                       bool &IsParent, // true or false
    1558              :                       int &NumInlets,
    1559              :                       Array1D_string &InletNodeNames,
    1560              :                       Array1D_int &InletNodeNums,
    1561              :                       Array1D<NodeInputManager::CompFluidStream> &InletFluidStreams,
    1562              :                       int &NumOutlets,
    1563              :                       Array1D_string &OutletNodeNames,
    1564              :                       Array1D_int &OutletNodeNums,
    1565              :                       Array1D<NodeInputManager::CompFluidStream> &OutletFluidStreams)
    1566              : {
    1567              : 
    1568              :     // SUBROUTINE INFORMATION:
    1569              :     //       AUTHOR         Linda Lawrie
    1570              :     //       DATE WRITTEN   May 2005
    1571              : 
    1572              :     // PURPOSE OF THIS SUBROUTINE:
    1573              :     // This routine gets data for a given Component Type and Name Name.
    1574              : 
    1575              :     // METHODOLOGY EMPLOYED:
    1576              :     // Traverses CompSet structure.
    1577              : 
    1578           67 :     if (allocated(InletNodeNames)) InletNodeNames.deallocate();
    1579           67 :     if (allocated(InletNodeNums)) InletNodeNums.deallocate();
    1580           67 :     if (allocated(InletFluidStreams)) InletFluidStreams.deallocate();
    1581           67 :     if (allocated(OutletNodeNames)) OutletNodeNames.deallocate();
    1582           67 :     if (allocated(OutletNodeNums)) OutletNodeNums.deallocate();
    1583           67 :     if (allocated(OutletFluidStreams)) OutletFluidStreams.deallocate();
    1584              : 
    1585           67 :     NumInlets = 0;
    1586           67 :     NumOutlets = 0;
    1587              : 
    1588           67 :     IsParent = false;
    1589         6870 :     for (int Which = 1; Which <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Which) {
    1590         7017 :         if (state.dataBranchNodeConnections->NodeConnections(Which).ObjectType != ComponentType ||
    1591          214 :             state.dataBranchNodeConnections->NodeConnections(Which).ObjectName != ComponentName)
    1592         6711 :             continue;
    1593           92 :         if (state.dataBranchNodeConnections->NodeConnections(Which).ObjectIsParent) IsParent = true;
    1594           92 :         if (state.dataBranchNodeConnections->NodeConnections(Which).ConnectionType == DataLoopNode::ConnectionType::Inlet) {
    1595           25 :             ++NumInlets;
    1596           67 :         } else if (state.dataBranchNodeConnections->NodeConnections(Which).ConnectionType == DataLoopNode::ConnectionType::Outlet) {
    1597           65 :             ++NumOutlets;
    1598              :         }
    1599              :     }
    1600              : 
    1601           67 :     InletNodeNames.allocate(NumInlets);
    1602           67 :     InletNodeNums.allocate(NumInlets);
    1603           67 :     InletFluidStreams.allocate(NumInlets);
    1604           67 :     OutletNodeNames.allocate(NumOutlets);
    1605           67 :     OutletNodeNums.allocate(NumOutlets);
    1606           67 :     OutletFluidStreams.allocate(NumOutlets);
    1607              : 
    1608           67 :     InletNodeNames = std::string();
    1609           67 :     InletNodeNums = 0;
    1610           67 :     InletFluidStreams = NodeInputManager::CompFluidStream::Invalid;
    1611           67 :     OutletNodeNames = std::string();
    1612           67 :     OutletNodeNums = 0;
    1613           67 :     OutletFluidStreams = NodeInputManager::CompFluidStream::Invalid;
    1614           67 :     NumInlets = 0;
    1615           67 :     NumOutlets = 0;
    1616              : 
    1617         6870 :     for (int Which = 1; Which <= state.dataBranchNodeConnections->NumOfNodeConnections; ++Which) {
    1618         7017 :         if (state.dataBranchNodeConnections->NodeConnections(Which).ObjectType != ComponentType ||
    1619          214 :             state.dataBranchNodeConnections->NodeConnections(Which).ObjectName != ComponentName)
    1620         6711 :             continue;
    1621           92 :         if (state.dataBranchNodeConnections->NodeConnections(Which).ConnectionType == DataLoopNode::ConnectionType::Inlet) {
    1622           25 :             ++NumInlets;
    1623           25 :             InletNodeNames(NumInlets) = state.dataBranchNodeConnections->NodeConnections(Which).NodeName;
    1624           25 :             InletNodeNums(NumInlets) = state.dataBranchNodeConnections->NodeConnections(Which).NodeNumber;
    1625           25 :             InletFluidStreams(NumInlets) = state.dataBranchNodeConnections->NodeConnections(Which).FluidStream;
    1626           67 :         } else if (state.dataBranchNodeConnections->NodeConnections(Which).ConnectionType == DataLoopNode::ConnectionType::Outlet) {
    1627           65 :             ++NumOutlets;
    1628           65 :             OutletNodeNames(NumOutlets) = state.dataBranchNodeConnections->NodeConnections(Which).NodeName;
    1629           65 :             OutletNodeNums(NumOutlets) = state.dataBranchNodeConnections->NodeConnections(Which).NodeNumber;
    1630           65 :             OutletFluidStreams(NumOutlets) = state.dataBranchNodeConnections->NodeConnections(Which).FluidStream;
    1631              :         }
    1632              :     }
    1633           67 : }
    1634              : 
    1635          106 : void GetChildrenData(EnergyPlusData &state,
    1636              :                      DataLoopNode::ConnectionObjectType const ComponentType,
    1637              :                      std::string const &ComponentName,
    1638              :                      int &NumChildren,
    1639              :                      EPVector<DataLoopNode::ConnectionObjectType> &ChildrenCType,
    1640              :                      Array1D_string &ChildrenCName,
    1641              :                      Array1D_string &InletNodeName,
    1642              :                      Array1D_int &InletNodeNum,
    1643              :                      Array1D_string &OutletNodeName,
    1644              :                      Array1D_int &OutletNodeNum,
    1645              :                      bool &ErrorsFound)
    1646              : {
    1647              : 
    1648              :     // SUBROUTINE INFORMATION:
    1649              :     //       AUTHOR         Linda Lawrie
    1650              :     //       DATE WRITTEN   May 2005
    1651              : 
    1652              :     // PURPOSE OF THIS SUBROUTINE:
    1653              :     // This routine gets children data for given parent node.
    1654              : 
    1655              :     // METHODOLOGY EMPLOYED:
    1656              :     // Traverses CompSet structure.
    1657              : 
    1658              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1659          106 :     EPVector<DataLoopNode::ConnectionObjectType> ChildCType;
    1660          106 :     Array1D_string ChildCName;
    1661          106 :     Array1D_string ChildInNodeName;
    1662          106 :     Array1D_string ChildOutNodeName;
    1663          106 :     Array1D_int ChildInNodeNum;
    1664          106 :     Array1D_int ChildOutNodeNum;
    1665              :     bool ErrInObject;
    1666              : 
    1667          106 :     std::fill(ChildrenCType.begin(), ChildrenCType.end(), DataLoopNode::ConnectionObjectType::Invalid);
    1668          106 :     ChildrenCName = std::string();
    1669          106 :     InletNodeName = std::string();
    1670          106 :     InletNodeNum = 0;
    1671          106 :     OutletNodeName = std::string();
    1672          106 :     OutletNodeNum = 0;
    1673          106 :     ErrInObject = false;
    1674              : 
    1675          106 :     if (IsParentObject(state, ComponentType, ComponentName)) {
    1676          106 :         NumChildren = GetNumChildren(state, ComponentType, ComponentName);
    1677          106 :         if (NumChildren == 0) {
    1678            0 :             ShowWarningError(state,
    1679            0 :                              format("GetChildrenData: Parent Node has no children, node={}:{}.",
    1680            0 :                                     ConnectionObjectTypeNames[static_cast<int>(ComponentType)],
    1681              :                                     ComponentName));
    1682              :         } else {
    1683              :             int ParentInletNodeNum;
    1684              :             int ParentOutletNodeNum;
    1685          106 :             std::string ParentInletNodeName;
    1686          106 :             std::string ParentOutletNodeName;
    1687          106 :             GetParentData(
    1688              :                 state, ComponentType, ComponentName, ParentInletNodeName, ParentInletNodeNum, ParentOutletNodeName, ParentOutletNodeNum, ErrInObject);
    1689          106 :             ChildCType.clear();
    1690          106 :             ChildCType.allocate(NumChildren);
    1691          106 :             ChildCName.allocate(NumChildren);
    1692          106 :             ChildInNodeName.allocate(NumChildren);
    1693          106 :             ChildOutNodeName.allocate(NumChildren);
    1694          106 :             ChildInNodeNum.allocate(NumChildren);
    1695          106 :             ChildOutNodeNum.allocate(NumChildren);
    1696          106 :             ChildCName = std::string();
    1697          106 :             ChildInNodeName = std::string();
    1698          106 :             ChildOutNodeName = std::string();
    1699          106 :             ChildInNodeNum = 0;
    1700          106 :             ChildOutNodeNum = 0;
    1701          106 :             int CountNum = 0;
    1702         1770 :             for (int Loop = 1; Loop <= state.dataBranchNodeConnections->NumCompSets; ++Loop) {
    1703         1991 :                 if (state.dataBranchNodeConnections->CompSets(Loop).ParentObjectType == ComponentType &&
    1704          327 :                     state.dataBranchNodeConnections->CompSets(Loop).ParentCName == ComponentName) {
    1705          183 :                     ++CountNum;
    1706          183 :                     ChildCType(CountNum) = state.dataBranchNodeConnections->CompSets(Loop).ComponentObjectType;
    1707          183 :                     ChildCName(CountNum) = state.dataBranchNodeConnections->CompSets(Loop).CName;
    1708          183 :                     ChildInNodeName(CountNum) = state.dataBranchNodeConnections->CompSets(Loop).InletNodeName;
    1709          183 :                     ChildOutNodeName(CountNum) = state.dataBranchNodeConnections->CompSets(Loop).OutletNodeName;
    1710              :                     // Get Node Numbers
    1711          183 :                     ChildInNodeNum(CountNum) = Util::FindItemInList(ChildInNodeName(CountNum),
    1712          366 :                                                                     state.dataLoopNodes->NodeID({1, state.dataLoopNodes->NumOfNodes}),
    1713          183 :                                                                     state.dataLoopNodes->NumOfNodes);
    1714          183 :                     ChildOutNodeNum(CountNum) = Util::FindItemInList(ChildOutNodeName(CountNum),
    1715          366 :                                                                      state.dataLoopNodes->NodeID({1, state.dataLoopNodes->NumOfNodes}),
    1716          183 :                                                                      state.dataLoopNodes->NumOfNodes);
    1717              :                 }
    1718              :             }
    1719          106 :             if (CountNum != NumChildren) {
    1720            0 :                 ShowSevereError(state, "GetChildrenData: Counted nodes not equal to GetNumChildren count");
    1721            0 :                 ErrInObject = true;
    1722              :             } else {
    1723              :                 // Children arrays built.  Now "sort" for flow connection order(?)
    1724          106 :                 std::string MatchNodeName = ParentInletNodeName;
    1725          106 :                 CountNum = 0;
    1726          106 :                 int CountMatchLoop = 0;
    1727          289 :                 while (CountMatchLoop < NumChildren) {
    1728          183 :                     ++CountMatchLoop;
    1729              :                     //          Matched=.FALSE.
    1730          501 :                     for (int Loop = 1; Loop <= NumChildren; ++Loop) {
    1731          385 :                         if (ChildInNodeName(Loop) == MatchNodeName) {
    1732           67 :                             ++CountNum;
    1733           67 :                             ChildrenCType(CountNum) = ChildCType(Loop);
    1734           67 :                             ChildrenCName(CountNum) = ChildCName(Loop);
    1735           67 :                             InletNodeName(CountNum) = ChildInNodeName(Loop);
    1736           67 :                             InletNodeNum(CountNum) = ChildInNodeNum(Loop);
    1737           67 :                             OutletNodeName(CountNum) = ChildOutNodeName(Loop);
    1738           67 :                             OutletNodeNum(CountNum) = ChildOutNodeNum(Loop);
    1739           67 :                             ChildInNodeName(Loop).clear(); // So it won't match anymore
    1740              :                             //              Matched=.TRUE.
    1741           67 :                             MatchNodeName = ChildOutNodeName(Loop);
    1742           67 :                             break;
    1743              :                         }
    1744              :                     }
    1745              :                 }
    1746          106 :                 if (MatchNodeName != ParentOutletNodeName) {
    1747           76 :                     for (int Loop = 1; Loop <= NumChildren; ++Loop) {
    1748           76 :                         if (ChildInNodeName(Loop).empty()) continue;
    1749           76 :                         if (ChildOutNodeName(Loop) == ParentOutletNodeName) break;
    1750           16 :                         break;
    1751              :                     }
    1752              :                 }
    1753          289 :                 for (int Loop = 1; Loop <= NumChildren; ++Loop) {
    1754          183 :                     if (ChildInNodeName(Loop).empty()) continue;
    1755          116 :                     ++CountNum;
    1756          116 :                     ChildrenCType(CountNum) = ChildCType(Loop);
    1757          116 :                     ChildrenCName(CountNum) = ChildCName(Loop);
    1758          116 :                     InletNodeName(CountNum) = ChildInNodeName(Loop);
    1759          116 :                     InletNodeNum(CountNum) = ChildInNodeNum(Loop);
    1760          116 :                     OutletNodeName(CountNum) = ChildOutNodeName(Loop);
    1761          116 :                     OutletNodeNum(CountNum) = ChildOutNodeNum(Loop);
    1762              :                 }
    1763          106 :                 ChildCType.deallocate();
    1764          106 :                 ChildCName.deallocate();
    1765          106 :                 ChildInNodeName.deallocate();
    1766          106 :                 ChildOutNodeName.deallocate();
    1767          106 :                 ChildInNodeNum.deallocate();
    1768          106 :                 ChildOutNodeNum.deallocate();
    1769          106 :             }
    1770          106 :         }
    1771              :     } else {
    1772            0 :         ShowWarningError(state,
    1773            0 :                          format("GetChildrenData: Requested Children Data for non Parent Node={}:{}.",
    1774            0 :                                 ConnectionObjectTypeNames[static_cast<int>(ComponentType)],
    1775              :                                 ComponentName));
    1776            0 :         ErrInObject = true;
    1777              :     }
    1778              : 
    1779          106 :     if (ErrInObject) ErrorsFound = true;
    1780          106 : }
    1781              : 
    1782         3015 : void SetUpCompSets(EnergyPlusData &state,
    1783              :                    std::string_view ParentType,       // Parent Object Type
    1784              :                    std::string_view ParentName,       // Parent Object Name
    1785              :                    std::string_view CompType,         // Component Type
    1786              :                    std::string_view CompName,         // Component Name
    1787              :                    std::string_view InletNode,        // Inlet Node Name
    1788              :                    std::string_view OutletNode,       // Outlet Node Name
    1789              :                    std::string_view const Description // Description
    1790              : )
    1791              : {
    1792              : 
    1793              :     // SUBROUTINE INFORMATION:
    1794              :     //       AUTHOR         Linda Lawrie
    1795              :     //       DATE WRITTEN   November 2001
    1796              : 
    1797              :     // PURPOSE OF THIS SUBROUTINE:
    1798              :     // This subroutine sets up "Component Sets" as input in the branch
    1799              :     // lists.  These can be used later to verify that the proper names and
    1800              :     // inlet/outlet nodes have been input.  This routine assumes that identical
    1801              :     // "CompSets" cannot be used in multiple places and issues a warning if they are.
    1802              : 
    1803         3015 :     std::string ParentTypeUC = Util::makeUPPER(ParentType);
    1804         3015 :     std::string CompTypeUC = Util::makeUPPER(CompType);
    1805              :     // TODO: Refactor this away by passing in enums
    1806              :     DataLoopNode::ConnectionObjectType ParentTypeEnum =
    1807         3015 :         static_cast<DataLoopNode::ConnectionObjectType>(getEnumValue(ConnectionObjectTypeNamesUC, ParentTypeUC));
    1808         3015 :     assert(ParentTypeEnum != DataLoopNode::ConnectionObjectType::Invalid);
    1809              : 
    1810              :     DataLoopNode::ConnectionObjectType ComponentTypeEnum =
    1811         3015 :         static_cast<DataLoopNode::ConnectionObjectType>(getEnumValue(ConnectionObjectTypeNamesUC, CompTypeUC));
    1812         3015 :     assert(ComponentTypeEnum != DataLoopNode::ConnectionObjectType::Invalid);
    1813              : 
    1814         3015 :     int Found = 0;
    1815              : 
    1816              :     // See if Component-Nodes set is already there - should be unique
    1817              :     // Try to fill in blanks (passed in as undefined
    1818        17283 :     for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) {
    1819        14956 :         if (CompName != state.dataBranchNodeConnections->CompSets(Count).CName) continue;
    1820         1095 :         if (ComponentTypeEnum != DataLoopNode::ConnectionObjectType::Undefined) {
    1821         1044 :             if (ComponentTypeEnum != state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType) continue;
    1822              :         }
    1823              :         // Component name matches, component type matches or is undefined
    1824         1091 :         if (InletNode != undefined) {
    1825          924 :             if (state.dataBranchNodeConnections->CompSets(Count).InletNodeName != undefined) {
    1826          913 :                 if (InletNode != state.dataBranchNodeConnections->CompSets(Count).InletNodeName) continue;
    1827              :             } else {
    1828           11 :                 state.dataBranchNodeConnections->CompSets(Count).InletNodeName = InletNode;
    1829              :             }
    1830              :         }
    1831          747 :         if (OutletNode != undefined) {
    1832          638 :             if (state.dataBranchNodeConnections->CompSets(Count).OutletNodeName != undefined) {
    1833          627 :                 if (OutletNode != state.dataBranchNodeConnections->CompSets(Count).OutletNodeName) continue;
    1834              :             } else {
    1835           11 :                 state.dataBranchNodeConnections->CompSets(Count).OutletNodeName = OutletNode;
    1836              :             }
    1837              :         }
    1838              :         //  See if something undefined and set here
    1839         1410 :         if (state.dataBranchNodeConnections->CompSets(Count).ParentObjectType == DataLoopNode::ConnectionObjectType::Undefined &&
    1840          688 :             state.dataBranchNodeConnections->CompSets(Count).ParentCName == undefined) {
    1841              :             // Assume this is a further definition for this compset
    1842          688 :             state.dataBranchNodeConnections->CompSets(Count).ParentObjectType = ParentTypeEnum;
    1843          688 :             state.dataBranchNodeConnections->CompSets(Count).ParentCName = ParentName;
    1844          688 :             if (!Description.empty()) {
    1845           18 :                 state.dataBranchNodeConnections->CompSets(Count).Description = Description;
    1846              :             }
    1847          688 :             Found = Count;
    1848          688 :             break;
    1849              :         }
    1850              :     }
    1851         3015 :     if (Found == 0) {
    1852        12994 :         for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) {
    1853        10693 :             Found = 0;
    1854              :             // Test if inlet node has been used before as an inlet node
    1855              :             // If the matching node name does not belong to the parent object, then error
    1856              :             // For example a fan may share the same inlet node as the furnace object which is its parent
    1857        10693 :             if (InletNode != state.dataBranchNodeConnections->CompSets(Count).InletNodeName) {
    1858        10287 :                 continue;
    1859              :                 // If parent type is undefined then no error
    1860          700 :             } else if ((ParentTypeEnum == DataLoopNode::ConnectionObjectType::Undefined) ||
    1861          294 :                        (state.dataBranchNodeConnections->CompSets(Count).ParentObjectType == DataLoopNode::ConnectionObjectType::Undefined)) {
    1862              :                 // If node name is undefined then no error
    1863          224 :             } else if (InletNode != undefined) {
    1864              :                 // If the matching node name does not belong to the parent or child object, then error
    1865              :                 // For example a fan may share the same inlet node as the furnace object which is its parent
    1866            8 :                 if ((ParentTypeEnum == state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType) &&
    1867            3 :                     (ParentName == state.dataBranchNodeConnections->CompSets(Count).CName)) {
    1868              :                     // OK - The duplicate inlet node belongs to this component's parent
    1869            2 :                 } else if ((ComponentTypeEnum == state.dataBranchNodeConnections->CompSets(Count).ParentObjectType) &&
    1870            0 :                            (CompName == state.dataBranchNodeConnections->CompSets(Count).ParentCName)) {
    1871              :                     // OK - The duplicate inlet node belongs to a child of this component
    1872              :                 } else {
    1873              :                     // Due to possibility of grandparents or more, if the matching node name
    1874              :                     // belongs to a component that appears as a parent, then OK
    1875            2 :                     int Found2 = 0;
    1876            8 :                     for (int Count2 = 1; Count2 <= state.dataBranchNodeConnections->NumCompSets; ++Count2) {
    1877            6 :                         if ((state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType ==
    1878            6 :                              state.dataBranchNodeConnections->CompSets(Count2).ParentObjectType) &&
    1879            0 :                             (state.dataBranchNodeConnections->CompSets(Count).CName == state.dataBranchNodeConnections->CompSets(Count2).ParentCName))
    1880            0 :                             Found2 = 1;
    1881            6 :                         if ((ComponentTypeEnum == state.dataBranchNodeConnections->CompSets(Count2).ParentObjectType) &&
    1882            0 :                             (CompName == state.dataBranchNodeConnections->CompSets(Count2).ParentCName))
    1883            0 :                             Found2 = 1;
    1884              :                     }
    1885            2 :                     if (Found2 == 0) {
    1886            2 :                         ShowWarningError(state, format("Node used as an inlet more than once: {}", InletNode));
    1887            4 :                         ShowContinueError(
    1888              :                             state,
    1889            4 :                             format("  Used by: {}, name={}",
    1890            2 :                                    ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ParentObjectType)],
    1891            2 :                                    state.dataBranchNodeConnections->CompSets(Count).ParentCName));
    1892            4 :                         ShowContinueError(
    1893              :                             state,
    1894            4 :                             format("  as inlet for: {}, name={}",
    1895            2 :                                    ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)],
    1896            2 :                                    state.dataBranchNodeConnections->CompSets(Count).CName));
    1897            2 :                         ShowContinueError(state, format("{}{}{}", "  and  by     : ", ParentTypeUC + ", name=", ParentName));
    1898            2 :                         ShowContinueError(state, format("{}{}{}", "  as inlet for: ", CompTypeUC + ", name=", CompName));
    1899              :                     }
    1900              :                 }
    1901              :             }
    1902              :             // Test if outlet node has been used before as an outlet node
    1903              :             // If the matching node name does not belong to the parent or child object, then error
    1904              :             // For example a fan may share the same outlet node as the furnace object which is its parent
    1905          406 :             if (OutletNode != state.dataBranchNodeConnections->CompSets(Count).OutletNodeName) {
    1906          100 :                 continue;
    1907              :                 // If parent type is undefined then no error
    1908          511 :             } else if ((ParentTypeEnum == DataLoopNode::ConnectionObjectType::Undefined) ||
    1909          205 :                        (state.dataBranchNodeConnections->CompSets(Count).ParentObjectType == DataLoopNode::ConnectionObjectType::Undefined)) {
    1910              :                 // If node name is undefined then no error
    1911          137 :             } else if (OutletNode != undefined) {
    1912           33 :                 if ((ParentTypeEnum == state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType) &&
    1913            3 :                     (ParentName == state.dataBranchNodeConnections->CompSets(Count).CName)) {
    1914              :                     // OK - The duplicate outlet node belongs to this component's parent
    1915           27 :                 } else if ((ComponentTypeEnum == state.dataBranchNodeConnections->CompSets(Count).ParentObjectType) &&
    1916            0 :                            (CompName == state.dataBranchNodeConnections->CompSets(Count).ParentCName)) {
    1917              :                     // OK - The duplicate outlet node belongs to a child of this component
    1918              :                 } else {
    1919              :                     // Due to possibility of grandparents or more, if the matching node name
    1920              :                     // belongs to a component that appears as a parent, then OK
    1921           27 :                     int Found2 = 0;
    1922          141 :                     for (int Count2 = 1; Count2 <= state.dataBranchNodeConnections->NumCompSets; ++Count2) {
    1923          114 :                         if ((state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType ==
    1924          114 :                              state.dataBranchNodeConnections->CompSets(Count2).ParentObjectType) &&
    1925            0 :                             (state.dataBranchNodeConnections->CompSets(Count).CName == state.dataBranchNodeConnections->CompSets(Count2).ParentCName))
    1926            0 :                             Found2 = 1;
    1927          114 :                         if ((ComponentTypeEnum == state.dataBranchNodeConnections->CompSets(Count2).ParentObjectType) &&
    1928            0 :                             (CompName == state.dataBranchNodeConnections->CompSets(Count2).ParentCName))
    1929            0 :                             Found2 = 1;
    1930              :                     }
    1931              :                     // This rule is violated by dual duct units, so let it pass
    1932           27 :                     if (Found2 == 0) {
    1933              :                         std::string_view const CType =
    1934           27 :                             ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)];
    1935           27 :                         if ((!has_prefixi(CType, "AirTerminal:DualDuct:")) && (!has_prefixi(CompTypeUC, "AirTerminal:DualDuct:"))) {
    1936           25 :                             ShowWarningError(state, format("Node used as an outlet more than once: {}", OutletNode));
    1937           50 :                             ShowContinueError(
    1938              :                                 state,
    1939           50 :                                 format("  Used by: {}, name={}",
    1940           25 :                                        ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ParentObjectType)],
    1941           25 :                                        state.dataBranchNodeConnections->CompSets(Count).ParentCName));
    1942           50 :                             ShowContinueError(
    1943              :                                 state,
    1944           50 :                                 format(
    1945              :                                     "  as outlet for: {}, name={}",
    1946           25 :                                     ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)],
    1947           25 :                                     state.dataBranchNodeConnections->CompSets(Count).CName));
    1948           25 :                             ShowContinueError(state, format("{}{}{}", "  and  by     : ", ParentTypeUC + ", name=", ParentName));
    1949           25 :                             ShowContinueError(state, format("{}{}{}", "  as outlet for: ", CompTypeUC + ", name=", CompName));
    1950              :                         }
    1951              :                     }
    1952              :                 }
    1953              :             }
    1954          306 :             if (ComponentTypeEnum != state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType &&
    1955              :                 ComponentTypeEnum != DataLoopNode::ConnectionObjectType::Undefined)
    1956          223 :                 continue;
    1957           83 :             if (CompName != state.dataBranchNodeConnections->CompSets(Count).CName) continue;
    1958           26 :             Found = Count;
    1959           26 :             break;
    1960              :         }
    1961              :     }
    1962         3015 :     if (Found == 0) {
    1963         2301 :         state.dataBranchNodeConnections->CompSets.resize(++state.dataBranchNodeConnections->NumCompSets);
    1964         2301 :         state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).ParentObjectType = ParentTypeEnum;
    1965              : 
    1966         2301 :         state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).ParentCName = ParentName;
    1967         2301 :         state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).ComponentObjectType = ComponentTypeEnum;
    1968         2301 :         state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).CName = CompName;
    1969         2301 :         state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).InletNodeName =
    1970              : 
    1971         4602 :             Util::makeUPPER(InletNode); // TODO: Fix this....
    1972         2301 :         state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).OutletNodeName =
    1973         4602 :             Util::makeUPPER(OutletNode); // TODO: Fix this....
    1974              : 
    1975         2301 :         if (!Description.empty()) {
    1976         1313 :             state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).Description = Description;
    1977              :         } else {
    1978          988 :             state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).Description = undefined;
    1979              :         }
    1980              :     }
    1981         3015 : }
    1982              : 
    1983           86 : void TestInletOutletNodes(EnergyPlusData &state)
    1984              : {
    1985              : 
    1986              :     // SUBROUTINE INFORMATION:
    1987              :     //       AUTHOR         Linda Lawrie
    1988              :     //       DATE WRITTEN   November 2001
    1989              : 
    1990              :     // PURPOSE OF THIS SUBROUTINE:
    1991              :     // This subroutine tests the branches to see if a duplicate inlet node
    1992              :     // exists under a different name in the sequence; likewise for outlet.
    1993              : 
    1994           86 :     Array1D_bool AlreadyNoted;
    1995              : 
    1996              :     // Test component sets created by branches
    1997           86 :     AlreadyNoted.dimension(state.dataBranchNodeConnections->NumCompSets, false);
    1998          813 :     for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) {
    1999        10610 :         for (int Other = 1; Other <= state.dataBranchNodeConnections->NumCompSets; ++Other) {
    2000         9883 :             if (Count == Other) continue;
    2001         9156 :             if (state.dataBranchNodeConnections->CompSets(Count).InletNodeName != state.dataBranchNodeConnections->CompSets(Other).InletNodeName)
    2002         9134 :                 continue;
    2003           22 :             if (AlreadyNoted(Count)) continue;
    2004              :             //  All other values must match
    2005            5 :             if (state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType !=
    2006            8 :                     state.dataBranchNodeConnections->CompSets(Other).ComponentObjectType ||
    2007            8 :                 state.dataBranchNodeConnections->CompSets(Count).CName != state.dataBranchNodeConnections->CompSets(Other).CName ||
    2008            0 :                 state.dataBranchNodeConnections->CompSets(Count).OutletNodeName != state.dataBranchNodeConnections->CompSets(Other).OutletNodeName) {
    2009            5 :                 AlreadyNoted(Other) = true;
    2010           10 :                 ShowWarningError(state,
    2011           10 :                                  format("Node used as an inlet more than once: {}", state.dataBranchNodeConnections->CompSets(Count).InletNodeName));
    2012           10 :                 ShowContinueError(
    2013              :                     state,
    2014           10 :                     format("  Used by: {}, name={}",
    2015            5 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ParentObjectType)],
    2016            5 :                            state.dataBranchNodeConnections->CompSets(Count).ParentCName));
    2017           10 :                 ShowContinueError(
    2018              :                     state,
    2019           10 :                     format("  as inlet for: {}, name={}",
    2020            5 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Other).ComponentObjectType)],
    2021            5 :                            state.dataBranchNodeConnections->CompSets(Other).CName));
    2022           10 :                 ShowContinueError(
    2023              :                     state,
    2024           10 :                     format("  and by: {}, name={}",
    2025            5 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Other).ParentObjectType)],
    2026            5 :                            state.dataBranchNodeConnections->CompSets(Other).ParentCName));
    2027           10 :                 ShowContinueError(
    2028              :                     state,
    2029           10 :                     format("  as inlet for: {}, name={}",
    2030            5 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)],
    2031            5 :                            state.dataBranchNodeConnections->CompSets(Count).CName));
    2032              :             }
    2033              :         }
    2034              :     }
    2035              : 
    2036           86 :     AlreadyNoted = false;
    2037          813 :     for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) {
    2038        10610 :         for (int Other = 1; Other <= state.dataBranchNodeConnections->NumCompSets; ++Other) {
    2039         9883 :             if (Count == Other) continue;
    2040         9156 :             if (state.dataBranchNodeConnections->CompSets(Count).OutletNodeName != state.dataBranchNodeConnections->CompSets(Other).OutletNodeName)
    2041         9146 :                 continue;
    2042           10 :             if (AlreadyNoted(Count)) continue;
    2043              :             //  All other values must match
    2044            5 :             if (state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType !=
    2045            5 :                     state.dataBranchNodeConnections->CompSets(Other).ComponentObjectType ||
    2046            5 :                 state.dataBranchNodeConnections->CompSets(Count).CName != state.dataBranchNodeConnections->CompSets(Other).CName ||
    2047            0 :                 state.dataBranchNodeConnections->CompSets(Count).InletNodeName != state.dataBranchNodeConnections->CompSets(Other).InletNodeName) {
    2048            5 :                 AlreadyNoted(Other) = true;
    2049           10 :                 ShowWarningError(
    2050           10 :                     state, format("Node used as an outlet more than once: {}", state.dataBranchNodeConnections->CompSets(Count).OutletNodeName));
    2051           10 :                 ShowContinueError(
    2052              :                     state,
    2053           10 :                     format("  Used by: {}, name={}",
    2054            5 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ParentObjectType)],
    2055            5 :                            state.dataBranchNodeConnections->CompSets(Count).ParentCName));
    2056           10 :                 ShowContinueError(
    2057              :                     state,
    2058           10 :                     format("  as outlet for: {}, name={}",
    2059            5 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Other).ComponentObjectType)],
    2060            5 :                            state.dataBranchNodeConnections->CompSets(Other).CName));
    2061           10 :                 ShowContinueError(
    2062              :                     state,
    2063           10 :                     format("  and by: {}, name={}",
    2064            5 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Other).ParentObjectType)],
    2065            5 :                            state.dataBranchNodeConnections->CompSets(Other).ParentCName));
    2066           10 :                 ShowContinueError(
    2067              :                     state,
    2068           10 :                     format("  as outlet for: {}, name={}",
    2069            5 :                            ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)],
    2070            5 :                            state.dataBranchNodeConnections->CompSets(Count).CName));
    2071              :             }
    2072              :         }
    2073              :     }
    2074              : 
    2075           86 :     AlreadyNoted.deallocate();
    2076           86 : }
    2077              : 
    2078         2178 : void TestCompSet(EnergyPlusData &state,
    2079              :                  std::string_view const CompType, // Component Type
    2080              :                  std::string_view CompName,       // Component Name
    2081              :                  std::string const &InletNode,    // Inlet Node Name
    2082              :                  std::string const &OutletNode,   // Outlet Node Name
    2083              :                  std::string const &Description   // Description of Node Pair (for warning message)
    2084              : )
    2085              : {
    2086              : 
    2087              :     // SUBROUTINE INFORMATION:
    2088              :     //       AUTHOR         Linda K. Lawrie
    2089              :     //       DATE WRITTEN   November 2001
    2090              : 
    2091              :     // PURPOSE OF THIS SUBROUTINE:
    2092              :     // Register a child component in the CompSets data structure.
    2093              :     // NOTE:  This function was originally designed to test the stored "Component Sets" to
    2094              :     // see if there was one of this combination in there.  Thus the name "TestCompSet".
    2095              :     // However, this was based on a false assumption that input would always be gotten
    2096              :     // first for the parent object, then for the child object.  But this is often not the
    2097              :     // case.  Ultimately, the name of this function should be changed or it should be merged
    2098              :     // into SetUpCompSets.
    2099              :     // Until then, this function does the following:
    2100              :     //   a)  Search CompSets for this combination of component type, component name,
    2101              :     //       inlet node and outlet node.  If component type/name match and the existing
    2102              :     //       node names are UNDEFINED, this compset is assumed to be a match.
    2103              :     //   b)  If found, fill in any missing data such as node names or node description
    2104              :     //   c)  If not found, call SetUpCompSets (with parent type and name UNDEFINED)
    2105              :     //       to add a new item in the CompSets array
    2106              : 
    2107         2178 :     std::string CompTypeUC = Util::makeUPPER(CompType);
    2108              : 
    2109              :     // TODO: Refactor this away by passing in enums
    2110              :     DataLoopNode::ConnectionObjectType ComponentTypeEnum =
    2111         2178 :         static_cast<DataLoopNode::ConnectionObjectType>(getEnumValue(ConnectionObjectTypeNamesUC, CompTypeUC));
    2112         2178 :     assert(ComponentTypeEnum != DataLoopNode::ConnectionObjectType::Invalid);
    2113              : 
    2114              :     // See if Already there
    2115         2178 :     int Found = 0;
    2116        12422 :     for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) {
    2117        19491 :         if ((ComponentTypeEnum != state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType) &&
    2118         8367 :             (state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType != DataLoopNode::ConnectionObjectType::Undefined))
    2119         8367 :             continue;
    2120         2757 :         if (CompName != state.dataBranchNodeConnections->CompSets(Count).CName) continue;
    2121         1693 :         if ((InletNode != state.dataBranchNodeConnections->CompSets(Count).InletNodeName) &&
    2122         1693 :             (state.dataBranchNodeConnections->CompSets(Count).InletNodeName != undefined) && (InletNode != undefined))
    2123          264 :             continue;
    2124         1022 :         if ((OutletNode != state.dataBranchNodeConnections->CompSets(Count).OutletNodeName) &&
    2125         1022 :             (state.dataBranchNodeConnections->CompSets(Count).OutletNodeName != undefined) && (OutletNode != undefined))
    2126            0 :             continue;
    2127              : 
    2128          880 :         Found = Count;
    2129          880 :         break;
    2130              :     }
    2131              : 
    2132         2178 :     if (Found == 0) {
    2133         1298 :         SetUpCompSets(state, undefined, undefined, CompType, CompName, InletNode, OutletNode, Description);
    2134              :     } else {
    2135              :         // Fill in node names and component type for previously undefined values:
    2136              :         //   If the parent object did not specify a component type or inlet or outlet node, then that value
    2137              :         //   is UNDEFINED in CompSets.  When a component calls TestCompSet, the comp type and inlet and
    2138              :         //   outlet nodes are known, so they can be filled in for future reference.
    2139          880 :         if (state.dataBranchNodeConnections->CompSets(Found).ComponentObjectType == DataLoopNode::ConnectionObjectType::Undefined) {
    2140            0 :             state.dataBranchNodeConnections->CompSets(Found).ComponentObjectType = ComponentTypeEnum;
    2141              :         }
    2142          880 :         if (state.dataBranchNodeConnections->CompSets(Found).InletNodeName == undefined)
    2143          241 :             state.dataBranchNodeConnections->CompSets(Found).InletNodeName = InletNode;
    2144          880 :         if (state.dataBranchNodeConnections->CompSets(Found).OutletNodeName == undefined)
    2145           98 :             state.dataBranchNodeConnections->CompSets(Found).OutletNodeName = OutletNode;
    2146          880 :         if (state.dataBranchNodeConnections->CompSets(Found).Description == undefined)
    2147          863 :             state.dataBranchNodeConnections->CompSets(Found).Description = Description;
    2148              :     }
    2149         2178 : }
    2150              : 
    2151           73 : void TestCompSetInletOutletNodes(EnergyPlusData &state, bool &ErrorsFound)
    2152              : {
    2153              : 
    2154              :     // SUBROUTINE INFORMATION:
    2155              :     //       AUTHOR         Linda Lawrie
    2156              :     //       DATE WRITTEN   March 2008
    2157              :     //       MODIFIED       na
    2158              :     //       RE-ENGINEERED  na
    2159              : 
    2160              :     // PURPOSE OF THIS SUBROUTINE:
    2161              :     // This subroutine tests the comp sets to see if a duplicate comp name
    2162              :     // exists under a different set of inlet/outlet nodes.
    2163              : 
    2164              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2165           73 :     Array1D_bool AlreadyNoted;
    2166              : 
    2167              :     // Test component sets created by branches
    2168           73 :     AlreadyNoted.dimension(state.dataBranchNodeConnections->NumCompSets, false);
    2169          420 :     for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) {
    2170         7924 :         for (int Other = 1; Other <= state.dataBranchNodeConnections->NumCompSets; ++Other) {
    2171         7577 :             if (Count == Other) continue;
    2172         7230 :             if (state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType ==
    2173              :                 DataLoopNode::ConnectionObjectType ::SolarCollectorUnglazedTranspired)
    2174            0 :                 continue;
    2175         7230 :             if (state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType !=
    2176         8274 :                     state.dataBranchNodeConnections->CompSets(Other).ComponentObjectType ||
    2177         1044 :                 state.dataBranchNodeConnections->CompSets(Count).CName != state.dataBranchNodeConnections->CompSets(Other).CName)
    2178         7180 :                 continue;
    2179           50 :             if (state.dataBranchNodeConnections->CompSets(Count).Description != state.dataBranchNodeConnections->CompSets(Other).Description) {
    2180          100 :                 if (state.dataBranchNodeConnections->CompSets(Count).Description != undefined &&
    2181           50 :                     state.dataBranchNodeConnections->CompSets(Other).Description != undefined)
    2182           50 :                     continue;
    2183              :             }
    2184            0 :             if (state.dataBranchNodeConnections->CompSets(Count).InletNodeName == state.dataBranchNodeConnections->CompSets(Other).InletNodeName)
    2185            0 :                 continue;
    2186            0 :             if (state.dataBranchNodeConnections->CompSets(Count).OutletNodeName == state.dataBranchNodeConnections->CompSets(Other).OutletNodeName)
    2187            0 :                 continue;
    2188            0 :             if (AlreadyNoted(Count)) continue;
    2189              :             //  All other values must match
    2190            0 :             AlreadyNoted(Other) = true;
    2191            0 :             ShowSevereError(state, "Same component name and type has differing Node Names.");
    2192            0 :             ShowContinueError(
    2193              :                 state,
    2194            0 :                 format("  Component: {}, name={}",
    2195            0 :                        ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)],
    2196            0 :                        state.dataBranchNodeConnections->CompSets(Count).CName));
    2197            0 :             ShowContinueError(state,
    2198            0 :                               format("   Nodes, inlet: {}, outlet: {}",
    2199            0 :                                      state.dataBranchNodeConnections->CompSets(Count).InletNodeName,
    2200            0 :                                      state.dataBranchNodeConnections->CompSets(Count).OutletNodeName));
    2201            0 :             ShowContinueError(state,
    2202            0 :                               format(" & Nodes, inlet: {}, outlet: {}",
    2203            0 :                                      state.dataBranchNodeConnections->CompSets(Other).InletNodeName,
    2204            0 :                                      state.dataBranchNodeConnections->CompSets(Other).OutletNodeName));
    2205            0 :             ShowContinueError(state,
    2206            0 :                               format("   Node Types:   {} & {}",
    2207            0 :                                      state.dataBranchNodeConnections->CompSets(Count).Description,
    2208            0 :                                      state.dataBranchNodeConnections->CompSets(Other).Description));
    2209            0 :             ErrorsFound = true;
    2210              :         }
    2211              :     }
    2212              : 
    2213           73 :     AlreadyNoted.deallocate();
    2214           73 : }
    2215              : 
    2216           53 : void GetNodeConnectionType(EnergyPlusData &state, int const NodeNumber, EPVector<DataLoopNode::ConnectionType> &NodeConnectType, bool &errFlag)
    2217              : {
    2218              : 
    2219              :     // FUNCTION INFORMATION:
    2220              :     //       AUTHOR         Lixing Gu
    2221              :     //       DATE WRITTEN   Jan 2007
    2222              : 
    2223              :     // PURPOSE OF THIS FUNCTION:
    2224              :     // This function provides a connection type with given node number
    2225              : 
    2226           53 :     Array1D_int ListArray;
    2227           53 :     Array1D_string ConnectionTypes(15);
    2228              : 
    2229          848 :     for (int nodetype = 1; nodetype < static_cast<int>(ConnectionType::Num); ++nodetype) {
    2230          795 :         ConnectionTypes(nodetype) = ConnectionTypeNames[nodetype];
    2231              :     }
    2232              : 
    2233           53 :     if (allocated(NodeConnectType)) NodeConnectType.deallocate();
    2234              : 
    2235              :     int NumInList;
    2236          106 :     FindAllNodeNumbersInList(
    2237           53 :         NodeNumber, state.dataBranchNodeConnections->NodeConnections, state.dataBranchNodeConnections->NumOfNodeConnections, NumInList, ListArray);
    2238              : 
    2239           53 :     NodeConnectType.allocate(NumInList);
    2240              : 
    2241           53 :     if (NumInList > 0) {
    2242           80 :         for (int NodeConnectIndex = 1; NodeConnectIndex <= NumInList; ++NodeConnectIndex) {
    2243           41 :             NodeConnectType(NodeConnectIndex) = state.dataBranchNodeConnections->NodeConnections(ListArray(NodeConnectIndex)).ConnectionType;
    2244              :         }
    2245              :     } else {
    2246           14 :         if (NodeNumber > 0) {
    2247           14 :             ShowWarningError(state, format("Node not found = {}.", state.dataLoopNodes->NodeID(NodeNumber)));
    2248              :         } else {
    2249            0 :             ShowWarningError(state, "Invalid node number passed = 0.");
    2250              :         }
    2251           14 :         errFlag = true;
    2252              :     }
    2253           53 : }
    2254              : 
    2255           53 : void FindAllNodeNumbersInList(int const WhichNumber,
    2256              :                               EPVector<DataBranchNodeConnections::NodeConnectionDef> const &NodeConnections,
    2257              :                               int const NumItems,
    2258              :                               int &CountOfItems,            // Number of items found
    2259              :                               Array1D_int &AllNumbersInList // Index array to all numbers found
    2260              : )
    2261              : {
    2262              : 
    2263              :     // FUNCTION INFORMATION:
    2264              :     //       AUTHOR         R. Raustad
    2265              :     //       DATE WRITTEN   January 2007
    2266              : 
    2267              :     // PURPOSE OF THIS FUNCTION:
    2268              :     // This function looks up a number(integer) in a similar list of
    2269              :     // items and returns the index of the item in the list, if
    2270              :     // found.
    2271              : 
    2272           53 :     CountOfItems = 0;
    2273              : 
    2274           53 :     if (allocated(AllNumbersInList)) AllNumbersInList.deallocate();
    2275              : 
    2276          332 :     for (int Count = 1; Count <= NumItems; ++Count) {
    2277          279 :         if (WhichNumber == NodeConnections(Count).NodeNumber) {
    2278           41 :             ++CountOfItems;
    2279              :         }
    2280              :     }
    2281              : 
    2282           53 :     if (CountOfItems > 0) {
    2283              : 
    2284           39 :         AllNumbersInList.dimension(CountOfItems, 0);
    2285           39 :         CountOfItems = 0;
    2286              : 
    2287          276 :         for (int Count = 1; Count <= NumItems; ++Count) {
    2288          237 :             if (WhichNumber == NodeConnections(Count).NodeNumber) {
    2289           41 :                 ++CountOfItems;
    2290           41 :                 AllNumbersInList(CountOfItems) = Count;
    2291              :             }
    2292              :         }
    2293              :     }
    2294           53 : }
    2295              : 
    2296              : } // namespace EnergyPlus::BranchNodeConnections
        

Generated by: LCOV version 2.0-1