mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fieldMinMax FO updated following update to use functionObjectState
Properties stored in state dictionary: - minimum value: min<identifier> - position of minimum value: min<identifier>_position - processor ID of minimum value: min<identifier>_processor - maximum value: max<identifier> - position of maximum value: max<identifier>_position - processor ID of maximum value: max<identifier>_processor
This commit is contained in:
@ -98,32 +98,16 @@ Foam::fieldMinMax::fieldMinMax
|
|||||||
const bool loadFromFiles
|
const bool loadFromFiles
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
|
functionObjectState(obr, name),
|
||||||
functionObjectFile(obr, name, typeName, dict),
|
functionObjectFile(obr, name, typeName, dict),
|
||||||
obr_(obr),
|
obr_(obr),
|
||||||
active_(true),
|
|
||||||
log_(true),
|
log_(true),
|
||||||
writeLocation_(true),
|
writeLocation_(true),
|
||||||
mode_(mdMag),
|
mode_(mdMag),
|
||||||
fieldSet_()
|
fieldSet_()
|
||||||
{
|
{
|
||||||
// Check if the available mesh is an fvMesh otherise deactivate
|
// Check if the available mesh is an fvMesh otherise deactivate
|
||||||
if (!isA<fvMesh>(obr_))
|
if (setActive<fvMesh>())
|
||||||
{
|
|
||||||
active_ = false;
|
|
||||||
WarningIn
|
|
||||||
(
|
|
||||||
"fieldMinMax::fieldMinMax"
|
|
||||||
"("
|
|
||||||
"const word&, "
|
|
||||||
"const objectRegistry&, "
|
|
||||||
"const dictionary&, "
|
|
||||||
"const bool"
|
|
||||||
")"
|
|
||||||
) << "No fvMesh available, deactivating " << name_
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (active_)
|
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
writeFileHeader(file());
|
writeFileHeader(file());
|
||||||
|
|||||||
@ -43,13 +43,9 @@ Description
|
|||||||
...
|
...
|
||||||
writeToFile yes;
|
writeToFile yes;
|
||||||
log yes;
|
log yes;
|
||||||
location yes;
|
writeLocation yes;
|
||||||
mode magnitude;
|
mode magnitude;
|
||||||
fields
|
fields (U p);
|
||||||
(
|
|
||||||
U
|
|
||||||
p
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
@ -59,7 +55,7 @@ Description
|
|||||||
type | type name: fieldMinMax | yes |
|
type | type name: fieldMinMax | yes |
|
||||||
writeToFile | 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 | yes
|
log | write min/max data to standard output | no | yes
|
||||||
location | write location of the min/max value | no | yes
|
writeLocation | 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 |
|
fields | list of fields to process | yes |
|
||||||
\endtable
|
\endtable
|
||||||
@ -69,6 +65,7 @@ Description
|
|||||||
SeeAlso
|
SeeAlso
|
||||||
Foam::functionObject
|
Foam::functionObject
|
||||||
Foam::functionObjectFile
|
Foam::functionObjectFile
|
||||||
|
Foam::functionObjectState
|
||||||
Foam::OutputFilterFunctionObject
|
Foam::OutputFilterFunctionObject
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
@ -81,8 +78,10 @@ SourceFiles
|
|||||||
#ifndef fieldMinMax_H
|
#ifndef fieldMinMax_H
|
||||||
#define fieldMinMax_H
|
#define fieldMinMax_H
|
||||||
|
|
||||||
|
#include "functionObjectState.H"
|
||||||
#include "functionObjectFile.H"
|
#include "functionObjectFile.H"
|
||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
|
#include "NamedEnum.H"
|
||||||
#include "vector.H"
|
#include "vector.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -102,16 +101,20 @@ class mapPolyMesh;
|
|||||||
|
|
||||||
class fieldMinMax
|
class fieldMinMax
|
||||||
:
|
:
|
||||||
|
public functionObjectState,
|
||||||
public functionObjectFile
|
public functionObjectFile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Public enumerations
|
||||||
|
|
||||||
enum modeType
|
enum modeType
|
||||||
{
|
{
|
||||||
mdMag, // magnitude
|
mdMag, // magnitude
|
||||||
mdCmpt // component
|
mdCmpt // component
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected data
|
// Protected data
|
||||||
@ -119,16 +122,10 @@ protected:
|
|||||||
//- Mode type names
|
//- Mode type names
|
||||||
static const NamedEnum<modeType, 2> modeTypeNames_;
|
static const NamedEnum<modeType, 2> modeTypeNames_;
|
||||||
|
|
||||||
//- Name of this set of field min/max
|
//- Reference to the database
|
||||||
// Also used as the name of the output directory
|
|
||||||
word name_;
|
|
||||||
|
|
||||||
const objectRegistry& obr_;
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
//- On/off switch
|
//- Switch to send output to Info as well
|
||||||
bool active_;
|
|
||||||
|
|
||||||
//- 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
|
||||||
@ -193,12 +190,6 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return name of the set of field min/max
|
|
||||||
virtual const word& name() const
|
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Read the field min/max data
|
//- Read the field min/max data
|
||||||
virtual void read(const dictionary&);
|
virtual void read(const dictionary&);
|
||||||
|
|
||||||
|
|||||||
@ -95,6 +95,15 @@ void Foam::fieldMinMax::output
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (log_) Info<< endl;
|
if (log_) Info<< endl;
|
||||||
|
|
||||||
|
// Write state/results information
|
||||||
|
word nameStr('(' + outputName + ')');
|
||||||
|
this->setResult("min" + nameStr, minValue);
|
||||||
|
this->setResult("min" + nameStr + "_position", minC);
|
||||||
|
this->setResult("min" + nameStr + "_processor", minProcI);
|
||||||
|
this->setResult("max" + nameStr, maxValue);
|
||||||
|
this->setResult("max" + nameStr + "_position", maxC);
|
||||||
|
this->setResult("max" + nameStr + "_processor", maxProcI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,13 +172,15 @@ void Foam::fieldMinMax::calcMinMaxFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pstream::gatherList(minVs);
|
Pstream::gatherList(minVs);
|
||||||
|
Pstream::scatterList(minVs);
|
||||||
Pstream::gatherList(minCs);
|
Pstream::gatherList(minCs);
|
||||||
|
Pstream::scatterList(minCs);
|
||||||
|
|
||||||
Pstream::gatherList(maxVs);
|
Pstream::gatherList(maxVs);
|
||||||
|
Pstream::scatterList(maxVs);
|
||||||
Pstream::gatherList(maxCs);
|
Pstream::gatherList(maxCs);
|
||||||
|
Pstream::scatterList(maxCs);
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
label minI = findMin(minVs);
|
label minI = findMin(minVs);
|
||||||
scalar minValue = minVs[minI];
|
scalar minValue = minVs[minI];
|
||||||
const vector& minC = minCs[minI];
|
const vector& minC = minCs[minI];
|
||||||
@ -189,7 +200,6 @@ void Foam::fieldMinMax::calcMinMaxFields
|
|||||||
minValue,
|
minValue,
|
||||||
maxValue
|
maxValue
|
||||||
);
|
);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case mdCmpt:
|
case mdCmpt:
|
||||||
@ -236,13 +246,15 @@ void Foam::fieldMinMax::calcMinMaxFields
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pstream::gatherList(minVs);
|
Pstream::gatherList(minVs);
|
||||||
|
Pstream::scatterList(minVs);
|
||||||
Pstream::gatherList(minCs);
|
Pstream::gatherList(minCs);
|
||||||
|
Pstream::scatterList(minCs);
|
||||||
|
|
||||||
Pstream::gatherList(maxVs);
|
Pstream::gatherList(maxVs);
|
||||||
|
Pstream::scatterList(maxVs);
|
||||||
Pstream::gatherList(maxCs);
|
Pstream::gatherList(maxCs);
|
||||||
|
Pstream::scatterList(maxCs);
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
label minI = findMin(minVs);
|
label minI = findMin(minVs);
|
||||||
Type minValue = minVs[minI];
|
Type minValue = minVs[minI];
|
||||||
const vector& minC = minCs[minI];
|
const vector& minC = minCs[minI];
|
||||||
@ -262,7 +274,6 @@ void Foam::fieldMinMax::calcMinMaxFields
|
|||||||
minValue,
|
minValue,
|
||||||
maxValue
|
maxValue
|
||||||
);
|
);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -274,7 +285,8 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user