/* 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 #include using namespace std; /**************************************************************/ /* Ouput a single txt 1D graphic file */ /* name : file descriptor (Energy or fct name) */ /* findex : file index */ /* p : pointer to the data array */ /* vsize : size of data vector (No of fcts) */ /* t : value of t for the snapshot */ /* Output format: */ /* ti Fi */ /* Throw a string on error */ /**************************************************************/ void grf_pde_plain::write_1_grf(const char *name,int findex,double *p, int vsize,double t) { int ix,index; double x; string fname = make_file_name(file_name_+"_"+name,findex,"txt"); ofstream ofs(fname.c_str()); if(!ofs) { throw((string)" Error: Can't open file : "+fname); } index = 0 ; x = xmin_; for(ix = 0; ix < nx_; ix += 1) { ofs << x << " " << p[index] << "\n"; index += vsize; x += dx_; } } // Create a file name of the form: // NAME.DDD // Return the name as a string //******************************* string grf_pde_plain::make_file_name(string name,int index,string suffix) { char Buff[40]; sprintf(Buff,"%d",index); return(name+"."+Buff); }