Network validity checks added to openhyd()

Checks on illegal valve connections made whenever API creates a new link, changes its end nodes, or changes its type.
This commit is contained in:
Lew Rossman
2018-12-20 08:36:05 -05:00
parent a66f5a2c92
commit 3ce0361c1d
6 changed files with 118 additions and 77 deletions

View File

@@ -58,12 +58,26 @@ int openhyd(Project *pr)
int errcode = 0;
Slink *link;
// Check for too few nodes & no fixed grade nodes
if (pr->network.Nnodes < 2) errcode = 223;
else if (pr->network.Ntanks == 0) errcode = 224;
// Allocate memory for sparse matrix structures (see SMATRIX.C)
ERRCODE(createsparse(pr));
// Allocate memory for hydraulic variables
ERRCODE(allocmatrix(pr));
// Check for unconnected nodes
if (!errcode) for (i = 1; i <= pr->network.Njuncs; i++)
{
if (pr->network.Adjlist[i] == NULL)
{
errcode = 233;
break;
}
}
// Initialize link flows
if (!errcode) for (i = 1; i <= pr->network.Nlinks; i++)
{