Commit 4697fbe9 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Add deduction guides for readers and writers

parent 32ec234e
......@@ -26,5 +26,6 @@ install(FILES
add_subdirectory(datacollectors)
add_subdirectory(gridcreators)
add_subdirectory(test)
add_subdirectory(utility)
add_subdirectory(writers)
dune_add_test(SOURCES test-typededuction.cc
LINK_LIBRARIES dunevtk)
dune_add_test(SOURCES test-vtkwriter.cc
LINK_LIBRARIES dunevtk)
\ No newline at end of file
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#if HAVE_CONFIG_H
#include "config.h" // autoconf defines, needed by the dune headers
#endif
#include <dune/vtk/vtkreader.hh>
#include <dune/vtk/vtkwriter.hh>
#if HAVE_UG
#include <dune/grid/uggrid.hh>
using GridType = Dune::UGGrid<2>;
#else
#include <dune/grid/yaspgrid.hh>
using GridType = Dune::YaspGrid<2>;
#endif
#include <dune/grid/utility/structuredgridfactory.hh>
int main (int argc, char** argv)
{
using namespace Dune;
MPIHelper::instance(argc, argv);
auto grid = StructuredGridFactory<GridType>::createCubeGrid({0.0,0.0}, {1.0,2.0}, {2u,4u});
// 1. construct writer from gridView
VtkUnstructuredGridWriter writer1(grid->leafGridView());
// 2. construct writer from datacollector
ContinuousDataCollector dataCollector1(grid->leafGridView());
VtkUnstructuredGridWriter writer2(dataCollector1);
VtkUnstructuredGridWriter writer3(stackobject_to_shared_ptr(dataCollector1));
// 3. construct a default VtkWriter
VtkWriter writer4(grid->leafGridView());
// 4. construct reader from grid-factory
GridFactory<GridType> factory;
VtkReader reader1(factory);
// 5. construct reader from grid-creator
ContinuousGridCreator creator(factory);
VtkReader reader2(creator);
}
\ No newline at end of file
......@@ -18,6 +18,7 @@
#include <dune/grid/yaspgrid.hh>
#if HAVE_UG
#include <dune/grid/uggrid.hh>
#include <dune/grid/utility/structuredgridfactory.hh>
#endif
#include <dune/vtk/vtkwriter.hh>
......
......@@ -194,6 +194,21 @@ namespace Dune
std::uint64_t offset0_ = 0;
};
// deduction guides
template <class Grid>
VtkReader (GridFactory<Grid>&)
-> VtkReader<Grid, ContinuousGridCreator<Grid>>;
template <class GridCreator,
class = std::void_t<typename GridCreator::Grid>>
VtkReader (GridCreator&)
-> VtkReader<typename GridCreator::Grid, GridCreator>;
template <class GridCreator,
class = std::void_t<typename GridCreator::Grid>>
VtkReader (std::shared_ptr<GridCreator>)
-> VtkReader<typename GridCreator::Grid, GridCreator>;
} // end namespace Dune
#include "vtkreader.impl.hh"
......@@ -36,7 +36,20 @@ namespace Dune
* the concrete writer Implementation instead. \see VtkWriterInterface
**/
template <class GridView>
using VtkWriter = typename Impl::VtkWriterImpl<GridView, typename GridView::Grid>::type;
class VtkWriter
: public Impl::VtkWriterImpl<GridView, typename GridView::Grid>::type
{
using Super = typename Impl::VtkWriterImpl<GridView, typename GridView::Grid>::type;
public:
using Super::Super;
};
// deduction guide
template <class GridView,
class = std::void_t<typename GridView::IndexSet>>
VtkWriter (GridView const&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkWriter<GridView>;
namespace Impl
......
......@@ -9,5 +9,3 @@ install(FILES
vtkunstructuredgridwriter.hh
vtkunstructuredgridwriter.impl.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/vtkwriter/writers)
add_subdirectory(test)
\ No newline at end of file
dune_add_test(SOURCES test-vtkwriter.cc
LINK_LIBRARIES dunevtk)
\ No newline at end of file
......@@ -58,6 +58,22 @@ namespace Dune
using Super::cellData_;
};
// deduction guides
template <class GridView,
class = std::void_t<typename GridView::IndexSet>>
VtkImageDataWriter(GridView const&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkImageDataWriter<GridView, StructuredDataCollector<GridView>>;
template <class DataCollector,
class = std::void_t<typename DataCollector::GridView>>
VtkImageDataWriter(DataCollector&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkImageDataWriter<typename DataCollector::GridView, DataCollector>;
template <class DataCollector,
class = std::void_t<typename DataCollector::GridView>>
VtkImageDataWriter(std::shared_ptr<DataCollector>, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkImageDataWriter<typename DataCollector::GridView, DataCollector>;
} // end namespace Dune
#include "vtkimagedatawriter.impl.hh"
......@@ -64,6 +64,22 @@ namespace Dune
using Super::cellData_;
};
// deduction guides
template <class GridView,
class = std::void_t<typename GridView::IndexSet>>
VtkRectilinearGridWriter(GridView const&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkRectilinearGridWriter<GridView, StructuredDataCollector<GridView>>;
template <class DataCollector,
class = std::void_t<typename DataCollector::GridView>>
VtkRectilinearGridWriter(DataCollector&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkRectilinearGridWriter<typename DataCollector::GridView, DataCollector>;
template <class DataCollector,
class = std::void_t<typename DataCollector::GridView>>
VtkRectilinearGridWriter(std::shared_ptr<DataCollector>, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkRectilinearGridWriter<typename DataCollector::GridView, DataCollector>;
} // end namespace Dune
#include "vtkrectilineargridwriter.impl.hh"
......@@ -58,6 +58,22 @@ namespace Dune
using Super::cellData_;
};
// deduction guides
template <class GridView,
class = std::void_t<typename GridView::IndexSet>>
VtkStructuredGridWriter(GridView const&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkStructuredGridWriter<GridView, StructuredDataCollector<GridView>>;
template <class DataCollector,
class = std::void_t<typename DataCollector::GridView>>
VtkStructuredGridWriter(DataCollector&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkStructuredGridWriter<typename DataCollector::GridView, DataCollector>;
template <class DataCollector,
class = std::void_t<typename DataCollector::GridView>>
VtkStructuredGridWriter(std::shared_ptr<DataCollector>, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkStructuredGridWriter<typename DataCollector::GridView, DataCollector>;
} // end namespace Dune
#include "vtkstructuredgridwriter.impl.hh"
......@@ -90,7 +90,19 @@ namespace Dune
using Super::cellData_;
};
template <class DataCollector>
// deduction guides
template <class GridView,
class = std::void_t<typename GridView::IndexSet>>
VtkUnstructuredGridWriter(GridView const&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkUnstructuredGridWriter<GridView, ContinuousDataCollector<GridView>>;
template <class DataCollector,
class = std::void_t<typename DataCollector::GridView>>
VtkUnstructuredGridWriter(DataCollector&, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkUnstructuredGridWriter<typename DataCollector::GridView, DataCollector>;
template <class DataCollector,
class = std::void_t<typename DataCollector::GridView>>
VtkUnstructuredGridWriter(std::shared_ptr<DataCollector>, Vtk::FormatTypes = Vtk::BINARY, Vtk::DataTypes = Vtk::FLOAT32)
-> VtkUnstructuredGridWriter<typename DataCollector::GridView, DataCollector>;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment