From 1765b5a4acb3f1ccb1923425eb71657b36a4f56c Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Thu, 4 May 2017 09:39:23 +0100
Subject: [PATCH] DPMDyMFoam, DPMDyMFoam: Corrected support for closed-domain
 simulations

Also added support for extrapolated pressure boundary conditions.
---
 .../solvers/lagrangian/DPMFoam/DPMDyMFoam/pEqn.H      |  6 +++---
 applications/solvers/lagrangian/DPMFoam/pEqn.H        | 11 ++++++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/pEqn.H b/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/pEqn.H
index 2f7b843d25..dd4d382bef 100644
--- a/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/pEqn.H
+++ b/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/pEqn.H
@@ -1,6 +1,5 @@
 {
-    volVectorField HbyA("HbyA", Uc);
-    HbyA = rAUc*UcEqn.H();
+    volVectorField HbyA(constrainHbyA(rAUc*UcEqn.H(), Uc, p));
 
     surfaceScalarField phiHbyA
     (
@@ -8,7 +7,6 @@
         (
            fvc::flux(HbyA)
          + alphacf*rAUcf*fvc::ddtCorr(Uc, Ucf)
-         + phicForces
         )
     );
 
@@ -19,6 +17,8 @@
         fvc::makeAbsolute(phiHbyA, Uc);
     }
 
+    phiHbyA += phicForces;
+
     // Update the pressure BCs to ensure flux consistency
     constrainPressure(p, Uc, phiHbyA, rAUcf);
 
diff --git a/applications/solvers/lagrangian/DPMFoam/pEqn.H b/applications/solvers/lagrangian/DPMFoam/pEqn.H
index 9e46551122..ea0bd1c101 100644
--- a/applications/solvers/lagrangian/DPMFoam/pEqn.H
+++ b/applications/solvers/lagrangian/DPMFoam/pEqn.H
@@ -1,6 +1,5 @@
 {
-    volVectorField HbyA("HbyA", Uc);
-    HbyA = rAUc*UcEqn.H();
+    volVectorField HbyA(constrainHbyA(rAUc*UcEqn.H(), Uc, p));
 
     surfaceScalarField phiHbyA
     (
@@ -8,10 +7,16 @@
         (
            fvc::flux(HbyA)
          + alphacf*rAUcf*fvc::ddtCorr(Uc, phic)
-         + phicForces
         )
     );
 
+    if (p.needReference())
+    {
+        adjustPhi(phiHbyA, Uc, p);
+    }
+
+    phiHbyA += phicForces;
+
     // Update the pressure BCs to ensure flux consistency
     constrainPressure(p, Uc, phiHbyA, rAUcf);
 
-- 
GitLab