Beispiel #1
0
int flowrout_execute(int links[], int routingModel, float tStep)
//
//  Input:   links = array of link indexes in topo-sorted order
//           routingModel = type of routing method used
//           tStep = routing time step (sec)
//  Output:  returns number of computational steps taken
//  Purpose: routes flow through conveyance network over current time step.
//
{
    int   i, j;
    int   n1;                          // upstream node of link
    float qin;                         // link inflow (cfs)
    float qout;                        // link outflow (cfs)
    float steps;                       // computational step count

    // --- set updated state of all nodes to False
    if ( ErrorCode ) return 0;
    for (j = 0; j < Nobjects[NODE]; j++) Node[j].updated = FALSE;

    // --- execute dynamic wave routing if called for
    if ( routingModel == DW )
    {
        steps = dynwave_execute(links, tStep);
        return steps;
    }

    // --- otherwise examine each link, moving from upstream to downstream
    steps = 0.0;
    for (i = 0; i < Nobjects[LINK]; i++)
    {
        // --- see if upstream node is a storage unit whose state needs updating
        j = links[i];
        n1 = Link[j].node1;
        if ( Node[n1].type == STORAGE ) updateStorageState(n1, i, links, tStep);

        // --- retrieve inflow at upstream end of link
        qin  = getLinkInflow(j, tStep);

        // route flow through link
        if ( routingModel == SF ) steps += steadyflow_execute(j, &qin, &qout);
        else steps += kinwave_execute(j, &qin, &qout, tStep);
        Link[j].newFlow = qout;

        // adjust outflow at upstream node and inflow at downstream node
        Node[ Link[j].node1 ].outflow += qin;
        Node[ Link[j].node2 ].inflow += qout;
    }
    if ( Nobjects[LINK] > 0 ) steps /= Nobjects[LINK];

    // --- update state of each non-updated node and link
    for ( j=0; j<Nobjects[NODE]; j++) setNewNodeState(j, tStep);
    for ( j=0; j<Nobjects[LINK]; j++) setNewLinkState(j);
    return (int)(steps+0.5);
}
Beispiel #2
0
int flowrout_execute(Project* project, int links[], int routingModel, double tStep)
//
//  Input:   links = array of link indexes in topo-sorted order
//           routingModel = type of routing method used
//           tStep = routing time step (sec)
//  Output:  returns number of computational steps taken
//  Purpose: routes flow through conveyance network over current time step.
//
{
    int   i, j;
    int   n1;                          // upstream node of link
    double qin;                        // link inflow (cfs)
    double qout;                       // link outflow (cfs)
    double steps;                      // computational step count

    // --- set overflows to drain any ponded water
    if ( project->ErrorCode ) return 0;
    for (j = 0; j < project->Nobjects[NODE]; j++)
    {
        project->Node[j].updated = FALSE;
        project->Node[j].overflow = 0.0;
        if ( project->Node[j].type != STORAGE
        &&   project->Node[j].newVolume > project->Node[j].fullVolume )
        {
            project->Node[j].overflow = (project->Node[j].newVolume - project->Node[j].fullVolume)/tStep;
        }
    }

    // --- execute dynamic wave routing if called for
    if ( routingModel == DW )
    {
        return dynwave_execute(project,tStep);
    }

    // --- otherwise examine each link, moving from upstream to downstream
    steps = 0.0;
    for (i = 0; i < project->Nobjects[LINK]; i++)
    {
        // --- see if upstream node is a storage unit whose state needs updating
        j = links[i];
        n1 = project->Link[j].node1;
        if ( project->Node[n1].type == STORAGE ) updateStorageState(project, n1, i, links, tStep);

        // --- retrieve inflow at upstream end of link
		qin = getLinkInflow(project, j, tStep);

        // route flow through link
        if ( routingModel == SF )
			steps += steadyflow_execute(project, j, &qin, &qout, tStep);
        else steps += kinwave_execute(project,j, &qin, &qout, tStep);
        project->Link[j].newFlow = qout;

        // adjust outflow at upstream node and inflow at downstream node
        project->Node[ project->Link[j].node1 ].outflow += qin;
        project->Node[ project->Link[j].node2 ].inflow += qout;
    }
    if ( project->Nobjects[LINK] > 0 ) steps /= project->Nobjects[LINK];

    // --- update state of each non-updated node and link
	for (j = 0; j<project->Nobjects[NODE]; j++) setNewNodeState(project, j, tStep);
	for (j = 0; j<project->Nobjects[LINK]; j++) setNewLinkState(project, j);
    return (int)(steps+0.5);
}