Skip to content

Commit

Permalink
Update EN_setcurvetype to support EN_VALVE_CURVE
Browse files Browse the repository at this point in the history
  • Loading branch information
lbutler committed Sep 15, 2023
1 parent 39ffaeb commit 05c0528
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/epanet.c
Original file line number Diff line number Diff line change
Expand Up @@ -4907,7 +4907,7 @@ int DLLEXPORT EN_setcurvetype(EN_Project p, int index, int type)
Network *net = &p->network;
if (!p->Openflag) return 102;
if (index < 1 || index > net->Ncurves) return 206;
if (type < 0 || type > EN_GENERIC_CURVE) return 251;
if (type < 0 || type > EN_VALVE_CURVE) return 251;
net->Curve[index].Type = type;
return 0;
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_valve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ BOOST_FIXTURE_TEST_CASE(test_PCV_valve, FixtureOpenClose)
double x[] = { 0.0, 25., 50., 75., 100. };
double y[] = {0.0, 8.9, 18.4, 40.6, 100.0};
double v;
int linkIndex, curveIndex;
int linkIndex, curveIndex, curveType;

// Make steady state run
error = EN_settimeparam(ph, EN_DURATION, 0);
Expand All @@ -50,6 +50,11 @@ BOOST_FIXTURE_TEST_CASE(test_PCV_valve, FixtureOpenClose)
BOOST_REQUIRE(error == 0);
error = EN_setcurve(ph, curveIndex, x, y, npts);
BOOST_REQUIRE(error == 0);
error = EN_setcurvetype(ph, curveIndex, EN_VALVE_CURVE);
BOOST_REQUIRE(error == 0);
error = EN_getcurvetype(ph, curveIndex, &curveType);
BOOST_REQUIRE(error == 0);
BOOST_REQUIRE(curveType == EN_VALVE_CURVE);

// Assign curve & initial setting to PCV
error = EN_setlinkvalue(ph, linkIndex, EN_PCV_CURVE, curveIndex);
Expand Down

0 comments on commit 05c0528

Please sign in to comment.