00001
00002
00003
00004
00005
00006 #ifndef AMROC_PROBLEM_H
00007 #define AMROC_PROBLEM_H
00008
00009 #include "eulerrhok1.h"
00010
00011 #define NEQUATIONS 15
00012 #define NEQUSED 12
00013 #define NFIXUP 11
00014 #define NAUX 0
00015
00016 #include "ClpProblem.h"
00017
00018 #define OWN_FLAGGING
00019 #define OWN_AMRSOLVER
00020 #include "ClpStdProblem.h"
00021 #include "F77Interfaces/F77UpdateLevelTransfer.h"
00022
00023 #define MAXREGIONS 5
00024
00025 template <class VectorType, class FlagType, int dim>
00026 class PermanentFlagging : public StdCriterion<VectorType,FlagType,dim> {
00027 typedef typename VectorType::InternalDataType DataType;
00028 typedef StdCriterion<VectorType,FlagType,dim> base;
00029 public:
00030 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00031 typedef typename base::grid_fct_type grid_fct_type;
00032 typedef typename base::flag_fct_type flag_fct_type;
00033
00034 PermanentFlagging() {
00035 base::_IsUsed = true;
00036 }
00037
00038 virtual void register_at(ControlDevice& Ctrl) { register_at(Ctrl, ""); }
00039 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00040 base::LocCtrl = Ctrl.getSubDevice(prefix+"PermanentFlagging");
00041 char Name[16];
00042 for (int i=0; i<MAXREGIONS; i++) {
00043 x1[i] = -1.0; x2[i] = -1.0; lev[i] = -1;
00044 std::sprintf(Name,"x1(%d)",i+1);
00045 RegisterAt(base::LocCtrl,Name,x1[i]);
00046 std::sprintf(Name,"x2(%d)",i+1);
00047 RegisterAt(base::LocCtrl,Name,x2[i]);
00048 std::sprintf(Name,"l(%d)",i+1);
00049 RegisterAt(base::LocCtrl,Name,lev[i]);
00050 }
00051 }
00052
00053 virtual bool SetFlags(vec_grid_fct_type& u, grid_fct_type& work, flag_fct_type& flags,
00054 const int& cnt, const int& Time, const int& Level, const double& t,
00055 const FlagType& FlagValue) {
00056 forall(flags, Time, Level, c)
00057 BeginFastIndex1(err_flag, flags(Time,Level,c).bbox(),
00058 flags(Time,Level,c).data(), FlagType);
00059 BBox OpBox = flags.interiorbbox(Time,Level,c);
00060 Coords& OpBox_stepsize = OpBox.stepsize();
00061 Coords cell=OpBox.lower();
00062 for_1 (n, OpBox, OpBox_stepsize)
00063 cell(0) = n;
00064 DCoords xc = base::GH().worldCoords(cell, OpBox_stepsize);
00065 for (int i=0; i<MAXREGIONS; i++)
00066 if (xc(0)>=x1[i] && xc(0)<=x2[i] && Level<=lev[i])
00067 FastIndex1(err_flag,n) = BadPoint;
00068 end_for
00069 EndFastIndex1(err_flag);
00070 end_forall
00071 return true;
00072 }
00073
00074 virtual void OutputName(char* name, int cnt) { std::sprintf(name,"permanent_%d",cnt+1); }
00075
00076 private:
00077 double x1[MAXREGIONS];
00078 double x2[MAXREGIONS];
00079 int lev[MAXREGIONS];
00080 };
00081
00082 class FlaggingSpecific :
00083 public AMRFlagging<VectorType,FixupType,FlagType,DIM> {
00084 typedef AMRFlagging<VectorType,FixupType,FlagType,DIM> base;
00085 public:
00086 FlaggingSpecific(base::solver_type& solver) : base(solver) {
00087 base::AddCriterion(new F77ScaledGradient<VectorType,FlagType,DIM>(f_flg));
00088 base::AddCriterion(new F77LimiterType<VectorType,FlagType,DIM>(f_flg));
00089 base::AddCriterion(new F77AbsoluteError<VectorType,FixupType,FlagType,DIM>(solver,f_flg));
00090 base::AddCriterion(new F77RelativeError<VectorType,FixupType,FlagType,DIM>(solver,f_flg));
00091 base::AddCriterion(new PermanentFlagging<VectorType,FlagType,DIM>());
00092 }
00093
00094 ~FlaggingSpecific() { DeleteAllCriterions(); }
00095 };
00096
00097 class SolverSpecific :
00098 public AMRSolver<VectorType,FixupType,FlagType,DIM> {
00099 typedef AMRSolver<VectorType,FixupType,FlagType,DIM> base;
00100 public:
00101 SolverSpecific(IntegratorSpecific& integ,
00102 base::initial_condition_type& init,
00103 base::boundary_conditions_type& bc) :
00104 AMRSolver<VectorType,FixupType,FlagType,DIM>(integ, init, bc) {
00105 SetLevelTransfer(new F77UpdateLevelTransfer<VectorType,DIM>(f_prolong, f_restrict, f_tupdate));
00106 SetFileOutput(new F77FileOutput<VectorType,DIM>(f_out));
00107 SetFixup(new FixupSpecific(integ));
00108 SetFlagging(new FlaggingSpecific(*this));
00109 }
00110
00111 ~SolverSpecific() {
00112 delete _LevelTransfer;
00113 delete _Flagging;
00114 delete _Fixup;
00115 delete _FileOutput;