GIT: Initial state after latest Foundation merge

This commit is contained in:
Andrew Heather
2016-09-20 14:49:08 +01:00
4571 changed files with 115696 additions and 74609 deletions

View File

@ -0,0 +1,163 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
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_;
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::fieldMinMax::writeFileHeader(Ostream& os) const
{
writeHeader(os, "Field minima and maxima");
writeCommented(os, "Time");
if (writeLocation_)
{
writeTabbed(os, "field");
writeTabbed(os, "min");
writeTabbed(os, "location(min)");
if (Pstream::parRun())
{
writeTabbed(os, "processor");
}
writeTabbed(os, "max");
writeTabbed(os, "location(max)");
if (Pstream::parRun())
{
writeTabbed(os, "processor");
}
}
else
{
forAll(fieldSet_, fieldi)
{
writeTabbed(os, "min(" + fieldSet_[fieldi] + ')');
writeTabbed(os, "max(" + fieldSet_[fieldi] + ')');
}
}
os << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::fieldMinMax::fieldMinMax
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
fvMeshFunctionObject(name, runTime, dict),
writeFile(obr_, name, typeName, dict),
location_(true),
mode_(mdMag),
fieldSet_()
{
read(dict);
writeFileHeader(file());
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::fieldMinMax::~fieldMinMax()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
{
fvMeshFunctionObject::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()
{
return true;
}
bool Foam::functionObjects::fieldMinMax::write()
{
if (!location_) writeTime(file());
Log << type() << " " << name() << " write:" << 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;
Log << endl;
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,213 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
Class
Foam::functionObjects::fieldMinMax
Group
grpFieldFunctionObjects
Description
Calculates the value and location of scalar minimim and maximum for a list
of user-specified fields.
For variables with a rank greater than zero, either the min/max of a
component value or the magnitude is reported. When operating in parallel,
the processor owning the value is also given.
Example of function object specification:
\verbatim
fieldMinMax1
{
type fieldMinMax;
libs ("libfieldFunctionObjects.so");
...
writeToFile yes;
log yes;
writeLocation yes;
mode magnitude;
fields (U p);
}
\endverbatim
Usage
\table
Property | Description | Required | Default value
type | type name: fieldMinMax | yes |
writeToFile | write min/max data to file | no | yes
log | write min/max data to standard output | 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
Output data is written to the file \<timeDir\>/fieldMinMax.dat
See also
Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::writeFile
SourceFiles
fieldMinMax.C
fieldMinMaxTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_fieldMinMax_H
#define functionObjects_fieldMinMax_H
#include "Switch.H"
#include "NamedEnum.H"
#include "fvMeshFunctionObject.H"
#include "writeFile.H"
#include "vector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class fieldMinMax Declaration
\*---------------------------------------------------------------------------*/
class fieldMinMax
:
public fvMeshFunctionObject,
public writeFile
{
public:
// Public enumerations
enum modeType
{
mdMag, //!< magnitude
mdCmpt //!< component
};
protected:
// Protected data
//- Mode type names
static const NamedEnum<modeType, 2> modeTypeNames_;
//- Switch to write location of min/max values
Switch writeLocation_;
//- Mode for min/max - only applicable for ranks > 0
modeType mode_;
//- Fields to assess min/max
wordList fieldSet_;
// Private Member Functions
//- Helper function to write the output
template<class Type>
void output
(
const word& fieldName,
const word& outputName,
const vector& minC,
const vector& maxC,
const label minProci,
const label maxProci,
const Type& minValue,
const Type& maxValue
);
//- Output file header information
virtual void writeFileHeader(Ostream& os) const;
//- Disallow default bitwise copy construct
fieldMinMax(const fieldMinMax&) = delete;
//- Disallow default bitwise assignment
void operator=(const fieldMinMax&) = delete;
//- Calculate the field min/max
template<class Type>
void calcMinMaxFields
(
const word& fieldName,
const modeType& mode
);
public:
//- Runtime type information
TypeName("fieldMinMax");
// Constructors
//- Construct from Time and dictionary
fieldMinMax
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Destructor
virtual ~fieldMinMax();
// Member Functions
//- Read the field min/max data
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual bool execute();
//- Write the fieldMinMax
virtual bool write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "fieldMinMaxTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,286 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::functionObjects::fieldMinMax::output
(
const word& fieldName,
const word& outputName,
const vector& minC,
const vector& maxC,
const label minProci,
const label maxProci,
const Type& minValue,
const Type& maxValue
)
{
OFstream& file = this->file();
if (writeLocation_)
{
writeTime(file());
writeTabbed(file, fieldName);
file<< token::TAB << minValue
<< token::TAB << minC;
if (Pstream::parRun())
{
file<< token::TAB << minProci;
}
file<< token::TAB << maxValue
<< token::TAB << maxC;
if (Pstream::parRun())
{
file<< token::TAB << maxProci;
}
file<< endl;
Log << " min(" << outputName << ") = " << minValue
<< " at location " << minC;
if (Pstream::parRun())
{
Log << " on processor " << minProci;
}
Log << nl << " max(" << outputName << ") = " << maxValue
<< " at location " << maxC;
if (Pstream::parRun())
{
Log << " on processor " << maxProci;
}
}
else
{
file<< token::TAB << minValue << token::TAB << maxValue;
Log << " min/max(" << outputName << ") = "
<< minValue << ' ' << maxValue;
}
Log << 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);
}
template<class Type>
void Foam::functionObjects::fieldMinMax::calcMinMaxFields
(
const word& fieldName,
const modeType& mode
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (obr_.foundObject<fieldType>(fieldName))
{
const label proci = Pstream::myProcNo();
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
const volVectorField::Boundary& CfBoundary =
mesh_.C().boundaryField();
switch (mode)
{
case mdMag:
{
const volScalarField magField(mag(field));
const volScalarField::Boundary& magFieldBoundary =
magField.boundaryField();
scalarList minVs(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
label minProci = findMin(magField);
minVs[proci] = magField[minProci];
minCs[proci] = mesh_.C()[minProci];
labelList maxIs(Pstream::nProcs());
scalarList maxVs(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(magField);
maxVs[proci] = magField[maxProci];
maxCs[proci] = mesh_.C()[maxProci];
forAll(magFieldBoundary, patchi)
{
const scalarField& mfp = magFieldBoundary[patchi];
if (mfp.size())
{
const vectorField& Cfp = CfBoundary[patchi];
label minPI = findMin(mfp);
if (mfp[minPI] < minVs[proci])
{
minVs[proci] = mfp[minPI];
minCs[proci] = Cfp[minPI];
}
label maxPI = findMax(mfp);
if (mfp[maxPI] > maxVs[proci])
{
maxVs[proci] = mfp[maxPI];
maxCs[proci] = Cfp[maxPI];
}
}
}
Pstream::gatherList(minVs);
Pstream::scatterList(minVs);
Pstream::gatherList(minCs);
Pstream::scatterList(minCs);
Pstream::gatherList(maxVs);
Pstream::scatterList(maxVs);
Pstream::gatherList(maxCs);
Pstream::scatterList(maxCs);
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:
{
const typename fieldType::Boundary&
fieldBoundary = field.boundaryField();
List<Type> minVs(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
label minProci = findMin(field);
minVs[proci] = field[minProci];
minCs[proci] = mesh_.C()[minProci];
Pstream::gatherList(minVs);
Pstream::gatherList(minCs);
List<Type> maxVs(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(field);
maxVs[proci] = field[maxProci];
maxCs[proci] = mesh_.C()[maxProci];
forAll(fieldBoundary, patchi)
{
const Field<Type>& fp = fieldBoundary[patchi];
if (fp.size())
{
const vectorField& Cfp = CfBoundary[patchi];
label minPI = findMin(fp);
if (fp[minPI] < minVs[proci])
{
minVs[proci] = fp[minPI];
minCs[proci] = Cfp[minPI];
}
label maxPI = findMax(fp);
if (fp[maxPI] > maxVs[proci])
{
maxVs[proci] = fp[maxPI];
maxCs[proci] = Cfp[maxPI];
}
}
}
Pstream::gatherList(minVs);
Pstream::scatterList(minVs);
Pstream::gatherList(minCs);
Pstream::scatterList(minCs);
Pstream::gatherList(maxVs);
Pstream::scatterList(maxVs);
Pstream::gatherList(maxCs);
Pstream::scatterList(maxCs);
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:
{
FatalErrorInFunction
<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
}
}
}
// ************************************************************************* //