moved field-related function objects to field subfolder

This commit is contained in:
andy
2009-01-13 17:29:54 +00:00
parent 34c3702f1e
commit 654f844386
21 changed files with 73 additions and 81 deletions

View File

@ -0,0 +1,9 @@
fieldAverage/fieldAverage/fieldAverage.C
fieldAverage/fieldAverageItem/fieldAverageItem.C
fieldAverage/fieldAverageItem/fieldAverageItemIO.C
fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C
fieldMinMax/fieldMinMax.C
fieldMinMax/fieldMinMaxFunctionObject.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects

View File

@ -0,0 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-lsampling

View File

@ -0,0 +1,76 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application oodles;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 0.1;
deltaT 1e-05;
writeControl timeStep;
writeInterval 10;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
functions
(
fieldAverage1
{
// Type of functionObject
type fieldAverage;
// Where to load it from (if not already in solver)
functionObjectLibs ("libfieldAverage.so");
// Fields to be averaged - runTime modifiable
fields
(
U
{
mean on;
prime2Mean on;
base time;
}
p
{
mean on;
prime2Mean on;
base time;
}
);
}
);
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::IOfieldAverage
Description
Instance of the generic IOOutputFilter for fieldAverage.
\*---------------------------------------------------------------------------*/
#ifndef IOfieldAverage_H
#define IOfieldAverage_H
#include "fieldAverage.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<fieldAverage> IOFieldAverage;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,384 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldAverage.H"
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
#include "IFstream.H"
#include "OFstream.H"
#include "fieldAverageItem.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(fieldAverage, 0);
}
const Foam::word Foam::fieldAverage::EXT_MEAN = "Mean";
const Foam::word Foam::fieldAverage::EXT_PRIME2MEAN = "Prime2Mean";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::fieldAverage::resetLists(const label nItems)
{
meanScalarFields_.clear();
meanScalarFields_.setSize(nItems);
meanVectorFields_.clear();
meanVectorFields_.setSize(nItems);
meanSphericalTensorFields_.clear();
meanSphericalTensorFields_.setSize(nItems);
meanSymmTensorFields_.clear();
meanSymmTensorFields_.setSize(nItems);
meanTensorFields_.clear();
meanTensorFields_.setSize(nItems);
prime2MeanScalarFields_.clear();
prime2MeanScalarFields_.setSize(nItems);
prime2MeanSymmTensorFields_.clear();
prime2MeanSymmTensorFields_.setSize(nItems);
totalIter_.clear();
totalIter_.setSize(nItems, 1);
totalTime_.clear();
totalTime_.setSize(nItems, obr_.time().deltaT().value());
}
void Foam::fieldAverage::initialise()
{
// Add mean fields to the field lists
forAll(faItems_, i)
{
const word fieldName = faItems_[i].fieldName();
if (obr_.foundObject<volScalarField>(fieldName))
{
addMeanField<scalar>(i, meanScalarFields_);
}
else if (obr_.foundObject<volVectorField>(fieldName))
{
addMeanField<vector>(i, meanVectorFields_);
}
else if (obr_.foundObject<volSphericalTensorField>(fieldName))
{
addMeanField<sphericalTensor>(i, meanSphericalTensorFields_);
}
else if (obr_.foundObject<volSymmTensorField>(fieldName))
{
addMeanField<symmTensor>(i, meanSymmTensorFields_);
}
else if (obr_.foundObject<volTensorField>(fieldName))
{
addMeanField<tensor>(i, meanTensorFields_);
}
else
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "Requested field " << faItems_[i].fieldName()
<< " does not exist in the database" << nl
<< exit(FatalError);
}
}
// Add prime-squared mean fields to the field lists
forAll(faItems_, i)
{
if (faItems_[i].prime2Mean())
{
const word fieldName = faItems_[i].fieldName();
if (!faItems_[i].mean())
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "To calculate the prime-squared average, the "
<< "mean average must also be selected for field "
<< fieldName << nl << exit(FatalError);
}
if (obr_.foundObject<volScalarField>(fieldName))
{
addPrime2MeanField<scalar>
(
i,
meanScalarFields_,
prime2MeanScalarFields_
);
}
else if (obr_.foundObject<volVectorField>(fieldName))
{
addPrime2MeanField<vector>
(
i,
meanVectorFields_,
prime2MeanSymmTensorFields_
);
}
else
{
FatalErrorIn("Foam::fieldAverage::initialise()")
<< "prime2Mean average can only be applied to "
<< "volScalarFields and volVectorFields"
<< nl << " Field: " << fieldName << nl
<< exit(FatalError);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverage::fieldAverage
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
name_(name),
obr_(obr),
active_(true),
cleanRestart_(dict.lookupOrDefault<Switch>("cleanRestart", false)),
faItems_(dict.lookup("fields")),
meanScalarFields_(faItems_.size()),
meanVectorFields_(faItems_.size()),
meanSphericalTensorFields_(faItems_.size()),
meanSymmTensorFields_(faItems_.size()),
meanTensorFields_(faItems_.size()),
prime2MeanScalarFields_(faItems_.size()),
prime2MeanSymmTensorFields_(faItems_.size()),
totalIter_(faItems_.size(), 1),
totalTime_(faItems_.size(), obr_.time().deltaT().value())
{
// Check if the available mesh is an fvMesh otherise deactivate
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningIn
(
"fieldAverage::fieldAverage"
"("
"const word&,"
"const objectRegistry&,"
"const dictionary&,"
"const bool"
")"
) << "No fvMesh available, deactivating."
<< nl << endl;
}
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldAverage::~fieldAverage()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldAverage::read(const dictionary& dict)
{
if (active_)
{
faItems_.clear();
faItems_ = List<fieldAverageItem>(dict.lookup("fields"));
resetLists(faItems_.size());
initialise();
readAveragingProperties();
}
}
void Foam::fieldAverage::execute()
{
if (active_)
{
calcAverages();
}
}
void Foam::fieldAverage::write()
{
if (active_)
{
writeAverages();
writeAveragingProperties();
}
}
void Foam::fieldAverage::calcAverages()
{
Info<< "Calculating averages" << nl << endl;
forAll(faItems_, i)
{
totalIter_[i]++;
totalTime_[i] += obr_.time().deltaT().value();
}
addMeanSqrToPrime2Mean<scalar>
(
meanScalarFields_,
prime2MeanScalarFields_
);
addMeanSqrToPrime2Mean<vector>
(
meanVectorFields_,
prime2MeanSymmTensorFields_
);
calculateMeanFields<scalar>(meanScalarFields_);
calculateMeanFields<vector>(meanVectorFields_);
calculateMeanFields<sphericalTensor>(meanSphericalTensorFields_);
calculateMeanFields<symmTensor>(meanSymmTensorFields_);
calculateMeanFields<tensor>(meanTensorFields_);
calculatePrime2MeanFields<scalar>
(
meanScalarFields_,
prime2MeanScalarFields_
);
calculatePrime2MeanFields<vector>
(
meanVectorFields_,
prime2MeanSymmTensorFields_
);
}
void Foam::fieldAverage::writeAverages() const
{
writeFieldList<scalar>(meanScalarFields_);
writeFieldList<vector>(meanVectorFields_);
writeFieldList<sphericalTensor>(meanSphericalTensorFields_);
writeFieldList<symmTensor>(meanSymmTensorFields_);
writeFieldList<tensor>(meanTensorFields_);
writeFieldList<scalar>(prime2MeanScalarFields_);
writeFieldList<symmTensor>(prime2MeanSymmTensorFields_);
}
void Foam::fieldAverage::writeAveragingProperties() const
{
IOdictionary propsDict
(
IOobject
(
"fieldAveragingProperties",
obr_.time().timeName(),
"uniform",
obr_,
IOobject::NO_READ,
IOobject::NO_WRITE
)
);
forAll(faItems_, i)
{
const word fieldName = faItems_[i].fieldName();
propsDict.add(fieldName, dictionary());
propsDict.subDict(fieldName).add("totalIter", totalIter_[i]);
propsDict.subDict(fieldName).add("totalTime", totalTime_[i]);
}
propsDict.regIOobject::write();
}
void Foam::fieldAverage::readAveragingProperties()
{
if (cleanRestart_)
{
Info<< "fieldAverage: starting averaging at time "
<< obr_.time().timeName() << nl << endl;
}
else
{
IFstream propsFile
(
obr_.time().path()/obr_.time().timeName()
/"uniform"/"fieldAveragingProperties"
);
if (!propsFile.good())
{
Info<< "fieldAverage: starting averaging at time "
<< obr_.time().timeName() << nl << endl;
return;
}
dictionary propsDict(dictionary::null, propsFile);
Info<< "fieldAverage: restarting averaging for fields:" << endl;
forAll(faItems_, i)
{
const word& fieldName = faItems_[i].fieldName();
if (propsDict.found(fieldName))
{
dictionary fieldDict(propsDict.subDict(fieldName));
totalIter_[i] = readLabel(fieldDict.lookup("totalIter"));
totalTime_[i] = readScalar(fieldDict.lookup("totalTime"));
Info<< " " << fieldName
<< " iters = " << totalIter_[i]
<< " time = " << totalTime_[i] << endl;
}
}
Info<< endl;
}
}
void Foam::fieldAverage::updateMesh(const mapPolyMesh&)
{
// Do nothing
}
void Foam::fieldAverage::movePoints(const pointField&)
{
// Do nothing
}
// ************************************************************************* //

View File

@ -0,0 +1,312 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fieldAverage
Description
Calculates the field averages given list of fieldAverageItems, e.g.
@verbatim
fieldAverage1
{
// Type of functionObject
type fieldAverage;
// Where to load it from (if not already in solver)
functionObjectLibs ("libfieldAverage.so");
// Whether to perform a clean restart, or start from previous
// averaging info if available
cleanRestart true;
// Fields to be probed. runTime modifiable!
fields
(
U
{
mean on;
prime2Mean on;
base time;
}
p
{
mean on;
prime2Mean on;
base time;
}
);
@endverbatim
Member function calcAverages() calculates the averages.
Member function fieldAverage::write() calls calcAverages(). Average
field names are constructed by concatenating the base field with the
averaging type, e.g.
- base field, U
- arithmetic mean field, UMean
- prime-squared field, UPrime2Mean
Information regarding the number of averaging steps, and total averaging
time are written on a (base) per-field basis to the
fieldAveragingProperties dictionary, located in \<time\>/uniform
SourceFiles
fieldAverage.C
fieldAverageTemplates.C
IOfieldAverage.H
\*---------------------------------------------------------------------------*/
#ifndef fieldAverage_H
#define fieldAverage_H
#include "volFieldsFwd.H"
#include "pointFieldFwd.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class fieldAverageItem;
class OFstream;
template<class Type>
class List;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class fieldAverage Declaration
\*---------------------------------------------------------------------------*/
class fieldAverage
{
protected:
// Private data
//- Name of this set of field averages.
word name_;
//- Database this class is registered to
const objectRegistry& obr_;
//- On/off switch
bool active_;
//- Clean restart flag
Switch cleanRestart_;
//- List of field average items, describing waht averages to be
// calculated and output
List<fieldAverageItem> faItems_;
// File and field name extensions
//- Mean average
static const word EXT_MEAN;
//- Prime-squared average
static const word EXT_PRIME2MEAN;
// Lists of averages
// Arithmetic mean fields
PtrList<volScalarField> meanScalarFields_;
PtrList<volVectorField> meanVectorFields_;
PtrList<volSphericalTensorField> meanSphericalTensorFields_;
PtrList<volSymmTensorField> meanSymmTensorFields_;
PtrList<volTensorField> meanTensorFields_;
// Prime-squared fields - applicable to volVectorFields only
PtrList<volScalarField> prime2MeanScalarFields_;
PtrList<volSymmTensorField> prime2MeanSymmTensorFields_;
// Counters
//- Iteration steps counter
List<label> totalIter_;
//- Total time counter
List<scalar> totalTime_;
// Private Member Functions
// Initialisation routines
//- Reset size of lists (clear existing values)
void resetLists(const label nItems);
//- Intitialise averaging. Check requested field averages are
// valid, and populate field lists
void initialise();
//- Add mean average field to PtrList
template<class Type>
void addMeanField
(
const label,
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
);
//- Add prime-squared average field to PtrList
template<class Type1, class Type2>
void addPrime2MeanField
(
const label,
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
);
// Calculation functions
//- Main calculation routine
virtual void calcAverages();
//- Calculate mean average fields
template<class Type>
void calculateMeanFields
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >&
);
//- Add mean-squared field value to prime-squared mean field
template<class Type1, class Type2>
void addMeanSqrToPrime2Mean
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
);
//- Calculate prime-squared average fields
template<class Type1, class Type2>
void calculatePrime2MeanFields
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >&,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >&
);
// I-O
//- Write averages
virtual void writeAverages() const;
//- Write fields
template<class Type>
void writeFieldList
(
const PtrList<GeometricField<Type, fvPatchField, volMesh> >&
fieldList
) const;
//- Write averaging properties - steps and time
void writeAveragingProperties() const;
//- Read averaging properties - steps and time
void readAveragingProperties();
// Functions to be over-ridden from IOoutputFilter class
//- Update mesh
virtual void updateMesh(const mapPolyMesh&);
//- Move points
virtual void movePoints(const Field<point>&);
//- Disallow default bitwise copy construct
fieldAverage(const fieldAverage&);
//- Disallow default bitwise assignment
void operator=(const fieldAverage&);
public:
//- Runtime type information
TypeName("fieldAverage");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
fieldAverage
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
//- Destructor
virtual ~fieldAverage();
// Member Functions
//- Return name of the set of field averages
virtual const word& name() const
{
return name_;
}
//- Read the field average data
virtual void read(const dictionary&);
//- Execute the averaging
virtual void execute();
//- Calculate the field average data and write
virtual void write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "fieldAverageTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,239 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldAverageItem.H"
#include "volFields.H"
#include "OFstream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::fieldAverage::addMeanField
(
const label fieldi,
PtrList<GeometricField<Type, fvPatchField, volMesh> >& meanFieldList
)
{
if (faItems_[fieldi].mean())
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const word& fieldName = faItems_[fieldi].fieldName();
const fieldType& baseField = obr_.lookupObject<fieldType>(fieldName);
const word meanFieldName = fieldName + EXT_MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl;
meanFieldList.set
(
fieldi,
new fieldType
(
IOobject
(
meanFieldName,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
baseField
)
);
}
}
template<class Type1, class Type2>
void Foam::fieldAverage::addPrime2MeanField
(
const label fieldi,
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList
)
{
if (faItems_[fieldi].mean() && meanFieldList.set(fieldi))
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
const word& fieldName = faItems_[fieldi].fieldName();
const fieldType1& baseField = obr_.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField = meanFieldList[fieldi];
const word meanFieldName = fieldName + EXT_PRIME2MEAN;
Info<< "Reading/calculating field " << meanFieldName << nl << endl;
prime2MeanFieldList.set
(
fieldi,
new fieldType2
(
IOobject
(
meanFieldName,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
sqr(baseField) - sqr(meanField)
)
);
}
}
template<class Type>
void Foam::fieldAverage::calculateMeanFields
(
PtrList<GeometricField<Type, fvPatchField, volMesh> >& meanFieldList
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const scalar dt = obr_.time().deltaT().value();
forAll(faItems_, i)
{
if (faItems_[i].mean() && meanFieldList.set(i))
{
const word& fieldName = faItems_[i].fieldName();
const fieldType& baseField =
obr_.lookupObject<fieldType>(fieldName);
fieldType& meanField = meanFieldList[i];
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
alpha = (totalTime_[i] - dt)/totalTime_[i];
beta = dt/totalTime_[i];
}
else
{
alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]);
beta = 1.0/scalar(totalIter_[i]);
}
meanField = alpha*meanField + beta*baseField;
}
}
}
template<class Type1, class Type2>
void Foam::fieldAverage::calculatePrime2MeanFields
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList
)
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
const scalar dt = obr_.time().deltaT().value();
forAll(faItems_, i)
{
if
(
faItems_[i].prime2Mean()
&& meanFieldList.set(i)
&& prime2MeanFieldList.set(i)
)
{
const word& fieldName = faItems_[i].fieldName();
const fieldType1& baseField =
obr_.lookupObject<fieldType1>(fieldName);
const fieldType1& meanField = meanFieldList[i];
fieldType2& prime2MeanField = prime2MeanFieldList[i];
scalar alpha = 0.0;
scalar beta = 0.0;
if (faItems_[i].timeBase())
{
alpha = (totalTime_[i] - dt)/totalTime_[i];
beta = dt/totalTime_[i];
}
else
{
alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]);
beta = 1.0/scalar(totalIter_[i]);
}
prime2MeanField =
alpha*prime2MeanField
+ beta*sqr(baseField)
- sqr(meanField);
}
}
}
template<class Type1, class Type2>
void Foam::fieldAverage::addMeanSqrToPrime2Mean
(
PtrList<GeometricField<Type1, fvPatchField, volMesh> >& meanFieldList,
PtrList<GeometricField<Type2, fvPatchField, volMesh> >& prime2MeanFieldList
)
{
typedef GeometricField<Type1, fvPatchField, volMesh> fieldType1;
typedef GeometricField<Type2, fvPatchField, volMesh> fieldType2;
forAll(faItems_, i)
{
if
(
faItems_[i].prime2Mean()
&& meanFieldList.set(i)
&& prime2MeanFieldList.set(i)
)
{
const fieldType1& meanField = meanFieldList[i];
fieldType2& prime2MeanField = prime2MeanFieldList[i];
prime2MeanField += sqr(meanField);
}
}
}
template<class Type>
void Foam::fieldAverage::writeFieldList
(
const PtrList<GeometricField<Type, fvPatchField, volMesh> >& fieldList
) const
{
forAll(fieldList, i)
{
if (fieldList.set(i))
{
fieldList[i].write();
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldAverageFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(fieldAverageFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
fieldAverageFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::fieldAverageFunctionObject
Description
FunctionObject wrapper around fieldAverage to allow them to be created
via the functions list within controlDict.
SourceFiles
fieldAverageFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef fieldAverageFunctionObject_H
#define fieldAverageFunctionObject_H
#include "fieldAverage.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<fieldAverage>
fieldAverageFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldAverageItem.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* Foam::NamedEnum<Foam::fieldAverageItem::baseType, 2>::names[] =
{
"iteration",
"time"
};
const Foam::NamedEnum<Foam::fieldAverageItem::baseType, 2>
Foam::fieldAverageItem::baseTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverageItem::fieldAverageItem()
:
fieldName_("unknown"),
mean_(0),
prime2Mean_(0),
base_(ITER)
{}
Foam::fieldAverageItem::fieldAverageItem(const fieldAverageItem& faItem)
:
fieldName_(faItem.fieldName_),
mean_(faItem.mean_),
prime2Mean_(faItem.prime2Mean_),
base_(faItem.base_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldAverageItem::~fieldAverageItem()
{}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::fieldAverageItem::operator=(const fieldAverageItem& rhs)
{
// Check for assignment to self
if (this == &rhs)
{
FatalErrorIn
(
"Foam::fieldAverageItem::operator=(const Foam::fieldAverageItem&)"
) << "Attempted assignment to self" << nl
<< abort(FatalError);
}
// Set updated values
fieldName_ = rhs.fieldName_;
mean_ = rhs.mean_;
prime2Mean_ = rhs.prime2Mean_;
base_ = rhs.base_;
}
// ************************************************************************* //

View File

@ -0,0 +1,208 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fieldAverageItem
Description
Helper class to describe what form of averaging to apply. A set will be
applied to each base field in Foam::fieldAverage, of the form:
@verbatim
{
mean on;
prime2Mean on;
base time; // iteration
}
@endverbatim
SourceFiles
fieldAverageItem.C
fieldAverageItemIO.C
\*---------------------------------------------------------------------------*/
#ifndef fieldAverageItem_H
#define fieldAverageItem_H
#include "NamedEnum.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class fieldAverageItem;
Istream& operator>>(Istream&, fieldAverageItem&);
Ostream& operator<<(Ostream&, const fieldAverageItem&);
/*---------------------------------------------------------------------------*\
Class fieldAverageItem Declaration
\*---------------------------------------------------------------------------*/
class fieldAverageItem
{
public:
// Public data
//- Enumeration defining the averaging base type
enum baseType
{
ITER,
TIME
};
private:
// Private data
//- Field name
word fieldName_;
//- Compute mean flag
Switch mean_;
//- Compute prime-squared mean flag
Switch prime2Mean_;
//- Averaging base type names
static const NamedEnum<baseType, 2> baseTypeNames_;
//- Averaging base type
baseType base_;
public:
// Constructors
//- Construct null
fieldAverageItem();
//- Construct from Istream
fieldAverageItem(Istream&);
//- Construct as copy
fieldAverageItem(const fieldAverageItem&);
// Destructor
~fieldAverageItem();
// Member Functions
// Access
//- Return const access to the field name
const word& fieldName() const
{
return fieldName_;
}
//- Return const access to the mean flag
const Switch& mean() const
{
return mean_;
}
//- Return const access to the prime-squared mean flag
const Switch& prime2Mean() const
{
return prime2Mean_;
}
//- Return averaging base type name
const word base() const
{
return baseTypeNames_[base_];
}
//- Return true if base is ITER
Switch ITERBase() const
{
return base_ == ITER;
}
//- Return true if base is time
Switch timeBase() const
{
return base_ == TIME;
}
// Member Operators
void operator=(const fieldAverageItem&);
// Friend Operators
friend bool operator==
(
const fieldAverageItem& a,
const fieldAverageItem& b
)
{
return
a.fieldName_ == b.fieldName_
&& a.mean_ == b.mean_
&& a.prime2Mean_ == b.prime2Mean_
&& a.base_ == b.base_;
}
friend bool operator!=
(
const fieldAverageItem& a,
const fieldAverageItem& b
)
{
return !(a == b);
}
// IOstream Operators
friend Istream& operator>>(Istream&, fieldAverageItem&);
friend Ostream& operator<<(Ostream&, const fieldAverageItem&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldAverageItem.H"
#include "IOstreams.H"
#include "dictionaryEntry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldAverageItem::fieldAverageItem(Istream& is)
:
fieldName_("unknown"),
mean_(0),
prime2Mean_(0)
{
is.check("Foam::fieldAverageItem::fieldAverageItem(Foam::Istream&)");
const dictionaryEntry entry(dictionary::null, is);
fieldName_ = entry.keyword();
entry.lookup("mean") >> mean_;
entry.lookup("prime2Mean") >> prime2Mean_;
base_ = baseTypeNames_[entry.lookup("base")];
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, fieldAverageItem& faItem)
{
is.check
(
"Foam::Istream& Foam::operator>>"
"(Foam::Istream&, Foam::fieldAverageItem&)"
);
const dictionaryEntry entry(dictionary::null, is);
faItem.fieldName_ = entry.keyword();
entry.lookup("mean") >> faItem.mean_;
entry.lookup("prime2Mean") >> faItem.prime2Mean_;
faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")];
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem)
{
os.check
(
"Foam::Ostream& Foam::operator<<"
"(Foam::Ostream&, const Foam::fieldAverageItem&)"
);
os<< faItem.fieldName_ << nl;
os<< token::BEGIN_BLOCK << nl;
os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl;
os.writeKeyword("prime2Mean") << faItem.mean_
<< token::END_STATEMENT << nl;
os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_]
<< token::END_STATEMENT << nl;
os<< token::END_BLOCK << nl;
os.check
(
"Foam::Ostream& Foam::operator<<"
"(Foam::Ostream&, const Foam::fieldAverageItem&)"
);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::IOfieldMinMax
Description
Instance of the generic IOOutputFilter for fieldMinMax.
\*---------------------------------------------------------------------------*/
#ifndef IOfieldMinMax_H
#define IOfieldMinMax_H
#include "fieldMinMax.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<fieldMinMax> IOfieldMinMax;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,203 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldMinMax.H"
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(fieldMinMax, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldMinMax::fieldMinMax
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
name_(name),
obr_(obr),
active_(true),
log_(false),
fieldSet_(),
fieldMinMaxFilePtr_(NULL)
{
// Check if the available mesh is an fvMesh otherise deactivate
if (!isA<fvMesh>(obr_))
{
active_ = false;
WarningIn
(
"fieldMinMax::fieldMinMax"
"(const objectRegistry& obr, const dictionary& dict)"
) << "No fvMesh available, deactivating."
<< endl;
}
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldMinMax::~fieldMinMax()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldMinMax::read(const dictionary& dict)
{
if (active_)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
dict.lookup("fields") >> fieldSet_;
}
}
void Foam::fieldMinMax::makeFile()
{
// Create the fieldMinMax file if not already created
if (fieldMinMaxFilePtr_.empty())
{
if (debug)
{
Info<< "Creating fieldMinMax file." << endl;
}
// File update
if (Pstream::master())
{
fileName fieldMinMaxDir;
if (Pstream::parRun())
{
// Put in undecomposed case (Note: gives problems for
// distributed data running)
fieldMinMaxDir =
obr_.time().path()/".."/name_/obr_.time().timeName();
}
else
{
fieldMinMaxDir =
obr_.time().path()/name_/obr_.time().timeName();
}
// Create directory if does not exist.
mkDir(fieldMinMaxDir);
// Open new file at start up
fieldMinMaxFilePtr_.reset
(
new OFstream(fieldMinMaxDir/(type() + ".dat"))
);
// Add headers to output data
writeFileHeader();
}
}
}
void Foam::fieldMinMax::writeFileHeader()
{
if (fieldMinMaxFilePtr_.valid())
{
fieldMinMaxFilePtr_()
<< "# Time" << tab << "field" << tab << "min" << tab << "max"
<< endl;
}
}
void Foam::fieldMinMax::execute()
{
// Do nothing - only valid on write
}
void Foam::fieldMinMax::write()
{
if (active_)
{
// Create the fieldMinMax file if not already created
makeFile();
forAll(fieldSet_, fieldI)
{
calcMinMaxFields<scalar>(fieldSet_[fieldI]);
calcMinMaxFields<vector>(fieldSet_[fieldI]);
calcMinMaxFields<sphericalTensor>(fieldSet_[fieldI]);
calcMinMaxFields<symmTensor>(fieldSet_[fieldI]);
calcMinMaxFields<tensor>(fieldSet_[fieldI]);
}
}
}
template<>
void Foam::fieldMinMax::calcMinMaxFields<Foam::scalar>
(
const word& fieldName
)
{
if (obr_.foundObject<volScalarField>(fieldName))
{
const scalarField& field = obr_.lookupObject<scalarField>(fieldName);
scalar minValue = min(field);
scalar maxValue = max(field);
reduce(minValue, minOp<scalar>());
reduce(maxValue, maxOp<scalar>());
if (Pstream::master())
{
fieldMinMaxFilePtr_() << obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << endl;
if (log_)
{
Info<< "fieldMinMax output:" << nl
<< " min(" << fieldName << ") = " << minValue << nl
<< " max(" << fieldName << ") = " << maxValue << nl
<< endl;
}
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,182 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fieldMinMax
Description
Calculates scalar minimim and maximum field values.
For variables with rank > 0, computes the magnitude of the min/max
values.
Data written to the file \<timeDir\>/fieldMinMax.dat
SourceFiles
fieldMinMax.C
IOfieldMinMax.H
\*---------------------------------------------------------------------------*/
#ifndef fieldMinMax_H
#define fieldMinMax_H
#include "primitiveFieldsFwd.H"
#include "volFieldsFwd.H"
#include "HashSet.H"
#include "OFstream.H"
#include "Switch.H"
#include "pointFieldFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class fieldMinMax Declaration
\*---------------------------------------------------------------------------*/
class fieldMinMax
{
protected:
// Private data
//- Name of this set of forces,
// Also used as the name of the probes directory.
word name_;
const objectRegistry& obr_;
//- on/off switch
bool active_;
//- Switch to send output to Info as well as to file
Switch log_;
//- Patches to integrate forces over
wordList fieldSet_;
//- Forces/moment file ptr
autoPtr<OFstream> fieldMinMaxFilePtr_;
// Private Member Functions
//- If the forces file has not been created create it
void makeFile();
//- Disallow default bitwise copy construct
fieldMinMax(const fieldMinMax&);
//- Disallow default bitwise assignment
void operator=(const fieldMinMax&);
//- Output file header information
virtual void writeFileHeader();
public:
//- Runtime type information
TypeName("fieldMinMax");
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
fieldMinMax
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
);
// Destructor
virtual ~fieldMinMax();
// Member Functions
//- Return name of the set of forces
virtual const word& name() const
{
return name_;
}
//- Read the forces data
virtual void read(const dictionary&);
//- Execute
virtual void execute();
//- Calculate the field min/max
template<class Type>
void calcMinMaxFields(const word& fieldName);
//- Write the fieldMinMax
virtual void write();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&)
{}
//- Update for changes of mesh
virtual void movePoints(const pointField&)
{}
};
// Template specialisation for scalar fields
template<>
void fieldMinMax::calcMinMaxFields<scalar>(const word& fieldName);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "fieldMinMaxTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldMinMaxFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(fieldMinMaxFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
fieldMinMaxFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef
Foam::fieldMinMaxFunctionObject
Description
FunctionObject wrapper around fieldMinMax to allow them to be created via
the functions list within controlDict.
SourceFiles
fieldMinMaxFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef fieldMinMaxFunctionObject_H
#define fieldMinMaxFunctionObject_H
#include "fieldMinMax.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<fieldMinMax>
fieldMinMaxFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "fieldMinMax.H"
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (obr_.foundObject<fieldType>(fieldName))
{
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
scalar minValue = min(mag(field)).value();
scalar maxValue = max(mag(field)).value();
reduce(minValue, minOp<scalar>());
reduce(maxValue, maxOp<scalar>());
if (Pstream::master())
{
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;
}
}
}
}
// ************************************************************************* //