From 6d06eaedd46fe52ff9543a8aa8854b58663942fb Mon Sep 17 00:00:00 2001
From: acrovato <a.crovato@uliege.be>
Date: Tue, 21 Mar 2023 10:34:25 +0100
Subject: [PATCH] Fix steady pressure computation.

---
 sdpm/src/sdpmSolver.cpp |  5 ++---
 sdpm/tests/lann.py      |  4 ++--
 sdpm/tests/m6.py        | 10 +++++-----
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/sdpm/src/sdpmSolver.cpp b/sdpm/src/sdpmSolver.cpp
index 5e0e1eb..bcb8c29 100644
--- a/sdpm/src/sdpmSolver.cpp
+++ b/sdpm/src/sdpmSolver.cpp
@@ -426,9 +426,8 @@ void Solver::post(sdpmVectorXd const &etau, sdpmVectorXd const &emu)
         for (auto e : body->getElements())
         {
             sdpmVector3d u = ui - (_tau[e->getId() - 1] * e->getCompressibleNormal() + e->computeGradient(muNodes)).cwiseQuotient(sdpmVector3d(_pbl.getCompressibility(), 1., 1.));
-            sdpmDouble cpl = 1 - u.dot(u) / ui.dot(ui);
-            _u[e->getId() - 1] = u;                                      // velocity
-            _cp[e->getId() - 1] = cpl + 0.5 * 0.5 * cpl * cpl * mi * mi; // nonlinear pressure coefficient
+            _u[e->getId() - 1] = u;                                                                        // velocity
+            _cp[e->getId() - 1] = 1 - (u.dot(u) - mi * mi * (u(0) - ui(0)) * (u(0) - ui(0))) / ui.dot(ui); // nonlinear pressure coefficient
         }
     }
 
diff --git a/sdpm/tests/lann.py b/sdpm/tests/lann.py
index 031b183..5b0da28 100644
--- a/sdpm/tests/lann.py
+++ b/sdpm/tests/lann.py
@@ -65,8 +65,8 @@ def main():
 
     # test
     tests = CTests()
-    tests.add(CTest('CL0', sol.getLiftCoeff(), 0.258, 5e-2)) # MATLAB: 0.265
-    tests.add(CTest('CD0', sol.getDragCoeff(),  -0.0029, 5e-2)) # MATLAB: -0.0033
+    tests.add(CTest('CL0', sol.getLiftCoeff(), 0.264, 5e-2)) # MATLAB: 0.27
+    tests.add(CTest('CD0', sol.getDragCoeff(),  0.0020, 5e-2)) # MATLAB: 0.0031
     tests.add(CTest('CS0', sol.getSideforceCoeff(), 0.008, 5e-2))
     tests.add(CTest('CM0', sol.getMomentCoeff(), -0.079, 5e-2))
     tests.add(CTest('Abs(CL1)', abs(sol.getUnsteadyLiftCoeff(0, 0)) / amp / math.pi, 1.54, 5e-2)) # MATLAB: 1.62
diff --git a/sdpm/tests/m6.py b/sdpm/tests/m6.py
index 528d4b8..ae360e9 100644
--- a/sdpm/tests/m6.py
+++ b/sdpm/tests/m6.py
@@ -28,7 +28,7 @@ def main():
     pars = {'nC': 100, 'nS': 10, 'bC': 0.25, 'pS': 1.0}
     # flow parameters
     aoa = 3.06 * math.pi / 180
-    minf = 0.
+    minf = 0.839
 
     # start timer
     tms = sdpm.Timers()
@@ -58,10 +58,10 @@ def main():
 
     # test
     tests = CTests()
-    tests.add(CTest('CL', sol.getLiftCoeff(), 0.200, 5e-2)) # gitlab.uliege.be/am-dept/dartflo: 0.200
-    tests.add(CTest('CD', sol.getDragCoeff(), 0.003, 5e-2)) # dartflo: 0.004
-    tests.add(CTest('CS', sol.getSideforceCoeff(), 0.008, 5e-2)) # dartflo: 0.011
-    tests.add(CTest('CM', sol.getMomentCoeff(), -0.147, 5e-2)) # dartflo: -0.148
+    tests.add(CTest('CL', sol.getLiftCoeff(), 0.255, 5e-2)) # panair: 0.255
+    tests.add(CTest('CD', sol.getDragCoeff(), 0.005, 5e-2)) # panair: 0.005
+    tests.add(CTest('CS', sol.getSideforceCoeff(), 0.011, 5e-2)) # panair: 0.011
+    tests.add(CTest('CM', sol.getMomentCoeff(), -0.189, 5e-2)) # panair: -0.189
     tests.run()
 
     # eof
-- 
GitLab