mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
- Avoids the need for the 'OutputFilterFunctionObject' wrapper
- Time-control for execution and writing is now provided by the
'timeControlFunctionObject' which instantiates the processing
'functionObject' and controls its operation.
- Alternative time-control functionObjects can now be written and
selected at run-time without the need to compile wrapped version of
EVERY existing functionObject which would have been required in the
old structure.
- The separation of 'execute' and 'write' functions is now formalized in the
'functionObject' base-class and all derived classes implement the
two functions.
- Unnecessary implementations of functions with appropriate defaults
in the 'functionObject' base-class have been removed reducing
clutter and simplifying implementation of new functionObjects.
- The 'coded' 'functionObject' has also been updated, simplified and tested.
- Further simplification is now possible by creating some general
intermediate classes derived from 'functionObject'.
174 lines
4.4 KiB
C
174 lines
4.4 KiB
C
/*---------------------------------------------------------------------------*\
|
|
========= |
|
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
\\ / O peration |
|
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
\\/ M anipulation |
|
|
-------------------------------------------------------------------------------
|
|
License
|
|
This file is part of OpenFOAM.
|
|
|
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "fieldMinMax.H"
|
|
#include "fieldTypes.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
|
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
namespace functionObjects
|
|
{
|
|
defineTypeNameAndDebug(fieldMinMax, 0);
|
|
addToRunTimeSelectionTable(functionObject, fieldMinMax, dictionary);
|
|
}
|
|
}
|
|
|
|
template<>
|
|
const char* Foam::NamedEnum
|
|
<
|
|
Foam::functionObjects::fieldMinMax::modeType,
|
|
2
|
|
>::names[] = {"magnitude", "component"};
|
|
|
|
const Foam::NamedEnum
|
|
<
|
|
Foam::functionObjects::fieldMinMax::modeType,
|
|
2
|
|
> Foam::functionObjects::fieldMinMax::modeTypeNames_;
|
|
|
|
|
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
|
|
void Foam::functionObjects::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;
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
Foam::functionObjects::fieldMinMax::fieldMinMax
|
|
(
|
|
const word& name,
|
|
const Time& runTime,
|
|
const dictionary& dict
|
|
)
|
|
:
|
|
writeFiles(name, runTime, dict, name),
|
|
location_(true),
|
|
mode_(mdMag),
|
|
fieldSet_()
|
|
{
|
|
if (!isA<fvMesh>(obr_))
|
|
{
|
|
FatalErrorInFunction
|
|
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
|
}
|
|
|
|
read(dict);
|
|
resetName(typeName);
|
|
}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
|
|
Foam::functionObjects::fieldMinMax::~fieldMinMax()
|
|
{}
|
|
|
|
|
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
|
|
bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
|
|
{
|
|
writeFiles::read(dict);
|
|
|
|
location_ = dict.lookupOrDefault<Switch>("location", true);
|
|
|
|
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
|
|
dict.lookup("fields") >> fieldSet_;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
bool Foam::functionObjects::fieldMinMax::execute(const bool postProcess)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
|
|
bool Foam::functionObjects::fieldMinMax::write(const bool postProcess)
|
|
{
|
|
writeFiles::write();
|
|
|
|
if (!location_) writeTime(file());
|
|
if (log_) Info<< type() << " " << name() << " output:" << nl;
|
|
|
|
forAll(fieldSet_, fieldi)
|
|
{
|
|
calcMinMaxFields<scalar>(fieldSet_[fieldi], mdCmpt);
|
|
calcMinMaxFields<vector>(fieldSet_[fieldi], mode_);
|
|
calcMinMaxFields<sphericalTensor>(fieldSet_[fieldi], mode_);
|
|
calcMinMaxFields<symmTensor>(fieldSet_[fieldi], mode_);
|
|
calcMinMaxFields<tensor>(fieldSet_[fieldi], mode_);
|
|
}
|
|
|
|
if (!location_) file()<< endl;
|
|
if (log_) Info<< endl;
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
// ************************************************************************* //
|