From 59c5250eec79eed89975490fe94e71b6429833fb Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Wed, 21 Jul 2021 15:46:52 +0200
Subject: [PATCH] [XDMF] applied clang-format

---
 BaseLib/cpp23.h                        |   3 +-
 MeshLib/IO/XDMF/MeshPropertyDataType.h |   2 +-
 MeshLib/IO/XDMF/XdmfData.cpp           |  40 +++----
 MeshLib/IO/XDMF/XdmfHdfWriter.cpp      |   3 +-
 MeshLib/IO/XDMF/XdmfWriter.cpp         |   4 +-
 MeshLib/IO/XDMF/transformData.cpp      |  10 +-
 MeshLib/IO/XDMF/writeXdmf.cpp          | 139 +++++++++++++------------
 ProcessLib/Output/Output.cpp           |   8 +-
 ProcessLib/Output/Output.h             |   6 +-
 9 files changed, 115 insertions(+), 100 deletions(-)

diff --git a/BaseLib/cpp23.h b/BaseLib/cpp23.h
index 3d7b5680da5..63e9db40255 100644
--- a/BaseLib/cpp23.h
+++ b/BaseLib/cpp23.h
@@ -22,7 +22,8 @@ namespace BaseLib
  *  \return The integer value of the underlying type of Enum, converted from e.
  *
  * https://en.cppreference.com/w/cpp/utility/to_underlying
- * Implementation from Scott Meyers : Modern effective c++ , Item 10 Scoped enums
+ * Implementation from Scott Meyers : Modern effective c++ , Item 10 Scoped
+ * enums
  */
 
 template <typename E>
diff --git a/MeshLib/IO/XDMF/MeshPropertyDataType.h b/MeshLib/IO/XDMF/MeshPropertyDataType.h
index e792809d962..bd844cad458 100644
--- a/MeshLib/IO/XDMF/MeshPropertyDataType.h
+++ b/MeshLib/IO/XDMF/MeshPropertyDataType.h
@@ -15,7 +15,7 @@
 // TODO (tm) If used on several other places move definition of propertyVector
 enum class MeshPropertyDataType
 {
-    unknown=0,
+    unknown = 0,
     float64,
     float32,
     int32,
diff --git a/MeshLib/IO/XDMF/XdmfData.cpp b/MeshLib/IO/XDMF/XdmfData.cpp
index 2aa9bf64cb2..432895df556 100644
--- a/MeshLib/IO/XDMF/XdmfData.cpp
+++ b/MeshLib/IO/XDMF/XdmfData.cpp
@@ -24,26 +24,30 @@ XdmfData::XdmfData(std::size_t const size_partitioned_dim,
                    std::string const& name,
                    std::optional<MeshLib::MeshItemType> const attribute_center,
                    unsigned int const index)
-    : starts([&size_tuple]() {
-          if (size_tuple > 1)
+    : starts(
+          [&size_tuple]()
           {
-              return std::vector<XdmfDimType>{0, 0};
-          }
-          else
+              if (size_tuple > 1)
+              {
+                  return std::vector<XdmfDimType>{0, 0};
+              }
+              else
+              {
+                  return std::vector<XdmfDimType>{0};
+              }
+          }()),
+      strides(
+          [&size_tuple]()
           {
-              return std::vector<XdmfDimType>{0};
-          }
-      }()),
-      strides([&size_tuple]() {
-          if (size_tuple > 1)
-          {
-              return std::vector<XdmfDimType>{1, 1};
-          }
-          else
-          {
-              return std::vector<XdmfDimType>{1};
-          }
-      }()),
+              if (size_tuple > 1)
+              {
+                  return std::vector<XdmfDimType>{1, 1};
+              }
+              else
+              {
+                  return std::vector<XdmfDimType>{1};
+              }
+          }()),
       data_type(mesh_property_data_type),
       name(name),
       attribute_center(attribute_center),
