Commit 7a18a879 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'feature/cleanup_stdcxx17' into 'master'

replace Dune::Std::optional with std::optional

See merge request spraetor/dune-vtk!23
parents 9d6d4bc5 28967950
#pragma once #pragma once
#include <optional>
#include <string> #include <string>
#include <dune/common/std/optional.hh>
#include <dune/vtk/forward.hh> #include <dune/vtk/forward.hh>
namespace Dune namespace Dune
...@@ -14,7 +14,7 @@ namespace Dune ...@@ -14,7 +14,7 @@ namespace Dune
virtual ~FileWriter () = default; virtual ~FileWriter () = default;
/// Write to file given by `filename` and (optionally) store additional data in `dataDir` /// Write to file given by `filename` and (optionally) store additional data in `dataDir`
virtual std::string write (std::string const& filename, Std::optional<std::string> dataDir = {}) const = 0; virtual std::string write (std::string const& filename, std::optional<std::string> dataDir = {}) const = 0;
}; };
} // end namespace Dune } // end namespace Dune
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
#include <cassert> #include <cassert>
#include <cstdint> #include <cstdint>
#include <limits> #include <limits>
#include <optional>
#include <vector> #include <vector>
#include <dune/common/exceptions.hh> #include <dune/common/exceptions.hh>
#include <dune/common/hybridutilities.hh> #include <dune/common/hybridutilities.hh>
#include <dune/common/std/optional.hh>
#include <dune/geometry/utility/typefromvertexcount.hh> #include <dune/geometry/utility/typefromvertexcount.hh>
#include <dune/localfunctions/lagrange.hh> #include <dune/localfunctions/lagrange.hh>
#include <dune/grid/common/gridfactory.hh> #include <dune/grid/common/gridfactory.hh>
...@@ -297,7 +297,7 @@ namespace Dune ...@@ -297,7 +297,7 @@ namespace Dune
private: private:
LocalFE localFE_; LocalFE localFE_;
std::vector<GlobalCoordinate> localNodes_; std::vector<GlobalCoordinate> localNodes_;
Std::optional<LocalGeometry> localGeometry_; std::optional<LocalGeometry> localGeometry_;
mutable std::vector<typename LocalBasisTraits::RangeType> shapeValues_; mutable std::vector<typename LocalBasisTraits::RangeType> shapeValues_;
}; };
...@@ -343,7 +343,7 @@ namespace Dune ...@@ -343,7 +343,7 @@ namespace Dune
LagrangeGridCreator const* gridCreator_; LagrangeGridCreator const* gridCreator_;
LocalContext localContext_; LocalContext localContext_;
Std::optional<LocalParametrization> localParametrization_; std::optional<LocalParametrization> localParametrization_;
}; };
} // end namespace Dune } // end namespace Dune
#pragma once #pragma once
#include <iosfwd> #include <iosfwd>
#include <optional>
#include <string> #include <string>
#include <vector> #include <vector>
#include <tuple> #include <tuple>
#include <dune/common/std/optional.hh>
#include <dune/vtk/vtktypes.hh> #include <dune/vtk/vtktypes.hh>
#include <dune/vtk/filewriter.hh> #include <dune/vtk/filewriter.hh>
#include <dune/vtk/forward.hh> #include <dune/vtk/forward.hh>
...@@ -42,7 +41,7 @@ namespace Dune ...@@ -42,7 +41,7 @@ namespace Dune
* \param dir Specifies where to write the timestep files. * \param dir Specifies where to write the timestep files.
* \param writeCollection Create a collection .pvd file directly * \param writeCollection Create a collection .pvd file directly
**/ **/
void writeTimestep (double time, std::string const& fn, Std::optional<std::string> dir = {}, void writeTimestep (double time, std::string const& fn, std::optional<std::string> dir = {},
bool writeCollection = true) const; bool writeCollection = true) const;
/// \brief Writes collection of timesteps to .pvd file. /// \brief Writes collection of timesteps to .pvd file.
...@@ -52,7 +51,7 @@ namespace Dune ...@@ -52,7 +51,7 @@ namespace Dune
* \param dir (Ignored) Timestep files are already written and their filenames are * \param dir (Ignored) Timestep files are already written and their filenames are
* stored in \ref timesteps_. * stored in \ref timesteps_.
**/ **/
virtual std::string write (std::string const& fn, Std::optional<std::string> dir = {}) const override; virtual std::string write (std::string const& fn, std::optional<std::string> dir = {}) const override;
/// Attach point data to the writer, \see VtkFunction for possible arguments /// Attach point data to the writer, \see VtkFunction for possible arguments
template <class Function, class... Args> template <class Function, class... Args>
......
...@@ -10,7 +10,7 @@ namespace Dune { ...@@ -10,7 +10,7 @@ namespace Dune {
template <class W> template <class W>
void PvdWriter<W> void PvdWriter<W>
::writeTimestep (double time, std::string const& fn, Std::optional<std::string> dir, bool writeCollection) const ::writeTimestep (double time, std::string const& fn, std::optional<std::string> dir, bool writeCollection) const
{ {
auto p = filesystem::path(fn); auto p = filesystem::path(fn);
auto name = p.stem(); auto name = p.stem();
...@@ -50,7 +50,7 @@ void PvdWriter<W> ...@@ -50,7 +50,7 @@ void PvdWriter<W>
template <class W> template <class W>
std::string PvdWriter<W> std::string PvdWriter<W>
::write (std::string const& fn, Std::optional<std::string> /*dir*/) const ::write (std::string const& fn, std::optional<std::string> /*dir*/) const
{ {
auto p = filesystem::path(fn); auto p = filesystem::path(fn);
auto name = p.stem(); auto name = p.stem();
......
#pragma once #pragma once
#include <optional>
#include <type_traits> #include <type_traits>
#include <dune/common/std/optional.hh>
#include <dune/common/std/type_traits.hh> #include <dune/common/std/type_traits.hh>
#include "vtklocalfunction.hh" #include "vtklocalfunction.hh"
...@@ -52,7 +52,7 @@ namespace Dune ...@@ -52,7 +52,7 @@ namespace Dune
* \param type The VTK datatype how to write the function values to the output [Vtk::FLOAT64] * \param type The VTK datatype how to write the function values to the output [Vtk::FLOAT64]
**/ **/
VtkFunction (std::shared_ptr<VTKFunction<GridView> const> const& fct, VtkFunction (std::shared_ptr<VTKFunction<GridView> const> const& fct,
Std::optional<Vtk::DataTypes> type = {}) std::optional<Vtk::DataTypes> type = {})
: localFct_(fct) : localFct_(fct)
, name_(fct->name()) , name_(fct->name())
, ncomps_(fct->ncomps()) , ncomps_(fct->ncomps())
...@@ -73,8 +73,8 @@ namespace Dune ...@@ -73,8 +73,8 @@ namespace Dune
template <class F, template <class F,
class = void_t<LocalFunction<F>> > class = void_t<LocalFunction<F>> >
VtkFunction (F&& fct, std::string name, VtkFunction (F&& fct, std::string name,
Std::optional<int> ncomps = {}, std::optional<int> ncomps = {},
Std::optional<Vtk::DataTypes> type = {}) std::optional<Vtk::DataTypes> type = {})
: localFct_(localFunction(std::forward<F>(fct))) : localFct_(localFunction(std::forward<F>(fct)))
, name_(std::move(name)) , name_(std::move(name))
{ {
...@@ -88,7 +88,7 @@ namespace Dune ...@@ -88,7 +88,7 @@ namespace Dune
template <class F, template <class F,
class = void_t<LocalFunction<F>> > class = void_t<LocalFunction<F>> >
VtkFunction (F&& fct, Vtk::FieldInfo fieldInfo, VtkFunction (F&& fct, Vtk::FieldInfo fieldInfo,
Std::optional<Vtk::DataTypes> type = {}) std::optional<Vtk::DataTypes> type = {})
: VtkFunction(std::forward<F>(fct), fieldInfo.name(), fieldInfo.ncomps(), type) : VtkFunction(std::forward<F>(fct), fieldInfo.name(), fieldInfo.ncomps(), type)
{} {}
......
#pragma once #pragma once
#include <cassert> #include <cassert>
#include <optional>
#include <string> #include <string>
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include <dune/common/std/optional.hh>
#include <dune/vtk/filewriter.hh> #include <dune/vtk/filewriter.hh>
#include <dune/vtk/forward.hh> #include <dune/vtk/forward.hh>
#include <dune/vtk/vtktypes.hh> #include <dune/vtk/vtktypes.hh>
...@@ -66,7 +65,7 @@ namespace Dune ...@@ -66,7 +65,7 @@ namespace Dune
* \param writeCollection Create a timeseries file directly * \param writeCollection Create a timeseries file directly
**/ **/
void writeTimestep (double time, std::string const& fn, void writeTimestep (double time, std::string const& fn,
Std::optional<std::string> tmpDir = {}, std::optional<std::string> tmpDir = {},
bool writeCollection = true) const; bool writeCollection = true) const;
/// Writes all timesteps to single timeseries file. /// Writes all timesteps to single timeseries file.
...@@ -79,7 +78,7 @@ namespace Dune ...@@ -79,7 +78,7 @@ namespace Dune
* *
* \returns File name of the actual written file * \returns File name of the actual written file
**/ **/
virtual std::string write (std::string const& fn, Std::optional<std::string> dir = {}) const override; virtual std::string write (std::string const& fn, std::optional<std::string> dir = {}) const override;
/// Attach point data to the writer, \see VtkFunction for possible arguments /// Attach point data to the writer, \see VtkFunction for possible arguments
template <class Function, class... Args> template <class Function, class... Args>
......
...@@ -39,7 +39,7 @@ VtkTimeseriesWriter<W>::~VtkTimeseriesWriter () ...@@ -39,7 +39,7 @@ VtkTimeseriesWriter<W>::~VtkTimeseriesWriter ()
template <class W> template <class W>
void VtkTimeseriesWriter<W> void VtkTimeseriesWriter<W>
::writeTimestep (double time, std::string const& fn, Std::optional<std::string> tmpDir, bool writeCollection) const ::writeTimestep (double time, std::string const& fn, std::optional<std::string> tmpDir, bool writeCollection) const
{ {
auto name = filesystem::path(fn).stem(); auto name = filesystem::path(fn).stem();
auto tmpBase = tmpDir ? filesystem::path(*tmpDir) : tmpDir_; auto tmpBase = tmpDir ? filesystem::path(*tmpDir) : tmpDir_;
...@@ -75,7 +75,7 @@ void VtkTimeseriesWriter<W> ...@@ -75,7 +75,7 @@ void VtkTimeseriesWriter<W>
template <class W> template <class W>
std::string VtkTimeseriesWriter<W> std::string VtkTimeseriesWriter<W>
::write (std::string const& fn, Std::optional<std::string> dir) const ::write (std::string const& fn, std::optional<std::string> dir) const
{ {
assert( initialized_ ); assert( initialized_ );
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
#include <iosfwd> #include <iosfwd>
#include <map> #include <map>
#include <memory> #include <memory>
#include <optional>
#include <string> #include <string>
#include <vector> #include <vector>
#include <dune/common/parallel/mpihelper.hh> #include <dune/common/parallel/mpihelper.hh>
#include <dune/common/std/optional.hh>
#include <dune/vtk/filewriter.hh> #include <dune/vtk/filewriter.hh>
#include <dune/vtk/forward.hh> #include <dune/vtk/forward.hh>
#include <dune/vtk/vtkfunction.hh> #include <dune/vtk/vtkfunction.hh>
...@@ -84,7 +84,7 @@ namespace Dune ...@@ -84,7 +84,7 @@ namespace Dune
* *
* \returns File name that is actually written. * \returns File name that is actually written.
**/ **/
virtual std::string write (std::string const& fn, Std::optional<std::string> dir = {}) const override; virtual std::string write (std::string const& fn, std::optional<std::string> dir = {}) const override;
/// \brief Attach point data to the writer /// \brief Attach point data to the writer
/** /**
...@@ -158,7 +158,7 @@ namespace Dune ...@@ -158,7 +158,7 @@ namespace Dune
std::vector<pos_type>& offsets, std::vector<pos_type>& offsets,
VtkFunction const& fct, VtkFunction const& fct,
PositionTypes type, PositionTypes type,
Std::optional<std::size_t> timestep = {}) const; std::optional<std::size_t> timestep = {}) const;
// Write point-data and cell-data in raw/compressed format to output stream // Write point-data and cell-data in raw/compressed format to output stream
void writeDataAppended (std::ofstream& out, std::vector<std::uint64_t>& blocks) const; void writeDataAppended (std::ofstream& out, std::vector<std::uint64_t>& blocks) const;
...@@ -168,7 +168,7 @@ namespace Dune ...@@ -168,7 +168,7 @@ namespace Dune
// vector `offsets`. // vector `offsets`.
void writePoints (std::ofstream& out, void writePoints (std::ofstream& out,
std::vector<pos_type>& offsets, std::vector<pos_type>& offsets,
Std::optional<std::size_t> timestep = {}) const; std::optional<std::size_t> timestep = {}) const;
// Write Appended section and fillin offset values to XML attributes // Write Appended section and fillin offset values to XML attributes
void writeAppended (std::ofstream& out, std::vector<pos_type> const& offsets) const; void writeAppended (std::ofstream& out, std::vector<pos_type> const& offsets) const;
......
...@@ -24,7 +24,7 @@ namespace Dune { ...@@ -24,7 +24,7 @@ namespace Dune {
template <class GV, class DC> template <class GV, class DC>
std::string VtkWriterInterface<GV,DC> std::string VtkWriterInterface<GV,DC>
::write (std::string const& fn, Std::optional<std::string> dir) const ::write (std::string const& fn, std::optional<std::string> dir) const
{ {
dataCollector_->update(); dataCollector_->update();
...@@ -80,7 +80,7 @@ template <class GV, class DC> ...@@ -80,7 +80,7 @@ template <class GV, class DC>
void VtkWriterInterface<GV,DC> void VtkWriterInterface<GV,DC>
::writeData (std::ofstream& out, std::vector<pos_type>& offsets, ::writeData (std::ofstream& out, std::vector<pos_type>& offsets,
VtkFunction const& fct, PositionTypes type, VtkFunction const& fct, PositionTypes type,
Std::optional<std::size_t> timestep) const std::optional<std::size_t> timestep) const
{ {
out << "<DataArray Name=\"" << fct.name() << "\" type=\"" << to_string(fct.type()) << "\"" out << "<DataArray Name=\"" << fct.name() << "\" type=\"" << to_string(fct.type()) << "\""
<< " NumberOfComponents=\"" << fct.ncomps() << "\" format=\"" << (format_ == Vtk::ASCII ? "ascii\"" : "appended\""); << " NumberOfComponents=\"" << fct.ncomps() << "\" format=\"" << (format_ == Vtk::ASCII ? "ascii\"" : "appended\"");
...@@ -106,7 +106,7 @@ void VtkWriterInterface<GV,DC> ...@@ -106,7 +106,7 @@ void VtkWriterInterface<GV,DC>
template <class GV, class DC> template <class GV, class DC>
void VtkWriterInterface<GV,DC> void VtkWriterInterface<GV,DC>
::writePoints (std::ofstream& out, std::vector<pos_type>& offsets, ::writePoints (std::ofstream& out, std::vector<pos_type>& offsets,
Std::optional<std::size_t> timestep) const std::optional<std::size_t> timestep) const
{ {
out << "<DataArray type=\"" << to_string(datatype_) << "\"" out << "<DataArray type=\"" << to_string(datatype_) << "\""
<< " NumberOfComponents=\"3\" format=\"" << (format_ == Vtk::ASCII ? "ascii\"" : "appended\""); << " NumberOfComponents=\"3\" format=\"" << (format_ == Vtk::ASCII ? "ascii\"" : "appended\"");
......
...@@ -42,7 +42,7 @@ namespace Dune ...@@ -42,7 +42,7 @@ namespace Dune
virtual void writeParallelFile (std::ofstream& out, std::string const& pfilename, int size) const override; virtual void writeParallelFile (std::ofstream& out, std::string const& pfilename, int size) const override;
void writeCoordinates (std::ofstream& out, std::vector<pos_type>& offsets, void writeCoordinates (std::ofstream& out, std::vector<pos_type>& offsets,
Std::optional<std::size_t> timestep = {}) const; std::optional<std::size_t> timestep = {}) const;
template <class T> template <class T>
std::array<std::uint64_t, 3> writeCoordinatesAppended (std::ofstream& out) const; std::array<std::uint64_t, 3> writeCoordinatesAppended (std::ofstream& out) const;
......
...@@ -116,7 +116,7 @@ void VtkRectilinearGridWriter<GV,DC> ...@@ -116,7 +116,7 @@ void VtkRectilinearGridWriter<GV,DC>
template <class GV, class DC> template <class GV, class DC>
void VtkRectilinearGridWriter<GV,DC> void VtkRectilinearGridWriter<GV,DC>
::writeCoordinates (std::ofstream& out, std::vector<pos_type>& offsets, ::writeCoordinates (std::ofstream& out, std::vector<pos_type>& offsets,
Std::optional<std::size_t> timestep) const std::optional<std::size_t> timestep) const
{ {
std::string names = "xyz"; std::string names = "xyz";
if (format_ == Vtk::ASCII) { if (format_ == Vtk::ASCII) {
......
...@@ -74,11 +74,11 @@ namespace Dune ...@@ -74,11 +74,11 @@ namespace Dune
// vector `offsets`. // vector `offsets`.
void writeCells (std::ofstream& out, void writeCells (std::ofstream& out,
std::vector<pos_type>& offsets, std::vector<pos_type>& offsets,
Std::optional<std::size_t> timestep = {}) const; std::optional<std::size_t> timestep = {}) const;
void writePointIds (std::ofstream& out, void writePointIds (std::ofstream& out,
std::vector<pos_type>& offsets, std::vector<pos_type>& offsets,
Std::optional<std::size_t> timestep = {}) const; std::optional<std::size_t> timestep = {}) const;
private: private:
using Super::dataCollector_; using Super::dataCollector_;
......
...@@ -281,7 +281,7 @@ void VtkUnstructuredGridWriter<GV,DC> ...@@ -281,7 +281,7 @@ void VtkUnstructuredGridWriter<GV,DC>
template <class GV, class DC> template <class GV, class DC>
void VtkUnstructuredGridWriter<GV,DC> void VtkUnstructuredGridWriter<GV,DC>
::writeCells (std::ofstream& out, std::vector<pos_type>& offsets, ::writeCells (std::ofstream& out, std::vector<pos_type>& offsets,
Std::optional<std::size_t> timestep) const std::optional<std::size_t> timestep) const
{ {
if (format_ == Vtk::ASCII) { if (format_ == Vtk::ASCII) {
auto cells = dataCollector_->cells(); auto cells = dataCollector_->cells();
...@@ -337,7 +337,7 @@ template <class GV, class DC> ...@@ -337,7 +337,7 @@ template <class GV, class DC>
void VtkUnstructuredGridWriter<GV,DC> void VtkUnstructuredGridWriter<GV,DC>
::writePointIds (std::ofstream& out, ::writePointIds (std::ofstream& out,
std::vector<pos_type>& offsets, std::vector<pos_type>& offsets,
Std::optional<std::size_t> timestep) const std::optional<std::size_t> timestep) const
{ {
auto ids = dataCollector_->pointIds(); auto ids = dataCollector_->pointIds();
if (ids.empty()) if (ids.empty())
......
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