From 6a042bdefeec10701382e8cbe795b2d3440a54e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 10 Apr 2012 14:09:32 +0200 Subject: [PATCH] Do not write denormal values to vtk files. Workaround for a bug in Paraview, at least on Mac. --- opm/core/utility/writeVtkData.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/opm/core/utility/writeVtkData.cpp b/opm/core/utility/writeVtkData.cpp index 8c337073..63c8284c 100644 --- a/opm/core/utility/writeVtkData.cpp +++ b/opm/core/utility/writeVtkData.cpp @@ -283,7 +283,6 @@ namespace Opm } Tag celldatatag("CellData", pm, os); pm.clear(); - pm["type"] = "Int32"; pm["NumberOfComponents"] = "1"; pm["format"] = "ascii"; pm["type"] = "Float64"; @@ -298,7 +297,13 @@ namespace Opm if (item % num_per_line == 0) { Tag::indent(os); } - os << field[item] << ' '; + double value = field[item]; + if (std::fabs(value) < std::numeric_limits::min()) { + // Avoiding denormal numbers to work around + // bug in Paraview. + value = 0.0; + } + os << value << ' '; if (item % num_per_line == num_per_line - 1 || item == num_cells - 1) { os << '\n';