From 01c14532bdc0c815a426dcf8cab8cd6e7c2e4c89 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Thu, 6 Feb 2020 12:35:22 +0000
Subject: [PATCH] ENH: checkMesh: write cellZone, faceZone info. See #1543.

---
 .../mesh/manipulation/checkMesh/checkMesh.C   |  6 +-
 .../mesh/manipulation/checkMesh/writeFields.C | 57 +++++++++++++++++++
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C
index 216e2b1ce47..46869bd38ba 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2017 OpenFOAM Foundation
-    Copyright (C) 2015-2019 OpenCFD Ltd.
+    Copyright (C) 2015-2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -163,7 +163,9 @@ int main(int argc, char *argv[])
             "minTetVolume",
             "minPyrVolume",
             "cellRegion",
-            "wallDistance"
+            "wallDistance",
+            "cellZone",
+            "faceZone"
         });
     }
 
diff --git a/applications/utilities/mesh/manipulation/checkMesh/writeFields.C b/applications/utilities/mesh/manipulation/checkMesh/writeFields.C
index 7f86c28bd9b..f58db28de7d 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/writeFields.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/writeFields.C
@@ -586,5 +586,62 @@ void Foam::writeFields
         }
     }
 
+    if (selectedFields.found("cellZone"))
+    {
+        volScalarField cellZone
+        (
+            IOobject
+            (
+                "cellZone",
+                mesh.time().timeName(),
+                mesh,
+                IOobject::NO_READ,
+                IOobject::AUTO_WRITE,
+                false
+            ),
+            mesh,
+            dimensionedScalar(scalar(-1)),
+            calculatedFvPatchScalarField::typeName
+        );
+
+        const cellZoneMesh& czs = mesh.cellZones();
+        for (const auto& zone : czs)
+        {
+            UIndirectList<scalar>(cellZone, zone) = zone.index();
+        }
+
+        cellZone.correctBoundaryConditions();
+        Info<< "    Writing cell zoning to " << cellZone.name() << endl;
+        cellZone.write();
+    }
+    if (selectedFields.found("faceZone"))
+    {
+        surfaceScalarField faceZone
+        (
+            IOobject
+            (
+                "faceZone",
+                mesh.time().timeName(),
+                mesh,
+                IOobject::NO_READ,
+                IOobject::AUTO_WRITE,
+                false
+            ),
+            mesh,
+            dimensionedScalar(scalar(-1)),
+            calculatedFvsPatchScalarField::typeName
+        );
+
+        const faceZoneMesh& czs = mesh.faceZones();
+        for (const auto& zone : czs)
+        {
+            UIndirectList<scalar>(faceZone, zone) = zone.index();
+        }
+
+        //faceZone.correctBoundaryConditions();
+        Info<< "    Writing face zoning to " << faceZone.name() << endl;
+        faceZone.write();
+    }
+
     Info<< endl;
 }
-- 
GitLab