AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

AMRFlagging1.h

Go to the documentation of this file.
00001 #ifndef AMROC_AMRFLAGGING1_H
00002 #define AMROC_AMRFLAGGING1_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(1) : 
00026   public AMRFlaggingBase(1)<VectorType,FixupType,FlagType> {
00027   typedef Solver(1)<VectorType,FixupType,FlagType> solver_type;    
00028   typedef typename VectorType::InternalDataType DataType;
00029   typedef GridFunction(1)<DataType> gr_fct_type;
00030 public:
00031   AMRFlagging(1)(solver_type& solver) :
00032     AMRFlaggingBase(1)<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       BeginFastIndex1(u, u(Time,Level,c).bbox(), 
00044                       u(Time,Level,c).data(), DataType);
00045       BeginFastIndex1(uout, u(Time+TStep,Level,c).bbox(), 
00046                       u(Time+TStep,Level,c).data(), DataType);
00047       BeginFastIndex1(Flags, Flags()(Time,Level,c).bbox(), 
00048                       Flags()(Time,Level,c).data(), FlagType);
00049 
00050       Coords o1 = Coords(1,Offset1)*OpBox_stepsize;
00051       Coords o2 = Coords(1,Offset2)*OpBox_stepsize;
00052       for_1 (n, OpBox, OpBox_stepsize)
00053         FastIndex1(uout,n) = fabs(FastIndex1(u,n+o1(0))-FastIndex1(u,n+o2(0)));
00054         if (FastIndex1(uout,n) >= TolSp) 
00055           FastIndex1(Flags,n) = FlagValue; 
00056       end_for
00057 
00058       EndFastIndex1(u);
00059       EndFastIndex1(uout);
00060       EndFastIndex1(Flags);
00061     end_forall
00062   }
00063 
00064   virtual void FlagByDifference(const int Time, const int Level, gr_fct_type &u,
00065                                 DataType TolSp, FlagType FlagValue) { 
00066     if (TolSp <= 0.0) return;
00067     int East[1]  = { 1 }; int West[1]  = { -1 };
00068     FlagInDirection(Time, Level, u, East, West, TolSp, FlagValue);
00069   }
00070 
00071   virtual void FlagByErrorEstimation(const int Time, const int Level, gr_fct_type &ush,
00072                                      DataType Tol, FlagType FlagValue) {
00073 
00074     if (Tol <= 0.0) return;
00075     int ShTStep = TimeStep(ush,Level);
00076     forall(Flags(), Time, Level, c)
00077       BeginFastIndex1(ush, ush(Time+ShTStep,Level,c).bbox(), 
00078                       ush(Time+ShTStep,Level,c).data(), DataType);        
00079       BeginFastIndex1(Flags, Flags()(Time,Level,c).bbox(), 
00080                       Flags()(Time,Level,c).data(), FlagType);
00081       BBox OpBox = ush.interiorbbox(Time+ShTStep,Level,c);
00082       Coords& Os = OpBox.stepsize();
00083 
00084       for_1 (n, OpBox, Os)
00085         FastIndex1(ush,n) = fabs(FastIndex1(ush,n));
00086         if (FastIndex1(ush,n) >= Tol) { 
00087           FastIndex1(Flags,n) = FlagValue;
00088           FastIndex1(Flags,n+Os(0)/2) = FlagValue; 
00089         }
00090       end_for
00091 
00092       EndFastIndex1(ush);
00093       EndFastIndex1(Flags);
00094     end_forall
00095   } 
00096 
00097 };
00098 
00099 
00100 
00101 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04