AutoAMRCore.h

00001 #ifndef gridripper_amr1d_AutoAMRCore_h
00002 #define gridripper_amr1d_AutoAMRCore_h
00003 
00004 #include "AMRCore.h"
00005 #include <gridripper/math/expr/Evaluator.h>
00006 #include <string>
00007 #ifdef HAVE_GSTREAM
00008 #include <gstream/gstream.h>
00009 #else
00010 #include <fstream>
00011 #endif
00012 
00013 namespace gridripper { namespace amr1d {
00014 
00015 using namespace std;
00016 using namespace gridripper::math::expr;
00017 
00024 class AutoAMRCore: public AMRCore
00025 {
00026 public:
00030     class OutFileExistsException: public gridripper::Exception
00031     {
00032     public:
00034         OutFileExistsException(const Exception& other):
00035             gridripper::Exception(other) { }
00036 
00041         OutFileExistsException(const string& fname):
00042             gridripper::Exception(fname + ": file exists",
00043                                   "AutoAMRCore::AutoAMRCore") { }
00044     };
00045 private:
00046     Evaluator::Function* dtwriteFunc;
00047     GReal_t dtwriteValue;
00048 
00049     int blankLines;
00050 
00051     int fileNo;
00052     int nfile;
00053     string outputFile;
00054     int maxBDataSize;
00055 
00056     bool outputAppended;
00057 
00058     bool endless;
00059 
00060     int initialTimeStepCount;
00061 
00062     GReal_t prevSaveTime;
00063 
00064     int prevSaveTimeStep;
00065 
00066     GReal_t theLastTime;
00067 
00068     int msecsPerDisplay;
00069 
00070     int nextTimeStepToDisplay;
00071 
00073     double calcTimeWAvg;
00074 
00076     long calcTimeTot;
00077 
00079     long waitTimeTot;
00080 
00081     string dataFormat;
00082     string energyFormatStr;
00083 
00084     unsigned startTime;
00085     int maxRuntime;
00086 
00088     bool binary;
00089 
00091 #ifdef HAVE_GSTREAM
00092     ogstream outputFileStream;
00093 #else
00094     ofstream outputFileStream;
00095 #endif
00096 
00097 public:
00130     AutoAMRCore(PDE* pde, InitCond& ini, bool constrforced, Integrator* gi,
00131                 Regridder* regridder, const string& dtdx,
00132                 int maxi, int npabovemax,
00133                 int maxl, int r,
00134                 AMError* amerr, double maxerr,
00135                 int errchkf, int regridf,
00136                 int bufzoner,
00137                 int fms, string f, int fileno, int bdatasize, int blines,
00138                 const string& dtwrite, bool endless,
00139                 GReal_t tmax, int maxruntime, 
00140                 const string& datafmt, const string& energyfmt, bool enable)
00141             throw(InitCond::Exception&, IllegalArgumentException&,
00142                   OutFileExistsException&);
00143 
00144     virtual ~AutoAMRCore();
00145 
00150     AMRCore* cloneAMRCore() const;
00151 
00152     long getCalcTime() const {
00153         return calcTimeTot;
00154     }
00155 
00156     long getWaitTime() const {
00157         return waitTimeTot;
00158     }
00159 
00160     bool isOutputAppended() const {
00161         return outputAppended;
00162     }
00163 
00164     bool isTimeSliceSaved(int tsc) const;
00165 
00169     void output();
00170 
00171 protected:
00177     bool isLastTime(const Grid& g) const;
00178 
00184     virtual void coarseStepped(GReal_t t);
00185 };
00186 
00187 } } // namespace gridripper::amr1d
00188 
00189 #endif /* gridripper_amr1d_AutoAMRCore_h */

Generated on Wed Jun 17 18:46:47 2009 for GridRipper by  doxygen 1.5.6