Skip to content
Snippets Groups Projects
Commit 9b382a36 authored by Henry's avatar Henry
Browse files

fieldMinMax: add optional switch to control the output of max/min location

and simplify output format for graphing

With "location yes;"

log:
    fieldMinMax fieldMinMax output:
        min/max(mag(U.air)) = 0 28.309442
        min/max(mag(U.water)) = 0 27.221734

file:
    # Field minima and maxima
    # Time          min(U.air)      max(U.air)      min(U.water)    max(U.water)
    4.00061050e-01  0.00000000e+00  2.87015987e+01  0.00000000e+00  2.71025731e+01
    4.00134265e-01  0.00000000e+00  2.86505310e+01  0.00000000e+00  2.71134246e+01
    4.00222098e-01  0.00000000e+00  2.85937449e+01  0.00000000e+00  2.71255302e+01

With "location no;"

log:
    fieldMinMax fieldMinMax output:
        min(mag(U.air)) = 0 at location (-0.058373423 -0.15376628 0.021017389)
        max(mag(U.air)) = 28.701599 at location (-0.24002836 0.0053456235 3.8964638)
        min(mag(U.water)) = 0 at location (-0.058373423 -0.15376628 0.021017389)
        max(mag(U.water)) = 27.102573 at location (-0.24002836 0.0053456235 3.8964638)

file:
    # Field minima and maxima
    # Time          field           min             location(min)   max             location(max)
    4.00061050e-01  U.air           0.00000000e+00  (-5.83734226e-02 -1.53766281e-01 2.10173892e-02)        2.87015987e+01  (-2.40028359e-01 5.34562354e-03 3.89646377e+00)
    4.00061050e-01  U.water         0.00000000e+00  (-5.83734226e-02 -1.53766281e-01 2.10173892e-02)        2.71025731e+01  (-2.40028359e-01 5.34562354e-03 3.89646377e+00)
