Salome HOME
Merge branch 'BR_MULTI_BATHS' into HEAD
[modules/hydro.git] / src / HYDROTools / controls.py
index a69e6ec4104e331dbebcf9ea75ab3dcc9115276d..a75fdc99dab5ed68a5013dc1b065576cdeca554a 100644 (file)
@@ -5,7 +5,7 @@
 def controlGeomProps(geompy, geomShape, refLength, refArea):
   """
   compare area and length of a geometric face with a reference,
-  with relative precision of 1.E-7 
+  with relative precision of 1.E-3 
   """
   props = geompy.BasicProperties(geomShape)
   print " Wires length: ", props[0]
@@ -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")
+