From 319ca5cc0672f9df86e9573c85387c480eaeb724 Mon Sep 17 00:00:00 2001 From: Simon Praetorius <simon.praetorius@tu-dresden.de> Date: Tue, 28 Aug 2018 18:21:32 +0200 Subject: [PATCH] removed experimental namespace and geometrygrid example added --- .../datacollectors/continuousdatacollector.hh | 4 +- .../datacollectors/datacollectorinterface.hh | 8 +- .../discontinuousdatacollector.hh | 4 +- .../datacollectors/quadraticdatacollector.hh | 4 +- dune/vtk/datacollectors/spdatacollector.hh | 4 +- .../datacollectors/structureddatacollector.hh | 5 +- .../unstructureddatacollector.hh | 4 +- dune/vtk/datacollectors/yaspdatacollector.hh | 32 ++++++-- dune/vtk/defaultvtkfunction.hh | 4 +- dune/vtk/filereader.hh | 4 +- dune/vtk/filewriter.hh | 4 +- dune/vtk/gridcreator.hh | 4 +- dune/vtk/legacyvtkfunction.hh | 4 +- dune/vtk/vtkfunction.hh | 4 +- dune/vtk/vtklocalfunction.hh | 4 +- dune/vtk/vtklocalfunctioninterface.hh | 4 +- dune/vtk/vtkreader.hh | 4 +- dune/vtk/vtkreader.impl.hh | 4 +- dune/vtk/vtktypes.cc | 4 +- dune/vtk/vtktypes.hh | 4 +- dune/vtk/vtkwriter.hh | 4 +- dune/vtk/writers/vtkimagedatawriter.hh | 4 +- dune/vtk/writers/vtkimagedatawriter.impl.hh | 4 +- dune/vtk/writers/vtkrectilineargridwriter.hh | 4 +- .../writers/vtkrectilineargridwriter.impl.hh | 4 +- dune/vtk/writers/vtkstructuredgridwriter.hh | 4 +- .../writers/vtkstructuredgridwriter.impl.hh | 4 +- dune/vtk/writers/vtkunstructuredgridwriter.hh | 4 +- .../writers/vtkunstructuredgridwriter.impl.hh | 4 +- dune/vtk/writers/vtkwriterinterface.hh | 6 +- dune/vtk/writers/vtkwriterinterface.impl.hh | 4 +- src/CMakeLists.txt | 4 + src/benchmark.cc | 16 ++-- src/datacollector.cc | 1 - src/geometrygrid.cc | 78 +++++++++++++++++++ src/legacyvtkwriter.cc | 1 - src/polygongrid.cc | 1 - src/structuredgridwriter.cc | 1 - src/test/mixed_element_test.cc | 1 - src/test/reader_writer_test.cc | 1 - src/vtkreader.cc | 1 - src/vtkwriter.cc | 2 - 42 files changed, 180 insertions(+), 86 deletions(-) create mode 100644 src/geometrygrid.cc diff --git a/dune/vtk/datacollectors/continuousdatacollector.hh b/dune/vtk/datacollectors/continuousdatacollector.hh index 1c9d4dc..22f48f3 100644 --- a/dune/vtk/datacollectors/continuousdatacollector.hh +++ b/dune/vtk/datacollectors/continuousdatacollector.hh @@ -2,7 +2,7 @@ #include "unstructureddatacollector.hh" -namespace Dune { namespace experimental +namespace Dune { /// Implementation of \ref DataCollector for linear cells, with continuous data. @@ -101,4 +101,4 @@ protected: using Super::gridView_; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/datacollectors/datacollectorinterface.hh b/dune/vtk/datacollectors/datacollectorinterface.hh index 5d4f16d..1dcb283 100644 --- a/dune/vtk/datacollectors/datacollectorinterface.hh +++ b/dune/vtk/datacollectors/datacollectorinterface.hh @@ -2,7 +2,7 @@ #include <dune/vtk/vtktypes.hh> -namespace Dune { namespace experimental { +namespace Dune { template <class GridView, class Derived> class DataCollectorInterface @@ -98,10 +98,10 @@ public: // default implementations auto localFct = localFunction(fct); for (auto const& e : elements(gridView_, Partitions::all)) { localFct.bind(e); - auto geometry = e.geometry(); + auto refElem = referenceElement<T,GridView::dimension>(e.type()); std::size_t idx = fct.ncomps() * indexSet.index(e); for (int comp = 0; comp < fct.ncomps(); ++comp) - data[idx + comp] = T(localFct.evaluate(comp, geometry.center())); + data[idx + comp] = T(localFct.evaluate(comp, refElem.position(0,0))); localFct.unbind(); } return data; @@ -111,4 +111,4 @@ protected: GridView gridView_; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/datacollectors/discontinuousdatacollector.hh b/dune/vtk/datacollectors/discontinuousdatacollector.hh index 1816a37..4a50662 100644 --- a/dune/vtk/datacollectors/discontinuousdatacollector.hh +++ b/dune/vtk/datacollectors/discontinuousdatacollector.hh @@ -2,7 +2,7 @@ #include "unstructureddatacollector.hh" -namespace Dune { namespace experimental +namespace Dune { /// Implementation of \ref DataCollector for linear cells, with discontinuous data. @@ -115,4 +115,4 @@ protected: std::vector<std::int64_t> indexMap_; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/datacollectors/quadraticdatacollector.hh b/dune/vtk/datacollectors/quadraticdatacollector.hh index e9c8052..55e98c2 100644 --- a/dune/vtk/datacollectors/quadraticdatacollector.hh +++ b/dune/vtk/datacollectors/quadraticdatacollector.hh @@ -2,7 +2,7 @@ #include "unstructureddatacollector.hh" -namespace Dune { namespace experimental +namespace Dune { /// Implementation of \ref DataCollector for quadratic cells, with continuous data. @@ -132,4 +132,4 @@ protected: using Super::gridView_; }; -}} // end namespace Dune::extensions +} // end namespace Dune diff --git a/dune/vtk/datacollectors/spdatacollector.hh b/dune/vtk/datacollectors/spdatacollector.hh index cb7e2b6..a7ba208 100644 --- a/dune/vtk/datacollectors/spdatacollector.hh +++ b/dune/vtk/datacollectors/spdatacollector.hh @@ -6,7 +6,7 @@ #include "structureddatacollector.hh" -namespace Dune { namespace experimental +namespace Dune { #if HAVE_DUNE_SPGRID @@ -88,4 +88,4 @@ namespace Impl } #endif // HAVE_DUNE_SPGRID -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/datacollectors/structureddatacollector.hh b/dune/vtk/datacollectors/structureddatacollector.hh index 854aa03..9a5bb0f 100644 --- a/dune/vtk/datacollectors/structureddatacollector.hh +++ b/dune/vtk/datacollectors/structureddatacollector.hh @@ -1,11 +1,12 @@ #pragma once #include <array> +#include <dune/common/filledarray.hh> #include <dune/common/fvector.hh> #include "continuousdatacollector.hh" -namespace Dune { namespace experimental +namespace Dune { namespace Impl @@ -228,4 +229,4 @@ protected: #endif }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/datacollectors/unstructureddatacollector.hh b/dune/vtk/datacollectors/unstructureddatacollector.hh index b831102..a473ed3 100644 --- a/dune/vtk/datacollectors/unstructureddatacollector.hh +++ b/dune/vtk/datacollectors/unstructureddatacollector.hh @@ -5,7 +5,7 @@ #include "datacollectorinterface.hh" -namespace Dune { namespace experimental { +namespace Dune { struct Cells { @@ -41,4 +41,4 @@ protected: using Super::gridView_; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/datacollectors/yaspdatacollector.hh b/dune/vtk/datacollectors/yaspdatacollector.hh index 7dbbfd4..12315d1 100644 --- a/dune/vtk/datacollectors/yaspdatacollector.hh +++ b/dune/vtk/datacollectors/yaspdatacollector.hh @@ -4,7 +4,7 @@ #include "structureddatacollector.hh" -namespace Dune { namespace experimental +namespace Dune { // Specialization for YaspGrid template <class GridView> @@ -53,10 +53,10 @@ public: for (int i = 0; i < dim; ++i) { wholeExtent_[2*i] = 0; - wholeExtent_[2*i+1] = gridView_.grid().levelSize(level_,i); + wholeExtent_[2*i+1] = grid(gridView_).levelSize(level_,i); } - auto const& gl = *gridView_.grid().begin(level_); + auto const& gl = *grid(gridView_).begin(level_); auto const& g = gl.interior[0]; auto const& gc = *g.dataBegin(); for (int i = 0; i < dim; ++i) { @@ -64,7 +64,7 @@ public: extent_[2*i+1] = gc.max(i)+1; } - auto it = gridView_.grid().begin(level_); + auto it = grid(gridView_).begin(level_); initGeometry(it->coords); } @@ -97,7 +97,7 @@ public: template <class T> std::array<std::vector<T>, 3> coordinatesImpl () const { - auto it = gridView_.grid().begin(level_); + auto it = grid(gridView_).begin(level_); auto const& coords = it->coords; std::array<std::vector<T>, 3> ordinates{}; @@ -114,6 +114,26 @@ public: return ordinates; } + +private: + + template <class G> + using HostGrid = decltype(std::declval<G>().hostGrid()); + + template <class GV, + std::enable_if_t<Std::is_detected<HostGrid, typename GV::Grid>::value, int> = 0> + auto const& grid (GV const& gridView) const + { + return gridView.grid().hostGrid(); + } + + template <class GV, + std::enable_if_t<not Std::is_detected<HostGrid, typename GV::Grid>::value, int> = 0> + auto const& grid (GV const& gridView) const + { + return gridView.grid(); + } + protected: using Super::gridView_; std::array<int, 6> wholeExtent_; @@ -132,4 +152,4 @@ namespace Impl }; } -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/defaultvtkfunction.hh b/dune/vtk/defaultvtkfunction.hh index 078909b..d32f8a4 100644 --- a/dune/vtk/defaultvtkfunction.hh +++ b/dune/vtk/defaultvtkfunction.hh @@ -2,7 +2,7 @@ #include "vtklocalfunctioninterface.hh" -namespace Dune { namespace experimental +namespace Dune { /// Type erasure for dune-functions LocalFunction interface template <class GridView, class LocalFunction> @@ -60,4 +60,4 @@ namespace Dune { namespace experimental LocalFunction localFct_; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/filereader.hh b/dune/vtk/filereader.hh index aad0764..abc9d0c 100644 --- a/dune/vtk/filereader.hh +++ b/dune/vtk/filereader.hh @@ -4,7 +4,7 @@ #include <string> #include <utility> -namespace Dune { namespace experimental +namespace Dune { template <class Grid, class FilerReaderImp> class FileReader @@ -68,4 +68,4 @@ namespace Dune { namespace experimental } }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/filewriter.hh b/dune/vtk/filewriter.hh index f184f34..ffe21e0 100644 --- a/dune/vtk/filewriter.hh +++ b/dune/vtk/filewriter.hh @@ -2,7 +2,7 @@ #include <string> -namespace Dune { namespace experimental +namespace Dune { class FileWriter { @@ -14,4 +14,4 @@ namespace Dune { namespace experimental virtual void write (std::string const& filename) = 0; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/gridcreator.hh b/dune/vtk/gridcreator.hh index 50504b8..4fec129 100644 --- a/dune/vtk/gridcreator.hh +++ b/dune/vtk/gridcreator.hh @@ -10,7 +10,7 @@ #include "vtktypes.hh" -namespace Dune { namespace experimental +namespace Dune { // Create a grid where the input points and connectivity is already // connected correctly. @@ -116,4 +116,4 @@ namespace Dune { namespace experimental } }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/legacyvtkfunction.hh b/dune/vtk/legacyvtkfunction.hh index 2d3f797..10cfb04 100644 --- a/dune/vtk/legacyvtkfunction.hh +++ b/dune/vtk/legacyvtkfunction.hh @@ -6,7 +6,7 @@ #include "vtklocalfunctioninterface.hh" -namespace Dune { namespace experimental +namespace Dune { /// Type erasure for Legacy VTKFunction template <class GridView> @@ -42,4 +42,4 @@ namespace Dune { namespace experimental Entity const* entity_; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/vtkfunction.hh b/dune/vtk/vtkfunction.hh index 70428b0..4593f8d 100644 --- a/dune/vtk/vtkfunction.hh +++ b/dune/vtk/vtkfunction.hh @@ -8,7 +8,7 @@ #include "vtklocalfunction.hh" #include "vtktypes.hh" -namespace Dune { namespace experimental +namespace Dune { template <class GridView> class VtkFunction @@ -86,4 +86,4 @@ namespace Dune { namespace experimental Vtk::DataTypes type_ = Vtk::FLOAT32; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/vtklocalfunction.hh b/dune/vtk/vtklocalfunction.hh index 9b5dc85..faf8309 100644 --- a/dune/vtk/vtklocalfunction.hh +++ b/dune/vtk/vtklocalfunction.hh @@ -9,7 +9,7 @@ #include "legacyvtkfunction.hh" #include "defaultvtkfunction.hh" -namespace Dune { namespace experimental +namespace Dune { template <class GridView> class VtkLocalFunction @@ -56,4 +56,4 @@ namespace Dune { namespace experimental std::shared_ptr<VtkLocalFunctionInterface<GridView>> localFct_; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/vtklocalfunctioninterface.hh b/dune/vtk/vtklocalfunctioninterface.hh index 221dbc1..d1d047c 100644 --- a/dune/vtk/vtklocalfunctioninterface.hh +++ b/dune/vtk/vtklocalfunctioninterface.hh @@ -1,6 +1,6 @@ #pragma once -namespace Dune { namespace experimental +namespace Dune { /// An abstract base class for LocalFunctions template <class GridView> @@ -23,4 +23,4 @@ namespace Dune { namespace experimental virtual ~VtkLocalFunctionInterface () = default; }; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/vtkreader.hh b/dune/vtk/vtkreader.hh index 2dc6beb..3b90c76 100644 --- a/dune/vtk/vtkreader.hh +++ b/dune/vtk/vtkreader.hh @@ -7,7 +7,7 @@ #include "gridcreator.hh" #include "vtktypes.hh" -namespace Dune { namespace experimental +namespace Dune { /// File-Reader for Vtk .vtu files /** @@ -129,6 +129,6 @@ namespace Dune { namespace experimental std::uint64_t offset0_; }; -}} // end namespace Dune::experimental +} // end namespace Dune #include "vtkreader.impl.hh" diff --git a/dune/vtk/vtkreader.impl.hh b/dune/vtk/vtkreader.impl.hh index 320fae1..948c387 100644 --- a/dune/vtk/vtkreader.impl.hh +++ b/dune/vtk/vtkreader.impl.hh @@ -12,7 +12,7 @@ #include "utility/filesystem.hh" #include "utility/string.hh" -namespace Dune { namespace experimental { +namespace Dune { template <class Grid, class Creator> void VtkReader<Grid,Creator>::readFromFile (std::string const& filename) @@ -512,4 +512,4 @@ std::map<std::string, std::string> VtkReader<Grid,Creator>::parseXml (std::strin return attr; } -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/vtktypes.cc b/dune/vtk/vtktypes.cc index 6e2f9e6..d8becf4 100644 --- a/dune/vtk/vtktypes.cc +++ b/dune/vtk/vtktypes.cc @@ -2,7 +2,7 @@ #include <iostream> -namespace Dune { namespace experimental { +namespace Dune { namespace Vtk { std::string to_string (FormatTypes type) @@ -154,4 +154,4 @@ CellType::CellType (GeometryType const& t, CellParametrization parametrization) } } -}}} // end namespace Dune::experimental::Vtk +}} // end namespace Dune::Vtk diff --git a/dune/vtk/vtktypes.hh b/dune/vtk/vtktypes.hh index 9991b23..250d5a8 100644 --- a/dune/vtk/vtktypes.hh +++ b/dune/vtk/vtktypes.hh @@ -7,7 +7,7 @@ #include <dune/geometry/type.hh> -namespace Dune { namespace experimental +namespace Dune { namespace Vtk { @@ -113,4 +113,4 @@ namespace Dune { namespace experimental }; } // end namespace Vtk -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/vtkwriter.hh b/dune/vtk/vtkwriter.hh index 6667f8e..d333392 100644 --- a/dune/vtk/vtkwriter.hh +++ b/dune/vtk/vtkwriter.hh @@ -14,7 +14,7 @@ #include <dune/grid/yaspgrid.hh> #include <dune/vtk/datacollectors/yaspdatacollector.hh> -namespace Dune { namespace experimental +namespace Dune { namespace Impl { @@ -63,4 +63,4 @@ namespace Dune { namespace experimental template <class GridView> using VtkWriter = typename Impl::VtkWriterImpl<GridView, typename GridView::Grid>::type; -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/writers/vtkimagedatawriter.hh b/dune/vtk/writers/vtkimagedatawriter.hh index 34c9fa7..c9a6783 100644 --- a/dune/vtk/writers/vtkimagedatawriter.hh +++ b/dune/vtk/writers/vtkimagedatawriter.hh @@ -11,7 +11,7 @@ #include "vtkwriterinterface.hh" -namespace Dune { namespace experimental +namespace Dune { /// File-Writer for ImageData VTK .vti files /** @@ -57,6 +57,6 @@ namespace Dune { namespace experimental using Super::cellData_; }; -}} // end namespace Dune::experimental +} // end namespace Dune #include "vtkimagedatawriter.impl.hh" diff --git a/dune/vtk/writers/vtkimagedatawriter.impl.hh b/dune/vtk/writers/vtkimagedatawriter.impl.hh index 468b785..235b4ef 100644 --- a/dune/vtk/writers/vtkimagedatawriter.impl.hh +++ b/dune/vtk/writers/vtkimagedatawriter.impl.hh @@ -14,7 +14,7 @@ #include <dune/vtk/utility/filesystem.hh> #include <dune/vtk/utility/string.hh> -namespace Dune { namespace experimental { +namespace Dune { template <class GV, class DC> void VtkImageDataWriter<GV,DC> @@ -163,4 +163,4 @@ void VtkImageDataWriter<GV,DC> out << "</VTKFile>"; } -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/writers/vtkrectilineargridwriter.hh b/dune/vtk/writers/vtkrectilineargridwriter.hh index 8ee4f80..fdfa416 100644 --- a/dune/vtk/writers/vtkrectilineargridwriter.hh +++ b/dune/vtk/writers/vtkrectilineargridwriter.hh @@ -11,7 +11,7 @@ #include "vtkwriterinterface.hh" -namespace Dune { namespace experimental +namespace Dune { /// File-Writer for RectilinearGrid VTK .vtr files /** @@ -62,6 +62,6 @@ namespace Dune { namespace experimental using Super::cellData_; }; -}} // end namespace Dune::experimental +} // end namespace Dune #include "vtkrectilineargridwriter.impl.hh" diff --git a/dune/vtk/writers/vtkrectilineargridwriter.impl.hh b/dune/vtk/writers/vtkrectilineargridwriter.impl.hh index 6d37be6..23b8f09 100644 --- a/dune/vtk/writers/vtkrectilineargridwriter.impl.hh +++ b/dune/vtk/writers/vtkrectilineargridwriter.impl.hh @@ -14,7 +14,7 @@ #include <dune/vtk/utility/filesystem.hh> #include <dune/vtk/utility/string.hh> -namespace Dune { namespace experimental { +namespace Dune { template <class GV, class DC> void VtkRectilinearGridWriter<GV,DC> @@ -219,4 +219,4 @@ std::array<std::uint64_t,3> VtkRectilinearGridWriter<GV,DC> return {bs0, bs1, bs2}; } -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/writers/vtkstructuredgridwriter.hh b/dune/vtk/writers/vtkstructuredgridwriter.hh index e2772b8..6dff211 100644 --- a/dune/vtk/writers/vtkstructuredgridwriter.hh +++ b/dune/vtk/writers/vtkstructuredgridwriter.hh @@ -11,7 +11,7 @@ #include "vtkwriterinterface.hh" -namespace Dune { namespace experimental +namespace Dune { /// File-Writer for StructuredGrid VTK .vts files /** @@ -57,6 +57,6 @@ namespace Dune { namespace experimental using Super::cellData_; }; -}} // end namespace Dune::experimental +} // end namespace Dune #include "vtkstructuredgridwriter.impl.hh" diff --git a/dune/vtk/writers/vtkstructuredgridwriter.impl.hh b/dune/vtk/writers/vtkstructuredgridwriter.impl.hh index 1cab9b5..61c69cb 100644 --- a/dune/vtk/writers/vtkstructuredgridwriter.impl.hh +++ b/dune/vtk/writers/vtkstructuredgridwriter.impl.hh @@ -14,7 +14,7 @@ #include <dune/vtk/utility/filesystem.hh> #include <dune/vtk/utility/string.hh> -namespace Dune { namespace experimental { +namespace Dune { template <class GV, class DC> void VtkStructuredGridWriter<GV,DC> @@ -170,4 +170,4 @@ void VtkStructuredGridWriter<GV,DC> out << "</VTKFile>"; } -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/writers/vtkunstructuredgridwriter.hh b/dune/vtk/writers/vtkunstructuredgridwriter.hh index 2616e01..4368d0b 100644 --- a/dune/vtk/writers/vtkunstructuredgridwriter.hh +++ b/dune/vtk/writers/vtkunstructuredgridwriter.hh @@ -11,7 +11,7 @@ #include "vtkwriterinterface.hh" -namespace Dune { namespace experimental +namespace Dune { /// File-Writer for VTK .vtu files /** @@ -67,6 +67,6 @@ namespace Dune { namespace experimental using Super::cellData_; }; -}} // end namespace Dune::experimental +} // end namespace Dune #include "vtkunstructuredgridwriter.impl.hh" diff --git a/dune/vtk/writers/vtkunstructuredgridwriter.impl.hh b/dune/vtk/writers/vtkunstructuredgridwriter.impl.hh index 4d34751..42769b6 100644 --- a/dune/vtk/writers/vtkunstructuredgridwriter.impl.hh +++ b/dune/vtk/writers/vtkunstructuredgridwriter.impl.hh @@ -14,7 +14,7 @@ #include <dune/vtk/utility/filesystem.hh> #include <dune/vtk/utility/string.hh> -namespace Dune { namespace experimental { +namespace Dune { template <class GV, class DC> void VtkUnstructuredGridWriter<GV,DC> @@ -234,4 +234,4 @@ std::array<std::uint64_t,3> VtkUnstructuredGridWriter<GV,DC> } -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/dune/vtk/writers/vtkwriterinterface.hh b/dune/vtk/writers/vtkwriterinterface.hh index aa65796..5f9d3d2 100644 --- a/dune/vtk/writers/vtkwriterinterface.hh +++ b/dune/vtk/writers/vtkwriterinterface.hh @@ -10,7 +10,7 @@ #include <dune/vtk/vtkfunction.hh> #include <dune/vtk/vtktypes.hh> -namespace Dune { namespace experimental +namespace Dune { /// File-Writer for Vtk .vtu files template <class GridView, class DataCollector> @@ -20,7 +20,7 @@ namespace Dune { namespace experimental protected: static constexpr int dimension = GridView::dimension; - using VtkFunction = Dune::experimental::VtkFunction<GridView>; + using VtkFunction = Dune::VtkFunction<GridView>; using pos_type = typename std::ostream::pos_type; enum PositionTypes { @@ -136,6 +136,6 @@ namespace Dune { namespace experimental int compression_level = -1; // in [0,9], -1 ... use default value }; -}} // end namespace Dune::experimental +} // end namespace Dune #include "vtkwriterinterface.impl.hh" diff --git a/dune/vtk/writers/vtkwriterinterface.impl.hh b/dune/vtk/writers/vtkwriterinterface.impl.hh index 353fb08..5b17a3c 100644 --- a/dune/vtk/writers/vtkwriterinterface.impl.hh +++ b/dune/vtk/writers/vtkwriterinterface.impl.hh @@ -18,7 +18,7 @@ #include <dune/vtk/utility/filesystem.hh> #include <dune/vtk/utility/string.hh> -namespace Dune { namespace experimental { +namespace Dune { template <class GV, class DC> void VtkWriterInterface<GV,DC> @@ -236,4 +236,4 @@ std::uint64_t VtkWriterInterface<GV,DC> return std::uint64_t(end_pos - begin_pos); } -}} // end namespace Dune::experimental +} // end namespace Dune diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0cd13b5..a50e8fc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,10 @@ add_executable("legacyvtkwriter" legacyvtkwriter.cc) target_link_dune_default_libraries("legacyvtkwriter") target_link_libraries("legacyvtkwriter" dunevtk) +add_executable("geometrygrid" geometrygrid.cc) +target_link_dune_default_libraries("geometrygrid") +target_link_libraries("geometrygrid" dunevtk) + if (dune-polygongrid_FOUND) add_executable("polygongrid" polygongrid.cc) target_link_dune_default_libraries("polygongrid") diff --git a/src/benchmark.cc b/src/benchmark.cc index 3f2cf8f..e1d731a 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -34,14 +34,14 @@ static TestCasesOld test_cases_old = { }; -using TestCasesNew = std::set<std::tuple<std::string,experimental::Vtk::FormatTypes,experimental::Vtk::DataTypes>>; +using TestCasesNew = std::set<std::tuple<std::string,Vtk::FormatTypes,Vtk::DataTypes>>; static TestCasesNew test_cases_new = { - {"ascii32", experimental::Vtk::ASCII, experimental::Vtk::FLOAT32}, - {"bin32", experimental::Vtk::BINARY, experimental::Vtk::FLOAT32}, - // {"zlib32", experimental::Vtk::COMPRESSED, experimental::Vtk::FLOAT32}, - // {"ascii64", experimental::Vtk::ASCII, experimental::Vtk::FLOAT64}, - // {"bin64", experimental::Vtk::BINARY, experimental::Vtk::FLOAT64}, - // {"zlib64", experimental::Vtk::COMPRESSED, experimental::Vtk::FLOAT64} + {"ascii32", Vtk::ASCII, Vtk::FLOAT32}, + {"bin32", Vtk::BINARY, Vtk::FLOAT32}, + // {"zlib32", Vtk::COMPRESSED, Vtk::FLOAT32}, + // {"ascii64", Vtk::ASCII, Vtk::FLOAT64}, + // {"bin64", Vtk::BINARY, Vtk::FLOAT64}, + // {"zlib64", Vtk::COMPRESSED, Vtk::FLOAT64} }; template <class GridView> @@ -61,7 +61,7 @@ template <class GridView> void writer_new (GridView const& gridView) { Timer t; - experimental::VtkUnstructuredGridWriter<GridView> vtkWriter(gridView); + VtkUnstructuredGridWriter<GridView> vtkWriter(gridView); for (auto const& test_case : test_cases_new) { t.reset(); vtkWriter.write("writer_new_" + std::get<0>(test_case) + ".vtu", diff --git a/src/datacollector.cc b/src/datacollector.cc index fed2887..5864a4f 100644 --- a/src/datacollector.cc +++ b/src/datacollector.cc @@ -27,7 +27,6 @@ #include <dune/vtk/datacollectors/quadraticdatacollector.hh> using namespace Dune; -using namespace Dune::experimental; using namespace Dune::Functions; template <class DataCollector, class GridView, class Fct1, class Fct2> diff --git a/src/geometrygrid.cc b/src/geometrygrid.cc new file mode 100644 index 0000000..0bb10c7 --- /dev/null +++ b/src/geometrygrid.cc @@ -0,0 +1,78 @@ +// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- +// vi: set et ts=4 sw=2 sts=2: + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <iostream> +#include <vector> + +#include <dune/common/parallel/mpihelper.hh> // An initializer of MPI +#include <dune/functions/functionspacebases/defaultglobalbasis.hh> +#include <dune/functions/functionspacebases/lagrangebasis.hh> +#include <dune/functions/gridfunctions/analyticgridviewfunction.hh> +#include <dune/grid/yaspgrid.hh> +#include <dune/grid/geometrygrid.hh> + +#include <dune/vtk/vtkwriter.hh> + +using namespace Dune; +using namespace Dune::Functions; + +class TorusMapper + : public AnalyticalCoordFunction<double, 2, 3, TorusMapper> +{ + using Super = AnalyticalCoordFunction<double, 2, 3, TorusMapper>; + +public: + using DomainVector = Super::DomainVector; + using RangeVector = Super::RangeVector; + + TorusMapper(double R, double r) + : R_(R), r_(r) {} + + void evaluate(DomainVector const& x, RangeVector& y) const + { + y[0] = (R_ + r_*std::cos(x[0])) * std::cos(x[1]); + y[1] = (R_ + r_*std::cos(x[0])) * std::sin(x[1]); + y[2] = r_*std::sin(x[0]); + } + +private: + double R_, r_; +}; + +template <class GridView> +void write (std::string prefix, GridView const& gridView) +{ + FieldVector<double,GridView::dimension> c; + if (GridView::dimension > 0) c[0] = 11.0; + if (GridView::dimension > 1) c[1] = 7.0; + if (GridView::dimension > 2) c[2] = 3.0; + + auto p1Analytic = makeAnalyticGridViewFunction([&c](auto const& x) { return c.dot(x); }, gridView); + + VtkWriter<GridView> vtkWriter(gridView); + vtkWriter.addPointData(p1Analytic, "q1"); + vtkWriter.addCellData(p1Analytic, "q0"); + vtkWriter.write(prefix + "_ascii.vtu", Vtk::ASCII, Vtk::FLOAT32); +} + +int main (int argc, char** argv) +{ + Dune::MPIHelper::instance(argc, argv); + + using HostGrid = YaspGrid<2>; + FieldVector<double,2> bbox = {2.0*M_PI, 2.0*M_PI}; + std::array num = {4, 12}; + HostGrid hostGrid{bbox, num}; //, std::bitset<2>{"11"}}; + + // grid build up of mapped coordinates + double R = 1.0, r = 0.25; + TorusMapper mapper{R,r}; + using Grid = GeometryGrid<HostGrid,TorusMapper>; + Grid grid{hostGrid, mapper}; + + write("torus", grid.leafGridView()); +} \ No newline at end of file diff --git a/src/legacyvtkwriter.cc b/src/legacyvtkwriter.cc index 52e2735..0ed25c6 100644 --- a/src/legacyvtkwriter.cc +++ b/src/legacyvtkwriter.cc @@ -24,7 +24,6 @@ #include <dune/vtk/legacyvtkfunction.hh> using namespace Dune; -using namespace Dune::experimental; using namespace Dune::Functions; int main(int argc, char** argv) diff --git a/src/polygongrid.cc b/src/polygongrid.cc index dcc1ff9..fd24fd3 100644 --- a/src/polygongrid.cc +++ b/src/polygongrid.cc @@ -24,7 +24,6 @@ #include <dune/vtk/vtkunstructuredgridwriter.hh> using namespace Dune; -using namespace Dune::experimental; using namespace Dune::Functions; using GridType = Dune::PolygonGrid<double>; diff --git a/src/structuredgridwriter.cc b/src/structuredgridwriter.cc index a331c4b..a8db430 100644 --- a/src/structuredgridwriter.cc +++ b/src/structuredgridwriter.cc @@ -28,7 +28,6 @@ #include <dune/vtk/datacollectors/spdatacollector.hh> using namespace Dune; -using namespace Dune::experimental; using namespace Dune::Functions; template <int dim> diff --git a/src/test/mixed_element_test.cc b/src/test/mixed_element_test.cc index 8293398..6b15247 100644 --- a/src/test/mixed_element_test.cc +++ b/src/test/mixed_element_test.cc @@ -21,7 +21,6 @@ #include <dune/vtk/writers/vtkunstructuredgridwriter.hh> using namespace Dune; -using namespace Dune::experimental; // see https://stackoverflow.com/questions/6163611/compare-two-files bool compare_files (std::string const& fn1, std::string const& fn2) diff --git a/src/test/reader_writer_test.cc b/src/test/reader_writer_test.cc index 0bb509e..d34cbd8 100644 --- a/src/test/reader_writer_test.cc +++ b/src/test/reader_writer_test.cc @@ -21,7 +21,6 @@ #include <dune/vtk/writers/vtkunstructuredgridwriter.hh> using namespace Dune; -using namespace Dune::experimental; // see https://stackoverflow.com/questions/6163611/compare-two-files bool compare_files (std::string const& fn1, std::string const& fn2) diff --git a/src/vtkreader.cc b/src/vtkreader.cc index f788716..b02fcee 100644 --- a/src/vtkreader.cc +++ b/src/vtkreader.cc @@ -19,7 +19,6 @@ #include <dune/vtk/writers/vtkunstructuredgridwriter.hh> using namespace Dune; -using namespace Dune::experimental; int main(int argc, char** argv) { diff --git a/src/vtkwriter.cc b/src/vtkwriter.cc index 001d0d3..b15b5ff 100644 --- a/src/vtkwriter.cc +++ b/src/vtkwriter.cc @@ -10,7 +10,6 @@ #include <dune/common/parallel/mpihelper.hh> // An initializer of MPI #include <dune/common/exceptions.hh> // We use exceptions -#include <dune/common/filledarray.hh> #include <dune/functions/functionspacebases/defaultglobalbasis.hh> #include <dune/functions/functionspacebases/lagrangebasis.hh> @@ -23,7 +22,6 @@ #include <dune/vtk/vtkwriter.hh> using namespace Dune; -using namespace Dune::experimental; using namespace Dune::Functions; using TestCases = std::set<std::tuple<std::string,Vtk::FormatTypes,Vtk::DataTypes>>; -- GitLab