Skip to content
Snippets Groups Projects
Commit 7fa77e9c authored by Andrew Heather's avatar Andrew Heather
Browse files

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
parent bf041156
Branches
Tags
1 merge request!5Feature function objects
......@@ -98,32 +98,16 @@ Foam::fieldMinMax::fieldMinMax
const bool loadFromFiles
)
:
functionObjectState(obr, name),
functionObjectFile(obr, name, typeName, dict),
obr_(obr),
active_(true),
log_(true),
writeLocation_(true),
mode_(mdMag),
fieldSet_()
{
// Check if the available mesh is an fvMesh otherise deactivate
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningIn
(
"fieldMinMax::fieldMinMax"
"("
"const word&, "
"const objectRegistry&, "
"const dictionary&, "
"const bool"
")"
) << "No fvMesh available, deactivating " << name_
<< endl;
}
if (active_)
if (setActive<fvMesh>())
{
read(dict);
writeFileHeader(file());
......
......@@ -43,13 +43,9 @@ Description
...
writeToFile yes;
log yes;
location yes;
writeLocation yes;
mode magnitude;
fields
(
U
p
);
fields (U p);
}
\endverbatim
......@@ -59,7 +55,7 @@ Description
type | type name: fieldMinMax | yes |
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
writeLocation | 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
......@@ -69,6 +65,7 @@ Description
SeeAlso
Foam::functionObject
Foam::functionObjectFile
Foam::functionObjectState
Foam::OutputFilterFunctionObject
SourceFiles
......@@ -81,8 +78,10 @@ SourceFiles
#ifndef fieldMinMax_H
#define fieldMinMax_H
#include "functionObjectState.H"
#include "functionObjectFile.H"
#include "Switch.H"
#include "NamedEnum.H"
#include "vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -97,20 +96,24 @@ class polyMesh;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class fieldMinMax Declaration
Class fieldMinMax Declaration
\*---------------------------------------------------------------------------*/
class fieldMinMax
:
public functionObjectState,
public functionObjectFile
{
public:
enum modeType
{
mdMag, // magnitude
mdCmpt // component
};
// Public enumerations
enum modeType
{
mdMag, // magnitude
mdCmpt // component
};
protected:
......@@ -119,16 +122,10 @@ protected:
//- Mode type names
static const NamedEnum<modeType, 2> modeTypeNames_;
//- Name of this set of field min/max
// Also used as the name of the output directory
word name_;
//- Reference to the database
const objectRegistry& obr_;
//- On/off switch
bool active_;
//- Switch to send output to Info as well as file
//- Switch to send output to Info as well
Switch log_;
//- Switch to write location of min/max values
......@@ -193,12 +190,6 @@ public:
// Member Functions
//- Return name of the set of field min/max
virtual const word& name() const
{
return name_;
}
//- Read the field min/max data
virtual void read(const dictionary&);
......
......@@ -95,6 +95,15 @@ void Foam::fieldMinMax::output
}
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,33 +172,34 @@ void Foam::fieldMinMax::calcMinMaxFields
}
Pstream::gatherList(minVs);
Pstream::scatterList(minVs);
Pstream::gatherList(minCs);
Pstream::scatterList(minCs);
Pstream::gatherList(maxVs);
Pstream::scatterList(maxVs);
Pstream::gatherList(maxCs);
Pstream::scatterList(maxCs);
if (Pstream::master())
{
label minI = findMin(minVs);
scalar minValue = minVs[minI];
const vector& minC = minCs[minI];
label maxI = findMax(maxVs);
scalar maxValue = maxVs[maxI];
const vector& maxC = maxCs[maxI];
output
(
fieldName,
word("mag(" + fieldName + ")"),
minC,
maxC,
minI,
maxI,
minValue,
maxValue
);
}
label minI = findMin(minVs);
scalar minValue = minVs[minI];
const vector& minC = minCs[minI];
label maxI = findMax(maxVs);
scalar maxValue = maxVs[maxI];
const vector& maxC = maxCs[maxI];
output
(
fieldName,
word("mag(" + fieldName + ")"),
minC,
maxC,
minI,
maxI,
minValue,
maxValue
);
break;
}
case mdCmpt:
......@@ -236,33 +246,34 @@ void Foam::fieldMinMax::calcMinMaxFields
}
Pstream::gatherList(minVs);
Pstream::scatterList(minVs);
Pstream::gatherList(minCs);
Pstream::scatterList(minCs);
Pstream::gatherList(maxVs);
Pstream::scatterList(maxVs);
Pstream::gatherList(maxCs);
Pstream::scatterList(maxCs);
if (Pstream::master())
{
label minI = findMin(minVs);
Type minValue = minVs[minI];
const vector& minC = minCs[minI];
label maxI = findMax(maxVs);
Type maxValue = maxVs[maxI];
const vector& maxC = maxCs[maxI];
output
(
fieldName,
fieldName,
minC,
maxC,
minI,
maxI,
minValue,
maxValue
);
}
label minI = findMin(minVs);
Type minValue = minVs[minI];
const vector& minC = minCs[minI];
label maxI = findMax(maxVs);
Type maxValue = maxVs[maxI];
const vector& maxC = maxCs[maxI];
output
(
fieldName,
fieldName,
minC,
maxC,
minI,
maxI,
minValue,
maxValue
);
break;
}
default:
......@@ -274,7 +285,8 @@ void Foam::fieldMinMax::calcMinMaxFields
"const word&, "
"const modeType&"
")"
) << "Unknown min/max mode: " << modeTypeNames_[mode_]
)
<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment