From b6dec5860b9c37908b4789f1570d93d1f5833fa5 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 18 May 2017 10:54:45 +0100 Subject: [PATCH] ENH: histogram: output raw count, auto-range. Fixes #467 --- .../gnuplot/gnuplotSetWriter.C | 22 +++++++++++++++---- .../field/histogram/histogram.H | 6 +++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C b/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C index 4809bb35045..f6c724275e9 100644 --- a/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C +++ b/src/fileFormats/sampledSetWriters/gnuplot/gnuplotSetWriter.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -68,8 +68,18 @@ void Foam::gnuplotSetWriter<Type>::write ) const { os << "set term postscript color" << nl - << "set output \"" << points.name() << ".ps\"" << nl - << "plot"; + << "set output \"" << points.name() << ".ps\"" << nl; + + // Set secondary Y axis if using two columns. Falls back to same + // values if both on same scale. However, ignore if more columns. + if (valueSetNames.size() == 2) + { + os << "set ylabel \"" << valueSetNames[0] << "\"" << nl + << "set y2label \"" << valueSetNames[1] << "\"" << nl + << "set ytics nomirror" << nl << "set y2tics" << nl; + } + + os << "plot"; forAll(valueSets, i) { @@ -79,10 +89,14 @@ void Foam::gnuplotSetWriter<Type>::write } os << " \"-\" title \"" << valueSetNames[i] << "\" with lines"; + + if (valueSetNames.size() == 2) + { + os << " axes x1y" << (i+1) ; + } } os << nl; - forAll(valueSets, i) { this->writeTable(points, *valueSets[i], os); diff --git a/src/functionObjects/field/histogram/histogram.H b/src/functionObjects/field/histogram/histogram.H index d6147cff1b3..f5b9402a44e 100644 --- a/src/functionObjects/field/histogram/histogram.H +++ b/src/functionObjects/field/histogram/histogram.H @@ -58,6 +58,12 @@ Usage setFormat | Output format | yes | \endtable +Note + If max is not provided it will use the field's min and max as the bin + extremes. If max is provided but not min it will use 0. The set written + contains two columns, the first the volume averaged values, the second + the raw bin count. + See also Foam::functionObject Foam::functionObjects::fvMeshFunctionObject -- GitLab