From 4e09a6e598fc44fbeb4b3aa93c2ccd5ed0ac1682 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Sat, 25 Jun 2016 22:14:25 +0100 Subject: [PATCH] foamGraph.*: Simplified scripts Added a 'deprecated' comment and recommendation to use 'foamLog' --- bin/foamGraphExecTime | 31 ++++------- bin/foamGraphResKE | 67 ++++++++---------------- bin/foamGraphResUVWP | 118 +++++++++--------------------------------- bin/foamLog | 14 +++-- 4 files changed, 62 insertions(+), 168 deletions(-) diff --git a/bin/foamGraphExecTime b/bin/foamGraphExecTime index 72ce3e53a31..73bd8d56334 100755 --- a/bin/foamGraphExecTime +++ b/bin/foamGraphExecTime @@ -26,7 +26,10 @@ # foamGraphExecTime # # Description +# Deprecated script extract the 'ExecutionTime' for each time-step from a +# log file for graphing. # +# Superceded by the more general foamLog script. #------------------------------------------------------------------------------ Script=${0##*/} @@ -36,30 +39,14 @@ if [ ! -f "$1" ]; then 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 +cat $1 | \ + grep "ExecutionTime = " | \ + awk 'BEGIN { NENTRIES = 0 ; TPREV = 0.0 }{NENTRIES++; printf("%f %e\n", NENTRIES, $3 - TPREV); TPREV = $3}' - > $tmpTime -linesExec=$(cat $tmpTime | wc -l) - -ngraphs=0 - -cat << EOF > executionTime.dat -Solver Performance -iterations -time/iteration -0 0 -0 0 -1 -EOF - -if [ "$linesExec" -gt 1 ]; then -cat << EOF >> executionTime.dat -time -0 -$linesExec -EOF -cat $tmpTime >> executionTime.dat +if [ "$(cat $tmpTime | wc -l)" -gt 1 ]; then + mv $tmpTime executionTime.dat fi -rm $tmpTime +rm -f $tmpTime #------------------------------------------------------------------------------ diff --git a/bin/foamGraphResKE b/bin/foamGraphResKE index 756a6317eaf..57e936b457e 100755 --- a/bin/foamGraphResKE +++ b/bin/foamGraphResKE @@ -26,7 +26,10 @@ # foamGraphResKE # # Description +# Deprecated script extract initial turbulence residuals for each time-step +# from a log file for graphing. # +# Superceded by the more general foamLog script. #------------------------------------------------------------------------------ Script=${0##*/} @@ -35,53 +38,27 @@ if [ ! -f "$1" ]; then 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 +scan() +{ + tmpFile=new$1$$.dat + cat $2 | \ + grep "Solving for $1" | \ + grep -v "solution singularity" | \ + sed s/,//g | \ + awk 'BEGIN { NENTRIES = 0 }{NENTRIES++; printf("%d %e\n", NENTRIES, $8)}' - > $tmpFile -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 + if [ "$(cat $tmpFile | wc -l)" -gt 1 ]; then + echo >> residualKE.dat + cat $tmpFile >> residualKE.dat + fi -linesK=$(cat $tmpK | wc -l) -linesEpsilon=$(cat $tmpEpsilon | wc -l) + rm $tmpFile +} -ngraphs=0 - -if [ "$linesK" -gt 1 ]; then - ngraphs=$(($ngraphs+1)) -fi - -if [ "$linesEpsilon" -gt 1 ]; then - ngraphs=$(($ngraphs+1)) -fi - -cat << EOF > residualKE.dat -Solver Performance -number of iterations -residual -0 0 -0 0 -$ngraphs -EOF - -if [ "$linesK" -gt 1 ]; then -cat << EOF >> residualKE.dat -k -0 -$linesK -EOF -cat $tmpK >> residualKE.dat -fi - -if [ "$linesEpsilon" -gt 1 ]; then -cat << EOF >> residualKE.dat -epsilon -0 -$linesEpsilon -EOF -cat $tmpEpsilon >> residualKE.dat -fi - -rm $tmpK -rm $tmpEpsilon +rm -f residualKE.dat +scan "k" $1 +scan "epsilon" $1 +scan "omega" $1 +scan "nuTilda" $1 #------------------------------------------------------------------------------ diff --git a/bin/foamGraphResUVWP b/bin/foamGraphResUVWP index fa2af3417a4..580db29f763 100755 --- a/bin/foamGraphResUVWP +++ b/bin/foamGraphResUVWP @@ -26,7 +26,10 @@ # foamGraphResUVWP # # Description +# Deprecated script extract initial velocity and pressure residuals for each +# time-step from a log file for graphing. # +# Superceded by the more general foamLog script. #------------------------------------------------------------------------------ Script=${0##*/} @@ -35,98 +38,27 @@ if [ ! -f "$1" ]; then 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 - -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 - -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 - -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 - -linesU=$(cat $tmpU | wc -l) -linesV=$(cat $tmpV | wc -l) -linesW=$(cat $tmpW | wc -l) -linesP=$(cat $tmpP | wc -l) - -ngraphs=0 - -if [ "$linesU" -gt 1 ]; then - ngraphs=$(($ngraphs+1)) -fi - -if [ "$linesV" -gt 1 ]; then - ngraphs=$(($ngraphs+1)) -fi - -if [ "$linesW" -gt 1 ]; then - ngraphs=$(($ngraphs+1)) -fi - -if [ "$linesP" -gt 1 ]; then - ngraphs=$(($ngraphs+1)) -fi - -cat << EOF > residualUVWP.dat -EOF -#Solver Performance -#number of iterations -#residual -#0 0 -#0 0 -#$ngraphs -#EOF - -if [ "$linesU" -gt 1 ]; then -cat << EOF >> residualUVWP.dat - -EOF -#U -#0 -#$linesU -#EOF -cat $tmpU >> residualUVWP.dat -fi - -if [ "$linesV" -gt 1 ]; then -cat << EOF >> residualUVWP.dat - -EOF -#V -#0 -#$linesV -#EOF -cat $tmpV >> residualUVWP.dat -fi - -if [ "$linesW" -gt 1 ]; then -cat << EOF >> residualUVWP.dat - -EOF -#W -#0 -#$linesW -#EOF -cat $tmpW >> residualUVWP.dat -fi - -if [ "$linesP" -gt 1 ]; then -cat << EOF >> residualUVWP.dat - -EOF -#P -#0 -#$linesP -#EOF -cat $tmpP >> residualUVWP.dat -fi - -rm $tmpU -rm $tmpV -rm $tmpW -rm $tmpP +scan() +{ + tmpFile=new$1$$.dat + cat $2 | \ + grep "Solving for $1" | \ + grep -v "solution singularity" | \ + sed s/,//g | \ + awk 'BEGIN { NENTRIES = 0 }{NENTRIES++; printf("%d %e\n", NENTRIES, $8)}' - > $tmpFile + + if [ "$(cat $tmpFile | wc -l)" -gt 1 ]; then + echo >> residualUVWP.dat + cat $tmpFile >> residualUVWP.dat + fi + + rm $tmpFile +} + +rm -f residualUVWP.dat +scan "Ux" $1 +scan "Uy" $1 +scan "Uz" $1 +scan "p" $1 #------------------------------------------------------------------------------ diff --git a/bin/foamLog b/bin/foamLog index 5caf052679e..8b7d6587e75 100755 --- a/bin/foamLog +++ b/bin/foamLog @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -26,10 +26,8 @@ # foamLog # # Description -# extracts info from log file +# Script extract data for each time-step from a log file for graphing. # -# Bugs -# -solution singularity not handled #------------------------------------------------------------------------------ Script=${0##*/} toolsDir=${0%/*}/tools @@ -106,7 +104,7 @@ usage timeName=Time unset listOpt quietOpt localDB -# parse options +# Parse options while [ "$#" -gt 0 ] do case "$1" in @@ -139,17 +137,17 @@ do esac done -# find the database file +# Find the database file DBFILE=$Script.db [ -f $DBFILE ] || DBFILE=`foamEtcFile $Script.db` || DBFILE=$toolsDir/$Script.db -# need the database file +# Heed the database file [ -f $DBFILE ] || { echo "$Script: Cannot read database $DBFILE" exit 1 } -# single logFile +# Single logFile if [ $# -eq 1 ] then LOG=$1 -- GitLab