File: plot

package info (click to toggle)
openfoam 1912.200626-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 238,956 kB
  • sloc: cpp: 1,159,641; sh: 15,902; ansic: 5,195; lex: 660; xml: 387; python: 282; awk: 212; makefile: 103; sed: 88; csh: 3
file content (88 lines) | stat: -rwxr-xr-x 2,377 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
#!/bin/bash
cd "${0%/*}" || exit                                # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions        # Tutorial run functions
#------------------------------------------------------------------------------

# Plot temperature, heat flux vs analytical

graphDir="postProcessing/singleGraph"

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

plotTemperature() {
    graphName="Tprofile.png"
    echo "Creating temperature profile graph to $graphName"
    gnuplot<<GNUPLOT
    set terminal pngcairo font "Helvetica,12" size 800,600
    set title "Temperature profile" font "Helvetica,12"

    set key bottom right
    set xlabel "z" font "Helvetica,12"
    set ylabel "Temperature" font "Helvetica,16"
    set output "$graphName"

    set logscale y
    set format y "10^{%L}"
    set key font ",12"

    set lmargin 10
    set rmargin 1.5
    set bmargin 3.2

    s1=1
    s2=1e6

    fo(x)=s1/(s1+s2)+s2*x/(s1+s2)
    fu(x)=s1/(s1+s2)+s1*x/(s1+s2)

    plot \
    (x<=0)?fu(x):fo(x) w l lc 0 t 'analytical solution', \
    "$graphDir/1/line_T.xy" u 1:2 w p pt 2 ps 2 lt rgb "red" t 'linear interpolation', \
    "$graphDir/2/line_T.xy" u 1:2 w p pt 6 ps 2 lt rgb "green" t 'harmonic interpolation'

GNUPLOT
}


plotHeatFlux() {
    graphName="heatFlux.png"
    echo "Creating heat-flux graph to $graphName"
    gnuplot<<GNUPLOT
    set terminal pngcairo font "Helvetica,12" size 800,600
    set title "Heat Flux" font "Helvetica,16"

    set key top right
    set xlabel "z" font "Helvetica,12"
    set output "$graphName"

    set logscale y
    set format y "10^{%L}"
    set key font ",12"

    set lmargin 10
    set rmargin 1.5
    set bmargin 3.2

    plot \
    "$graphDir/1/line_flux.xy" u 1:4 w p pt 6 ps 2 lt rgb "red" t 'laplacian: linear, grad: linear', \
    "$graphDir/2/line_flux.xy" u 1:4 w p pt 2 ps 2 lt rgb "blue" t 'laplacian: harmonic, grad: linear', \
    "$graphDir/3/line_flux.xy" u 1:4 w l lt rgb "green" t 'laplacian: harmonic, grad: weightedFlux'
GNUPLOT
}


if notTest $@
then
    # Create validation plots

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

    plotTemperature
    plotHeatFlux
fi

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