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