From d20af8a0e7d65638edb2357061f1c753cfdbf67f Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Tue, 14 Mar 2017 11:29:08 +0100
Subject: [PATCH] [A/U/MP] Move check in copyPropertyVector.

---
 .../PartitionMesh/NodeWiseMeshPartitioner.cpp | 31 +++++++------------
 .../PartitionMesh/NodeWiseMeshPartitioner.h   |  6 +++-
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp
index b3535273ca4..4cf92f0ecfc 100644
--- a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp
+++ b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.cpp
@@ -221,26 +221,19 @@ void NodeWiseMeshPartitioner::processProperties()
     auto property_names = original_properties.getPropertyVectorNames();
     for (auto const& name : property_names)
     {
-        if (original_properties.existsPropertyVector<double>(name))
-        {
-            copyPropertyVector<double>(name, total_number_of_tuples);
-        }
-        else if (original_properties.existsPropertyVector<float>(name))
-        {
-            copyPropertyVector<float>(name, total_number_of_tuples);
-        }
-        else if (original_properties.existsPropertyVector<int>(name))
-        {
-            copyPropertyVector<int>(name, total_number_of_tuples);
-        }
-        else if (original_properties.existsPropertyVector<long>(name))
-        {
-            copyPropertyVector<long>(name, total_number_of_tuples);
-        }
-        else if (original_properties.existsPropertyVector<std::size_t>(name))
-        {
+        bool success =
+            copyPropertyVector<double>(name, total_number_of_tuples) ||
+            copyPropertyVector<float>(name, total_number_of_tuples) ||
+            copyPropertyVector<int>(name, total_number_of_tuples) ||
+            copyPropertyVector<long>(name, total_number_of_tuples) ||
+            copyPropertyVector<unsigned>(name, total_number_of_tuples) ||
+            copyPropertyVector<unsigned long>(name, total_number_of_tuples) ||
             copyPropertyVector<std::size_t>(name, total_number_of_tuples);
-        }
+        if (!success)
+            WARN(
+                "processProperties: Could not create partitioned "
+                "PropertyVector '%s'.",
+                name.c_str());
     }
 }
 
diff --git a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h
index 190e1cdc1e5..3ddd8f5288e 100644
--- a/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h
+++ b/Applications/Utils/ModelPreparation/PartitionMesh/NodeWiseMeshPartitioner.h
@@ -171,10 +171,13 @@ private:
     void processProperties();
 
     template <typename T>
-    void copyPropertyVector(std::string const& name,
+    bool copyPropertyVector(std::string const& name,
                             std::size_t const total_number_of_tuples)
     {
         auto const& original_properties(_mesh->getProperties());
+        if (!original_properties.existsPropertyVector<T>(name))
+            return false;
+
         auto const& pv(original_properties.getPropertyVector<T>(name));
         auto partitioned_pv =
             _partitioned_properties.createNewPropertyVector<T>(
@@ -191,6 +194,7 @@ private:
             }
             position_offset += p.nodes.size();
         }
+        return true;
     }
 
     template <typename T>
-- 
GitLab