From 3f477c59ed5ec94c865ba66cfd705e4560edc12a Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Wed, 13 Jul 2016 16:38:26 +0200 Subject: [PATCH] improve test controls --- .../examples/h014_caseDigueManualInterpolZ.py | 4 +-- .../examples/h015_normalCaseManualTelemac.py | 20 +++++++++-- src/HYDROTools/controls.py | 33 +++++++++++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/doc/salome/examples/h014_caseDigueManualInterpolZ.py b/doc/salome/examples/h014_caseDigueManualInterpolZ.py index 63604b15..ec45d249 100644 --- a/doc/salome/examples/h014_caseDigueManualInterpolZ.py +++ b/doc/salome/examples/h014_caseDigueManualInterpolZ.py @@ -542,8 +542,8 @@ zUndef = 90 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) -#refstatz = {'riveDroite': (10.88, 32.47999954), 'riveGauche': (7.72, 71.38999939), 'litMineur': (2.06, 25.41)} -#controlStatZ(statz, refstatz) +refstatz = {'riveDroite': (10.88, 32.47999954), 'riveGauche': (7.72, 71.38999939), 'litMineur': (2.06, 25.41), 'digue': (14.10,27.09)} +controlStatZ(statz, refstatz) # --- add a field on nodes of type double with z values, named "BOTTOM" createZfield2(fichierMaillage) diff --git a/doc/salome/examples/h015_normalCaseManualTelemac.py b/doc/salome/examples/h015_normalCaseManualTelemac.py index 10d67570..6c3fc2d9 100644 --- a/doc/salome/examples/h015_normalCaseManualTelemac.py +++ b/doc/salome/examples/h015_normalCaseManualTelemac.py @@ -422,6 +422,13 @@ print "tmpdir=",tmpdir fichierMaillage = os.path.join(tmpdir, 'garonne_1.med') garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) +mesures = garonne_1.GetMeshInfo() +d= {} +for key, value in mesures.iteritems(): + d[str(key)] = value +nbTriangles = d['Entity_Triangle'] +nbNodes = d['Entity_Node'] + controlMeshStats(garonne_1, 3888, 475, 7597) controlSubMeshStats(litMineur_2, 2384) controlSubMeshStats(riveDroite_1, 2342) @@ -475,9 +482,9 @@ jdc = """ PYTEL(CODE='telemac2d', FICHIER_CAS='%s/init.cas', REPERTOIRE_TRAVAIL='%s/work', - ENTREE_MED=_F(FICHIER_MED='%s/garonne_1F.med', + ENTREE_MED=_F(FICHIER_MED='%s/garonne_1Z.med', FICHIER_BCD='%s/condlim.bcd',), - SORTIE_MED='%s/r2d_garonne_1F.med',); + SORTIE_MED='%s/r2d_garonne_1Z.med',); """ % (tmpdir, tmpdir, tmpdir, tmpdir, tmpdir) print jdc @@ -489,3 +496,12 @@ print param_dict from salome.hydro.pytel.launcher import run_pytel run_pytel(param_dict) + +from salome.hydrotools.controls import controlTelemacResult +aMedResult = tmpdir + '/r2d_garonne_1Z.med' +refstats = {'nbTriangles' : nbTriangles, + 'nbNodes' : nbNodes, + 'fieldNames':('DEBIT SCALAIRE', 'FOND', 'FROTTEMENT', "HAUTEUR D'EAU", 'NBRE DE COURANT', 'SURFACE LIBRE', 'VITESSE U', 'VITESSE V'), + 'iterations':[(0, -1), (1, -1), (2, -1), (3, -1), (4, -1), (5, -1)] + } +controlTelemacResult(aMedResult, refstats) diff --git a/src/HYDROTools/controls.py b/src/HYDROTools/controls.py index 8f7f3c53..a75fdc99 100644 --- a/src/HYDROTools/controls.py +++ b/src/HYDROTools/controls.py @@ -78,3 +78,36 @@ def controlStatZ(statz,refstatz): print nomreg print "value: ", vals, " reference: ", valsref raise ValueError("z interpolation error") + +from MEDLoader import MEDLoader, MEDCouplingFieldDouble, ON_NODES, DataArrayDouble, MEDFileMesh +import os, time + +def controlTelemacResult(aMedFile, refs): + """ + Check if the result med file exist and contains result fields + """ + print aMedFile + for i in range(10): + time.sleep(3) + print 'waiting result...' + if os.path.exists(aMedFile): + break + time.sleep(3) + try: + MEDLoader.CheckFileForRead(aMedFile) + except: + raise ValueError("problem while reading Telemac result med file") + names = MEDLoader.GetMeshNames(aMedFile) + infos = MEDLoader.GetUMeshGlobalInfo(aMedFile, names[0]) + stats = {} + stats['nbTriangles'] = infos[0][0][0][1] + stats['nbNodes'] = infos[3] + stats['fieldNames'] = MEDLoader.GetNodeFieldNamesOnMesh(aMedFile, names[0]) + stats['iterations'] = MEDLoader.GetNodeFieldIterations(aMedFile, names[0], 'SURFACE LIBRE') + for nomreg, valsref in refs.iteritems(): + vals = stats[nomreg] + if vals != valsref: + print nomreg + print "value: ", vals, " reference: ", valsref + raise ValueError("error in Telemac result") + -- 2.39.2