From b0d0a4209d4c5906d8cce97e13b444c1d1433990 Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@irstea.fr>
Date: Wed, 15 Apr 2020 16:33:52 +0200
Subject: [PATCH] Fix #206 Speed extra result should be calculated in Calc
 instead of Equation

---
 .../regime_uniforme/regime_uniforme_rect.spec.ts     |  2 +-
 src/open-channel/regime_uniforme.ts                  | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/spec/open-channel/regime_uniforme/regime_uniforme_rect.spec.ts b/spec/open-channel/regime_uniforme/regime_uniforme_rect.spec.ts
index 3c9397d6..4204d341 100644
--- a/spec/open-channel/regime_uniforme/regime_uniforme_rect.spec.ts
+++ b/spec/open-channel/regime_uniforme/regime_uniforme_rect.spec.ts
@@ -26,7 +26,7 @@ function generateRegimeUniforme(sect: acSection): RegimeUniforme {
 let ruRect1 = generateRegimeUniforme(generateRectangularSection());
 
 describe("Class RegimeUniforme / section rectangulaire :", () => {
-    fdescribe("pas de débordement : ", () => {
+    describe("pas de débordement : ", () => {
         beforeEach(() => {
             ruRect1 = generateRegimeUniforme(generateRectangularSection());
             SessionSettings.precision = 1E-7;
diff --git a/src/open-channel/regime_uniforme.ts b/src/open-channel/regime_uniforme.ts
index 3a6d330b..857622bc 100644
--- a/src/open-channel/regime_uniforme.ts
+++ b/src/open-channel/regime_uniforme.ts
@@ -43,10 +43,6 @@ export class RegimeUniforme extends SectionNub {
                 throw new Error("RegimeUniforme.Equation() : invalid variable name " + sVarCalc);
         }
 
-        // Vitesse moyenne
-        const V = this.section.CalcSection("V", this.section.prms.Y.v);
-        r.resultElement.values.V = V.vCalc;
-
         return r;
     }
 
@@ -58,6 +54,11 @@ export class RegimeUniforme extends SectionNub {
      */
     public Calc(sVarCalc?: string, rInit?: number): Result {
         const r = super.Calc(sVarCalc, rInit);
+
+        // Vitesse moyenne
+        const V = this.section.CalcSection("V", this.section.prms.Y.v);
+        r.resultElement.values.V = V.vCalc;
+
         // Est-ce que ça déborde ?
         if (this.section.prms.Y.v > this.section.prms.YB.v) {
             r.resultElement.log.add(new Message(MessageCode.WARNING_SECTION_OVERFLOW));
@@ -73,11 +74,12 @@ export class RegimeUniforme extends SectionNub {
     }
 
     // tslint:disable-next-line:no-empty
-    protected setParametersCalculability() {}
+    protected setParametersCalculability() { }
 
     protected adjustChildParameters(): void {
         this.section.prms.Q.calculability = ParamCalculability.EQUATION;
         this.section.prms.Y.calculability = ParamCalculability.EQUATION;
+        this.section.prms.YB.calculability = ParamCalculability.FREE;
     }
 
     protected exposeResults() {
-- 
GitLab