mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-dev-OpenCFD into develop
Conflicts: src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,13 +37,16 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::cloudInfo::writeFileHeader(const label i)
|
||||
void Foam::cloudInfo::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(file(), "Cloud information");
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "nParcels");
|
||||
writeTabbed(file(), "mass");
|
||||
file() << endl;
|
||||
writeHeader(os, "Cloud information");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "nParcels");
|
||||
writeTabbed(os, "mass");
|
||||
writeTabbed(os, "Dmax");
|
||||
writeTabbed(os, "D10");
|
||||
writeTabbed(os, "D32");
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +63,10 @@ Foam::cloudInfo::cloudInfo
|
||||
functionObjectFile(obr, name),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true)
|
||||
active_(true),
|
||||
log_(true),
|
||||
cloudNames_(),
|
||||
filePtrs_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -78,47 +84,70 @@ void Foam::cloudInfo::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::resetNames(dict.lookup("clouds"));
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
Info<< type() << " " << name_ << ": ";
|
||||
if (names().size())
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
dict.lookup("clouds") >> cloudNames_;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< "applying to clouds:" << nl;
|
||||
forAll(names(), i)
|
||||
Info<< type() << " " << name_ << ": ";
|
||||
|
||||
if (cloudNames_.size())
|
||||
{
|
||||
Info<< " " << names()[i] << nl;
|
||||
Info<< "applying to clouds:" << nl;
|
||||
forAll(cloudNames_, i)
|
||||
{
|
||||
Info<< " " << cloudNames_[i] << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "no clouds to be processed" << nl << endl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
else
|
||||
|
||||
if (writeToFile())
|
||||
{
|
||||
Info<< "no clouds to be processed" << nl << endl;
|
||||
filePtrs_.setSize(cloudNames_.size());
|
||||
filePtrs_.clear();
|
||||
forAll(filePtrs_, fileI)
|
||||
{
|
||||
const word& cloudName = cloudNames_[fileI];
|
||||
filePtrs_.set(fileI, createFile(cloudName));
|
||||
writeFileHeader(filePtrs_[fileI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::cloudInfo::execute()
|
||||
{}
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::cloudInfo::end()
|
||||
{}
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::cloudInfo::timeSet()
|
||||
{}
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::cloudInfo::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
forAll(names(), i)
|
||||
forAll(cloudNames_, cloudI)
|
||||
{
|
||||
const word& cloudName = names()[i];
|
||||
const word& cloudName = cloudNames_[cloudI];
|
||||
|
||||
const kinematicCloud& cloud =
|
||||
obr_.lookupObject<kinematicCloud>(cloudName);
|
||||
@ -127,12 +156,31 @@ void Foam::cloudInfo::write()
|
||||
scalar massInSystem =
|
||||
returnReduce(cloud.massInSystem(), sumOp<scalar>());
|
||||
|
||||
scalar Dmax = cloud.Dmax();
|
||||
scalar D10 = cloud.Dij(1, 0);
|
||||
scalar D32 = cloud.Dij(3, 2);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file(i)
|
||||
filePtrs_[cloudI]
|
||||
<< obr_.time().value() << token::TAB
|
||||
<< nParcels << token::TAB
|
||||
<< massInSystem << endl;
|
||||
<< massInSystem << token::TAB
|
||||
<< Dmax << token::TAB
|
||||
<< D10 << token::TAB
|
||||
<< D32 << token::TAB
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " number of parcels : " << nParcels << nl
|
||||
<< " mass in system : " << massInSystem << nl
|
||||
<< " maximum diameter : " << Dmax << nl
|
||||
<< " D10 diameter : " << D10 << nl
|
||||
<< " D32 diameter : " << D32 << nl
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -109,11 +109,20 @@ protected:
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well
|
||||
Switch log_;
|
||||
|
||||
//- List of cloud names
|
||||
wordList cloudNames_;
|
||||
|
||||
//- Output file per cloud
|
||||
PtrList<OFstream> filePtrs_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
cloudInfo(const cloudInfo&);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -63,6 +63,8 @@ functions
|
||||
enabled yes;
|
||||
timeStart 0;
|
||||
timeEnd 10;
|
||||
evaluateControl timeStep;
|
||||
evaluateInterval 1;
|
||||
outputControl outputTime;
|
||||
outputInterval 1;
|
||||
...
|
||||
@ -78,7 +80,9 @@ Where:
|
||||
region | name of region for multi-region cases | no |
|
||||
enabled | on/off switch | no | yes
|
||||
timeStart| start time | no |
|
||||
timeEnd | end time | no |
|
||||
timeEnd | end time | no |
|
||||
evaluateControl | when to evaluate: either 'outputTime' or 'timeStep'| no | timeStep
|
||||
evaluateInterval| steps between evaluation when evaluateControl=timeStep | no | 1
|
||||
outputControl | when to output: either 'outputTime' or 'timeStep'| no | timeStep
|
||||
outputInterval| steps between output when outputControl=timeStep | no | 1
|
||||
\endtable
|
||||
@ -88,7 +92,7 @@ typically used as the name of the output directory for any derived data. The
|
||||
\c type entry defines the type of function object properties that follow.
|
||||
Since the function objects are packaged into separate libraries, the user must
|
||||
tell the code where to find the function object implementation, identified
|
||||
using the \c libs entry.
|
||||
using the \c functionObjectLibs entry.
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -66,7 +66,8 @@ void Foam::fieldAverage::initialize()
|
||||
{
|
||||
resetFields();
|
||||
|
||||
Info<< type() << " " << name_ << ":" << nl;
|
||||
if (log_) Info << type() << " " << name_ << ":" << nl;
|
||||
|
||||
|
||||
// Add mean fields to the field lists
|
||||
forAll(faItems_, fieldI)
|
||||
@ -98,7 +99,7 @@ void Foam::fieldAverage::initialize()
|
||||
// ensure first averaging works unconditionally
|
||||
prevTimeIndex_ = -1;
|
||||
|
||||
Info<< endl;
|
||||
if (log_) Info << endl;
|
||||
|
||||
initialised_ = true;
|
||||
}
|
||||
@ -123,9 +124,11 @@ void Foam::fieldAverage::calcAverages()
|
||||
prevTimeIndex_ = currentTimeIndex;
|
||||
}
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
Info<< " Calculating averages" << nl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " Calculating averages" << nl;
|
||||
}
|
||||
|
||||
addMeanSqrToPrime2Mean<scalar, scalar>();
|
||||
addMeanSqrToPrime2Mean<vector, symmTensor>();
|
||||
@ -149,7 +152,7 @@ void Foam::fieldAverage::calcAverages()
|
||||
|
||||
void Foam::fieldAverage::writeAverages() const
|
||||
{
|
||||
Info<< " Writing average fields" << endl;
|
||||
if (log_) Info << " Writing average fields" << endl;
|
||||
|
||||
writeFields<scalar>();
|
||||
writeFields<vector>();
|
||||
@ -159,31 +162,17 @@ void Foam::fieldAverage::writeAverages() const
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldAverage::writeAveragingProperties() const
|
||||
void Foam::fieldAverage::writeAveragingProperties()
|
||||
{
|
||||
IOdictionary propsDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"fieldAveragingProperties",
|
||||
obr_.time().timeName(),
|
||||
"uniform",
|
||||
obr_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
forAll(faItems_, fieldI)
|
||||
{
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
propsDict.add(fieldName, dictionary());
|
||||
propsDict.subDict(fieldName).add("totalIter", totalIter_[fieldI]);
|
||||
propsDict.subDict(fieldName).add("totalTime", totalTime_[fieldI]);
|
||||
}
|
||||
|
||||
propsDict.regIOobject::write();
|
||||
dictionary propsDict;
|
||||
propsDict.add("totalIter", totalIter_[fieldI]);
|
||||
propsDict.add("totalTime", totalTime_[fieldI]);
|
||||
setProperty(fieldName, propsDict);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -195,46 +184,41 @@ void Foam::fieldAverage::readAveragingProperties()
|
||||
totalTime_.clear();
|
||||
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
|
||||
|
||||
if (resetOnRestart_ || resetOnOutput_)
|
||||
if (log_ && (resetOnRestart_ || resetOnOutput_))
|
||||
{
|
||||
Info<< " Starting averaging at time " << obr_.time().timeName()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
IOobject propsDictHeader
|
||||
(
|
||||
"fieldAveragingProperties",
|
||||
obr_.time().timeName(obr_.time().startTime().value()),
|
||||
"uniform",
|
||||
obr_,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
if (log_) Info << " Restarting averaging for fields:" << nl;
|
||||
|
||||
if (!propsDictHeader.headerOk())
|
||||
{
|
||||
Info<< " Starting averaging at time " << obr_.time().timeName()
|
||||
<< nl;
|
||||
return;
|
||||
}
|
||||
|
||||
IOdictionary propsDict(propsDictHeader);
|
||||
|
||||
Info<< " Restarting averaging for fields:" << nl;
|
||||
forAll(faItems_, fieldI)
|
||||
{
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
if (propsDict.found(fieldName))
|
||||
if (foundProperty(fieldName))
|
||||
{
|
||||
dictionary fieldDict(propsDict.subDict(fieldName));
|
||||
dictionary fieldDict;
|
||||
getProperty(fieldName, fieldDict);
|
||||
|
||||
totalIter_[fieldI] = readLabel(fieldDict.lookup("totalIter"));
|
||||
totalTime_[fieldI] = readScalar(fieldDict.lookup("totalTime"));
|
||||
Info<< " " << fieldName
|
||||
<< " iters = " << totalIter_[fieldI]
|
||||
<< " time = " << totalTime_[fieldI] << nl;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " " << fieldName
|
||||
<< " iters = " << totalIter_[fieldI]
|
||||
<< " time = " << totalTime_[fieldI] << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (log_)
|
||||
{
|
||||
Info<< " " << fieldName
|
||||
<< ": starting averaging at time "
|
||||
<< obr_.time().timeName() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,37 +235,22 @@ Foam::fieldAverage::fieldAverage
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
functionObjectState(obr, name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
prevTimeIndex_(-1),
|
||||
resetOnRestart_(false),
|
||||
resetOnOutput_(false),
|
||||
log_(true),
|
||||
initialised_(false),
|
||||
faItems_(),
|
||||
totalIter_(),
|
||||
totalTime_()
|
||||
{
|
||||
// Only active if a fvMesh is available
|
||||
if (isA<fvMesh>(obr_))
|
||||
if (setActive<fvMesh>())
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"fieldAverage::fieldAverage"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool "
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -299,7 +268,9 @@ void Foam::fieldAverage::read(const dictionary& dict)
|
||||
{
|
||||
initialised_ = false;
|
||||
|
||||
Info<< type() << " " << name_ << ":" << nl;
|
||||
log_.readIfPresent("log", dict);
|
||||
|
||||
if (log_) Info << type() << " " << name_ << ":" << nl;
|
||||
|
||||
dict.readIfPresent("resetOnRestart", resetOnRestart_);
|
||||
dict.readIfPresent("resetOnOutput", resetOnOutput_);
|
||||
@ -307,7 +278,7 @@ void Foam::fieldAverage::read(const dictionary& dict)
|
||||
|
||||
readAveragingProperties();
|
||||
|
||||
Info<< endl;
|
||||
if (log_) Info << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,7 +288,7 @@ void Foam::fieldAverage::execute()
|
||||
if (active_)
|
||||
{
|
||||
calcAverages();
|
||||
Info<< endl;
|
||||
if (log_) Info << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,8 +297,7 @@ void Foam::fieldAverage::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
calcAverages();
|
||||
Info<< endl;
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,8 +315,11 @@ void Foam::fieldAverage::write()
|
||||
|
||||
if (resetOnOutput_)
|
||||
{
|
||||
Info<< " Restarting averaging at time " << obr_.time().timeName()
|
||||
<< nl << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Restarting averaging at time " << obr_.time().timeName()
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
totalIter_.clear();
|
||||
totalIter_.setSize(faItems_.size(), 1);
|
||||
@ -357,7 +330,7 @@ void Foam::fieldAverage::write()
|
||||
initialize();
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
if (log_) Info << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -94,9 +94,10 @@ Description
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldAverage | yes |
|
||||
resetOnRestart | flag to reset the averaging on restart | yes |
|
||||
resetOnRestart | flag to reset the averaging on restart | yes |
|
||||
resetOnOutput| flag to reset the averaging on output | yes |
|
||||
fields | list of fields and averaging options | yes |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
|
||||
@ -117,6 +118,7 @@ SourceFiles
|
||||
#ifndef fieldAverage_H
|
||||
#define fieldAverage_H
|
||||
|
||||
#include "functionObjectState.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "Switch.H"
|
||||
|
||||
@ -139,20 +141,16 @@ class mapPolyMesh;
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldAverage
|
||||
:
|
||||
public functionObjectState
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of field averages.
|
||||
word name_;
|
||||
|
||||
//- Database this class is registered to
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Time at last call, prevents repeated averaging
|
||||
label prevTimeIndex_;
|
||||
|
||||
@ -162,6 +160,9 @@ protected:
|
||||
//- Reset the averaging process on output flag
|
||||
Switch resetOnOutput_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Initialised flag
|
||||
bool initialised_;
|
||||
|
||||
@ -251,7 +252,7 @@ protected:
|
||||
void writeFields() const;
|
||||
|
||||
//- Write averaging properties - steps and time
|
||||
void writeAveragingProperties() const;
|
||||
void writeAveragingProperties();
|
||||
|
||||
//- Read averaging properties - steps and time
|
||||
void readAveragingProperties();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,7 +38,7 @@ void Foam::fieldAverage::addMeanFieldType(const label fieldI)
|
||||
const word& fieldName = faItems_[fieldI].fieldName();
|
||||
const word& meanFieldName = faItems_[fieldI].meanFieldName();
|
||||
|
||||
Info<< " Reading/initialising field " << meanFieldName << endl;
|
||||
if (log_) Info << " Reading/initialising field " << meanFieldName << endl;
|
||||
|
||||
if (obr_.foundObject<Type>(meanFieldName))
|
||||
{
|
||||
@ -46,9 +46,12 @@ void Foam::fieldAverage::addMeanFieldType(const label fieldI)
|
||||
}
|
||||
else if (obr_.found(meanFieldName))
|
||||
{
|
||||
Info<< " Cannot allocate average field " << meanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging for field." << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Cannot allocate average field " << meanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging for field." << endl;
|
||||
}
|
||||
|
||||
faItems_[fieldI].mean() = false;
|
||||
}
|
||||
@ -107,7 +110,10 @@ void Foam::fieldAverage::addPrime2MeanFieldType(const label fieldI)
|
||||
const word& meanFieldName = faItems_[fieldI].meanFieldName();
|
||||
const word& prime2MeanFieldName = faItems_[fieldI].prime2MeanFieldName();
|
||||
|
||||
Info<< " Reading/initialising field " << prime2MeanFieldName << nl;
|
||||
if (log_)
|
||||
{
|
||||
Info << " Reading/initialising field " << prime2MeanFieldName << nl;
|
||||
}
|
||||
|
||||
if (obr_.foundObject<Type2>(prime2MeanFieldName))
|
||||
{
|
||||
@ -115,9 +121,12 @@ void Foam::fieldAverage::addPrime2MeanFieldType(const label fieldI)
|
||||
}
|
||||
else if (obr_.found(prime2MeanFieldName))
|
||||
{
|
||||
Info<< " Cannot allocate average field " << prime2MeanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging for field." << nl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Cannot allocate average field " << prime2MeanFieldName
|
||||
<< " since an object with that name already exists."
|
||||
<< " Disabling averaging for field." << nl;
|
||||
}
|
||||
|
||||
faItems_[fieldI].prime2Mean() = false;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,6 +49,45 @@ const Foam::NamedEnum<Foam::fieldMinMax::modeType, 2>
|
||||
Foam::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, "position(min)");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(os, "processor");
|
||||
}
|
||||
|
||||
writeTabbed(os, "max");
|
||||
writeTabbed(os, "position(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::fieldMinMax::fieldMinMax
|
||||
@ -59,33 +98,20 @@ Foam::fieldMinMax::fieldMinMax
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
functionObjectState(obr, name),
|
||||
functionObjectFile(obr, name, typeName, dict),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(true),
|
||||
location_(true),
|
||||
writeLocation_(true),
|
||||
mode_(mdMag),
|
||||
fieldSet_()
|
||||
{
|
||||
// Check if the available mesh is an fvMesh otherise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
if (setActive<fvMesh>())
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"fieldMinMax::fieldMinMax"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_
|
||||
<< endl;
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
@ -101,8 +127,10 @@ void Foam::fieldMinMax::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
location_ = dict.lookupOrDefault<Switch>("location", true);
|
||||
writeLocation_ = dict.lookupOrDefault<Switch>("writeLocation", true);
|
||||
|
||||
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
@ -110,46 +138,6 @@ void Foam::fieldMinMax::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::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;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldMinMax::execute()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
@ -172,9 +160,7 @@ void Foam::fieldMinMax::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
if (!location_) file()<< obr_.time().value();
|
||||
if (!writeLocation_) file()<< obr_.time().value();
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
forAll(fieldSet_, fieldI)
|
||||
@ -186,7 +172,7 @@ void Foam::fieldMinMax::write()
|
||||
calcMinMaxFields<tensor>(fieldSet_[fieldI], mode_);
|
||||
}
|
||||
|
||||
if (!location_) file()<< endl;
|
||||
if (!writeLocation_) file()<< endl;
|
||||
if (log_) Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +28,7 @@ Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates the value and location of scalar minimim
|
||||
This function object calculates the value and position 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
|
||||
@ -41,15 +41,11 @@ Description
|
||||
type fieldMinMax;
|
||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||
...
|
||||
write yes;
|
||||
writeToFile yes;
|
||||
log yes;
|
||||
location yes;
|
||||
writeLocation yes;
|
||||
mode magnitude;
|
||||
fields
|
||||
(
|
||||
U
|
||||
p
|
||||
);
|
||||
fields (U p);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
@ -57,20 +53,24 @@ Description
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: fieldMinMax | yes |
|
||||
write | write min/max data to file | no | yes
|
||||
log | write min/max data to standard output | no | no
|
||||
location | write location of the min/max value | no | 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
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjectFile
|
||||
Foam::functionObjectState
|
||||
Foam::OutputFilterFunctionObject
|
||||
|
||||
SourceFiles
|
||||
fieldMinMax.C
|
||||
fieldMinMaxTemplates.C
|
||||
IOfieldMinMax.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -78,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"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -94,20 +96,24 @@ class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldMinMax Declaration
|
||||
Class fieldMinMax Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldMinMax
|
||||
:
|
||||
public functionObjectState,
|
||||
public functionObjectFile
|
||||
{
|
||||
public:
|
||||
|
||||
enum modeType
|
||||
{
|
||||
mdMag,
|
||||
mdCmpt
|
||||
};
|
||||
// Public enumerations
|
||||
|
||||
enum modeType
|
||||
{
|
||||
mdMag, // magnitude
|
||||
mdCmpt // component
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -116,20 +122,14 @@ 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
|
||||
Switch log_;
|
||||
|
||||
//- Switch to write location of min/max values
|
||||
Switch location_;
|
||||
Switch writeLocation_;
|
||||
|
||||
//- Mode for min/max - only applicable for ranks > 0
|
||||
modeType mode_;
|
||||
@ -154,15 +154,16 @@ protected:
|
||||
const Type& maxValue
|
||||
);
|
||||
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldMinMax(const fieldMinMax&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fieldMinMax&);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -189,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&);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,7 +43,7 @@ void Foam::fieldMinMax::output
|
||||
{
|
||||
OFstream& file = this->file();
|
||||
|
||||
if (location_)
|
||||
if (writeLocation_)
|
||||
{
|
||||
file<< obr_.time().value();
|
||||
|
||||
@ -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 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];
|
||||
label maxI = findMax(maxVs);
|
||||
scalar maxValue = maxVs[maxI];
|
||||
const vector& maxC = maxCs[maxI];
|
||||
|
||||
output
|
||||
(
|
||||
fieldName,
|
||||
word("mag(" + fieldName + ")"),
|
||||
minC,
|
||||
maxC,
|
||||
minI,
|
||||
maxI,
|
||||
minValue,
|
||||
maxValue
|
||||
);
|
||||
}
|
||||
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 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];
|
||||
label maxI = findMax(maxVs);
|
||||
Type maxValue = maxVs[maxI];
|
||||
const vector& maxC = maxCs[maxI];
|
||||
|
||||
output
|
||||
(
|
||||
fieldName,
|
||||
fieldName,
|
||||
minC,
|
||||
maxC,
|
||||
minI,
|
||||
maxI,
|
||||
minValue,
|
||||
maxValue
|
||||
);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,8 +79,6 @@ void Foam::fieldValues::cellSource::setCellZoneCells()
|
||||
{
|
||||
case stCellZone:
|
||||
{
|
||||
dict().lookup("sourceName") >> sourceName_;
|
||||
|
||||
label zoneId = mesh().cellZones().findZoneID(sourceName_);
|
||||
|
||||
if (zoneId < 0)
|
||||
@ -135,7 +133,8 @@ void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
|
||||
WarningIn
|
||||
(
|
||||
"Foam::fieldValues::cellSource::initialise(const dictionary&)"
|
||||
) << type() << " " << name_ << ": "
|
||||
)
|
||||
<< type() << " " << name_ << ": "
|
||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
||||
<< " Source has no cells - deactivating" << endl;
|
||||
|
||||
@ -145,44 +144,46 @@ void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
|
||||
|
||||
volume_ = volume();
|
||||
|
||||
Info<< type() << " " << name_ << ":"
|
||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
||||
<< " total cells = " << nCells_ << nl
|
||||
<< " total volume = " << volume_
|
||||
<< nl << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << ":"
|
||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
||||
<< " total cells = " << nCells_ << nl
|
||||
<< " total volume = " << volume_
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||
{
|
||||
Info<< " weight field = " << weightFieldName_;
|
||||
if (log_) Info << " weight field = " << weightFieldName_;
|
||||
}
|
||||
|
||||
Info<< nl << endl;
|
||||
if (log_) Info << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::cellSource::writeFileHeader(const label i)
|
||||
void Foam::fieldValues::cellSource::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeCommented(file(), "Source : ");
|
||||
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
|
||||
writeCommented(file(), "Cells : ");
|
||||
file() << nCells_ << endl;
|
||||
writeCommented(file(), "Volume : ");
|
||||
file() << volume_ << endl;
|
||||
writeHeaderValue(os, "Source", sourceTypeNames_[source_]);
|
||||
writeHeaderValue(os, "Name", sourceName_);
|
||||
writeHeaderValue(os, "Cells", nCells_);
|
||||
writeHeaderValue(os, "Volume", volume_);
|
||||
writeHeaderValue(os, "Scale factor", scaleFactor_);
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
|
||||
writeCommented(os, "Time");
|
||||
if (writeVolume_)
|
||||
{
|
||||
file() << tab << "Volume";
|
||||
os << tab << "Volume";
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
file()
|
||||
<< tab << operationTypeNames_[operation_]
|
||||
os << tab << operationTypeNames_[operation_]
|
||||
<< "(" << fields_[i] << ")";
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -204,7 +205,11 @@ Foam::fieldValues::cellSource::cellSource
|
||||
weightFieldName_("none"),
|
||||
writeVolume_(dict.lookupOrDefault("writeVolume", false))
|
||||
{
|
||||
read(dict);
|
||||
if (active_)
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -218,11 +223,11 @@ Foam::fieldValues::cellSource::~cellSource()
|
||||
|
||||
void Foam::fieldValues::cellSource::read(const dictionary& dict)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
// no additional info to read
|
||||
fieldValue::read(dict);
|
||||
|
||||
// No additional info to read
|
||||
initialise(dict);
|
||||
}
|
||||
}
|
||||
@ -234,33 +239,34 @@ void Foam::fieldValues::cellSource::write()
|
||||
|
||||
if (active_)
|
||||
{
|
||||
if (Pstream::master())
|
||||
file() << obr_.time().value();
|
||||
|
||||
// Construct weight field. Note: zero size indicates unweighted
|
||||
scalarField weightField;
|
||||
if (weightFieldName_ != "none")
|
||||
{
|
||||
file() << obr_.time().value();
|
||||
weightField = setFieldValues<scalar>(weightFieldName_, true);
|
||||
}
|
||||
|
||||
if (writeVolume_)
|
||||
{
|
||||
volume_ = volume();
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << tab << volume_;
|
||||
}
|
||||
file() << tab << volume_;
|
||||
if (log_) Info<< " total volume = " << volume_ << endl;
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
const word& fieldName = fields_[i];
|
||||
bool processed = false;
|
||||
bool ok = false;
|
||||
|
||||
processed = processed || writeValues<scalar>(fieldName);
|
||||
processed = processed || writeValues<vector>(fieldName);
|
||||
processed = processed || writeValues<sphericalTensor>(fieldName);
|
||||
processed = processed || writeValues<symmTensor>(fieldName);
|
||||
processed = processed || writeValues<tensor>(fieldName);
|
||||
ok = ok || writeValues<scalar>(fieldName, weightField);
|
||||
ok = ok || writeValues<vector>(fieldName, weightField);
|
||||
ok = ok || writeValues<sphericalTensor>(fieldName, weightField);
|
||||
ok = ok || writeValues<symmTensor>(fieldName, weightField);
|
||||
ok = ok || writeValues<tensor>(fieldName, weightField);
|
||||
|
||||
if (!processed)
|
||||
if (!ok)
|
||||
{
|
||||
WarningIn("void Foam::fieldValues::cellSource::write()")
|
||||
<< "Requested field " << fieldName
|
||||
@ -269,10 +275,7 @@ void Foam::fieldValues::cellSource::write()
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file()<< endl;
|
||||
}
|
||||
file()<< endl;
|
||||
|
||||
if (log_) Info<< endl;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -62,11 +62,11 @@ Description
|
||||
log | Write data to standard output | no | no
|
||||
valueOutput | Write the raw output values | yes |
|
||||
writeVolume | Write the volume of the cellSource | no |
|
||||
source | cell source: see below | yes |
|
||||
sourceName | name of cell source if required | no |
|
||||
operation | operation to perform | yes |
|
||||
weightField | name of field to apply weighting | no |
|
||||
fields | list of fields to operate on | yes |
|
||||
source | Cell source: see below | yes |
|
||||
sourceName | Name of cell source if required | no |
|
||||
operation | Operation to perform | yes |
|
||||
weightField | Name of field to apply weighting | no |
|
||||
fields | List of fields to operate on | yes |
|
||||
\endtable
|
||||
|
||||
\linebreak
|
||||
@ -228,7 +228,7 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -272,7 +272,11 @@ public:
|
||||
|
||||
//- Templated helper function to output field values
|
||||
template<class Type>
|
||||
bool writeValues(const word& fieldName);
|
||||
bool writeValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const scalarField& weightField
|
||||
);
|
||||
|
||||
//- Filter a field according to cellIds
|
||||
template<class Type>
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -87,52 +87,66 @@ Type Foam::fieldValues::cellSource::processValues
|
||||
{
|
||||
case opSum:
|
||||
{
|
||||
result = sum(values);
|
||||
result = gSum(values);
|
||||
break;
|
||||
}
|
||||
case opSumMag:
|
||||
{
|
||||
result = sum(cmptMag(values));
|
||||
result = gSum(cmptMag(values));
|
||||
break;
|
||||
}
|
||||
case opAverage:
|
||||
{
|
||||
result = sum(values)/values.size();
|
||||
label n = returnReduce(values.size(), sumOp<label>());
|
||||
result = gSum(values)/(scalar(n) + ROOTVSMALL);
|
||||
break;
|
||||
}
|
||||
case opWeightedAverage:
|
||||
{
|
||||
result = sum(weightField*values)/sum(weightField);
|
||||
label wSize = returnReduce(weightField.size(), sumOp<label>());
|
||||
|
||||
if (wSize > 0)
|
||||
{
|
||||
result =
|
||||
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
label n = returnReduce(values.size(), sumOp<label>());
|
||||
result = gSum(values)/(scalar(n) + ROOTVSMALL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case opVolAverage:
|
||||
{
|
||||
result = sum(V*values)/sum(V);
|
||||
result = gSum(values*V)/(gSum(V) + ROOTVSMALL);
|
||||
break;
|
||||
}
|
||||
case opWeightedVolAverage:
|
||||
{
|
||||
result = sum(weightField*V*values)/sum(weightField*V);
|
||||
result = gSum(weightField*V*values)/gSum(weightField*V);
|
||||
break;
|
||||
}
|
||||
case opVolIntegrate:
|
||||
{
|
||||
result = sum(V*values);
|
||||
result = gSum(V*values);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
{
|
||||
result = min(values);
|
||||
result = gMin(values);
|
||||
break;
|
||||
}
|
||||
case opMax:
|
||||
{
|
||||
result = max(values);
|
||||
result = gMax(values);
|
||||
break;
|
||||
}
|
||||
case opCoV:
|
||||
{
|
||||
Type meanValue = sum(values*V)/sum(V);
|
||||
const scalar sumV = gSum(V);
|
||||
|
||||
Type meanValue = gSum(V*values)/sumV;
|
||||
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
@ -142,7 +156,7 @@ Type Foam::fieldValues::cellSource::processValues
|
||||
scalar mean = component(meanValue, d);
|
||||
scalar& res = setComponent(result, d);
|
||||
|
||||
res = sqrt(sum(V*sqr(vals - mean))/sum(V))/mean;
|
||||
res = sqrt(gSum(V*sqr(vals - mean))/sumV)/(mean + ROOTVSMALL);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -160,7 +174,11 @@ Type Foam::fieldValues::cellSource::processValues
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
||||
bool Foam::fieldValues::cellSource::writeValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const scalarField& weightField
|
||||
)
|
||||
{
|
||||
const bool ok = validField<Type>(fieldName);
|
||||
|
||||
@ -168,26 +186,13 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
||||
{
|
||||
Field<Type> values(setFieldValues<Type>(fieldName));
|
||||
scalarField V(filterField(mesh().V()));
|
||||
scalarField weightField(values.size(), 1.0);
|
||||
|
||||
if (weightFieldName_ != "none")
|
||||
if (valueOutput_)
|
||||
{
|
||||
weightField = setFieldValues<scalar>(weightFieldName_, true);
|
||||
}
|
||||
Field<Type> allValues(values);
|
||||
combineFields(allValues);
|
||||
|
||||
// Combine onto master
|
||||
combineFields(values);
|
||||
combineFields(V);
|
||||
combineFields(weightField);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Type result = processValues(values, V, weightField);
|
||||
|
||||
// Add to result dictionary, over-writing any previous entry
|
||||
resultDict_.add(fieldName, result, true);
|
||||
|
||||
if (valueOutput_)
|
||||
if (Pstream::master())
|
||||
{
|
||||
IOField<Type>
|
||||
(
|
||||
@ -200,17 +205,29 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
weightField*values
|
||||
allValues
|
||||
).write();
|
||||
}
|
||||
}
|
||||
|
||||
// Apply scale factor
|
||||
values *= scaleFactor_;
|
||||
|
||||
file()<< tab << result;
|
||||
Type result = processValues(values, V, weightField);
|
||||
|
||||
if (log_) Info<< " " << operationTypeNames_[operation_]
|
||||
file()<< tab << result;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " " << operationTypeNames_[operation_]
|
||||
<< "(" << sourceName_ << ") of " << fieldName
|
||||
<< " = " << result << endl;
|
||||
}
|
||||
|
||||
// write state/results information
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
word resultName = opName + '(' + sourceName_ + ',' + fieldName + ')';
|
||||
this->setResult(resultName, result);
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
@ -60,10 +60,13 @@ functions
|
||||
// Output field values as well
|
||||
valueOutput true;
|
||||
|
||||
// Output format for field values
|
||||
surfaceFormat vtk;
|
||||
|
||||
// Type of source: patch/faceZone/sampledSurface
|
||||
source patch;
|
||||
|
||||
// if patch or faceZone: name of patch or faceZone
|
||||
// If patch or faceZone: name of patch or faceZone
|
||||
sourceName movingWall;
|
||||
|
||||
//// if sampledSurface: dictionary with a sampledSurface
|
||||
@ -96,6 +99,7 @@ functions
|
||||
outputControl outputTime;
|
||||
log true;
|
||||
valueOutput true;
|
||||
surfaceFormat vtk;
|
||||
source faceZone;
|
||||
sourceName f0;
|
||||
operation sum;
|
||||
|
||||
@ -352,7 +352,7 @@ void Foam::fieldValues::faceSource::combineSurfaceGeometry
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// dimension as fraction of mesh bounding box
|
||||
// Dimension as fraction of mesh bounding box
|
||||
scalar mergeDim = 1e-10*mesh().bounds().mag();
|
||||
|
||||
labelList pointsMap;
|
||||
@ -400,8 +400,6 @@ Foam::scalar Foam::fieldValues::faceSource::totalArea() const
|
||||
|
||||
void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("sourceName") >> sourceName_;
|
||||
|
||||
switch (source_)
|
||||
{
|
||||
case stFaceZone:
|
||||
@ -450,15 +448,14 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
|
||||
totalArea_ = totalArea();
|
||||
|
||||
Info<< type() << " " << name_ << ":" << nl
|
||||
<< " total faces = " << nFaces_
|
||||
<< nl
|
||||
<< " total area = " << totalArea_
|
||||
<< nl;
|
||||
if (log_) Info
|
||||
<< type() << " " << name_ << ":" << nl
|
||||
<< " total faces = " << nFaces_ << nl
|
||||
<< " total area = " << totalArea_ << nl;
|
||||
|
||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||
{
|
||||
Info<< " weight field = " << weightFieldName_ << nl;
|
||||
if (log_) Info << " weight field = " << weightFieldName_ << nl;
|
||||
|
||||
if (source_ == stSampledSurface)
|
||||
{
|
||||
@ -480,7 +477,7 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
if (weightFieldName_ == "none")
|
||||
{
|
||||
dict.lookup("orientedWeightField") >> weightFieldName_;
|
||||
Info<< " weight field = " << weightFieldName_ << nl;
|
||||
if (log_) Info << " weight field = " << weightFieldName_ << nl;
|
||||
orientWeightField_ = true;
|
||||
}
|
||||
else
|
||||
@ -506,12 +503,7 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
fields_.append(orientedFields);
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("scaleFactor", scaleFactor_))
|
||||
{
|
||||
Info<< " scale factor = " << scaleFactor_ << nl;
|
||||
}
|
||||
|
||||
Info<< nl << endl;
|
||||
if (log_) Info << nl << endl;
|
||||
|
||||
if (valueOutput_)
|
||||
{
|
||||
@ -530,29 +522,27 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSource::writeFileHeader(const label i)
|
||||
void Foam::fieldValues::faceSource::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeCommented(file(), "Source : ");
|
||||
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
|
||||
writeCommented(file(), "Faces : ");
|
||||
file() << nFaces_ << endl;
|
||||
writeCommented(file(), "Area : ");
|
||||
file() << totalArea_ << endl;
|
||||
writeHeaderValue(os, "Source", sourceTypeNames_[source_]);
|
||||
writeHeaderValue(os, "Name", sourceName_);
|
||||
writeHeaderValue(os, "Faces", nFaces_);
|
||||
writeHeaderValue(os, "Total area", totalArea_);
|
||||
writeHeaderValue(os, "Scale factor", scaleFactor_);
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
writeCommented(os, "Time");
|
||||
if (writeArea_)
|
||||
{
|
||||
file() << tab << "Area";
|
||||
os << tab << "Area";
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
file()
|
||||
<< tab << operationTypeNames_[operation_]
|
||||
os << tab << operationTypeNames_[operation_]
|
||||
<< "(" << fields_[i] << ")";
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -569,14 +559,14 @@ Foam::scalar Foam::fieldValues::faceSource::processValues
|
||||
case opSumDirection:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
return sum(pos(values*(Sf & n))*mag(values));
|
||||
return gSum(pos(values*(Sf & n))*mag(values));
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
const scalarField nv(values*(Sf & n));
|
||||
|
||||
return sum(pos(nv)*mag(values) - neg(nv)*mag(values));
|
||||
return gSum(pos(nv)*mag(values) - neg(nv)*mag(values));
|
||||
}
|
||||
default:
|
||||
{
|
||||
@ -603,7 +593,7 @@ Foam::vector Foam::fieldValues::faceSource::processValues
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
const scalarField nv(n & values);
|
||||
|
||||
return sum(pos(nv)*n*(nv));
|
||||
return gSum(pos(nv)*n*(nv));
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
@ -611,16 +601,16 @@ Foam::vector Foam::fieldValues::faceSource::processValues
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
const scalarField nv(n & values);
|
||||
|
||||
return sum(pos(nv)*n*(nv));
|
||||
return gSum(pos(nv)*n*(nv));
|
||||
}
|
||||
case opAreaNormalAverage:
|
||||
{
|
||||
scalar result = sum(values & Sf)/sum(mag(Sf));
|
||||
scalar result = gSum(values & Sf)/gSum(mag(Sf));
|
||||
return vector(result, 0.0, 0.0);
|
||||
}
|
||||
case opAreaNormalIntegrate:
|
||||
{
|
||||
scalar result = sum(values & Sf);
|
||||
scalar result = gSum(values & Sf);
|
||||
return vector(result, 0.0, 0.0);
|
||||
}
|
||||
default:
|
||||
@ -649,14 +639,17 @@ Foam::fieldValues::faceSource::faceSource
|
||||
weightFieldName_("none"),
|
||||
orientWeightField_(false),
|
||||
orientedFieldsStart_(labelMax),
|
||||
scaleFactor_(1.0),
|
||||
writeArea_(dict.lookupOrDefault("writeArea", false)),
|
||||
nFaces_(0),
|
||||
faceId_(),
|
||||
facePatchId_(),
|
||||
faceSign_()
|
||||
{
|
||||
read(dict);
|
||||
if (active_)
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -670,10 +663,11 @@ Foam::fieldValues::faceSource::~faceSource()
|
||||
|
||||
void Foam::fieldValues::faceSource::read(const dictionary& dict)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
fieldValue::read(dict);
|
||||
|
||||
// No additional info to read
|
||||
initialise(dict);
|
||||
}
|
||||
}
|
||||
@ -690,27 +684,21 @@ void Foam::fieldValues::faceSource::write()
|
||||
surfacePtr_().update();
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << obr_.time().value();
|
||||
}
|
||||
file() << obr_.time().value();
|
||||
|
||||
if (writeArea_)
|
||||
{
|
||||
totalArea_ = totalArea();
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << tab << totalArea_;
|
||||
}
|
||||
file() << tab << totalArea_;
|
||||
if (log_) Info<< " total area = " << totalArea_ << endl;
|
||||
}
|
||||
|
||||
// construct weight field. Note: zero size means weight = 1
|
||||
// Construct weight field. Note: zero size indicates unweighted
|
||||
scalarField weightField;
|
||||
if (weightFieldName_ != "none")
|
||||
{
|
||||
weightField =
|
||||
getFieldValues<scalar>
|
||||
setFieldValues<scalar>
|
||||
(
|
||||
weightFieldName_,
|
||||
true,
|
||||
@ -718,10 +706,7 @@ void Foam::fieldValues::faceSource::write()
|
||||
);
|
||||
}
|
||||
|
||||
// Combine onto master
|
||||
combineFields(weightField);
|
||||
|
||||
// process the fields
|
||||
// Process the fields
|
||||
forAll(fields_, i)
|
||||
{
|
||||
const word& fieldName = fields_[i];
|
||||
@ -730,8 +715,8 @@ void Foam::fieldValues::faceSource::write()
|
||||
bool orient = i >= orientedFieldsStart_;
|
||||
ok = ok || writeValues<scalar>(fieldName, weightField, orient);
|
||||
ok = ok || writeValues<vector>(fieldName, weightField, orient);
|
||||
ok = ok
|
||||
|| writeValues<sphericalTensor>(fieldName, weightField, orient);
|
||||
ok = ok ||
|
||||
writeValues<sphericalTensor>(fieldName, weightField, orient);
|
||||
ok = ok || writeValues<symmTensor>(fieldName, weightField, orient);
|
||||
ok = ok || writeValues<tensor>(fieldName, weightField, orient);
|
||||
|
||||
@ -744,10 +729,7 @@ void Foam::fieldValues::faceSource::write()
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file()<< endl;
|
||||
}
|
||||
file()<< endl;
|
||||
|
||||
if (log_) Info<< endl;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -257,9 +257,6 @@ protected:
|
||||
//- Start index of fields that require application of flipMap
|
||||
label orientedFieldsStart_;
|
||||
|
||||
//- Scale factor - optional
|
||||
scalar scaleFactor_;
|
||||
|
||||
//- Total area of the faceSource
|
||||
scalar totalArea_;
|
||||
|
||||
@ -300,7 +297,7 @@ protected:
|
||||
|
||||
//- Return field values by looking up field name
|
||||
template<class Type>
|
||||
tmp<Field<Type> > getFieldValues
|
||||
tmp<Field<Type> > setFieldValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool mustGet = false,
|
||||
@ -328,7 +325,7 @@ protected:
|
||||
) const;
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -51,7 +51,7 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues
|
||||
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::setFieldValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const bool mustGet,
|
||||
@ -113,7 +113,7 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::tmp<Foam::Field<Type> > "
|
||||
"Foam::fieldValues::faceSource::getFieldValues"
|
||||
"Foam::fieldValues::faceSource::setFieldValues"
|
||||
"("
|
||||
"const word&, "
|
||||
"const bool, "
|
||||
@ -140,12 +140,12 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
{
|
||||
case opSum:
|
||||
{
|
||||
result = sum(values);
|
||||
result = gSum(values);
|
||||
break;
|
||||
}
|
||||
case opSumMag:
|
||||
{
|
||||
result = sum(cmptMag(values));
|
||||
result = gSum(cmptMag(values));
|
||||
break;
|
||||
}
|
||||
case opSumDirection:
|
||||
@ -190,18 +190,23 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
}
|
||||
case opAverage:
|
||||
{
|
||||
result = sum(values)/values.size();
|
||||
label n = returnReduce(values.size(), sumOp<label>());
|
||||
result = gSum(values)/(scalar(n) + ROOTVSMALL);
|
||||
break;
|
||||
}
|
||||
case opWeightedAverage:
|
||||
{
|
||||
if (weightField.size())
|
||||
label wSize = returnReduce(weightField.size(), sumOp<label>());
|
||||
|
||||
if (wSize > 0)
|
||||
{
|
||||
result = sum(weightField*values)/sum(weightField);
|
||||
result =
|
||||
gSum(weightField*values)/(gSum(weightField) + ROOTVSMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = sum(values)/values.size();
|
||||
label n = returnReduce(values.size(), sumOp<label>());
|
||||
result = gSum(values)/(scalar(n) + ROOTVSMALL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -209,20 +214,21 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
result = sum(magSf*values)/sum(magSf);
|
||||
result = gSum(magSf*values)/gSum(magSf);
|
||||
break;
|
||||
}
|
||||
case opWeightedAreaAverage:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
label wSize = returnReduce(weightField.size(), sumOp<label>());
|
||||
|
||||
if (weightField.size())
|
||||
if (wSize > 0)
|
||||
{
|
||||
result = sum(weightField*magSf*values)/sum(magSf*weightField);
|
||||
result = gSum(weightField*magSf*values)/gSum(magSf*weightField);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = sum(magSf*values)/sum(magSf);
|
||||
result = gSum(magSf*values)/gSum(magSf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -230,24 +236,26 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
result = sum(magSf*values);
|
||||
result = gSum(magSf*values);
|
||||
break;
|
||||
}
|
||||
case opMin:
|
||||
{
|
||||
result = min(values);
|
||||
result = gMin(values);
|
||||
break;
|
||||
}
|
||||
case opMax:
|
||||
{
|
||||
result = max(values);
|
||||
result = gMax(values);
|
||||
break;
|
||||
}
|
||||
case opCoV:
|
||||
{
|
||||
const scalarField magSf(mag(Sf));
|
||||
|
||||
Type meanValue = sum(values*magSf)/sum(magSf);
|
||||
const scalar gSumMagSf = gSum(magSf);
|
||||
|
||||
Type meanValue = gSum(values*magSf)/gSumMagSf;
|
||||
|
||||
const label nComp = pTraits<Type>::nComponents;
|
||||
|
||||
@ -257,7 +265,9 @@ Type Foam::fieldValues::faceSource::processSameTypeValues
|
||||
scalar mean = component(meanValue, d);
|
||||
scalar& res = setComponent(result, d);
|
||||
|
||||
res = sqrt(sum(magSf*sqr(vals - mean))/sum(magSf))/mean;
|
||||
res =
|
||||
sqrt(gSum(magSf*sqr(vals - mean))/gSumMagSf)
|
||||
/(mean + ROOTVSMALL);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -299,7 +309,7 @@ bool Foam::fieldValues::faceSource::writeValues
|
||||
|
||||
if (ok)
|
||||
{
|
||||
Field<Type> values(getFieldValues<Type>(fieldName, true, orient));
|
||||
Field<Type> values(setFieldValues<Type>(fieldName, true, orient));
|
||||
|
||||
vectorField Sf;
|
||||
if (surfacePtr_.valid())
|
||||
@ -313,13 +323,12 @@ bool Foam::fieldValues::faceSource::writeValues
|
||||
Sf = filterField(mesh().Sf(), true);
|
||||
}
|
||||
|
||||
// Combine onto master
|
||||
combineFields(values);
|
||||
combineFields(Sf);
|
||||
|
||||
// Write raw values on surface if specified
|
||||
if (surfaceWriterPtr_.valid())
|
||||
{
|
||||
Field<Type> allValues(values);
|
||||
combineFields(allValues);
|
||||
|
||||
faceList faces;
|
||||
pointField points;
|
||||
|
||||
@ -344,29 +353,30 @@ bool Foam::fieldValues::faceSource::writeValues
|
||||
points,
|
||||
faces,
|
||||
fieldName,
|
||||
values,
|
||||
allValues,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Apply scale factor
|
||||
values *= scaleFactor_;
|
||||
|
||||
if (Pstream::master())
|
||||
Type result = processValues(values, Sf, weightField);
|
||||
|
||||
file()<< tab << result;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Type result = processValues(values, Sf, weightField);
|
||||
|
||||
// Add to result dictionary, over-writing any previous entry
|
||||
resultDict_.add(fieldName, result, true);
|
||||
|
||||
file()<< tab << result;
|
||||
|
||||
if (log_) Info<< " " << operationTypeNames_[operation_]
|
||||
<< "(" << sourceName_ << ") of " << fieldName
|
||||
Info<< " " << operationTypeNames_[operation_]
|
||||
<< "(" << sourceName_ << ") for " << fieldName
|
||||
<< " = " << result << endl;
|
||||
}
|
||||
|
||||
// Write state/results information
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
word resultName = opName + '(' + sourceName_ + ',' + fieldName + ')';
|
||||
this->setResult(resultName, result);
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,11 +43,14 @@ void Foam::fieldValue::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
dict_ = dict;
|
||||
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
dict.lookup("fields") >> fields_;
|
||||
dict.lookup("valueOutput") >> valueOutput_;
|
||||
dict.readIfPresent("scaleFactor", scaleFactor_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,9 +59,7 @@ void Foam::fieldValue::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << nl;
|
||||
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,37 +75,21 @@ Foam::fieldValue::fieldValue
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, valueType),
|
||||
name_(name),
|
||||
functionObjectState(obr, name),
|
||||
functionObjectFile(obr, name, valueType, dict),
|
||||
obr_(obr),
|
||||
dict_(dict),
|
||||
active_(true),
|
||||
log_(true),
|
||||
sourceName_(word::null),
|
||||
fields_(dict.lookup("fields")),
|
||||
valueOutput_(dict.lookup("valueOutput")),
|
||||
resultDict_(fileName("name"), dictionary::null)
|
||||
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
|
||||
fields_(),
|
||||
valueOutput_(false),
|
||||
scaleFactor_(1.0)
|
||||
{
|
||||
// Only active if obr is an fvMesh
|
||||
if (isA<fvMesh>(obr_))
|
||||
if (setActive<fvMesh>())
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"fieldValue::fieldValue"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name << nl
|
||||
<< endl;
|
||||
active_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +28,7 @@ Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
Base class for field value -based function objects.
|
||||
Base class for field value-based function objects.
|
||||
|
||||
SourceFiles
|
||||
fieldValue.C
|
||||
@ -38,6 +38,7 @@ SourceFiles
|
||||
#ifndef fieldValue_H
|
||||
#define fieldValue_H
|
||||
|
||||
#include "functionObjectState.H"
|
||||
#include "functionObjectFile.H"
|
||||
#include "Switch.H"
|
||||
#include "OFstream.H"
|
||||
@ -62,6 +63,7 @@ class mapPolyMesh;
|
||||
|
||||
class fieldValue
|
||||
:
|
||||
public functionObjectState,
|
||||
public functionObjectFile
|
||||
{
|
||||
|
||||
@ -69,18 +71,12 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this fieldValue object
|
||||
word name_;
|
||||
|
||||
//- Database this class is registered to
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Construction dictionary
|
||||
dictionary dict_;
|
||||
|
||||
//- Active flag
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
@ -93,8 +89,8 @@ protected:
|
||||
//- Output field values flag
|
||||
Switch valueOutput_;
|
||||
|
||||
//- Results dictionary for external access of results
|
||||
dictionary resultDict_;
|
||||
//- Scale factor - optional
|
||||
scalar scaleFactor_;
|
||||
|
||||
|
||||
public:
|
||||
@ -173,9 +169,6 @@ public:
|
||||
//- Helper function to return the reference to the mesh
|
||||
inline const fvMesh& mesh() const;
|
||||
|
||||
//- Return access to the latest set of results
|
||||
inline const dictionary& resultDict() const;
|
||||
|
||||
|
||||
// Function object functions
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -82,10 +82,4 @@ inline const Foam::fvMesh& Foam::fieldValue::mesh() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::dictionary& Foam::fieldValue::resultDict() const
|
||||
{
|
||||
return resultDict_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,16 +37,14 @@ void Foam::fieldValue::combineFields(Field<Type>& field)
|
||||
allValues[Pstream::myProcNo()] = field;
|
||||
|
||||
Pstream::gatherList(allValues);
|
||||
Pstream::scatterList(allValues);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
field =
|
||||
ListListOps::combine<Field<Type> >
|
||||
(
|
||||
allValues,
|
||||
accessOp<Field<Type> >()
|
||||
);
|
||||
}
|
||||
field =
|
||||
ListListOps::combine<Field<Type> >
|
||||
(
|
||||
allValues,
|
||||
accessOp<Field<Type> >()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,30 +54,9 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
Foam::fieldValues::fieldValueDelta::fieldValueDelta
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
loadFromFiles_(loadFromFiles),
|
||||
log_(true),
|
||||
operation_(opSubtract),
|
||||
source1Ptr_(NULL),
|
||||
source2Ptr_(NULL)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
|
||||
void Foam::fieldValues::fieldValueDelta::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
const wordList& fields1 = source1Ptr_->fields();
|
||||
const wordList& fields2 = source2Ptr_->fields();
|
||||
@ -92,8 +71,6 @@ void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
|
||||
}
|
||||
}
|
||||
|
||||
Ostream& os = file();
|
||||
|
||||
writeHeaderValue(os, "Source1", source1Ptr_->name());
|
||||
writeHeaderValue(os, "Source2", source2Ptr_->name());
|
||||
writeHeaderValue(os, "Operation", operationTypeNames_[operation_]);
|
||||
@ -108,6 +85,33 @@ void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldValues::fieldValueDelta::fieldValueDelta
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectState(obr, name),
|
||||
functionObjectFile(obr, name, typeName, dict),
|
||||
obr_(obr),
|
||||
loadFromFiles_(loadFromFiles),
|
||||
log_(true),
|
||||
operation_(opSubtract),
|
||||
source1Ptr_(NULL),
|
||||
source2Ptr_(NULL)
|
||||
{
|
||||
if (setActive<fvMesh>())
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldValues::fieldValueDelta::~fieldValueDelta()
|
||||
@ -118,83 +122,130 @@ Foam::fieldValues::fieldValueDelta::~fieldValueDelta()
|
||||
|
||||
void Foam::fieldValues::fieldValueDelta::read(const dictionary& dict)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
source1Ptr_.reset
|
||||
(
|
||||
fieldValue::New
|
||||
(
|
||||
name_ + ".source1",
|
||||
obr_,
|
||||
dict.subDict("source1"),
|
||||
loadFromFiles_,
|
||||
false
|
||||
).ptr()
|
||||
);
|
||||
source2Ptr_.reset
|
||||
(
|
||||
fieldValue::New
|
||||
(
|
||||
name_ + ".source2",
|
||||
obr_,
|
||||
dict.subDict("source2"),
|
||||
loadFromFiles_,
|
||||
false
|
||||
).ptr()
|
||||
);
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
operation_ = operationTypeNames_.read(dict.lookup("operation"));
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
source1Ptr_.reset
|
||||
(
|
||||
fieldValue::New
|
||||
(
|
||||
name_ + ".source1",
|
||||
obr_,
|
||||
dict.subDict("source1"),
|
||||
loadFromFiles_,
|
||||
false
|
||||
).ptr()
|
||||
);
|
||||
source2Ptr_.reset
|
||||
(
|
||||
fieldValue::New
|
||||
(
|
||||
name_ + ".source2",
|
||||
obr_,
|
||||
dict.subDict("source2"),
|
||||
loadFromFiles_,
|
||||
false
|
||||
).ptr()
|
||||
);
|
||||
|
||||
operation_ = operationTypeNames_.read(dict.lookup("operation"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::fieldValueDelta::write()
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
source1Ptr_->write();
|
||||
source2Ptr_->write();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file()<< obr_.time().value();
|
||||
}
|
||||
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << endl;
|
||||
|
||||
bool found = false;
|
||||
processFields<scalar>(found);
|
||||
processFields<vector>(found);
|
||||
processFields<sphericalTensor>(found);
|
||||
processFields<symmTensor>(found);
|
||||
processFields<tensor>(found);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file()<< endl;
|
||||
}
|
||||
|
||||
if (log_)
|
||||
{
|
||||
if (!found)
|
||||
{
|
||||
Info<< " none" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::fieldValueDelta::execute()
|
||||
{
|
||||
// Do nothing
|
||||
if (active_)
|
||||
{
|
||||
source1Ptr_->write();
|
||||
source2Ptr_->write();
|
||||
|
||||
file()<< obr_.time().value();
|
||||
|
||||
if (log_) Info << type() << " " << name_ << " output:" << endl;
|
||||
|
||||
const word& name1 = source1Ptr_->name();
|
||||
const word& name2 = source2Ptr_->name();
|
||||
|
||||
const wordList entries1 = objectResultEntries(name1);
|
||||
const wordList entries2 = objectResultEntries(name2);
|
||||
|
||||
if (entries1.size() != entries2.size())
|
||||
{
|
||||
FatalErrorIn("void Foam::fieldValues::fieldValueDelta::execute()")
|
||||
<< name_ << ": objects must generate the same number of results"
|
||||
<< nl
|
||||
<< " " << name1 << " objects: " << entries1 << nl
|
||||
<< " " << name2 << " objects: " << entries2 << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
forAll(entries1, i)
|
||||
{
|
||||
const word& entry1(entries1[i]);
|
||||
const word& entry2(entries2[i]);
|
||||
const word type1 = objectResultType(name1, entry1);
|
||||
const word type2 = objectResultType(name2, entry2);
|
||||
|
||||
if (type1 != type2)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"void Foam::fieldValues::fieldValueDelta::execute()"
|
||||
)
|
||||
<< name_
|
||||
<< ": input values for operation must be of the same type"
|
||||
<< nl
|
||||
<< " " << entry1 << ": " << type1 << nl
|
||||
<< " " << entry2 << ": " << type2 << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
|
||||
apply<scalar>(type1, name1, name2, entry1, entry2, found);
|
||||
apply<vector>(type1, name1, name2, entry1, entry2, found);
|
||||
apply<sphericalTensor>(type1, name1, name2, entry1, entry2, found);
|
||||
apply<symmTensor>(type1, name1, name2, entry1, entry2, found);
|
||||
apply<tensor>(type1, name1, name2, entry1, entry2, found);
|
||||
|
||||
if (log_ && !found)
|
||||
{
|
||||
Info<< "Operation between "
|
||||
<< name1 << " with result " << entry1 << " and "
|
||||
<< name2 << " with result " << entry2 << " not applied"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (log_)
|
||||
{
|
||||
if (entries1.empty())
|
||||
{
|
||||
Info<< " none";
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
file()<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::fieldValueDelta::end()
|
||||
{
|
||||
// Do nothing
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,8 +28,11 @@ Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object provides a differencing option between two 'field
|
||||
value' function objects.
|
||||
This function object provides applies an operation to the output of two
|
||||
fieldValue function objects.
|
||||
|
||||
The operation is applied to all results of each fieldValue object.
|
||||
Accordingly, each object must generate the same number and type of results.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
@ -39,11 +42,11 @@ Description
|
||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||
operation subtract;
|
||||
|
||||
fieldValue1
|
||||
source1
|
||||
{
|
||||
...
|
||||
}
|
||||
fieldValue2
|
||||
source2
|
||||
{
|
||||
...
|
||||
}
|
||||
@ -65,6 +68,7 @@ Description
|
||||
max | maximum
|
||||
average | average
|
||||
\endplaintable
|
||||
|
||||
SeeAlso
|
||||
Foam::fieldValue
|
||||
|
||||
@ -76,6 +80,7 @@ SourceFiles
|
||||
#ifndef fieldValueDelta_H
|
||||
#define fieldValueDelta_H
|
||||
|
||||
#include "functionObjectState.H"
|
||||
#include "functionObjectFile.H"
|
||||
#include "fieldValue.H"
|
||||
#include "autoPtr.H"
|
||||
@ -94,6 +99,7 @@ namespace fieldValues
|
||||
|
||||
class fieldValueDelta
|
||||
:
|
||||
public functionObjectState,
|
||||
public functionObjectFile
|
||||
{
|
||||
public:
|
||||
@ -115,9 +121,6 @@ private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Name of this fieldValue object
|
||||
word name_;
|
||||
|
||||
//- Database this class is registered to
|
||||
const objectRegistry& obr_;
|
||||
|
||||
@ -139,13 +142,17 @@ private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Templated function to process common fields
|
||||
template<class Type>
|
||||
void processFields(bool& found);
|
||||
|
||||
//- Templated function to apply the operation
|
||||
template<class Type>
|
||||
Type applyOperation(const Type& value1, const Type& value2) const;
|
||||
void apply
|
||||
(
|
||||
const word& resultType,
|
||||
const word& name1,
|
||||
const word& name2,
|
||||
const word& entryName1,
|
||||
const word& entryName2,
|
||||
bool& found
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
@ -153,7 +160,7 @@ protected:
|
||||
// Functions to be over-ridden from IOoutputFilter class
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,21 +23,31 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "GeometricField.H"
|
||||
#include "volMesh.H"
|
||||
#include "surfaceMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::fieldValues::fieldValueDelta::applyOperation
|
||||
void Foam::fieldValues::fieldValueDelta::apply
|
||||
(
|
||||
const Type& value1,
|
||||
const Type& value2
|
||||
) const
|
||||
const word& resultType,
|
||||
const word& name1,
|
||||
const word& name2,
|
||||
const word& entryName1,
|
||||
const word& entryName2,
|
||||
bool& found
|
||||
)
|
||||
{
|
||||
if (pTraits<Type>::typeName != resultType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Type result = pTraits<Type>::zero;
|
||||
|
||||
Type value1 = this->getObjectResult<Type>(name1, entryName1);
|
||||
Type value2 = this->getObjectResult<Type>(name2, entryName2);
|
||||
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
|
||||
switch (operation_)
|
||||
{
|
||||
case opAdd:
|
||||
@ -69,63 +79,32 @@ Type Foam::fieldValues::fieldValueDelta::applyOperation
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Type Foam::fieldValues::fieldValueDelta::applyOperation"
|
||||
"void Foam::fieldValues::fieldValueDelta::applyOperation"
|
||||
"("
|
||||
"const Type&, "
|
||||
"const Type&"
|
||||
"const word&, "
|
||||
"const word&, "
|
||||
"const word&, "
|
||||
"const word&, "
|
||||
"const word&"
|
||||
"bool&"
|
||||
") const"
|
||||
)
|
||||
<< "Unable to process operation "
|
||||
<< operationTypeNames_[operation_]
|
||||
<< "Operation not supported: "
|
||||
<< opName
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
const word resultName(opName + '(' + entryName1 + ',' + entryName2 + ')');
|
||||
|
||||
if (log_) Info << " " << resultName << " = " << result << endl;
|
||||
|
||||
template<class Type>
|
||||
void Foam::fieldValues::fieldValueDelta::processFields(bool& found)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
|
||||
this->file()<< tab << result;
|
||||
|
||||
const wordList& fields1 = source1Ptr_->fields();
|
||||
// Write state/results information
|
||||
this->setResult(resultName, result);
|
||||
|
||||
const dictionary& results1 = source1Ptr_->resultDict();
|
||||
const dictionary& results2 = source2Ptr_->resultDict();
|
||||
|
||||
Type r1(pTraits<Type>::zero);
|
||||
Type r2(pTraits<Type>::zero);
|
||||
|
||||
forAll(fields1, i)
|
||||
{
|
||||
const word& fieldName = fields1[i];
|
||||
|
||||
if
|
||||
(
|
||||
(obr_.foundObject<vf>(fieldName) || obr_.foundObject<sf>(fieldName))
|
||||
&& results2.found(fieldName)
|
||||
)
|
||||
{
|
||||
results1.lookup(fieldName) >> r1;
|
||||
results2.lookup(fieldName) >> r2;
|
||||
|
||||
Type result = applyOperation(r1, r2);
|
||||
|
||||
if (log_) Info<< " " << operationTypeNames_[operation_]
|
||||
<< "(" << fieldName << ") = " << result
|
||||
<< endl;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file()<< tab << result;
|
||||
}
|
||||
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -72,8 +72,11 @@ void Foam::regionSizeDistribution::writeGraph
|
||||
|
||||
OFstream str(outputPath/formatterPtr_().getFileName(coords, valNames));
|
||||
|
||||
Info<< "Writing distribution of " << valueName << " to " << str.name()
|
||||
<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< "Writing distribution of " << valueName << " to " << str.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
List<const scalarField*> valPtrs(1);
|
||||
valPtrs[0] = &values;
|
||||
@ -149,16 +152,26 @@ void Foam::regionSizeDistribution::writeAlphaFields
|
||||
liquidCore.correctBoundaryConditions();
|
||||
backgroundAlpha.correctBoundaryConditions();
|
||||
|
||||
Info<< " Volume of liquid-core = "
|
||||
<< fvc::domainIntegrate(liquidCore).value()
|
||||
<< endl;
|
||||
Info<< " Volume of background = "
|
||||
<< fvc::domainIntegrate(backgroundAlpha).value()
|
||||
<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Volume of liquid-core = "
|
||||
<< fvc::domainIntegrate(liquidCore).value()
|
||||
<< endl;
|
||||
Info<< " Volume of background = "
|
||||
<< fvc::domainIntegrate(backgroundAlpha).value()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Info<< "Writing liquid-core field to " << liquidCore.name() << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< "Writing liquid-core field to " << liquidCore.name() << endl;
|
||||
}
|
||||
liquidCore.write();
|
||||
Info<< "Writing background field to " << backgroundAlpha.name() << endl;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< "Writing background field to " << backgroundAlpha.name() << endl;
|
||||
}
|
||||
backgroundAlpha.write();
|
||||
}
|
||||
|
||||
@ -322,12 +335,13 @@ Foam::regionSizeDistribution::regionSizeDistribution
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
functionObjectFile(obr, name),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
alphaName_(dict.lookup("field")),
|
||||
patchNames_(dict.lookup("patches"))
|
||||
patchNames_(dict.lookup("patches")),
|
||||
log_(true)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (isA<fvMesh>(obr_))
|
||||
@ -364,6 +378,10 @@ void Foam::regionSizeDistribution::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
log_.readIfPresent("log", dict);
|
||||
|
||||
dict.lookup("field") >> alphaName_;
|
||||
dict.lookup("patches") >> patchNames_;
|
||||
dict.lookup("threshold") >> threshold_;
|
||||
@ -380,8 +398,11 @@ void Foam::regionSizeDistribution::read(const dictionary& dict)
|
||||
{
|
||||
coordSysPtr_.reset(new coordinateSystem(obr_, dict));
|
||||
|
||||
Info<< "Transforming all vectorFields with coordinate system "
|
||||
<< coordSysPtr_().name() << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< "Transforming all vectorFields with coordinate system "
|
||||
<< coordSysPtr_().name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -409,18 +430,18 @@ void Foam::regionSizeDistribution::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
autoPtr<volScalarField> alphaPtr;
|
||||
if (obr_.foundObject<volScalarField>(alphaName_))
|
||||
{
|
||||
Info<< " Looking up field " << alphaName_ << endl;
|
||||
if (log_) Info << " Looking up field " << alphaName_ << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " Reading field " << alphaName_ << endl;
|
||||
if (log_) Info << " Reading field " << alphaName_ << endl;
|
||||
alphaPtr.reset
|
||||
(
|
||||
new volScalarField
|
||||
@ -446,17 +467,24 @@ void Foam::regionSizeDistribution::write()
|
||||
: obr_.lookupObject<volScalarField>(alphaName_)
|
||||
);
|
||||
|
||||
Info<< " Volume of alpha = "
|
||||
<< fvc::domainIntegrate(alpha).value()
|
||||
<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Volume of alpha = "
|
||||
<< fvc::domainIntegrate(alpha).value()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
const scalar meshVol = gSum(mesh.V());
|
||||
const scalar maxDropletVol = 1.0/6.0*pow(maxDiam_, 3);
|
||||
const scalar delta = (maxDiam_-minDiam_)/nBins_;
|
||||
|
||||
Info<< " Mesh volume = " << meshVol << endl;
|
||||
Info<< " Maximum droplet diameter = " << maxDiam_ << endl;
|
||||
Info<< " Maximum droplet volume = " << maxDropletVol << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Mesh volume = " << meshVol << nl
|
||||
<< " Maximum droplet diameter = " << maxDiam_ << nl
|
||||
<< " Maximum droplet volume = " << maxDropletVol
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// Determine blocked faces
|
||||
@ -515,8 +543,11 @@ void Foam::regionSizeDistribution::write()
|
||||
|
||||
regionSplit regions(mesh, blockedFace);
|
||||
|
||||
Info<< " Determined " << regions.nRegions()
|
||||
<< " disconnected regions" << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Determined " << regions.nRegions()
|
||||
<< " disconnected regions" << endl;
|
||||
}
|
||||
|
||||
|
||||
if (debug)
|
||||
@ -534,8 +565,13 @@ void Foam::regionSizeDistribution::write()
|
||||
mesh,
|
||||
dimensionedScalar("zero", dimless, 0)
|
||||
);
|
||||
Info<< " Dumping region as volScalarField to " << region.name()
|
||||
<< endl;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Dumping region as " << volScalarField::typeName
|
||||
<< " to " << region.name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
forAll(regions, cellI)
|
||||
{
|
||||
@ -566,11 +602,15 @@ void Foam::regionSizeDistribution::write()
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< " " << token::TAB << "Region"
|
||||
<< token::TAB << "Volume(mesh)"
|
||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||
<< token::TAB << "nCells"
|
||||
<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " " << token::TAB << "Region"
|
||||
<< token::TAB << "Volume(mesh)"
|
||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||
<< token::TAB << "nCells"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
scalar meshSumVol = 0.0;
|
||||
scalar alphaSumVol = 0.0;
|
||||
label nCells = 0;
|
||||
@ -586,50 +626,61 @@ void Foam::regionSizeDistribution::write()
|
||||
++vIter, ++aIter, ++numIter
|
||||
)
|
||||
{
|
||||
Info<< " " << token::TAB << vIter.key()
|
||||
<< token::TAB << vIter()
|
||||
<< token::TAB << aIter()
|
||||
<< token::TAB << numIter()
|
||||
<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " " << token::TAB << vIter.key()
|
||||
<< token::TAB << vIter()
|
||||
<< token::TAB << aIter()
|
||||
<< token::TAB << numIter()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
meshSumVol += vIter();
|
||||
alphaSumVol += aIter();
|
||||
nCells += numIter();
|
||||
}
|
||||
Info<< " " << token::TAB << "Total:"
|
||||
<< token::TAB << meshSumVol
|
||||
<< token::TAB << alphaSumVol
|
||||
<< token::TAB << nCells
|
||||
<< endl;
|
||||
Info<< endl;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " " << token::TAB << "Total:"
|
||||
<< token::TAB << meshSumVol
|
||||
<< token::TAB << alphaSumVol
|
||||
<< token::TAB << nCells
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Patch connected regions (liquid core):" << endl;
|
||||
Info<< token::TAB << " Region"
|
||||
Info<< " Patch connected regions (liquid core):" << nl
|
||||
<< token::TAB << " Region"
|
||||
<< token::TAB << "Volume(mesh)"
|
||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||
<< endl;
|
||||
|
||||
forAllConstIter(Map<label>, patchRegions, iter)
|
||||
{
|
||||
label regionI = iter.key();
|
||||
|
||||
Info<< " " << token::TAB << iter.key()
|
||||
<< token::TAB << allRegionVolume[regionI]
|
||||
<< token::TAB << allRegionAlphaVolume[regionI] << endl;
|
||||
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Background regions:" << endl;
|
||||
Info<< " " << token::TAB << "Region"
|
||||
Info<< " Background regions:" << nl
|
||||
<< " " << token::TAB << "Region"
|
||||
<< token::TAB << "Volume(mesh)"
|
||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||
<< endl;
|
||||
|
||||
Map<scalar>::const_iterator vIter = allRegionVolume.begin();
|
||||
Map<scalar>::const_iterator aIter = allRegionAlphaVolume.begin();
|
||||
|
||||
@ -652,6 +703,7 @@ void Foam::regionSizeDistribution::write()
|
||||
<< token::TAB << aIter() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -746,9 +798,10 @@ void Foam::regionSizeDistribution::write()
|
||||
}
|
||||
|
||||
// Write to screen
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Bins:" << endl;
|
||||
Info<< " " << token::TAB << "Bin"
|
||||
Info<< " Bins:" << nl
|
||||
<< " " << token::TAB << "Bin"
|
||||
<< token::TAB << "Min diameter"
|
||||
<< token::TAB << "Count:"
|
||||
<< endl;
|
||||
@ -759,8 +812,10 @@ void Foam::regionSizeDistribution::write()
|
||||
Info<< " " << token::TAB << binI
|
||||
<< token::TAB << diam
|
||||
<< token::TAB << binCount[binI] << endl;
|
||||
|
||||
diam += delta;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -783,7 +838,7 @@ void Foam::regionSizeDistribution::write()
|
||||
forAll(selected, i)
|
||||
{
|
||||
const word& fldName = scalarNames[selected[i]];
|
||||
Info<< " Scalar field " << fldName << endl;
|
||||
if (log_) Info << " Scalar field " << fldName << endl;
|
||||
|
||||
const scalarField& fld = obr_.lookupObject
|
||||
<
|
||||
@ -812,7 +867,7 @@ void Foam::regionSizeDistribution::write()
|
||||
forAll(selected, i)
|
||||
{
|
||||
const word& fldName = vectorNames[selected[i]];
|
||||
Info<< " Vector field " << fldName << endl;
|
||||
if (log_) Info << " Vector field " << fldName << endl;
|
||||
|
||||
vectorField fld = obr_.lookupObject
|
||||
<
|
||||
@ -821,10 +876,13 @@ void Foam::regionSizeDistribution::write()
|
||||
|
||||
if (coordSysPtr_.valid())
|
||||
{
|
||||
Info<< "Transforming vector field " << fldName
|
||||
<< " with coordinate system "
|
||||
<< coordSysPtr_().name()
|
||||
<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< "Transforming vector field " << fldName
|
||||
<< " with coordinate system "
|
||||
<< coordSysPtr_().name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
fld = coordSysPtr_().localVector(fld);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -92,6 +92,7 @@ Description
|
||||
minDiameter | minimum region equivalent diameter | no | 0
|
||||
setFormat | writing format | yes |
|
||||
coordinateSystem | transformation for vector fields | no |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
@ -113,6 +114,7 @@ SourceFiles
|
||||
#include "volFieldsFwd.H"
|
||||
#include "wordReList.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -150,6 +152,9 @@ class regionSizeDistribution
|
||||
//- Patches to walk from
|
||||
wordReList patchNames_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Clip value
|
||||
scalar threshold_;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -580,41 +580,55 @@ void Foam::streamLine::write()
|
||||
|
||||
// Distribute the track positions. Note: use scheduled comms
|
||||
// to prevent buffering.
|
||||
mapDistribute::distribute
|
||||
allTracks_.shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
allTracks_
|
||||
false,
|
||||
allTracks_,
|
||||
flipOp()
|
||||
);
|
||||
|
||||
// Distribute the scalars
|
||||
forAll(allScalars_, scalarI)
|
||||
{
|
||||
mapDistribute::distribute
|
||||
allScalars_[scalarI].shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
allScalars_[scalarI]
|
||||
false,
|
||||
allScalars_[scalarI],
|
||||
flipOp()
|
||||
);
|
||||
allScalars_[scalarI].setCapacity(allScalars_[scalarI].size());
|
||||
}
|
||||
// Distribute the vectors
|
||||
forAll(allVectors_, vectorI)
|
||||
{
|
||||
mapDistribute::distribute
|
||||
allVectors_[vectorI].shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
allVectors_[vectorI]
|
||||
false,
|
||||
allVectors_[vectorI],
|
||||
flipOp()
|
||||
);
|
||||
allVectors_[vectorI].setCapacity(allVectors_[vectorI].size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -705,41 +705,55 @@ void Foam::wallBoundedStreamLine::write()
|
||||
|
||||
// Distribute the track positions. Note: use scheduled comms
|
||||
// to prevent buffering.
|
||||
mapDistribute::distribute
|
||||
allTracks_.shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
allTracks_
|
||||
false,
|
||||
allTracks_,
|
||||
flipOp()
|
||||
);
|
||||
|
||||
// Distribute the scalars
|
||||
forAll(allScalars_, scalarI)
|
||||
{
|
||||
mapDistribute::distribute
|
||||
allScalars_[scalarI].shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
allScalars_[scalarI]
|
||||
false,
|
||||
allScalars_[scalarI],
|
||||
flipOp()
|
||||
);
|
||||
allScalars_[scalarI].setCapacity(allScalars_[scalarI].size());
|
||||
}
|
||||
// Distribute the vectors
|
||||
forAll(allVectors_, vectorI)
|
||||
{
|
||||
mapDistribute::distribute
|
||||
allVectors_[vectorI].shrink();
|
||||
mapDistributeBase::distribute
|
||||
(
|
||||
Pstream::scheduled,
|
||||
distMap.schedule(),
|
||||
distMap.constructSize(),
|
||||
distMap.subMap(),
|
||||
false,
|
||||
distMap.constructMap(),
|
||||
allVectors_[vectorI]
|
||||
false,
|
||||
allVectors_[vectorI],
|
||||
flipOp()
|
||||
);
|
||||
allVectors_[vectorI].setCapacity(allVectors_[vectorI].size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,9 @@ License
|
||||
#include "Time.H"
|
||||
#include "Pstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "fvMesh.H"
|
||||
#include "dimensionedTypes.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -39,81 +42,157 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::forceCoeffs::writeFileHeader(const label i)
|
||||
void Foam::forceCoeffs::createFiles()
|
||||
{
|
||||
if (i == 0)
|
||||
// Note: Only possible to create bin files after bins have been initialised
|
||||
|
||||
if (writeToFile() && !coeffFilePtr_.valid())
|
||||
{
|
||||
// force coeff data
|
||||
coeffFilePtr_ = createFile("coefficient");
|
||||
writeIntegratedHeader("Coefficients", coeffFilePtr_());
|
||||
|
||||
writeHeader(file(i), "Force coefficients");
|
||||
writeHeaderValue(file(i), "liftDir", liftDir_);
|
||||
writeHeaderValue(file(i), "dragDir", dragDir_);
|
||||
writeHeaderValue(file(i), "pitchAxis", pitchAxis_);
|
||||
writeHeaderValue(file(i), "magUInf", magUInf_);
|
||||
writeHeaderValue(file(i), "lRef", lRef_);
|
||||
writeHeaderValue(file(i), "Aref", Aref_);
|
||||
writeHeaderValue(file(i), "CofR", coordSys_.origin());
|
||||
writeCommented(file(i), "Time");
|
||||
writeTabbed(file(i), "Cm");
|
||||
writeTabbed(file(i), "Cd");
|
||||
writeTabbed(file(i), "Cl");
|
||||
writeTabbed(file(i), "Cl(f)");
|
||||
writeTabbed(file(i), "Cl(r)");
|
||||
file(i)
|
||||
<< tab << "Cm" << tab << "Cd" << tab << "Cl" << tab << "Cl(f)"
|
||||
<< tab << "Cl(r)";
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
// bin coeff data
|
||||
|
||||
writeHeader(file(i), "Force coefficient bins");
|
||||
writeHeaderValue(file(i), "bins", nBin_);
|
||||
writeHeaderValue(file(i), "start", binMin_);
|
||||
writeHeaderValue(file(i), "delta", binDx_);
|
||||
writeHeaderValue(file(i), "direction", binDir_);
|
||||
|
||||
vectorField binPoints(nBin_);
|
||||
writeCommented(file(i), "x co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
if (nBin_ > 1)
|
||||
{
|
||||
binPoints[pointI] = (binMin_ + (pointI + 1)*binDx_)*binDir_;
|
||||
file(i) << tab << binPoints[pointI].x();
|
||||
}
|
||||
file(i) << nl;
|
||||
|
||||
writeCommented(file(i), "y co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
{
|
||||
file(i) << tab << binPoints[pointI].y();
|
||||
}
|
||||
file(i) << nl;
|
||||
|
||||
writeCommented(file(i), "z co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
{
|
||||
file(i) << tab << binPoints[pointI].z();
|
||||
}
|
||||
file(i) << nl;
|
||||
|
||||
writeCommented(file(i), "Time");
|
||||
|
||||
for (label j = 0; j < nBin_; j++)
|
||||
{
|
||||
const word jn('(' + Foam::name(j) + ')');
|
||||
writeTabbed(file(i), "Cm" + jn);
|
||||
writeTabbed(file(i), "Cd" + jn);
|
||||
writeTabbed(file(i), "Cl" + jn);
|
||||
CmBinFilePtr_ = createFile("CmBin");
|
||||
writeBinHeader("Moment coefficient bins", CmBinFilePtr_());
|
||||
CdBinFilePtr_ = createFile("CdBin");
|
||||
writeBinHeader("Drag coefficient bins", CdBinFilePtr_());
|
||||
ClBinFilePtr_ = createFile("ClBin");
|
||||
writeBinHeader("Lift coefficient bins", ClBinFilePtr_());
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeIntegratedHeader
|
||||
(
|
||||
const word& header,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeHeader(os, "Force coefficients");
|
||||
writeHeaderValue(os, "liftDir", liftDir_);
|
||||
writeHeaderValue(os, "dragDir", dragDir_);
|
||||
writeHeaderValue(os, "pitchAxis", pitchAxis_);
|
||||
writeHeaderValue(os, "magUInf", magUInf_);
|
||||
writeHeaderValue(os, "lRef", lRef_);
|
||||
writeHeaderValue(os, "Aref", Aref_);
|
||||
writeHeaderValue(os, "CofR", coordSys_.origin());
|
||||
writeHeader(os, "");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "Cm");
|
||||
writeTabbed(os, "Cd");
|
||||
writeTabbed(os, "Cl");
|
||||
writeTabbed(os, "Cl(f)");
|
||||
writeTabbed(os, "Cl(r)");
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeBinHeader
|
||||
(
|
||||
const word& header,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
writeHeader(os, header);
|
||||
writeHeaderValue(os, "bins", nBin_);
|
||||
writeHeaderValue(os, "start", binMin_);
|
||||
writeHeaderValue(os, "delta", binDx_);
|
||||
writeHeaderValue(os, "direction", binDir_);
|
||||
|
||||
vectorField binPoints(nBin_);
|
||||
writeCommented(os, "x co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
{
|
||||
FatalErrorIn("void Foam::forces::writeFileHeader(const label)")
|
||||
<< "Unhandled file index: " << i
|
||||
<< abort(FatalError);
|
||||
binPoints[pointI] = (binMin_ + (pointI + 1)*binDx_)*binDir_;
|
||||
os << tab << binPoints[pointI].x();
|
||||
}
|
||||
os << nl;
|
||||
|
||||
writeCommented(os, "y co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
{
|
||||
os << tab << binPoints[pointI].y();
|
||||
}
|
||||
os << nl;
|
||||
|
||||
writeCommented(os, "z co-ords :");
|
||||
forAll(binPoints, pointI)
|
||||
{
|
||||
os << tab << binPoints[pointI].z();
|
||||
}
|
||||
os << nl;
|
||||
|
||||
writeHeader(os, "");
|
||||
writeCommented(os, "Time");
|
||||
|
||||
for (label j = 0; j < nBin_; j++)
|
||||
{
|
||||
word jn(Foam::name(j) + ':');
|
||||
writeTabbed(os, jn + "total");
|
||||
writeTabbed(os, jn + "pressure");
|
||||
writeTabbed(os, jn + "viscous");
|
||||
|
||||
if (porosity_)
|
||||
{
|
||||
writeTabbed(os, jn + "porous");
|
||||
}
|
||||
}
|
||||
|
||||
file(i)<< endl;
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeIntegratedData
|
||||
(
|
||||
const word& title,
|
||||
const List<Field<scalar> >& coeff
|
||||
) const
|
||||
{
|
||||
scalar pressure = sum(coeff[0]);
|
||||
scalar viscous = sum(coeff[1]);
|
||||
scalar porous = sum(coeff[2]);
|
||||
scalar total = pressure + viscous + porous;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " " << title << " : " << total << token::TAB
|
||||
<< "("
|
||||
<< "pressure: " << pressure << token::TAB
|
||||
<< "viscous: " << viscous;
|
||||
|
||||
if (porosity_)
|
||||
{
|
||||
Info<< token::TAB << "porous: " << porous;
|
||||
}
|
||||
|
||||
Info<< ")" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::writeBinData
|
||||
(
|
||||
const List<Field<scalar> > coeffs,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << obr_.time().value();
|
||||
|
||||
for (label binI = 0; binI < nBin_; binI++)
|
||||
{
|
||||
scalar total = coeffs[0][binI] + coeffs[1][binI] + coeffs[2][binI];
|
||||
|
||||
os << tab << total << tab << coeffs[0][binI] << tab << coeffs[1][binI];
|
||||
|
||||
if (porosity_)
|
||||
{
|
||||
os << tab << coeffs[2][binI];
|
||||
}
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -124,7 +203,8 @@ Foam::forceCoeffs::forceCoeffs
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
const bool loadFromFiles,
|
||||
const bool readFields
|
||||
)
|
||||
:
|
||||
forces(name, obr, dict, loadFromFiles, false),
|
||||
@ -133,11 +213,17 @@ Foam::forceCoeffs::forceCoeffs
|
||||
pitchAxis_(vector::zero),
|
||||
magUInf_(0.0),
|
||||
lRef_(0.0),
|
||||
Aref_(0.0)
|
||||
Aref_(0.0),
|
||||
coeffFilePtr_(),
|
||||
CmBinFilePtr_(),
|
||||
CdBinFilePtr_(),
|
||||
ClBinFilePtr_()
|
||||
{
|
||||
read(dict);
|
||||
|
||||
Info<< endl;
|
||||
if (readFields)
|
||||
{
|
||||
read(dict);
|
||||
if (log_) Info << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -151,115 +237,225 @@ Foam::forceCoeffs::~forceCoeffs()
|
||||
|
||||
void Foam::forceCoeffs::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
if (!active_)
|
||||
{
|
||||
forces::read(dict);
|
||||
return;
|
||||
}
|
||||
|
||||
// Directions for lift and drag forces, and pitch moment
|
||||
dict.lookup("liftDir") >> liftDir_;
|
||||
dict.lookup("dragDir") >> dragDir_;
|
||||
dict.lookup("pitchAxis") >> pitchAxis_;
|
||||
forces::read(dict);
|
||||
|
||||
// Free stream velocity magnitude
|
||||
dict.lookup("magUInf") >> magUInf_;
|
||||
// Directions for lift and drag forces, and pitch moment
|
||||
dict.lookup("liftDir") >> liftDir_;
|
||||
dict.lookup("dragDir") >> dragDir_;
|
||||
dict.lookup("pitchAxis") >> pitchAxis_;
|
||||
|
||||
// Reference length and area scales
|
||||
dict.lookup("lRef") >> lRef_;
|
||||
dict.lookup("Aref") >> Aref_;
|
||||
// Free stream velocity magnitude
|
||||
dict.lookup("magUInf") >> magUInf_;
|
||||
|
||||
// Reference length and area scales
|
||||
dict.lookup("lRef") >> lRef_;
|
||||
dict.lookup("Aref") >> Aref_;
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
tmp<volVectorField> tforceCoeff
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName("forceCoeff"),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector("0", dimless, vector::zero)
|
||||
)
|
||||
);
|
||||
|
||||
obr_.store(tforceCoeff.ptr());
|
||||
|
||||
tmp<volVectorField> tmomentCoeff
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName("momentCoeff"),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector("0", dimless, vector::zero)
|
||||
)
|
||||
);
|
||||
|
||||
obr_.store(tmomentCoeff.ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::execute()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::timeSet()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::write()
|
||||
{
|
||||
forces::calcForcesMoment();
|
||||
|
||||
if (!active_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
forces::calcForcesMoment();
|
||||
|
||||
createFiles();
|
||||
|
||||
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
|
||||
|
||||
// Storage for pressure, viscous and porous contributions to coeffs
|
||||
List<Field<scalar> > momentCoeffs(3);
|
||||
List<Field<scalar> > dragCoeffs(3);
|
||||
List<Field<scalar> > liftCoeffs(3);
|
||||
forAll(liftCoeffs, i)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
momentCoeffs[i].setSize(nBin_);
|
||||
dragCoeffs[i].setSize(nBin_);
|
||||
liftCoeffs[i].setSize(nBin_);
|
||||
}
|
||||
|
||||
scalar pDyn = 0.5*rhoRef_*magUInf_*magUInf_;
|
||||
// Calculate coefficients
|
||||
scalar CmTot = 0;
|
||||
scalar CdTot = 0;
|
||||
scalar ClTot = 0;
|
||||
forAll(liftCoeffs, i)
|
||||
{
|
||||
momentCoeffs[i] = (moment_[i] & pitchAxis_)/(Aref_*pDyn*lRef_);
|
||||
dragCoeffs[i] = (force_[i] & dragDir_)/(Aref_*pDyn);
|
||||
liftCoeffs[i] = (force_[i] & liftDir_)/(Aref_*pDyn);
|
||||
|
||||
Field<vector> totForce(force_[0] + force_[1] + force_[2]);
|
||||
Field<vector> totMoment(moment_[0] + moment_[1] + moment_[2]);
|
||||
CmTot += sum(momentCoeffs[i]);
|
||||
CdTot += sum(dragCoeffs[i]);
|
||||
ClTot += sum(liftCoeffs[i]);
|
||||
}
|
||||
|
||||
List<Field<scalar> > coeffs(3);
|
||||
coeffs[0].setSize(nBin_);
|
||||
coeffs[1].setSize(nBin_);
|
||||
coeffs[2].setSize(nBin_);
|
||||
scalar ClfTot = ClTot/2.0 + CmTot;
|
||||
scalar ClrTot = ClTot/2.0 - CmTot;
|
||||
|
||||
// lift, drag and moment
|
||||
coeffs[0] = (totForce & liftDir_)/(Aref_*pDyn);
|
||||
coeffs[1] = (totForce & dragDir_)/(Aref_*pDyn);
|
||||
coeffs[2] = (totMoment & pitchAxis_)/(Aref_*lRef_*pDyn);
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " Coefficients" << nl;
|
||||
}
|
||||
writeIntegratedData("Cm", momentCoeffs);
|
||||
writeIntegratedData("Cd", dragCoeffs);
|
||||
writeIntegratedData("Cl", liftCoeffs);
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Cl(f) : " << ClfTot << nl
|
||||
<< " Cl(r) : " << ClrTot << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
scalar Cl = sum(coeffs[0]);
|
||||
scalar Cd = sum(coeffs[1]);
|
||||
scalar Cm = sum(coeffs[2]);
|
||||
if (writeToFile())
|
||||
{
|
||||
coeffFilePtr_()
|
||||
<< obr_.time().value() << tab << CmTot << tab << CdTot
|
||||
<< tab << ClTot << tab << ClfTot << tab << ClrTot << endl;
|
||||
|
||||
scalar Clf = Cl/2.0 + Cm;
|
||||
scalar Clr = Cl/2.0 - Cm;
|
||||
|
||||
file(0)
|
||||
<< obr_.time().value() << tab << Cm << tab << Cd
|
||||
<< tab << Cl << tab << Clf << tab << Clr << endl;
|
||||
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " Cm = " << Cm << nl
|
||||
<< " Cd = " << Cd << nl
|
||||
<< " Cl = " << Cl << nl
|
||||
<< " Cl(f) = " << Clf << nl
|
||||
<< " Cl(r) = " << Clr << endl;
|
||||
|
||||
if (nBin_ > 1)
|
||||
{
|
||||
if (binCumulative_)
|
||||
{
|
||||
for (label i = 1; i < coeffs[0].size(); i++)
|
||||
forAll(liftCoeffs, i)
|
||||
{
|
||||
coeffs[0][i] += coeffs[0][i-1];
|
||||
coeffs[1][i] += coeffs[1][i-1];
|
||||
coeffs[2][i] += coeffs[2][i-1];
|
||||
for (label binI = 1; binI < nBin_; binI++)
|
||||
{
|
||||
liftCoeffs[i][binI] += liftCoeffs[i][binI-1];
|
||||
dragCoeffs[i][binI] += dragCoeffs[i][binI-1];
|
||||
momentCoeffs[i][binI] += momentCoeffs[i][binI-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file(1)<< obr_.time().value();
|
||||
|
||||
forAll(coeffs[0], i)
|
||||
{
|
||||
file(1)
|
||||
<< tab << coeffs[2][i]
|
||||
<< tab << coeffs[1][i]
|
||||
<< tab << coeffs[0][i];
|
||||
}
|
||||
|
||||
file(1) << endl;
|
||||
writeBinData(dragCoeffs, CdBinFilePtr_());
|
||||
writeBinData(liftCoeffs, ClBinFilePtr_());
|
||||
writeBinData(momentCoeffs, CmBinFilePtr_());
|
||||
}
|
||||
}
|
||||
|
||||
if (log_) Info<< endl;
|
||||
// Write state/results information
|
||||
{
|
||||
setResult("Cm", CmTot);
|
||||
setResult("Cd", CdTot);
|
||||
setResult("Cl", ClTot);
|
||||
setResult("Cl(f)", ClfTot);
|
||||
setResult("Cl(r)", ClrTot);
|
||||
}
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
const volVectorField& force =
|
||||
obr_.lookupObject<volVectorField>(fieldName("force"));
|
||||
|
||||
const volVectorField& moment =
|
||||
obr_.lookupObject<volVectorField>(fieldName("moment"));
|
||||
|
||||
volVectorField& forceCoeff =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
obr_.lookupObject<volVectorField>(fieldName("forceCoeff"))
|
||||
);
|
||||
|
||||
volVectorField& momentCoeff =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
obr_.lookupObject<volVectorField>(fieldName("momentCoeff"))
|
||||
);
|
||||
|
||||
dimensionedScalar f0("f0", dimForce, Aref_*pDyn);
|
||||
dimensionedScalar m0("m0", dimForce*dimLength, Aref_*lRef_*pDyn);
|
||||
|
||||
forceCoeff == force/f0;
|
||||
momentCoeff == moment/m0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::forceCoeffs::write()
|
||||
{
|
||||
if (!active_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
const volVectorField& forceCoeff =
|
||||
obr_.lookupObject<volVectorField>(fieldName("forceCoeff"));
|
||||
|
||||
const volVectorField& momentCoeff =
|
||||
obr_.lookupObject<volVectorField>(fieldName("momentCoeff"));
|
||||
|
||||
forceCoeff.write();
|
||||
momentCoeff.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,6 +32,19 @@ Description
|
||||
lift, drag and moment coefficients. The data can optionally be output into
|
||||
bins, defined in a given direction.
|
||||
|
||||
The binned data provides the total and consitituentcomponents per bin:
|
||||
- total coefficient
|
||||
- pressure coefficient contribution
|
||||
- viscous coefficient contribution
|
||||
- porous coefficient contribution
|
||||
|
||||
Data is written into multiple files in the
|
||||
postProcessing/\<functionObjectName\> directory:
|
||||
- coefficient.dat : integrated coefficients over all geometries
|
||||
- CmBin.dat : moment coefficient bins
|
||||
- CdBin.dat : drag coefficient bins
|
||||
- ClBin.dat : lift coefficient bins
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
forceCoeffs1
|
||||
@ -40,6 +53,7 @@ Description
|
||||
functionObjectLibs ("libforces.so");
|
||||
...
|
||||
log yes;
|
||||
writeFields yes;
|
||||
patches (walls);
|
||||
liftDir (0 1 0);
|
||||
dragDir (-1 0 0);
|
||||
@ -62,6 +76,7 @@ Description
|
||||
Property | Description | Required | Default value
|
||||
type | type name: forces | yes |
|
||||
log | write force data to standard output | no | no
|
||||
writeFields | write the force and moment coefficient fields | no | no
|
||||
patches | patches included in the forces calculation | yes |
|
||||
liftDir | lift direction | yes |
|
||||
dragDir | drag direction | yes |
|
||||
@ -137,6 +152,21 @@ class forceCoeffs
|
||||
scalar Aref_;
|
||||
|
||||
|
||||
// File streams
|
||||
|
||||
//- Integrated coefficients
|
||||
autoPtr<OFstream> coeffFilePtr_;
|
||||
|
||||
//- Moment coefficient
|
||||
autoPtr<OFstream> CmBinFilePtr_;
|
||||
|
||||
//- Drag coefficient
|
||||
autoPtr<OFstream> CdBinFilePtr_;
|
||||
|
||||
//- Lift coefficient
|
||||
autoPtr<OFstream> ClBinFilePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -148,8 +178,26 @@ class forceCoeffs
|
||||
|
||||
protected:
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
// Protected Member Functions
|
||||
|
||||
//- Create the output files
|
||||
void createFiles();
|
||||
|
||||
//- Write header for integrated data
|
||||
void writeIntegratedHeader(const word& header, Ostream& os) const;
|
||||
|
||||
//- Write header for binned data
|
||||
void writeBinHeader(const word& header, Ostream& os) const;
|
||||
|
||||
//- Write integrated data
|
||||
void writeIntegratedData
|
||||
(
|
||||
const word& title,
|
||||
const List<Field<scalar> >& coeff
|
||||
) const;
|
||||
|
||||
//- Write binned data
|
||||
void writeBinData(const List<Field<scalar> > coeffs, Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -167,7 +215,8 @@ public:
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
const bool loadFromFiles = false,
|
||||
const bool readFields = true
|
||||
);
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,11 +29,24 @@ Group
|
||||
|
||||
Description
|
||||
This function object calculates the forces and moments by integrating the
|
||||
pressure and skin-friction forces over a given list of patches.
|
||||
pressure and skin-friction forces over a given list of patches, and
|
||||
the resistance from porous zones.
|
||||
|
||||
Member function forces::write() calculates the forces/moments and
|
||||
writes the forces/moments into the file \<timeDir\>/forces.dat and bin
|
||||
data (if selected) to the file \<timeDir\>/forces_bin.dat
|
||||
Forces and moments are calculated, with optional co-ordinate system and
|
||||
writing of binned data, where force and moment contributions are collected
|
||||
into a user-defined number of bins that span the input geometries for a
|
||||
user-defined direction vector.
|
||||
|
||||
Data is written into multiple files in the
|
||||
postProcessing/\<functionObjectName\> directory:
|
||||
- force.dat : forces in global Cartesian co-ordinate system
|
||||
- moment.dat : moments in global Cartesian co-ordinate system
|
||||
- forceBin.dat : force bins in global Cartesian co-ordinate system
|
||||
- momentBin.dat : moment bins in global Cartesian co-ordinate system
|
||||
- localForce.dat : forces in local co-ordinate system
|
||||
- localMoment.dat : moments in local co-ordinate system
|
||||
- localForceBin.dat : force bins in local co-ordinate system
|
||||
- localMomentBin.dat : moment bins in local co-ordinate system
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
@ -43,6 +56,7 @@ Description
|
||||
functionObjectLibs ("libforces.so");
|
||||
...
|
||||
log yes;
|
||||
writeFields yes;
|
||||
patches (walls);
|
||||
|
||||
binData
|
||||
@ -59,6 +73,7 @@ Description
|
||||
Property | Description | Required | Default value
|
||||
type | type name: forces | yes |
|
||||
log | write force data to standard output | no | no
|
||||
writeFields | write the force and moment fields | no | no
|
||||
patches | patches included in the forces calculation | yes |
|
||||
pName | pressure field name | no | p
|
||||
UName | velocity field name | no | U
|
||||
@ -101,6 +116,8 @@ Note
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjectFile
|
||||
Foam::functionObjectState
|
||||
Foam::OutputFilterFunctionObject
|
||||
Foam::forceCoeffs
|
||||
|
||||
@ -113,6 +130,7 @@ SourceFiles
|
||||
#ifndef forces_H
|
||||
#define forces_H
|
||||
|
||||
#include "functionObjectState.H"
|
||||
#include "functionObjectFile.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "coordinateSystems.H"
|
||||
@ -122,7 +140,6 @@ SourceFiles
|
||||
#include "Tuple2.H"
|
||||
#include "OFstream.H"
|
||||
#include "Switch.H"
|
||||
#include "writer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -141,21 +158,16 @@ class mapPolyMesh;
|
||||
|
||||
class forces
|
||||
:
|
||||
public functionObjectState,
|
||||
public functionObjectFile
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of forces,
|
||||
// Also used as the name of the probes directory.
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
@ -165,6 +177,32 @@ protected:
|
||||
//- Pressure, viscous and porous moment per bin
|
||||
List<Field<vector> > moment_;
|
||||
|
||||
// File streams
|
||||
|
||||
//- Forces
|
||||
autoPtr<OFstream> forceFilePtr_;
|
||||
|
||||
//- Moments
|
||||
autoPtr<OFstream> momentFilePtr_;
|
||||
|
||||
//- Force bins
|
||||
autoPtr<OFstream> forceBinFilePtr_;
|
||||
|
||||
//- Moment bins
|
||||
autoPtr<OFstream> momentBinFilePtr_;
|
||||
|
||||
//- Local force
|
||||
autoPtr<OFstream> localForceFilePtr_;
|
||||
|
||||
//- Local moment
|
||||
autoPtr<OFstream> localMomentFilePtr_;
|
||||
|
||||
//- Local force bins
|
||||
autoPtr<OFstream> localForceBinFilePtr_;
|
||||
|
||||
//- Local moment bins
|
||||
autoPtr<OFstream> localMomentBinFilePtr_;
|
||||
|
||||
|
||||
// Read from dictionary
|
||||
|
||||
@ -223,21 +261,36 @@ protected:
|
||||
bool binCumulative_;
|
||||
|
||||
|
||||
//- Write fields flag
|
||||
bool writeFields_;
|
||||
|
||||
//- Initialised flag
|
||||
bool initialised_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Create file names for forces and bins
|
||||
wordList createFileNames(const dictionary& dict) const;
|
||||
//- Create a field name
|
||||
word fieldName(const word& name) const;
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
//- Create the output files
|
||||
void createFiles();
|
||||
|
||||
//- Write header for integrated data
|
||||
void writeIntegratedHeader(const word& header, Ostream& os) const;
|
||||
|
||||
//- Write header for binned data
|
||||
void writeBinHeader(const word& header, Ostream& os) const;
|
||||
|
||||
//- Initialise the fields
|
||||
void initialise();
|
||||
|
||||
//- Initialise the collection bins
|
||||
void initialiseBins();
|
||||
|
||||
//- Reset the fields prior to accumulation of force/moments
|
||||
void resetFields();
|
||||
|
||||
//- Return the effective viscous stress (laminar + turbulent).
|
||||
tmp<volSymmTensorField> devRhoReff() const;
|
||||
|
||||
@ -261,10 +314,47 @@ protected:
|
||||
const vectorField& d
|
||||
);
|
||||
|
||||
//- Helper function to write force data
|
||||
//- Add patch contributions to force and moment fields
|
||||
void addToFields
|
||||
(
|
||||
const label patchI,
|
||||
const vectorField& Md,
|
||||
const vectorField& fN,
|
||||
const vectorField& fT,
|
||||
const vectorField& fP
|
||||
);
|
||||
|
||||
//- Add cell contributions to force and moment fields
|
||||
void addToFields
|
||||
(
|
||||
const labelList& cellIDs,
|
||||
const vectorField& Md,
|
||||
const vectorField& fN,
|
||||
const vectorField& fT,
|
||||
const vectorField& fP
|
||||
);
|
||||
|
||||
//- Helper function to write integrated forces and moments
|
||||
void writeIntegratedForceMoment
|
||||
(
|
||||
const string& descriptor,
|
||||
const vectorField& fm0,
|
||||
const vectorField& fm1,
|
||||
const vectorField& fm2,
|
||||
autoPtr<OFstream>& osPtr
|
||||
) const;
|
||||
|
||||
//- Write force data
|
||||
void writeForces();
|
||||
|
||||
//- Helper function to write bin data
|
||||
//- Helper function to write binned forces and moments
|
||||
void writeBinnedForceMoment
|
||||
(
|
||||
const List<Field<vector> >& fm,
|
||||
autoPtr<OFstream>& osPtr
|
||||
) const;
|
||||
|
||||
//- Write binned data
|
||||
void writeBins();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
|
||||
4
src/postProcessing/functionObjects/graphics/Allwmake
Executable file
4
src/postProcessing/functionObjects/graphics/Allwmake
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
./runTimePostProcessing/Allwmake
|
||||
12
src/postProcessing/functionObjects/graphics/runTimePostProcessing/Allwclean
Executable file
12
src/postProcessing/functionObjects/graphics/runTimePostProcessing/Allwclean
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Source the wmake functions
|
||||
. $WM_DIR/scripts/wmakeFunctions
|
||||
|
||||
(
|
||||
# Where are the generated files stored?
|
||||
findObjectDir dummy.C
|
||||
depDir="$objectsDir"
|
||||
rm -rf "$depDir" > /dev/null 2>&1
|
||||
)
|
||||
28
src/postProcessing/functionObjects/graphics/runTimePostProcessing/Allwmake
Executable file
28
src/postProcessing/functionObjects/graphics/runTimePostProcessing/Allwmake
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Source the wmake functions
|
||||
. $WM_DIR/scripts/wmakeFunctions
|
||||
|
||||
# Store current directory
|
||||
sourceDir=$PWD
|
||||
|
||||
# Where are any generated files stored?
|
||||
findObjectDir dummy.C
|
||||
depDir="$objectsDir"
|
||||
|
||||
if [ -d "$VTK_DIR" -o -d "$ParaView_DIR" ]
|
||||
then
|
||||
# ensure CMake gets the correct C++ compiler
|
||||
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
||||
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
||||
|
||||
(mkdir -p $depDir && cd $depDir && cmake $sourceDir && make)
|
||||
else
|
||||
echo "ERROR: Build of $PWD requires a valid VTK installation which"
|
||||
echo " can be supplied either by ParaView by VTK. In case of"
|
||||
echo " - ParaView : export the ParaView_DIR environment variable"
|
||||
echo " - VTK : export the VTK_DIR variable"
|
||||
fi
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
@ -0,0 +1,84 @@
|
||||
include(${VTK_USE_FILE})
|
||||
|
||||
if(VTK_LIBRARIES)
|
||||
message("Found VTK LIBRARIES: " ${VTK_USE_FILE})
|
||||
endif()
|
||||
|
||||
if(${VTK_VERSION} VERSION_GREATER "6")
|
||||
message("VTK version: " ${VTK_VERSION})
|
||||
else()
|
||||
message(FATAL_ERROR " VTK6 required")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
$ENV{WM_PROJECT_DIR}/src/OpenFOAM/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/OSspecific/$ENV{WM_OSTYPE}/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/triSurface/lnInclude
|
||||
$ENV{WM_PROJECT_DIR}/src/finiteVolume/lnInclude
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
link_directories(
|
||||
$ENV{FOAM_LIBBIN}
|
||||
$ENV{FOAM_EXT_LIBBIN}
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DWM_$ENV{WM_PRECISION_OPTION} -DNoRepository
|
||||
-DWM_LABEL_SIZE=$ENV{WM_LABEL_SIZE}
|
||||
)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG
|
||||
"-g -O0 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
|
||||
)
|
||||
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE
|
||||
"-O3 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
||||
|
||||
# Set output library destination to plugin directory
|
||||
set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN}
|
||||
CACHE INTERNAL
|
||||
""
|
||||
)
|
||||
|
||||
file(GLOB SOURCE_FILES
|
||||
fieldVisualisationBase.C
|
||||
functionObjectCloud.C
|
||||
functionObjectLine.C
|
||||
functionObjectSurface.C
|
||||
geometryBase.C
|
||||
geometrySurface.C
|
||||
pathline.C
|
||||
pointData.C
|
||||
runTimePostProcessing.C
|
||||
runTimePostProcessingFunctionObject.C
|
||||
scene.C
|
||||
surface.C
|
||||
text.C
|
||||
)
|
||||
|
||||
set(OPENFOAM_LIBRARIES
|
||||
OpenFOAM
|
||||
triSurface
|
||||
finiteVolume
|
||||
)
|
||||
|
||||
add_library(
|
||||
runTimePostProcessing
|
||||
SHARED
|
||||
${SOURCE_FILES}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
runTimePostProcessing
|
||||
${VTK_LIBRARIES}
|
||||
${OPENFOAM_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(runTimePostProcessing)
|
||||
|
||||
if (EXISTS $ENV{VTK_DIR})
|
||||
message("Building with VTK from $ENV{VTK_DIR}")
|
||||
find_package(VTK REQUIRED HINTS $ENV{VTK_DIR})
|
||||
include(${VTK_USE_FILE})
|
||||
|
||||
else (EXISTS $ENV{ParaView_DIR})
|
||||
message("Building with Paraview from $ENV{ParaView_DIR}")
|
||||
find_package(ParaView REQUIRED)
|
||||
include(${VTK_USE_FILE})
|
||||
|
||||
set(
|
||||
VTK_VERSION
|
||||
"${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}"
|
||||
)
|
||||
endif (EXISTS $ENV{VTK_DIR})
|
||||
|
||||
include(CMakeLists-Common.txt)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOrunTimePostProcessing
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for runTimePostProcessing.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOrunTimePostProcessing_H
|
||||
#define IOrunTimePostProcessing_H
|
||||
|
||||
#include "runTimePostProcessing.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<runTimePostProcessing> IOrunTimePostProcessing;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,517 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "fieldVisualisationBase.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkArrowSource.h"
|
||||
#include "vtkColorTransferFunction.h"
|
||||
#include "vtkFloatArray.h"
|
||||
#include "vtkGlyph3D.h"
|
||||
#include "vtkLookupTable.h"
|
||||
#include "vtkPointData.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkScalarBarActor.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkSphereSource.h"
|
||||
#include "vtkTextActor.h"
|
||||
#include "vtkTextProperty.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum<fieldVisualisationBase::colourByType, 2>::names[] =
|
||||
{
|
||||
"colour",
|
||||
"field"
|
||||
};
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<fieldVisualisationBase::colourMapType, 4>::names[] =
|
||||
{
|
||||
"rainbow",
|
||||
"blueWhiteRed",
|
||||
"fire",
|
||||
"greyscale"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::fieldVisualisationBase::colourByType, 2>
|
||||
Foam::fieldVisualisationBase::colourByTypeNames;
|
||||
|
||||
const Foam::NamedEnum<Foam::fieldVisualisationBase::colourMapType, 4>
|
||||
Foam::fieldVisualisationBase::colourMapTypeNames;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldVisualisationBase::setColourMap(vtkLookupTable* lut) const
|
||||
{
|
||||
label nColours = 256;
|
||||
|
||||
lut->SetNumberOfColors(nColours);
|
||||
|
||||
vtkSmartPointer<vtkColorTransferFunction> ctf =
|
||||
vtkSmartPointer<vtkColorTransferFunction>::New();
|
||||
|
||||
switch (colourMap_)
|
||||
{
|
||||
case cmRainbow:
|
||||
{
|
||||
ctf->SetColorSpaceToHSV();
|
||||
ctf->AddRGBPoint(0, 0, 0, 1);
|
||||
ctf->AddRGBPoint(0.5, 0, 1, 0);
|
||||
ctf->AddRGBPoint(1, 1, 0, 0);
|
||||
break;
|
||||
}
|
||||
case cmBlueWhiteRed:
|
||||
{
|
||||
// Values taken from ParaView settings
|
||||
ctf->SetColorSpaceToDiverging();
|
||||
ctf->AddRGBPoint(0.0, 0.231373, 0.298039, 0.752941);
|
||||
ctf->AddRGBPoint(0.5, 0.865003, 0.865003, 0.865003);
|
||||
ctf->AddRGBPoint(1.0, 0.705882, 0.0156863, 0.14902);
|
||||
break;
|
||||
}
|
||||
case cmFire:
|
||||
{
|
||||
// Values taken from ParaView settings
|
||||
ctf->SetColorSpaceToRGB();
|
||||
ctf->AddRGBPoint(0, 0, 0, 0);
|
||||
ctf->AddRGBPoint(0.4, 0.901961, 0, 0);
|
||||
ctf->AddRGBPoint(0.8, 0.901961, 0.901961, 0);
|
||||
ctf->AddRGBPoint(1, 1, 1, 1);
|
||||
break;
|
||||
}
|
||||
case cmGreyscale:
|
||||
{
|
||||
ctf->SetColorSpaceToRGB();
|
||||
ctf->AddRGBPoint(0, 0, 0, 0);
|
||||
ctf->AddRGBPoint(1, 1, 1, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (label i = 0; i < nColours; i++)
|
||||
{
|
||||
double* c = ctf->GetColor(scalar(i)/scalar(nColours));
|
||||
lut->SetTableValue(i, c[0], c[1], c[2], 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldVisualisationBase::addScalarBar
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer,
|
||||
vtkLookupTable* lut
|
||||
) const
|
||||
{
|
||||
// add scalar bar legend
|
||||
if (!scalarBar_.visible_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkScalarBarActor> sbar =
|
||||
vtkSmartPointer<vtkScalarBarActor>::New();
|
||||
sbar->SetLookupTable(lut);
|
||||
sbar->SetNumberOfLabels(scalarBar_.numberOfLabels_);
|
||||
|
||||
const vector textColour = colours_["text"]->value(position);
|
||||
|
||||
// workaround to supply our own scalarbar title
|
||||
vtkSmartPointer<vtkTextActor> titleActor =
|
||||
vtkSmartPointer<vtkTextActor>::New();
|
||||
sbar->SetTitle(" ");
|
||||
titleActor->SetInput(scalarBar_.title_.c_str());
|
||||
titleActor->GetTextProperty()->SetFontFamilyToArial();
|
||||
titleActor->GetTextProperty()->SetFontSize(3*scalarBar_.fontSize_);
|
||||
titleActor->GetTextProperty()->SetJustificationToCentered();
|
||||
titleActor->GetTextProperty()->SetVerticalJustificationToBottom();
|
||||
titleActor->GetTextProperty()->BoldOn();
|
||||
titleActor->GetTextProperty()->ItalicOff();
|
||||
titleActor->GetTextProperty()->SetColor
|
||||
(
|
||||
textColour[0],
|
||||
textColour[1],
|
||||
textColour[2]
|
||||
);
|
||||
titleActor->GetPositionCoordinate()->
|
||||
SetCoordinateSystemToNormalizedViewport();
|
||||
|
||||
/*
|
||||
sbar->SetTitle(scalarBar_.title_.c_str());
|
||||
sbar->GetTitleTextProperty()->SetColor
|
||||
(
|
||||
textColour[0],
|
||||
textColour[1],
|
||||
textColour[2]
|
||||
);
|
||||
sbar->GetTitleTextProperty()->SetFontSize(scalarBar_.fontSize_);
|
||||
sbar->GetTitleTextProperty()->ShadowOff();
|
||||
sbar->GetTitleTextProperty()->BoldOn();
|
||||
sbar->GetTitleTextProperty()->ItalicOff();
|
||||
*/
|
||||
|
||||
sbar->GetLabelTextProperty()->SetColor
|
||||
(
|
||||
textColour[0],
|
||||
textColour[1],
|
||||
textColour[2]
|
||||
);
|
||||
sbar->GetLabelTextProperty()->SetFontSize(scalarBar_.fontSize_);
|
||||
sbar->GetLabelTextProperty()->ShadowOff();
|
||||
sbar->GetLabelTextProperty()->BoldOff();
|
||||
sbar->GetLabelTextProperty()->ItalicOff();
|
||||
sbar->SetLabelFormat(scalarBar_.labelFormat_.c_str());
|
||||
|
||||
sbar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
|
||||
sbar->GetPositionCoordinate()->SetValue
|
||||
(
|
||||
scalarBar_.position_.first(),
|
||||
scalarBar_.position_.second()
|
||||
);
|
||||
if (scalarBar_.vertical_)
|
||||
{
|
||||
sbar->SetOrientationToVertical();
|
||||
sbar->SetWidth(0.1);
|
||||
sbar->SetHeight(0.75);
|
||||
sbar->SetTextPositionToSucceedScalarBar();
|
||||
}
|
||||
else
|
||||
{
|
||||
sbar->SetOrientationToHorizontal();
|
||||
|
||||
// adjustments since not using scalarbar title property
|
||||
sbar->SetWidth(0.75);
|
||||
sbar->SetHeight(0.07);
|
||||
sbar->SetBarRatio(0.5);
|
||||
// sbar->SetHeight(0.1);
|
||||
// sbar->SetTitleRatio(0.01);
|
||||
sbar->SetTextPositionToPrecedeScalarBar();
|
||||
}
|
||||
|
||||
titleActor->GetPositionCoordinate()->SetValue
|
||||
(
|
||||
scalarBar_.position_.first() + 0.5*sbar->GetWidth(),
|
||||
scalarBar_.position_.second() + sbar->GetHeight()
|
||||
);
|
||||
|
||||
// sbar->DrawFrameOn();
|
||||
// sbar->DrawBackgroundOn();
|
||||
// sbar->UseOpacityOff();
|
||||
// sbar->VisibilityOff();
|
||||
sbar->VisibilityOn();
|
||||
|
||||
renderer->AddActor(sbar);
|
||||
renderer->AddActor2D(titleActor);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldVisualisationBase::setField
|
||||
(
|
||||
const scalar position,
|
||||
const word& colourFieldName,
|
||||
vtkPolyDataMapper* mapper,
|
||||
vtkRenderer* renderer
|
||||
) const
|
||||
{
|
||||
mapper->InterpolateScalarsBeforeMappingOn();
|
||||
|
||||
switch (colourBy_)
|
||||
{
|
||||
case cbColour:
|
||||
{
|
||||
mapper->ScalarVisibilityOff();
|
||||
break;
|
||||
}
|
||||
case cbField:
|
||||
{
|
||||
// create look-up table for colours
|
||||
vtkSmartPointer<vtkLookupTable> lut =
|
||||
vtkSmartPointer<vtkLookupTable>::New();
|
||||
setColourMap(lut);
|
||||
lut->SetVectorMode(vtkScalarsToColors::MAGNITUDE);
|
||||
|
||||
// configure the mapper
|
||||
mapper->SelectColorArray(colourFieldName.c_str());
|
||||
mapper->SetScalarRange(range_.first(), range_.second());
|
||||
mapper->SetScalarModeToUsePointFieldData();
|
||||
|
||||
mapper->SetColorModeToMapScalars();
|
||||
mapper->SetLookupTable(lut);
|
||||
mapper->ScalarVisibilityOn();
|
||||
|
||||
// add the bar
|
||||
addScalarBar(position, renderer, lut);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mapper->Modified();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::fieldVisualisationBase::addGlyphs
|
||||
(
|
||||
const scalar position,
|
||||
const word& scaleFieldName,
|
||||
const word& colourFieldName,
|
||||
const scalar maxGlyphLength,
|
||||
vtkPolyData* data,
|
||||
vtkActor* actor,
|
||||
vtkRenderer* renderer
|
||||
) const
|
||||
{
|
||||
vtkSmartPointer<vtkGlyph3D> glyph = vtkSmartPointer<vtkGlyph3D>::New();
|
||||
vtkSmartPointer<vtkPolyDataMapper> glyphMapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
glyphMapper->SetInputConnection(glyph->GetOutputPort());
|
||||
|
||||
glyph->SetInputData(data);
|
||||
glyph->ScalingOn();
|
||||
bool ok = true;
|
||||
|
||||
label nComponents =
|
||||
data->GetPointData()->GetArray(scaleFieldName.c_str())
|
||||
->GetNumberOfComponents();
|
||||
|
||||
if (nComponents == 1)
|
||||
{
|
||||
vtkSmartPointer<vtkSphereSource> sphere =
|
||||
vtkSmartPointer<vtkSphereSource>::New();
|
||||
sphere->SetCenter(0, 0, 0);
|
||||
sphere->SetRadius(0.5);
|
||||
// setting higher resolution slows the rendering significantly
|
||||
// sphere->SetPhiResolution(20);
|
||||
// sphere->SetThetaResolution(20);
|
||||
|
||||
glyph->SetSourceConnection(sphere->GetOutputPort());
|
||||
|
||||
if (maxGlyphLength > 0)
|
||||
{
|
||||
double range[2];
|
||||
|
||||
// can use values to find range
|
||||
// vtkDataArray* values =
|
||||
// data->GetPointData()->GetScalars(scaleFieldName.c_str());
|
||||
// values->GetRange(range);
|
||||
|
||||
// set range accoding to user-supplied limits
|
||||
range[0] = range_.first();
|
||||
range[1] = range_.second();
|
||||
glyph->ClampingOn();
|
||||
glyph->SetRange(range);
|
||||
|
||||
// if range[0] != min(value), maxGlyphLength behaviour will not
|
||||
// be correct...
|
||||
glyph->SetScaleFactor(maxGlyphLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
glyph->SetScaleFactor(1);
|
||||
}
|
||||
glyph->SetScaleModeToScaleByScalar();
|
||||
glyph->OrientOff();
|
||||
glyph->SetColorModeToColorByScalar();
|
||||
glyph->SetInputArrayToProcess
|
||||
(
|
||||
0, // scalars
|
||||
0,
|
||||
0,
|
||||
vtkDataObject::FIELD_ASSOCIATION_POINTS,
|
||||
scaleFieldName.c_str()
|
||||
);
|
||||
}
|
||||
else if (nComponents == 3)
|
||||
{
|
||||
vtkSmartPointer<vtkArrowSource> arrow =
|
||||
vtkSmartPointer<vtkArrowSource>::New();
|
||||
arrow->SetTipResolution(10);
|
||||
arrow->SetTipRadius(0.1);
|
||||
arrow->SetTipLength(0.35);
|
||||
arrow->SetShaftResolution(10);
|
||||
arrow->SetShaftRadius(0.03);
|
||||
|
||||
glyph->SetSourceConnection(arrow->GetOutputPort());
|
||||
|
||||
if (maxGlyphLength > 0)
|
||||
{
|
||||
vtkDataArray* values =
|
||||
data->GetPointData()->GetVectors(scaleFieldName.c_str());
|
||||
double range[6];
|
||||
values->GetRange(range);
|
||||
|
||||
/*
|
||||
// attempt to set range for vectors...
|
||||
scalar x0 = sqrt(sqr(range_.first())/3.0);
|
||||
scalar x1 = sqrt(sqr(range_.second())/3.0);
|
||||
range[0] = x0;
|
||||
range[1] = x0;
|
||||
range[2] = x0;
|
||||
range[3] = x1;
|
||||
range[4] = x1;
|
||||
range[5] = x1;
|
||||
*/
|
||||
glyph->ClampingOn();
|
||||
glyph->SetRange(range);
|
||||
glyph->SetScaleFactor(maxGlyphLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
glyph->SetScaleFactor(1);
|
||||
}
|
||||
glyph->SetScaleModeToScaleByVector();
|
||||
glyph->OrientOn();
|
||||
glyph->SetVectorModeToUseVector();
|
||||
glyph->SetColorModeToColorByVector();
|
||||
glyph->SetInputArrayToProcess
|
||||
(
|
||||
1, // vectors
|
||||
0,
|
||||
0,
|
||||
vtkDataObject::FIELD_ASSOCIATION_POINTS,
|
||||
scaleFieldName.c_str()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"void Foam::fieldVisualisationBase::addGlyphs"
|
||||
"("
|
||||
"const scalar, "
|
||||
"const word&, "
|
||||
"const word&, "
|
||||
"const scalar, "
|
||||
"vtkPolyData*, "
|
||||
"vtkActor*, "
|
||||
"vtkRenderer*"
|
||||
") const"
|
||||
)
|
||||
<< "Glyphs can only be added to " << pTraits<scalar>::typeName
|
||||
<< " and " << pTraits<vector>::typeName << " fields. "
|
||||
<< " Field " << scaleFieldName << " has " << nComponents
|
||||
<< " components" << endl;
|
||||
|
||||
ok = false;
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
glyph->Update();
|
||||
|
||||
setField(position, colourFieldName, glyphMapper, renderer);
|
||||
|
||||
glyphMapper->Update();
|
||||
|
||||
actor->SetMapper(glyphMapper);
|
||||
|
||||
renderer->AddActor(actor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldVisualisationBase::fieldVisualisationBase
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
parent_(parent),
|
||||
colours_(colours),
|
||||
fieldName_(dict.lookup("fieldName")),
|
||||
colourBy_(cbColour),
|
||||
colourMap_(cmRainbow),
|
||||
range_()
|
||||
{
|
||||
colourBy_ = colourByTypeNames.read(dict.lookup("colourBy"));
|
||||
|
||||
switch (colourBy_)
|
||||
{
|
||||
case cbColour:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case cbField:
|
||||
{
|
||||
dict.lookup("range") >> range_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.found("colourMap"))
|
||||
{
|
||||
colourMap_ = colourMapTypeNames.read(dict.lookup("colourMap"));
|
||||
}
|
||||
|
||||
const dictionary& sbarDict = dict.subDict("scalarBar");
|
||||
sbarDict.lookup("visible") >> scalarBar_.visible_;
|
||||
if (scalarBar_.visible_)
|
||||
{
|
||||
sbarDict.lookup("vertical") >> scalarBar_.vertical_;
|
||||
sbarDict.lookup("position") >> scalarBar_.position_;
|
||||
sbarDict.lookup("title") >> scalarBar_.title_;
|
||||
sbarDict.lookup("fontSize") >> scalarBar_.fontSize_;
|
||||
sbarDict.lookup("labelFormat") >> scalarBar_.labelFormat_;
|
||||
sbarDict.lookup("numberOfLabels") >> scalarBar_.numberOfLabels_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldVisualisationBase::~fieldVisualisationBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::HashPtrTable<Foam::DataEntry<Foam::vector>, Foam::word>&
|
||||
Foam::fieldVisualisationBase::colours() const
|
||||
{
|
||||
return colours_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::word& Foam::fieldVisualisationBase::fieldName() const
|
||||
{
|
||||
return fieldName_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,216 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::fieldVisualisationBase
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
fieldVisualisationBase.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef fieldVisualisationBase_H
|
||||
#define fieldVisualisationBase_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "Tuple2.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "vector.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "DataEntry.H"
|
||||
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkActor;
|
||||
class vtkLookupTable;
|
||||
class vtkPolyData;
|
||||
class vtkPolyDataMapper;
|
||||
class vtkRenderer;
|
||||
|
||||
|
||||
class vtkMapper;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class runTimePostProcessing;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class fieldVisualisationBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class fieldVisualisationBase
|
||||
{
|
||||
public:
|
||||
|
||||
// Public enumerations
|
||||
|
||||
enum colourByType
|
||||
{
|
||||
cbColour,
|
||||
cbField
|
||||
};
|
||||
|
||||
static const NamedEnum<colourByType, 2> colourByTypeNames;
|
||||
|
||||
enum colourMapType
|
||||
{
|
||||
cmRainbow,
|
||||
cmBlueWhiteRed,
|
||||
cmFire,
|
||||
cmGreyscale
|
||||
};
|
||||
|
||||
static const NamedEnum<colourMapType, 4> colourMapTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the parent function object
|
||||
const runTimePostProcessing& parent_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldVisualisationBase(const fieldVisualisationBase&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const fieldVisualisationBase&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
struct scalarBar
|
||||
{
|
||||
bool visible_;
|
||||
bool vertical_;
|
||||
Tuple2<scalar, scalar> position_;
|
||||
string title_;
|
||||
label fontSize_;
|
||||
string labelFormat_;
|
||||
label numberOfLabels_;
|
||||
};
|
||||
|
||||
//- Colours
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours_;
|
||||
|
||||
//- Field name
|
||||
word fieldName_;
|
||||
|
||||
//- Colour by type
|
||||
colourByType colourBy_;
|
||||
|
||||
//- Colour map type
|
||||
colourMapType colourMap_;
|
||||
|
||||
//- Range of values
|
||||
Tuple2<scalar, scalar> range_;
|
||||
|
||||
//- Scalar bar
|
||||
scalarBar scalarBar_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Set the colour map
|
||||
void setColourMap(vtkLookupTable* lut) const;
|
||||
|
||||
//- Add scalar bar to renderer
|
||||
void addScalarBar
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer,
|
||||
vtkLookupTable* lut
|
||||
) const;
|
||||
|
||||
//- Set field/configure mapper, add scalar bar
|
||||
void setField
|
||||
(
|
||||
const scalar position,
|
||||
const word& colourFieldName,
|
||||
vtkPolyDataMapper* mapper,
|
||||
vtkRenderer* renderer
|
||||
) const;
|
||||
|
||||
//- Add glyphs
|
||||
void addGlyphs
|
||||
(
|
||||
const scalar position,
|
||||
const word& scaleFieldName,
|
||||
const word& colourFieldName,
|
||||
const scalar maxGlyphLength,
|
||||
vtkPolyData* data,
|
||||
vtkActor* actor,
|
||||
vtkRenderer* renderer
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
fieldVisualisationBase
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~fieldVisualisationBase();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the colours
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours() const;
|
||||
|
||||
//- Return the field name
|
||||
const word& fieldName() const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,157 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "functionObjectCloud.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkActor.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkPolyDataReader.h"
|
||||
#include "vtkProperty.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(functionObjectCloud, 0);
|
||||
addToRunTimeSelectionTable(pointData, functionObjectCloud, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectCloud::functionObjectCloud
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
pointData(parent, dict, colours),
|
||||
fieldVisualisationBase(parent, dict, colours),
|
||||
cloudName_(dict.lookup("cloudName")),
|
||||
functionObject_(dict.lookup("functionObject")),
|
||||
colourFieldName_(dict.lookup("colourFieldName")),
|
||||
actor_()
|
||||
{
|
||||
actor_ = vtkSmartPointer<vtkActor>::New();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectCloud::~functionObjectCloud()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjectCloud::addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
)
|
||||
{
|
||||
if (!visible_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const dictionary& cloudDict =
|
||||
geometryBase::parent_.obr().lookupObject<IOdictionary>
|
||||
(
|
||||
cloudName_ + "OutputProperties"
|
||||
);
|
||||
|
||||
fileName fName;
|
||||
if (cloudDict.found("cloudFunctionObject"))
|
||||
{
|
||||
const dictionary& foDict = cloudDict.subDict("cloudFunctionObject");
|
||||
if (foDict.found(functionObject_))
|
||||
{
|
||||
foDict.subDict(functionObject_).readIfPresent("file", fName);
|
||||
}
|
||||
}
|
||||
|
||||
if (fName.empty())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"void Foam::functionObjectCloud::addToScene"
|
||||
"("
|
||||
"const scalar, "
|
||||
"vtkRenderer*"
|
||||
")"
|
||||
)
|
||||
<< "Unable to find function object " << functionObject_
|
||||
<< " output for field " << fieldName_
|
||||
<< ". Line will not be processed"
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fName.ext() == "vtk")
|
||||
{
|
||||
vtkSmartPointer<vtkPolyDataReader> points =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
points->SetFileName(fName.c_str());
|
||||
points->Update();
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
|
||||
actor_->SetMapper(mapper);
|
||||
|
||||
addGlyphs
|
||||
(
|
||||
position,
|
||||
fieldName_,
|
||||
colourFieldName_,
|
||||
maxGlyphLength_,
|
||||
points->GetOutput(),
|
||||
actor_,
|
||||
renderer
|
||||
);
|
||||
|
||||
renderer->AddActor(actor_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectCloud::updateActors(const scalar position)
|
||||
{
|
||||
actor_->GetProperty()->SetOpacity(opacity(position));
|
||||
|
||||
vector pc = pointColour_->value(position);
|
||||
actor_->GetProperty()->SetColor(pc[0], pc[1], pc[2]);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjectCloud
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
functionObjectCloud.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjectCloud_H
|
||||
#define functionObjectCloud_H
|
||||
|
||||
#include "pointData.H"
|
||||
#include "fieldVisualisationBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjectCloud Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class functionObjectCloud
|
||||
:
|
||||
public pointData,
|
||||
public fieldVisualisationBase
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectCloud(const functionObjectCloud&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const functionObjectCloud&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of cloud
|
||||
word cloudName_;
|
||||
|
||||
//- Name of cloud function object result to render
|
||||
word functionObject_;
|
||||
|
||||
//- Name of field to colour by
|
||||
word colourFieldName_;
|
||||
|
||||
//- Actor
|
||||
vtkSmartPointer<vtkActor> actor_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("functionObjectCloud");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
functionObjectCloud
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~functionObjectCloud();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add tube(s) to scene
|
||||
virtual void addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
);
|
||||
|
||||
//- Update actors
|
||||
virtual void updateActors(const scalar position);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,138 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "functionObjectLine.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkActor.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkPolyDataReader.h"
|
||||
#include "vtkProperty.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(functionObjectLine, 0);
|
||||
addToRunTimeSelectionTable(pathline, functionObjectLine, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectLine::functionObjectLine
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
pathline(parent, dict, colours),
|
||||
fieldVisualisationBase(parent, dict, colours),
|
||||
functionObject_(dict.lookup("functionObject")),
|
||||
actor_()
|
||||
{
|
||||
actor_ = vtkSmartPointer<vtkActor>::New();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectLine::~functionObjectLine()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjectLine::addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
)
|
||||
{
|
||||
if (!visible_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const dictionary dict =
|
||||
geometryBase::parent_.getObjectProperty
|
||||
(
|
||||
functionObject_,
|
||||
fieldName_,
|
||||
dictionary::null
|
||||
);
|
||||
|
||||
fileName fName;
|
||||
if (!dict.readIfPresent("file", fName))
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"void Foam::functionObjectLine::addToScene"
|
||||
"("
|
||||
"const scalar, "
|
||||
"vtkRenderer*"
|
||||
")"
|
||||
)
|
||||
<< "Unable to find function object " << functionObject_
|
||||
<< " output for field " << fieldName_
|
||||
<< ". Line will not be processed"
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fName.ext() == "vtk")
|
||||
{
|
||||
vtkSmartPointer<vtkPolyDataReader> lines =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
lines->SetFileName(fName.c_str());
|
||||
lines->Update();
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
setField(position, fieldName_, mapper, renderer);
|
||||
|
||||
actor_->SetMapper(mapper);
|
||||
|
||||
addLines(position, actor_, lines->GetOutput());
|
||||
|
||||
renderer->AddActor(actor_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectLine::updateActors(const scalar position)
|
||||
{
|
||||
actor_->GetProperty()->SetLineWidth(2);
|
||||
actor_->GetProperty()->SetOpacity(opacity(position));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,119 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjectLine
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
functionObjectLine.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjectLine_H
|
||||
#define functionObjectLine_H
|
||||
|
||||
#include "pathline.H"
|
||||
#include "fieldVisualisationBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjectLine Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class functionObjectLine
|
||||
:
|
||||
public pathline,
|
||||
public fieldVisualisationBase
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectLine(const functionObjectLine&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const functionObjectLine&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of function object result to render
|
||||
word functionObject_;
|
||||
|
||||
//- Actor
|
||||
vtkSmartPointer<vtkActor> actor_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("line");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
functionObjectLine
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~functionObjectLine();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add tube(s) to scene
|
||||
virtual void addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
);
|
||||
|
||||
//- Update actors
|
||||
virtual void updateActors(const scalar position);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "functionObjectSurface.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkActor.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkPolyDataReader.h"
|
||||
#include "vtkProperty.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(functionObjectSurface, 0);
|
||||
addToRunTimeSelectionTable(surface, functionObjectSurface, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectSurface::functionObjectSurface
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
geometrySurface(parent, dict, colours, List<fileName>()),
|
||||
fieldVisualisationBase(parent, dict, colours),
|
||||
functionObject_("")
|
||||
{
|
||||
if (visible_)
|
||||
{
|
||||
dict.lookup("functionObject") >> functionObject_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjectSurface::~functionObjectSurface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjectSurface::addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
)
|
||||
{
|
||||
if (!visible_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const dictionary dict =
|
||||
geometryBase::parent_.getObjectProperty
|
||||
(
|
||||
functionObject_,
|
||||
fieldName_,
|
||||
dictionary::null
|
||||
);
|
||||
|
||||
fileName fName;
|
||||
if (!dict.readIfPresent("file", fName))
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"void Foam::functionObjectSurface::addToScene"
|
||||
"("
|
||||
"const scalar, "
|
||||
"vtkRenderer*"
|
||||
")"
|
||||
)
|
||||
<< "Unable to find function object " << functionObject_
|
||||
<< " output for field " << fieldName_
|
||||
<< ". Surface will not be processed"
|
||||
<< endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (representation_ == rtGlyph)
|
||||
{
|
||||
vtkSmartPointer<vtkPolyDataReader> surf =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
surf->SetFileName(fName.c_str());
|
||||
surf->Update();
|
||||
|
||||
addGlyphs
|
||||
(
|
||||
position,
|
||||
fieldName_,
|
||||
fieldName_,
|
||||
maxGlyphLength_,
|
||||
surf->GetOutput(),
|
||||
surfaceActor_,
|
||||
renderer
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((colourBy_ == cbField) && (fName.ext() == "vtk"))
|
||||
{
|
||||
vtkSmartPointer<vtkPolyDataReader> surf =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
surf->SetFileName(fName.c_str());
|
||||
surf->Update();
|
||||
|
||||
addFeatureEdges(renderer, surf->GetOutput());
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection(surf->GetOutputPort());
|
||||
|
||||
setField(position, fieldName_, mapper, renderer);
|
||||
|
||||
surfaceActor_->SetMapper(mapper);
|
||||
|
||||
setRepresentation(surfaceActor_);
|
||||
|
||||
renderer->AddActor(surfaceActor_);
|
||||
}
|
||||
else
|
||||
{
|
||||
geometrySurface::addGeometryToScene(position, renderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,115 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjectSurface
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
functionObjectSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjectSurface_H
|
||||
#define functionObjectSurface_H
|
||||
|
||||
#include "geometrySurface.H"
|
||||
#include "fieldVisualisationBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjectSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class functionObjectSurface
|
||||
:
|
||||
public geometrySurface,
|
||||
public fieldVisualisationBase
|
||||
{
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectSurface(const functionObjectSurface&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const functionObjectSurface&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of function object result to render
|
||||
word functionObject_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("functionObject");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
functionObjectSurface
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~functionObjectSurface();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add surface(s) to scene
|
||||
virtual void addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,149 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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 "geometryBase.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
#include "Constant.H"
|
||||
|
||||
#include "vtkActor.h"
|
||||
#include "vtkProperty.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum<geometryBase::renderModeType, 3>::names[] =
|
||||
{
|
||||
"flat",
|
||||
"gouraud",
|
||||
"phong"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::geometryBase::renderModeType, 3>
|
||||
Foam::geometryBase::renderModeTypeNames;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::geometryBase::initialiseActor(vtkActor* actor) const
|
||||
{
|
||||
actor->GetProperty()->SetSpecular(0);
|
||||
actor->GetProperty()->SetSpecularPower(20);
|
||||
|
||||
switch (renderMode_)
|
||||
{
|
||||
case rmFlat:
|
||||
{
|
||||
actor->GetProperty()->SetInterpolationToFlat();
|
||||
break;
|
||||
}
|
||||
case rmGouraud:
|
||||
{
|
||||
actor->GetProperty()->SetInterpolationToGouraud();
|
||||
break;
|
||||
}
|
||||
case rmPhong:
|
||||
{
|
||||
actor->GetProperty()->SetInterpolationToPhong();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::geometryBase::geometryBase
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
parent_(parent),
|
||||
name_(dict.dictName()),
|
||||
visible_(readBool(dict.lookup("visible"))),
|
||||
renderMode_(rmGouraud),
|
||||
opacity_(NULL),
|
||||
colours_(colours)
|
||||
{
|
||||
if (dict.found("renderMode"))
|
||||
{
|
||||
renderMode_ = renderModeTypeNames.read(dict.lookup("renderMode"));
|
||||
}
|
||||
|
||||
if (dict.found("opacity"))
|
||||
{
|
||||
opacity_.reset(DataEntry<scalar>::New("opacity", dict).ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
opacity_.reset(new Constant<scalar>("opacity", 1.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::geometryBase::~geometryBase()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::runTimePostProcessing& Foam::geometryBase::parent() const
|
||||
{
|
||||
return parent_;
|
||||
}
|
||||
|
||||
|
||||
const Foam::word& Foam::geometryBase::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::geometryBase::visible() const
|
||||
{
|
||||
return visible_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::geometryBase::opacity(const scalar position) const
|
||||
{
|
||||
return opacity_->value(position);
|
||||
}
|
||||
|
||||
|
||||
const Foam::HashPtrTable<Foam::DataEntry<Foam::vector>, Foam::word>&
|
||||
Foam::geometryBase::colours() const
|
||||
{
|
||||
return colours_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,171 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::geometryBase
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
geometryBase.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef geometryBase_H
|
||||
#define geometryBase_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "vector.H"
|
||||
#include "DataEntry.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkRenderer;
|
||||
class vtkActor;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class runTimePostProcessing;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class geometryBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class geometryBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public enumerations
|
||||
|
||||
enum renderModeType
|
||||
{
|
||||
rmFlat,
|
||||
rmGouraud,
|
||||
rmPhong
|
||||
};
|
||||
|
||||
static const NamedEnum<renderModeType, 3> renderModeTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
geometryBase(const geometryBase&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const geometryBase&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the parent function object
|
||||
const runTimePostProcessing& parent_;
|
||||
|
||||
//- Name
|
||||
word name_;
|
||||
|
||||
//- Visible flag
|
||||
bool visible_;
|
||||
|
||||
//- Render mode
|
||||
renderModeType renderMode_;
|
||||
|
||||
//- Opacity
|
||||
autoPtr<DataEntry<scalar> > opacity_;
|
||||
|
||||
//- Reference to the colours
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours_;
|
||||
|
||||
|
||||
// Protected functions
|
||||
|
||||
//- Initialse actor
|
||||
void initialiseActor(vtkActor* actor) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
geometryBase
|
||||
(
|
||||
const runTimePostProcessing& parent_,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~geometryBase();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the reference to the parent function object
|
||||
const runTimePostProcessing& parent() const;
|
||||
|
||||
//- Return the name
|
||||
const word& name() const;
|
||||
|
||||
//- Return the visible flag
|
||||
bool visible() const;
|
||||
|
||||
//- Return the opacity
|
||||
scalar opacity(const scalar position) const;
|
||||
|
||||
//- Return reference to the colours
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours() const;
|
||||
|
||||
|
||||
//- Add geometry to scene
|
||||
virtual void addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
) = 0;
|
||||
|
||||
//- Update the actors
|
||||
virtual void updateActors(const scalar position) = 0;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,214 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "geometrySurface.H"
|
||||
#include "stringOps.H"
|
||||
#include "triSurface.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkActor.h"
|
||||
#include "vtkCellArray.h"
|
||||
#include "vtkCellData.h"
|
||||
#include "vtkDoubleArray.h"
|
||||
#include "vtkPointData.h"
|
||||
#include "vtkPoints.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkProperty.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkTriangle.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(geometrySurface, 0);
|
||||
addToRunTimeSelectionTable(surface, geometrySurface, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::geometrySurface::addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer,
|
||||
const fileName& fName
|
||||
) const
|
||||
{
|
||||
if (representation_ == rtGlyph)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"void Foam::geometrySurface::addGeometryToScene"
|
||||
"("
|
||||
"const label, "
|
||||
"vtkRenderer*, "
|
||||
"const fileName&"
|
||||
") const"
|
||||
)
|
||||
<< "Glyph representation not available for " << typeName
|
||||
<< "object" << exit(FatalError);
|
||||
}
|
||||
|
||||
triSurface surf(fName);
|
||||
|
||||
const Field<point>& surfPoints = surf.points();
|
||||
const Field<vector>& surfFaceNormals = surf.faceNormals();
|
||||
|
||||
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
||||
vtkSmartPointer<vtkCellArray> triangles =
|
||||
vtkSmartPointer<vtkCellArray>::New();
|
||||
vtkSmartPointer<vtkDoubleArray> faceNormals =
|
||||
vtkSmartPointer<vtkDoubleArray>::New();
|
||||
|
||||
faceNormals->SetNumberOfComponents(3);
|
||||
|
||||
forAll(surfPoints, i)
|
||||
{
|
||||
const point& pt = surfPoints[i];
|
||||
points->InsertNextPoint(pt.x(), pt.y(), pt.z());
|
||||
}
|
||||
|
||||
forAll(surf, i)
|
||||
{
|
||||
const Foam::face& f = surf[i];
|
||||
|
||||
vtkSmartPointer<vtkTriangle> triangle =
|
||||
vtkSmartPointer<vtkTriangle>::New();
|
||||
triangle->GetPointIds()->SetId(0, f[0]);
|
||||
triangle->GetPointIds()->SetId(1, f[1]);
|
||||
triangle->GetPointIds()->SetId(2, f[2]);
|
||||
triangles->InsertNextCell(triangle);
|
||||
|
||||
double n[3];
|
||||
n[0] = surfFaceNormals[i].x();
|
||||
n[1] = surfFaceNormals[i].y();
|
||||
n[2] = surfFaceNormals[i].z();
|
||||
|
||||
faceNormals->InsertNextTuple(n);
|
||||
}
|
||||
|
||||
surf.clearOut();
|
||||
|
||||
vtkSmartPointer<vtkPolyData> polyData =
|
||||
vtkSmartPointer<vtkPolyData>::New();
|
||||
polyData->SetPoints(points);
|
||||
polyData->SetPolys(triangles);
|
||||
polyData->GetCellData()->SetNormals(faceNormals);
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->ScalarVisibilityOff();
|
||||
mapper->SetInputData(polyData);
|
||||
|
||||
addFeatureEdges(renderer, polyData);
|
||||
|
||||
surfaceActor_->SetMapper(mapper);
|
||||
|
||||
setRepresentation(surfaceActor_);
|
||||
|
||||
renderer->AddActor(surfaceActor_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::geometrySurface::geometrySurface
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
surface(parent, dict, colours),
|
||||
fileNames_(dict.lookup("files"))
|
||||
{}
|
||||
|
||||
|
||||
Foam::geometrySurface::geometrySurface
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours,
|
||||
const List<fileName>& fileNames
|
||||
)
|
||||
:
|
||||
surface(parent, dict, colours),
|
||||
fileNames_(fileNames)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::geometrySurface::~geometrySurface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::geometrySurface::addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
)
|
||||
{
|
||||
if (!visible_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
forAll(fileNames_, i)
|
||||
{
|
||||
fileName fName = fileNames_[i].expand();
|
||||
addGeometryToScene(position, renderer, fName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::geometrySurface::updateActors(const scalar position)
|
||||
{
|
||||
if (!visible_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
surface::updateActors(position);
|
||||
|
||||
surfaceActor_->GetProperty()->SetOpacity(opacity(position));
|
||||
|
||||
vector sc = surfaceColour_->value(position);
|
||||
surfaceActor_->GetProperty()->SetColor(sc[0], sc[1], sc[2]);
|
||||
|
||||
vector ec = edgeColour_->value(position);
|
||||
surfaceActor_->GetProperty()->SetEdgeColor(ec[0], ec[1], ec[2]);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,136 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::geometrySurface
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
geometrySurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef geometrySurface_H
|
||||
#define geometrySurface_H
|
||||
|
||||
#include "surface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkPolyData;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class geometrySurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class geometrySurface
|
||||
:
|
||||
public surface
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
geometrySurface(const geometrySurface&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const geometrySurface&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- File names
|
||||
List<fileName> fileNames_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Add surface (file) to scene
|
||||
void addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer,
|
||||
const fileName& fName
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("geometry");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
geometrySurface
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
//- Construct from components
|
||||
geometrySurface
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours,
|
||||
const List<fileName>& fileNames
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~geometrySurface();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add surface(s) to scene
|
||||
virtual void addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
);
|
||||
|
||||
//- Update actors
|
||||
virtual void updateActors(const scalar position);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,211 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "pathline.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkActor.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkProperty.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkTubeFilter.h"
|
||||
#include "vtkLookupTable.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum<pathline::representationType, 4>::names[] =
|
||||
{
|
||||
"none",
|
||||
"line",
|
||||
"tube",
|
||||
"vector"
|
||||
};
|
||||
|
||||
defineTypeNameAndDebug(pathline, 0);
|
||||
defineRunTimeSelectionTable(pathline, dictionary);
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::pathline::representationType, 4>
|
||||
Foam::pathline::representationTypeNames;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::pathline::addLines
|
||||
(
|
||||
const label frameI,
|
||||
vtkActor* actor,
|
||||
vtkPolyData* data
|
||||
) const
|
||||
{
|
||||
geometryBase::initialiseActor(actor);
|
||||
|
||||
vector colour = lineColour_->value(frameI);
|
||||
actor->GetProperty()->SetColor(colour[0], colour[1], colour[2]);
|
||||
|
||||
vtkPolyDataMapper* mapper =
|
||||
vtkPolyDataMapper::SafeDownCast(actor->GetMapper());
|
||||
|
||||
switch (representation_)
|
||||
{
|
||||
case rtNone:
|
||||
{
|
||||
actor->VisibilityOff();
|
||||
break;
|
||||
}
|
||||
case rtLine:
|
||||
{
|
||||
mapper->SetInputData(data);
|
||||
mapper->Update();
|
||||
break;
|
||||
|
||||
}
|
||||
case rtTube:
|
||||
{
|
||||
vtkSmartPointer<vtkTubeFilter> tubes =
|
||||
vtkSmartPointer<vtkTubeFilter>::New();
|
||||
tubes->SetInputData(data);
|
||||
tubes->SetRadius(tubeRadius_);
|
||||
tubes->SetNumberOfSides(20);
|
||||
tubes->CappingOn();
|
||||
tubes->Update();
|
||||
|
||||
mapper->SetInputConnection(tubes->GetOutputPort());
|
||||
mapper->Update();
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
case rtVector:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pathline::pathline
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
geometryBase(parent, dict, colours),
|
||||
representation_
|
||||
(
|
||||
representationTypeNames.read(dict.lookup("representation"))
|
||||
),
|
||||
tubeRadius_(0.0),
|
||||
lineColour_(NULL)
|
||||
{
|
||||
if (dict.found("lineColour"))
|
||||
{
|
||||
lineColour_.reset(DataEntry<vector>::New("lineColour", dict).ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
lineColour_.reset(colours["line"]->clone().ptr());
|
||||
}
|
||||
|
||||
switch (representation_)
|
||||
{
|
||||
case rtNone:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case rtLine:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case rtTube:
|
||||
{
|
||||
dict.lookup("tubeRadius") >> tubeRadius_;
|
||||
break;
|
||||
}
|
||||
case rtVector:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::pathline> Foam::pathline::New
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours,
|
||||
const word& pathlineType
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Selecting pathline " << pathlineType << endl;
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(pathlineType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::autoPtr<Foam::pathline> Foam::pathline::New"
|
||||
"("
|
||||
"const runTimePostProcessing&, "
|
||||
"const dictionary&, "
|
||||
"const HashPtrTable<DataEntry<vector>, word>&, "
|
||||
"const word&"
|
||||
")"
|
||||
) << "Unknown pathline type "
|
||||
<< pathlineType << nl << nl
|
||||
<< "Valid pathline types are:" << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<pathline>(cstrIter()(parent, dict, colours));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pathline::~pathline()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,167 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::pathline
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
pathline.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pathline_H
|
||||
#define pathline_H
|
||||
|
||||
#include "geometryBase.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkActor;
|
||||
class vtkPolyData;
|
||||
class vtkPolyDataMapper;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pathline Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pathline
|
||||
:
|
||||
public geometryBase
|
||||
{
|
||||
public:
|
||||
|
||||
// Public enumerations
|
||||
|
||||
enum representationType
|
||||
{
|
||||
rtNone,
|
||||
rtLine,
|
||||
rtTube,
|
||||
rtVector
|
||||
};
|
||||
|
||||
static const NamedEnum<representationType, 4> representationTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pathline(const pathline&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const pathline&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Representation type
|
||||
representationType representation_;
|
||||
|
||||
//- Radius for the tube filter
|
||||
scalar tubeRadius_;
|
||||
|
||||
//- Line colour
|
||||
autoPtr<DataEntry<vector> > lineColour_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Add the pathlines to the renderer
|
||||
void addLines
|
||||
(
|
||||
const label frameI,
|
||||
vtkActor* actor,
|
||||
vtkPolyData* data
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("pathline");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
pathline,
|
||||
dictionary,
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
),
|
||||
(parent, dict, colours)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
pathline
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected RAS model
|
||||
static autoPtr<pathline> New
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours,
|
||||
const word& pathlineName
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pathline();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,171 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "pointData.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkActor.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkProperty.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkTubeFilter.h"
|
||||
#include "vtkLookupTable.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum<pointData::representationType, 2>::names[] =
|
||||
{
|
||||
"sphere",
|
||||
"vector"
|
||||
};
|
||||
|
||||
defineTypeNameAndDebug(pointData, 0);
|
||||
defineRunTimeSelectionTable(pointData, dictionary);
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::pointData::representationType, 2>
|
||||
Foam::pointData::representationTypeNames;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::pointData::addPoints
|
||||
(
|
||||
const label frameI,
|
||||
vtkActor* actor,
|
||||
vtkPolyDataMapper* mapper,
|
||||
vtkPolyData* data
|
||||
) const
|
||||
{
|
||||
geometryBase::initialiseActor(actor);
|
||||
|
||||
vector colour = pointColour_->value(frameI);
|
||||
actor->GetProperty()->SetColor(colour[0], colour[1], colour[2]);
|
||||
|
||||
switch (representation_)
|
||||
{
|
||||
case rtSphere:
|
||||
case rtVector:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointData::pointData
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
geometryBase(parent, dict, colours),
|
||||
representation_
|
||||
(
|
||||
representationTypeNames.read(dict.lookup("representation"))
|
||||
),
|
||||
maxGlyphLength_(readScalar(dict.lookup("maxGlyphLength"))),
|
||||
pointColour_(NULL)
|
||||
{
|
||||
if (dict.found("pointColour"))
|
||||
{
|
||||
pointColour_.reset(DataEntry<vector>::New("pointColour", dict).ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
pointColour_.reset(colours["point"]->clone().ptr());
|
||||
}
|
||||
|
||||
switch (representation_)
|
||||
{
|
||||
case rtSphere:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case rtVector:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::pointData> Foam::pointData::New
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours,
|
||||
const word& pointDataType
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Selecting pointData " << pointDataType << endl;
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(pointDataType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::autoPtr<Foam::pointData> Foam::pointData::New"
|
||||
"("
|
||||
"const runTimePostProcessing&, "
|
||||
"const dictionary&, "
|
||||
"const HashPtrTable<DataEntry<vector>, word>&, "
|
||||
"const word&"
|
||||
")"
|
||||
) << "Unknown pointData type "
|
||||
<< pointDataType << nl << nl
|
||||
<< "Valid pointData types are:" << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<pointData>(cstrIter()(parent, dict, colours));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointData::~pointData()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,166 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::pointData
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
pointData.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pointData_H
|
||||
#define pointData_H
|
||||
|
||||
#include "geometryBase.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkActor;
|
||||
class vtkPolyData;
|
||||
class vtkPolyDataMapper;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pointData Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pointData
|
||||
:
|
||||
public geometryBase
|
||||
{
|
||||
public:
|
||||
|
||||
// Public enumerations
|
||||
|
||||
enum representationType
|
||||
{
|
||||
rtSphere,
|
||||
rtVector
|
||||
};
|
||||
|
||||
static const NamedEnum<representationType, 2> representationTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pointData(const pointData&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const pointData&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Representation type
|
||||
representationType representation_;
|
||||
|
||||
//- Max glyph length
|
||||
scalar maxGlyphLength_;
|
||||
|
||||
//- Point colour
|
||||
autoPtr<DataEntry<vector> > pointColour_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Add the point data to the renderer
|
||||
void addPoints
|
||||
(
|
||||
const label frameI,
|
||||
vtkActor* actor,
|
||||
vtkPolyDataMapper* mapper,
|
||||
vtkPolyData* data
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("pointData");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
pointData,
|
||||
dictionary,
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
),
|
||||
(parent, dict, colours)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
pointData
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected RAS model
|
||||
static autoPtr<pointData> New
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours,
|
||||
const word& pointDataName
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pointData();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,210 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "runTimePostProcessing.H"
|
||||
#include "dictionary.H"
|
||||
#include "pointData.H"
|
||||
#include "pathline.H"
|
||||
#include "surface.H"
|
||||
#include "text.H"
|
||||
#include "Time.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkRenderWindow.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
#include "vtkLight.h"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(runTimePostProcessing, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::runTimePostProcessing::runTimePostProcessing
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectState(obr, name),
|
||||
scene_(obr, name),
|
||||
points_(),
|
||||
lines_(),
|
||||
surfaces_(),
|
||||
text_(),
|
||||
obr_(obr),
|
||||
active_(true)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::runTimePostProcessing::~runTimePostProcessing()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::runTimePostProcessing::read(const dictionary& dict)
|
||||
{
|
||||
Info<< type() << " " << name_ << ": reading post-processing data" << endl;
|
||||
|
||||
scene_.read(dict);
|
||||
|
||||
const dictionary& outputDict = dict.subDict("output");
|
||||
outputDict.lookup("name") >> output_.name_;
|
||||
outputDict.lookup("width") >> output_.width_;
|
||||
outputDict.lookup("height") >> output_.height_;
|
||||
|
||||
|
||||
readObjects(dict.subOrEmptyDict("points"), points_);
|
||||
readObjects(dict.subOrEmptyDict("lines"), lines_);
|
||||
readObjects(dict.subOrEmptyDict("surfaces"), surfaces_);
|
||||
|
||||
|
||||
const dictionary& textDict = dict.subDict("text");
|
||||
forAllConstIter(dictionary, textDict, iter)
|
||||
{
|
||||
if (!iter().isDict())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"void Foam::runTimePostProcessing::read(const dictionary&)",
|
||||
textDict
|
||||
)
|
||||
<< "text must be specified in dictionary format"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
text_.append(new text(*this, iter().dict(), scene_.colours()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::runTimePostProcessing::execute()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::runTimePostProcessing::end()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::runTimePostProcessing::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::runTimePostProcessing::write()
|
||||
{
|
||||
if (!Pstream::master())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " Constructing scene" << endl;
|
||||
|
||||
// Initialise render window
|
||||
vtkSmartPointer<vtkRenderWindow> renderWindow =
|
||||
vtkSmartPointer<vtkRenderWindow>::New();
|
||||
renderWindow->OffScreenRenderingOn();
|
||||
renderWindow->SetSize(output_.width_, output_.height_);
|
||||
renderWindow->SetAAFrames(10);
|
||||
renderWindow->SetAlphaBitPlanes(true);
|
||||
renderWindow->SetMultiSamples(0);
|
||||
// renderWindow->PolygonSmoothingOn();
|
||||
|
||||
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
|
||||
scene_.initialise(renderer, output_.name_);
|
||||
|
||||
renderWindow->AddRenderer(renderer);
|
||||
|
||||
// Add the points
|
||||
forAll(points_, i)
|
||||
{
|
||||
points_[i].addGeometryToScene(0, renderer);
|
||||
}
|
||||
|
||||
// Add the lines
|
||||
forAll(lines_, i)
|
||||
{
|
||||
lines_[i].addGeometryToScene(0, renderer);
|
||||
}
|
||||
|
||||
// Add the surfaces
|
||||
forAll(surfaces_, i)
|
||||
{
|
||||
surfaces_[i].addGeometryToScene(0, renderer);
|
||||
}
|
||||
|
||||
while (scene_.loop(renderer))
|
||||
{
|
||||
scalar position = scene_.position();
|
||||
|
||||
// Add the text
|
||||
forAll(text_, i)
|
||||
{
|
||||
text_[i].addGeometryToScene(position, renderer);
|
||||
}
|
||||
|
||||
// Update the points
|
||||
forAll(points_, i)
|
||||
{
|
||||
points_[i].updateActors(position);
|
||||
}
|
||||
|
||||
// Update the lines
|
||||
forAll(lines_, i)
|
||||
{
|
||||
lines_[i].updateActors(position);
|
||||
}
|
||||
|
||||
// Update the surfaces
|
||||
forAll(surfaces_, i)
|
||||
{
|
||||
surfaces_[i].updateActors(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,205 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::runTimePostProcessing
|
||||
|
||||
Description
|
||||
Function object to generate images during run-time.
|
||||
|
||||
The functionality makes use of the VTK libraries (see http://www.vtk.org)
|
||||
which provide a broad set of functionality for scene composition and
|
||||
manipulation.
|
||||
|
||||
Images are generated using a combination of function object output, and
|
||||
additional data e.gg triangulated surfaces and text. Current capabilities
|
||||
include support for:
|
||||
- Camera
|
||||
- Objects
|
||||
- Points
|
||||
- Lines
|
||||
- Surfaces
|
||||
- Scalar bars
|
||||
- Annotations
|
||||
- Selection of colour maps
|
||||
Scene configuration is performed using standard OpenFOAM dictionaries, using
|
||||
the main headings of: output=, camera, colours, points, lines,
|
||||
surfaces and text.
|
||||
|
||||
SourceFiles
|
||||
runTimePostProcessing.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef runTimePostProcessing_H
|
||||
#define runTimePostProcessing_H
|
||||
|
||||
#include "functionObjectState.H"
|
||||
#include "objectRegistry.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "PtrList.H"
|
||||
#include "scene.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkRenderer;
|
||||
class vtkRenderWindow;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class dictionary;
|
||||
class pointData;
|
||||
class pathline;
|
||||
class surface;
|
||||
class text;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class runTimePostProcessing Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class runTimePostProcessing
|
||||
:
|
||||
public functionObjectState
|
||||
{
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
// Output
|
||||
struct outputType
|
||||
{
|
||||
word name_;
|
||||
label width_;
|
||||
label height_;
|
||||
};
|
||||
|
||||
//- Output instance
|
||||
outputType output_;
|
||||
|
||||
//- Scene manager
|
||||
scene scene_;
|
||||
|
||||
//- List of points
|
||||
PtrList<pointData> points_;
|
||||
|
||||
//- List of lines
|
||||
PtrList<pathline> lines_;
|
||||
|
||||
//- List of surfaces
|
||||
PtrList<surface> surfaces_;
|
||||
|
||||
//- List of text
|
||||
PtrList<text> text_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Helper function to read scene objects
|
||||
template<class Type>
|
||||
void readObjects
|
||||
(
|
||||
const dictionary& dict,
|
||||
PtrList<Type>& objects
|
||||
) const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("runTimePostProcessing");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
runTimePostProcessing
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
//- Desructor
|
||||
virtual ~runTimePostProcessing();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual const objectRegistry& obr() const
|
||||
{
|
||||
return obr_;
|
||||
}
|
||||
|
||||
//- Read the field min/max data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "runTimePostProcessingTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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 "runTimePostProcessingFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(runTimePostProcessingFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
runTimePostProcessingFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::runTimePostProcessingFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around runTimePostProcessing to allow them to be
|
||||
created via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
runTimePostProcessingFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef runTimePostProcessingFunctionObject_H
|
||||
#define runTimePostProcessingFunctionObject_H
|
||||
|
||||
#include "runTimePostProcessing.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<runTimePostProcessing>
|
||||
runTimePostProcessingFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::runTimePostProcessing::readObjects
|
||||
(
|
||||
const dictionary& dict,
|
||||
PtrList<Type>& objects
|
||||
) const
|
||||
{
|
||||
objects.clear();
|
||||
forAllConstIter(dictionary, dict, iter)
|
||||
{
|
||||
if (!iter().isDict())
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"void Foam::runTimePostProcessing::readObjects"
|
||||
"("
|
||||
"const dictionary&, "
|
||||
"PtrList<Type>&"
|
||||
")",
|
||||
dict
|
||||
)
|
||||
<< dict.dictName()
|
||||
<< " objects must be specified in dictionary format"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
const dictionary& objectDict(iter().dict());
|
||||
word objectType = objectDict.lookup("type");
|
||||
|
||||
objects.append
|
||||
(
|
||||
Type::New(*this, iter().dict(), scene_.colours(), objectType)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,410 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "scene.H"
|
||||
#include "Constant.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkCamera.h"
|
||||
#include "vtkCubeSource.h"
|
||||
#include "vtkLightKit.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkPNGWriter.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkRendererCollection.h"
|
||||
#include "vtkRenderWindow.h"
|
||||
#include "vtkWindowToImageFilter.h"
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum<scene::modeType, 2>::names[] =
|
||||
{
|
||||
"static",
|
||||
"flightPath"
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::scene::modeType, 2> modeTypeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::scene::readCamera(const dictionary& dict)
|
||||
{
|
||||
if (dict.readIfPresent("nFrameTotal", nFrameTotal_))
|
||||
{
|
||||
if (nFrameTotal_ < 1)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"void Foam::scene::readCamera(const dictionary&)",
|
||||
dict
|
||||
) << "nFrameTotal must be 1 or greater"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("startPosition", position_))
|
||||
{
|
||||
if ((position_ < 0) || (position_ > 1))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"void Foam::scene::readCamera(const dictionary&)",
|
||||
dict
|
||||
) << "startPosition must be in the range 0-1"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dict.lookup("parallelProjection") >> parallelProjection_;
|
||||
|
||||
if (nFrameTotal_ > 1)
|
||||
{
|
||||
scalar endPosition = dict.lookupOrDefault<scalar>("endPosition", 1);
|
||||
if ((endPosition < 0) || (endPosition > 1))
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"void Foam::scene::readCamera(const dictionary&)",
|
||||
dict
|
||||
) << "endPosition must be in the range 0-1"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
dPosition_ = (endPosition - position_)/scalar(nFrameTotal_ - 1);
|
||||
}
|
||||
|
||||
mode_ = modeTypeNames_.read(dict.lookup("mode"));
|
||||
|
||||
word coeffsName = modeTypeNames_[mode_] + word("Coeffs");
|
||||
const dictionary& coeffs = dict.subDict(coeffsName);
|
||||
|
||||
switch (mode_)
|
||||
{
|
||||
case mtStatic:
|
||||
{
|
||||
clipBox_ = boundBox(coeffs.lookup("clipBox"));
|
||||
const vector lookDir(vector(coeffs.lookup("lookDir")));
|
||||
cameraPosition_.reset(new Constant<point>("position", -lookDir));
|
||||
const vector focalPoint(coeffs.lookup("focalPoint"));
|
||||
cameraFocalPoint_.reset
|
||||
(
|
||||
new Constant<point>("focalPoint", focalPoint)
|
||||
);
|
||||
const vector up(coeffs.lookup("up"));
|
||||
cameraUp_.reset(new Constant<point>("up", up));
|
||||
break;
|
||||
}
|
||||
case mtFlightPath:
|
||||
{
|
||||
cameraPosition_.reset
|
||||
(
|
||||
DataEntry<vector>::New("position", coeffs).ptr()
|
||||
);
|
||||
cameraFocalPoint_.reset
|
||||
(
|
||||
DataEntry<point>::New("focalPoint", coeffs).ptr()
|
||||
);
|
||||
cameraUp_.reset(DataEntry<vector>::New("up", coeffs).ptr());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("void Foam::scene::read(const dictionary&)")
|
||||
<< "Unhandled enumeration " << modeTypeNames_[mode_]
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.found("zoom"))
|
||||
{
|
||||
cameraZoom_.reset(DataEntry<scalar>::New("zoom", dict).ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraZoom_.reset(new Constant<scalar>("zoom", 1.0));
|
||||
}
|
||||
|
||||
if (dict.found("viewAngle"))
|
||||
{
|
||||
cameraViewAngle_.reset(DataEntry<scalar>::New("viewAngle", dict).ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraViewAngle_.reset(new Constant<scalar>("viewAngle", 35.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::scene::readColours(const dictionary& dict)
|
||||
{
|
||||
const wordList colours = dict.toc();
|
||||
forAll(colours, i)
|
||||
{
|
||||
const word& c = colours[i];
|
||||
colours_.insert(c, DataEntry<vector>::New(c, dict).ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::scene::initialise(vtkRenderer* renderer, const word& outputName)
|
||||
{
|
||||
currentFrameI_ = 0;
|
||||
|
||||
outputName_ = outputName;
|
||||
|
||||
// Set the background
|
||||
const vector backgroundColour = colours_["background"]->value(position());
|
||||
renderer->SetBackground
|
||||
(
|
||||
backgroundColour.x(),
|
||||
backgroundColour.y(),
|
||||
backgroundColour.z()
|
||||
);
|
||||
|
||||
// Apply gradient background if "background2" defined
|
||||
if (colours_.found("background2"))
|
||||
{
|
||||
renderer->GradientBackgroundOn();
|
||||
vector backgroundColour2 = colours_["background2"]->value(position());
|
||||
|
||||
renderer->SetBackground2
|
||||
(
|
||||
backgroundColour2.x(),
|
||||
backgroundColour2.y(),
|
||||
backgroundColour2.z()
|
||||
);
|
||||
}
|
||||
|
||||
// Depth peeling
|
||||
renderer->SetUseDepthPeeling(true);
|
||||
renderer->SetMaximumNumberOfPeels(4);
|
||||
renderer->SetOcclusionRatio(0);
|
||||
|
||||
// Set the camera
|
||||
vtkSmartPointer<vtkCamera> camera = vtkSmartPointer<vtkCamera>::New();
|
||||
camera->SetParallelProjection(parallelProjection_);
|
||||
renderer->SetActiveCamera(camera);
|
||||
|
||||
setCamera(renderer, true);
|
||||
|
||||
// Initialise the extents
|
||||
if (mode_ == mtStatic)
|
||||
{
|
||||
const point& min = clipBox_.min();
|
||||
const point& max = clipBox_.max();
|
||||
vtkSmartPointer<vtkCubeSource> clipBox =
|
||||
vtkSmartPointer<vtkCubeSource>::New();
|
||||
clipBox->SetXLength(max.x() - min.x());
|
||||
clipBox->SetYLength(max.y() - min.y());
|
||||
clipBox->SetZLength(max.z() - min.z());
|
||||
clipBox->SetCenter
|
||||
(
|
||||
min.x() + 0.5*(max.x() - min.x()),
|
||||
min.y() + 0.5*(max.y() - min.y()),
|
||||
min.z() + 0.5*(max.z() - min.z())
|
||||
);
|
||||
vtkSmartPointer<vtkPolyDataMapper> clipMapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
clipMapper->SetInputConnection(clipBox->GetOutputPort());
|
||||
|
||||
vtkSmartPointer<vtkActor> clipActor = vtkSmartPointer<vtkActor>::New();
|
||||
clipActor->SetMapper(clipMapper);
|
||||
clipActor->VisibilityOn();
|
||||
renderer->AddActor(clipActor);
|
||||
|
||||
renderer->ResetCamera();
|
||||
|
||||
clipActor->VisibilityOff();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::scene::setCamera(vtkRenderer* renderer, const bool override) const
|
||||
{
|
||||
if (mode_ == mtFlightPath || override)
|
||||
{
|
||||
vtkCamera* camera = renderer->GetActiveCamera();
|
||||
|
||||
if (!parallelProjection_)
|
||||
{
|
||||
camera->SetViewAngle(cameraViewAngle_->value(position()));
|
||||
}
|
||||
|
||||
const vector up = cameraUp_->value(position());
|
||||
const vector pos = cameraPosition_->value(position());
|
||||
const point focalPoint = cameraFocalPoint_->value(position());
|
||||
|
||||
camera->SetViewUp(up.x(), up.y(), up.z());
|
||||
camera->SetPosition(pos.x(), pos.y(), pos.z());
|
||||
camera->SetFocalPoint(focalPoint.x(), focalPoint.y(), focalPoint.z());
|
||||
camera->Modified();
|
||||
|
||||
vtkSmartPointer<vtkLightKit> lightKit =
|
||||
vtkSmartPointer<vtkLightKit>::New();
|
||||
lightKit->AddLightsToRenderer(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::scene::frameIndexStr() const
|
||||
{
|
||||
string str = Foam::name(currentFrameI_);
|
||||
str.insert(0, 4 - str.length(), '0');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scene::scene(const objectRegistry& obr, const word& name)
|
||||
:
|
||||
obr_(obr),
|
||||
name_(name),
|
||||
colours_(),
|
||||
mode_(mtStatic),
|
||||
cameraPosition_(NULL),
|
||||
cameraFocalPoint_(NULL),
|
||||
cameraUp_(NULL),
|
||||
cameraZoom_(NULL),
|
||||
cameraViewAngle_(NULL),
|
||||
clipBox_(),
|
||||
parallelProjection_(true),
|
||||
nFrameTotal_(1),
|
||||
position_(0),
|
||||
dPosition_(0),
|
||||
currentFrameI_(0),
|
||||
outputName_("unknown")
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scene::~scene()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::HashPtrTable<Foam::DataEntry<Foam::vector>, Foam::word>&
|
||||
Foam::scene::colours() const
|
||||
{
|
||||
return colours_;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::scene::frameIndex() const
|
||||
{
|
||||
return currentFrameI_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::scene::position() const
|
||||
{
|
||||
return position_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::scene::read(const dictionary& dict)
|
||||
{
|
||||
readCamera(dict.subDict("camera"));
|
||||
readColours(dict.subDict("colours"));
|
||||
}
|
||||
|
||||
|
||||
bool Foam::scene::loop(vtkRenderer* renderer)
|
||||
{
|
||||
static bool initialised = false;
|
||||
|
||||
setCamera(renderer, false);
|
||||
|
||||
if (!initialised)
|
||||
{
|
||||
initialised = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Save image from last iteration
|
||||
saveImage(renderer->GetRenderWindow());
|
||||
|
||||
currentFrameI_++;
|
||||
|
||||
position_ += currentFrameI_*dPosition_;
|
||||
|
||||
if (currentFrameI_ < nFrameTotal_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::scene::saveImage(vtkRenderWindow* renderWindow) const
|
||||
{
|
||||
if (!renderWindow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fileName prefix("postProcessing"/name_/obr_.time().timeName());
|
||||
mkDir(prefix);
|
||||
|
||||
renderWindow->Render();
|
||||
|
||||
// Set up off-screen rendering
|
||||
vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter =
|
||||
vtkSmartPointer<vtkWindowToImageFilter>::New();
|
||||
|
||||
windowToImageFilter->SetInput(renderWindow);
|
||||
|
||||
//// Add alpha channel for transparency
|
||||
// windowToImageFilter->SetInputBufferTypeToRGBA();
|
||||
windowToImageFilter->SetInputBufferTypeToRGB();
|
||||
|
||||
// windowToImageFilter->ReadFrontBufferOff();
|
||||
windowToImageFilter->Update();
|
||||
|
||||
// Save the image
|
||||
vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::New();
|
||||
fileName fName(prefix/outputName_ + '.' + frameIndexStr() + ".png");
|
||||
writer->SetFileName(fName.c_str());
|
||||
writer->SetInputConnection(windowToImageFilter->GetOutputPort());
|
||||
|
||||
Info<< " Generating image: " << fName << endl;
|
||||
|
||||
writer->Write();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,202 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::camera
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
scene.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef scene_H
|
||||
#define scene_H
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "dictionary.H"
|
||||
#include "DataEntry.H"
|
||||
#include "vector.H"
|
||||
#include "point.H"
|
||||
#include "boundBox.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "vector.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkRenderer;
|
||||
class vtkRenderWindow;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class scene Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class scene
|
||||
{
|
||||
public:
|
||||
|
||||
enum modeType{mtStatic, mtFlightPath};
|
||||
|
||||
NamedEnum<modeType, 2> modeTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the object registry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Object name
|
||||
const word name_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read camera properties
|
||||
void readCamera(const dictionary& dict);
|
||||
|
||||
//- Read solour properties
|
||||
void readColours(const dictionary& dict);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
scene(const scene&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const scene&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Colours
|
||||
HashPtrTable<DataEntry<vector>, word> colours_;
|
||||
|
||||
|
||||
// Camera settings
|
||||
|
||||
//- Mode
|
||||
modeType mode_;
|
||||
|
||||
//- Position
|
||||
autoPtr<DataEntry<point> > cameraPosition_;
|
||||
|
||||
//- Focal point
|
||||
autoPtr<DataEntry<point> > cameraFocalPoint_;
|
||||
|
||||
//- Up direction
|
||||
autoPtr<DataEntry<vector> > cameraUp_;
|
||||
|
||||
//- Zoom level
|
||||
autoPtr<DataEntry<scalar> > cameraZoom_;
|
||||
|
||||
//- View angle
|
||||
autoPtr<DataEntry<scalar> > cameraViewAngle_;
|
||||
|
||||
|
||||
// Scene management
|
||||
|
||||
//- Clipping box
|
||||
boundBox clipBox_;
|
||||
|
||||
//- Parallel projection flag
|
||||
bool parallelProjection_;
|
||||
|
||||
//- Number of frames
|
||||
label nFrameTotal_;
|
||||
|
||||
//- Position [0-1]
|
||||
scalar position_;
|
||||
|
||||
//- Change in position per frame
|
||||
scalar dPosition_;
|
||||
|
||||
//- Index of current frame
|
||||
label currentFrameI_;
|
||||
|
||||
//- Name prefix of output
|
||||
word outputName_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
void setCamera(vtkRenderer* renderer, const bool override) const;
|
||||
|
||||
string frameIndexStr() const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
scene(const objectRegistry& obr, const word& name);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~scene();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the colours
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours() const;
|
||||
|
||||
//- Return the current frame index
|
||||
label frameIndex() const;
|
||||
|
||||
//- Return the current position (in range 0-1)
|
||||
scalar position() const;
|
||||
|
||||
void read(const dictionary& dict);
|
||||
|
||||
void initialise(vtkRenderer* renderer, const word& outputName);
|
||||
|
||||
//- Main control loop
|
||||
bool loop(vtkRenderer* renderer);
|
||||
|
||||
//- Save image to file
|
||||
void saveImage(vtkRenderWindow* renderWindow) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,262 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "surface.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkActor.h"
|
||||
#include "vtkFeatureEdges.h"
|
||||
#include "vtkPolyData.h"
|
||||
#include "vtkPolyDataMapper.h"
|
||||
#include "vtkProperty.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum<surface::representationType, 5>::names[] =
|
||||
{
|
||||
"none",
|
||||
"wireframe",
|
||||
"surface",
|
||||
"surfaceWithEdges",
|
||||
"glyph"
|
||||
};
|
||||
|
||||
defineTypeNameAndDebug(surface, 0);
|
||||
defineRunTimeSelectionTable(surface, dictionary);
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::surface::representationType, 5>
|
||||
Foam::surface::representationTypeNames;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::surface::setRepresentation(vtkActor* actor) const
|
||||
{
|
||||
geometryBase::initialiseActor(actor);
|
||||
|
||||
switch (representation_)
|
||||
{
|
||||
case rtNone:
|
||||
{
|
||||
actor->VisibilityOff();
|
||||
break;
|
||||
}
|
||||
case rtWireframe:
|
||||
{
|
||||
// note: colour is set using general SetColour, not setEdgeColor
|
||||
actor->GetProperty()->SetRepresentationToWireframe();
|
||||
break;
|
||||
}
|
||||
case rtGlyph:
|
||||
case rtSurface:
|
||||
{
|
||||
actor->GetProperty()->SetRepresentationToSurface();
|
||||
break;
|
||||
}
|
||||
case rtSurfaceWithEdges:
|
||||
{
|
||||
actor->GetProperty()->SetRepresentationToSurface();
|
||||
actor->GetProperty()->EdgeVisibilityOn();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::surface::addFeatureEdges
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
vtkPolyData* data
|
||||
) const
|
||||
{
|
||||
if (!featureEdges_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkFeatureEdges> featureEdges =
|
||||
vtkSmartPointer<vtkFeatureEdges>::New();
|
||||
featureEdges->SetInputData(data);
|
||||
featureEdges->BoundaryEdgesOn();
|
||||
featureEdges->FeatureEdgesOn();
|
||||
featureEdges->ManifoldEdgesOff();
|
||||
featureEdges->NonManifoldEdgesOff();
|
||||
// featureEdges->SetFeatureAngle(60);
|
||||
featureEdges->ColoringOff();
|
||||
featureEdges->Update();
|
||||
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection(featureEdges->GetOutputPort());
|
||||
mapper->ScalarVisibilityOff();
|
||||
|
||||
edgeActor_->GetProperty()->SetSpecular(0);
|
||||
edgeActor_->GetProperty()->SetSpecularPower(20);
|
||||
edgeActor_->GetProperty()->SetRepresentationToWireframe();
|
||||
edgeActor_->SetMapper(mapper);
|
||||
|
||||
renderer->AddActor(edgeActor_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surface::surface
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
geometryBase(parent, dict, colours),
|
||||
representation_
|
||||
(
|
||||
representationTypeNames.read(dict.lookup("representation"))
|
||||
),
|
||||
featureEdges_(false),
|
||||
surfaceColour_(NULL),
|
||||
edgeColour_(NULL),
|
||||
surfaceActor_(),
|
||||
edgeActor_(),
|
||||
maxGlyphLength_(0.0)
|
||||
{
|
||||
surfaceActor_ = vtkSmartPointer<vtkActor>::New();
|
||||
edgeActor_ = vtkSmartPointer<vtkActor>::New();
|
||||
|
||||
if (dict.found("surfaceColour"))
|
||||
{
|
||||
surfaceColour_.reset
|
||||
(
|
||||
DataEntry<vector>::New("surfaceColour", dict).ptr()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
surfaceColour_.reset(colours["surface"]->clone().ptr());
|
||||
}
|
||||
|
||||
if (dict.found("edgeColour"))
|
||||
{
|
||||
edgeColour_.reset(DataEntry<vector>::New("edgeColour", dict).ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeColour_.reset(colours["edge"]->clone().ptr());
|
||||
}
|
||||
|
||||
if (representation_ == rtGlyph)
|
||||
{
|
||||
dict.lookup("maxGlyphLength") >> maxGlyphLength_;
|
||||
}
|
||||
else
|
||||
{
|
||||
dict.lookup("featureEdges") >> featureEdges_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::surface> Foam::surface::New
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours,
|
||||
const word& surfaceType
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Selecting surface " << surfaceType << endl;
|
||||
}
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(surfaceType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::autoPtr<Foam::surface> Foam::surface::New"
|
||||
"("
|
||||
"const runTimePostProcessing&, "
|
||||
"const dictionary&, "
|
||||
"const HashPtrTable<DataEntry<vector>, word>&, "
|
||||
"const word&"
|
||||
")"
|
||||
) << "Unknown surface type "
|
||||
<< surfaceType << nl << nl
|
||||
<< "Valid surface types are:" << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<surface>(cstrIter()(parent, dict, colours));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surface::~surface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::surface::updateActors(const scalar position)
|
||||
{
|
||||
if (!featureEdges_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
edgeActor_->GetProperty()->SetLineWidth(2);
|
||||
edgeActor_->GetProperty()->SetOpacity(opacity(position));
|
||||
|
||||
const vector colour = edgeColour_->value(position);
|
||||
edgeActor_->GetProperty()->SetColor
|
||||
(
|
||||
colour[0],
|
||||
colour[1],
|
||||
colour[2]
|
||||
);
|
||||
edgeActor_->GetProperty()->SetEdgeColor
|
||||
(
|
||||
colour[0],
|
||||
colour[1],
|
||||
colour[2]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,190 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::surface
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
surface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surface_H
|
||||
#define surface_H
|
||||
|
||||
#include "geometryBase.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkActor;
|
||||
class vtkRenderer;
|
||||
class vtkPolyData;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surface
|
||||
:
|
||||
public geometryBase
|
||||
{
|
||||
public:
|
||||
|
||||
// Public enumerations
|
||||
|
||||
enum representationType
|
||||
{
|
||||
rtNone,
|
||||
rtWireframe,
|
||||
rtSurface,
|
||||
rtSurfaceWithEdges,
|
||||
rtGlyph
|
||||
};
|
||||
|
||||
static const NamedEnum<representationType, 5> representationTypeNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
surface(const surface&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const surface&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Representation type
|
||||
representationType representation_;
|
||||
|
||||
//- Activate feature edges
|
||||
bool featureEdges_;
|
||||
|
||||
//- Surface colour
|
||||
autoPtr<DataEntry<vector> > surfaceColour_;
|
||||
|
||||
//- Edge colour
|
||||
autoPtr<DataEntry<vector> > edgeColour_;
|
||||
|
||||
//- Surface actor
|
||||
vtkSmartPointer<vtkActor> surfaceActor_;
|
||||
|
||||
//- Edge actor
|
||||
vtkSmartPointer<vtkActor> edgeActor_;
|
||||
|
||||
//- Max glyph length for representation type rtGlyph
|
||||
scalar maxGlyphLength_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Set the representation
|
||||
void setRepresentation(vtkActor* actor) const;
|
||||
|
||||
//- Add feature edges to scene
|
||||
void addFeatureEdges
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
vtkPolyData* data
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Run-time type information
|
||||
TypeName("surface");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
surface,
|
||||
dictionary,
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
),
|
||||
(parent, dict, colours)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
surface
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected RAS model
|
||||
static autoPtr<surface> New
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours,
|
||||
const word& surfaceName
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~surface();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Update the actors
|
||||
virtual void updateActors(const scalar position);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// OpenFOAM includes
|
||||
#include "text.H"
|
||||
#include "runTimePostProcessing.H"
|
||||
|
||||
// VTK includes
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
#include "vtkTextActor.h"
|
||||
#include "vtkTextProperty.h"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::text::text
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
)
|
||||
:
|
||||
geometryBase(parent, dict, colours),
|
||||
string_(dict.lookup("string")),
|
||||
position_(dict.lookup("position")),
|
||||
size_(readScalar(dict.lookup("size"))),
|
||||
colour_(NULL),
|
||||
bold_(readBool(dict.lookup("bold")))
|
||||
{
|
||||
if (dict.found("colour"))
|
||||
{
|
||||
colour_.reset(DataEntry<vector>::New("colour", dict).ptr());
|
||||
}
|
||||
else
|
||||
{
|
||||
colour_.reset(colours["text"]->clone().ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::text::~text()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::text::addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
)
|
||||
{
|
||||
if (!visible_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
|
||||
|
||||
actor->SetInput(string_.c_str());
|
||||
actor->GetTextProperty()->SetFontFamilyToArial();
|
||||
actor->GetTextProperty()->SetFontSize(size_);
|
||||
actor->GetTextProperty()->SetJustificationToLeft();
|
||||
actor->GetTextProperty()->SetVerticalJustificationToBottom();
|
||||
actor->GetTextProperty()->SetBold(bold_);
|
||||
|
||||
const vector colour = colour_->value(position);
|
||||
actor->GetTextProperty()->SetColor(colour[0], colour[1], colour[2]);
|
||||
actor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
|
||||
actor->GetPositionCoordinate()->SetValue
|
||||
(
|
||||
position_.first(),
|
||||
position_.second()
|
||||
);
|
||||
|
||||
renderer->AddActor2D(actor);
|
||||
}
|
||||
|
||||
|
||||
void Foam::text::updateActors(const scalar position)
|
||||
{
|
||||
// do nothing - all handled by addGeometryToScene
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,125 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Class
|
||||
Foam::text
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
text.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef text_H
|
||||
#define text_H
|
||||
|
||||
#include "geometryBase.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class vtkRenderer;
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class text Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class text
|
||||
:
|
||||
public geometryBase
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
text(const text&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const text&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Text
|
||||
string string_;
|
||||
|
||||
//- Position
|
||||
Tuple2<scalar, scalar> position_;
|
||||
|
||||
//- Size
|
||||
scalar size_;
|
||||
|
||||
//- Colour
|
||||
autoPtr<DataEntry<vector> > colour_;
|
||||
|
||||
//- Bold flag
|
||||
bool bold_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from dictionary
|
||||
text
|
||||
(
|
||||
const runTimePostProcessing& parent,
|
||||
const dictionary& dict,
|
||||
const HashPtrTable<DataEntry<vector>, word>& colours
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~text();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Add surface(s) to scene
|
||||
virtual void addGeometryToScene
|
||||
(
|
||||
const scalar position,
|
||||
vtkRenderer* renderer
|
||||
);
|
||||
|
||||
//- Update actors
|
||||
virtual void updateActors(const scalar position);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -93,6 +93,9 @@ Description
|
||||
Property | Description | Required | Default value
|
||||
type | type name: pressureTools| yes |
|
||||
calcTotal | Calculate total coefficient | yes |
|
||||
pName | Name of pressure field | no | p
|
||||
UName | Name of velocity field | no | U
|
||||
rhoName | Name of density field | no | rho
|
||||
pRef | Reference pressure for total pressure | no | 0.0
|
||||
calcCoeff | Calculate pressure coefficient | yes |
|
||||
pInf | Freestream pressure for coefficient calculation | no |
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,6 +35,23 @@ namespace Foam
|
||||
defineTypeNameAndDebug(residuals, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::residuals::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(os, "Residuals");
|
||||
writeCommented(os, "Time");
|
||||
|
||||
forAll(fieldSet_, fieldI)
|
||||
{
|
||||
writeTabbed(os, fieldSet_[fieldI]);
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::residuals::residuals
|
||||
@ -45,7 +62,7 @@ Foam::residuals::residuals
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
functionObjectFile(obr, name, typeName, dict),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
@ -68,7 +85,11 @@ Foam::residuals::residuals
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
if (active_)
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -84,24 +105,11 @@ void Foam::residuals::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
}
|
||||
}
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
|
||||
void Foam::residuals::writeFileHeader(const label i)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeHeader(file(), "Residuals");
|
||||
writeCommented(file(), "Time");
|
||||
|
||||
forAll(fieldSet_, fieldI)
|
||||
{
|
||||
writeTabbed(file(), fieldSet_[fieldI]);
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
wordList allFields(dict.lookup("fields"));
|
||||
wordHashSet uniqueFields(allFields);
|
||||
fieldSet_ = uniqueFields.toc();
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,8 +136,6 @@ void Foam::residuals::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file()<< obr_.time().value();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -83,7 +83,7 @@ class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class residuals Declaration
|
||||
Class residuals Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class residuals
|
||||
@ -116,7 +116,7 @@ protected:
|
||||
void operator=(const residuals&);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -150,7 +150,7 @@ public:
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the field min/max data
|
||||
//- Read the field residuals data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
@ -162,7 +162,7 @@ public:
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the field min/max
|
||||
//- Calculate the field residuals
|
||||
template<class Type>
|
||||
void writeResidual(const word& fieldName);
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,16 +26,11 @@ License
|
||||
#include "residuals.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::residuals::writeResidual
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
void Foam::residuals::writeResidual(const word& fieldName)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -70,6 +70,34 @@ Foam::wordList Foam::scalarTransport::boundaryTypes() const
|
||||
}
|
||||
|
||||
|
||||
Foam::volScalarField& Foam::scalarTransport::transportedField()
|
||||
{
|
||||
if (!mesh_.foundObject<volScalarField>(name()))
|
||||
{
|
||||
volScalarField* fldPtr = new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name(),
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("zero", dimless, 0.0),
|
||||
boundaryTypes()
|
||||
);
|
||||
fldPtr->store();
|
||||
}
|
||||
|
||||
return const_cast<volScalarField&>
|
||||
(
|
||||
mesh_.lookupObject<volScalarField>(name())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::scalarTransport::DT
|
||||
(
|
||||
const surfaceScalarField& phi
|
||||
@ -158,27 +186,13 @@ Foam::scalarTransport::scalarTransport
|
||||
resetOnStartUp_(false),
|
||||
nCorr_(0),
|
||||
autoSchemes_(false),
|
||||
fvOptions_(mesh_),
|
||||
T_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("zero", dimless, 0.0),
|
||||
boundaryTypes()
|
||||
)
|
||||
fvOptions_(mesh_)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
if (resetOnStartUp_)
|
||||
{
|
||||
T_ == dimensionedScalar("zero", dimless, 0.0);
|
||||
transportedField() == dimensionedScalar("zero", dimless, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,11 +241,13 @@ void Foam::scalarTransport::execute()
|
||||
const surfaceScalarField& phi =
|
||||
mesh_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
volScalarField& T = transportedField();
|
||||
|
||||
// calculate the diffusivity
|
||||
volScalarField DT(this->DT(phi));
|
||||
|
||||
// set schemes
|
||||
word schemeVar = T_.name();
|
||||
word schemeVar = T.name();
|
||||
if (autoSchemes_)
|
||||
{
|
||||
schemeVar = UName_;
|
||||
@ -257,11 +273,11 @@ void Foam::scalarTransport::execute()
|
||||
{
|
||||
fvScalarMatrix TEqn
|
||||
(
|
||||
fvm::ddt(rho, T_)
|
||||
+ fvm::div(phi, T_, divScheme)
|
||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
||||
fvm::ddt(rho, T)
|
||||
+ fvm::div(phi, T, divScheme)
|
||||
- fvm::laplacian(DT, T, laplacianScheme)
|
||||
==
|
||||
fvOptions_(rho, T_)
|
||||
fvOptions_(rho, T)
|
||||
);
|
||||
|
||||
TEqn.relax(relaxCoeff);
|
||||
@ -278,11 +294,11 @@ void Foam::scalarTransport::execute()
|
||||
{
|
||||
fvScalarMatrix TEqn
|
||||
(
|
||||
fvm::ddt(T_)
|
||||
+ fvm::div(phi, T_, divScheme)
|
||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
||||
fvm::ddt(T)
|
||||
+ fvm::div(phi, T, divScheme)
|
||||
- fvm::laplacian(DT, T, laplacianScheme)
|
||||
==
|
||||
fvOptions_(T_)
|
||||
fvOptions_(T)
|
||||
);
|
||||
|
||||
TEqn.relax(relaxCoeff);
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -108,15 +108,15 @@ class scalarTransport
|
||||
//- Run-time selectable finite volume options, e.g. sources, constraints
|
||||
fv::optionList fvOptions_;
|
||||
|
||||
//- The scalar field
|
||||
volScalarField T_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Return the boundary types for the scalar field
|
||||
wordList boundaryTypes() const;
|
||||
|
||||
//- Return reference to registered transported field
|
||||
volScalarField& transportedField();
|
||||
|
||||
//- Return the diffusivity field
|
||||
tmp<volScalarField> DT(const surfaceScalarField& phi) const;
|
||||
|
||||
|
||||
@ -35,27 +35,31 @@ namespace Foam
|
||||
defineTypeNameAndDebug(turbulenceFields, 0);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<turbulenceFields::compressibleField, 6>::names[] =
|
||||
const char* NamedEnum<turbulenceFields::compressibleField, 8>::names[] =
|
||||
{
|
||||
"R",
|
||||
"devRhoReff",
|
||||
"k",
|
||||
"epsilon",
|
||||
"mut",
|
||||
"muEff",
|
||||
"alphat",
|
||||
"alphaEff"
|
||||
"alphaEff",
|
||||
"R",
|
||||
"devRhoReff"
|
||||
};
|
||||
const NamedEnum<turbulenceFields::compressibleField, 6>
|
||||
const NamedEnum<turbulenceFields::compressibleField, 8>
|
||||
turbulenceFields::compressibleFieldNames_;
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<turbulenceFields::incompressibleField, 4>::names[] =
|
||||
const char* NamedEnum<turbulenceFields::incompressibleField, 6>::names[] =
|
||||
{
|
||||
"R",
|
||||
"devReff",
|
||||
"k",
|
||||
"epsilon",
|
||||
"nut",
|
||||
"nuEff"
|
||||
"nuEff",
|
||||
"R",
|
||||
"devReff"
|
||||
};
|
||||
const NamedEnum<turbulenceFields::incompressibleField, 4>
|
||||
const NamedEnum<turbulenceFields::incompressibleField, 6>
|
||||
turbulenceFields::incompressibleFieldNames_;
|
||||
|
||||
const word turbulenceFields::modelName = turbulenceModel::propertiesName;
|
||||
@ -174,14 +178,14 @@ void Foam::turbulenceFields::execute()
|
||||
const word& f = iter.key();
|
||||
switch (compressibleFieldNames_[f])
|
||||
{
|
||||
case cfR:
|
||||
case cfK:
|
||||
{
|
||||
processField<symmTensor>(f, model.R());
|
||||
processField<scalar>(f, model.k());
|
||||
break;
|
||||
}
|
||||
case cfDevRhoReff:
|
||||
case cfEpsilon:
|
||||
{
|
||||
processField<symmTensor>(f, model.devRhoReff());
|
||||
processField<scalar>(f, model.epsilon());
|
||||
break;
|
||||
}
|
||||
case cfMut:
|
||||
@ -204,6 +208,16 @@ void Foam::turbulenceFields::execute()
|
||||
processField<scalar>(f, model.alphaEff());
|
||||
break;
|
||||
}
|
||||
case cfR:
|
||||
{
|
||||
processField<symmTensor>(f, model.R());
|
||||
break;
|
||||
}
|
||||
case cfDevRhoReff:
|
||||
{
|
||||
processField<symmTensor>(f, model.devRhoReff());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("void Foam::turbulenceFields::execute()")
|
||||
@ -222,14 +236,14 @@ void Foam::turbulenceFields::execute()
|
||||
const word& f = iter.key();
|
||||
switch (incompressibleFieldNames_[f])
|
||||
{
|
||||
case ifR:
|
||||
case ifK:
|
||||
{
|
||||
processField<symmTensor>(f, model.R());
|
||||
processField<scalar>(f, model.k());
|
||||
break;
|
||||
}
|
||||
case ifDevReff:
|
||||
case ifEpsilon:
|
||||
{
|
||||
processField<symmTensor>(f, model.devReff());
|
||||
processField<scalar>(f, model.epsilon());
|
||||
break;
|
||||
}
|
||||
case ifNut:
|
||||
@ -242,6 +256,16 @@ void Foam::turbulenceFields::execute()
|
||||
processField<scalar>(f, model.nuEff());
|
||||
break;
|
||||
}
|
||||
case ifR:
|
||||
{
|
||||
processField<symmTensor>(f, model.R());
|
||||
break;
|
||||
}
|
||||
case ifDevReff:
|
||||
{
|
||||
processField<symmTensor>(f, model.devReff());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("void Foam::turbulenceFields::execute()")
|
||||
@ -263,15 +287,11 @@ void Foam::turbulenceFields::end()
|
||||
|
||||
|
||||
void Foam::turbulenceFields::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void Foam::turbulenceFields::write()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,22 +53,24 @@ Description
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: processorField | yes |
|
||||
fields | fields to store (see below) | yes |
|
||||
Property | Description | Required | Default value
|
||||
type | type name: turbulenceFields | yes |
|
||||
fields | fields to store (see below) | yes |
|
||||
\endtable
|
||||
|
||||
Where \c fields can include:
|
||||
\plaintable
|
||||
R | Stress tensor
|
||||
devRhoReff |
|
||||
k | turbulence kinetic energy
|
||||
epsilon | turbulence kinetic energy dissipation rate
|
||||
nut | turbulence viscosity (incompressible)
|
||||
nuEff | effective turbulence viscosity (incompressible)
|
||||
mut | turbulence viscosity (compressible)
|
||||
muEff | effective turbulence viscosity (compressible)
|
||||
alphat | turbulence thermal diffusivity (compressible)
|
||||
alphaEff | effective turbulence thermal diffusivity (compressible)
|
||||
devReff |
|
||||
nut | turbulence viscosity (incompressible)
|
||||
nuEff | effective turbulence viscosity (incompressible)
|
||||
R | Reynolds stress tensor
|
||||
devReff | Deviatoric part of the effective Reynolds stress
|
||||
devRhoReff | Divergence of the Reynolds stress
|
||||
\endplaintable
|
||||
|
||||
SeeAlso
|
||||
@ -109,23 +111,27 @@ public:
|
||||
|
||||
enum compressibleField
|
||||
{
|
||||
cfR,
|
||||
cfDevRhoReff,
|
||||
cfK,
|
||||
cfEpsilon,
|
||||
cfMut,
|
||||
cfMuEff,
|
||||
cfAlphat,
|
||||
cfAlphaEff
|
||||
cfAlphaEff,
|
||||
cfR,
|
||||
cfDevRhoReff
|
||||
};
|
||||
static const NamedEnum<compressibleField, 6> compressibleFieldNames_;
|
||||
static const NamedEnum<compressibleField, 8> compressibleFieldNames_;
|
||||
|
||||
enum incompressibleField
|
||||
{
|
||||
ifR,
|
||||
ifDevReff,
|
||||
ifK,
|
||||
ifEpsilon,
|
||||
ifNut,
|
||||
ifNuEff
|
||||
ifNuEff,
|
||||
ifR,
|
||||
ifDevReff
|
||||
};
|
||||
static const NamedEnum<incompressibleField, 4> incompressibleFieldNames_;
|
||||
static const NamedEnum<incompressibleField, 6> incompressibleFieldNames_;
|
||||
|
||||
static const word modelName;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,15 +40,15 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::wallShearStress::writeFileHeader(const label i)
|
||||
void Foam::wallShearStress::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
// Add headers to output data
|
||||
writeHeader(file(), "Wall shear stress");
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "patch");
|
||||
writeTabbed(file(), "min");
|
||||
writeTabbed(file(), "max");
|
||||
file() << endl;
|
||||
writeHeader(os, "Wall shear stress");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "patch");
|
||||
writeTabbed(os, "min");
|
||||
writeTabbed(os, "max");
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -74,17 +74,17 @@ void Foam::wallShearStress::calcShearStress
|
||||
vector minSsp = gMin(ssp);
|
||||
vector maxSsp = gMax(ssp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << mesh.time().value()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << minSsp
|
||||
<< token::TAB << maxSsp
|
||||
<< endl;
|
||||
}
|
||||
file() << mesh.time().value()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << minSsp
|
||||
<< token::TAB << maxSsp
|
||||
<< endl;
|
||||
|
||||
if (log_) Info<< " min/max(" << pp.name() << ") = "
|
||||
<< minSsp << ", " << maxSsp << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< " min/max(" << pp.name() << ") = "
|
||||
<< minSsp << ", " << maxSsp << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,10 +99,11 @@ Foam::wallShearStress::wallShearStress
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
functionObjectFile(obr, name, typeName, dict),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
resultName_(name),
|
||||
log_(true),
|
||||
patchSet_()
|
||||
{
|
||||
@ -123,6 +124,8 @@ Foam::wallShearStress::wallShearStress
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
@ -133,7 +136,7 @@ Foam::wallShearStress::wallShearStress
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
resultName_,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
@ -150,9 +153,9 @@ Foam::wallShearStress::wallShearStress
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(wallShearStressPtr);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -168,7 +171,10 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
log_.readIfPresent("log", dict);
|
||||
dict.readIfPresent("resultName", resultName_);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||
@ -179,7 +185,7 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
||||
wordReList(dict.lookupOrDefault("patches", wordReList()))
|
||||
);
|
||||
|
||||
Info<< type() << " " << name_ << ":" << nl;
|
||||
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||
|
||||
if (patchSet_.empty())
|
||||
{
|
||||
@ -191,11 +197,11 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
||||
}
|
||||
}
|
||||
|
||||
Info<< " processing all wall patches" << nl << endl;
|
||||
if (log_) Info << " processing all wall patches" << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " processing wall patches: " << nl;
|
||||
if (log_) Info << " processing wall patches: " << nl;
|
||||
labelHashSet filteredPatchSet;
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
@ -203,7 +209,7 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
||||
if (isA<wallPolyPatch>(pbm[patchI]))
|
||||
{
|
||||
filteredPatchSet.insert(patchI);
|
||||
Info<< " " << pbm[patchI].name() << endl;
|
||||
if (log_) Info << " " << pbm[patchI].name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -213,7 +219,7 @@ void Foam::wallShearStress::read(const dictionary& dict)
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
if (log_) Info << endl;
|
||||
|
||||
patchSet_ = filteredPatchSet;
|
||||
}
|
||||
@ -228,17 +234,15 @@ void Foam::wallShearStress::execute()
|
||||
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volVectorField& wallShearStress =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
mesh.lookupObject<volVectorField>(type())
|
||||
mesh.lookupObject<volVectorField>(resultName_)
|
||||
);
|
||||
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << nl;
|
||||
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||
|
||||
|
||||
tmp<volSymmTensorField> Reff;
|
||||
@ -258,12 +262,14 @@ void Foam::wallShearStress::execute()
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("void Foam::wallShearStress::execute()")
|
||||
FatalErrorIn("void Foam::wallShearStress::write()")
|
||||
<< "Unable to find turbulence model in the "
|
||||
<< "database" << exit(FatalError);
|
||||
}
|
||||
|
||||
calcShearStress(mesh, Reff(), wallShearStress);
|
||||
|
||||
if (log_) Info << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,14 +293,15 @@ void Foam::wallShearStress::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const volVectorField& wallShearStress =
|
||||
obr_.lookupObject<volVectorField>(type());
|
||||
obr_.lookupObject<volVectorField>(resultName_);
|
||||
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << wallShearStress.name() << nl
|
||||
<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << wallShearStress.name() << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
wallShearStress.write();
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -59,9 +59,11 @@ Description
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
Property | Description | Required | Default value
|
||||
type | type name: wallShearStress | yes |
|
||||
resultName | Name of wall shear stress field | no | <function name>
|
||||
patches | list of patches to process | no | all wall patches
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
@ -105,11 +107,15 @@ protected:
|
||||
//- Name of this set of wallShearStress object
|
||||
word name_;
|
||||
|
||||
//- Refefence to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Result name
|
||||
word resultName_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
@ -120,7 +126,7 @@ protected:
|
||||
// Protected Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
//- Calculate the shear stress
|
||||
void calcShearStress
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,16 +38,15 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlus::writeFileHeader(const label i)
|
||||
void Foam::yPlus::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(file(), "y+ ()");
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "patch");
|
||||
writeTabbed(file(), "min");
|
||||
writeTabbed(file(), "max");
|
||||
writeTabbed(file(), "average");
|
||||
file() << endl;
|
||||
writeHeader(os, "y+");
|
||||
writeCommented(os, "Time");
|
||||
writeTabbed(os, "patch");
|
||||
writeTabbed(os, "min");
|
||||
writeTabbed(os, "max");
|
||||
writeTabbed(os, "average");
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -61,12 +60,13 @@ Foam::yPlus::yPlus
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
functionObjectFile(obr, name, typeName, dict),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(true),
|
||||
phiName_("phi")
|
||||
phiName_("phi"),
|
||||
resultName_(name),
|
||||
log_(true)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -87,6 +87,8 @@ Foam::yPlus::yPlus
|
||||
|
||||
if (active_)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* yPlusPtr
|
||||
@ -95,7 +97,7 @@ Foam::yPlus::yPlus
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
resultName_,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
@ -107,6 +109,8 @@ Foam::yPlus::yPlus
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(yPlusPtr);
|
||||
|
||||
writeFileHeader(file());
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,51 +127,81 @@ void Foam::yPlus::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
functionObjectFile::read(dict);
|
||||
|
||||
log_.readIfPresent("log", dict);
|
||||
dict.readIfPresent("resultName", resultName_);
|
||||
dict.readIfPresent("phiName", phiName_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlus::execute()
|
||||
{
|
||||
typedef compressible::turbulenceModel cmpModel;
|
||||
typedef incompressible::turbulenceModel icoModel;
|
||||
typedef compressible::turbulenceModel cmpTurbModel;
|
||||
typedef incompressible::turbulenceModel icoTurbModel;
|
||||
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
const surfaceScalarField& phi =
|
||||
obr_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField& yPlus =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh.lookupObject<volScalarField>(type())
|
||||
mesh.lookupObject<volScalarField>(resultName_)
|
||||
);
|
||||
|
||||
if (log_) Info<< type() << " " << name_ << " output:" << nl;
|
||||
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||
|
||||
tmp<volSymmTensorField> Reff;
|
||||
if (mesh.foundObject<cmpModel>(turbulenceModel::propertiesName))
|
||||
if (phi.dimensions() == dimMass/dimTime)
|
||||
{
|
||||
const cmpModel& model =
|
||||
mesh.lookupObject<cmpModel>(turbulenceModel::propertiesName);
|
||||
if (mesh.foundObject<cmpTurbModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
const cmpTurbModel& model =
|
||||
mesh.lookupObject<cmpTurbModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
calcYPlus(model, mesh, yPlus);
|
||||
calcYPlus(model, mesh, yPlus);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("void Foam::yPlus::execute()")
|
||||
<< "Unable to find compressible turbulence model in the "
|
||||
<< "database: yPlus will not be calculated" << endl;
|
||||
}
|
||||
}
|
||||
else if (mesh.foundObject<icoModel>(turbulenceModel::propertiesName))
|
||||
else if (phi.dimensions() == dimVolume/dimTime)
|
||||
{
|
||||
const icoModel& model =
|
||||
mesh.lookupObject<icoModel>(turbulenceModel::propertiesName);
|
||||
if (mesh.foundObject<icoTurbModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
const icoTurbModel& model =
|
||||
mesh.lookupObject<icoTurbModel>
|
||||
(
|
||||
turbulenceModel::propertiesName
|
||||
);
|
||||
|
||||
calcYPlus(model, mesh, yPlus);
|
||||
calcYPlus(model, mesh, yPlus);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("void Foam::yPlus::execute()")
|
||||
<< "Unable to find incompressible turbulence model in the "
|
||||
<< "database: yPlus will not be calculated" << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("void Foam::yPlus::write()")
|
||||
<< "Unable to find turbulence model in the "
|
||||
<< "database" << exit(FatalError);
|
||||
WarningIn("void Foam::yPlus::execute()")
|
||||
<< "Unknown " << phiName_ << " dimensions: "
|
||||
<< phi.dimensions() << nl
|
||||
<< "Expected either " << dimMass/dimTime << " or "
|
||||
<< dimVolume/dimTime << nl
|
||||
<< "yPlus will not be calculated" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,12 +226,16 @@ void Foam::yPlus::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const volScalarField& yPlus =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
obr_.lookupObject<volScalarField>(resultName_);
|
||||
|
||||
if (log_) Info<< " writing field " << yPlus.name() << nl << endl;
|
||||
if (log_)
|
||||
{
|
||||
Info
|
||||
<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << yPlus.name() << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
yPlus.write();
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,8 +28,29 @@ Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Evaluates and outputs turbulence y+ for models. Values written to
|
||||
time directories as field 'yPlus'
|
||||
This function object evaluates and outputs turbulence y+ for turbulence
|
||||
models. The field is stored on the mesh database so that it can be
|
||||
retrieved and used for other applications.
|
||||
|
||||
Example of function object specification to calculate the y+ (LES):
|
||||
\verbatim
|
||||
yPlus1
|
||||
{
|
||||
type yPlus;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | Type name: yPlus | yes |
|
||||
phiName | Name of flux field | no | phi
|
||||
resultName | Name of y+ field | no | <function name>
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
|
||||
SourceFiles
|
||||
yPlus.C
|
||||
@ -44,6 +65,7 @@ SourceFiles
|
||||
#include "volFieldsFwd.H"
|
||||
#include "Switch.H"
|
||||
#include "OFstream.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -58,7 +80,7 @@ class mapPolyMesh;
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class yPlus Declaration
|
||||
Class yPlus Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class yPlus
|
||||
@ -75,17 +97,20 @@ class yPlus
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Name of mass/volume flux field (optional, default = phi)
|
||||
word phiName_;
|
||||
|
||||
//- Result name
|
||||
word resultName_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
//- Calculate y+
|
||||
template<class TurbulenceModel>
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,10 +23,9 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "yPlus.H"
|
||||
#include "wallFvPatch.H"
|
||||
#include "nutWallFunctionFvPatchScalarField.H"
|
||||
#include "nearWallDist.H"
|
||||
#include "wallFvPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -70,20 +69,19 @@ void Foam::yPlus::calcYPlus
|
||||
const scalar maxYplus = gMax(yPlusp);
|
||||
const scalar avgYplus = gAverage(yPlusp);
|
||||
|
||||
if (Pstream::master())
|
||||
if (log_)
|
||||
{
|
||||
if (log_) Info
|
||||
<< " patch " << patch.name()
|
||||
Info<< " patch " << patch.name()
|
||||
<< " y+ : min = " << minYplus << ", max = " << maxYplus
|
||||
<< ", average = " << avgYplus << nl;
|
||||
|
||||
file() << obr_.time().value()
|
||||
<< token::TAB << patch.name()
|
||||
<< token::TAB << minYplus
|
||||
<< token::TAB << maxYplus
|
||||
<< token::TAB << avgYplus
|
||||
<< endl;
|
||||
}
|
||||
|
||||
file() << obr_.time().value()
|
||||
<< token::TAB << patch.name()
|
||||
<< token::TAB << minYplus
|
||||
<< token::TAB << maxYplus
|
||||
<< token::TAB << avgYplus
|
||||
<< endl;
|
||||
}
|
||||
else if (isA<wallFvPatch>(patch))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user