From 7e30dcb80d007d045bbd1bed8d731ab4fe7b8897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Fri, 14 Apr 2023 16:57:29 +0200 Subject: [PATCH] refactor: CloisonAval: do not check submergence error for vanne levante structures refs #302 --- src/pab/cloison_aval.ts | 2 + src/structure/parallel_structure.ts | 12 ++++++ src/structure/structure.ts | 40 +++++++++++++++----- src/structure/structure_vanlev_larinier.ts | 4 ++ src/structure/structure_vanlev_villemonte.ts | 4 ++ 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/pab/cloison_aval.ts b/src/pab/cloison_aval.ts index 39c48c4a..ab93fa43 100644 --- a/src/pab/cloison_aval.ts +++ b/src/pab/cloison_aval.ts @@ -74,7 +74,9 @@ export class CloisonAval extends ParallelStructure { } if (!this.hasVanneLevante() || this.result.ok) { // Calculation of Z1 with the new ZDV in case of existing vanne levante + this._doVanLevSubmergenceCheck = false; this.currentResultElement = super.Calc("Z1", rInit); + this._doVanLevSubmergenceCheck = true; if (this.result.ok) { this.getParameter(sVarCalc).v = this.result.vCalc; // Recalcul du débit total pour récupérer les résultats des ouvrages dans les résultats complémentaires diff --git a/src/structure/parallel_structure.ts b/src/structure/parallel_structure.ts index 682beb1c..addfaac7 100644 --- a/src/structure/parallel_structure.ts +++ b/src/structure/parallel_structure.ts @@ -16,9 +16,17 @@ import { MessageCode, Message } from "../internal_modules"; */ export class ParallelStructure extends Nub { + /** + * false pour inihiber le test d'erreur d'ennoiement dans les vannes levantes + * @see checkSubmergence + * @see checkSubmergenceMin + */ + protected _doVanLevSubmergenceCheck: boolean; + constructor(prms: ParamsEquation, dbg: boolean = false) { super(prms, dbg); this.setCalculatorType(CalculatorType.ParallelStructure); + this._doVanLevSubmergenceCheck = true; } /** children casting */ @@ -40,6 +48,10 @@ export class ParallelStructure extends Nub { return this._prms as ParallelStructureParams; } + public get doVanLevSubmergenceCheck(): boolean { + return this._doVanLevSubmergenceCheck; + } + /** Returns admissible LoiDebit grouped by StructureType */ public getLoisAdmissibles(): { [key: string]: LoiDebit[]; } { return loiAdmissiblesOuvrages; diff --git a/src/structure/structure.ts b/src/structure/structure.ts index 5ac03cb2..e90938f0 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -81,16 +81,22 @@ export abstract class Structure extends ChildNub { * méthode générique de vérification que l'ennoiement est supérieur à une valeur donnée * @param min valeur minimum de l'ennoiement */ - protected checkSubmergenceMin(min: number) { - const h2h1ratio = this.prms.h2.v / this.prms.h1.v; - if (h2h1ratio < min) { - this._result.resultElement.addMessage(new Message( - MessageCode.ERROR_STRUCTURE_SUBMERGENCE_LOWER_THAN, - { - submergencePerc: this.computeSubmergencePercentage().toString(), - min: min * 100 - } - )); + protected checkSubmergenceMin(res: Result, min: number) { + // on fait le test soit : + // - si cette structure n'est pas une vanne levante + // - si cette structure est une vanne levante et le flag d'autorisation du test est vrai + if (!this.isVanneLevante || this.doVanLevSubmergenceCheck) { + const h2h1ratio = this.prms.h2.v / this.prms.h1.v; + if (h2h1ratio < min) { + res.resultElement.addMessage(new Message( + // this._result.globalLog.add(new Message( + MessageCode.ERROR_STRUCTURE_SUBMERGENCE_LOWER_THAN, + { + submergencePerc: this.computeSubmergencePercentage().toString(), + min: min * 100 + } + )); + } } } @@ -119,6 +125,20 @@ export abstract class Structure extends ChildNub { this._intlType = "Ouvrage"; } + public get doVanLevSubmergenceCheck(): boolean { + const ps = this.parent as ParallelStructure; + return ps.doVanLevSubmergenceCheck; + } + + /** + * true si la structure est une vanne levante + * @see StructureVanLevLarinier + * @see StructureVanLevVillemonte + */ + protected get isVanneLevante(): boolean { + return false; + } + public get isZDVcalculable(): boolean { return this._isZDVcalculable; } diff --git a/src/structure/structure_vanlev_larinier.ts b/src/structure/structure_vanlev_larinier.ts index 002838b5..0f010354 100644 --- a/src/structure/structure_vanlev_larinier.ts +++ b/src/structure/structure_vanlev_larinier.ts @@ -15,4 +15,8 @@ export class StructureVanLevLarinier extends StructureWeirSubmergedLarinier { get prms(): StructureVanLevParams { return this._prms as StructureVanLevParams; } + + protected get isVanneLevante(): boolean { + return true; + } } diff --git a/src/structure/structure_vanlev_villemonte.ts b/src/structure/structure_vanlev_villemonte.ts index da61603d..9c01ef9f 100644 --- a/src/structure/structure_vanlev_villemonte.ts +++ b/src/structure/structure_vanlev_villemonte.ts @@ -15,4 +15,8 @@ export class StructureVanLevVillemonte extends StructureWeirVillemonte { get prms(): StructureVanLevParams { return this._prms as StructureVanLevParams; } + + protected get isVanneLevante(): boolean { + return true; + } } -- GitLab