diff --git a/dumux/io/gnuplotinterface.hh b/dumux/io/gnuplotinterface.hh index 55fa13e5e7c0cee59953e690f9b34d8d9716a956..22950c5edd5bc189af6012ba56e9062f03edea9b 100644 --- a/dumux/io/gnuplotinterface.hh +++ b/dumux/io/gnuplotinterface.hh @@ -42,7 +42,7 @@ #include <string> #include <vector> -#include <dune/common/deprecated.hh> +#include <dune/common/exceptions.hh> #include <dune/common/stdstreams.hh> namespace Dumux { @@ -244,7 +244,15 @@ public: const std::string& fileName, const std::string& options = "with lines") { - assert(x.size() == y.size()); + if (x.empty() || y.empty()) + DUNE_THROW(Dune::InvalidStateException, "Data vectors have to contain data!"); + + if (x.size() > y.size()) + DUNE_THROW(Dune::InvalidStateException, "Non-matching data field sizes!"); + + if (x.size() != y.size()) + std::cout << "GnuplotInterface warning: Added data fields of different size! " + << "Only plotting the first " << x.size() << " elements.\n"; // write data to file std::ofstream file; @@ -435,5 +443,5 @@ private: std::string plotOptions_; std::string gnuplotPath_; }; -} // end of namespace +} // end namespace Dumux #endif // DUMUX_GNUPLOT_INTERFACE_HH