From afa64919ecc355e978a2819d8acfe33b3f990371 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Fri, 24 Jun 2016 15:16:51 +0100
Subject: [PATCH] potentialFoam: simplify the Phi BCs to use only fixedValue
 and zeroGradient by default Resolves bug-report
 http://bugs.openfoam.org/view.php?id=2129

---
 .../basic/potentialFoam/createFields.H        | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/applications/solvers/basic/potentialFoam/createFields.H b/applications/solvers/basic/potentialFoam/createFields.H
index 97801c0221..40db86dacf 100644
--- a/applications/solvers/basic/potentialFoam/createFields.H
+++ b/applications/solvers/basic/potentialFoam/createFields.H
@@ -40,7 +40,7 @@ word pName("p");
 // Update name of the pressure field from the command-line option
 args.optionReadIfPresent("pName", pName);
 
-// Infer the pressure BCs from the velocity BCs
+// Infer the pressure BCs from the velocity
 wordList pBCTypes
 (
     U.boundaryField().size(),
@@ -71,6 +71,21 @@ volScalarField p
     pBCTypes
 );
 
+// Infer the velocity potential BCs from the pressure
+wordList PhiBCTypes
+(
+    p.boundaryField().size(),
+    zeroGradientFvPatchScalarField::typeName
+);
+
+forAll(p.boundaryField(), patchi)
+{
+    if (p.boundaryField()[patchi].fixesValue())
+    {
+        PhiBCTypes[patchi] = fixedValueFvPatchScalarField::typeName;
+    }
+}
+
 Info<< "Constructing velocity potential field Phi\n" << endl;
 volScalarField Phi
 (
@@ -84,7 +99,7 @@ volScalarField Phi
     ),
     mesh,
     dimensionedScalar("Phi", dimLength*dimVelocity, 0),
-    p.boundaryField().types()
+    PhiBCTypes
 );
 
 label PhiRefCell = 0;
-- 
GitLab