Skip to content

Commit 95705b8

Browse files
author
Amir Roth
committed
Handle node configurations with cycles
1 parent 090f6e7 commit 95705b8

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/EnergyPlus/BranchNodeConnections.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,16 +1732,24 @@ void GetChildrenData(EnergyPlusData &state,
17321732
} else {
17331733
// Children arrays built. Now "sort" for flow connection order(?)
17341734
// FindIntInList is 0-based and FindItemInList is 1-based .. great!
1735-
int ParentInletNodeIndex = Util::FindIntInList(ChildInNodeNum, ParentInletNodeNum) + 1;
1736-
int ParentOutletNodeIndex = Util::FindIntInList(ChildOutNodeNum, ParentOutletNodeNum) + 1;
1735+
int ParentInletNodeIndex = 0;
1736+
for (int Loop = 1; Loop <= NumChildren; ++Loop)
1737+
if (ChildInNodeNum(Loop) == ParentInletNodeNum) { ParentInletNodeIndex = Loop; break; }
1738+
1739+
int ParentOutletNodeIndex = 0;
1740+
for (int Loop = 1; Loop <= NumChildren; ++Loop)
1741+
if (ChildOutNodeNum(Loop) == ParentOutletNodeNum) { ParentOutletNodeIndex = Loop; break; }
17371742

17381743
// Parent inlet node matches one of the inlet-nodes of the sub-components
17391744
if (ParentInletNodeIndex > 0) {
17401745
int MatchInNodeNum = ParentInletNodeNum;
17411746
CountNum = 0;
17421747

17431748
while (CountNum < NumChildren) {
1744-
int MatchInNodeIndex = Util::FindIntInList(ChildInNodeNum, MatchInNodeNum) + 1;
1749+
int MatchInNodeIndex = 0;
1750+
for (int Loop = 1; Loop <= NumChildren; ++Loop)
1751+
if (ChildInNodeNum(Loop) == MatchInNodeNum && !ChildMatched(Loop)) { MatchInNodeIndex = Loop; break; }
1752+
17451753
if (MatchInNodeIndex == 0) // The chain is broken
17461754
break;
17471755

@@ -1773,7 +1781,10 @@ void GetChildrenData(EnergyPlusData &state,
17731781
CountNum = NumChildren + 1;
17741782

17751783
while (CountNum > 1) {
1776-
int MatchOutNodeIndex = Util::FindIntInList(ChildOutNodeNum, MatchOutNodeNum) + 1;
1784+
int MatchOutNodeIndex = 0;
1785+
for (int Loop = 1; Loop <= NumChildren; ++Loop)
1786+
if (ChildOutNodeNum(Loop) == MatchOutNodeNum && !ChildMatched(Loop)) { MatchOutNodeIndex = Loop; break; }
1787+
17771788
if (MatchOutNodeIndex == 0) // The chain is broken
17781789
break;
17791790

0 commit comments

Comments
 (0)