diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C index d13ae8d791..cc01c6696d 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -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("log", true); + location_ = dict.lookupOrDefault("location", true); mode_ = modeTypeNames_[dict.lookupOrDefault("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)"); + + if (Pstream::parRun()) + { + writeTabbed(file, "processor"); + } + + writeTabbed(file, "max"); + writeTabbed(file, "location(max)"); + + if (Pstream::parRun()) + { + writeTabbed(file, "processor"); + } + } + else + { + forAll(fieldSet_, fieldI) + { + writeTabbed(file, "min(" + fieldSet_[fieldI] + ')'); + writeTabbed(file, "max(" + fieldSet_[fieldI] + ')'); + } } - writeTabbed(file(), "max"); - writeTabbed(file(), "position(max)"); - - if (Pstream::parRun()) - { - writeTabbed(file(), "processor"); - } - - 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(fieldSet_[fieldI], mode_); } + if (!location_) + { + file()<< endl; + } + Info(log_)<< endl; } } diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H index 361420da07..b2246eb9b1 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H @@ -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_; diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C index a8477d8d50..42da3d3c1b 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C @@ -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(); + + writeTabbed(file, fieldName); + + file<< token::TAB << minValue + << token::TAB << minC; + + if (Pstream::parRun()) + { + file<< token::TAB << minProcI; + } + + file<< token::TAB << maxValue + << token::TAB << maxC; + + if (Pstream::parRun()) + { + file<< token::TAB << maxProcI; + } + + file<< endl; + + 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; + } } - - file() - << token::TAB << maxValue - << token::TAB << maxC; - - if (Pstream::parRun()) + else { - file()<< token::TAB << maxProcI; - } + file<< token::TAB << minValue << token::TAB << maxValue; - file() << endl; - - Info(log_)<< " min(" << outputName << ") = " - << minValue << " at position " << minC; - - if (Pstream::parRun()) - { - Info(log_)<< " on processor " << minProcI; - } - - Info(log_)<< nl << " max(" << outputName << ") = " - << maxValue << " at position " << maxC; - - if (Pstream::parRun()) - { - Info(log_)<< " on processor " << maxProcI; + 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); } }