Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef AMROC_AMRFLAGGINGREL1_H 00002 #define AMROC_AMRFLAGGINGREL1_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(1) : 00028 public AMRFlaggingRelBase(1)<VectorType,FixupType,FlagType> { 00029 typedef Solver(1)<VectorType,FixupType,FlagType> solver_type; 00030 typedef typename VectorType::InternalDataType DataType; 00031 typedef GridFunction(1)<DataType> gr_fct_type; 00032 public: 00033 AMRFlaggingRel(1)(solver_type& solver) : 00034 AMRFlaggingRelBase(1)<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(1,Offset)*Os; 00046 BeginFastIndex1(u, u(Time,Level,c).bbox(), 00047 u(Time,Level,c).data(), DataType); 00048 BeginFastIndex1(uout, u(Time+TStep,Level,c).bbox(), 00049 u(Time+TStep,Level,c).data(), DataType); 00050 BeginFastIndex1(Flags, Flags()(Time,Level,c).bbox(), 00051 Flags()(Time,Level,c).data(), FlagType); 00052 00053 for_1 (n, OpBox, Os) 00054 DataType ui = FastIndex1(u,n); 00055 DataType uim = FastIndex1(u,n-Os2(0)); 00056 DataType uip = FastIndex1(u,n+Os2(0)); 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 FastIndex1(Flags,n) = FlagValue; 00064 FastIndex1(uout,n) = uc; 00065 end_for 00066 00067 EndFastIndex1(u); 00068 EndFastIndex1(uout); 00069 EndFastIndex1(Flags); 00070 end_forall 00071 } 00072 00073 virtual void FlagByDifferenceRel(const int Time, const int Level, gr_fct_type &u, 00074 DataType TolSp, DataType Sc, FlagType FlagValue) { 00075 int Offset[1] = { 1 }; 00076 FlagInDirectionRel(Time, Level, u, Offset, TolSp, Sc, FlagValue); 00077 } 00078 00079 virtual void FlagByErrorEstimationRel(const int Time, const int Level, gr_fct_type &ush, 00080 DataType Tol, DataType Sc, FlagType FlagValue) { 00081 00082 if (Tol<=0 || Sc<=0.0) return; 00083 int ShTStep = TimeStep(ush,Level); 00084 forall(Flags(), Time, Level, c) 00085 BeginFastIndex1(ush, ush(Time+ShTStep,Level,c).bbox(), 00086 ush(Time+ShTStep,Level,c).data(), DataType); 00087 BeginFastIndex1(ushr, ush(Time,Level,c).bbox(), 00088 ush(Time,Level,c).data(), DataType); 00089 BeginFastIndex1(Flags, Flags()(Time,Level,c).bbox(), 00090 Flags()(Time,Level,c).data(), FlagType); 00091 00092 BBox OpBox = ush.interiorbbox(Time,Level,c); 00093 Coords& Os = OpBox.stepsize(); 00094 00095 for_1 (n, OpBox, Os) 00096 FastIndex1(ush,n) = fabs(FastIndex1(ush,n)/Max(Sc,FastIndex1(ushr,n))); 00097 if (FastIndex1(ush,n) >= Tol) { 00098 FastIndex1(Flags,n) = FlagValue; 00099 FastIndex1(Flags,n+Os(0)/2) = FlagValue; 00100 } 00101 end_for 00102 00103 EndFastIndex1(ush); 00104 EndFastIndex1(ushr); 00105 EndFastIndex1(Flags); 00106 end_forall 00107 } 00108 00109 }; 00110 00111 00112 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04