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