Create graphs in a sub-directory

This commit is contained in:
Henry
2011-04-28 21:13:08 +01:00
parent ffb0a2df21
commit 5222405567
6 changed files with 52 additions and 18 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -110,7 +110,12 @@ int main(int argc, char *argv[])
if (runTime.outputTime()) if (runTime.outputTime())
{ {
calcEk(U, K).write(runTime.timePath()/"Ek", runTime.graphFormat()); calcEk(U, K).write
(
runTime.path()/"graphs"/runTime.timeName(),
"Ek",
runTime.graphFormat()
);
} }
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,7 +51,7 @@ int main(int argc, char *argv[])
#include "readBoxTurbDict.H" #include "readBoxTurbDict.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Kmesh K(mesh); Kmesh K(mesh);
@ -67,7 +67,12 @@ int main(int argc, char *argv[])
U.write(); U.write();
calcEk(U, K).write(runTime.timePath()/"Ek", runTime.graphFormat()); calcEk(U, K).write
(
runTime.path()/"graphs"/runTime.timeName(),
"Ek",
runTime.graphFormat()
);
Info<< "end" << endl; Info<< "end" << 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 | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -27,6 +27,7 @@ License
#include "OFstream.H" #include "OFstream.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "Pair.H" #include "Pair.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -211,11 +212,11 @@ void Foam::graph::write(Ostream& os, const word& format) const
} }
void Foam::graph::write(const fileName& fName, const word& format) const void Foam::graph::write(const fileName& pName, const word& format) const
{ {
autoPtr<writer> graphWriter(writer::New(format)); autoPtr<writer> graphWriter(writer::New(format));
OFstream graphFile(fName + '.' + graphWriter().ext()); OFstream graphFile(pName + '.' + graphWriter().ext());
if (graphFile.good()) if (graphFile.good())
{ {
@ -230,6 +231,18 @@ void Foam::graph::write(const fileName& fName, const word& format) const
} }
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) Foam::Ostream& Foam::operator<<(Ostream& os, const graph& g)
{ {
g.writeTable(os); g.writeTable(os);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -252,8 +252,16 @@ public:
//- Write graph to stream in given format //- Write graph to stream in given format
void write(Ostream&, const word& format) const; void write(Ostream&, const word& format) const;
//- Write graph to file in given format //- Write graph to file in given path-name and format
void write(const fileName& fName, const word& format) const; 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;
// Friend operators // Friend operators

View File

@ -16,6 +16,9 @@ void writeCellGraph
const word& graphFormat const word& graphFormat
) )
{ {
fileName path(vsf.time().path()/"graphs"/vsf.time().timeName());
mkDir(path);
graph graph
( (
vsf.name(), vsf.name(),
@ -23,7 +26,7 @@ void writeCellGraph
vsf.name(), vsf.name(),
vsf.mesh().C().internalField().component(vector::X), vsf.mesh().C().internalField().component(vector::X),
vsf.internalField() vsf.internalField()
).write(vsf.time().timePath()/vsf.name(), graphFormat); ).write(path/vsf.name(), graphFormat);
} }