From 26904bf6dfce685b3fbe87867f8688d1d0a2cf6b Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Mon, 15 Jan 2024 15:23:09 +0000
Subject: [PATCH] ENH: pointConstraints: allow non-facePointPatch. Fixes #3085

---
 .../volPointInterpolation/pointConstraints.C  | 32 ++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/finiteVolume/interpolation/volPointInterpolation/pointConstraints.C b/src/finiteVolume/interpolation/volPointInterpolation/pointConstraints.C
index 0aba8151470..efbbaa7140f 100644
--- a/src/finiteVolume/interpolation/volPointInterpolation/pointConstraints.C
+++ b/src/finiteVolume/interpolation/volPointInterpolation/pointConstraints.C
@@ -56,8 +56,6 @@ void Foam::pointConstraints::makePatchPatchAddressing()
     const polyMesh& mesh = pMesh();
 
     const pointBoundaryMesh& pbm = pMesh.boundary();
-    const polyBoundaryMesh& bm = mesh.boundaryMesh();
-
 
     // first count the total number of patch-patch points
 
@@ -65,9 +63,15 @@ void Foam::pointConstraints::makePatchPatchAddressing()
 
     forAll(pbm, patchi)
     {
-        if (!isA<emptyPointPatch>(pbm[patchi]) && !pbm[patchi].coupled())
+        const auto* fpp = isA<facePointPatch>(pbm[patchi]);
+        if
+        (
+            fpp
+         && !isA<emptyPointPatch>(pbm[patchi])
+         && !pbm[patchi].coupled()
+        )
         {
-            const labelList& bp = bm[patchi].boundaryPoints();
+            const labelList& bp = fpp->patch().boundaryPoints();
 
             nPatchPatchPoints += bp.size();
 
@@ -103,9 +107,15 @@ void Foam::pointConstraints::makePatchPatchAddressing()
 
     forAll(pbm, patchi)
     {
-        if (!isA<emptyPointPatch>(pbm[patchi]) && !pbm[patchi].coupled())
+        const auto* fpp = isA<facePointPatch>(pbm[patchi]);
+        if
+        (
+            fpp
+         && !isA<emptyPointPatch>(pbm[patchi])
+         && !pbm[patchi].coupled()
+        )
         {
-            const labelList& bp = bm[patchi].boundaryPoints();
+            const labelList& bp = fpp->patch().boundaryPoints();
             const labelList& meshPoints = pbm[patchi].meshPoints();
 
             forAll(bp, pointi)
@@ -163,9 +173,15 @@ void Foam::pointConstraints::makePatchPatchAddressing()
         // Copy from patchPatch constraints into coupledConstraints.
         forAll(pbm, patchi)
         {
-            if (!isA<emptyPointPatch>(pbm[patchi]) && !pbm[patchi].coupled())
+            const auto* fpp = isA<facePointPatch>(pbm[patchi]);
+            if
+            (
+                fpp
+             && !isA<emptyPointPatch>(pbm[patchi])
+             && !pbm[patchi].coupled()
+            )
             {
-                const labelList& bp = bm[patchi].boundaryPoints();
+                const labelList& bp = fpp->patch().boundaryPoints();
                 const labelList& meshPoints = pbm[patchi].meshPoints();
 
                 forAll(bp, pointi)
-- 
GitLab