controlDict: the optional graphFormat entry is now used as the default for all setFormat entries

Foam::graph superseded by the more general Foam::setWriter reducing code
maintenance overhead, simplifying usage and further development.
This commit is contained in:
Henry Weller
2023-06-12 17:14:37 +01:00
parent 1e9e0c141b
commit 618d9d33b2
72 changed files with 372 additions and 2034 deletions

View File

@ -34,8 +34,7 @@ Description
#include "Kmesh.H" #include "Kmesh.H"
#include "UOprocess.H" #include "UOprocess.H"
#include "fft.H" #include "fft.H"
#include "calcEk.H" #include "writeEk.H"
#include "graph.H"
#include "writeFile.H" #include "writeFile.H"
#include "pisoControl.H" #include "pisoControl.H"
@ -130,15 +129,7 @@ int main(int argc, char *argv[])
if (runTime.writeTime()) if (runTime.writeTime())
{ {
calcEk(U, K).write writeEk(U, K);
(
runTime.path()
/functionObjects::writeFile::outputPrefix
/"graphs"
/runTime.name(),
"Ek",
runTime.graphFormat()
);
} }
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"

View File

@ -408,7 +408,11 @@ bool Foam::functionObjects::populationBalanceSizeDistribution::read
fvMeshFunctionObject::read(dict); fvMeshFunctionObject::read(dict);
formatterPtr_ = setWriter::New(dict.lookup("setFormat"), dict); formatterPtr_ = setWriter::New
(
dict.lookupOrDefault("setFormat", time_.graphFormat()),
dict
);
return false; return false;
} }

View File

@ -6,4 +6,7 @@ label sampleFrequency(propsDict.lookup<label>("sampleFrequency"));
label maxPositions(propsDict.lookup<label>("maxPositions")); label maxPositions(propsDict.lookup<label>("maxPositions"));
word setFormat(propsDict.lookupOrDefault<word>("setFormat", "vtk")); word setFormat
(
propsDict.lookupOrDefault<word>("setFormat", runTime.graphFormat())
);

View File

@ -1,21 +0,0 @@
const word dictName("noiseDict");
IOdictionary dict(systemDict(dictName, args, runTime));
// reference pressure
scalar pRef = dict.lookupOrDefault("pRef", 0.0);
// number of samples in sampling window
label N = dict.lookupOrDefault("N", 65536);
// number of sampling windows
label nw = dict.lookupOrDefault("nw", 100);
// lower frequency of frequency band
scalar f1 = dict.lookupOrDefault("f1", 25.0);
// upper frequency of frequency band
scalar fU = dict.lookupOrDefault("fU", 10000.0);
// graph format
word graphFormat = dict.lookupOrDefault<word>("graphFormat", "raw");

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -77,13 +77,13 @@ See also
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "noiseFFT.H" #include "noiseFFT.H"
#include "argList.H" #include "argList.H"
#include "Time.H" #include "Time.H"
#include "Table.H" #include "Table.H"
#include "IOdictionary.H"
#include "systemDict.H" #include "systemDict.H"
#include "setWriter.H"
#include "writeFile.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -132,7 +132,31 @@ int main(int argc, char *argv[])
#include "addDictOption.H" #include "addDictOption.H"
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "createFields.H"
const word dictName("noiseDict");
IOdictionary dict(systemDict(dictName, args, runTime));
// Reference pressure
const scalar pRef = dict.lookupOrDefault("pRef", 0.0);
// Number of samples in sampling window
const label N = dict.lookupOrDefault("N", 65536);
// Number of sampling windows
const label nw = dict.lookupOrDefault("nw", 100);
// Lower frequency of frequency band
const scalar f1 = dict.lookupOrDefault("f1", 25.0);
// Upper frequency of frequency band
const scalar fU = dict.lookupOrDefault("fU", 10000.0);
// Graph format
const word graphFormat
(
dict.lookupOrDefault<word>("graphFormat", runTime.graphFormat())
);
Info<< "Reading data file" << endl; Info<< "Reading data file" << endl;
Function1s::Table<scalar> pData Function1s::Table<scalar> pData
@ -163,24 +187,60 @@ int main(int argc, char *argv[])
nfft -= pRef; nfft -= pRef;
fileName pDateFileName(dict.subDict("pressureData").lookup("file")); const fileName pDateFileName(dict.subDict("pressureData").lookup("file"));
fileName baseFileName(pDateFileName.lessExt()); const fileName baseFileName(pDateFileName.lessExt());
const fileName outputPath
(
runTime.path()
/functionObjects::writeFile::outputPrefix
/baseFileName
);
graph Pf(nfft.RMSmeanPf(N, min(nfft.size()/N, nw))); autoPtr<setWriter> writer(setWriter::New(graphFormat));
Info<< " Creating graph for " << Pf.title() << endl;
Pf.write(baseFileName + graph::wordify(Pf.title()), graphFormat);
graph Lf(nfft.Lf(Pf)); const Pair<scalarField> Pf(nfft.RMSmeanPf(N, min(nfft.size()/N, nw)));
Info<< " Creating graph for " << Lf.title() << endl; Info<< " Creating graph for P(f)" << endl;
Lf.write(baseFileName + graph::wordify(Lf.title()), graphFormat); writer->write
(
outputPath,
"Pf",
coordSet(true, "f [Hz]", Pf.first()),
"P(f) [Pa]",
Pf.second()
);
graph Ldelta(nfft.Ldelta(Lf, f1, fU)); const Pair<scalarField> Lf(nfft.Lf(Pf));
Info<< " Creating graph for " << Ldelta.title() << endl; Info<< " Creating graph for L(f)" << endl;
Ldelta.write(baseFileName + graph::wordify(Ldelta.title()), graphFormat); writer->write
(
outputPath,
"Lf",
coordSet(true, "f [Hz]", Lf.first()),
"L(f) [dB]",
Lf.second()
);
graph Pdelta(nfft.Pdelta(Pf, f1, fU)); const Pair<scalarField> Ldelta(nfft.Ldelta(Lf, f1, fU));
Info<< " Creating graph for " << Pdelta.title() << endl; Info<< " Creating graph for Ldelta" << endl;
Pdelta.write(baseFileName + graph::wordify(Pdelta.title()), graphFormat); writer->write
(
outputPath,
"Ldelta",
coordSet(true, "fm [Hz]", Ldelta.first()),
"Ldelta(f) [dB]",
Ldelta.second()
);
const Pair<scalarField> Pdelta(nfft.Pdelta(Pf, f1, fU));
Info<< " Creating graph for Pdelta" << endl;
writer->write
(
outputPath,
"Pdelta",
coordSet(true, "fm [Hz]", Pdelta.first()),
"P(f) [dB]",
Pdelta.second()
);
Info<< nl << "End\n" << endl; Info<< nl << "End\n" << endl;

View File

@ -32,11 +32,10 @@ Description
#include "argList.H" #include "argList.H"
#include "volFields.H" #include "volFields.H"
#include "graph.H"
#include "OFstream.H" #include "OFstream.H"
#include "Kmesh.H" #include "Kmesh.H"
#include "turbGen.H" #include "turbGen.H"
#include "calcEk.H" #include "writeEk.H"
#include "writeFile.H" #include "writeFile.H"
using namespace Foam; using namespace Foam;
@ -70,15 +69,7 @@ int main(int argc, char *argv[])
U.write(); U.write();
calcEk(U, K).write writeEk(U, K);
(
runTime.path()
/functionObjects::writeFile::outputPrefix
/"graphs"
/runTime.name(),
"Ek",
runTime.graphFormat()
);
Info<< "end" << endl; Info<< "end" << endl;

View File

