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 "F77Interfaces/F77FileOutput.h"
00024
00032 template <class VectorType, class FlagType, int dim>
00033 class F77ByValue : public F77OutBase<VectorType,dim>,
00034 public ByValue<VectorType,FlagType,dim> {
00035 typedef typename VectorType::InternalDataType DataType;
00036 typedef ByValue<VectorType,FlagType,dim> base;
00037 typedef F77OutBase<VectorType,dim> out_base;
00038 public:
00039 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00040 typedef typename base::grid_fct_type grid_fct_type;
00041 typedef typename base::flag_fct_type flag_fct_type;
00042 typedef typename out_base::generic_func_type generic_func_type;
00043
00044 F77ByValue(generic_func_type out) : out_base(out), base() {}
00045
00046 virtual ~F77ByValue() {}
00047
00048 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00049 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00050 { base::register_at(Ctrl, "F77"); }
00051
00052 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00053 const int& cnt, const int& Time, const int& Level, const double& t,
00054 const FlagType& FlagValue) {
00055 if (base::Tol(cnt) <= 0.0 ||
00056 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00057 out_base::Transform(u,work,Time,Level,cnt+1,t);
00058 int TStep = TimeStep(work,Level);
00059 forall(work,Time+TStep,Level,c)
00060 work(Time+TStep,Level,c).equals(work(Time,Level,c));
00061 end_forall
00062 base::FlagByValue(work, flags, Time, Level, base::Tol(cnt), FlagValue,
00063 base::_Comparison[cnt]);
00064 return true;
00065 }
00066
00067 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77value_%d",cnt+1); }
00068 };
00069
00070
00077 template <class VectorType, class FlagType, int dim>
00078 class F77ScaledGradient : public F77OutBase<VectorType,dim>,
00079 public ScaledGradient<VectorType,FlagType,dim> {
00080 typedef typename VectorType::InternalDataType DataType;
00081 typedef ScaledGradient<VectorType,FlagType,dim> base;
00082 typedef F77OutBase<VectorType,dim> out_base;
00083 public:
00084 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00085 typedef typename base::grid_fct_type grid_fct_type;
00086 typedef typename base::flag_fct_type flag_fct_type;
00087 typedef typename out_base::generic_func_type generic_func_type;
00088
00089 F77ScaledGradient(generic_func_type out) : out_base(out), base() {}
00090
00091 virtual ~F77ScaledGradient() {}
00092
00093 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00094 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00095 { base::register_at(Ctrl, "F77"); }
00096
00097 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00098 const int& cnt, const int& Time, const int& Level, const double& t,
00099 const FlagType& FlagValue) {
00100 if (base::Tol(cnt) <= 0.0 ||
00101 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00102 out_base::Transform(u,work,Time,Level,cnt+1,t);
00103 return base::FlagByScaledGradient(work, flags, Time, Level, base::Tol(cnt), FlagValue);
00104 }
00105
00106 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77grad_%d",cnt+1); }
00107 };
00108
00109
00116 template <class VectorType, class Fixup, class FlagType, int dim>
00117 class F77AbsoluteError : public F77OutBase<VectorType,dim>,
00118 public AbsoluteError<VectorType,Fixup,FlagType,dim> {
00119 typedef typename VectorType::InternalDataType DataType;
00120 typedef AbsoluteError<VectorType,Fixup,FlagType,dim> base;
00121 typedef F77OutBase<VectorType,dim> out_base;
00122 public:
00123 typedef typename base::solver_type solver_type;
00124 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00125 typedef typename base::grid_fct_type grid_fct_type;
00126 typedef typename base::flag_fct_type flag_fct_type;
00127 typedef typename out_base::generic_func_type generic_func_type;
00128
00129 F77AbsoluteError(solver_type& solver, generic_func_type out) : out_base(out), base(solver) {}
00130
00131 virtual ~F77AbsoluteError() {}
00132
00133 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00134 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00135 { base::register_at(Ctrl, "F77"); }
00136
00137 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00138 const int& cnt, const int& Time, const int& Level, const double& t,
00139 const FlagType& FlagValue) {
00140 if (base::Tol(cnt) <= 0.0 || Time==0 ||
00141 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00142 int TStep = TimeStep(work,Level);
00143 out_base::Transform(u,work,Time,Level,cnt+1,t);
00144 out_base::Transform(u,work,Time+TStep,Level,cnt+1,t);
00145 forall(work,Time,Level,c)
00146 work(Time+TStep,Level,c).minus(work(Time,Level,c));
00147 base::Abs(work(Time+TStep,Level,c));
00148 work(Time+TStep,Level,c).divide(base::Order);
00149 end_forall
00150 base::FlagByValue(work, flags, Time, Level, base::Tol(cnt), FlagValue);
00151 return true;
00152 }
00153
00154 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77abserr_%d",cnt+1); }
00155 };
00156
00157
00165 template <class VectorType, class FlagType, int dim>
00166 class F77LimiterType : public F77OutBase<VectorType,dim>,
00167 public LimiterType<VectorType,FlagType,dim> {
00168 typedef typename VectorType::InternalDataType DataType;
00169 typedef LimiterType<VectorType,FlagType,dim> base;
00170 typedef F77OutBase<VectorType,dim> out_base;
00171 public:
00172 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00173 typedef typename base::grid_fct_type grid_fct_type;
00174 typedef typename base::flag_fct_type flag_fct_type;
00175 typedef typename out_base::generic_func_type generic_func_type;
00176
00177 F77LimiterType(generic_func_type out) : out_base(out), base() {}
00178
00179 virtual ~F77LimiterType() {}
00180
00181 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00182 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00183 { base::register_at(Ctrl, "F77"); }
00184
00185 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00186 const int& cnt, const int& Time, const int& Level, const double& t,
00187 const FlagType& FlagValue) {
00188 if (base::Tol(cnt) <= 0.0 || base::Sc(cnt)<=0.0 ||
00189 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00190 out_base::Transform(u,work,Time,Level,cnt+1,t);
00191 return base::FlagByLimiter(work, flags, Time, Level, base::Tol(cnt), base::Sc(cnt), FlagValue);
00192 }
00193
00194 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77limtype_%d",cnt+1); }
00195 };
00196
00197
00204 template <class VectorType, class Fixup, class FlagType, int dim>
00205 class F77RelativeError : public F77OutBase<VectorType,dim>,
00206 public RelativeError<VectorType,Fixup,FlagType,dim> {
00207 typedef typename VectorType::InternalDataType DataType;
00208 typedef RelativeError<VectorType,Fixup,FlagType,dim> base;
00209 typedef F77OutBase<VectorType,dim> out_base;
00210 public:
00211 typedef typename base::solver_type solver_type;
00212 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00213 typedef typename base::grid_fct_type grid_fct_type;
00214 typedef typename base::flag_fct_type flag_fct_type;
00215 typedef typename out_base::generic_func_type generic_func_type;
00216
00217 F77RelativeError(solver_type& solver, generic_func_type out) : out_base(out), base(solver) {}
00218
00219 virtual ~F77RelativeError() {}
00220
00221 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl, "F77"); }
00222 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix)
00223 { base::register_at(Ctrl, "F77"); }
00224
00225 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00226 const int& cnt, const int& Time, const int& Level, const double& t,
00227 const FlagType& FlagValue) {
00228 if (base::Tol(cnt) <= 0.0 || base::Sc(cnt)<=0.0 || Time==0 ||
00229 (base::MaxLevel(cnt)<Level && base::MaxLevel(cnt)>=0)) return false;
00230 int TStep = TimeStep(work,Level);
00231 out_base::Transform(u,work,Time,Level,cnt+1,t);
00232 out_base::Transform(u,work,Time+TStep,Level,cnt+1,t);
00233 forall(u,Time,Level,c)
00234 work(Time+TStep,Level,c).minus(work(Time,Level,c));
00235 base::Abs(work(Time+TStep,Level,c));
00236 end_forall
00237
00238 if (base::OutputFlags() && base::Solver_().LastOutputTime()==Time && Level==0) {
00239 DataType Maxv = MaxVal(work, Time, 0);
00240 if (MY_PROC == VizServer)
00241 std::cout << " F77Max(" << cnt+1 << ") on L0=" << Maxv << " ";
00242 }
00243
00244 forall(u,Time,Level,c)
00245 base::Abs(work(Time,Level,c));
00246 base::Max(work(Time,Level,c),base::Sc(cnt));
00247 work(Time+TStep,Level,c).divide(work(Time,Level,c));
00248 work(Time+TStep,Level,c).divide(base::Order);
00249 end_forall
00250
00251 base::FlagByValue(work, flags, Time, Level, base::Tol(cnt), FlagValue);
00252 return true;
00253 }
00254
00255 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"f77relerr_%d",cnt+1); }
00256 };
00257
00258 #endif