Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jalhyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cassiopée
jalhyd
Commits
5ea96a6e
Commit
5ea96a6e
authored
4 years ago
by
mathias.chouet
Browse files
Options
Downloads
Patches
Plain Diff
Fix
nghyd#451
- merge PreBarrage duplicate walls at calculate time
parent
ee83e0f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/pre_barrage/pre-barrage.spec.ts
+69
-0
69 additions, 0 deletions
spec/pre_barrage/pre-barrage.spec.ts
src/prebarrage/pre_barrage.ts
+78
-0
78 additions, 0 deletions
src/prebarrage/pre_barrage.ts
with
147 additions
and
0 deletions
spec/pre_barrage/pre-barrage.spec.ts
+
69
−
0
View file @
5ea96a6e
...
...
@@ -582,6 +582,75 @@ describe("Class PreBarrage:", () => {
});
describe
(
"
merge duplicate walls −
"
,
()
=>
{
it
(
"
no duplicate walls
"
,
()
=>
{
const
sess
=
`{"header":{"source":"jalhyd","format_version":"1.3","created":"2020-06-29T13:15:21.029Z"},"settings":{"precision":1e-7,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"b2kxNm","props":{"calcType":"PreBarrage"},"meta":{"title":"Prébarrages"},"children":[{"uid":"Zjczdz","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":13.8},{"symbol":"ZF","mode":"SINGLE","value":95}]},{"uid":"dWJrZX","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":15.4},{"symbol":"ZF","mode":"SINGLE","value":94.7}]},{"uid":"dzMxN2","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":16.2},{"symbol":"ZF","mode":"SINGLE","value":94.7}]},{"uid":"ZXZua2","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":17.5},{"symbol":"ZF","mode":"SINGLE","value":94.4}]},{"uid":"YmR5aD","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":32.1},{"symbol":"ZF","mode":"SINGLE","value":94.25}]},{"uid":"bDN2OW","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":35},{"symbol":"ZF","mode":"SINGLE","value":94.1}]},{"uid":"MWxycH","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"Zjczdz"},"children":[{"uid":"MmZ2aG","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.3},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"eW9jZH","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":4.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"c3Zpb2","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"dWJrZX"},"children":[{"uid":"bTQ2cG","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96},{"symbol":"L","mode":"SINGLE","value":1},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"N24zM2","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":5},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"MG4wNG","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"YmR5aD"},"children":[{"uid":"azV4dj","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":3.5},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"YjJra2","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"bDN2OW"},"children":[{"uid":"aDd4Y3","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":3.6},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"enE4cn","props":{"calcType":"PbCloison","upstreamBasin":"Zjczdz","downstreamBasin":"dzMxN2"},"children":[{"uid":"ZHczZ2","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"aXRjZ3","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":5.2},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"NXNoNG","props":{"calcType":"PbCloison","upstreamBasin":"dWJrZX","downstreamBasin":"dzMxN2"},"children":[{"uid":"eXFqeH","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.85},{"symbol":"L","mode":"SINGLE","value":4.38},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"bGhodG","props":{"calcType":"PbCloison","upstreamBasin":"dWJrZX","downstreamBasin":"ZXZua2"},"children":[{"uid":"b3Z3OD","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.85},{"symbol":"L","mode":"SINGLE","value":3},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"MDZ3aH","props":{"calcType":"PbCloison","upstreamBasin":"dWJrZX","downstreamBasin":"YmR5aD"},"children":[{"uid":"NTBzZm","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.5},{"symbol":"L","mode":"SINGLE","value":1},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"b3pjZX","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.75},{"symbol":"L","mode":"SINGLE","value":3},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"emZ2bX","props":{"calcType":"PbCloison","upstreamBasin":"dzMxN2","downstreamBasin":"ZXZua2"},"children":[{"uid":"cGllNj","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.7},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"aWFseW","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.65},{"symbol":"L","mode":"SINGLE","value":5.74},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"bG1ucj","props":{"calcType":"PbCloison","upstreamBasin":"ZXZua2","downstreamBasin":"YmR5aD"},"children":[{"uid":"MDJsaD","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.4},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"ZzY2bT","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.35},{"symbol":"L","mode":"SINGLE","value":6},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"dGNnZz","props":{"calcType":"PbCloison","upstreamBasin":"YmR5aD","downstreamBasin":"bDN2OW"},"children":[{"uid":"dnNqeX","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.25},{"symbol":"L","mode":"SINGLE","value":0.7},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"ODFkZ2","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.05},{"symbol":"L","mode":"SINGLE","value":9.5},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"amprcm","props":{"calcType":"PbCloison","upstreamBasin":"bDN2OW","downstreamBasin":""},"children":[{"uid":"OG02MT","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.1},{"symbol":"L","mode":"SINGLE","value":0.95},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"MHVxZn","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.75},{"symbol":"L","mode":"SINGLE","value":10.2},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":0.844},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"SINGLE","value":94.45}]}]}`
;
Session
.
getInstance
().
clear
();
Session
.
getInstance
().
unserialise
(
sess
);
const
pb
=
Session
.
getInstance
().
findNubByUid
(
"
b2kxNm
"
)
as
PreBarrage
;
const
nbBassins1
=
pb
.
bassins
.
length
;
const
nbCloisons1
=
pb
.
children
.
length
-
nbBassins1
;
pb
.
CalcSerie
();
const
nbBassins2
=
pb
.
bassins
.
length
;
const
nbCloisons2
=
pb
.
children
.
length
-
nbBassins2
;
expect
(
nbBassins2
).
toEqual
(
nbBassins1
);
expect
(
nbCloisons2
).
toEqual
(
nbCloisons1
);
});
it
(
"
complex case
"
,
()
=>
{
const
sess
=
`{"header":{"source":"jalhyd","format_version":"1.3","created":"2020-09-29T07:51:16.492Z"},"settings":{"precision":1e-7,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"b2kxNm","props":{"calcType":"PreBarrage"},"meta":{"title":"Prébarrages"},"children":[{"uid":"Zjczdz","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":13.8},{"symbol":"ZF","mode":"SINGLE","value":95}]},{"uid":"dWJrZX","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":15.4},{"symbol":"ZF","mode":"SINGLE","value":94.7}]},{"uid":"dzMxN2","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":16.2},{"symbol":"ZF","mode":"SINGLE","value":94.7}]},{"uid":"ZXZua2","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":17.5},{"symbol":"ZF","mode":"SINGLE","value":94.4}]},{"uid":"YmR5aD","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":32.1},{"symbol":"ZF","mode":"SINGLE","value":94.25}]},{"uid":"bDN2OW","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":35},{"symbol":"ZF","mode":"SINGLE","value":94.1}]},{"uid":"MWxycH","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"Zjczdz"},"children":[{"uid":"MmZ2aG","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.3},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"eW9jZH","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":4.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"c3Zpb2","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"dWJrZX"},"children":[{"uid":"bTQ2cG","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96},{"symbol":"L","mode":"SINGLE","value":1},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"N24zM2","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":5},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"MG4wNG","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"YmR5aD"},"children":[{"uid":"azV4dj","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":3.5},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"YjJra2","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"bDN2OW"},"children":[{"uid":"aDd4Y3","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":3.6},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"enE4cn","props":{"calcType":"PbCloison","upstreamBasin":"Zjczdz","downstreamBasin":"dzMxN2"},"children":[{"uid":"ZHczZ2","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"aXRjZ3","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":96.25},{"symbol":"L","mode":"SINGLE","value":5.2},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"NXNoNG","props":{"calcType":"PbCloison","upstreamBasin":"dWJrZX","downstreamBasin":"dzMxN2"},"children":[{"uid":"eXFqeH","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.85},{"symbol":"L","mode":"SINGLE","value":4.38},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"bGhodG","props":{"calcType":"PbCloison","upstreamBasin":"dWJrZX","downstreamBasin":"ZXZua2"},"children":[{"uid":"b3Z3OD","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.85},{"symbol":"L","mode":"SINGLE","value":3},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"MDZ3aH","props":{"calcType":"PbCloison","upstreamBasin":"dWJrZX","downstreamBasin":"YmR5aD"},"children":[{"uid":"NTBzZm","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.5},{"symbol":"L","mode":"SINGLE","value":1},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"b3pjZX","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.75},{"symbol":"L","mode":"SINGLE","value":3},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"emZ2bX","props":{"calcType":"PbCloison","upstreamBasin":"dzMxN2","downstreamBasin":"ZXZua2"},"children":[{"uid":"cGllNj","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.7},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"aWFseW","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.65},{"symbol":"L","mode":"SINGLE","value":5.74},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"bG1ucj","props":{"calcType":"PbCloison","upstreamBasin":"ZXZua2","downstreamBasin":"YmR5aD"},"children":[{"uid":"MDJsaD","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.4},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"ZzY2bT","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.35},{"symbol":"L","mode":"SINGLE","value":6},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"dGNnZz","props":{"calcType":"PbCloison","upstreamBasin":"YmR5aD","downstreamBasin":"bDN2OW"},"children":[{"uid":"dnNqeX","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.25},{"symbol":"L","mode":"SINGLE","value":0.7},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"ODFkZ2","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.05},{"symbol":"L","mode":"SINGLE","value":9.5},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"amprcm","props":{"calcType":"PbCloison","upstreamBasin":"bDN2OW","downstreamBasin":""},"children":[{"uid":"OG02MT","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.1},{"symbol":"L","mode":"SINGLE","value":0.95},{"symbol":"CdCunge","mode":"SINGLE","value":1}]},{"uid":"MHVxZn","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":94.75},{"symbol":"L","mode":"SINGLE","value":10.2},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"MWhyOG","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"dWJrZX"},"children":[{"uid":"c2E3MH","props":{"calcType":"Structure","loiDebit":"GateCunge80","structureType":"VanneRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":101},{"symbol":"W","mode":"SINGLE","value":0.5},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"ZzIzen","props":{"calcType":"PbCloison","upstreamBasin":"dzMxN2","downstreamBasin":"ZXZua2"},"children":[{"uid":"Y2FtaH","props":{"calcType":"Structure","loiDebit":"WeirSubmergedLarinier","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":101},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]}],"parameters":[]},{"uid":"ODEwN2","props":{"calcType":"PbCloison","upstreamBasin":"bDN2OW","downstreamBasin":""},"children":[{"uid":"dGNuaX","props":{"calcType":"Structure","loiDebit":"WeirSubmergedLarinier","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":101},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]},{"uid":"NWxsbj","props":{"calcType":"Structure","loiDebit":"TriangularTruncWeirFree","structureType":"SeuilTriangulaireTrunc"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":101},{"symbol":"BT","mode":"SINGLE","value":0.9},{"symbol":"ZT","mode":"SINGLE","value":101},{"symbol":"CdT","mode":"SINGLE","value":1.36}]}],"parameters":[]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":0.844},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"SINGLE","value":94.45}]}]}`
;
Session
.
getInstance
().
clear
();
Session
.
getInstance
().
unserialise
(
sess
);
const
pb
=
Session
.
getInstance
().
findNubByUid
(
"
b2kxNm
"
)
as
PreBarrage
;
const
nbBassins1
=
pb
.
bassins
.
length
;
const
nbCloisons1
=
pb
.
children
.
length
-
nbBassins1
;
const
b2
=
pb
.
bassins
[
1
];
const
b3
=
pb
.
bassins
[
2
];
const
b6
=
pb
.
bassins
[
5
];
expect
(
b2
.
cloisonsAmont
.
length
).
toBe
(
2
);
expect
(
b3
.
cloisonsAval
.
length
).
toBe
(
2
);
expect
(
b6
.
cloisonsAval
.
length
).
toBe
(
2
);
pb
.
CalcSerie
();
const
nbBassins2
=
pb
.
bassins
.
length
;
const
nbCloisons2
=
pb
.
children
.
length
-
nbBassins2
;
expect
(
nbBassins2
).
toEqual
(
nbBassins1
);
// 3 walls are supposed to be removed (merged)
expect
(
nbCloisons2
).
toEqual
(
nbCloisons1
-
3
);
expect
(
b2
.
cloisonsAmont
.
length
).
toBe
(
1
);
expect
(
b2
.
cloisonsAmont
[
0
].
structures
.
length
).
toBe
(
3
);
expect
(
b3
.
cloisonsAval
.
length
).
toBe
(
1
);
expect
(
b3
.
cloisonsAval
[
0
].
structures
.
length
).
toBe
(
3
);
expect
(
b6
.
cloisonsAval
.
length
).
toBe
(
1
);
expect
(
b6
.
cloisonsAval
[
0
].
structures
.
length
).
toBe
(
4
);
});
it
(
"
duplicate walls
"
,
()
=>
{
const
sess
=
`{"header":{"source":"jalhyd","format_version":"1.3","created":"2020-09-29T08:24:40.715Z"},"settings":{"precision":1e-7,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"cHM5am","props":{"calcType":"PreBarrage"},"meta":{"title":"Prébarrages"},"children":[{"uid":"bGZuOT","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":""},"children":[{"uid":"ZXhrZ3","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.3},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"dHIwem","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":""},"children":[{"uid":"NnpjeT","props":{"calcType":"Structure","loiDebit":"TriangularWeirBroad","structureType":"SeuilTriangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.3},{"symbol":"alpha2","mode":"SINGLE","value":45},{"symbol":"CdT","mode":"SINGLE","value":1.36}]},{"uid":"dTdsMD","props":{"calcType":"Structure","loiDebit":"OrificeSubmerged","structureType":"Orifice"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":0.1},{"symbol":"CdO","mode":"SINGLE","value":0.7}]}],"parameters":[]},{"uid":"d3BoZG","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":""},"children":[{"uid":"dTA3Mm","props":{"calcType":"Structure","loiDebit":"OrificeFree","structureType":"Orifice"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":0.1},{"symbol":"CdO","mode":"SINGLE","value":0.7},{"symbol":"Zco","mode":"SINGLE","value":101}]}],"parameters":[]},{"uid":"OWVvNn","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":20},{"symbol":"ZF","mode":"SINGLE","value":99}]},{"uid":"MHpwNH","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"OWVvNn"},"children":[{"uid":"bW50ZT","props":{"calcType":"Structure","loiDebit":"WeirSubmergedLarinier","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":101},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]}],"parameters":[]},{"uid":"dXNzcW","props":{"calcType":"PbCloison","upstreamBasin":"OWVvNn","downstreamBasin":""},"children":[{"uid":"bW53ZG","props":{"calcType":"Structure","loiDebit":"WeirSubmergedLarinier","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":101},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]}],"parameters":[]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":1},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"SINGLE","value":100}]}]}`
;
Session
.
getInstance
().
clear
();
Session
.
getInstance
().
unserialise
(
sess
);
const
pb
=
Session
.
getInstance
().
findNubByUid
(
"
cHM5am
"
)
as
PreBarrage
;
const
nbBassins1
=
pb
.
bassins
.
length
;
const
nbCloisons1
=
pb
.
children
.
length
-
nbBassins1
;
expect
(
nbBassins1
).
toBe
(
1
);
expect
(
nbCloisons1
).
toBe
(
5
);
pb
.
CalcSerie
();
const
nbBassins2
=
pb
.
bassins
.
length
;
const
nbCloisons2
=
pb
.
children
.
length
-
nbBassins2
;
expect
(
nbBassins2
).
toEqual
(
nbBassins1
);
// 3 walls are merged into 1
expect
(
nbCloisons2
).
toEqual
(
nbCloisons1
-
2
);
let
c1
:
PbCloison
;
for
(
const
c
of
pb
.
children
)
{
if
(
c
instanceof
PbCloison
&&
c
.
bassinAval
===
undefined
&&
c
.
bassinAmont
===
undefined
)
{
c1
=
c
;
}
}
expect
(
c1
).
toBeDefined
();
expect
(
c1
.
structures
.
length
).
toBe
(
4
);
});
});
describe
(
"
error cases −
"
,
()
=>
{
it
(
"
downstream water elevation > upstream water elevation
"
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/prebarrage/pre_barrage.ts
+
78
−
0
View file @
5ea96a6e
...
...
@@ -228,12 +228,90 @@ export class PreBarrage extends Nub {
this
.
updatePointers
();
}
/**
* Detect duplicate walls between same basins pair, and merges
* them into one wall containing all the previous walls' structures.
*/
private
detectAndMergeDuplicateWalls
()
{
// browse all upstream basins
for
(
const
b
of
this
.
_bassins
)
{
// for each upstream basin, group walls by downstream basin
this
.
mergeDuplicateWalls
(
b
);
}
// walls between upstream and another basin
for
(
const
b
of
this
.
cloisonsAmont
.
map
((
ca
)
=>
ca
.
bassinAval
))
{
if
(
b
!==
undefined
)
{
this
.
mergeDuplicateWalls
(
b
,
false
);
}
}
// walls between river upstream and downstream
const
udWalls
:
PbCloison
[]
=
[];
for
(
const
w
of
this
.
_children
)
{
if
(
w
instanceof
PbCloison
)
{
if
(
w
.
bassinAmont
===
undefined
&&
w
.
bassinAval
===
undefined
)
{
udWalls
.
push
(
w
);
}
}
}
this
.
mergeStructuresInFirstWall
(
udWalls
);
}
/**
* Finds all walls connected to the given basin's upstream (is upstream is true) or
* downstream. Among those walls, finds those who have the same basin at their
* opposite connection and merges them into one wall.
* @param b
* @param upstream
*/
private
mergeDuplicateWalls
(
b
:
PbBassin
,
upstream
:
boolean
=
true
)
{
// group walls attached to b by the other basin they are attached to
const
wallsByOtherBasin
:
{
[
key
:
string
]:
PbCloison
[]
}
=
{};
const
linkedWalls
=
upstream
?
b
.
cloisonsAval
:
b
.
cloisonsAmont
;
for
(
const
w
of
linkedWalls
)
{
let
dbId
=
"
-
"
;
// river upstream / downstream
const
otherBasin
=
upstream
?
w
.
bassinAval
:
w
.
bassinAmont
;
if
(
otherBasin
!==
undefined
)
{
dbId
=
otherBasin
.
uid
;
}
if
(
!
Object
.
keys
(
wallsByOtherBasin
).
includes
(
dbId
))
{
wallsByOtherBasin
[
dbId
]
=
[];
}
wallsByOtherBasin
[
dbId
].
push
(
w
);
}
// if multiple walls attached to b share the same other basin, merge them
for
(
const
dbUid
of
Object
.
keys
(
wallsByOtherBasin
))
{
const
dbWalls
=
wallsByOtherBasin
[
dbUid
];
this
.
mergeStructuresInFirstWall
(
dbWalls
);
}
}
/**
* Given a list of walls, moves all structures belonging to
* structures #2+ into structure #1, and removes structures
* #2+ from the current PreBarrage
* @param walls
*/
private
mergeStructuresInFirstWall
(
walls
:
PbCloison
[])
{
if
(
walls
.
length
>
1
)
{
// move all structures of walls > 1 to 1st wall
for
(
let
i
=
1
;
i
<
walls
.
length
;
i
++
)
{
const
dbw
=
walls
[
i
];
for
(
const
s
of
dbw
.
structures
)
{
walls
[
0
].
addChild
(
s
);
}
// delete "merged" wall
this
.
deleteChild
(
dbw
.
findPositionInParent
());
}
}
}
/**
* Effectue une série de calculs sur un paramètre; déclenche le calcul en chaîne
* des modules en amont si nécessaire
* @param rInit solution approximative du paramètre
*/
public
CalcSerie
(
rInit
?:
number
):
Result
{
this
.
detectAndMergeDuplicateWalls
();
this
.
_precision
=
Math
.
max
(
5
E
-
4
,
SessionSettings
.
precision
);
return
super
.
CalcSerie
(
rInit
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment