From 00e0b543c16e727d8462b49d01edd97ddb269e4a Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Mon, 23 Sep 2024 10:28:18 +0200
Subject: [PATCH] [MeL/IO/XDMF] Pass parent_data_type (from
 TransformedMeshData) to transformTopology()

---
 MeshLib/IO/XDMF/XdmfHdfWriter.cpp |  6 +++---
 MeshLib/IO/XDMF/transformData.cpp |  3 ++-
 MeshLib/IO/XDMF/transformData.h   | 12 +++++++-----
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/MeshLib/IO/XDMF/XdmfHdfWriter.cpp b/MeshLib/IO/XDMF/XdmfHdfWriter.cpp
index ad2ffc65650..2a88a96364f 100644
--- a/MeshLib/IO/XDMF/XdmfHdfWriter.cpp
+++ b/MeshLib/IO/XDMF/XdmfHdfWriter.cpp
@@ -108,9 +108,9 @@ XdmfHdfWriter::XdmfHdfWriter(
         auto const geometry = transformGeometry(
             mesh, xdmf_conforming_data->flattened_geometry_values.data(),
             n_files, chunk_size_bytes);
-        auto const topology =
-            transformTopology(xdmf_conforming_data->flattened_topology_values,
-                              n_files, chunk_size_bytes);
+        auto const topology = transformTopology(
+            xdmf_conforming_data->flattened_topology_values,
+            xdmf_conforming_data->parent_data_type, n_files, chunk_size_bytes);
         auto const attributes =
             transformAttributes(mesh, n_files, chunk_size_bytes);
         return XdmfHdfMesh{std::move(geometry), std::move(topology),
diff --git a/MeshLib/IO/XDMF/transformData.cpp b/MeshLib/IO/XDMF/transformData.cpp
index 093eb53f8a3..60c43f0a16f 100644
--- a/MeshLib/IO/XDMF/transformData.cpp
+++ b/MeshLib/IO/XDMF/transformData.cpp
@@ -353,6 +353,7 @@ std::pair<std::vector<int>, ParentDataType> transformToXDMFTopology(
 }
 
 XdmfHdfData transformTopology(std::vector<int> const& values,
+                              ParentDataType const parent_data_type,
                               unsigned int const n_files,
                               unsigned int const chunk_size_bytes)
 {
@@ -367,7 +368,7 @@ XdmfHdfData transformTopology(std::vector<int> const& values,
                         std::nullopt,
                         3,
                         n_files,
-                        std::nullopt};
+                        parent_data_type};
 
     return XdmfHdfData{std::move(hdf), std::move(xdmf)};
 }
diff --git a/MeshLib/IO/XDMF/transformData.h b/MeshLib/IO/XDMF/transformData.h
index 28460d90e69..839f84e66fe 100644
--- a/MeshLib/IO/XDMF/transformData.h
+++ b/MeshLib/IO/XDMF/transformData.h
@@ -51,13 +51,15 @@ XdmfHdfData transformGeometry(MeshLib::Mesh const& mesh, double const* data_ptr,
 /**
  * \brief  Create meta data for topology used for HDF5 and XDMF
  * \param values actual topology values to get size and memory location
- * \param n_files specifies the number of files. If greater than 1 it groups the
- * data of each process to n_files
- * \param chunk_size_bytes Data will be split into chunks. The parameter
- * specifies the size (in bytes) of the largest chunk.
- * \return Topology meta data
+ * \param parent_data_type XDMF topological element data types as listed in the
+ * enum ParentDataTypei
+ * \param n_files specifies the number of files. If greater
+ * than 1 it groups the data of each process to n_files \param chunk_size_bytes
+ * Data will be split into chunks. The parameter specifies the size (in bytes)
+ * of the largest chunk. \return Topology meta data
  */
 XdmfHdfData transformTopology(std::vector<int> const& values,
+                              ParentDataType const parent_data_type,
                               unsigned int n_files,
                               unsigned int chunk_size_bytes);
 /**
-- 
GitLab