[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203

Stephane Popinet popinet at users.sf.net
Fri May 15 02:54:50 UTC 2009


The following commit has been merged in the upstream branch:
commit f36018bbc695f30584c502b5bfd4337dbb364bb6
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Tue Nov 6 10:56:45 2007 +1100

    New script gfsjoin (written by Daniel Fuster)
    
    darcs-hash:20071105235645-d4795-c39232f8595742919a8468ffbdfe4583e9941b5a.gz

diff --git a/AUTHORS b/AUTHORS
index 5a738e7..06ae08a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -8,3 +8,4 @@ Marcelo E. Magallon: Debian packages.
 Ruben Scardovelli: - author of the Fortran version of gfs_plane_alpha()
       		   - Mixed Youngs-Centered VOF normal calculation
 Ivan Adam Vari: RPM packages.
+Daniel Fuster: gfsjoin script
diff --git a/tools/Makefile.am b/tools/Makefile.am
index e018f6f..80e4a5e 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -18,7 +18,8 @@ bin_SCRIPTS = \
 	darcs2dist \
 	bat2gts \
 	ppm2mpeg \
-	gfs2gfs
+	gfs2gfs \
+	gfsjoin
 
 EXTRA_DIST = $(bin_SCRIPTS)
 
diff --git a/tools/gfsjoin b/tools/gfsjoin
new file mode 100644
index 0000000..414e1b0
--- /dev/null
+++ b/tools/gfsjoin
@@ -0,0 +1,167 @@
+# !/bin/bash
+# script to join gerris output files in parallel simulations
+
+
+help ()
+{
+    echo ""
+    echo "Usage: gfsjoin Simfile Directory Rootname NP Tailname > Joined"
+    echo ""
+    echo "Simfile:        Name of the simulation file"
+    echo "Directory:      Directory where results are located"
+    echo "Rootname:       File root name"
+    echo "NP:             Number of processors"
+    echo "Tailname:       File tail name (without .gz)"
+    echo ""
+    exit
+}
+
+# verbose=1
+
+message ()
+{
+    if test $verbose; then
+	echo $1 > /dev/stderr
+    fi
+}
+
+#------------------------------------------------------------------------------
+
+if [ $1 == '-h' ]; then
+    help
+fi
+
+# removing all blanks and tabs immediately before the end of line.
+# Comments are also removed to avoid errors
+tmp=`mktemp -d`
+sed -e 's/#.*//' -e 's/[ ^I]*$//' -e '/^$/ d' $1 | sed '/^#/ d'  > $tmp/sim.tmp
+
+c1=$3
+c2=$5
+c3="$tmp/sim.tmp"
+numproc=$4
+dir=$2
+
+p1=$(awk '/GfsSimulation/ {print $1}' $c3)
+p2=$(awk '/GfsSimulation/ {print $2}' $c3)
+
+i=1
+while [ $i -le $numproc ]; do
+    gunzip -q ${dir}'/'$c1$[$i-1]$c2
+    i=$[$i+1]
+done
+
+message 'Creating output................'
+
+# Variables to handle the files names
+i=0
+while [ $i -lt $numproc ]; do
+    mainfile[$i]=${dir}'/'$c1$i$c2
+    message "${mainfile[$i]}"
+    i=$[$i+1]
+done
+
+# Copying the first two lines of the simulation file
+head -2 ${mainfile[0]} > $tmp/tmp.tmp
+# Inserting the correct number of boxes and connections
+sed -e '/GfsSimulation/ s/[0-9]*/'$p1'/1' -e '/GfsSimulation/s/[0-9]*/'$p2'/2' $tmp/tmp.tmp
+
+# Copying solid file (if any)
+sed -n '/SurfaceFile/ p' $c3
+
+# The first two lines are removed because they have useless information.
+# As I have already inserted the solid, this information is also removed from the files
+i=0
+while [ $i -lt $numproc ]; do
+    nend=$(awk '$1 ~ /GfsSourceDiffusion/ && $7 ~ /U/ {print NR}' ${mainfile[$i]})
+    nend=$[$nend+0]
+    if [ $nend -ne 0 ]; then
+	sed -e '1,2 d' -e '/GfsSolid/,'$[$nend-1]' d' ${mainfile[$i]} > $tmp/tmpfile$i
+    else
+	more +3 ${mainfile[$i]} > $tmp/tmpfile$i
+    fi
+    i=$[$i+1]
+done
+
+# Taking the initial common arguments (awk is used to remove the local 
+# connectivities in case they will be equal)
+(comm -1 -2 $tmp/tmpfile0 $tmp/tmpfile1 | awk '
+BEGIN{}
+{
+condition1 = ( $3 == "right" || $3 == "left" || $3 == "top" || $3 == "bottom" || $3 == "front" || $3 == "back" )
+if(!(NF == 3 && condition1)) {print $0}
+}
+END{}')
+
+# Creating temporal file with all the boxes (awk is used to remove the 
+# local connectivities in case they will be equal)
+# boxes in proc 0
+(comm -2 -3 $tmp/tmpfile0 $tmp/tmpfile1 | awk '
+BEGIN{}
+{
+condition1 = ( $3 == "right" || $3 == "left" || $3 == "top" || $3 == "bottom" || $3 == "front" || $3 == "back" )
+if(!(NF == 3 && condition1)) {print $0}
+}
+END{}') > $tmp/tmp.tmp
+
+# the rest of boxes
+i=1
+while [ $i -lt $numproc ]; do
+    (comm -3 -1 $tmp/tmpfile0 $tmp/tmpfile$i | awk '
+BEGIN{}
+{
+condition1= ( $3 == "right" || $3 == "left" || $3 == "top" || $3 == "bottom" || $3 == "front" || $3 == "back" )
+if(!(NF == 3 && condition1)) {print $0}
+}
+END{}') >> $tmp/tmp.tmp
+    i=$[$i+1]
+done
+
+message
+message "IMPORTANT: This script assumes that the \"id\" is in correlative order in your simulation file (not the pid)"
+message
+
+awk '$1 ~ /GfsBox/ && /id =/ {print $0}' $tmp/tmp.tmp | \
+    awk 'BEGIN{}
+     { i = 0
+       do {
+           i++
+       } while ( $i !~ /^id/ )
+        print $(i+2)
+}
+END{}' > $tmp/tmp.tmp2
+
+# The last box in the temporal file is:
+lastid=$(tail -1 $tmp/tmp.tmp2)
+# And the total number of boxes:
+numboxes=$(wc -l $tmp/tmp.tmp2 | awk '{print $1}')
+
+message "Putting boxes in order in the final file"
+# Boxes are pasted in the final file in order (it is assumed to be sequential)
+i=1
+while [ $i -le $numboxes ]; do
+    if [ $i -ne $lastid ]; then
+	message -n "$i ,"
+        n0=$(awk '{if($1 == '$i') {print NR}}' $tmp/tmp.tmp2)
+        n1=$(awk 'FNR == '$[$n0+1]' {print $1}' $tmp/tmp.tmp2)
+        # Taking the lines of this range (the last line is removed
+	# because it corresponds to the next box)
+        (awk '/id = '$i' pid/,/id = '$n1' pid/ {print $0}' $tmp/tmp.tmp | head -n -1)
+        i=$[$i+1]
+    else
+	message -n "$i ,"
+        nf=$(awk '$1 ~ /GfsBox/ && $5 ~ /'$i'/ && $3 ~ /id/ {print NR}' $tmp/tmp.tmp)
+        more +$nf $tmp/tmp.tmp
+        i=$[$i+1]
+    fi
+done
+
+# Copying the global conectivities
+tail -n $p2 $c3
+
+message
+message
+message 'compressing files again'
+gzip -f -q ${dir}'/'${c1}*'.gfs'
+
+rm -rf $tmp

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list