#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | Website: https://openfoam.org
# \\ / A nd | Copyright (C) 2024-2025 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see .
#
# Script
# frictionFactorReGraph
#
# Description
# Plots a graph of "frictionFactor" vs "Re" for the moodyChart tutorial
#
#------------------------------------------------------------------------------
! command -v gnuplot >/dev/null 2>&1 && \
echo 'gnuplot not found - skipping graph creation' && \
exit 1
# Formatting
format () {
cat< 2000 ? 1/(-1.8*log10((Ks/D/3.7)**1.11+(6.9/x)))**2 : 0
g(x) = x < 2000 ? 64/x : 0
set output 'moodyChart.png'
plot 'postProcessing/0/frictionFactor/data' u 2:3 t 'Laminar CFD' $ptFmt $colLam, \
'postProcessing/2/frictionFactor/data' u 2:3 t 'RAS CFD' $ptFmt $colTurb, \
g(x) t 'Laminar (64/x)' $lineFmt $colLam, \
f(x) t 'Turbulent (Haaland)' $lineFmt $colTurb
EOF