From f3f789631240882730ecc55e32cd52350a53f80f Mon Sep 17 00:00:00 2001 From: Simon Praetorius <simon.praetorius@tu-dresden.de> Date: Wed, 4 Mar 2020 14:46:45 +0100 Subject: [PATCH] added missing includes --- dune.module | 4 ++-- dune/vtk/datacollectorinterface.hh | 2 +- dune/vtk/defaultvtkfunction.hh | 3 ++- dune/vtk/filereader.hh | 2 ++ dune/vtk/filewriter.hh | 2 +- dune/vtk/vtkfunction.hh | 5 +++-- dune/vtk/vtklocalfunction.hh | 18 +++++++++++++++--- dune/vtk/vtklocalfunctioninterface.hh | 3 ++- dune/vtk/vtkreader.hh | 5 +++-- dune/vtk/vtktimeserieswriter.hh | 3 ++- dune/vtk/vtkwriterinterface.hh | 3 +++ src/test/CMakeLists.txt | 3 +-- 12 files changed, 37 insertions(+), 16 deletions(-) diff --git a/dune.module b/dune.module index 4c1f8ee..e318f46 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 d60677d..c815b6a 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 bb6351a..32a0222 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 ff7e36c..77c40b9 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 3760185..5a8472b 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 db66f60..d745da6 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 faf8309..e636b0b 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 d1d047c..9ba2afe 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 92aefb0..c92bc82 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 d3f881e..83a3d4c 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 e35fb48..877d760 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 86a7f5f..f07379b 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) -- GitLab