mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fieldMinMax FO updated follwing changes to functionObjectFile
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,6 +49,45 @@ const Foam::NamedEnum<Foam::fieldMinMax::modeType, 2>
|
||||
Foam::fieldMinMax::modeTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldMinMax::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(os, "Field minima and maxima");
|
||||
writeCommented(os, "Time");
|
||||
|
||||
if (writeLocation_)
|
||||
{
|
||||
writeTabbed(os, "field");
|
||||
writeTabbed(os, "min");
|
||||
writeTabbed(os, "position(min)");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(os, "processor");
|
||||
}
|
||||
|
||||
writeTabbed(os, "max");
|
||||
writeTabbed(os, "position(max)");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(os, "processor");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(fieldSet_, fieldI)
|
||||
{
|
||||
writeTabbed(os, "min(" + fieldSet_[fieldI] + ')');
|
||||
writeTabbed(os, "max(" + fieldSet_[fieldI] + ')');
|
||||
}
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldMinMax::fieldMinMax
|
||||
@ -59,12 +98,11 @@ Foam::fieldMinMax::fieldMinMax
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
functionObjectFile(obr, name, typeName, dict),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(true),
|
||||
location_(true),
|
||||
writeLocation_(true),
|
||||
mode_(mdMag),
|
||||
fieldSet_()
|
||||
{
|
||||
@ -85,7 +123,11 @@ Foam::fieldMinMax::fieldMinMax
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
if (active_)
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -101,8 +143,10 @@ void Foam::fieldMinMax::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
location_ = dict.lookupOrDefault<Switch>("location", true);
|
||||
writeLocation_ = dict.lookupOrDefault<Switch>("writeLocation", true);
|
||||
|
||||
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
@ -110,46 +154,6 @@ void Foam::fieldMinMax::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldMinMax::writeFileHeader(const label i)
|
||||
{
|
||||
OFstream& file = this->file();
|
||||
|
||||
writeHeader(file, "Field minima and maxima");
|
||||
writeCommented(file, "Time");
|
||||
|
||||
if (location_)
|
||||
{
|
||||
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] + ')');
|
||||
}
|
||||
}
|
||||
|
||||
file<< endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldMinMax::execute()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
@ -172,9 +176,7 @@ void Foam::fieldMinMax::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
if (!location_) file()<< obr_.time().value();
|
||||
if (!writeLocation_) file()<< obr_.time().value();
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
forAll(fieldSet_, fieldI)
|
||||
@ -186,7 +188,7 @@ void Foam::fieldMinMax::write()
|
||||
calcMinMaxFields<tensor>(fieldSet_[fieldI], mode_);
|
||||
}
|
||||
|
||||
if (!location_) file()<< endl;
|
||||
if (!writeLocation_) file()<< endl;
|
||||
if (log_) Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates the value and location of scalar minimim
|
||||
This function object calculates the value and position 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
|
||||
@ -41,7 +41,7 @@ Description
|
||||
type fieldMinMax;
|
||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
write yes;
|
||||
writeToFile yes;
|
||||
log yes;
|
||||
location yes;
|
||||
mode magnitude;
|
||||
@ -57,20 +57,23 @@ Description
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldMinMax | yes |
|
||||
write | write min/max data to file | no | yes
|
||||
log | write min/max data to standard output | no | no
|
||||
writeToFile | write min/max data to file | no | yes
|
||||
log | write min/max data to standard output | no | yes
|
||||
location | write location of the min/max value | no | yes
|
||||
mode | calculation mode: magnitude or component | no | magnitude
|
||||
fields | list of fields to process | yes |
|
||||
\endtable
|
||||
|
||||
Output data is written to the file \<timeDir\>/fieldMinMax.dat
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjectFile
|
||||
Foam::OutputFilterFunctionObject
|
||||
|
||||
SourceFiles
|
||||
fieldMinMax.C
|
||||
fieldMinMaxTemplates.C
|
||||
IOfieldMinMax.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -105,8 +108,8 @@ public:
|
||||
|
||||
enum modeType
|
||||
{
|
||||
mdMag,
|
||||
mdCmpt
|
||||
mdMag, // magnitude
|
||||
mdCmpt // component
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -122,14 +125,14 @@ protected:
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well
|
||||
//- Switch to send output to Info as well as file
|
||||
Switch log_;
|
||||
|
||||
//- Switch to write location of min/max values
|
||||
Switch location_;
|
||||
Switch writeLocation_;
|
||||
|
||||
//- Mode for min/max - only applicable for ranks > 0
|
||||
modeType mode_;
|
||||
@ -154,15 +157,16 @@ protected:
|
||||
const Type& maxValue
|
||||
);
|
||||
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldMinMax(const fieldMinMax&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fieldMinMax&);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,7 +43,7 @@ void Foam::fieldMinMax::output
|
||||
{
|
||||
OFstream& file = this->file();
|
||||
|
||||
if (location_)
|
||||
if (writeLocation_)
|
||||
{
|
||||
file<< obr_.time().value();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user