From 34852ce8428586a5540d2c7611f8db640172f75f Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Mon, 16 Jul 2018 02:24:38 +0200
Subject: [PATCH] [io][vtk] Rename VTUReader to VTKReader as is supports
 multiple vtk formats

---
 dumux/io/CMakeLists.txt                     |  3 +++
 dumux/io/loadsolution.hh                    | 14 +++++++-------
 dumux/io/vtk/CMakeLists.txt                 |  3 +++
 dumux/io/vtk/{vtureader.hh => vtkreader.hh} | 14 +++++++-------
 dumux/io/xml/CMakeLists.txt                 |  4 ++++
 test/io/vtk/test_vtkreader.cc               |  6 +++---
 6 files changed, 27 insertions(+), 17 deletions(-)
 create mode 100644 dumux/io/vtk/CMakeLists.txt
 rename dumux/io/vtk/{vtureader.hh => vtkreader.hh} (97%)
 create mode 100644 dumux/io/xml/CMakeLists.txt

diff --git a/dumux/io/CMakeLists.txt b/dumux/io/CMakeLists.txt
index 6e76c281b1..72dd61cd93 100644
--- a/dumux/io/CMakeLists.txt
+++ b/dumux/io/CMakeLists.txt
@@ -1,10 +1,13 @@
 add_subdirectory(grid)
