From 13ce7b24f86692d19c4a96672a3766338bc56ec6 Mon Sep 17 00:00:00 2001 From: Simon Praetorius <simon.praetorius@tu-dresden.de> Date: Sat, 1 Sep 2018 14:46:19 +0200 Subject: [PATCH] cleanup pvdwriter interface --- dune/vtk/pvdwriter.hh | 2 +- dune/vtk/pvdwriter.impl.hh | 2 +- dune/vtk/vtktimeserieswriter.hh | 6 +++--- dune/vtk/vtktimeserieswriter.impl.hh | 1 + src/pvdwriter.cc | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dune/vtk/pvdwriter.hh b/dune/vtk/pvdwriter.hh index a752176..c5345b4 100644 --- a/dune/vtk/pvdwriter.hh +++ b/dune/vtk/pvdwriter.hh @@ -29,7 +29,7 @@ namespace Dune } /// Write the attached data to the file - void write (double time, std::string const& fn) const; + void writeTimestep (double time, std::string const& fn) const; /// Attach point data to the writer, \see VtkFunction for possible arguments template <class Function, class... Args> diff --git a/dune/vtk/pvdwriter.impl.hh b/dune/vtk/pvdwriter.impl.hh index fd43b80..669a894 100644 --- a/dune/vtk/pvdwriter.impl.hh +++ b/dune/vtk/pvdwriter.impl.hh @@ -9,7 +9,7 @@ namespace Dune { template <class W> void PvdWriter<W> - ::write (double time, std::string const& fn) const + ::writeTimestep (double time, std::string const& fn) const { auto p = filesystem::path(fn); auto name = p.stem(); diff --git a/dune/vtk/vtktimeserieswriter.hh b/dune/vtk/vtktimeserieswriter.hh index da15804..13e8507 100644 --- a/dune/vtk/vtktimeserieswriter.hh +++ b/dune/vtk/vtktimeserieswriter.hh @@ -53,7 +53,7 @@ namespace Dune } /// Write the attached data to the file with \ref Vtk::FormatTypes and \ref Vtk::DataTypes - void writeTimestep (double time, std::string const& fn); + void writeTimestep (double time, std::string const& fn) const; /// Writes all timesteps to single timeseries file. // NOTE: requires an aforging call to \ref writeTimestep @@ -79,10 +79,10 @@ namespace Dune VtkWriter vtkWriter_; filesystem::path tmpDir_; - bool initialized_ = false; + mutable bool initialized_ = false; // block size of attached data - std::vector<std::uint64_t> blocks_; + mutable std::vector<std::uint64_t> blocks_; mutable std::string filenameMesh_; mutable std::vector<std::pair<double, std::string>> timesteps_; diff --git a/dune/vtk/vtktimeserieswriter.impl.hh b/dune/vtk/vtktimeserieswriter.impl.hh index 3b886ec..4e53490 100644 --- a/dune/vtk/vtktimeserieswriter.impl.hh +++ b/dune/vtk/vtktimeserieswriter.impl.hh @@ -118,6 +118,7 @@ void VtkTimeseriesWriter<W> assert(ec == 0); } timesteps_.clear(); + initialized_ = false; } } // end namespace Dune diff --git a/src/pvdwriter.cc b/src/pvdwriter.cc index 7d35be6..2c466ed 100644 --- a/src/pvdwriter.cc +++ b/src/pvdwriter.cc @@ -44,7 +44,7 @@ void write (std::string prefix, GridView const& gridView) pvdWriter.addPointData(p1Analytic, "p1"); pvdWriter.addCellData(p1Analytic, "p0"); for (double t = 0.0; t < 10.0; t += 1.0) { - pvdWriter.write(t, prefix + "_" + std::to_string(GridView::dimensionworld) + "d_ascii.vtu"); + pvdWriter.writeTimestep(t, prefix + "_" + std::to_string(GridView::dimensionworld) + "d_ascii.vtu"); } } -- GitLab