From f1a15f3eb9c3be636bf4ae539be7bbdd4bc68508 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@uliege.be>
Date: Thu, 28 Apr 2022 17:13:10 +0200
Subject: [PATCH] only save groups of elements when saveGroupsOfElements is
 negavtive if the (dim+1)^th digit is 1 (as documented); this allows to use
 other values to disable group of element saving altogether

---
 src/geo/GModelIO_INP.cpp | 36 ++++++++++++++++++------------------
 src/mesh/meshGFace.cpp   |  3 +++
 2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/geo/GModelIO_INP.cpp b/src/geo/GModelIO_INP.cpp
index ab02c1182f..90d40eb3ea 100644
--- a/src/geo/GModelIO_INP.cpp
+++ b/src/geo/GModelIO_INP.cpp
@@ -114,27 +114,27 @@ int GModel::writeINP(const std::string &name, bool saveAll,
     // elements: is there this concept in Abaqus?) if saveGroupsOfElements is
     // positive; if saveGroupsOfElements is negative, only save groups of
     // dimension dim if the (dim+1)^th least significant digit of
-    // -saveGroupsOfElements is non-zero (for example: -100 will only save
-    // surfaces, while -1010 will save volumes and curves)
+    // -saveGroupsOfElements is 1 (for example: -100 will only save surfaces,
+    // while -1010 will save volumes and curves)
     for(int dim = 1; dim <= 3; dim++) {
-      if(saveGroupsOfElements < 0 &&
-         !((-saveGroupsOfElements / (int)std::pow(10, dim)) % 10)) {
-        continue;
-      }
-      for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) {
-        std::vector<GEntity *> &ent = it->second;
-        fprintf(fp, "*ELSET,ELSET=%s\n",
-                physicalName(this, dim, it->first).c_str());
-        int n = 0;
-        for(std::size_t i = 0; i < ent.size(); i++) {
-          for(std::size_t j = 0; j < ent[i]->getNumMeshElements(); j++) {
-            MElement *e = ent[i]->getMeshElement(j);
-            if(n && !(n % 10)) fprintf(fp, "\n");
-            fprintf(fp, "%lu, ", e->getNum());
-            n++;
+      if(saveGroupsOfElements > 0 ||
+         (saveGroupsOfElements < 0 &&
+          ((-saveGroupsOfElements / (int)std::pow(10, dim)) % 10) == 1)) {
+        for(auto it = groups[dim].begin(); it != groups[dim].end(); it++) {
+          std::vector<GEntity *> &ent = it->second;
+          fprintf(fp, "*ELSET,ELSET=%s\n",
+                  physicalName(this, dim, it->first).c_str());
+          int n = 0;
+          for(std::size_t i = 0; i < ent.size(); i++) {
+            for(std::size_t j = 0; j < ent[i]->getNumMeshElements(); j++) {
+              MElement *e = ent[i]->getMeshElement(j);
+              if(n && !(n % 10)) fprintf(fp, "\n");
+              fprintf(fp, "%lu, ", e->getNum());
+              n++;
+            }
           }
+          fprintf(fp, "\n");
         }
-        fprintf(fp, "\n");
       }
     }
   }
diff --git a/src/mesh/meshGFace.cpp b/src/mesh/meshGFace.cpp
index b635ee2921..a8c4e24b8a 100644
--- a/src/mesh/meshGFace.cpp
+++ b/src/mesh/meshGFace.cpp
@@ -2057,6 +2057,9 @@ static bool buildConsecutiveListOfVertices(
     count++;
   }
 
+  Msg::Debug("Succeeded finding consecutive list of nodes on surface "
+             "%d, with tolerance %g", gf->tag(), tol);
+
   // we're all set!
   recoverMap.insert(recoverMapLocal.begin(), recoverMapLocal.end());
 
-- 
GitLab