diff --git a/MeshLib/IO/XDMF/XdmfHdfWriter.cpp b/MeshLib/IO/XDMF/XdmfHdfWriter.cpp
index 7ec87403806..c3f3abd6f79 100644
--- a/MeshLib/IO/XDMF/XdmfHdfWriter.cpp
+++ b/MeshLib/IO/XDMF/XdmfHdfWriter.cpp
@@ -88,7 +88,8 @@ XdmfHdfWriter::XdmfHdfWriter(MeshLib::Mesh const& mesh,
     std::vector<XdmfData> xdmf_attributes;
     std::transform(attributes.begin(), attributes.end(),
                    std::back_inserter(xdmf_attributes),
-                   [&attributes](AttributeMeta& att) -> XdmfData {
+                   [&attributes](AttributeMeta& att) -> XdmfData
+                   {
                        size_t const i = &att - &attributes.front();
                        // index 1 geo, index 2 topology, attributes start at
                        // index 3
diff --git a/MeshLib/IO/XDMF/XdmfWriter.cpp b/MeshLib/IO/XDMF/XdmfWriter.cpp
index fa26367eeb2..222dca5d209 100644
--- a/MeshLib/IO/XDMF/XdmfWriter.cpp
+++ b/MeshLib/IO/XDMF/XdmfWriter.cpp
@@ -2,9 +2,9 @@
 
 #include <fstream>
 
-#include "writeXdmf.h"
-#include "BaseLib/RunTime.h"
 #include "BaseLib/Logging.h"
+#include "BaseLib/RunTime.h"
+#include "writeXdmf.h"
 
 namespace MeshLib::IO
 {
diff --git a/MeshLib/IO/XDMF/transformData.cpp b/MeshLib/IO/XDMF/transformData.cpp
index 33ac0e59859..d8179c8f34e 100644
--- a/MeshLib/IO/XDMF/transformData.cpp
+++ b/MeshLib/IO/XDMF/transformData.cpp
@@ -16,7 +16,6 @@
 #include <optional>
 #include <string>
 
-
 #include "BaseLib/cpp23.h"
 #include "InfoLib/GitInfo.h"
 #include "MeshLib/Elements/Element.h"
@@ -26,7 +25,6 @@
 #include "MeshPropertyDataType.h"
 #include "partition.h"
 
-
 using namespace BaseLib;
 namespace MeshLib::IO
 {
@@ -40,7 +38,8 @@ struct XdmfTopology
 
 constexpr auto elemOGSTypeToXDMFType()
 {
-    std::array<XdmfTopology, to_underlying(MeshLib::CellType::enum_length)> elem_type{};
+    std::array<XdmfTopology, to_underlying(MeshLib::CellType::enum_length)>
+        elem_type{};
     elem_type[to_underlying(MeshLib::CellType::POINT1)] = {0x1, 1};
     elem_type[to_underlying(MeshLib::CellType::LINE2)] = {0x2, 2};
     elem_type[to_underlying(MeshLib::CellType::LINE3)] = {0x2, 3};
@@ -118,8 +117,9 @@ std::optional<AttributeMeta> transformAttribute(
                           "Signed int has 32-1 bits");
             data_type = MeshPropertyDataType::int32;
         }
-        // ToDo (tm) These tests are platform specific and currently fail on Windows
-        // else if constexpr (std::is_same_v<long, decltype(basic_type)>)
+        // ToDo (tm) These tests are platform specific and currently fail on
+        // Windows else if constexpr (std::is_same_v<long,
+        // decltype(basic_type)>)
         //{
         //    static_assert((std::numeric_limits<long>::digits == 63),
         //                  "Signed int has 64-1 bits");
diff --git a/MeshLib/IO/XDMF/writeXdmf.cpp b/MeshLib/IO/XDMF/writeXdmf.cpp
index c1d1bde0f4d..0310d83a9cd 100644
--- a/MeshLib/IO/XDMF/writeXdmf.cpp
+++ b/MeshLib/IO/XDMF/writeXdmf.cpp
@@ -110,8 +110,10 @@ std::function<std::string(std::vector<double>)> write_xdmf(
     // return a unary function
     // _a suffix is a user defined literal for fmt named arguments
     auto const time_dataitem_genfn = [](int const time_step, int const max_step,
-                                        std::string const h5filename) {
-        return [time_step, max_step, h5filename](auto const& xdmfdata) {
+                                        std::string const h5filename)
+    {
+        return [time_step, max_step, h5filename](auto const& xdmfdata)
+        {
             return fmt::format(
                 "\n\t\t<DataItem DataType=\"{datatype}\" "
                 "Dimensions=\"{local_dimensions}\" "
@@ -137,13 +139,14 @@ std::function<std::string(std::vector<double>)> write_xdmf(
     };
 
     // string_join could be moved to ogs lib if used more
-    auto const string_join_fn = [](auto const& collection) {
-        return fmt::to_string(fmt::join(collection, ""));
-    };
+    auto const string_join_fn = [](auto const& collection)
+    { return fmt::to_string(fmt::join(collection, "")); };
 
     // m_bind could be moved to ogs lib if used more
-    auto const m_bind_fn = [](auto const& transform, auto const& join) {
-        return [join, transform](auto const& collection) {
+    auto const m_bind_fn = [](auto const& transform, auto const& join)
+    {
+        return [join, transform](auto const& collection)
+        {
             std::vector<std::string> temp;
             temp.resize(collection.size());
             std::transform(collection.begin(), collection.end(),
@@ -155,7 +158,8 @@ std::function<std::string(std::vector<double>)> write_xdmf(
     // XDMF if part of the data that is already written in any previous step
     // subsequent steps can refer to this data collection of elements navigates
     // the xml tree (take first child, then in child take 2nd child ...)
-    auto const pointer_transfrom = [](auto const& elements) {
+    auto const pointer_transfrom = [](auto const& elements)
+    {
         return fmt::format(
             "\n\t<xi:include xpointer=\"element(/{elements})\"/>",
             "elements"_a = fmt::join(elements, "/"));
@@ -163,8 +167,9 @@ std::function<std::string(std::vector<double>)> write_xdmf(
 
     // Defines content of <Attribute> in XDMF, child of Attribute is a single
     // <DataItem>
-    auto const attribute_transform = [](XdmfData const& attribute,
-                                        auto const& dataitem_transform) {
+    auto const attribute_transform =
+        [](XdmfData const& attribute, auto const& dataitem_transform)
+    {
         return fmt::format(
             "\n\t<Attribute Center=\"{center}\" ElementCell=\"\" "
             "ElementDegree=\"0\" "
@@ -176,16 +181,18 @@ std::function<std::string(std::vector<double>)> write_xdmf(
     };
 
     // Define content of <Geometry> in XDMF, same as attribute_transform
-    auto const geometry_transform = [](XdmfData const& geometry,
-                                       auto const& dataitem_transform) {
+    auto const geometry_transform =
+        [](XdmfData const& geometry, auto const& dataitem_transform)
+    {
         return fmt::format(
             "\n\t<Geometry Origin=\"\" Type=\"XYZ\">{dataitem}\n\t</Geometry>",
             "dataitem"_a = dataitem_transform(geometry));
     };
 
     // Define content of <Topology> in XDMF, same as attribute_transform
-    auto const topology_transform = [](XdmfData const& topology,
-                                       auto const& dataitem_transform) {
+    auto const topology_transform =
+        [](XdmfData const& topology, auto const& dataitem_transform)
+    {
         return fmt::format(
             "\n\t<Topology Dimensions=\"{dimensions}\" "
             "Type=\"Mixed\">{dataitem}\n\t</Topology>",
@@ -195,10 +202,10 @@ std::function<std::string(std::vector<double>)> write_xdmf(
 
     // Defines content of <Grid> of a single time step, takes specific transform
     // functions for all of its child elements
-    auto const grid_transform = [](double const& time_value,
-                                   auto const& geometry, auto const& topology,
-                                   auto const& constant_attributes,
-                                   auto const& variable_attributes) {
+    auto const grid_transform =
+        [](double const& time_value, auto const& geometry, auto const& topology,
+           auto const& constant_attributes, auto const& variable_attributes)
+    {
         return fmt::format(
             "\n<Grid Name=\"Grid\">\n\t<Time "
             "Value=\"{time_value}\"/"
@@ -222,10 +229,11 @@ std::function<std::string(std::vector<double>)> write_xdmf(
                                h5filename](auto const& component_transform,
                                            int const time_step,
                                            int const max_step,
-                                           time_attribute const variable) {
+                                           time_attribute const variable)
+    {
         return [component_transform, time_dataitem_genfn, pointer_transfrom,
-                variable, time_step, max_step,
-                h5filename](XdmfData const& attr) {
+                variable, time_step, max_step, h5filename](XdmfData const& attr)
+        {
             // new data arrived
             bool changed =
                 ((time_step > 0 && (variable == time_attribute::variable)) ||
@@ -253,29 +261,30 @@ std::function<std::string(std::vector<double>)> write_xdmf(
          geometry_transform, topology_transform, attribute_transform](
             double const time, int const step, int const max_step,
             auto const& geometry, auto const& topology,
-            auto const& constant_attributes, auto const& variable_attributes) {
-            auto const time_step_geometry_transform = time_step_fn(
-                geometry_transform, step, max_step, time_attribute::constant);
-            auto const time_step_topology_transform = time_step_fn(
-                topology_transform, step, max_step, time_attribute::constant);
-            auto const time_step_const_attribute_fn = time_step_fn(
-                attribute_transform, step, max_step, time_attribute::constant);
-            auto const time_step_variable_attribute_fn = time_step_fn(
-                attribute_transform, step, max_step, time_attribute::variable);
+            auto const& constant_attributes, auto const& variable_attributes)
+    {
+        auto const time_step_geometry_transform = time_step_fn(
+            geometry_transform, step, max_step, time_attribute::constant);
+        auto const time_step_topology_transform = time_step_fn(
+            topology_transform, step, max_step, time_attribute::constant);
+        auto const time_step_const_attribute_fn = time_step_fn(
+            attribute_transform, step, max_step, time_attribute::constant);
+        auto const time_step_variable_attribute_fn = time_step_fn(
+            attribute_transform, step, max_step, time_attribute::variable);
 
-            // lift both functions from handling single attributes to work with
-            // collection of attributes
-            auto const variable_attributes_transform =
-                m_bind_fn(time_step_variable_attribute_fn, string_join_fn);
-            auto const constant_attributes_transform =
-                m_bind_fn(time_step_const_attribute_fn, string_join_fn);
+        // lift both functions from handling single attributes to work with
+        // collection of attributes
+        auto const variable_attributes_transform =
+            m_bind_fn(time_step_variable_attribute_fn, string_join_fn);
+        auto const constant_attributes_transform =
+            m_bind_fn(time_step_const_attribute_fn, string_join_fn);
 
-            return grid_transform(
-                time, time_step_geometry_transform(geometry),
-                time_step_topology_transform(topology),
-                constant_attributes_transform(constant_attributes),
-                variable_attributes_transform(variable_attributes));
-        };
+        return grid_transform(
+            time, time_step_geometry_transform(geometry),
+            time_step_topology_transform(topology),
+            constant_attributes_transform(constant_attributes),
+            variable_attributes_transform(variable_attributes));
+    };
 
     // Function that combines all the data from spatial (geometry, topology,
     // attribute) and temporal domain (time) with the time domain
@@ -283,30 +292,31 @@ std::function<std::string(std::vector<double>)> write_xdmf(
     auto const temporal_grid_collection_transform =
         [time_grid_transform](
             auto const& times, auto const& geometry, auto const& topology,
-            auto const& constant_attributes, auto const& variable_attributes) {
-            // c++20 ranges zip missing
-            auto const max_step = times.size();
-            std::vector<std::string> grids;
-            grids.resize(max_step);
-            for (size_t time_step = 0; time_step < max_step; ++time_step)
-            {
-                grids.push_back(time_grid_transform(
-                    times[time_step], time_step, max_step, geometry, topology,
-                    constant_attributes, variable_attributes));
-            }
-            return fmt::format(
-                "\n<Grid CollectionType=\"Temporal\" GridType=\"Collection\" "
-                "Name=\"Collection\">{grids}\n</Grid>\n",
-                "grids"_a = fmt::join(grids, ""));
-        };
+            auto const& constant_attributes, auto const& variable_attributes)
+    {
+        // c++20 ranges zip missing
+        auto const max_step = times.size();
+        std::vector<std::string> grids;
+        grids.resize(max_step);
+        for (size_t time_step = 0; time_step < max_step; ++time_step)
+        {
+            grids.push_back(time_grid_transform(
+                times[time_step], time_step, max_step, geometry, topology,
+                constant_attributes, variable_attributes));
+        }
+        return fmt::format(
+            "\n<Grid CollectionType=\"Temporal\" GridType=\"Collection\" "
+            "Name=\"Collection\">{grids}\n</Grid>\n",
+            "grids"_a = fmt::join(grids, ""));
+    };
 
     // Generator function that return a function that represents complete xdmf
     // structure
-    auto const xdmf_writer_fn = [temporal_grid_collection_transform](
-                                    auto const& ogs_version,
-                                    auto const& geometry, auto const& topology,
-                                    auto const& constant_attributes,
-                                    auto const& variable_attributes) {
+    auto const xdmf_writer_fn =
+        [temporal_grid_collection_transform](
+            auto const& ogs_version, auto const& geometry, auto const& topology,
+            auto const& constant_attributes, auto const& variable_attributes)
+    {
         // This function will be the return of the surrounding named function
         // capture by copy - it is the function that will survive this scope!!
         // Use generalized lambda capture to move for optimization
@@ -314,7 +324,8 @@ std::function<std::string(std::vector<double>)> write_xdmf(
                 geometry = std::move(geometry), topology = std::move(topology),
                 constant_attributes = std::move(constant_attributes),
                 variable_attributes = std::move(variable_attributes)](
-                   std::vector<double> const& times) {
+                   std::vector<double> const& times)
+        {
             return fmt::format(
                 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Xdmf "
                 "xmlns:xi=\"http://www.w3.org/2001/XInclude\" "
diff --git a/ProcessLib/Output/Output.cpp b/ProcessLib/Output/Output.cpp
index 73ee24acc75..cc960786e3b 100644
--- a/ProcessLib/Output/Output.cpp
+++ b/ProcessLib/Output/Output.cpp
@@ -243,17 +243,17 @@ void Output::outputMeshXdmf(OutputFile const& output_file,
     {
         std::filesystem::path path(output_file.path);
         _mesh_xdmf_hdf_writer = std::make_unique<MeshLib::IO::XdmfHdfWriter>(
-        MeshLib::IO::XdmfHdfWriter(
+            MeshLib::IO::XdmfHdfWriter(
                 mesh, path, timestep, t,
-                _output_data_specification.output_variables, output_file.compression));
+                _output_data_specification.output_variables,
+                output_file.compression));
     }
     else
     {
-    _mesh_xdmf_hdf_writer->writeStep(timestep, t);
+        _mesh_xdmf_hdf_writer->writeStep(timestep, t);
     };
 }
 
-
 void Output::outputMesh(OutputFile const& output_file,
                         MeshLib::IO::PVDFile* const pvd_file,
                         MeshLib::Mesh const& mesh,
diff --git a/ProcessLib/Output/Output.h b/ProcessLib/Output/Output.h
index 1cf0709012c..78c0bbee5e8 100644
--- a/ProcessLib/Output/Output.h
+++ b/ProcessLib/Output/Output.h
@@ -38,8 +38,8 @@ public:
     };
 
 public:
-    Output(std::string directory, OutputType const type,
-           std::string prefix, std::string suffix, bool const compress_output,
+    Output(std::string directory, OutputType const type, std::string prefix,
+           std::string suffix, bool const compress_output,
            std::string const& data_mode,
            bool const output_nonlinear_iteration_results,
            std::vector<PairRepeatEachSteps> repeats_each_steps,
@@ -97,9 +97,7 @@ private:
                         int const timestep,
                         double const t);
 
-
 private:
-
     std::unique_ptr<MeshLib::IO::XdmfHdfWriter> _mesh_xdmf_hdf_writer;
 
     std::string const _output_directory;
-- 
GitLab