Commit 7eab8984 authored by Samuel Scherrer's avatar Samuel Scherrer
Browse files

[io][precision] started work on setting precision. Doesn't work with containers of containers yet.

parent e4f43fd7
......@@ -30,9 +30,12 @@
#include <iostream>
#include <fstream>
#include <iterator>
#include <iomanip>
#include <limits>
namespace Dumux {
/*!
* \ingroup InputOutput
* \brief Writes a container to file
......@@ -46,6 +49,8 @@ void writeContainerToFile(const Container& v,
const std::string& filename)
{
std::ofstream outfile(filename, std::ios::out);
outfile << std::scientific;
outfile << std::setprecision(std::numeric_limits<typename Container::value_type>::max_digits10+1);
std::ostream_iterator<typename Container::value_type> it(outfile, "\n");
std::copy(v.begin(),v.end(), it);
}
......
......@@ -109,7 +109,7 @@ int main()
passed = passed && Dumux::testContainerWriter<std::array<int, 2>>({{1, 2}});
passed = passed && Dumux::testContainerWriter<std::array<std::string, 2>>({{"1.0", "2.0"}});
passed = passed && Dumux::testContainerWriter<std::array<Dune::FieldVector<double, 3>, 2>>(
std::array<Dune::FieldVector<double, 3>, 2>{{Dune::FieldVector<double, 3>(0.0), Dune::FieldVector<double, 3>(1.0)}});
std::array<Dune::FieldVector<double, 3>, 2>{{Dune::FieldVector<double, 3>(0.0000100012004), Dune::FieldVector<double, 3>(1.12341502e-10)}});
if (!passed) return 1;
return 0;
......
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