Commit 5871e774 authored by Dorchies David's avatar Dorchies David
Browse files

#33 Delete all reference to PabCloisons

Showing with 9 additions and 172 deletions
+9 -172
......@@ -8,7 +8,6 @@
import { Cloisons, CloisonsParams } from "../../src/pab/cloisons";
import { Pab, PabParams } from "../../src/pab/pab";
import { PabCloisons } from "../../src/pab/pab_cloisons";
import { ParallelStructure, ParallelStructureParams } from "../../src/structure/parallel_structure";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureKivi, StructureKiviParams } from "../../src/structure/structure_kivi";
......
......@@ -22,8 +22,7 @@ export enum CalculatorType {
PabChute,
PabNombre,
Section,
Pab, // Passe à bassins;
PabCloisons // modèle de cloisons + débit d'attrait, pour Passe à bassins
Pab // Passe à bassins;
}
/**
......
......@@ -37,4 +37,3 @@ export * from "./jalhyd_object";
export * from "./date_revision";
export * from "./section/section_nub";
export * from "./pab/pab";
export * from "./pab/pab_cloisons";
......@@ -872,7 +872,7 @@ export abstract class Nub extends ComputeNode implements IObservable {
}
}
// define calculated param at Nub level
// @TODO except if we are a Section / Structure / PabCloisons ?
// @TODO except if we are a Section / Structure / Cloisons ?
if (ret.p) {
this.calculatedParam = ret.p;
}
......
......@@ -40,7 +40,7 @@ export class Pab extends Nub {
/**
* Add Cloisons to the PAB from a cloison model
* @param cloisonModel Cloison model parametrised as first upstream basin
* @param n Number of walls of the PAB (Number of basin = n - 1)
* @param n Number of walls (or falls) of the PAB (Number of basin = n - 1)
*/
public addCloisonsFromModel(cloisonModel: Cloisons , n: number) {
// Fix some parameters of the upstream cloison (= Wall + basin)
......@@ -154,6 +154,7 @@ export class Pab extends Nub {
* Finds the ParallelStructure targetted by modelUid and defines it as the current downWall
*/
public setDownWall(modelUid: string) {
// TODO: check if this is still necessary
this.properties.setPropValue("modeleCloisonAval", modelUid);
const dw = (Session.getInstance().findNubByUid(modelUid) as ParallelStructure);
if (dw) {
......@@ -164,17 +165,18 @@ export class Pab extends Nub {
}
/**
* Once session is loaded, run a second pass on all PabCloisons to
* Once session is loaded, run a second pass on all PAB's Cloisons to
* reinit their target if needed
*/
public fixPAB(obj: any) {
// TODO: check if this is still necessary
if (obj.children && Array.isArray(obj.children)) {
// Cloisons models
for (const c of obj.children) {
if (c.props.calcType === CalculatorType.PabCloisons) { // who knows ?
if (c.props.calcType === CalculatorType.Cloisons) { // who knows ?
const childUid = c.uid;
const targetCloisonsUid = c.props.modeleCloisons;
// find child PabCloisons to relink
// find child Cloisons to relink
const cloisons = (this.getChild(childUid) as Cloisons);
if (cloisons) {
// cloisons.setModel(targetCloisonsUid);
......
import { ParamCalculability, ParamDefinition, ParamFamily} from "../param/param-definition";
import { ParamDomainValue } from "../param/param-domain";
import { Result } from "../util/result";
import { CalculatorType, Session } from "../index";
import { Cloisons, CloisonsParams } from "./cloisons";
import { Pab } from "./pab";
class PabCloisonsParams extends CloisonsParams {
/** Débit d'attrait d'un bassin (m3/s) */
public _QA: ParamDefinition;
/** Model of cloison on which this pabCloison is based */
private _modelCloisonsParams: CloisonsParams;
/**
* Paramètres communs à toutes les équations de structure
* @param rQ Débit total (m3/s)
* @param rZ1 Cote de l'eau amont (m)
* @param rLB Longueur des bassins (m)
* @param rBB Largeur des bassins (m)
* @param rPB Profondeur moyenne (m)
* @param rDH Hauteur de chute (m)
*/
constructor(modelCloisonsParams?: CloisonsParams, rQA: number = 0) {
super(1, 1, 1, 1, 1, 1); // overwritten by init() below
this.modelCloisonsParams = modelCloisonsParams;
// Débit d'attrait
this._QA = new ParamDefinition(this, "QA", ParamDomainValue.POS_NULL, rQA, ParamFamily.FLOWS);
this.addParamDefinition(this._QA);
}
public get QA() {
return this._QA;
}
/**
* Record pointer to the cloison model for future updating of local parameters
*/
set modelCloisonsParams(modelCloisonsParams: CloisonsParams) {
this._modelCloisonsParams = modelCloisonsParams;
}
/**
* Update Current values and sandobx values of parameter from cloison model
*/
public setCurrentValuesFromModel() {
if (this._modelCloisonsParams !== undefined) {
for (const p of this._modelCloisonsParams) {
this._paramMap[p.symbol].singleValue = p.currentValue;
this._paramMap[p.symbol].v = p.currentValue;
}
}
}
}
// tslint:disable-next-line:max-classes-per-file
export class PabCloisons extends Cloisons {
/**
* paramètres castés au bon type
*/
get prms(): PabCloisonsParams {
return this._prms as PabCloisonsParams;
}
/**
* Calculation of upstream water depth
*/
get Yam(): number {
// TODO: ajouter l'option radier horizontal
return this.prms.PB.currentValue + this.prms.DH.currentValue / 2;
}
public parent: Pab;
constructor(modelCloisons: Cloisons, rQA: number = 0, dbg: boolean = false) {
super(new PabCloisonsParams(), dbg); // model is set below
this.initModelCloisons(modelCloisons);
this._calcType = CalculatorType.PabCloisons;
}
public Calc(sVarCalc: string, rInit?: number): Result {
const r: Result = super.Calc(sVarCalc, rInit);
const p = this.getParamValuesAfterCalc(sVarCalc, r);
r.extraResults.ZRAM = p.Z1 - p.PB;
return r;
}
/**
* Update crest elevations from upstream apron elevation
*/
public updateZDV(rZR: number) {
for (const st of this.structures) {
if (st.prms.ZDV.calculability !== ParamCalculability.NONE) {
st.prms.ZDV.v = st.prms.ZDV.currentValue + rZR - (this.prms.Z1.currentValue - this.Yam);
}
}
}
/**
* Sets modelCloisons as the current model (set pointers to parameters and structure array)
*/
public initModelCloisons(modelCloisons: Cloisons) {
this.prms.modelCloisonsParams = modelCloisons ? modelCloisons.prms : undefined;
this._children = modelCloisons ? modelCloisons.structures : [];
}
/**
* Finds the Cloisons targetted by modelUid and defines it as the current model
*/
public setModel(modelUid: string) {
this.properties.setPropValue("modeleCloisons", modelUid);
const cloisons = (Session.getInstance().findNubByUid(modelUid) as Cloisons);
if (cloisons) {
this.initModelCloisons(cloisons);
} /* else {
console.error("PabCloisons.setModel : cannot find target Cloisons");
} */
}
/**
* Returns an object representation of the Nub's current state
*/
public objectRepresentation() {
const ret: any = {
uid: this.uid,
props: this.properties.props,
parameters: []
};
// ! do not iterate over local parameters (would copy the parameters of the Cloisons used as model),
// just serialise QA
ret.parameters.push(this.prms.QA.objectRepresentation());
// ! do not iterate over children Nubs (would copy the children of the Cloisons used as model)
return ret;
}
/**
* paramétrage de la calculabilité des paramètres
*/
protected setParametersCalculability() {
super.setParametersCalculability();
this.prms._QA.calculability = ParamCalculability.FREE;
}
}
......@@ -28,7 +28,6 @@ import { acSection } from "./section/section_type";
import { Cloisons } from "./pab/cloisons";
import { CloisonsParams } from "./pab/cloisons_params";
import { Pab, PabParams } from "./pab/pab";
import { PabCloisons } from "./pab/pab_cloisons";
import { ParamDefinition } from "./param/param-definition";
import { Dever, DeverParams } from "./structure/dever";
import { CreateStructure } from "./structure/factory_structure";
......@@ -401,17 +400,6 @@ export class Session {
);
break;
case CalculatorType.PabCloisons:
const modeleCloisons: string = params.getPropValue("modeleCloisons");
if (modeleCloisons) {
const cloisons = (Session.getInstance().findNubByUid(modeleCloisons) as Cloisons);
// si le module Cloisons ciblé n'existe pas, Session.fixPAB() est censé s'en occuper
nub = new PabCloisons(cloisons);
} else {
nub = new PabCloisons(undefined); // don't forget to init with a Cloisons model afterwards !
}
break;
default:
{
throw new Error(
......@@ -632,6 +620,7 @@ export class Session {
* Asks all loaded PAB Nubs to reinit any PabCloisons from their model
*/
private fixPAB(serialised: string, uids?: string[]) {
// TODO: check if this is still necessary
const data = JSON.parse(serialised);
if (data.session && Array.isArray(data.session)) {
// find each PAB in the session
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment