AMR1d.h
00001 #ifndef gridripper_main_AMR1d_h
00002 #define gridripper_main_AMR1d_h
00003
00004 #include <gridripper/util/THMSSLogFile.h>
00005 #include <gridripper/util/GrrProperties.h>
00006 #include <gridripper/amr1d/Grid.h>
00007 #include <gridripper/amr1d/PDE.h>
00008 #include <gridripper/amr1d/InitCond.h>
00009 #include <gridripper/amr1d/AutoAMRCore.h>
00010 #include <gridripper/amr1d/ParameterParser.h>
00011 #include <gridripper/io/IOException.h>
00012 #include <string>
00013
00014 namespace gridripper { namespace main {
00015
00016 using namespace std;
00017 using namespace gridripper::io;
00018 using namespace gridripper::amr1d;
00019
00026 class AMR1d
00027 {
00028 private:
00030 string inputFileName;
00031
00033 AutoAMRCore* autoAMRCore;
00034
00035 private:
00036 bool writeIntq;
00037
00038 string intqHeaderFormat;
00039
00040 string intqFormat;
00041
00042 bool writeMarker;
00043
00044 string markerHeaderFormat;
00045
00046 string markerFormat;
00047
00048 string logTimeFormat;
00049
00050 string initCondMessage;
00051
00052 public:
00053 class AMRLogger
00054 {
00055 private:
00056 const AMR1d* parent;
00057 THMSSLogFile flog;
00058
00059 public:
00060 AMRLogger(const AMR1d* p, const string& f, bool append)
00061 throw(IOException&);
00062
00063 void writeComment(const string& s) throw(IOException&);
00064
00065 void close() throw(IOException&);
00066
00067 void log(const Grid& g, double error) throw(IOException&);
00068 };
00069
00070 public:
00076 AMR1d(const string& f, bool enable) throw(InitCond::Exception&,
00077 IOException&, IllegalArgumentException&,
00078 AutoAMRCore::OutFileExistsException&);
00079
00080 ~AMR1d();
00081
00085 void play() throw(IOException&, IllegalArgumentException&);
00086
00090 const AMRCore& getAMRCore() const;
00091
00092 protected:
00097 string getDataFileName(const ParameterParser& p) const;
00098
00103 string getLogFilename() const;
00104
00109 string getIntegratedQuantitiesFilename() const;
00110
00111 string getMarkerQuantitiesFilename() const;
00112
00113 private:
00114 void init(istream& is, const string& streamname, bool enable)
00115 throw(InitCond::Exception&, IOException&, IllegalArgumentException&,
00116 AutoAMRCore::OutFileExistsException&);
00117
00118 void printIntqHeader(ostream& fintq, const PDE& pde,
00119 tvalarray<PDE::PhysicalQuantity*>& q);
00120
00121 void printIntq(ostream& fintq, const PDE& pde,
00122 tvalarray<PDE::PhysicalQuantity*>& q,
00123 GReal_t t, const tvalarray<GReal_t>& qv);
00124
00125 void printMarkerHeader(ostream& fmarker,
00126 tvalarray<PDE::MarkerQuantity*>& mq);
00127
00128 void printMarker(ostream& fmarker, GReal_t t, const tvalarray<GReal_t>& mqv);
00129
00133 AutoAMRCore* createAMRCore(const GrrProperties& props, bool enable)
00134 throw(InitCond::Exception&, IOException&,
00135 IllegalArgumentException&,
00136 AutoAMRCore::OutFileExistsException&);
00137
00138 void output(AMRLogger& logger, ostream& fintq, ostream& fmarker,
00139 AutoAMRCore& ai, const Grid& baseg,
00140 PDE::PhysicalQuantityArray& q, tvalarray<GReal_t>& qv,
00141 PDE::MarkerQuantityArray& mq, tvalarray<GReal_t>& mqv)
00142 throw(IOException&);
00143 };
00144
00145 } }
00146
00147 #endif