From 2183e1f87d11bd7cff0ce83c9d9a716cec46d6f6 Mon Sep 17 00:00:00 2001 From: Francois Gygi Date: Sun, 19 Aug 2018 17:43:17 -0700 Subject: [PATCH] Add output in cube format --- src/testFunction3d.C | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/testFunction3d.C b/src/testFunction3d.C index dd74418..4052e8b 100644 --- a/src/testFunction3d.C +++ b/src/testFunction3d.C @@ -16,11 +16,14 @@ // //////////////////////////////////////////////////////////////////////////////// #include +#include #include "Function3d.h" using namespace std; // usage: ./testFunction3d file.xml +// Read a Function3d from an XML file and print contents as a cube file + int main(int argc, char** argv) { Function3d f; @@ -42,12 +45,30 @@ int main(int argc, char** argv) } cout << "function norm2: " << sum / f.val.size() << endl; - // modify function - f.name = "output"; + f.write("output.xml"); + + // output data in cube format on stdout + cout << "Created by testFunction3d" << endl; + cout << endl; + cout << "8 0 0 0" << endl; + cout << f.nx << " " << f.a / f.nx << endl; + cout << f.ny << " " << f.b / f.ny << endl; + cout << f.nz << " " << f.c / f.nz << endl; + cout << "1 1 0.0 0.0 0.0" << endl; + cout << "1 1 " << f.a << endl; + cout << "1 1 " << f.b << endl; + cout << "1 1 " << f.c << endl; + cout << "1 1 " << f.a+f.b << endl; + cout << "1 1 " << f.b+f.c << endl; + cout << "1 1 " << f.c+f.a << endl; + cout << "1 1 " << f.a+f.b+f.c << endl; + cout.setf(ios::scientific,ios::floatfield); + cout.precision(5); for ( int i = 0; i < f.val.size(); i++ ) { - f.val[i] *= 0.5; + cout << setw(13) << f.val[i]; + if ( ( (i+1) % 6 ) == 0 ) + cout << endl; } - - f.write("output.xml"); + cout << endl; } -- libgit2 0.26.0