DefaultRegridder.h
00001 #ifndef gridripper_amr1d_regridder_DefaultRegridder_h
00002 #define gridripper_amr1d_regridder_DefaultRegridder_h
00003
00004 #include <gridripper/amr1d/Regridder.h>
00005 #include <gridripper/tvalarray.h>
00006
00007 namespace gridripper { namespace amr1d { namespace regridder {
00008
00009 using namespace gridripper::amr1d;
00010
00018 class DefaultRegridder: public Regridder
00019 {
00020 protected:
00022 tvalarray<bool> pointFlags;
00023
00024 private:
00026 int lastRegridTime;
00027
00028 public:
00029 DefaultRegridder();
00030
00031 protected:
00032 DefaultRegridder(const Grid& p);
00033
00034 DefaultRegridder(const DefaultRegridder& r);
00035
00036 public:
00037 virtual Regridder* newRegridder(const Grid& p) {
00038 return new DefaultRegridder(p);
00039 }
00040
00041 virtual Regridder* cloneRegridder() {
00042 return new DefaultRegridder(*this);
00043 }
00044
00049 bool isFlagged(int i) {
00050 return pointFlags[i];
00051 }
00052
00060 bool isDynamic() {
00061 return true;
00062 }
00063
00069 void setFlagged(int i, bool v) {
00070 pointFlags[i] = v;
00071 }
00072
00073 int getInvFreqUnit() {
00074 return 1;
00075 }
00076
00077 bool isErrorEstimated() {
00078 return true;
00079 }
00080
00081 void setLastRegridTime(int t) {
00082 lastRegridTime = t;
00083 }
00084
00085 int getLastRegridTime() {
00086 return lastRegridTime;
00087 }
00088
00089 virtual bool checkRegriddingIsDue(Grid& g, int maxAllowedLevel,
00090 bool onInitialHypersurface,
00091 int r, int ir,
00092 int errorCheckFreq, int regridFreq);
00093
00098 void init(int maxi) {
00099 pointFlags.resize(maxi + 1);
00100 }
00101
00107 void checkErrors(Integrator* integrator, double critical);
00108
00124 virtual IntervalList* getIntervalList(const Grid& grid,
00125 tvalarray<Grid*>& newSubSubgrids,
00126 int minl, int maxl, int numvel, int margin, int bufzoneradius,
00127 int tsc);
00128
00132 virtual void beginTimeStep(const Grid& baseg) {
00133 }
00134
00138 virtual void endTimeStep(GReal_t t) {
00139 }
00140
00141 protected:
00147 bool hasUncoveredFlaggedPoint(const Grid& grid,
00148 const tvalarray<Grid*>& subGrids,
00149 int margin);
00150
00151 private:
00159 tvalarray<unsigned char> blurPointFlags(const Grid& grid, int radius);
00160
00161 static void fillInterval(tvalarray<Grid*>& d, IntervalList* iv, Grid* g);
00162 };
00163
00164 } } }
00165
00166 #endif