From 52224055677ba7fd756f987afd7adf3e6dafee6d Mon Sep 17 00:00:00 2001
From: Henry <Henry>
Date: Thu, 28 Apr 2011 21:13:08 +0100
Subject: [PATCH] Create graphs in a sub-directory

---
 .../solvers/DNS/dnsFoam/createFields.H        |  2 +-
 applications/solvers/DNS/dnsFoam/dnsFoam.C    |  9 ++++++--
 .../utilities/preProcessing/boxTurb/boxTurb.C | 21 ++++++++++++-------
 src/OpenFOAM/graph/graph.C                    | 19 ++++++++++++++---
 src/OpenFOAM/graph/graph.H                    | 14 ++++++++++---
 src/sampling/graphField/writeCellGraph.C      |  5 ++++-
 6 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/applications/solvers/DNS/dnsFoam/createFields.H b/applications/solvers/DNS/dnsFoam/createFields.H
index 36fc513e020..6c1bb42929f 100644
--- a/applications/solvers/DNS/dnsFoam/createFields.H
+++ b/applications/solvers/DNS/dnsFoam/createFields.H
@@ -26,4 +26,4 @@
         mesh
     );
 
-#   include "createPhi.H"
+    #include "createPhi.H"
diff --git a/applications/solvers/DNS/dnsFoam/dnsFoam.C b/applications/solvers/DNS/dnsFoam/dnsFoam.C
index d3f1da2d99f..befa5e96552 100644
--- a/applications/solvers/DNS/dnsFoam/dnsFoam.C
+++ b/applications/solvers/DNS/dnsFoam/dnsFoam.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -110,7 +110,12 @@ int main(int argc, char *argv[])
 
         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"
diff --git a/applications/utilities/preProcessing/boxTurb/boxTurb.C b/applications/utilities/preProcessing/boxTurb/boxTurb.C
index dd00016f5be..3d6dc8e68fc 100644
--- a/applications/utilities/preProcessing/boxTurb/boxTurb.C
+++ b/applications/utilities/preProcessing/boxTurb/boxTurb.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -43,15 +43,15 @@ Description
 int main(int argc, char *argv[])
 {
     argList::noParallel();
-#   include "setRootCase.H"
+    #include "setRootCase.H"
 
-#   include "createTime.H"
-#   include "createMesh.H"
-#   include "createFields.H"
-#   include "readBoxTurbDict.H"
+    #include "createTime.H"
+    #include "createMesh.H"
+    #include "createFields.H"
+    #include "readBoxTurbDict.H"
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
     Kmesh K(mesh);
 
@@ -67,7 +67,12 @@ int main(int argc, char *argv[])
 
     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;
 
diff --git a/src/OpenFOAM/graph/graph.C b/src/OpenFOAM/graph/graph.C
index 1a0b8d1a4f3..7dbefcb424a 100644
--- a/src/OpenFOAM/graph/graph.C
+++ b/src/OpenFOAM/graph/graph.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -27,6 +27,7 @@ License
 #include "OFstream.H"
 #include "IOmanip.H"
 #include "Pair.H"
+#include "OSspecific.H"
 
 // * * * * * * * * * * * * * * 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));
 
-    OFstream graphFile(fName + '.' + graphWriter().ext());
+    OFstream graphFile(pName + '.' + graphWriter().ext());
 
     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)
 {
     g.writeTable(os);
diff --git a/src/OpenFOAM/graph/graph.H b/src/OpenFOAM/graph/graph.H
index 2e86c17efae..2519ca78f8b 100644
--- a/src/OpenFOAM/graph/graph.H
+++ b/src/OpenFOAM/graph/graph.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
+    \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -252,8 +252,16 @@ public:
             //- Write graph to stream in given format
             void write(Ostream&, const word& format) const;
 
-            //- Write graph to file in given format
-            void write(const fileName& fName, 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;
 
 
     // Friend operators
diff --git a/src/sampling/graphField/writeCellGraph.C b/src/sampling/graphField/writeCellGraph.C
index e502eccf243..740e3172cd6 100644
--- a/src/sampling/graphField/writeCellGraph.C
+++ b/src/sampling/graphField/writeCellGraph.C
@@ -16,6 +16,9 @@ void writeCellGraph
     const word& graphFormat
 )
 {
+    fileName path(vsf.time().path()/"graphs"/vsf.time().timeName());
+    mkDir(path);
+
     graph
     (
         vsf.name(),
@@ -23,7 +26,7 @@ void writeCellGraph
         vsf.name(),
         vsf.mesh().C().internalField().component(vector::X),
         vsf.internalField()
-    ).write(vsf.time().timePath()/vsf.name(), graphFormat);
+    ).write(path/vsf.name(), graphFormat);
 }
 
 
-- 
GitLab