aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@aei.mpg.de>2004-10-02 18:36:00 +0000
committerErik Schnetter <schnetter@aei.mpg.de>2004-10-02 18:36:00 +0000
commitb5ee673df8d0628d09effbc2e42ad136d89b1c28 (patch)
tree0368131a069d85a5ded297b70da65fe40d773096
parent14618be14f92c2b536e3cae63d00f8b56cd9befd (diff)
CarpetIOASCII: Round coordinates in output files
darcs-hash:20041002183605-891bb-bb77ee81f39ecfa61f7ba6a3eff5cd5495fb9dc5.gz
-rw-r--r--Carpet/CarpetIOASCII/src/ioascii.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc
index d98641bc7..1bb022558 100644
--- a/Carpet/CarpetIOASCII/src/ioascii.cc
+++ b/Carpet/CarpetIOASCII/src/ioascii.cc
@@ -978,6 +978,15 @@ namespace CarpetIOASCII {
+ static CCTK_REAL
+ nicelooking (CCTK_REAL const val,
+ CCTK_REAL const base)
+ {
+ return floor(val / base + 0.5) * base;
+ }
+
+
+
// Output
template<int D,int DD>
void WriteASCII (ostream& os,
@@ -1047,9 +1056,11 @@ namespace CarpetIOASCII {
if (gfext.upper()[d] - gfext.lower()[d] == 0) {
os << coord_lower[d];
} else {
- os << (coord_lower[d] + (index[d] - gfext.lower()[d])
- * (coord_upper[d] - coord_lower[d])
- / (gfext.upper()[d] - gfext.lower()[d]));
+ CCTK_REAL const dx = ((coord_upper[d] - coord_lower[d])
+ / (gfext.upper()[d] - gfext.lower()[d]));
+ os << (nicelooking
+ (coord_lower[d] + (index[d] - gfext.lower()[d]) * dx,
+ dx * 1.0e-8));
}
if (d != D-1) os << " ";
}