From 30574a43cde7a991bcbbe8f9969d9f30226c75e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org>
Date: Tue, 8 Sep 2020 14:48:26 +0200
Subject: [PATCH] [test] Test python conversion to TupleVector

---
 dune/fufem/test/dunepythontest.cc | 13 +++++++++++++
 dune/fufem/test/dunepythontest.py |  1 +
 2 files changed, 14 insertions(+)

diff --git a/dune/fufem/test/dunepythontest.cc b/dune/fufem/test/dunepythontest.cc
index 7126c1de..9abd90ca 100644
--- a/dune/fufem/test/dunepythontest.cc
+++ b/dune/fufem/test/dunepythontest.cc
@@ -12,6 +12,8 @@
 #include <dune/common/fvector.hh>
 #include <dune/common/function.hh>
 #include <dune/common/parametertree.hh>
+#include <dune/common/tuplevector.hh>
+#include <dune/common/indices.hh>
 
 #if HAVE_UG
 #include <dune/grid/uggrid.hh>
@@ -25,6 +27,7 @@
 #include <dune/fufem/dunepython.hh>
 
 
+using namespace Dune::Indices;
 
 int main(int argc, char** argv)
 {
@@ -401,6 +404,7 @@ int main(int argc, char** argv)
         auto int_list = module.get("int_list");
         auto str_list = module.get("str_list");
         auto int_tuple = module.get("int_tuple");
+        auto mixed_tuple = module.get("mixed_tuple");
 
         // Modify first argument of int_list.
         // Similar to calling a Callable you can either hand
@@ -431,6 +435,15 @@ int main(int argc, char** argv)
         std::cout << "python integer tuple converted to vector<int>:" << std::endl;
         for(size_t i=0; i<int_vec2.size(); ++i)
             std::cout << int_vec2[i] << std::endl;
+
+        // Convert python mixed tuple to Dune::TupleVector and print results:
+        Dune::TupleVector<std::vector<int>,std::string> mixed_tuple_c;
+        mixed_tuple.toC(mixed_tuple_c);
+        std::cout << "python mixed tuple (string representation):" << mixed_tuple.str() << std::endl;
+        std::cout << "python mixed tuple converted to Dune::TupleVector:" << std::endl;
+        for(size_t i=0; i<mixed_tuple_c[_0].size(); ++i)
+            std::cout << mixed_tuple_c[_0][i] << std::endl;
+        std::cout << mixed_tuple_c[_1] << std::endl;
     }
 
 
diff --git a/dune/fufem/test/dunepythontest.py b/dune/fufem/test/dunepythontest.py
index c82d9397..b9a32241 100644
--- a/dune/fufem/test/dunepythontest.py
+++ b/dune/fufem/test/dunepythontest.py
@@ -10,6 +10,7 @@ def add(x,y):
 int_list=[11,12,13]
 str_list=["string1","string2","string3"]
 int_tuple=(1,2,3)
+mixed_tuple=((1,2),"three")
 
 
 
-- 
GitLab