From 8e463c5430adf2e10ecad5072cff48a3e0875443 Mon Sep 17 00:00:00 2001
From: Jacques Xing <jxing1@ic.ac.uk>
Date: Thu, 26 Sep 2024 10:42:25 +0000
Subject: [PATCH] Fix BwdTrans for Pyr with var P

---
 CHANGELOG.md                                        | 1 +
 library/StdRegions/StdPyrExp.cpp                    | 2 +-
 solvers/ADRSolver/Tests/Advection3D_DG_pyr_varP.tst | 6 +++---
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3187b5e557..5ac7ade545 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ v5.7.0
 - Fix IterativeStaticCond when using absolute tolerance (!1850)
 - Fix deadlock by scotch with multi-threading support (!1853)
 - Fixed L2norm for FilterError (!1871)
+- Fix BwdTrans for Pyr with var P (!1886)
 
 **IncNavierStokesSolver**
 - Fix initial and boundary conditions in the moving reference frame (!1692, !1820)
diff --git a/library/StdRegions/StdPyrExp.cpp b/library/StdRegions/StdPyrExp.cpp
index ec9e46c2e6..223b75e8a7 100644
--- a/library/StdRegions/StdPyrExp.cpp
+++ b/library/StdRegions/StdPyrExp.cpp
@@ -299,7 +299,7 @@ void StdPyrExp::v_BwdTrans_SumFacKernel(
             mode1 += order2 - ijmax;
         }
         // increment mode in case order1!=order2
-        for (j = order1; j < order2 - i; ++j)
+        for (j = order1; j < order2; ++j)
         {
             int ijmax = max(i, j);
             mode += order2 - ijmax;
diff --git a/solvers/ADRSolver/Tests/Advection3D_DG_pyr_varP.tst b/solvers/ADRSolver/Tests/Advection3D_DG_pyr_varP.tst
index 90f88a1de5..d871a98e86 100644
--- a/solvers/ADRSolver/Tests/Advection3D_DG_pyr_varP.tst
+++ b/solvers/ADRSolver/Tests/Advection3D_DG_pyr_varP.tst
@@ -8,10 +8,10 @@
     </files>
     <metrics>
         <metric type="L2" id="1">
-            <value variable="u" tolerance="1e-9">0.000700559</value>
+            <value variable="u" tolerance="1e-9">0.000686284</value>
         </metric>
         <metric type="Linf" id="2">
-            <value variable="u" tolerance="1e-9">0.0141906</value>
+            <value variable="u" tolerance="1e-9">0.0139766</value>
         </metric>
     </metrics>
-</test>
\ No newline at end of file
+</test>
-- 
GitLab