]> SALOME platform Git repositories - modules/hydrosolver.git/commitdiff
Salome HOME
generation of the interpolZ script
authorasl <asl@opencascade.com>
Tue, 11 Oct 2016 08:18:15 +0000 (11:18 +0300)
committerasl <asl@opencascade.com>
Tue, 11 Oct 2016 08:18:32 +0000 (11:18 +0300)
src/salome_hydro/generate_interpolz.py [new file with mode: 0644]
src/salome_hydro/interpolz.template [new file with mode: 0644]

diff --git a/src/salome_hydro/generate_interpolz.py b/src/salome_hydro/generate_interpolz.py
new file mode 100644 (file)
index 0000000..8879667
--- /dev/null
@@ -0,0 +1,44 @@
+
+def replace( lines, pattern, subst ):
+       for i in range( 0, len( lines ) ):
+               line = lines[i]
+               if pattern in lines[i]:
+                       if isinstance( subst, list ):
+                               del lines[i]
+                               for s in subst:
+                                       new_line = line.replace( pattern, repr(s) )
+                                       lines.insert( i, new_line )
+                       elif isinstance( subst, dict ):
+                               del lines[i]
+                               name = pattern[1:-1]
+                               lines.insert( i, "%s = {}\n" % name )
+                               keys = subst.keys()
+                               keys.sort()
+                               i = i+1
+                               for k in keys:
+                                       v = subst[k]
+                                       lines.insert( i, "%s[%s] = %s\n" % (name, repr(k), repr(v) ) )
+                                       i = i+1
+                       else:
+                               new_line = line.replace( pattern, repr(subst) )
+                               lines[i] = new_line
+                               
+
+def generate( path, calc_case, med_file, med_groups_regions, z_undef, interp ):
+       f = open( path, "w" )
+       tf = open( "interpolz.template", "r" )
+       templ = tf.readlines()
+       
+       replace( templ, "<case_name_from_dlg>", calc_case )
+       replace( templ, "<MED_file_path_from_dlg>", med_file )
+       replace( templ, "<dictGroupRegion>", med_groups_regions )
+       replace( templ, "<z_undef_value_from_dlg>", z_undef )
+       replace( templ, "<interpolation_method_value_from_dlg>", interp )
+               
+       for line in templ:
+               f.write( line )
+       f.close()
+
+
+
+generate( "test_interpolz.py", "case_1", "mesh.med", {"group_1":"reg_1", "group_2":"reg_2"}, -9999, "linear" )
diff --git a/src/salome_hydro/interpolz.template b/src/salome_hydro/interpolz.template
new file mode 100644 (file)
index 0000000..1596f43
--- /dev/null
@@ -0,0 +1,21 @@
+\94\94\94Z interpolation with HYDRO\94\94\94
+
+from salome.hydrotools.interpolZ import interpolZ
+
+# Calculation case name in HYDRO
+caseName = <case_name_from_dlg>
+
+# MED file 2D(x,y) of the case produced by SMESH
+medFile = <MED_file_path_from_dlg>
+
+# Dictionary [med group name] = region name
+<dictGroupRegion>
+
+# Value to use for Z when the node is not in a region (used to detect problems)                       
+zUndef = <z_undef_value_from_dlg>
+
+# Interpolation method
+interpolMethod = <interpolation_method_value_from_dlg>
+
+# Z interpolation on the bathymetry/altimetry on the mesh nodes
+statZ = interpolZ(caseName, medFile, dictGroupRegion, zUndef,interpolMethod)