From a59351c64fb4c31cfae68c1a9e11b9856c61909c Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 23 Mar 2018 14:24:50 +0000 Subject: [PATCH] test: Refactored transposing of plot data into function bin/tools/RunFunctions::transposeFile() which simplifies the reactingEulerFoam populationBalance test cases. Patch contributed by Institute of Fluid Dynamics, Helmholtz-Zentrum Dresden - Rossendorf (HZDR) --- bin/tools/RunFunctions | 27 +++++++ .../binaryBreakup/Allrun | 24 +----- .../binaryBreakup/plot | 10 +-- .../binaryBreakup/system/controlDict | 2 +- .../populationBalanceModeling/breakup/Allrun | 24 +----- .../populationBalanceModeling/breakup/plot | 10 +-- .../breakup/system/controlDict | 2 +- .../coalescence/Allrun | 24 +----- .../coalescence/plot | 10 +-- .../coalescence/system/controlDict | 2 +- .../simultaneousCoalescenceAndBreakup/Allrun | 46 ++---------- .../simultaneousCoalescenceAndBreakup/plot | 74 ++++++++++++++++--- .../system/controlDict | 4 +- .../populationBalanceModeling/drift/Allrun | 24 +----- .../populationBalanceModeling/drift/plot | 12 +-- .../drift/system/controlDict | 4 +- .../negativeDrift/Allrun | 24 +----- .../negativeDrift/plot | 12 +-- .../negativeDrift/system/controlDict | 4 +- 19 files changed, 149 insertions(+), 190 deletions(-) diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index 11b8bb36e..0c1193b2e 100644 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -168,4 +168,31 @@ cloneCase() fi } +transposeFile() +{ + awk ' + { + for (i = 1; i <= NF; i++) + { + a[NR, i] = $i + } + } + + NF > p {p = NF} + + END { + for (j = 1; j <= p; j++) + { + str = a[1,j] + + for(i = 2; i <= NR; i++) + { + str = str" "a[i,j]; + } + + print str + } + }' $1 +} + #------------------------------------------------------------------------------ diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/Allrun b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/Allrun index 076ba12d8..45134c2b3 100755 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/Allrun +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/Allrun @@ -11,27 +11,9 @@ runApplication blockMesh runApplication $application # Get and transpose results -cp postProcessing/box.all.numberDensity.volume.bubbles/0/box.all.numberDensity.volume.bubbles.dat . - -sed -i -e 1d box.all.numberDensity.volume.bubbles.dat -sed -i -e 's/# /#/g' box.all.numberDensity.volume.bubbles.dat - -awk ' -{ - for (i=1; i<=NF; i++) { - a[NR,i] = $i - } -} -NF>p { p = NF } -END { - for(j=1; j<=p; j++) { - str=a[1,j] - for(i=2; i<=NR; i++){ - str=str" "a[i,j]; - } - print str - } -}' box.all.numberDensity.volume.bubbles.dat > box.all.numberDensity.volume.bubbles.transposed.dat +cp postProcessing/numberDensity/0/numberDensity.dat . +sed -i -e '1d' -e 's/# /#/g' numberDensity.dat +transposeFile numberDensity.dat > numberDensity.transposed.dat # Create plot ./plot diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/plot b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/plot index 9a081b873..206faaf82 100755 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/plot +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/binaryBreakup/plot @@ -13,7 +13,7 @@ set ylabel 'n(m^{-3}m^{-3})' set logscale xy set xrange [1e-5:1.5] set yrange [1e-5:10] -set key center +set key at graph 0.8,0.5 N0 = 0.05 v0 = 1.0 @@ -21,7 +21,7 @@ v0 = 1.0 n(x,t) = N0*exp(-t*x**2.0)*2.0*t*v0 plot "p { p = NF } -END { - for(j=1; j<=p; j++) { - str=a[1,j] - for(i=2; i<=NR; i++){ - str=str" "a[i,j]; - } - print str - } -}' box.all.numberDensity.volume.bubbles.dat > box.all.numberDensity.volume.bubbles.transposed.dat +cp postProcessing/numberDensity/0/numberDensity.dat . +sed -i -e '1d' -e 's/# /#/g' numberDensity.dat +transposeFile numberDensity.dat > numberDensity.transposed.dat # Create plot ./plot diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/breakup/plot b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/breakup/plot index 9a081b873..206faaf82 100755 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/breakup/plot +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/breakup/plot @@ -13,7 +13,7 @@ set ylabel 'n(m^{-3}m^{-3})' set logscale xy set xrange [1e-5:1.5] set yrange [1e-5:10] -set key center +set key at graph 0.8,0.5 N0 = 0.05 v0 = 1.0 @@ -21,7 +21,7 @@ v0 = 1.0 n(x,t) = N0*exp(-t*x**2.0)*2.0*t*v0 plot "p { p = NF } -END { - for(j=1; j<=p; j++) { - str=a[1,j] - for(i=2; i<=NR; i++){ - str=str" "a[i,j]; - } - print str - } -}' box.all.numberDensity.volume.bubbles.dat > box.all.numberDensity.volume.bubbles.transposed.dat +cp postProcessing/numberDensity/0/numberDensity.dat . +sed -i -e '1d' -e 's/# /#/g' numberDensity.dat +transposeFile numberDensity.dat > numberDensity.transposed.dat # Create plot ./plot diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/plot b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/plot index e43f9fc68..7676d6a2e 100755 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/plot +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/plot @@ -13,7 +13,7 @@ set ylabel 'n(m^{-3}m^{-3})' set logscale xy set xrange [1e-5:1e2] set yrange [1e-15:100] -set key center left +set key at graph 0.55,0.5 C = 1 N0 = 2.5 @@ -41,7 +41,7 @@ phi(x,t) = (8*exp((y_s(t,x) - 1)*X(x)*2))/(((T(t) + 2)**2)*y_s(t,x)*(4*pi*(2 - 1 n(x,t) = (N0/v0)*phi(x,t) plot n0(x) ls -1 t 'Initial Condition',\ -n(x,10.0) ls 2 lc rgb 'black' t 'Scott (1968)',\ -'box.all.numberDensity.volume.bubbles.transposed.dat' every ::0::46 u 1:2 w p pt 1 t 'air1',\ -'box.all.numberDensity.volume.bubbles.transposed.dat' every ::47::55 u 1:2 w p pt 5 t 'air2',\ -'box.all.numberDensity.volume.bubbles.transposed.dat' every ::56::70 u 1:2 w p pt 9 t 'air3' +n(x,10.0) ls 2 lc rgb 'black' t '[Scott, J. Atmos. Sci., 25: 54-65, 1968]',\ +'numberDensity.transposed.dat' every ::0::46 u 1:2 w p pt 1 t 'air1',\ +'numberDensity.transposed.dat' every ::47::55 u 1:2 w p pt 5 t 'air2',\ +'numberDensity.transposed.dat' every ::56::70 u 1:2 w p pt 9 t 'air3' diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/system/controlDict b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/system/controlDict index c430fd85d..0400b3e20 100644 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/system/controlDict +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/coalescence/system/controlDict @@ -53,7 +53,7 @@ maxDeltaT 1; functions { - box.all.numberDensity.volume.bubbles + numberDensity { type sizeDistribution; functionObjectLibs ("libreactingEulerFoamFunctionObjects.so"); diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/Allrun b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/Allrun index 6d4e4d38a..498057d51 100755 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/Allrun +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/Allrun @@ -11,47 +11,13 @@ runApplication blockMesh runApplication $application # Get and transpose results -cp postProcessing/box.all.numberDensity.volume.bubbles/0/box.all.numberDensity.volume.bubbles.dat . -cp postProcessing/box.all.volumeDensity.volume.bubbles/0/box.all.volumeDensity.volume.bubbles.dat . +cp postProcessing/numberDensity/0/numberDensity.dat . +sed -i -e '1d' -e 's/# /#/g' numberDensity.dat +transposeFile numberDensity.dat > numberDensity.transposed.dat -sed -i -e 1d box.all.numberDensity.volume.bubbles.dat -sed -i -e 's/# /#/g' box.all.numberDensity.volume.bubbles.dat -sed -i -e 1d box.all.volumeDensity.volume.bubbles.dat -sed -i -e 's/# /#/g' box.all.volumeDensity.volume.bubbles.dat - -awk ' -{ - for (i=1; i<=NF; i++) { - a[NR,i] = $i - } -} -NF>p { p = NF } -END { - for(j=1; j<=p; j++) { - str=a[1,j] - for(i=2; i<=NR; i++){ - str=str" "a[i,j]; - } - print str - } -}' box.all.volumeDensity.volume.bubbles.dat > box.all.volumeDensity.volume.bubbles.transposed.dat - -awk ' -{ - for (i=1; i<=NF; i++) { - a[NR,i] = $i - } -} -NF>p { p = NF } -END { - for(j=1; j<=p; j++) { - str=a[1,j] - for(i=2; i<=NR; i++){ - str=str" "a[i,j]; - } - print str - } -}' box.all.numberDensity.volume.bubbles.dat > box.all.numberDensity.volume.bubbles.transposed.dat +cp postProcessing/volumeDensity/0/volumeDensity.dat . +sed -i -e '1d' -e 's/# /#/g' volumeDensity.dat +transposeFile volumeDensity.dat > volumeDensity.transposed.dat # Create plot ./plot diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/plot b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/plot index a888f9470..e198ef185 100755 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/plot +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/plot @@ -13,13 +13,69 @@ set ylabel 'Probability density function (m^{-3})' set xrange [1:10] set yrange [0:0.4] -set key left +set key below -plot 'rigorous.numberDensity.dat' w l t "Number density, Vanni (2000)",\ -'rigorous.volumeDensity.dat' w l t "Volume density, Vanni (2000)",\ -'box.all.numberDensity.volume.bubbles.transposed.dat' every ::0::12 u 1:2 w p pt 1 t 'Number density, air1',\ -'box.all.numberDensity.volume.bubbles.transposed.dat' every ::13::22 u 1:2 w p pt 5 t 'Number density, air2',\ -'box.all.numberDensity.volume.bubbles.transposed.dat' every ::23::30 u 1:2 w p pt 9 t 'Number density, air3',\ -'box.all.volumeDensity.volume.bubbles.transposed.dat' every ::0::12 u 1:2 w p pt 2 t 'Volume density, air1',\ -'box.all.volumeDensity.volume.bubbles.transposed.dat' every ::13::22 u 1:2 w p pt 6 t 'Volume density, air2',\ -'box.all.volumeDensity.volume.bubbles.transposed.dat' every ::23::30 u 1:2 w p pt 10 t 'Volume density, air3' +plot '-' w l t "Number density, [Vanni, J. Colloid Interface Sci., 221: 143-160, 2000]",\ +'-' w l t "Volume density, [Vanni, J. Colloid Interface Sci., 221: 143-160, 2000]",\ +'numberDensity.transposed.dat' every ::0::12 u 1:2 w p pt 1 t 'Number density, air1',\ +'numberDensity.transposed.dat' every ::13::22 u 1:2 w p pt 5 t 'Number density, air2',\ +'numberDensity.transposed.dat' every ::23::30 u 1:2 w p pt 9 t 'Number density, air3',\ +'volumeDensity.transposed.dat' every ::0::12 u 1:2 w p pt 2 t 'Volume density, air1',\ +'volumeDensity.transposed.dat' every ::13::22 u 1:2 w p pt 6 t 'Volume density, air2',\ +'volumeDensity.transposed.dat' every ::23::30 u 1:2 w p pt 10 t 'Volume density, air3' +1.000 0.042 +1.460 0.062 +1.950 0.083 +2.403 0.100 +2.775 0.116 +3.109 0.127 +3.562 0.141 +4.015 0.151 +4.475 0.162 +4.876 0.172 +5.270 0.179 +5.700 0.188 +6.035 0.190 +6.436 0.188 +6.777 0.178 +7.163 0.157 +7.416 0.137 +7.705 0.109 +7.980 0.078 +8.285 0.047 +8.589 0.026 +8.953 0.010 +9.228 0.003 +9.495 0.002 +EOF +0.993 0.000 +0.985 0.002 +1.475 0.003 +1.965 0.005 +2.485 0.010 +2.975 0.020 +3.488 0.032 +3.985 0.055 +4.468 0.084 +4.995 0.123 +5.507 0.176 +6.087 0.240 +6.532 0.289 +6.755 0.309 +7.007 0.326 +7.260 0.324 +7.535 0.305 +7.683 0.284 +7.839 0.252 +8.017 0.215 +8.196 0.172 +8.351 0.137 +8.574 0.090 +8.723 0.065 +8.946 0.037 +9.161 0.021 +9.339 0.013 +9.517 0.006 +9.770 0.004 +9.993 0.002 +EOF diff --git a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/system/controlDict b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/system/controlDict index b1ac53709..7e6eb645c 100644 --- a/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/system/controlDict +++ b/test/multiphase/reactingMultiphaseEulerFoam/populationBalanceModeling/simultaneousCoalescenceAndBreakup/system/controlDict @@ -53,7 +53,7 @@ maxDeltaT 1; functions { - box.all.numberDensity.volume.bubbles + numberDensity { type sizeDistribution; functionObjectLibs ("libreactingEulerFoamFunctionObjects.so"); @@ -69,7 +69,7 @@ functions normalize true; } - box.all.volumeDensity.volume.bubbles + volumeDensity { type sizeDistribution; functionObjectLibs ("libreactingEulerFoamFunctionObjects.so"); diff --git a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/Allrun b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/Allrun index 076ba12d8..45134c2b3 100755 --- a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/Allrun +++ b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/Allrun @@ -11,27 +11,9 @@ runApplication blockMesh runApplication $application # Get and transpose results -cp postProcessing/box.all.numberDensity.volume.bubbles/0/box.all.numberDensity.volume.bubbles.dat . - -sed -i -e 1d box.all.numberDensity.volume.bubbles.dat -sed -i -e 's/# /#/g' box.all.numberDensity.volume.bubbles.dat - -awk ' -{ - for (i=1; i<=NF; i++) { - a[NR,i] = $i - } -} -NF>p { p = NF } -END { - for(j=1; j<=p; j++) { - str=a[1,j] - for(i=2; i<=NR; i++){ - str=str" "a[i,j]; - } - print str - } -}' box.all.numberDensity.volume.bubbles.dat > box.all.numberDensity.volume.bubbles.transposed.dat +cp postProcessing/numberDensity/0/numberDensity.dat . +sed -i -e '1d' -e 's/# /#/g' numberDensity.dat +transposeFile numberDensity.dat > numberDensity.transposed.dat # Create plot ./plot diff --git a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/plot b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/plot index 517570ccd..a6b66f101 100755 --- a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/plot +++ b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/drift/plot @@ -15,8 +15,8 @@ set yrange [0:1.5e-2] set key top right plot "p { p = NF } -END { - for(j=1; j<=p; j++) { - str=a[1,j] - for(i=2; i<=NR; i++){ - str=str" "a[i,j]; - } - print str - } -}' box.all.numberDensity.volume.bubbles.dat > box.all.numberDensity.volume.bubbles.transposed.dat +cp postProcessing/numberDensity/0/numberDensity.dat . +sed -i -e '1d' -e 's/# /#/g' numberDensity.dat +transposeFile numberDensity.dat > numberDensity.transposed.dat # Create plot ./plot diff --git a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/negativeDrift/plot b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/negativeDrift/plot index ec7e48628..15b549c77 100755 --- a/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/negativeDrift/plot +++ b/test/multiphase/reactingTwoPhaseEulerFoam/populationBalanceModeling/negativeDrift/plot @@ -14,9 +14,9 @@ set xrange [1:15] set yrange [0:1.5e-2] set key top right -plot "