diff --git a/dune.module b/dune.module index 4c1f8ee87949d93700f079752e9e5b0bafaa798a..e318f4687ba6fbb3e5fbaceb529d543eaf381bee 100644 --- a/dune.module +++ b/dune.module @@ -7,5 +7,5 @@ Module: dune-vtk Version: 0.2 Maintainer: simon.praetorius@tu-dresden.de #depending on -Depends: dune-common (>= 2.6) dune-geometry (>= 2.6) dune-grid -Suggests: dune-functions dune-spgrid dune-polygongrid dune-uggrid dune-alugrid +Depends: dune-common (>= 2.6) dune-geometry (>= 2.6) dune-grid dune-uggrid +Suggests: dune-functions dune-spgrid dune-polygongrid dune-alugrid diff --git a/dune/vtk/datacollectorinterface.hh b/dune/vtk/datacollectorinterface.hh index d60677d347b2205e00c72a08fda864437715789a..c815b6a4bd5b7c9a7494df7f0792a38d993cae5c 100644 --- a/dune/vtk/datacollectorinterface.hh +++ b/dune/vtk/datacollectorinterface.hh @@ -85,7 +85,7 @@ namespace Dune /// \brief Return a flat vector of function values evaluated at the cells in the order of traversal. /** * \see pointData. - * Note: Cells might be descibred explicitly by connectivity, offsets, and types, e.g. in + * Note: Cells might be described explicitly by connectivity, offsets, and types, e.g. in * an UnstructuredGrid, or might be described implicitly by the grid type, e.g. in * StructuredGrid. */ diff --git a/dune/vtk/defaultvtkfunction.hh b/dune/vtk/defaultvtkfunction.hh index bb6351a857db93737327ee762ec30e501247ceed..32a02225e906ef974bdcd37789d4be0ed2fdb5ed 100644 --- a/dune/vtk/defaultvtkfunction.hh +++ b/dune/vtk/defaultvtkfunction.hh @@ -24,7 +24,8 @@ namespace Dune public: /// Constructor. Stores a copy of the passed `localFct` in a local variable. - template <class LocalFct, disableCopyMove<Self, LocalFct> = 0> + template <class LocalFct, + disableCopyMove<Self, LocalFct> = 0> LocalFunctionWrapper (LocalFct&& localFct) : localFct_(std::forward<LocalFct>(localFct)) {} diff --git a/dune/vtk/filereader.hh b/dune/vtk/filereader.hh index ff7e36ccad09cdde75d4f4a9883f781d27eb4ff7..77c40b978f15d873dcf6896073c0b8cc24c07596 100644 --- a/dune/vtk/filereader.hh +++ b/dune/vtk/filereader.hh @@ -4,6 +4,8 @@ #include <string> #include <utility> +#include <dune/common/exceptions.hh> +#include <dune/grid/common/gridfactory.hh> #include <dune/vtk/forward.hh> namespace Dune diff --git a/dune/vtk/filewriter.hh b/dune/vtk/filewriter.hh index 376018506398c6b41afcd10380821db52cbf37b7..5a8472bc33f7ee9dc7d9de82857ef6a2b80643dc 100644 --- a/dune/vtk/filewriter.hh +++ b/dune/vtk/filewriter.hh @@ -1,8 +1,8 @@ #pragma once #include <string> -#include <dune/common/std/optional.hh> +#include <dune/common/std/optional.hh> #include <dune/vtk/forward.hh> namespace Dune diff --git a/dune/vtk/vtkfunction.hh b/dune/vtk/vtkfunction.hh index db66f60ed34eaa8c7fc562d9142626c4451970ed..d745da6e755b1dce3c3a5453361501983b7086cc 100644 --- a/dune/vtk/vtkfunction.hh +++ b/dune/vtk/vtkfunction.hh @@ -71,7 +71,7 @@ namespace Dune * GridFunction if not given. **/ template <class F, - std::enable_if_t<Std::is_detected<HasLocalFunction,F>::value, int> = 0> + class = void_t<HasLocalFunction<F>> > VtkFunction (F&& fct, std::string name, Std::optional<int> ncomps = {}, Std::optional<Vtk::DataTypes> type = {}) @@ -84,8 +84,9 @@ namespace Dune type_ = type ? *type : Vtk::Map::type<R>(); } + /// Constructor that forward the number of components and data type to the other constructor template <class F, - std::enable_if_t<Std::is_detected<HasLocalFunction,F>::value, int> = 0> + class = void_t<HasLocalFunction<F>> > VtkFunction (F&& fct, Vtk::FieldInfo fieldInfo, Std::optional<Vtk::DataTypes> type = {}) : VtkFunction(std::forward<F>(fct), fieldInfo.name(), fieldInfo.ncomps(), type) diff --git a/dune/vtk/vtklocalfunction.hh b/dune/vtk/vtklocalfunction.hh index faf8309daf959335c95ba976df0f2415f4ad41fa..e636b0b4396adb03db94ab4366227ed35cce7c3d 100644 --- a/dune/vtk/vtklocalfunction.hh +++ b/dune/vtk/vtklocalfunction.hh @@ -11,6 +11,11 @@ namespace Dune { + /// \brief A VtkLocalFunction is a function-like object that can be bound to a grid element + /// an that provides an evaluate method with a component argument. + /** + * Stores internally a VtkLocalFunctionInterface object for the concrete evaluation. + **/ template <class GridView> class VtkLocalFunction { @@ -22,38 +27,45 @@ namespace Dune using HasBind = decltype(std::declval<LF>().bind(std::declval<E>())); public: - template <class LF, disableCopyMove<Self, LF> = 0, - std::enable_if_t<Std::is_detected<HasBind,LF,Entity>::value, int> = 0> + /// Construct the VtkLocalFunction from any function object that has a bind(element) method. + template <class LF, + disableCopyMove<Self, LF> = 0, + class = void_t<HasBind<LF,Entity>> > VtkLocalFunction (LF&& lf) : localFct_(std::make_shared<LocalFunctionWrapper<GridView,LF>>(std::forward<LF>(lf))) {} + /// Construct a VtkLocalFunction from a legacy VTKFunction VtkLocalFunction (std::shared_ptr<VTKFunction<GridView> const> const& lf) : localFct_(std::make_shared<VTKLocalFunctionWrapper<GridView>>(lf)) {} + /// Allow the default construction of a VtkLocalFunction VtkLocalFunction () = default; /// Bind the function to the grid entity void bind (Entity const& entity) { + assert(bool(localFct_)); localFct_->bind(entity); } /// Unbind from the currently bound entity void unbind () { + assert(bool(localFct_)); localFct_->unbind(); } /// Evaluate the `comp` component of the Range value at local coordinate `xi` double evaluate (int comp, LocalCoordinate const& xi) const { + assert(bool(localFct_)); return localFct_->evaluate(comp, xi); } private: - std::shared_ptr<VtkLocalFunctionInterface<GridView>> localFct_; + std::shared_ptr<VtkLocalFunctionInterface<GridView>> localFct_ = nullptr; }; } // end namespace Dune diff --git a/dune/vtk/vtklocalfunctioninterface.hh b/dune/vtk/vtklocalfunctioninterface.hh index d1d047c7dc2c6803e67d9a9359b55c83f031404d..9ba2afeccea47eb143edfab28d2d84e35cd0bc1e 100644 --- a/dune/vtk/vtklocalfunctioninterface.hh +++ b/dune/vtk/vtklocalfunctioninterface.hh @@ -2,7 +2,8 @@ namespace Dune { - /// An abstract base class for LocalFunctions + /// \brief An abstract base class for LocalFunctions that can be bound to an element and + /// evaluated in local coordinates w.r.t. to a component of its value. template <class GridView> class VtkLocalFunctionInterface { diff --git a/dune/vtk/vtkreader.hh b/dune/vtk/vtkreader.hh index 92aefb084590fc8033c61d0120ffa1e0888e24d5..c92bc8210f2f7aeee692c38efe719bf53e68dd34 100644 --- a/dune/vtk/vtkreader.hh +++ b/dune/vtk/vtkreader.hh @@ -5,6 +5,7 @@ #include <memory> #include <vector> +#include <dune/common/shared_ptr.hh> #include <dune/common/typeutilities.hh> #include <dune/vtk/filereader.hh> @@ -94,7 +95,7 @@ namespace Dune /// Construct a grid using the GridCreator // NOTE: requires the internal data structures to be filled by an aforgoing call to readFromFile - void createGrid(bool insertPieces = true); + void createGrid (bool insertPieces = true); /// @} @@ -151,7 +152,7 @@ namespace Dune std::uint64_t findAppendedDataPosition (std::ifstream& input) const; // Read attributes from current xml tag - std::map<std::string, std::string> parseXml(std::string const& line, bool& closed); + std::map<std::string, std::string> parseXml (std::string const& line, bool& closed); // clear all vectors void clear (); diff --git a/dune/vtk/vtktimeserieswriter.hh b/dune/vtk/vtktimeserieswriter.hh index d3f881ea599d5bdd15e1b46432d851d06473b44d..83a3d4cf539a6d2ead06f6ed0d12f8675c3c61aa 100644 --- a/dune/vtk/vtktimeserieswriter.hh +++ b/dune/vtk/vtktimeserieswriter.hh @@ -39,7 +39,8 @@ namespace Dune public: /// Constructor, stores the gridView - template <class... Args, disableCopyMove<Self, Args...> = 0> + template <class... Args, + disableCopyMove<Self, Args...> = 0> VtkTimeseriesWriter (Args&&... args) : vtkWriter_{std::forward<Args>(args)...} { diff --git a/dune/vtk/vtkwriterinterface.hh b/dune/vtk/vtkwriterinterface.hh index e35fb484101f16623828962370fc1ad5c899d43c..877d7603d85821626e2645ab53c72c9f6a124c5e 100644 --- a/dune/vtk/vtkwriterinterface.hh +++ b/dune/vtk/vtkwriterinterface.hh @@ -46,6 +46,9 @@ namespace Dune * DataCollector that is used to collect point coordinates, cell connectivity and * data values. * + * This constructor assumes, that the DataCollector can be constructed from a single argument, + * the passed gridView. + * * \param gridView Implementation of Dune::GridView * \param format Format of the VTK file, either Vtk::BINARY, Vtk::ASCII, or Vtk::COMPRESSED * \param datatype Output datatype used for coordinates and other global floating point values diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 86a7f5ffc9fc24f93e4f94656353a139d211aa60..f07379b490af348d49610972beb737b1cabd9243 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -5,5 +5,4 @@ dune_add_test(SOURCES parallel_reader_writer_test.cc LINK_LIBRARIES dunevtk) dune_add_test(SOURCES mixed_element_test.cc - LINK_LIBRARIES dunevtk - CMAKE_GUARD HAVE_UG) \ No newline at end of file + LINK_LIBRARIES dunevtk)