00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef AMROC_F77_CRITERIA_H
00010 #define AMROC_F77_CRITERIA_H
00011
00018 #include "Criteria/ByValue.h"
00019 #include "Criteria/ScaledGradient.h"
00020 #include "Criteria/AbsoluteError.h"
00021 #include "Criteria/LimiterType.h"
00022 #include "Criteria/RelativeError.h"
00023 #include "Criteria/Regions.h"
00024 #include "Criteria/MRPrediction.h"
00025 #include "F77Interfaces/F77FileOutput.h"
00026
00034 template <class VectorType, class FlagType, int dim>
00035 class F77ByValue : public F77OutBase<VectorType,dim>,
00036 public ByValue<VectorType,FlagType,dim> {
00037 typedef typename VectorType::InternalDataType DataType;
00038 typedef ByValue<VectorType,FlagType,dim> base;
00039 typedef F77OutBase<VectorType,dim> out_base;
00040 public:
00041 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00042 typedef typename base::grid_fct_type grid_fct_type;
00043 typedef typename base::flag_fct_type flag_fct_type;
00044 typedef typename out_base::generic_func_type generic_func_type;
00045
00046 F77ByValue(generic_func_type out) : out_base(out), base() {}
00047
00048 virtual ~F77ByValue() {}
00049
00050 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00051 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00052 { base::register_at(Ctrl, "F77"); }
00053
00054 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00055 const int& cnt, const int& Time, const int& Level, const double& t,
00056 const FlagType& FlagValue) {
00057 if (base::Tol(cnt) <= 0.0 ||
00058 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00059 this->Transform(u,work,Time,Level,cnt+1,t);
00060 int TStep = TimeStep(work,Level);
00061 forall(work,Time+TStep,Level,c)
00062 work(Time+TStep,Level,c).equals(work(Time,Level,c));
00063 end_forall
00064 base::FlagByValue(work, flags, Time, Level, base::Tol(cnt), FlagValue,
00065 base::_Comparison[cnt]);
00066 return true;
00067 }
00068
00069 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77value_%d",cnt+1); }
00070 };
00071
00072
00079 template <class VectorType, class FlagType, int dim>
00080 class F77ScaledGradient : public F77OutBase<VectorType,dim>,
00081 public ScaledGradient<VectorType,FlagType,dim> {
00082 typedef typename VectorType::InternalDataType DataType;
00083 typedef ScaledGradient<VectorType,FlagType,dim> base;
00084 typedef F77OutBase<VectorType,dim> out_base;
00085 public:
00086 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00087 typedef typename base::grid_fct_type grid_fct_type;
00088 typedef typename base::flag_fct_type flag_fct_type;
00089 typedef typename out_base::generic_func_type generic_func_type;
00090
00091 F77ScaledGradient(generic_func_type out) : out_base(out), base() {}
00092
00093 virtual ~F77ScaledGradient() {}
00094
00095 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00096 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00097 { base::register_at(Ctrl, "F77"); }
00098
00099 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00100 const int& cnt, const int& Time, const int& Level, const double& t,
00101 const FlagType& FlagValue) {
00102 if (base::Tol(cnt) <= 0.0 ||
00103 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00104 this->Transform(u,work,Time,Level,cnt+1,t);
00105 return base::FlagByScaledGradient(work, flags, Time, Level, base::Tol(cnt), FlagValue);
00106 }
00107
00108 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77grad_%d",cnt+1); }
00109 };
00110
00111
00118 template <class VectorType, class Fixup, class FlagType, int dim>
00119 class F77AbsoluteError : public F77OutBase<VectorType,dim>,
00120 public AbsoluteError<VectorType,Fixup,FlagType,dim> {
00121 typedef typename VectorType::InternalDataType DataType;
00122 typedef AbsoluteError<VectorType,Fixup,FlagType,dim> base;
00123 typedef F77OutBase<VectorType,dim> out_base;
00124 public:
00125 typedef typename base::solver_type solver_type;
00126 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00127 typedef typename base::grid_fct_type grid_fct_type;
00128 typedef typename base::flag_fct_type flag_fct_type;
00129 typedef typename out_base::generic_func_type generic_func_type;
00130
00131 F77AbsoluteError(solver_type& solver, generic_func_type out) : out_base(out), base(solver) {}
00132
00133 virtual ~F77AbsoluteError() {}
00134
00135 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00136 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00137 { base::register_at(Ctrl, "F77"); }
00138
00139 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00140 const int& cnt, const int& Time, const int& Level, const double& t,
00141 const FlagType& FlagValue) {
00142 if (base::Tol(cnt) <= 0.0 || Time==0 ||
00143 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00144 int TStep = TimeStep(work,Level);
00145 this->Transform(u,work,Time,Level,cnt+1,t);
00146 this->Transform(u,work,Time+TStep,Level,cnt+1,t);
00147 forall(work,Time,Level,c)
00148 work(Time+TStep,Level,c).minus(work(Time,Level,c));
00149 base::Abs(work(Time+TStep,Level,c));
00150 work(Time+TStep,Level,c).divide(base::Order);
00151 end_forall
00152 base::FlagByValue(work, flags, Time, Level, base::Tol(cnt), FlagValue);
00153 return true;
00154 }
00155
00156 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77abserr_%d",cnt+1); }
00157 };
00158
00159
00167 template <class VectorType, class FlagType, int dim>
00168 class F77LimiterType : public F77OutBase<VectorType,dim>,
00169 public LimiterType<VectorType,FlagType,dim> {
00170 typedef typename VectorType::InternalDataType DataType;
00171 typedef LimiterType<VectorType,FlagType,dim> base;
00172 typedef F77OutBase<VectorType,dim> out_base;
00173 public:
00174 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00175 typedef typename base::grid_fct_type grid_fct_type;
00176 typedef typename base::flag_fct_type flag_fct_type;
00177 typedef typename out_base::generic_func_type generic_func_type;
00178
00179 F77LimiterType(generic_func_type out) : out_base(out), base() {}
00180
00181 virtual ~F77LimiterType() {}
00182
00183 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00184 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00185 { base::register_at(Ctrl, "F77"); }
00186
00187 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00188 const int& cnt, const int& Time, const int& Level, const double& t,
00189 const FlagType& FlagValue) {
00190 if (base::Tol(cnt) <= 0.0 || base::Sc(cnt)<=0.0 ||
00191 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00192 this->Transform(u,work,Time,Level,cnt+1,t);
00193 return base::FlagByLimiter(work, flags, Time, Level, base::Tol(cnt), base::Sc(cnt), FlagValue);
00194 }
00195
00196 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77limtype_%d",cnt+1); }
00197 };
00198
00199
00206 template <class VectorType, class Fixup, class FlagType, int dim>
00207 class F77RelativeError : public F77OutBase<VectorType,dim>,
00208 public RelativeError<VectorType,Fixup,FlagType,dim> {
00209 typedef typename VectorType::InternalDataType DataType;
00210 typedef RelativeError<VectorType,Fixup,FlagType,dim> base;
00211 typedef F77OutBase<VectorType,dim> out_base;
00212 public:
00213 typedef typename base::solver_type solver_type;
00214 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00215 typedef typename base::grid_fct_type grid_fct_type;
00216 typedef typename base::flag_fct_type flag_fct_type;
00217 typedef typename out_base::generic_func_type generic_func_type;
00218
00219 F77RelativeError(solver_type& solver, generic_func_type out) : out_base(out), base(solver) {}
00220
00221 virtual ~F77RelativeError() {}
00222
00223 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00224 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00225 { base::register_at(Ctrl, "F77"); }
00226
00227 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00228 const int& cnt, const int& Time, const int& Level, const double& t,
00229 const FlagType& FlagValue) {
00230 if (base::Tol(cnt) <= 0.0 || base::Sc(cnt)<=0.0 || Time==0 ||
00231 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00232 int TStep = TimeStep(work,Level);
00233 this->Transform(u,work,Time,Level,cnt+1,t);
00234 this->Transform(u,work,Time+TStep,Level,cnt+1,t);
00235 forall(u,Time,Level,c)
00236 work(Time+TStep,Level,c).minus(work(Time,Level,c));
00237 base::Abs(work(Time+TStep,Level,c));
00238 end_forall
00239
00240 if (base::OutputFlags() && base::Solver_().LastOutputTime()==Time && Level==0) {
00241 DataType Maxv = MaxVal(work, Time, 0);
00242 if (MY_PROC == VizServer)
00243 std::cout << " F77Max(" << cnt+1 << ") on L0=" << Maxv << " ";
00244 }
00245
00246 forall(u,Time,Level,c)
00247 base::Abs(work(Time,Level,c));
00248 base::Max(work(Time,Level,c),base::Sc(cnt));
00249 work(Time+TStep,Level,c).divide(work(Time,Level,c));
00250 work(Time+TStep,Level,c).divide(base::Order);
00251 end_forall
00252
00253 base::FlagByValue(work, flags, Time, Level, base::Tol(cnt), FlagValue);
00254 return true;
00255 }
00256
00257 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77relerr_%d",cnt+1); }
00258 };
00259
00260
00267 template <class VectorType, class FlagType, int dim>
00268 class F77MRPrediction : public F77OutBase<VectorType,dim>,
00269 public MRPrediction<VectorType,FlagType,dim> {
00270 typedef typename VectorType::InternalDataType DataType;
00271 typedef MRPrediction<VectorType,FlagType,dim> base;
00272 typedef F77OutBase<VectorType,dim> out_base;
00273 public:
00274 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00275 typedef typename base::grid_fct_type grid_fct_type;
00276 typedef typename base::flag_fct_type flag_fct_type;
00277 typedef typename out_base::generic_func_type generic_func_type;
00278
00279 F77MRPrediction(generic_func_type out) : out_base(out), base() {}
00280
00281 virtual ~F77MRPrediction() {}
00282
00283 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00284 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00285 { base::register_at(Ctrl, "F77"); }
00286
00287 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00288 const int& cnt, const int& Time, const int& Level, const double& t,
00289 const FlagType& FlagValue) {
00290 if (base::Tol(cnt) <= 0.0 ||
00291 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00292 this->Transform(u,work,Time,Level,cnt+1,t);
00293
00294 return base::FlagByMRPrediction(work, flags, Time, Level, base::Tol[cnt], base::ThresholdNorm[cnt],
00295 base::Relative[cnt], FlagValue);
00296 }
00297
00298 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77mrpredict_%d",cnt+1); }
00299 };
00300
00301 #endif