File: plot

package info (click to toggle)
openfoam 1912.200626-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 238,940 kB
  • sloc: cpp: 1,159,638; sh: 15,902; ansic: 5,195; lex: 660; xml: 387; python: 282; awk: 212; makefile: 103; sed: 88; csh: 3
file content (123 lines) | stat: -rwxr-xr-x 3,228 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
cd "${0%/*}" || exit                                # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions        # Tutorial run functions
#------------------------------------------------------------------------------

# Turbulence closure models
models=('kOmegaSST' 'SpalartAllmaras' 'kEpsilonPhitF')

# Note: CFL3D data available from:
# https://turbmodels.larc.nasa.gov/bump_sa.html
# The CFL3D-SpalartAllmaras datasets of Cf and Cp:
# Cf = https://turbmodels.larc.nasa.gov/Bump/SA/cf_bump.dat
# Cp = https://turbmodels.larc.nasa.gov/Bump/SA/cp_bump.dat

#------------------------------------------------------------------------------

plotCf() {
    declare -a resultSet=("${!1}")
    declare -a modelSet=("${!2}")

    graphNameCf="hill2D_cf.png"
    echo "Creating skin friction coefficient graph to $graphNameCf"
    gnuplot<<PLT_CF
    set terminal pngcairo font "helvetica,20" size 1000, 1000
    set xrange [0:1.5]
    set yrange [0:0.008]
    set grid
    set key bottom right
    set xlabel "x"
    set ylabel "C_f" rotate by 0
    set output "$graphNameCf"

    results="${resultSet[*]}"
    models="${modelSet[*]}"
    Uref = 69.44

    set lmargin 10
    set rmargin 1.5
    set bmargin 3.2

#    plot \
#        "cf_bump_cfl3d_sa.dat" every 10 u 1:2 t "CFL3D" \
#        w p ps 3 pt 6 lw 2 lc rgb "red", \
#        for [i=1:words(results)] word(results, i) \
#        u 1:(sqrt(\$2*\$2+\$3*\$3+\$4*\$4)/(0.5*Uref*Uref)) \
#        t word(models, i) with lines

    plot \
        for [i=1:words(results)] word(results, i) \
        u 1:(sqrt(\$2*\$2+\$3*\$3+\$4*\$4)/(0.5*Uref*Uref)) \
        t word(models, i) with lines

PLT_CF
}


plotCp() {
    declare -a resultSet=("${!1}")
    declare -a modelSet=("${!2}")

    graphNameCp="hill2D_cp.png"
    echo "Creating pressure coefficient graph to $graphNameCp"
    gnuplot<<PLT_CP
    set terminal pngcairo font "helvetica,20" size 1000, 1000
    set xrange [0:1.5]
    set yrange [0.4:-0.8]
    set grid
    set key bottom right
    set xlabel "x"
    set ylabel "C_p" rotate by 0
    set output "$graphNameCp"

    results="${resultSet[@]}"
    models="${modelSet[@]}"
    Uref = 69.44

    set lmargin 10
    set rmargin 1.5
    set bmargin 3.2

#    plot \
#        "cp_bump_cfl3d_sa.dat" every 10 u 1:2 t "CFL3D" \
#        w p ps 3 pt 6 lw 2 lc rgb "red", \
#        for [i=1:words(results)] word(results, i) \
#        u (\$1):(\$5) t word(models, i) with lines

    plot \
        for [i=1:words(results)] word(results, i) \
        u (\$1):(\$5) t word(models, i) with lines

PLT_CP
}


if notTest $@
then
    # Create validation plots

    # Require gnuplot
    command -v gnuplot >/dev/null || {
        echo "gnuplot not found - skipping graph creation" 1>&2
        exit 1
    }

    # Require awk
    command -v awk >/dev/null || {
        echo "awk not found - skipping graph creation" 1>&2
        exit 1
    }

    modelResults=()
    n=0
    for model in "${models[@]}"
    do
        modelResults[$n]="${model}/profiles.dat"
        n=$(($n+1))
    done

    plotCp modelResults[@] models[@]
    plotCf modelResults[@] models[@]
fi

# ------------------------------------------------------------------------------