Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef AMROC_AMRFLAGGING2_H 00002 #define AMROC_AMRFLAGGING2_H 00003 00011 #include "AMRFlaggingBase.h" 00012 00013 #ifndef AMRFlaggingName 00014 #define AMRFlagging(dim) name2(AMRFlagging,dim) 00015 #define AMRFlaggingName 00016 #endif 00017 00024 template <class VectorType, class FixupType, class FlagType> 00025 class AMRFlagging(2) : 00026 public AMRFlaggingBase(2)<VectorType,FixupType,FlagType> { 00027 typedef Solver(2)<VectorType,FixupType,FlagType> solver_type; 00028 typedef typename VectorType::InternalDataType DataType; 00029 typedef GridFunction(2)<DataType> gr_fct_type; 00030 public: 00031 AMRFlagging(2)(solver_type& solver) : 00032 AMRFlaggingBase(2)<VectorType,FixupType,FlagType>(solver) {} 00033 00034 protected: 00035 void FlagInDirection(const int Time, const int Level, gr_fct_type &u, 00036 int* Offset1, int* Offset2, DataType TolSp, FlagType FlagValue) { 00037 00038 if (TolSp <= 0.0) return; 00039 int TStep = TimeStep(u,Level); 00040 forall(Flags(), Time, Level, c) 00041 BBox OpBox = u.interiorbbox(Time,Level,c); 00042 Coords& OpBox_stepsize = OpBox.stepsize(); 00043 BeginFastIndex2(u, u(Time,Level,c).bbox(), 00044 u(Time,Level,c).data(), DataType); 00045 BeginFastIndex2(uout, u(Time+TStep,Level,c).bbox(), 00046 u(Time+TStep,Level,c).data(), DataType); 00047 BeginFastIndex2(Flags, Flags()(Time,Level,c).bbox(), 00048 Flags()(Time,Level,c).data(), FlagType); 00049 00050 Coords o1 = Coords(2,Offset1)*OpBox_stepsize; 00051 Coords o2 = Coords(2,Offset2)*OpBox_stepsize; 00052 DataType value; 00053 for_2 (n, m, OpBox, OpBox_stepsize) 00054 value = fabs(FastIndex2(u,n+o1(0),m+o1(1))-FastIndex2(u,n+o2(0),m+o2(1))); 00055 if (value >= TolSp) 00056 FastIndex2(Flags,n,m) = FlagValue; 00057 if (value > FastIndex2(uout,n,m)) 00058 FastIndex2(uout,n,m) = value; 00059 end_for 00060 00061 EndFastIndex2(u); 00062 EndFastIndex2(uout); 00063 EndFastIndex2(Flags); 00064 end_forall 00065 } 00066 00067 virtual void FlagByDifference(const int Time, const int Level, gr_fct_type &u, 00068 DataType TolSp, FlagType FlagValue) { 00069 if (TolSp <= 0.0) return; 00070 int East[2] = { 1, 0 }; int West[2] = { -1, 0 }; 00071 int North[2] = { 0, 1 }; int South[2] = { 0, -1 }; 00072 FlagInDirection(Time, Level, u, East, West, TolSp, FlagValue); 00073 FlagInDirection(Time, Level, u, North, South, TolSp, FlagValue); 00074 00075 int NorthEast[2] = { 1, 1 }; int SouthWest[2] = { -1, -1 }; 00076 int NorthWest[2] = { -1, 1 }; int SouthEast[2] = { 1, -1 }; 00077 FlagInDirection(Time, Level, u, NorthEast, SouthWest, TolSp, FlagValue); 00078 FlagInDirection(Time, Level, u, NorthWest, SouthEast, TolSp, FlagValue); 00079 } 00080 00081 virtual void FlagByErrorEstimation(const int Time, const int Level, gr_fct_type &ush, 00082 DataType Tol, FlagType FlagValue) { 00083 00084 if (Tol <= 0.0) return; 00085 int ShTStep = TimeStep(ush,Level); 00086 forall(Flags(), Time, Level, c) 00087 BeginFastIndex2(ush, ush(Time+ShTStep,Level,c).bbox(), 00088 ush(Time+ShTStep,Level,c).data(), DataType); 00089 BeginFastIndex2(Flags, Flags()(Time,Level,c).bbox(), 00090 Flags()(Time,Level,c).data(), FlagType); 00091 BBox OpBox = ush.interiorbbox(Time+ShTStep,Level,c); 00092 Coords& Os = OpBox.stepsize(); 00093 Coords Os2 = Os/2; 00094 00095 for_2 (n, m, OpBox, Os) 00096 FastIndex2(ush,n,m) = fabs(FastIndex2(ush,n,m)); 00097 if (FastIndex2(ush,n,m) >= Tol) { 00098 FastIndex2(Flags,n ,m ) = FlagValue; 00099 FastIndex2(Flags,n+Os2(0),m ) = FlagValue; 00100 FastIndex2(Flags,n ,m+Os2(1)) = FlagValue; 00101 FastIndex2(Flags,n+Os2(0),m+Os2(1)) = FlagValue; 00102 } 00103 end_for 00104 00105 EndFastIndex2(ush); 00106 EndFastIndex2(Flags); 00107 end_forall 00108 } 00109 00110 }; 00111 00112 00113 00114 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04