From fcebb1e6e7c4056b3ee59c34948dd77ec6a7170c Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Thu, 20 Oct 2011 16:11:45 +0100
Subject: [PATCH] BUG: potentialFoam/cylinder: indexing into non-existing patch
 in parallel

---
 .../basic/potentialFoam/cylinder/0.org/U      |  4 ++--
 .../potentialFoam/cylinder/system/controlDict | 24 +++++++++++++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/tutorials/basic/potentialFoam/cylinder/0.org/U b/tutorials/basic/potentialFoam/cylinder/0.org/U
index 550f88b5a4b..4d3f4887056 100644
--- a/tutorials/basic/potentialFoam/cylinder/0.org/U
+++ b/tutorials/basic/potentialFoam/cylinder/0.org/U
@@ -37,8 +37,8 @@ boundaryField
 
     left
     {
-        type            fixedValue;
-        value           uniform (1 0 0);
+        type            uniformFixedValue;
+        uniformValue    (1 0 0);
     }
 
     cylinder
diff --git a/tutorials/basic/potentialFoam/cylinder/system/controlDict b/tutorials/basic/potentialFoam/cylinder/system/controlDict
index cb71c177167..8bfa888ba1d 100644
--- a/tutorials/basic/potentialFoam/cylinder/system/controlDict
+++ b/tutorials/basic/potentialFoam/cylinder/system/controlDict
@@ -62,19 +62,39 @@ functions
 
             Info<< "Reading inlet velocity  uInfX\n" << endl;
 
+            scalar ULeft = 0.0;
+            label leftI = mesh().boundaryMesh().findPatchID("left");
+            const fvPatchVectorField& fvp = U.boundaryField()[leftI];
+            if (fvp.size())
+            {
+                ULeft = fvp[0].x();
+            }
+            reduce(ULeft, maxOp<scalar>());
+
             dimensionedScalar uInfX
             (
                 "uInfx",
                 dimensionSet(0, 1, -1, 0, 0),
-                U.boundaryField()[3][0].x()
+                ULeft
             );
+
             Info << "U at inlet = " << uInfX.value() << " m/s" << endl;
 
+
+            scalar magCylinder = 0.0;
+            label cylI = mesh().boundaryMesh().findPatchID("cylinder");
+            const fvPatchVectorField& cylFvp = mesh().C().boundaryField()[cylI];
+            if (cylFvp.size())
+            {
+                magCylinder = mag(cylFvp[0]);
+            }
+            reduce(magCylinder, maxOp<scalar>());
+
             dimensionedScalar radius
             (
                 "radius",
                 dimensionSet(0, 1, 0, 0, 0),
-                mag(U.mesh().boundary()[4].Cf()[0])
+                magCylinder
             );
 
             Info << "Cylinder radius = " << radius.value() << " m" << endl;
-- 
GitLab