Commit b1800b8b authored by Andrew Heather's avatar Andrew Heather
Browse files

adding mag/component options

parent 3bb18253
......@@ -38,6 +38,18 @@ namespace Foam
}
template<>
const char* Foam::NamedEnum<Foam::fieldMinMax::modeType, 2>::names[] =
{
"magnitude",
"component"
};
const Foam::NamedEnum<Foam::fieldMinMax::modeType, 2>
Foam::fieldMinMax::modeTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldMinMax::fieldMinMax
......@@ -52,6 +64,7 @@ Foam::fieldMinMax::fieldMinMax
obr_(obr),
active_(true),
log_(false),
mode_(mdMag),
fieldSet_(),
fieldMinMaxFilePtr_(NULL)
{
......@@ -85,6 +98,7 @@ void Foam::fieldMinMax::read(const dictionary& dict)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
mode_ = modeTypeNames_[dict.lookup("mode")];
dict.lookup("fields") >> fieldSet_;
}
}
......@@ -176,13 +190,13 @@ void Foam::fieldMinMax::calcMinMaxFields<Foam::scalar>
{
if (obr_.foundObject<volScalarField>(fieldName))
{
const volScalarField& field =
obr_.lookupObject<volScalarField>(fieldName);
scalar minValue = min(field).value();
scalar maxValue = max(field).value();
if (Pstream::master())
{
const volScalarField& field =
obr_.lookupObject<volScalarField>(fieldName);
scalar minValue = min(field).value();
scalar maxValue = max(field).value();
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << endl;
......
......@@ -49,6 +49,7 @@ SourceFiles
#include "OFstream.H"
#include "Switch.H"
#include "pointFieldFwd.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -66,9 +67,18 @@ class mapPolyMesh;
class fieldMinMax
{
public:
enum modeType
{
mdMag,
mdCmpt
};
protected:
// Private data
// Protected data
//- Name of this set of forces,
// Also used as the name of the probes directory.
......@@ -82,11 +92,17 @@ protected:
//- Switch to send output to Info as well as to file
Switch log_;
//- Patches to integrate forces over
//- Mode type names
static const NamedEnum<modeType, 2> modeTypeNames_;
//- Mode for min/max - only applicable for ranks > 0
modeType mode_;
//- Fields to assess min/max
wordList fieldSet_;
//- Forces/moment file ptr
//- Min/max file ptr
autoPtr<OFstream> fieldMinMaxFilePtr_;
......
......@@ -38,21 +38,60 @@ void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
if (obr_.foundObject<fieldType>(fieldName))
{
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
scalar minValue = min(mag(field)).value();
scalar maxValue = max(mag(field)).value();
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << endl;
if (log_)
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
switch (mode_)
{
Info<< "fieldMinMax output:" << nl
<< " min(mag(" << fieldName << ")) = " << minValue << nl
<< " max(mag(" << fieldName << ")) = " << maxValue << nl
<< endl;
case mdMag:
{
scalar minValue = min(mag(field)).value();
scalar maxValue = max(mag(field)).value();
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue
<< endl;
if (log_)
{
Info<< "fieldMinMax output:" << nl
<< " min(mag(" << fieldName << ")) = "
<< minValue << nl
<< " max(mag(" << fieldName << ")) = "
<< maxValue << nl
<< endl;
}
break;
}
case mdCmpt:
{
Type minValue = min(field).value();
Type maxValue = max(field).value();
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue
<< endl;
if (log_)
{
Info<< "fieldMinMax output:" << nl
<< " cmptMin(" << fieldName << ") = "
<< minValue << nl
<< " cmptMax(" << fieldName << ") = "
<< maxValue << nl
<< endl;
}
break;
}
default:
{
FatalErrorIn
(
"Foam::fieldMinMax::calcMinMaxFields"
"(const word& fieldName)"
)<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
}
}
}
......
Supports Markdown
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