+add_subdirectory(vtk)
+add_subdirectory(xml)
 
 install(FILES
 adaptivegridrestart.hh
 container.hh
 defaultvtkoutputfields.hh
 gnuplotinterface.hh
+loadsolution.hh
 ploteffectivediffusivitymodel.hh
 plotmateriallaw.hh
 plotmateriallaw3p.hh
diff --git a/dumux/io/loadsolution.hh b/dumux/io/loadsolution.hh
index edaf2c4637..47048d42c5 100644
--- a/dumux/io/loadsolution.hh
+++ b/dumux/io/loadsolution.hh
@@ -33,7 +33,7 @@
 
 #include <dumux/common/parameters.hh>
 #include <dumux/common/typetraits/isvalid.hh>
-#include <dumux/io/vtk/vtureader.hh>
+#include <dumux/io/vtk/vtkreader.hh>
 
 namespace Dumux {
 
@@ -55,12 +55,12 @@ struct hasState
  */
 template <class SolutionVector, class PvNamesFunc>
 auto loadSolutionFromVtuFile(const std::string fileName,
-                             const VTUReader::DataType& dataType,
+                             const VTKReader::DataType& dataType,
                              PvNamesFunc&& pvNamesFunc,
                              SolutionVector& sol)
 -> typename std::enable_if_t<!decltype(isValid(Detail::hasState())(sol[0]))::value, void>
 {
-    VTUReader vtu(fileName);
+    VTKReader vtu(fileName);
     using PrimaryVariables = typename SolutionVector::block_type;
     using Scalar = typename PrimaryVariables::field_type;
 
@@ -82,12 +82,12 @@ auto loadSolutionFromVtuFile(const std::string fileName,
  */
 template <class SolutionVector, class PvNamesFunc>
 auto loadSolutionFromVtuFile(const std::string fileName,
-                             const VTUReader::DataType& dataType,
+                             const VTKReader::DataType& dataType,
                              PvNamesFunc&& pvNamesFunc,
                              SolutionVector& sol)
 -> typename std::enable_if_t<decltype(isValid(Detail::hasState())(sol[0]))::value, void>
 {
-    VTUReader vtu(fileName);
+    VTKReader vtu(fileName);
     const auto vec = vtu.readData<std::vector<int>>("phase presence", dataType);
     std::unordered_set<int> states;
     for (size_t i = 0; i < sol.size(); ++i)
@@ -163,7 +163,7 @@ std::string primaryVariableName(int pvIdx)
 /*!
  * \ingroup InputOutput
  * \brief load a solution vector from file
- * \note Supports the following file extensions: *.vtu
+ * \note Supports the following file extensions: *.vtu *.vtp
  */
 template <class SolutionVector, class PvNamesFunc>
 void loadSolution(const std::string& fileName,
@@ -176,7 +176,7 @@ void loadSolution(const std::string& fileName,
     if (extension == "vtu" || extension == "vtp")
     {
         const auto dataType = discMethod == DiscretizationMethod::box
-                              ? VTUReader::DataType::pointData : VTUReader::DataType::cellData;
+                              ? VTKReader::DataType::pointData : VTKReader::DataType::cellData;
         loadSolutionFromVtuFile(fileName, dataType, pvNamesFunc, sol);
     }
     else
diff --git a/dumux/io/vtk/CMakeLists.txt b/dumux/io/vtk/CMakeLists.txt
new file mode 100644
index 0000000000..6c8d1b946c
--- /dev/null
+++ b/dumux/io/vtk/CMakeLists.txt
@@ -0,0 +1,3 @@
+install(FILES
+vtkreader.hh
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/io/vtk)
diff --git a/dumux/io/vtk/vtureader.hh b/dumux/io/vtk/vtkreader.hh
similarity index 97%
rename from dumux/io/vtk/vtureader.hh
rename to dumux/io/vtk/vtkreader.hh
index cf9a6e250f..f6dd03ddba 100644
--- a/dumux/io/vtk/vtureader.hh
+++ b/dumux/io/vtk/vtkreader.hh
@@ -19,10 +19,10 @@
 /*!
  * \file
  * \ingroup InputOutput
- * \brief A vtu reader using tinyxml2 as xml backend
+ * \brief A vtk file reader using tinyxml2 as xml backend
  */
-#ifndef DUMUX_IO_VTK_VTUREADER_HH
-#define DUMUX_IO_VTK_VTUREADER_HH
+#ifndef DUMUX_IO_VTK_VTKREADER_HH
+#define DUMUX_IO_VTK_VTKREADER_HH
 
 #include <iostream>
 #include <iterator>
@@ -39,9 +39,9 @@ namespace Dumux {
 
 /*!
  * \ingroup InputOutput
- * \brief A vtu reader using tinyxml2 as xml backend
+ * \brief A vtk file reader using tinyxml2 as xml backend
  */
-class VTUReader
+class VTKReader
 {
 public:
     /*!
@@ -55,7 +55,7 @@ public:
     /*!
      * \brief The contructor creates a tinyxml2::XMLDocument from file
      */
-    VTUReader(const std::string& fileName)
+    VTKReader(const std::string& fileName)
     : fileName_(fileName)
     {
         using namespace tinyxml2;
@@ -291,7 +291,7 @@ private:
         }
     }
 
-    const std::string fileName_; //!< the vtu file name
+    const std::string fileName_; //!< the vtk file name
     tinyxml2::XMLDocument doc_; //!< the xml document created from file with name fileName_
 };
 
diff --git a/dumux/io/xml/CMakeLists.txt b/dumux/io/xml/CMakeLists.txt
new file mode 100644
index 0000000000..25a59e1bc7
--- /dev/null
+++ b/dumux/io/xml/CMakeLists.txt
@@ -0,0 +1,4 @@
+install(FILES
+tinyxml2.cpp
+tinyxml2.h
+DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/io/xml)
diff --git a/test/io/vtk/test_vtkreader.cc b/test/io/vtk/test_vtkreader.cc
index 4d433e3c77..bc8a4cad49 100644
--- a/test/io/vtk/test_vtkreader.cc
+++ b/test/io/vtk/test_vtkreader.cc
@@ -35,9 +35,9 @@ int main(int argc, char** argv) try
 {
     Dune::MPIHelper::instance(argc, argv);
 
-    Dumux::VTUReader vtkReader("test-in.vtu");
+    Dumux::VTKReader vtkReader("test-in.vtu");
     using Grid = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming>;
-    Dumux::VTUReader::Data cellData, pointData;
+    Dumux::VTKReader::Data cellData, pointData;
     Dune::GridFactory<Grid> gridFactory;
     auto grid = vtkReader.readGrid(gridFactory, cellData, pointData, /*verbose=*/true);
     const auto& gridView = grid->leafGridView();
@@ -61,7 +61,7 @@ int main(int argc, char** argv) try
         }
     }
 
-    Dumux::VTUReader::Data reorderedCellData = cellData, reorderedPointData = pointData;
+    Dumux::VTKReader::Data reorderedCellData = cellData, reorderedPointData = pointData;
     for (const auto& data : cellData)
     {
         auto& reorderedData = reorderedCellData[data.first];
-- 
GitLab