00001
00002
00003
00004
00005
00006 #ifndef AMROC_PROBLEM_H
00007 #define AMROC_PROBLEM_H
00008
00009 #include "eulerrhok2.h"
00010 #include "Species.h"
00011
00012 #define NAUX 5
00013
00014 #include "ClpProblem.h"
00015
00016 #define OWN_FLAGGING
00017 #define OWN_GFMAMRSOLVER
00018 #include "ClpStdGFMProblem.h"
00019 #include "F77Interfaces/F77UpdateLevelTransfer.h"
00020 #include "AMRInterpolation.h"
00021
00022 #define f_track FORTRAN_NAME(track, TRACK)
00023 extern "C" {
00024 void f_track(const INTEGER &, const DOUBLE *, const DOUBLE *, DOUBLE *, INTEGER&,
00025 const DOUBLE&, const DOUBLE&, const DOUBLE&);
00026 }
00027
00028 class FlaggingSpecific :
00029 public AMRFlagging<VectorType,FixupType,FlagType,DIM> {
00030 typedef AMRFlagging<VectorType,FixupType,FlagType,DIM> base;
00031 public:
00032 FlaggingSpecific(solver_type& solver) : base(solver) {
00033 base::AddCriterion(new FlagRegions<VectorType,FlagType,DIM>());
00034 base::AddCriterion(new ByValue<VectorType,FlagType,DIM>());
00035 base::AddCriterion(new ScaledGradient<VectorType,FlagType,DIM>());
00036 base::AddCriterion(new LimiterType<VectorType,FlagType,DIM>());
00037 base::AddCriterion(new AbsoluteError<VectorType,FixupType,FlagType,DIM>(solver));
00038 base::AddCriterion(new RelativeError<VectorType,FixupType,FlagType,DIM>(solver));
00039 base::AddCriterion(new F77ScaledGradient<VectorType,FlagType,DIM>(f_flg));
00040 base::AddCriterion(new F77LimiterType<VectorType,FlagType,DIM>(f_flg));
00041 base::AddCriterion(new F77AbsoluteError<VectorType,FixupType,FlagType,DIM>(solver,f_flg));
00042 base::AddCriterion(new F77RelativeError<VectorType,FixupType,FlagType,DIM>(solver,f_flg));
00043 }
00044 ~FlaggingSpecific() { DeleteAllCriterions(); }
00045
00046 virtual void init() {
00047 base::init();
00048 base::AddCriterion(new UnflagRegions<VectorType,FlagType,DIM>());
00049 }
00050 };
00051
00052 class SolverSpecific :
00053 public AMRGFMSolver<VectorType,FixupType,FlagType,DIM> {
00054 typedef VectorType::InternalDataType DataType;
00055 typedef AMRGFMSolver<VectorType,FixupType,FlagType,DIM> base;
00056 typedef F77GFMFileOutput<VectorType,FixupType,FlagType,DIM> output_type;
00057 typedef AMRInterpolation<VectorType,DIM> interpolation_type;
00058 typedef interpolation_type::point_type point_type;
00059 public:
00060 SolverSpecific(IntegratorSpecific& integ,
00061 base::initial_condition_type& init,
00062 base::boundary_conditions_type& bc) : base(integ, init, bc) {
00063 SetLevelTransfer(new F77UpdateLevelTransfer<VectorType,DIM>(f_prolong, f_restrict, f_tupdate));
00064 SetFileOutput(new F77GFMFileOutput<VectorType,FixupType,FlagType,DIM>(*this,f_out));
00065 SetFixup(new FixupSpecific(integ));
00066 SetFlagging(new FlaggingSpecific(*this));
00067 AddGFM(new GhostFluidMethod<VectorType,DIM>(
00068 new F77GFMBoundary<VectorType,DIM>(f_ibndrfl,f_itrans),
00069 new F77GFMLevelSet<DataType,DIM>(f_lset)));
00070 _Interpolation = new interpolation_type();
00071 TrackFront = 0;
00072 TrackYPos = 0.;
00073 TrackMin = 0.1;
00074 TrackMax = 1.e4;
00075 TrackdfMin = 1000.;
00076 }
00077
00078 ~SolverSpecific() {
00079 delete _LevelTransfer;
00080 delete _Flagging;
00081 delete _Fixup;
00082 delete _FileOutput;
00083 }
00084
00085 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl); }
00086 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00087 base::register_at(Ctrl, prefix);
00088 RegisterAt(base::LocCtrl,"TrackFront",TrackFront);
00089 RegisterAt(base::LocCtrl,"TrackYPos",TrackYPos);
00090 RegisterAt(base::LocCtrl,"TrackMin",TrackMin);
00091 RegisterAt(base::LocCtrl,"TrackMax",TrackMax);
00092 RegisterAt(base::LocCtrl,"TrackdfMin",TrackdfMin);
00093 }
00094
00095 virtual void SetupData() {
00096 base::SetupData();
00097 _Interpolation->SetupData(base::PGH(), base::NGhosts());
00098 }
00099
00100 virtual void AdvanceLevel(const int Level, int RegridEvery, bool RegridDone,
00101 bool ShadowAllowed, bool DoFixup,
00102 bool RecomposeBaseLev, bool RecomposeHighLev) {
00103
00104 base::AdvanceLevel(Level,RegridEvery,RegridDone,ShadowAllowed,
00105 DoFixup,RecomposeBaseLev,RecomposeHighLev);
00106
00107 if (Level==FineLevel(base::GH()) && TrackFront) {
00108 int me = MY_PROC;
00109 int Npoints, finelevel = FineLevel(base::GH());
00110 Npoints = base::shape[0]*RefinedBy(base::GH(),finelevel);
00111 double dx = DeltaX(base::GH(),0,finelevel);
00112
00113 DataType* p = new DataType[Npoints];
00114 DataType* r = new DataType[Npoints];
00115 DataType* xr = new DataType[Npoints];
00116 point_type* xc = new point_type[Npoints];
00117 register int n;
00118
00119 for (n=0; n<Npoints; n++) {
00120 r[n] = base::geom[0]+(n+0.5)*dx;
00121 xc[n](0) = r[n]; xc[n](1) = TrackYPos;
00122 }
00123
00124 for (register int l=0; l<=FineLevel(base::GH()); l++) {
00125 int Time = CurrentTime(base::GH(),l);
00126 int press_cnt = base::Dim()+4;
00127 ((output_type*) _FileOutput)->Transform(base::U(), base::Work(), Time, l,
00128 TrackFront, base::t[l]);
00129 }
00130
00131 _Interpolation->PointsValues(base::Work(),base::t[0],Npoints,xc,p);
00132 _Interpolation->ArrayCombine(VizServer,Npoints,p);
00133
00134 if (me == VizServer) {
00135 int nc;
00136 f_track(Npoints,p,r,xr,nc,TrackMin,TrackMax,TrackdfMin);
00137 std::ofstream outfile;
00138 std::ostream* out;
00139 std::string fname = "xpos.dat";
00140 outfile.open(fname.c_str(), std::ios::out | std::ios::app);
00141 out = new std::ostream(outfile.rdbuf());
00142 nc=int((xr[0]-base::geom[0])/dx);
00143 DataType pmax=p[nc];
00144 for (int j=nc+1; j<Npoints; j++)
00145 if (p[j]>=pmax) pmax=p[j];
00146 else break;
00147 *out << base::t[Level] << " " << xr[0] << " " << pmax << std::endl;
00148 outfile.close();
00149 delete out;
00150 }
00151
00152 delete [] p;
00153 delete [] r;
00154 delete [] xr;
00155 delete [] xc;
00156 }
00157 }
00158
00159 protected:
00160 int TrackFront;
00161 double TrackYPos, TrackMin, TrackMax, TrackdfMin;
00162 interpolation_type* _Interpolation;
00163 };
00164
00165 #endif
00166
00167
00168