@ -41,9 +41,14 @@ bool Foam::functionObject::postProcess(false);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObject::functionObject(const word& name) Foam::functionObject::functionObject
(
const word& name,
const Time& runTime
)
: :
name_(name), name_(name),
time_(runTime),
log(false), log(false),
executeAtStart_(true) executeAtStart_(true)
{} {}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -148,6 +148,12 @@ class functionObject
const word name_; const word name_;
protected:
//- Reference to time
const Time& time_;
public: public:
ClassName("functionObject"); ClassName("functionObject");
@ -180,7 +186,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
functionObject(const word& name); functionObject(const word& name, const Time& runTime);
//- Return clone //- Return clone
autoPtr<functionObject> clone() const autoPtr<functionObject> clone() const

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -108,8 +108,7 @@ Foam::functionObjects::regionFunctionObject::regionFunctionObject
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, runTime),
time_(runTime),
obr_ obr_
( (
runTime.lookupObject<objectRegistry> runTime.lookupObject<objectRegistry>
@ -127,8 +126,7 @@ Foam::functionObjects::regionFunctionObject::regionFunctionObject
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, obr.time()),
time_(obr.time()),
obr_(obr) obr_(obr)
{} {}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -65,9 +65,6 @@ protected:
// Protected member data // Protected member data
//- Reference to the Time
const Time& time_;
//- Reference to the region objectRegistry //- Reference to the region objectRegistry
const objectRegistry& obr_; const objectRegistry& obr_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,7 +69,7 @@ private:
// Private Data // Private Data
//- Time object //- Reference to time
const Time& time_; const Time& time_;
//- Prefix //- Prefix

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -75,7 +75,7 @@ Foam::functionObjects::timeControl::timeControl
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, t),
time_(t), time_(t),
startTime_(-vGreat), startTime_(-vGreat),
endTime_(vGreat), endTime_(vGreat),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -87,7 +87,7 @@ bool Foam::functionObjects::CourantNo::calc()
tCo->ref() = tCo->ref() =
byRho byRho
( (
(0.5*mesh_.time().deltaT()) (0.5*time_.deltaT())
*fvc::surfaceSum(mag(phi))()() *fvc::surfaceSum(mag(phi))()()
/mesh_.V() /mesh_.V()
); );

View File

