From e4397aed411f8eda77e3cee4e0f9e9354d46921e Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 24 Jun 2016 22:32:50 +0100 Subject: [PATCH] bin/foamGraph.*: Converted to POSIX shell --- bin/foamGraphExecTime | 24 ++++++++------- bin/foamGraphResKE | 44 +++++++++++++------------- bin/foamGraphResUVWP | 72 ++++++++++++++++++++++--------------------- 3 files changed, 73 insertions(+), 67 deletions(-) diff --git a/bin/foamGraphExecTime b/bin/foamGraphExecTime index 5d6905a2f..72ce3e53a 100755 --- a/bin/foamGraphExecTime +++ b/bin/foamGraphExecTime @@ -1,9 +1,9 @@ -#!/bin/csh -f +#!/bin/sh #------------------------------------------------------------------------------ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -28,17 +28,19 @@ # Description # #------------------------------------------------------------------------------ -if (! -f "$1" ) then - echo "No file: '$1'" - exit 1 -endif +Script=${0##*/} -set tmpTime = newTime$$.dat +if [ ! -f "$1" ]; then + echo "$Script: $1 is not a valid filename" + exit 1 +fi + +tmpTime=newTime$$.dat cat $1 | grep "ExecutionTime = " | awk 'BEGIN { NENTRIES = 0 ; TPREV = 0.0 }{NENTRIES++; printf("%f %e\n", NENTRIES, $3 - TPREV); TPREV = $3}' - > $tmpTime -set linesExec = `cat $tmpTime | wc -l` +linesExec=$(cat $tmpTime | wc -l) -set ngraphs = 0 +ngraphs=0 cat << EOF > executionTime.dat Solver Performance @@ -49,14 +51,14 @@ time/iteration 1 EOF -if ($linesExec > 1) then +if [ "$linesExec" -gt 1 ]; then cat << EOF >> executionTime.dat time 0 $linesExec EOF cat $tmpTime >> executionTime.dat -endif +fi rm $tmpTime diff --git a/bin/foamGraphResKE b/bin/foamGraphResKE index 9998cd52e..756a6317e 100755 --- a/bin/foamGraphResKE +++ b/bin/foamGraphResKE @@ -1,9 +1,9 @@ -#!/bin/csh -f +#!/bin/sh #------------------------------------------------------------------------------ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -28,29 +28,31 @@ # Description # #------------------------------------------------------------------------------ -if (! -f "$1" ) then - echo "No file: '$1'" - exit 1 -endif +Script=${0##*/} -set tmpK = newK$$.dat +if [ ! -f "$1" ]; then + echo "$Script: $1 is not a valid filename" + exit 1 +fi + +tmpK=newK$$.dat cat $1 | grep "Solving for k" | grep -v "solution singularity" | sed s/,//g | awk 'BEGIN { NENTRIES = 0 }{NENTRIES++; printf("%f %e\n", NENTRIES, $8)}' - > $tmpK -set tmpEpsilon = newEpsilon$$.dat +tmpEpsilon=newEpsilon$$.dat cat $1 | grep "Solving for epsilon" | grep -v "solution singularity" | sed s/,//g | awk 'BEGIN { NENTRIES = 0 }{NENTRIES++; printf("%f %e\n", NENTRIES, $8)}' - > $tmpEpsilon -set linesK = `cat $tmpK | wc -l` -set linesEpsilon = `cat $tmpEpsilon | wc -l` +linesK=$(cat $tmpK | wc -l) +linesEpsilon=$(cat $tmpEpsilon | wc -l) -set ngraphs = 0 +ngraphs=0 -if ($linesK > 1) then -@ ngraphs = $ngraphs + 1 -endif +if [ "$linesK" -gt 1 ]; then + ngraphs=$(($ngraphs+1)) +fi -if ($linesEpsilon > 1) then -@ ngraphs = $ngraphs + 1 -endif +if [ "$linesEpsilon" -gt 1 ]; then + ngraphs=$(($ngraphs+1)) +fi cat << EOF > residualKE.dat Solver Performance @@ -61,23 +63,23 @@ residual $ngraphs EOF -if ($linesK > 1) then +if [ "$linesK" -gt 1 ]; then cat << EOF >> residualKE.dat k 0 $linesK EOF cat $tmpK >> residualKE.dat -endif +fi -if ($linesEpsilon > 1) then +if [ "$linesEpsilon" -gt 1 ]; then cat << EOF >> residualKE.dat epsilon 0 $linesEpsilon EOF cat $tmpEpsilon >> residualKE.dat -endif +fi rm $tmpK rm $tmpEpsilon diff --git a/bin/foamGraphResUVWP b/bin/foamGraphResUVWP index 66eaee441..fa2af3417 100755 --- a/bin/foamGraphResUVWP +++ b/bin/foamGraphResUVWP @@ -1,9 +1,9 @@ -#!/bin/csh -f +#!/bin/sh #------------------------------------------------------------------------------ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -28,45 +28,47 @@ # Description # #------------------------------------------------------------------------------ -if (! -f "$1" ) then - echo "No file: '$1'" - exit 1 -endif +Script=${0##*/} -set tmpU = newU$$.dat +if [ ! -f "$1" ]; then + echo "$Script: $1 is not a valid filename" + exit 1 +fi + +tmpU=newU$$.dat cat $1 | grep "Solving for Ux" | grep -v "solution singularity" | sed s/,//g | awk 'BEGIN { NENTRIES = 0 }{NENTRIES++; printf("%d %e\n", NENTRIES, $8)}' - > $tmpU -set tmpV = newV$$.dat +tmpV=newV$$.dat cat $1 | grep "Solving for Uy" | grep -v "solution singularity" | sed s/,//g | awk 'BEGIN { NENTRIES = 0 }{NENTRIES++; printf("%d %e\n", NENTRIES, $8)}' - > $tmpV -set tmpW = newW$$.dat +tmpW=newW$$.dat cat $1 | grep "Solving for Uz" | grep -v "solution singularity" | sed s/,//g | awk 'BEGIN { NENTRIES = 0 }{NENTRIES++; printf("%d %e\n", NENTRIES, $8)}' - > $tmpW -set tmpP = newP$$.dat +tmpP=newP$$.dat cat $1 | grep "Solving for p" | grep -v "solution singularity" | sed s/,//g | awk 'BEGIN { NENTRIES = 0 }{NENTRIES++; printf("%d %e\n", NENTRIES, $8)}' - > $tmpP -set linesU = `cat $tmpU | wc -l` -set linesV = `cat $tmpV | wc -l` -set linesW = `cat $tmpW | wc -l` -set linesP = `cat $tmpP | wc -l` +linesU=$(cat $tmpU | wc -l) +linesV=$(cat $tmpV | wc -l) +linesW=$(cat $tmpW | wc -l) +linesP=$(cat $tmpP | wc -l) -set ngraphs = 0 +ngraphs=0 -if ($linesU > 1) then -@ ngraphs = $ngraphs + 1 -endif +if [ "$linesU" -gt 1 ]; then + ngraphs=$(($ngraphs+1)) +fi -if ($linesV > 1) then -@ ngraphs = $ngraphs + 1 -endif +if [ "$linesV" -gt 1 ]; then + ngraphs=$(($ngraphs+1)) +fi -if ($linesW > 1) then -@ ngraphs = $ngraphs + 1 -endif +if [ "$linesW" -gt 1 ]; then + ngraphs=$(($ngraphs+1)) +fi -if ($linesP > 1) then -@ ngraphs = $ngraphs + 1 -endif +if [ "$linesP" -gt 1 ]; then + ngraphs=$(($ngraphs+1)) +fi cat << EOF > residualUVWP.dat EOF @@ -78,7 +80,7 @@ EOF #$ngraphs #EOF -if ($linesU > 1) then +if [ "$linesU" -gt 1 ]; then cat << EOF >> residualUVWP.dat EOF @@ -87,9 +89,9 @@ EOF #$linesU #EOF cat $tmpU >> residualUVWP.dat -endif +fi -if ($linesV > 1) then +if [ "$linesV" -gt 1 ]; then cat << EOF >> residualUVWP.dat EOF @@ -98,9 +100,9 @@ EOF #$linesV #EOF cat $tmpV >> residualUVWP.dat -endif +fi -if ($linesW > 1) then +if [ "$linesW" -gt 1 ]; then cat << EOF >> residualUVWP.dat EOF @@ -109,9 +111,9 @@ EOF #$linesW #EOF cat $tmpW >> residualUVWP.dat -endif +fi -if ($linesP > 1) then +if [ "$linesP" -gt 1 ]; then cat << EOF >> residualUVWP.dat EOF @@ -120,7 +122,7 @@ EOF #$linesP #EOF cat $tmpP >> residualUVWP.dat -endif +fi rm $tmpU rm $tmpV