00001 #ifndef gridripper_amr1d_ParameterParser_h
00002 #define gridripper_amr1d_ParameterParser_h
00003
00004 #include <gridripper/config.h>
00005 #include <gridripper/tvalarray.h>
00006 #include <gridripper/util/GrrProperties.h>
00007 #include <gridripper/util/ParameterPreprocessor.h>
00008 #include <gridripper/lang/IllegalArgumentException.h>
00009 #include <gridripper/io/IOException.h>
00010 #include <gridripper/amr1d/InitCond.h>
00011
00012 namespace gridripper { namespace amr1d {
00013
00014 using namespace gridripper::io;
00015 using namespace gridripper::util;
00016 class PDE;
00017 class Integrator;
00018 class Regridder;
00019 class AMError;
00020
00021 using namespace std;
00022
00029 class ParameterParser
00030 {
00031 private:
00032 const GrrProperties& properties;
00033 Parameters* unprocessedParameters;
00034
00035
00036
00037
00039 PDE* pde;
00040
00042 InitCond* initCond;
00043
00044
00046 Integrator* gridIntegrator;
00047
00049 AMError* amError;
00050
00052 Regridder* regridder;
00053
00054 public:
00056 bool debug;
00057
00059 bool constraintForced;
00060
00061
00062
00063
00065 string dtdx;
00066
00068 int maxi;
00069
00071 int numPointsAboveMaxX;
00072
00074 int maxLevel;
00075
00077 int refinementRatio;
00078
00083 GReal_t errorTolerance;
00084
00090 int errorCheckFreq;
00091
00097 int regridFreq;
00098
00102 int bufferZoneSize;
00103
00104
00105
00106
00107 int fileNo;
00108 int maxBDataSize;
00109
00113 string dtwrite;
00114
00118 string tmax_str;
00119
00121 bool endless;
00122
00123 int maxRuntime;
00124
00126 int blankLines;
00127
00129 string dataFormat;
00130
00132 string energyFormatStr;
00133
00135 bool energyWritten;
00136
00138 bool writeIntq;
00139
00141 string intqHeaderFormat;
00142
00144 string intqFormat;
00145
00146 bool writeMarker;
00147 string markerHeaderFormat;
00148 string markerFormat;
00149
00150 public:
00155 ParameterParser(const GrrProperties& props);
00156
00157 ~ParameterParser();
00158
00162 void parse() throw(InitCond::Exception&, IllegalArgumentException&,
00163 IOException&);
00164
00169 GReal_t getTmax() const throw(InitCond::Exception&);
00170
00175 string getTimeFormatString() const throw(InitCond::Exception&);
00176
00181 PDE* disownPDE();
00182
00187 InitCond& getInitCond() const;
00188
00193 Integrator* disownIntegrator();
00194
00199 AMError* disownAMError();
00200
00205 Regridder* disownRegridder();
00206
00207 protected:
00212 string getParameter(string key) const;
00213
00214 private:
00215 ParameterPreprocessor* createPreprocessor() const;
00216 void parseResolution(const string& s) throw(IllegalArgumentException&);
00217 static int parseInt(const string& s) throw(IllegalArgumentException&);
00218 static bool parseBool(const string& s) throw(IllegalArgumentException&);
00219 static GReal_t parseReal(const string& s) throw(IllegalArgumentException&);
00220 static int guessPrecision(const string& str);
00221 };
00222
00223 } }
00224
00225 #endif