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