@ -139,7 +139,7 @@ bool Foam::functionObjects::age::execute()
IOobject IOobject
( (
typeName, typeName,
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE, IOobject::AUTO_WRITE,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -321,7 +321,7 @@ bool Foam::functionObjects::comfort::execute()
IOobject IOobject
( (
"hc", "hc",
mesh_.time().name(), time_.name(),
mesh_ mesh_
), ),
mesh_, mesh_,
@ -441,7 +441,7 @@ bool Foam::functionObjects::comfort::execute()
IOobject IOobject
( (
"TI", "TI",
mesh_.time().name(), time_.name(),
mesh_ mesh_
), ),
mesh_, mesh_,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -86,7 +86,7 @@ void Foam::functionObjects::fieldAverage::initialise()
void Foam::functionObjects::fieldAverage::restart() void Foam::functionObjects::fieldAverage::restart()
{ {
Log << " Restarting averaging at time " << obr_.time().name() << nl; Log << " Restarting averaging at time " << time_.name() << nl;
// Clear the times // Clear the times
totalIter_ = 0; totalIter_ = 0;
@ -124,8 +124,8 @@ void Foam::functionObjects::fieldAverage::calcAverages()
{ {
Log << type() << " " << name() << ":" << nl; Log << type() << " " << name() << ":" << nl;
const label currentTimeIndex = obr_.time().timeIndex(); const label currentTimeIndex = time_.timeIndex();
const scalar currentTime = obr_.time().value(); const scalar currentTime = time_.value();
if (prevTimeIndex_ == currentTimeIndex) if (prevTimeIndex_ == currentTimeIndex)
{ {
@ -148,7 +148,7 @@ void Foam::functionObjects::fieldAverage::calcAverages()
forAll(faItems_, fieldi) forAll(faItems_, fieldi)
{ {
totalIter_[fieldi]++; totalIter_[fieldi]++;
totalTime_[fieldi] += obr_.time().deltaTValue(); totalTime_[fieldi] += time_.deltaTValue();
} }
Log << " Calculating averages" << nl; Log << " Calculating averages" << nl;
@ -185,7 +185,7 @@ void Foam::functionObjects::fieldAverage::writeAverages() const
IOobject IOobject
( (
name() + "Properties", name() + "Properties",
obr_.time().name(), time_.name(),
"uniform", "uniform",
obr_, obr_,
IOobject::NO_READ, IOobject::NO_READ,
@ -250,7 +250,7 @@ void Foam::functionObjects::fieldAverage::read
typeIOobject<timeIOdictionary> propsDictHeader typeIOobject<timeIOdictionary> propsDictHeader
( (
name() + "Properties", name() + "Properties",
obr_.time().name(), time_.name(),
"uniform", "uniform",
obr_, obr_,
IOobject::MUST_READ_IF_MODIFIED, IOobject::MUST_READ_IF_MODIFIED,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,7 +38,7 @@ void Foam::functionObjects::fieldAverage::readMeanFieldType(const label fieldi)
IOobject meanFieldIo IOobject meanFieldIo
( (
meanFieldName, meanFieldName,
obr_.time().name(), time_.name(),
obr_, obr_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -114,7 +114,7 @@ void Foam::functionObjects::fieldAverage::initialiseMeanFieldType
IOobject IOobject
( (
meanFieldName, meanFieldName,
obr_.time().name(), time_.name(),
obr_ obr_
), ),
1*baseField 1*baseField
@ -161,7 +161,7 @@ void Foam::functionObjects::fieldAverage::readPrime2MeanFieldType
IOobject prime2MeanFieldIo IOobject prime2MeanFieldIo
( (
prime2MeanFieldName, prime2MeanFieldName,
obr_.time().name(), time_.name(),
obr_, obr_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -253,7 +253,7 @@ void Foam::functionObjects::fieldAverage::initialisePrime2MeanFieldType
IOobject IOobject
( (
prime2MeanFieldName, prime2MeanFieldName,
obr_.time().name(), time_.name(),
obr_ obr_
), ),
sqr(baseField) - sqr(meanField) sqr(baseField) - sqr(meanField)
@ -313,7 +313,7 @@ void Foam::functionObjects::fieldAverage::calculateMeanFieldType
Type& meanField = Type& meanField =
obr_.lookupObjectRef<Type>(faItems_[fieldi].meanFieldName()); obr_.lookupObjectRef<Type>(faItems_[fieldi].meanFieldName());
scalar dt = obr_.time().deltaTValue(); scalar dt = time_.deltaTValue();
scalar Dt = totalTime_[fieldi]; scalar Dt = totalTime_[fieldi];
if (iterBase()) if (iterBase())
@ -379,7 +379,7 @@ void Foam::functionObjects::fieldAverage::calculatePrime2MeanFieldType
Type2& prime2MeanField = Type2& prime2MeanField =
obr_.lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName()); obr_.lookupObjectRef<Type2>(faItems_[fieldi].prime2MeanFieldName());
scalar dt = obr_.time().deltaTValue(); scalar dt = time_.deltaTValue();
scalar Dt = totalTime_[fieldi]; scalar Dt = totalTime_[fieldi];
if (iterBase()) if (iterBase())

View File

@ -67,7 +67,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::faceSign() const
inline Foam::fileName inline Foam::fileName
Foam::functionObjects::fieldValues::surfaceFieldValue::outputDir() const Foam::functionObjects::fieldValues::surfaceFieldValue::outputDir() const
{ {
return baseFileDir()/name()/"surface"/obr_.time().name(); return baseFileDir()/name()/"surface"/time_.name();
} }

View File

@ -264,7 +264,7 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
( (
fieldName + '_' + selectionTypeNames[selectionType()] fieldName + '_' + selectionTypeNames[selectionType()]
+ '-' + cellSetName(), + '-' + cellSetName(),
obr_.time().name(), time_.name(),
obr_, obr_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -71,7 +71,11 @@ bool Foam::functionObjects::histogram::read(const dictionary& dict)
min_ = dict.lookupOrDefault<scalar>("min", 0); min_ = dict.lookupOrDefault<scalar>("min", 0);
dict.lookup("nBins") >> nBins_; dict.lookup("nBins") >> nBins_;
formatterPtr_ = setWriter::New(dict.lookup("setFormat"), dict); formatterPtr_ = setWriter::New
(
dict.lookupOrDefault("setFormat", time_.graphFormat()),
dict
);
return true; return true;
} }
@ -108,7 +112,7 @@ bool Foam::functionObjects::histogram::write()
IOobject IOobject
( (
fieldName_, fieldName_,
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -245,7 +245,11 @@ bool Foam::functionObjects::layerAverage::read(const dictionary& dict)
fields_ = dict.lookup<wordList>("fields"); fields_ = dict.lookup<wordList>("fields");
formatter_ = setWriter::New(dict.lookup("setFormat"), dict); formatter_ = setWriter::New
(
dict.lookupOrDefault("setFormat", time_.graphFormat()),
dict
);
calcLayers(); calcLayers();
@ -316,11 +320,11 @@ bool Foam::functionObjects::layerAverage::write()
{ {
// Make output directory // Make output directory
const fileName outputPath = const fileName outputPath =
mesh_.time().globalPath() time_.globalPath()
/writeFile::outputPrefix /writeFile::outputPrefix
/(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word()) /(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word())
/name() /name()
/mesh_.time().name(); /time_.name();
mkDir(outputPath); mkDir(outputPath);
scalarField layerDistance(layerCentre_.size(), 0); scalarField layerDistance(layerCentre_.size(), 0);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -102,8 +102,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
// Dump particles // Dump particles
OBJstream str OBJstream str
( (
mesh_.time().path() time_.path()
/"wantedTracks_" + mesh_.time().name() + ".obj" /"wantedTracks_" + time_.name() + ".obj"
); );
InfoInFunction << "Dumping tracks to " << str.name() << endl; InfoInFunction << "Dumping tracks to " << str.name() << endl;
@ -161,8 +161,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
{ {
OBJstream str OBJstream str
( (
mesh_.time().path() time_.path()
/"obtainedTracks_" + mesh_.time().name() + ".obj" /"obtainedTracks_" + time_.name() + ".obj"
); );
InfoInFunction << "Dumping obtained to " << str.name() << endl; InfoInFunction << "Dumping obtained to " << str.name() << endl;

View File

@ -607,11 +607,11 @@ void Foam::functionObjects::patchCutLayerAverage::initialise()
Foam::fileName Foam::functionObjects::patchCutLayerAverage::outputPath() const Foam::fileName Foam::functionObjects::patchCutLayerAverage::outputPath() const
{ {
return return
mesh_.time().globalPath() time_.globalPath()
/writeFile::outputPrefix /writeFile::outputPrefix
/(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word()) /(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word())
/name() /name()
/mesh_.time().name(); /time_.name();
} }
@ -658,7 +658,11 @@ bool Foam::functionObjects::patchCutLayerAverage::read(const dictionary& dict)
) )
]; ];
formatter_ = setWriter::New(dict.lookup("setFormat"), dict); formatter_ = setWriter::New
(
dict.lookupOrDefault("setFormat", time_.graphFormat()),
dict
);
nOptimiseIter_ = dict.lookupOrDefault("nOptimiseIter", 2); nOptimiseIter_ = dict.lookupOrDefault("nOptimiseIter", 2);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,7 +55,7 @@ void Foam::functionObjects::readFields::loadField
IOobject fieldHeader IOobject fieldHeader
( (
fieldName, fieldName,
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -89,7 +89,7 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
IOobject IOobject
( (
alphaName_ + "_liquidCore", alphaName_ + "_liquidCore",
obr_.time().name(), time_.name(),
obr_, obr_,
IOobject::NO_READ IOobject::NO_READ
), ),
@ -102,7 +102,7 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
IOobject IOobject
( (
alphaName_ + "_background", alphaName_ + "_background",
obr_.time().name(), time_.name(),
obr_, obr_,
IOobject::NO_READ IOobject::NO_READ
), ),
@ -371,7 +371,11 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
dict.lookup("nBins") >> nBins_; dict.lookup("nBins") >> nBins_;
dict.lookup("fields") >> fields_; dict.lookup("fields") >> fields_;
formatterPtr_ = setWriter::New(dict.lookup("setFormat"), dict); formatterPtr_ = setWriter::New
(
dict.lookupOrDefault("setFormat", time_.graphFormat()),
dict
);
return true; return true;
} }
@ -410,7 +414,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
IOobject IOobject
( (
alphaName_, alphaName_,
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -505,7 +509,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
IOobject IOobject
( (
"region", "region",
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -181,7 +181,11 @@ bool Foam::functionObjects::streamlines::read(const dictionary& dict)
dict.subDict("seedSampleSet") dict.subDict("seedSampleSet")
); );
formatterPtr_ = setWriter::New(dict.lookup("setFormat"), dict); formatterPtr_ = setWriter::New
(
dict.lookupOrDefault("setFormat", time_.graphFormat()),
dict
);
return true; return true;
} }
@ -534,11 +538,11 @@ bool Foam::functionObjects::streamlines::write()
{ {
// Make output directory // Make output directory
const fileName outputPath = const fileName outputPath =
mesh_.time().globalPath() time_.globalPath()
/writeFile::outputPrefix /writeFile::outputPrefix
/(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word()) /(mesh_.name() != polyMesh::defaultRegion ? mesh_.name() : word())
/name() /name()
/mesh_.time().name(); /time_.name();
mkDir(outputPath); mkDir(outputPath);
// Pass data to the formatter to write // Pass data to the formatter to write

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -59,7 +59,7 @@ void Foam::functionObjects::turbulenceFields::processField
IOobject IOobject
( (
scopedName, scopedName,
obr_.time().name(), time_.name(),
obr_, obr_,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -261,7 +261,7 @@ bool Foam::functionObjects::wallHeatFlux::write()
if (Pstream::master()) if (Pstream::master())
{ {
file() file()
<< mesh_.time().userTimeValue() << time_.userTimeValue()
<< tab << pp.name() << tab << pp.name()
<< tab << minqp << tab << minqp
<< tab << maxqp << tab << maxqp

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -221,7 +221,7 @@ bool Foam::functionObjects::wallHeatTransferCoeff::write()
if (Pstream::master()) if (Pstream::master())
{ {
file() file()
<< mesh_.time().userTimeValue() << time_.userTimeValue()
<< tab << pp.name() << tab << pp.name()
<< tab << minHtcp << tab << minHtcp
<< tab << maxHtcp << tab << maxHtcp

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -243,7 +243,7 @@ bool Foam::functionObjects::wallShearStress::write()
if (Pstream::master()) if (Pstream::master())
{ {
file() << mesh_.time().userTimeValue() file() << time_.userTimeValue()
<< tab << pp.name() << tab << pp.name()
<< tab << minSsp << tab << minSsp
<< tab << maxSsp << tab << maxSsp

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -91,7 +91,7 @@ Foam::volScalarField& Foam::functionObjects::phaseScalarTransport::Phi()
IOobject IOobject
( (
"Phi" + s_.name(), "Phi" + s_.name(),
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
@ -164,7 +164,7 @@ Foam::functionObjects::phaseScalarTransport::alphaPhi()
Info<< type() << ": Writing " << DDtAlpha.name() << endl; Info<< type() << ": Writing " << DDtAlpha.name() << endl;
DDtAlpha.write(); DDtAlpha.write();
}; };
if (debug && mesh_.time().writeTime()) if (debug && time_.writeTime())
{ {
writeDDt(0); writeDDt(0);
} }
@ -224,7 +224,7 @@ Foam::functionObjects::phaseScalarTransport::alphaPhi()
} }
// Debug writing // Debug writing
if (debug && mesh_.time().writeTime()) if (debug && time_.writeTime())
{ {
writeDDt(1); writeDDt(1);
} }
@ -295,7 +295,7 @@ Foam::functionObjects::phaseScalarTransport::phaseScalarTransport
IOobject IOobject
( (
fieldName_, fieldName_,
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
@ -477,7 +477,7 @@ bool Foam::functionObjects::phaseScalarTransport::execute()
"alpha" "alpha"
+ word(toupper(fieldName_[0])) + word(toupper(fieldName_[0]))
+ fieldName_(1, fieldName_.size() - 1), + fieldName_(1, fieldName_.size() - 1),
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE

View File

@ -127,7 +127,7 @@ Foam::functionObjects::scalarTransport::scalarTransport
IOobject IOobject
( (
fieldName_, fieldName_,
mesh_.time().name(), time_.name(),
mesh_, mesh_,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
@ -464,7 +464,7 @@ void Foam::functionObjects::scalarTransport::solveMULES()
if if
( (
sRestart_ sRestart_
|| mesh_.time().timeIndex() > mesh_.time().startTimeIndex() + 1 || time_.timeIndex() > time_.startTimeIndex() + 1
) )
{ {
ocCoeff = ocCoeff =

View File

@ -119,9 +119,8 @@ Foam::codedFunctionObject::codedFunctionObject
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, time),
codedBase(name, dict), codedBase(name, dict)
time_(time)
{ {
read(dict); read(dict);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -90,9 +90,6 @@ class codedFunctionObject
{ {
// Private Data // Private Data
//- Reference to the time database
const Time& time_;
//- The dynamically generated functionObject pointer //- The dynamically generated functionObject pointer
mutable autoPtr<functionObject> redirectFunctionObjectPtr_; mutable autoPtr<functionObject> redirectFunctionObjectPtr_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,7 +55,7 @@ Foam::functionObjects::removeRegisteredObject::removeRegisteredObject
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, runTime),
obr_ obr_
( (
runTime.lookupObject<objectRegistry> runTime.lookupObject<objectRegistry>

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -53,8 +53,7 @@ Foam::functionObjects::setTimeStepFunctionObject::setTimeStepFunctionObject
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, runTime)
time_(runTime)
{ {
read(dict); read(dict);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -70,9 +70,6 @@ class setTimeStepFunctionObject
{ {
// Private Data // Private Data
//- Reference to the time database
const Time& time_;
//- Time step function/table //- Time step function/table
autoPtr<Function1<scalar>> timeStepPtr_; autoPtr<Function1<scalar>> timeStepPtr_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -54,8 +54,7 @@ setWriteIntervalFunctionObject
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, runTime)
time_(runTime)
{ {
read(dict); read(dict);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -81,9 +81,6 @@ class setWriteIntervalFunctionObject
{ {
// Private Data // Private Data
//- Reference to the time database
const Time& time_;
//- Time step function/table //- Time step function/table
autoPtr<Function1<scalar>> writeIntervalPtr_; autoPtr<Function1<scalar>> writeIntervalPtr_;

View File

@ -65,8 +65,7 @@ Foam::functionObjects::stopAt::stopAt
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, runTime),
time_(runTime),
action_(actionType::nextWrite), action_(actionType::nextWrite),
stopped_(false) stopped_(false)
{} {}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -73,9 +73,6 @@ protected:
// Protected data // Protected data
//- Reference to the Time
const Time& time_;
//- Action type names //- Action type names
static const NamedEnum<actionType, 3> actionTypeNames_; static const NamedEnum<actionType, 3> actionTypeNames_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -52,11 +52,11 @@ namespace functionObjects
Foam::functionObjects::systemCall::systemCall Foam::functionObjects::systemCall::systemCall
( (
const word& name, const word& name,
const Time&, const Time& time,
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, time),
executeCalls_(), executeCalls_(),
endCalls_(), endCalls_(),
writeCalls_() writeCalls_()

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -82,8 +82,7 @@ Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, runTime),
time_(runTime),
fileToUpdate_(dict.lookup("fileToUpdate")), fileToUpdate_(dict.lookup("fileToUpdate")),
fileVsTime_(), fileVsTime_(),
lastIndex_(-1) lastIndex_(-1)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -82,9 +82,6 @@ class timeActivatedFileUpdate
{ {
// Private Data // Private Data
//- Reference to Time
const Time& time_;
//- Name of file to update //- Name of file to update
fileName fileToUpdate_; fileName fileToUpdate_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -107,7 +107,7 @@ bool Foam::functionObjects::timeStep::write()
{ {
writeTime(file()); writeTime(file());
file() << tab << obr_.time().deltaTValue(); file() << tab << time_.deltaTValue();
file() << endl; file() << endl;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -104,7 +104,7 @@ Foam::functionObjects::writeDictionary::writeDictionary
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, runTime),
obr_ obr_
( (
runTime.lookupObject<objectRegistry> runTime.lookupObject<objectRegistry>
@ -190,16 +190,16 @@ bool Foam::functionObjects::writeDictionary::write()
} }
else else
{ {
bool processed = tryDirectory(i, obr_.time().name(), firstDict); bool processed = tryDirectory(i, time_.name(), firstDict);
if (!processed) if (!processed)
{ {
processed = tryDirectory(i, obr_.time().constant(), firstDict); processed = tryDirectory(i, time_.constant(), firstDict);
} }
if (!processed) if (!processed)
{ {
processed = tryDirectory(i, obr_.time().system(), firstDict); processed = tryDirectory(i, time_.system(), firstDict);
} }
if (!processed) if (!processed)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -108,7 +108,7 @@ void Foam::functionObjects::writeObjects::writeObject
if if
( (
obj.writeOpt() == IOobject::AUTO_WRITE obj.writeOpt() == IOobject::AUTO_WRITE
&& writeObr_.time().writeTime() && time_.writeTime()
) )
{ {
Log << " automatically written object " << obj.name() << endl; Log << " automatically written object " << obj.name() << endl;
@ -141,7 +141,7 @@ Foam::functionObjects::writeObjects::writeObjects
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, runTime),
writeObjectsBase writeObjectsBase
( (
runTime.lookupObject<objectRegistry> runTime.lookupObject<objectRegistry>

View File

@ -108,8 +108,18 @@ Foam::SizeDistribution<CloudType>::SizeDistribution
: :
CloudFunctionObject<CloudType>(dict, owner, modelName, typeName), CloudFunctionObject<CloudType>(dict, owner, modelName, typeName),
nPoints_(dict.lookup<label>("nPoints")), nPoints_(dict.lookup<label>("nPoints")),
formatter_(setWriter::New(dict.lookup("setFormat"), dict)) formatter_
(
setWriter::New
(
dict.lookupOrDefault
(
"setFormat",
owner.mesh().time().graphFormat()
),
dict
)
)
{} {}

View File

@ -1,34 +1,14 @@
Kmesh = Kmesh Kmesh/Kmesh.C
fft = fft fft/fft.C
fft/fftRenumber.C
fft/writeEk.C
fft/kShellIntegration.C
processes = processes processes/UOprocess/UOprocess.C
UOprocess = $(processes)/UOprocess
turbulence = turbulence turbulence/turbGen.C
noise = noise noise/noiseFFT.C
$(Kmesh)/Kmesh.C
$(fft)/fft.C
$(fft)/fftRenumber.C
$(fft)/calcEk.C
$(fft)/kShellIntegration.C
$(UOprocess)/UOprocess.C
$(turbulence)/turbGen.C
$(noise)/noiseFFT.C
graph/curve/curve.C
graph/graph.C
writers = graph/writers
$(writers)/rawGraph/rawGraph.C
$(writers)/gnuplotGraph/gnuplotGraph.C
$(writers)/xmgrGraph/xmgrGraph.C
$(writers)/jplotGraph/jplotGraph.C
LIB = $(FOAM_LIBBIN)/librandomProcesses LIB = $(FOAM_LIBBIN)/librandomProcesses

View File

@ -1,5 +1,7 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \ LIB_LIBS = \
-lfiniteVolume -lfiniteVolume \
-lsampling

View File

@ -1,48 +0,0 @@
/*======================================================================*/
// This routine evaluates q(k) (McComb, p61) by summing all wavevectors
// in a k-shell. Then we divide through by the volume of the box
// - to be accurate, by the volume of the ellipsoid enclosing the
// box (assume cells even in each direction). Finally, multiply the
// q(k) values by k^2 to give the full power spectrum E(k). Integrating
// this over the whole range gives the energy in turbulence.
/*======================================================================*/
#include "calcEk.H"
#include "fft.H"
#include "Kmesh.H"
#include "kShellIntegration.H"
#include "volFields.H"
#include "graph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
graph calcEk
(
const volVectorField& U,
const Kmesh& K
)
{
return kShellIntegration
(
fft::forwardTransform
(
ReComplexField(U.primitiveField()),
K.nn()
),
K
);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,25 +0,0 @@
#ifndef calcEk_H
#define calcEk_H
#include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class graph;
class Kmesh;
graph calcEk
(
const volVectorField& U,
const Kmesh& K
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
#endif

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::graph Foam::kShellIntegration Foam::Pair<Foam::scalarField> Foam::kShellIntegration
( (
const complexVectorField& Ek, const complexVectorField& Ek,
const Kmesh& K const Kmesh& K
@ -37,9 +37,9 @@ Foam::graph Foam::kShellIntegration
// evaluate the radial component of the spectra as an average // evaluate the radial component of the spectra as an average
// over the shells of thickness dk // over the shells of thickness dk
graph kShellMeanEk = kShellMean(Ek, K); Pair<scalarField> kShellMeanEk(kShellMean(Ek, K));
const scalarField& x = kShellMeanEk.x(); const scalarField& x = kShellMeanEk.first();
scalarField& y = *kShellMeanEk.begin()(); scalarField& y = kShellMeanEk.second();
// now multiply by 4pi k^2 (the volume of each shell) to get the // now multiply by 4pi k^2 (the volume of each shell) to get the
// spectra E(k). int E(k) dk is now the total energy in a box // spectra E(k). int E(k) dk is now the total energy in a box
@ -66,7 +66,7 @@ Foam::graph Foam::kShellIntegration
// kShellMean : average over the points in a k-shell to evaluate the // kShellMean : average over the points in a k-shell to evaluate the
// radial part of the energy spectrum. // radial part of the energy spectrum.
Foam::graph Foam::kShellMean Foam::Pair<Foam::scalarField> Foam::kShellMean
( (
const complexVectorField& Ek, const complexVectorField& Ek,
const Kmesh& K const Kmesh& K
@ -130,7 +130,7 @@ Foam::graph Foam::kShellMean
} }
} }
return graph("E(k)", "k", "E(k)", k1D, Ek1D); return Pair<scalarField>(k1D, Ek1D);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -38,7 +38,7 @@ SourceFiles
#include "complexFields.H" #include "complexFields.H"
#include "Kmesh.H" #include "Kmesh.H"
#include "graph.H" #include "Pair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,14 +47,14 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
graph kShellIntegration Pair<scalarField> kShellIntegration
( (
const complexVectorField& Ek, const complexVectorField& Ek,
const Kmesh& K const Kmesh& K
); );
graph kShellMean Pair<scalarField> kShellMean
( (
const complexVectorField& Ek, const complexVectorField& Ek,
const Kmesh& K const Kmesh& K

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -21,81 +21,62 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::jplotGraph
Description
jplot graph output
SourceFiles
jplotGraph.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef jplotGraph_H #include "writeEk.H"
#define jplotGraph_H #include "fft.H"
#include "kShellIntegration.H"
#include "graph.H" #include "volFields.H"
#include "setWriter.H"
#include "writeFile.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
/*---------------------------------------------------------------------------*\ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Class jplotGraph Declaration
\*---------------------------------------------------------------------------*/
class jplotGraph void writeEk
: (
public graph::writer const volVectorField& U,
const Kmesh& K
)
{ {
const Pair<scalarField> Ek
(
kShellIntegration
(
fft::forwardTransform
(
ReComplexField(U.primitiveField()),
K.nn()
),
K
)
);
public: autoPtr<setWriter> writer
(
setWriter::New(U.time().graphFormat())
);
//- Runtime type information writer->write
TypeName("jplot"); (
U.time().path()
//- FileName extension for this graph format /functionObjects::writeFile::outputPrefix
static const word ext_; /"graphs"
/U.time().name(),
"Ek",
// Constructors coordSet(true,"k", Ek.first()),
"E(k)",
//- Construct null Ek.second()
jplotGraph() );
{}
//- Destructor
~jplotGraph()
{}
// Member Functions
// Access
//- Return the appropriate fileName extension
// for this graph format
const word& ext() const
{
return ext_;
} }
// Write
void write(const graph&, Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -21,73 +21,36 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Application
Foam::rawGraph writeEk
Description Description
A raw xy graph output This function evaluates q(k) (McComb, p61) by summing all wavevectors
in a k-shell. Then we divide through by the volume of the box
SourceFiles - to be accurate, by the volume of the ellipsoid enclosing the
rawGraph.C box (assume cells even in each direction). Finally, multiply the
q(k) values by k^2 to give the full power spectrum E(k). Integrating
this over the whole range gives the energy in turbulence.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef rawGraph_H #ifndef writeEk_H
#define rawGraph_H #define writeEk_H
#include "graph.H" #include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
/*---------------------------------------------------------------------------*\ class Kmesh;
Class rawGraph Declaration
\*---------------------------------------------------------------------------*/
class rawGraph void writeEk
: (
public graph::writer const volVectorField& U,
{ const Kmesh& K
);
public:
//- Runtime type information
TypeName("raw");
//- FileName extension for this graph format
static const word ext_;
// Constructors
//- Construct null
rawGraph()
{}
//- Destructor
~rawGraph()
{}
// Member Functions
// Access
//- Return the appropriate fileName extension
// for this graph format
const word& ext() const
{
return ext_;
}
// Write
void write(const graph&, Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,72 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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 "curve.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::curve::curve
(
const string& name,
const curveStyle& style,
const label l
)
:
scalarField(l, 0.0),
name_(name),
style_(style)
{}
Foam::curve::curve
(
const string& name,
const curveStyle& style,
const scalarField& y
)
:
scalarField(y),
name_(name),
style_(style)
{}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const curve& c)
{
os << nl
<< c.name_ << nl
<< c.style_ << nl
<< static_cast<const scalarField&>(c);
os.check("Ostream& operator>>(Ostream&, const curve&)");
return os;
}
// ************************************************************************* //

View File

@ -1,188 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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::curve
Description
A single curve in a graph.
SourceFiles
curve.C
\*---------------------------------------------------------------------------*/
#ifndef curve_H
#define curve_H
#include "string.H"
#include "primitiveFields.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class curve;
Ostream& operator<<(Ostream&, const curve&);
/*---------------------------------------------------------------------------*\
Class curve Declaration
\*---------------------------------------------------------------------------*/
class curve
:
public scalarField
{
public:
//- The style (line, symbol, etc) of a curve
class curveStyle
{
public:
//- Enumeration definitions
enum curveStyleNo
{
CONTINUOUS,
SYMBOL,
SYMBOL_CURVE,
SYMBOL_WITH_ERROR_BARS,
SYMBOL_WITH_VARIABLE_SIZE
};
private:
// Private Data
curveStyleNo CurveStyleNo;
public:
// Constructors
//- Construct given a curveStyleNo
curveStyle(const curveStyleNo csn)
:
CurveStyleNo(csn)
{}
//- Construct from Istream
curveStyle(Istream& is)
:
CurveStyleNo(curveStyleNo(readInt(is)))
{}
// Ostream operator
friend Ostream& operator<<(Ostream& os, const curveStyle& cs)
{
os << int(cs.CurveStyleNo);
return os;
}
};
private:
// Private Data
string name_;
curveStyle style_;
public:
// Constructors
//- Construct as interpolation of an existing curve
// curve(const curve&, const label);
//- Construct from name, style and size
curve
(
const string& name,
const curveStyle& style,
const label l
);
//- Construct from the components
curve
(
const string&,
const curveStyle&,
const scalarField& y
);
autoPtr<curve> clone() const
{
return autoPtr<curve>(new curve(*this));
}
// Member Functions
// Access
const string& name() const
{
return name_;
}
const curveStyle& style() const
{
return style_;
}
// Friend Functions
//- Gradient of the curve
// friend curve grad(const curve&);
// Ostream operator
friend Ostream& operator<<(Ostream&, const curve&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,182 +0,0 @@
#include "scalar.H"
#include "vector.H"
#include "curveTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scalar distance(const vector& p1, const vector& p2)
{
return mag(p2 - p1);
}
bool stepForwardsToNextPoint
(
const vector& o,
vector& n,
label& i,
label& ip1,
scalar l,
const curve& Curve
)
{
label ip1n = ip1-1;
while (++ip1n < Curve.size() && distance(o, Curve[ip1n]) < l);
label in = ip1n - 1;
bool eoc = true;
if (ip1n < Curve.size() && in >= 0)
{
eoc = interpolate(Curve[in], Curve[ip1n], o, n, l);
i = in;
ip1 = ip1n;
}
return eoc;
}
bool stepBackwardsToNextPoint
(
const vector& o,
vector& n,
label& i,
label& ip1,
scalar l,
const curve& Curve
)
{
label ip1n = ip1+1;
while (--ip1n >= 0 && distance(o, Curve[ip1n]) < l);
label in = ip1n + 1;
bool eoc = true;
if (ip1n >= 0 && in < Curve.size())
{
eoc = interpolate(Curve[in], Curve[ip1n], o, n, l);
i = in;
ip1 = ip1n;
}
return eoc;
}
bool interpolate
(
const vector& p1,
const vector& p2,
const vector& o,
vector& n,
scalar l
)
{
vector D = p1 - p2;
scalar a = magSqr(D);
scalar b = 2.0*(D&(p2 - o));
scalar c = magSqr(p2) + (o&(o - 2.0*p2)) - l*l;
scalar b2m4ac = b*b - 4.0*a*c;
if (b2m4ac >= 0.0)
{
scalar srb2m4ac = sqrt(b2m4ac);
scalar lambda = (-b - srb2m4ac)/(2.0*a);
if (lambda > 1.0+curveSmall || lambda < -curveSmall)
{
lambda = (-b + srb2m4ac)/(2.0*a);
}
if (lambda < 1.0+curveSmall && lambda > -curveSmall)
{
n = p2 + lambda*(p1 - p2);
return false;
}
else
{
return true;
}
}
else
{
return true;
}
}
bool XstepForwardsToNextPoint
(
const vector& o,
vector& n,
label& i,
label& ip1,
scalar l,
const curve& Curve
)
{
label ip1n = ip1-1;
while (++ip1n < Curve.size() && mag(o.x() - Curve[ip1n].x()) < l);
label in = ip1n - 1;
bool eoc = true;
if (ip1n < Curve.size() && in >= 0)
{
eoc = Xinterpolate(Curve[in], Curve[ip1n], o, n, l);
i = in;
ip1 = ip1n;
}
return eoc;
}
bool Xinterpolate
(
const vector& p1,
const vector& p2,
const vector& o,
vector& n,
scalar l
)
{
n.x() = o.x() + l;
if (p2.x() < o.x() + l - curveSmall && p2.x() > o.x() - l + curveSmall)
{
return true;
}
if (p2.x() < o.x() + l)
{
n.x() = o.x() - l;
}
vector D = p2 - p1;
scalar lambda = (n.x() - p1.x())/D.x();
n.y() = p1.y() + lambda*D.y();
return false;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,82 +0,0 @@
#ifndef curveTools_H
#define curveTools_H
#include "scalar.H"
#include "vector.H"
#include "curve.H"
#include "char.H"
#include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
#define curveSmall 1.0e-8
#define curveGreat 1.0e8
typedef List<char> charList;
typedef List<charList> charListList;
scalar distance(const vector&, const vector&);
bool stepForwardsToNextPoint
(
const vector&,
vector&,
label&,
label&,
scalar,
const curve&
);
bool stepBackwardsToNextPoint
(
const vector&,
vector&,
label&,
label&,
scalar,
const curve&
);
bool interpolate
(
const vector&,
const vector&,
const vector&,
vector&,
scalar
);
bool XstepForwardsToNextPoint
(
const vector&,
vector&,
label&,
label&,
scalar,
const curve&
);
bool Xinterpolate
(
const vector&,
const vector&,
const vector&,
vector&,
scalar
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
#endif

View File

@ -1,266 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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 "graph.H"
#include "OFstream.H"
#include "IOmanip.H"
#include "Pair.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
typedef graph::writer graphWriter;
defineTypeNameAndDebug(graphWriter, 0);
defineRunTimeSelectionTable(graphWriter, word);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::word Foam::graph::wordify(const Foam::string& sname)
{
string wname = sname;
wname.replace(' ', '_');
wname.replace('(', '_');
wname.replace(')', "");
return word(wname);
}
void Foam::graph::readCurves(Istream& is)
{
List<xy> xyData(is);
x_.setSize(xyData.size());
scalarField y(xyData.size());
forAll(xyData, i)
{
x_[i] = xyData[i].x_;
y[i] = xyData[i].y_;
}
insert
(
wordify(yName_),
new curve(wordify(yName_), curve::curveStyle::CONTINUOUS, y)
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::graph::graph
(
const string& title,
const string& xName,
const string& yName,
const scalarField& x
)
:
title_(title),
xName_(xName),
yName_(yName),
x_(x)
{}
Foam::graph::graph
(
const string& title,
const string& xName,
const string& yName,
const scalarField& x,
const scalarField& y
)
:
title_(title),
xName_(xName),
yName_(yName),
x_(x)
{
insert(wordify(yName), new curve(yName, curve::curveStyle::CONTINUOUS, y));
}
Foam::graph::graph
(
const string& title,
const string& xName,
const string& yName,
Istream& is
)
:
title_(title),
xName_(xName),
yName_(yName)
{
readCurves(is);
}
Foam::graph::graph(Istream& is)
:
title_(is),
xName_(is),
yName_(is)
{
readCurves(is);
}
const Foam::scalarField& Foam::graph::y() const
{
if (size() != 1)
{
FatalErrorInFunction
<< "y field requested for graph containing " << size()
<< "ys" << exit(FatalError);
}
return *begin()();
}
Foam::scalarField& Foam::graph::y()
{
if (size() != 1)
{
FatalErrorInFunction
<< "y field requested for graph containing " << size()
<< "ys" << exit(FatalError);
}
return *begin()();
}
Foam::autoPtr<Foam::graph::writer> Foam::graph::writer::New
(
const word& graphFormat
)
{
if (!wordConstructorTablePtr_)
{
FatalErrorInFunction
<< "Graph writer table is empty"
<< exit(FatalError);
}
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(graphFormat);
if (cstrIter == wordConstructorTablePtr_->end())
{
FatalErrorInFunction
<< "Unknown graph format " << graphFormat
<< endl << endl
<< "Valid graph formats are : " << endl
<< wordConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<graph::writer>(cstrIter()());
}
void Foam::graph::writer::writeXY
(
const scalarField& x,
const scalarField& y,
Ostream& os
) const
{
forAll(x, xi)
{
os << setw(10) << x[xi] << token::SPACE << setw(10) << y[xi]<< endl;
}
}
void Foam::graph::writeTable(Ostream& os) const
{
forAll(x_, xi)
{
os << setw(10) << x_[xi];
forAllConstIter(graph, *this, iter)
{
os << token::SPACE << setw(10) << (*iter())[xi];
}
os << endl;
}
}
void Foam::graph::write(Ostream& os, const word& format) const
{
writer::New(format)().write(*this, os);
}
void Foam::graph::write(const fileName& pName, const word& format) const
{
autoPtr<writer> graphWriter(writer::New(format));
OFstream graphFile(pName + '.' + graphWriter().ext());
if (graphFile.good())
{
write(graphFile, format);
}
else
{
WarningInFunction
<< "Could not open graph file " << graphFile.name()
<< endl;
}
}
void Foam::graph::write
(
const fileName& path,
const word& name,
const word& format
) const
{
mkDir(path);
write(path/name, format);
}
Foam::Ostream& Foam::operator<<(Ostream& os, const graph& g)
{
g.writeTable(os);
os.check("Ostream& operator<<(Ostream&, const graph&)");
return os;
}
// ************************************************************************* //

View File

@ -1,285 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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::graph
Description
Class to create, store and output qgraph files.
SourceFiles
graph.C
\*---------------------------------------------------------------------------*/
#ifndef graph_H
#define graph_H
#include "string.H"
#include "point.H"
#include "HashPtrTable.H"
#include "curve.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class graph;
Ostream& operator<<(Ostream&, const graph&);
/*---------------------------------------------------------------------------*\
Class graph Declaration
\*---------------------------------------------------------------------------*/
class graph
:
public HashPtrTable<curve>
{
// private data
string title_;
string xName_;
string yName_;
scalarField x_;
struct xy
{
scalar x_, y_;
xy()
{}
// Friend Operators
friend bool operator==(const xy& a, const xy& b)
{
return equal(a.x_, b.x_) && equal(a.y_, b.y_);
}
friend bool operator!=(const xy& a, const xy& b)
{
return !(a == b);
}
friend Istream& operator>>(Istream& is, xy& xyd)
{
is >> xyd.x_ >> xyd.y_;
return is;
}
friend Ostream& operator<<(Ostream& os, const xy& xyd)
{
os << xyd.x_ << ' ' << xyd.y_;
return os;
}
};
// Private Member Functions
void readCurves(Istream&);
public:
// Constructors
//- Construct from title and labels (no curves)
graph
(
const string& title,
const string& xName,
const string& yName,
const scalarField& x
);
//- Construct from title, labels and y data for 1 curve
graph
(
const string& title,
const string& xName,
const string& yName,
const scalarField& x,
const scalarField& y
);
//- Construct from Istream given title and labels
graph
(
const string& title,
const string& xName,
const string& yName,
Istream& is
);
//- Construct from Istream
graph(Istream& is);
// Member Functions
// Access
const string& title() const
{
return title_;
}
const string& xName() const
{
return xName_;
}
const string& yName() const
{
return yName_;
}
const scalarField& x() const
{
return x_;
}
scalarField& x()
{
return x_;
}
const scalarField& y() const;
scalarField& y();
// Write
//- Abstract base class for a graph writer
class writer
{
protected:
void writeXY
(
const scalarField& x,
const scalarField& y,
Ostream&
) const;
public:
//- Runtime type information
TypeName("writer");
//- Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
writer,
word,
(),
()
);
// Selectors
//- Return a reference to the selected writer
static autoPtr<writer> New
(
const word& writeFormat
);
// Constructors
//- Construct null
writer()
{}
//- Destructor
virtual ~writer()
{}
// Member Functions
// Access
//- Return the appropriate fileName extension
// for this graph format
virtual const word& ext() const = 0;
// Write
//- Write graph in appropriate format
virtual void write(const graph&, Ostream&) const = 0;
};
//- Write out graph data as a simple table
void writeTable(Ostream&) const;
//- Write graph to stream in given format
void write(Ostream&, const word& format) const;
//- Write graph to file in given path-name and format
void write(const fileName& pName, const word& format) const;
//- Write graph to file in given path, name and format
void write
(
const fileName& path,
const word& name,
const word& format
) const;
//- Helper function to convert string name into appropriate word
static word wordify(const string& sname);
// Friend operators
//- Ostream Operator
friend Ostream& operator<<(Ostream&, const graph&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,78 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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 "gnuplotGraph.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(gnuplotGraph, 0);
const word gnuplotGraph::ext_("gplt");
typedef graph::writer graphWriter;
addToRunTimeSelectionTable(graphWriter, gnuplotGraph, word);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::gnuplotGraph::write(const graph& g, Ostream& os) const
{
os << "set term postscript color" << nl
<< "set output \"" << word(g.title()) << ".ps\"" << nl
<< "set title " << g.title() << " offset 0,0" << nl
<< "show title" << nl
<< "set xlabel " << g.xName() << " offset 0,0" << nl
<< "show xlabel" << nl
<< "set ylabel " << g.yName() << " offset 0,0" << nl
<< "show ylabel" << nl
<< "plot";
bool firstField = true;
forAllConstIter(graph, g, iter)
{
if (!firstField)
{
os << ',';
}
firstField = false;
os << "'-' title " << iter()->name() << " with lines";
}
os << "; pause -1" << nl;
forAllConstIter(graph, g, iter)
{
os << nl;
writeXY(g.x(), *iter(), os);
}
}
// ************************************************************************* //

View File

@ -1,101 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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::gnuplotGraph
Description
Output in gnuplot (http://www.gnuplot.info) format
SourceFiles
gnuplotGraph.C
\*---------------------------------------------------------------------------*/
#ifndef gnuplotGraph_H
#define gnuplotGraph_H
#include "graph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class gnuplotGraph Declaration
\*---------------------------------------------------------------------------*/
class gnuplotGraph
:
public graph::writer
{
public:
//- Runtime type information
TypeName("gnuplot");
//- FileName extension for this graph format
static const word ext_;
// Constructors
//- Construct null
gnuplotGraph()
{}
//- Destructor
~gnuplotGraph()
{}
// Member Functions
// Access
//- Return the appropriate fileName extension
// for this graph format
const word& ext() const
{
return ext_;
}
// Write
void write(const graph&, Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,60 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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 "jplotGraph.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(jplotGraph, 0);
const word jplotGraph::ext_("dat");
typedef graph::writer graphWriter;
addToRunTimeSelectionTable(graphWriter, jplotGraph, word);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::jplotGraph::write(const graph& g, Ostream& os) const
{
os << "# JPlot file" << nl
<< "# column 1: " << g.xName() << endl;
label fieldi = 0;
forAllConstIter(graph, g, iter)
{
os << "# column " << fieldi + 2 << ": " << (*iter()).name() << endl;
fieldi++;
}
g.writeTable(os);
}
// ************************************************************************* //

View File

@ -1,49 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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 "rawGraph.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(rawGraph, 0);
const word rawGraph::ext_("xy");
typedef graph::writer graphWriter;
addToRunTimeSelectionTable(graphWriter, rawGraph, word);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rawGraph::write(const graph& g, Ostream& os) const
{
g.writeTable(os);
}
// ************************************************************************* //

View File

@ -1,67 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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 "xmgrGraph.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(xmgrGraph, 0);
const word xmgrGraph::ext_("agr");
typedef graph::writer graphWriter;
addToRunTimeSelectionTable(graphWriter, xmgrGraph, word);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::xmgrGraph::write(const graph& g, Ostream& os) const
{
os << "@title " << g.title() << nl
<< "@xaxis label " << g.xName() << nl
<< "@yaxis label " << g.yName() << endl;
label fieldi = 0;
forAllConstIter(graph, g, iter)
{
os << "@s" << fieldi << " legend "
<< iter()->name() << nl
<< "@target G0.S" << fieldi << nl
<< "@type xy" << endl;
writeXY(g.x(), *iter(), os);
os << endl;
fieldi++;
}
}
// ************************************************************************* //

View File

@ -1,102 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 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::xmgrGraph
Description
Output and \b agr file for \em xmgrace
(http://plasma-gate.weizmann.ac.il/Grace/)
SourceFiles
xmgrGraph.C
\*---------------------------------------------------------------------------*/
#ifndef xmgrGraph_H
#define xmgrGraph_H
#include "graph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class xmgrGraph Declaration
\*---------------------------------------------------------------------------*/
class xmgrGraph
:
public graph::writer
{
public:
//- Runtime type information
TypeName("xmgr");
//- FileName extension for this graph format
static const word ext_;
// Constructors
//- Construct null
xmgrGraph()
{}
//- Destructor
~xmgrGraph()
{}
// Member Functions
// Access
//- Return the appropriate fileName extension
// for this graph format
const word& ext() const
{
return ext_;
}
// Write
void write(const graph&, Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -102,7 +102,7 @@ Foam::noiseFFT::noiseFFT(const fileName& pFileName, const label skip)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::graph Foam::noiseFFT::pt() const Foam::Pair<Foam::scalarField> Foam::noiseFFT::pt() const
{ {
scalarField t(size()); scalarField t(size());
forAll(t, i) forAll(t, i)
@ -110,14 +110,7 @@ Foam::graph Foam::noiseFFT::pt() const
t[i] = i*deltat_; t[i] = i*deltat_;
} }
return graph return Pair<scalarField>(t, *this);
(
"p(t)",
"t [s]",
"p(t) [Pa]",
t,
*this
);
} }
@ -202,7 +195,7 @@ Foam::tmp<Foam::scalarField> Foam::noiseFFT::Pf
} }
Foam::graph Foam::noiseFFT::meanPf Foam::Pair<Foam::scalarField> Foam::noiseFFT::meanPf
( (
const label N, const label N,
const label nw const label nw
@ -237,18 +230,11 @@ Foam::graph Foam::noiseFFT::meanPf
f[i] = i*deltaf; f[i] = i*deltaf;
} }
return graph return Pair<scalarField>(f, MeanPf);
(
"P(f)",
"f [Hz]",
"P(f) [Pa]",
f,
MeanPf
);
} }
Foam::graph Foam::noiseFFT::RMSmeanPf Foam::Pair<Foam::scalarField> Foam::noiseFFT::RMSmeanPf
( (
const label N, const label N,
const label nw const label nw
@ -283,39 +269,28 @@ Foam::graph Foam::noiseFFT::RMSmeanPf
f[i] = i*deltaf; f[i] = i*deltaf;
} }
return graph return Pair<scalarField>(f, RMSMeanPf);
(
"P(f)",
"f [Hz]",
"P(f) [Pa]",
f,
RMSMeanPf
);
} }
Foam::graph Foam::noiseFFT::Lf(const graph& gPf) const Foam::Pair<Foam::scalarField> Foam::noiseFFT::Lf
(
const Pair<scalarField>& gPf
) const
{ {
return graph return Pair<scalarField>(gPf.first(), 20*log10(gPf.second()/p0));
(
"L(f)",
"f [Hz]",
"L(f) [dB]",
gPf.x(),
20*log10(gPf.y()/p0)
);
} }
Foam::graph Foam::noiseFFT::Ldelta Foam::Pair<Foam::scalarField> Foam::noiseFFT::Ldelta
( (
const graph& gLf, const Pair<scalarField>& gLf,
const scalar f1, const scalar f1,
const scalar fU const scalar fU
) const ) const
{ {
const scalarField& f = gLf.x(); const scalarField& f = gLf.first();
const scalarField& Lf = gLf.y(); const scalarField& Lf = gLf.second();
scalarField ldelta(Lf.size(), 0.0); scalarField ldelta(Lf.size(), 0.0);
scalarField fm(ldelta.size()); scalarField fm(ldelta.size());
@ -352,26 +327,19 @@ Foam::graph Foam::noiseFFT::Ldelta
fm.setSize(j); fm.setSize(j);
ldelta.setSize(j); ldelta.setSize(j);
return graph return Pair<scalarField>(fm, ldelta);
(
"Ldelta",
"fm [Hz]",
"Ldelta [dB]",
fm,
ldelta
);
} }
Foam::graph Foam::noiseFFT::Pdelta Foam::Pair<Foam::scalarField> Foam::noiseFFT::Pdelta
( (
const graph& gPf, const Pair<scalarField>& gPf,
const scalar f1, const scalar f1,
const scalar fU const scalar fU
) const ) const
{ {
const scalarField& f = gPf.x(); const scalarField& f = gPf.first();
const scalarField& Pf = gPf.y(); const scalarField& Pf = gPf.second();
scalarField pdelta(Pf.size(), 0.0); scalarField pdelta(Pf.size(), 0.0);
scalarField fm(pdelta.size()); scalarField fm(pdelta.size());
@ -408,20 +376,13 @@ Foam::graph Foam::noiseFFT::Pdelta
fm.setSize(j); fm.setSize(j);
pdelta.setSize(j); pdelta.setSize(j);
return graph return Pair<scalarField>(fm, pdelta);
(
"Pdelta",
"fm [Hz]",
"Pdelta [dB]",
fm,
pdelta
);
} }
Foam::scalar Foam::noiseFFT::Lsum(const graph& gLf) const Foam::scalar Foam::noiseFFT::Lsum(const Pair<Foam::scalarField>& gLf) const
{ {
const scalarField& Lf = gLf.y(); const scalarField& Lf = gLf.second();
scalar lsum = 0.0; scalar lsum = 0.0;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,7 +36,6 @@ SourceFiles
#define noiseFFT_H #define noiseFFT_H
#include "scalarField.H" #include "scalarField.H"
#include "graph.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -81,8 +80,8 @@ public:
// Member Functions // Member Functions
//- Return the graph of p(t) //- Return p(t)
graph pt() const; Pair<scalarField> pt() const;
//- Return the nth window //- Return the nth window
tmp<scalarField> window(const label N, const label n) const; tmp<scalarField> window(const label N, const label n) const;
@ -94,24 +93,34 @@ public:
tmp<scalarField> Pf(const tmp<scalarField>& pn) const; tmp<scalarField> Pf(const tmp<scalarField>& pn) const;
//- Return the multi-window mean fft of the complete pressure data //- Return the multi-window mean fft of the complete pressure data
graph meanPf(const label N, const label nw) const; Pair<scalarField> meanPf(const label N, const label nw) const;
//- Return the multi-window RMS mean fft of the complete pressure data //- Return the multi-window RMS mean fft of the complete pressure data
graph RMSmeanPf(const label N, const label nw) const; Pair<scalarField> RMSmeanPf(const label N, const label nw) const;
//- Return the narrow-band PFL (pressure-fluctuation level) spectrum //- Return the narrow-band PFL (pressure-fluctuation level) spectrum
graph Lf(const graph& gPf) const; Pair<scalarField> Lf(const Pair<scalarField>& gPf) const;
//- Return the one-third-octave-band PFL spectrum //- Return the one-third-octave-band PFL spectrum
// starting at octave with mean frequency f1 // starting at octave with mean frequency f1
graph Ldelta(const graph& gLf, const scalar f1, const scalar fU) const; Pair<scalarField> Ldelta
(
const Pair<scalarField>& gLf,
const scalar f1,
const scalar fU
) const;
//- Return the one-third-octave-band pressure spectrum //- Return the one-third-octave-band pressure spectrum
// starting at octave with mean frequency f1 // starting at octave with mean frequency f1
graph Pdelta(const graph& gLf, const scalar f1, const scalar fU) const; Pair<scalarField> Pdelta
(
const Pair<scalarField>& gLf,
const scalar f1,
const scalar fU
) const;
//- Return the total PFL as the sum of Lf over all frequencies //- Return the total PFL as the sum of Lf over all frequencies
scalar Lsum(const graph& gLf) const; scalar Lsum(const Pair<scalarField>& gLf) const;
//- Convert the db into Pa //- Convert the db into Pa
scalar dbToPa(const scalar db) const; scalar dbToPa(const scalar db) const;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -263,7 +263,7 @@ Foam::probes::probes
const dictionary& dict const dictionary& dict
) )
: :
functionObject(name), functionObject(name, t),
pointField(0), pointField(0),
mesh_ mesh_
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -145,7 +145,10 @@ bool Foam::functionObjects::sampledSets::read(const dictionary& dict)
dict.lookup("interpolationScheme") >> interpolationScheme_; dict.lookup("interpolationScheme") >> interpolationScheme_;
const word writeType(dict.lookup("setFormat")); const word writeType
(
dict.lookupOrDefault("setFormat", time_.graphFormat())
);
// Define the set formatter // Define the set formatter
formatter_ = setWriter::New(writeType, dict); formatter_ = setWriter::New(writeType, dict);