00001 #ifndef ExodusWRITER_H 00002 #define ExodusWRITER_H 00003 00004 #include "SundanceDefs.h" 00005 #include "FieldWriterBase.h" 00006 #include "TSFSmartPtr.h" 00007 #include "CellSet.h" 00008 #include <fstream> 00009 00010 namespace Sundance 00011 { 00012 00013 using namespace TSF; 00014 using std::string; 00015 using std::ostream; 00016 00017 /** */ 00018 class ExodusWriter : public FieldWriterBase 00019 { 00020 public: 00021 /** open a Exodus writer that will write to a file 00022 * The file given must be an already existing ExodusII Database*/ 00023 ExodusWriter(const string& filename); 00024 00025 /** open a Exodus writer that will write to a file 00026 * The file given must be an already existing ExodusII Database*/ 00027 ExodusWriter(const string& filename, const CellSet& cellSet); 00028 00029 /** open a Exodus writer that will write to standard out */ 00030 ExodusWriter(); 00031 00032 virtual ~ExodusWriter(); 00033 00034 /** initialize the variables to write to the exodus file 00035 * This is to be used when there is more than one variable 00036 * that will be written out.*/ 00037 virtual int initializeVariables(const string* names, const int num_vars) const ; 00038 00039 00040 00041 /** write a field, tagging it with the given string as a name and timestep 00042 * If time_step is less than zero, the step will automatically be incremented to 00043 * the next avaliable step. 00044 * If no variables have been put in the ExodusII database, then a new variable with 00045 * the name given will be added. 00046 * If variables have been put in the database, then the expression will be added if 00047 * and only if the variable name matches one of the variables that has already been added 00048 */ 00049 virtual void writeField(const string& name, 00050 const Expr& expr, double time_value, int time_step) const ; 00051 00052 00053 00054 virtual void writeElementalField(const string& name, 00055 const Expr& expr, double time_value, int time_step) const ; 00056 00057 /** write a field, tagging it with the given string as a name 00058 * If no variables have been put in the ExodusII database, then a new variable with 00059 * the name given will be added. 00060 * If variables have been put in the database, then the expression will be added if 00061 * and only if the name matches one of the variables that has already been added 00062 */ 00063 virtual void writeField(const string& name, 00064 const Expr& expr) const {writeField(name,expr,0.0,1);} 00065 00066 /** write a mesh in Exodus format */ 00067 virtual void writeMesh(const Mesh& mesh) const ; 00068 00069 /** write a comment */ 00070 virtual void writeCommentLine(const string& line) const ; 00071 00072 /** This will copy all of the Model data from the source ExodusII database 00073 * to the destination ExodusII database. 00074 * This allows new results to be written to the destination file if 00075 * results have already been recorded in the source file 00076 * If the destination file exists, it will be replaced. 00077 * NOTE: it is perfectly legal for the source and dest to be the same, 00078 * this will have the overall effect of wiping any results that 00079 * were previously recorded in the source file. 00080 */ 00081 static void duplicateMesh(const string& source, const string& dest); 00082 private: 00083 static const int CPUWORDSIZE; 00084 static const int IOWORDSIZE; 00085 int exoid_; 00086 mutable string filename_; 00087 CellSet cellSet_; 00088 }; 00089 } 00090 00091 #endif 00092