Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef AMROC_AMRFLAGGINGREL2_H 00002 #define AMROC_AMRFLAGGINGREL2_H 00003 00011 #include "AMRFlaggingRelBase.h" 00012 00013 #define UROUND 1.0e-15 00014 00015 #ifndef AMRFlaggingRelName 00016 #define AMRFlaggingRel(dim) name2(AMRFlaggingRel,dim) 00017 #define AMRFlaggingRelName 00018 #endif 00019 00026 template <class VectorType, class FixupType, class FlagType> 00027 class AMRFlaggingRel(2) : 00028 public AMRFlaggingRelBase(2)<VectorType,FixupType,FlagType> { 00029 typedef Solver(2)<VectorType,FixupType,FlagType> solver_type; 00030 typedef typename VectorType::InternalDataType DataType; 00031 typedef GridFunction(2)<DataType> gr_fct_type; 00032 public: 00033 AMRFlaggingRel(2)(solver_type& solver) : 00034 AMRFlaggingRelBase(2)<VectorType,FixupType,FlagType>(solver) {} 00035 00036 protected: 00037 void FlagInDirectionRel(const int Time, const int Level, gr_fct_type &u, 00038 int* Offset, DataType Tol, DataType Sc, FlagType FlagValue) { 00039 00040 if (Tol<=0 || Sc<=0.0) return; 00041 int TStep = TimeStep(u,Level); 00042 forall(Flags(), Time, Level, c) 00043 BBox OpBox = u.interiorbbox(Time,Level,c); 00044 Coords& Os = OpBox.stepsize(); 00045 Coords Os2 = Coords(2,Offset)*Os; 00046 BeginFastIndex2(u, u(Time,Level,c).bbox(), 00047 u(Time,Level,c).data(), DataType); 00048 BeginFastIndex2(uout, u(Time+TStep,Level,c).bbox(), 00049 u(Time+TStep,Level,c).data(), DataType); 00050 BeginFastIndex2(Flags, Flags()(Time,Level,c).bbox(), 00051 Flags()(Time,Level,c).data(), FlagType); 00052 00053 for_2 (n, m, OpBox, Os) 00054 DataType ui = FastIndex2(u,n,m); 00055 DataType uim = FastIndex2(u,n-Os2(0),m-Os2(1)); 00056 DataType uip = FastIndex2(u,n+Os2(0),m+Os2(1)); 00057 DataType uc = 1.0; 00058 if (fabs(ui-uip)>Sc || fabs(ui-uim)>Sc) 00059 if (fabs(ui-uip)>UROUND) 00060 uc = phi( fabs((ui-uim)/(ui-uip)) ); 00061 else uc = 0.0; 00062 if (uc < Tol) 00063 FastIndex2(Flags,n,m) = FlagValue; 00064 if (uc < FastIndex2(uout,n,m)) 00065 FastIndex2(uout,n,m) = uc; 00066 end_for 00067 00068 EndFastIndex2(u); 00069 EndFastIndex2(uout); 00070 EndFastIndex2(Flags); 00071 end_forall 00072 } 00073 00074 virtual void FlagByDifferenceRel(const int Time, const int Level, gr_fct_type &u, 00075 DataType TolSp, DataType Sc, FlagType FlagValue) { 00076 int OffsetX[2] = { 1, 0 }; int OffsetY[2] = { 0, 1 }; 00077 FlagInDirectionRel(Time, Level, u, OffsetX, TolSp, Sc, FlagValue); 00078 FlagInDirectionRel(Time, Level, u, OffsetY, TolSp, Sc, FlagValue); 00079 } 00080 00081 virtual void FlagByErrorEstimationRel(const int Time, const int Level, gr_fct_type &ush, 00082 DataType Tol, DataType Sc, FlagType FlagValue) { 00083 00084 if (Tol<=0 || Sc<=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(ushr, ush(Time,Level,c).bbox(), 00090 ush(Time,Level,c).data(), DataType); 00091 BeginFastIndex2(Flags, Flags()(Time,Level,c).bbox(), 00092 Flags()(Time,Level,c).data(), FlagType); 00093 00094 BBox OpBox = ush.interiorbbox(Time,Level,c); 00095 Coords& Os = OpBox.stepsize(); 00096 Coords Os2 = Os/2; 00097 00098 for_2 (n, m, OpBox, Os) 00099 FastIndex2(ush,n,m) = fabs(FastIndex2(ush,n,m)/Max(Sc,FastIndex2(ushr,n,m))); 00100 if (FastIndex2(ush,n,m) >= Tol) { 00101 FastIndex2(Flags,n ,m ) = FlagValue; 00102 FastIndex2(Flags,n+Os2(0),m ) = FlagValue; 00103 FastIndex2(Flags,n ,m+Os2(1)) = FlagValue; 00104 FastIndex2(Flags,n+Os2(0),m+Os2(1)) = FlagValue; 00105 } 00106 end_for 00107 00108 EndFastIndex2(ush); 00109 EndFastIndex2(ushr); 00110 EndFastIndex2(Flags); 00111 end_forall 00112 } 00113 00114 }; 00115 00116 00117 00118 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04