From db877dba2ca7fe6730a3c2296ca8a598a90b1cac Mon Sep 17 00:00:00 2001
From: Amaury Johnen <amaury.johnen@uclouvain.be>
Date: Fri, 17 Nov 2017 09:49:05 +0100
Subject: [PATCH] fix subdivision non-curved high-order quad faces if heavyVisu
 true

---
 Geo/MHexahedron.cpp | 12 ++++++------
 Geo/MPrism.cpp      | 12 ++++++------
 Geo/MPyramid.cpp    |  3 ++-
 Geo/MQuadrangle.cpp |  8 +++-----
 4 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/Geo/MHexahedron.cpp b/Geo/MHexahedron.cpp
index 3f73d503ee..ce6d4f139b 100644
--- a/Geo/MHexahedron.cpp
+++ b/Geo/MHexahedron.cpp
@@ -438,20 +438,20 @@ int MHexahedron::getNumFacesRep(bool curved)
 
 int MHexahedron20::getNumFacesRep(bool curved)
 {
-  return curved ? 6 * (CTX::instance()->mesh.numSubEdges *
-                       CTX::instance()->mesh.numSubEdges * 2) : 12;
+  return curved ? 12 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
+         MHexahedron::getNumFacesRep(curved);
 }
 
 int MHexahedron27::getNumFacesRep(bool curved)
 {
-  return curved ? 6 * (CTX::instance()->mesh.numSubEdges *
-                       CTX::instance()->mesh.numSubEdges * 2) : 12;
+  return curved ? 12 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
+         MHexahedron::getNumFacesRep(curved);
 }
 
 int MHexahedronN::getNumFacesRep(bool curved)
 {
-  return curved ? 6 * (CTX::instance()->mesh.numSubEdges *
-                       CTX::instance()->mesh.numSubEdges * 2) : 12;
+  return curved ? 12 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
+         MHexahedron::getNumFacesRep(curved);
 }
 
 void _getIndicesReversedHex(int order, indicesReversed &indices)
diff --git a/Geo/MPrism.cpp b/Geo/MPrism.cpp
index caa99c36c6..38306fe013 100644
--- a/Geo/MPrism.cpp
+++ b/Geo/MPrism.cpp
@@ -496,20 +496,20 @@ int MPrism::getNumFacesRep(bool curved)
 
 int MPrism15::getNumFacesRep(bool curved)
 {
-  return curved ? 4 * (CTX::instance()->mesh.numSubEdges *
-                       CTX::instance()->mesh.numSubEdges * 2) : 8;
+  return curved ? 8 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
+         MPrism::getNumFacesRep(curved);
 }
 
 int MPrism18::getNumFacesRep(bool curved)
 {
-  return curved ? 4 * (CTX::instance()->mesh.numSubEdges *
-                       CTX::instance()->mesh.numSubEdges * 2) : 8;
+  return curved ? 8 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
+         MPrism::getNumFacesRep(curved);
 }
 
 int MPrismN::getNumFacesRep(bool curved)
 {
-  return curved ? 4 * (CTX::instance()->mesh.numSubEdges *
-                       CTX::instance()->mesh.numSubEdges * 2) : 8;
+  return curved ? 8 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
+         MPrism::getNumFacesRep(curved);
 }
 
 static void _addEdgeNodes(int num, bool reverse, int order,
diff --git a/Geo/MPyramid.cpp b/Geo/MPyramid.cpp
index 457a7f952a..73ee2fe9aa 100644
--- a/Geo/MPyramid.cpp
+++ b/Geo/MPyramid.cpp
@@ -97,7 +97,8 @@ int MPyramidN::getNumFacesRep(bool curved)
 {
   // FIXME: remove !getIsAssimilatedSerendipity() when serendip are implemented
   return (curved && !getIsAssimilatedSerendipity()) ?
-    6 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) : 6;
+         6 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
+         MPyramid::getNumFacesRep(curved);
 }
 
 static void _myGetFaceRep(MPyramid *pyr, int num, double *x, double *y, double *z,
diff --git a/Geo/MQuadrangle.cpp b/Geo/MQuadrangle.cpp
index e274fc9928..b552a504ca 100644
--- a/Geo/MQuadrangle.cpp
+++ b/Geo/MQuadrangle.cpp
@@ -17,8 +17,6 @@
 
 #include <cstring>
 
-#define SQU(a)      ((a)*(a))
-
 void MQuadrangle::getEdgeRep(bool curved, int num, double *x, double *y, double *z,
                              SVector3 *n)
 {
@@ -137,19 +135,19 @@ int MQuadrangle::getNumFacesRep(bool curved)
 
 int MQuadrangleN::getNumFacesRep(bool curved)
 {
-  return curved ? 2*SQU(CTX::instance()->mesh.numSubEdges) :
+  return curved ? 2 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
          MQuadrangle::getNumFacesRep(curved);
 }
 
 int MQuadrangle8::getNumFacesRep(bool curved)
 {
-  return curved ? 2*SQU(CTX::instance()->mesh.numSubEdges) :
+  return curved ? 2 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
          MQuadrangle::getNumFacesRep(curved);
 }
 
 int MQuadrangle9::getNumFacesRep(bool curved)
 {
-  return curved ? 2*SQU(CTX::instance()->mesh.numSubEdges) :
+  return curved ? 2 * gmsh_SQU(CTX::instance()->mesh.numSubEdges) :
          MQuadrangle::getNumFacesRep(curved);
 }
 
-- 
GitLab