diff --git a/spec/structure/structure.spec.ts b/spec/structure/structure.spec.ts index 53e0a6741aa47e9d21e231284d2e087e76e879bf..81391e6c4994a67b3e06da42cb53b0cdfccdb0d4 100644 --- a/spec/structure/structure.spec.ts +++ b/spec/structure/structure.spec.ts @@ -6,42 +6,9 @@ */ // import { describe, expect, it, xdescribe } from "../mock_jasmine"; -import { Structure, StructureFlowMode, StructureFlowRegime, StructureParams } from "../../src/structure/structure"; -import { Result } from "../../src/util/result"; +import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure"; import { checkResult } from "../test_func"; - -class StructureTest extends Structure { - - constructor(prms: StructureParams, dbg: boolean = false) { - super(prms, dbg); - } - - /** - * Test of getFlowMode - */ - public testGetFlowMode() { - this.prms.update_h1h2(); - return this.getFlowMode(); - } - - /** - * Test of getFlowRegime - */ - public testGetFlowRegime() { - this.prms.update_h1h2(); - return this.getFlowRegime(); - } - - public Equation(sVarCalc: string): Result { - this.prms.update_h1h2(); - this.CheckEquation(sVarCalc); - return new Result(this.prms.Z1.v - this.prms.Z2.v); - } - -} - -const structTestPrm: StructureParams = new StructureParams(1, 0, 30, 15); -const structTest: StructureTest = new StructureTest(structTestPrm, false); +import { structTest } from "./structure_test"; describe("Class Structure: ", () => { diff --git a/spec/structure/structure_test.ts b/spec/structure/structure_test.ts new file mode 100644 index 0000000000000000000000000000000000000000..20c03c7663255b53f70228fc0ce10965027d3cae --- /dev/null +++ b/spec/structure/structure_test.ts @@ -0,0 +1,35 @@ +import { Structure, StructureParams } from "../../src/structure/structure"; +import { Result } from "../../src/util/result"; + +class StructureTest extends Structure { + + constructor(prms: StructureParams, dbg: boolean = false) { + super(prms, dbg); + } + + /** + * Test of getFlowMode + */ + public testGetFlowMode() { + this.prms.update_h1h2(); + return this.getFlowMode(); + } + + /** + * Test of getFlowRegime + */ + public testGetFlowRegime() { + this.prms.update_h1h2(); + return this.getFlowRegime(); + } + + public Equation(sVarCalc: string): Result { + this.prms.update_h1h2(); + Structure.CheckEquation(sVarCalc); + return new Result(this.prms.Z1.v - this.prms.Z2.v); + } + +} + +export const structTestPrm: StructureParams = new StructureParams(1, 0, 30, 15); +export const structTest: StructureTest = new StructureTest(structTestPrm, false); diff --git a/src/structure/rectangular_structure_params.ts b/src/structure/rectangular_structure_params.ts index 4d5d267e1a5f90482132903ea625e6d31aadd612..485d540bdfa2b17d1d4363d1edcac93da1be0ff4 100644 --- a/src/structure/rectangular_structure_params.ts +++ b/src/structure/rectangular_structure_params.ts @@ -10,6 +10,7 @@ export class RectangularStructureParams extends StructureParams { public L: ParamDefinition; /** Discharge coefficient */ + // tslint:disable-next-line:variable-name public Cd: ParamDefinition; /** diff --git a/src/structure/structure.ts b/src/structure/structure.ts index 612c197fb6ebb9ec7c39ec285675904da9135d3e..ca8abac0fe2b525da10664807698c6d4ce630407 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -38,6 +38,13 @@ export enum StructureFlowRegime { */ export abstract class Structure extends Nub { + /** + * Test générique si VarCalc="Q" pour l'utilisation de Equation + */ + public static CheckEquation(sVarCalc: string) { + if (sVarCalc !== "Q") { throw new Error("Structure.Equation() : invalid parameter name " + sVarCalc); } + } + /** Constante utile : Racine de 2g */ protected static readonly R2G: number = Math.sqrt(2 * 9.81); @@ -52,11 +59,6 @@ export abstract class Structure extends Nub { return this._prms as StructureParams; } - /** - * Calcul du mode et du régime d'écoulement - */ - public abstract Equation(sVarCalc: string): Result; - /** * Calcul d'une équation quelque soit l'inconnue à calculer. * Gestion du débit nul et de l'inversion de débit @@ -164,11 +166,4 @@ export abstract class Structure extends Nub { return StructureFlowRegime.SUBMERGED; } } - - /** - * Test générique si VarCalc="Q" pour l'utilisation de Equation - */ - protected CheckEquation(sVarCalc: string) { - if (sVarCalc !== "Q") { throw new Error("Structure.Equation() : invalid parameter name " + sVarCalc); } - } } diff --git a/src/structure/structure_cem88d.ts b/src/structure/structure_cem88d.ts index 345e6825f5ca9008efc551a3324ce23c14839b37..99c675de829c5c94b934cda2a0bc92d775c66738 100644 --- a/src/structure/structure_cem88d.ts +++ b/src/structure/structure_cem88d.ts @@ -15,7 +15,7 @@ export class StructureCem88d extends RectangularStructure { * @param sVarCalc Variable à calculer (doit être "Q") */ public Equation(sVarCalc: string): Result { - super.CheckEquation(sVarCalc); + Structure.CheckEquation(sVarCalc); const data = super.defaultResultData(); let v: number; diff --git a/src/structure/structure_cem88v.ts b/src/structure/structure_cem88v.ts index cef783f7cb1adb6d65f57ca65d1bfce705b20c05..b636fc0e55dd51ded8f86bf7309ce63c8bd21d05 100644 --- a/src/structure/structure_cem88v.ts +++ b/src/structure/structure_cem88v.ts @@ -15,7 +15,7 @@ export class StructureCem88v extends RectangularStructure { * @param sVarCalc Variable à calculer (doit être "Q") */ public Equation(sVarCalc: string): Result { - super.CheckEquation(sVarCalc); + Structure.CheckEquation(sVarCalc); const data = super.defaultResultData(); let v: number; diff --git a/src/structure/structure_cunge80.ts b/src/structure/structure_cunge80.ts index bc8b05c40545d4128eb3351d70b42bc434eae8f0..38435d5546636ebdebaac7249e4cda28d4d3ed0d 100644 --- a/src/structure/structure_cunge80.ts +++ b/src/structure/structure_cunge80.ts @@ -14,7 +14,7 @@ export class StructureCunge80 extends RectangularStructure { * @param sVarCalc Variable à calculer (doit être égale à Q ici) */ public Equation(sVarCalc: string): Result { - super.CheckEquation(sVarCalc); + Structure.CheckEquation(sVarCalc); const data = super.defaultResultData(); let v: number; diff --git a/src/structure/structure_orifice_free.ts b/src/structure/structure_orifice_free.ts index 39272136e8abf5a59581bb2e84ed0a02bcb4a0a3..1f4b266fc2a665fd1a18a7e6b8b7c25b6946f002 100644 --- a/src/structure/structure_orifice_free.ts +++ b/src/structure/structure_orifice_free.ts @@ -14,7 +14,7 @@ export class StructureOrificeFree extends RectangularStructure { * @param sVarCalc Variable à calculer (doit être égale à Q ici) */ public Equation(sVarCalc: string): Result { - super.CheckEquation(sVarCalc); + Structure.CheckEquation(sVarCalc); const data = super.defaultResultData(); // TODO : Warning si les conditions hydrauliques ne correspondent pas à un écoulement dénoyé diff --git a/src/structure/structure_orifice_submerged.ts b/src/structure/structure_orifice_submerged.ts index c8a670153bdffe166825e33770b2427b1eecd966..c4f42b50dc793947217a0873660bb901d0fa629e 100644 --- a/src/structure/structure_orifice_submerged.ts +++ b/src/structure/structure_orifice_submerged.ts @@ -14,7 +14,7 @@ export class StructureOrificeSubmerged extends RectangularStructure { * @param sVarCalc Variable à calculer (doit être égale à Q ici) */ public Equation(sVarCalc: string): Result { - super.CheckEquation(sVarCalc); + Structure.CheckEquation(sVarCalc); const data = super.defaultResultData(); // TODO : Warning si les conditions hydrauliques ne correspondent pas à un écoulement dénoyé diff --git a/src/structure/structure_params.ts b/src/structure/structure_params.ts index 5929b5bc684b4804d56edf25b92a05ed895728bf..468fd6a43cb48b9e032dcdb416ea052a0723e533 100644 --- a/src/structure/structure_params.ts +++ b/src/structure/structure_params.ts @@ -38,13 +38,13 @@ export class StructureParams extends ParamsEquation { */ constructor(rQ: number, rZDV: number, rZ1: number, rZ2: number, rW: number = Infinity ) { super(); - this.Q = new ParamDefinition(ComputeNodeType.CondDistri, "Q", ParamDomainValue.POS_NULL, rQ); + this.Q = new ParamDefinition(ComputeNodeType.CondDistri, "Q", ParamDomainValue.ANY, rQ); this.addParamDefinition(this.Q); - this.ZDV = new ParamDefinition(ComputeNodeType.CondDistri, "ZDV", ParamDomainValue.POS_NULL, rZDV); + this.ZDV = new ParamDefinition(ComputeNodeType.CondDistri, "ZDV", ParamDomainValue.ANY, rZDV); this.addParamDefinition(this.ZDV); - this.Z1 = new ParamDefinition(ComputeNodeType.CondDistri, "Z1", ParamDomainValue.POS_NULL, rZ1); + this.Z1 = new ParamDefinition(ComputeNodeType.CondDistri, "Z1", ParamDomainValue.ANY, rZ1); this.addParamDefinition(this.Z1); - this.Z2 = new ParamDefinition(ComputeNodeType.CondDistri, "Z2", ParamDomainValue.POS_NULL, rZ2); + this.Z2 = new ParamDefinition(ComputeNodeType.CondDistri, "Z2", ParamDomainValue.ANY, rZ2); this.addParamDefinition(this.Z2); this.h1 = new ParamDefinition(ComputeNodeType.CondDistri, "h1", ParamDomainValue.POS_NULL, Math.max(0, this.Z1.v - this.ZDV.v)); diff --git a/src/structure/structure_weir_free.ts b/src/structure/structure_weir_free.ts index 4f862723bb97b245245a9775db7402e63d8e88de..57ff2f154d8911268d1125ac6854c6565a413278 100644 --- a/src/structure/structure_weir_free.ts +++ b/src/structure/structure_weir_free.ts @@ -14,7 +14,7 @@ export class StructureWeirFree extends RectangularStructure { * @param sVarCalc Variable à calculer (doit être "Q") */ public Equation(sVarCalc: string): Result { - super.CheckEquation(sVarCalc); + Structure.CheckEquation(sVarCalc); const data = super.defaultResultData(); // TODO : Warning si les conditions hydrauliques ne correspondent pas à un seuil dénoyé