/* Copyright (C) Bernard Piette University of Durham (UK) Department of Mathematical Sciences This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. You can modify or use any part of the source code but only under the condition that this Copyright notice is kept in the resulting source file. */ #include #include #include using namespace std; // Constructor // Get the parameters from the pde // file_name the name for the output file //**************************************** grf_pde::grf_pde(pde *pde,string file_name) : file_name_(file_name) { nx_ = pde->nx(); xmin_ = pde->xmin(); xmax_ = pde->xmax(); dx_ = pde->dx(); }; // Ouput a single txt 1D graphic file // findex : file index // p : pointer to the data array // t : value of t for the snapshot // Output format: // The file should be a .m file. It can be execute by matlab // # t = t // ti Fi // The file can be plotted using the following gnuplot command: // gnuplot> plot 'FILENAME' with lines // Throw a string on error //*************************************************************** void grf_pde::write_1_grf(int findex,double *p, double t) { int ix,index; double x; string fname = make_file_name(file_name_,findex,"txt"); ofstream ofs(fname.c_str()); if(!ofs) { throw((string)" Error: Can't open file : "+fname); } ofs <<"# t = "<