parent 52f22486
No related merge requests found
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,9 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "fieldMinMax.H"
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -66,6 +64,7 @@ Foam::fieldMinMax::fieldMinMax
obr_(obr),
active_(true),
log_(true),
location_(true),
mode_(mdMag),
fieldSet_()
{
......@@ -103,6 +102,7 @@ void Foam::fieldMinMax::read(const dictionary& dict)
if (active_)
{
log_ = dict.lookupOrDefault<Switch>("log", true);
location_ = dict.lookupOrDefault<Switch>("location", true);
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
dict.lookup("fields") >> fieldSet_;
......@@ -112,26 +112,41 @@ void Foam::fieldMinMax::read(const dictionary& dict)
void Foam::fieldMinMax::writeFileHeader(const label i)
{
writeHeader(file(), "Field minima and maxima");
writeCommented(file(), "Time");
writeTabbed(file(), "field");
writeTabbed(file(), "min");
writeTabbed(file(), "position(min)");
OFstream& file = this->file();
if (Pstream::parRun())
writeHeader(file, "Field minima and maxima");
writeCommented(file, "Time");
if (location_)
{
writeTabbed(file(), "processor");
}
writeTabbed(file, "field");
writeTabbed(file, "min");
writeTabbed(file, "location(min)");
writeTabbed(file(), "max");
writeTabbed(file(), "position(max)");
if (Pstream::parRun())
{
writeTabbed(file, "processor");
}
if (Pstream::parRun())
writeTabbed(file, "max");
writeTabbed(file, "location(max)");
if (Pstream::parRun())
{
writeTabbed(file, "processor");
}
}
else
{
writeTabbed(file(), "processor");
forAll(fieldSet_, fieldI)
{
writeTabbed(file, "min(" + fieldSet_[fieldI] + ')');
writeTabbed(file, "max(" + fieldSet_[fieldI] + ')');
}
}
file() << endl;
file<< endl;
}
......@@ -159,6 +174,11 @@ void Foam::fieldMinMax::write()
{
functionObjectFile::write();
if (!location_)
{
file()<< obr_.time().value();
}
Info(log_)<< type() << " " << name_ << " output:" << nl;
forAll(fieldSet_, fieldI)
......@@ -170,6 +190,11 @@ void Foam::fieldMinMax::write()
calcMinMaxFields<tensor>(fieldSet_[fieldI], mode_);
}
if (!location_)
{
file()<< endl;
}
Info(log_)<< endl;
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -28,7 +28,7 @@ Group
grpFieldFunctionObjects
Description
This function object calculates the value and position of scalar minimim
This function object calculates the value and location of scalar minimim
and maximum for a list of user-specified fields. For variables with a rank
greater than zero, either the min/max of a component value or the magnitude
is reported. When operating in parallel, the processor owning the value
......@@ -43,6 +43,7 @@ Description
...
write yes;
log yes;
location yes;
mode magnitude;
fields
(
......@@ -58,6 +59,7 @@ Description
type | type name: fieldMinMax | yes |
write | write min/max data to file | no | yes
log | write min/max data to standard output | no | no
location | write location of the min/max value | no | yes
mode | calculation mode: magnitude or component | no | magnitude
\endtable
......@@ -77,12 +79,8 @@ SourceFiles
#define fieldMinMax_H
#include "functionObjectFile.H"
#include "primitiveFieldsFwd.H"
#include "volFieldsFwd.H"
#include "HashSet.H"
#include "OFstream.H"
#include "Switch.H"
#include "NamedEnum.H"
#include "vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -130,6 +128,9 @@ protected:
//- Switch to send output to Info as well
Switch log_;
//- Switch to write location of min/max values
Switch location_;
//- Mode for min/max - only applicable for ranks > 0
modeType mode_;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,9 +25,6 @@ License
#include "fieldMinMax.H"
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -44,43 +41,57 @@ void Foam::fieldMinMax::output
const Type& maxValue
)
{
file()<< obr_.time().value();
writeTabbed(file(), fieldName);
OFstream& file = this->file();
file()
<< token::TAB << minValue
<< token::TAB << minC;
if (Pstream::parRun())
if (location_)
{
file()<< token::TAB << minProcI;
}
file<< obr_.time().value();
file()
<< token::TAB << maxValue
<< token::TAB << maxC;
writeTabbed(file, fieldName);
if (Pstream::parRun())
{
file()<< token::TAB << maxProcI;
}
file<< token::TAB << minValue
<< token::TAB << minC;
file() << endl;
if (Pstream::parRun())
{
file<< token::TAB << minProcI;
}
Info(log_)<< " min(" << outputName << ") = "
<< minValue << " at position " << minC;
file<< token::TAB << maxValue
<< token::TAB << maxC;
if (Pstream::parRun())
{
Info(log_)<< " on processor " << minProcI;
}
if (Pstream::parRun())
{
file<< token::TAB << maxProcI;
}
Info(log_)<< nl << " max(" << outputName << ") = "
<< maxValue << " at position " << maxC;
file<< endl;
if (Pstream::parRun())
Info(log_)
<< " min(" << outputName << ") = " << minValue
<< " at location " << minC;
if (Pstream::parRun())
{
Info(log_)<< " on processor " << minProcI;
}
Info(log_)
<< nl << " max(" << outputName << ") = " << maxValue
<< " at location " << maxC;
if (Pstream::parRun())
{
Info(log_)<< " on processor " << maxProcI;
}
}
else
{
Info(log_)<< " on processor " << maxProcI;
file<< token::TAB << minValue << token::TAB << maxValue;
Info(log_)
<< " min/max(" << outputName << ") = "
<< minValue << ' ' << maxValue;
}
Info(log_)<< endl;
......@@ -263,8 +274,7 @@ void Foam::fieldMinMax::calcMinMaxFields
"const word&, "
"const modeType&"
")"
)
<< "Unknown min/max mode: " << modeTypeNames_[mode_]
) << "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment