From d4d4f7282796bcc638626de7c6209d6b4bd743d0 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs@hunt.opencfd.co.uk>
Date: Thu, 28 May 2009 18:15:16 +0100
Subject: [PATCH] optional reading of writeGraph

---
 .../scotchDecomp/scotchDecomp.C               | 57 ++++++++++---------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/src/decompositionMethods/decompositionMethods/scotchDecomp/scotchDecomp.C b/src/decompositionMethods/decompositionMethods/scotchDecomp/scotchDecomp.C
index a33e49b8288..f1e1cd27804 100644
--- a/src/decompositionMethods/decompositionMethods/scotchDecomp/scotchDecomp.C
+++ b/src/decompositionMethods/decompositionMethods/scotchDecomp/scotchDecomp.C
@@ -153,37 +153,40 @@ Foam::label Foam::scotchDecomp::decompose
         const dictionary& scotchCoeffs =
             decompositionDict_.subDict("scotchCoeffs");
 
-        Switch writeGraph(scotchCoeffs.lookup("writeGraph"));
-
-        if (writeGraph)
+        if (scotchCoeffs.found("writeGraph"))
         {
-            OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
-
-            Info<< "Dumping Scotch graph file to " << str.name() << endl
-                << "Use this in combination with gpart." << endl;
-
-            label version = 0;
-            str << version << nl;
-            // Numer of vertices
-            str << xadj.size()-1 << ' ' << adjncy.size() << nl;
-            // Numbering starts from 0
-            label baseval = 0;
-            // Has weights?
-            label hasEdgeWeights = 0;
-            label hasVertexWeights = 0;
-            label numericflag = 10*hasEdgeWeights+hasVertexWeights;
-            str << baseval << ' ' << numericflag << nl;
-            for (label cellI = 0; cellI < xadj.size()-1; cellI++)
-            {
-                label start = xadj[cellI];
-                label end = xadj[cellI+1];
-                str << end-start;
+            Switch writeGraph(scotchCoeffs.lookup("writeGraph"));
 
-                for (label i = start; i < end; i++)
+            if (writeGraph)
+            {
+                OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
+
+                Info<< "Dumping Scotch graph file to " << str.name() << endl
+                    << "Use this in combination with gpart." << endl;
+
+                label version = 0;
+                str << version << nl;
+                // Numer of vertices
+                str << xadj.size()-1 << ' ' << adjncy.size() << nl;
+                // Numbering starts from 0
+                label baseval = 0;
+                // Has weights?
+                label hasEdgeWeights = 0;
+                label hasVertexWeights = 0;
+                label numericflag = 10*hasEdgeWeights+hasVertexWeights;
+                str << baseval << ' ' << numericflag << nl;
+                for (label cellI = 0; cellI < xadj.size()-1; cellI++)
                 {
-                    str << ' ' << adjncy[i];
+                    label start = xadj[cellI];
+                    label end = xadj[cellI+1];
+                    str << end-start;
+
+                    for (label i = start; i < end; i++)
+                    {
+                        str << ' ' << adjncy[i];
+                    }
+                    str << nl;
                 }
-                str << nl;
             }
         }
     }
-- 
GitLab