vtf-logo

clawpack/applications/euler/3d/ConvShock_Cyl/src/Problem.h

00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2003-2007 California Institute of Technology
00004 // Ralf Deiterding, ralf@amroc.net
00005 
00006 #ifndef AMROC_PROBLEM_H
00007 #define AMROC_PROBLEM_H
00008 
00009 #include "eulerznd3.h"
00010 #include "ClpProblem.h"
00011 
00012 #define f_track FORTRAN_NAME(track, TRACK)
00013 #define f_lsetrfl FORTRAN_NAME(lsrfl, LSRFL)
00014 #define f_lsetrdi FORTRAN_NAME(lsrdi, LSRDI)
00015 
00016 extern "C" {
00017   void f_track(const INTEGER &, const DOUBLE *, const DOUBLE *, DOUBLE *, INTEGER&,
00018                const DOUBLE&, const DOUBLE&, const DOUBLE&); 
00019   void f_lsetrfl();
00020   void f_lsetrdi();
00021 }
00022 
00023 #define OWN_GFMAMRSOLVER
00024 #include "ClpStdGFMProblem.h"
00025 #include "AMRGFMInterpolation.h"
00026 
00027 class SolverSpecific : 
00028   public AMRGFMSolver<VectorType,FixupType,FlagType,DIM> {
00029   typedef VectorType::InternalDataType DataType;
00030   typedef AMRGFMSolver<VectorType,FixupType,FlagType,DIM> base;
00031   typedef AMRGFMInterpolation<VectorType,FixupType,FlagType,DIM> interpolation_type;
00032   typedef interpolation_type::point_type point_type;
00033   typedef F77GFMFileOutput<VectorType,FixupType,FlagType,DIM> output_type;
00034 public:
00035   SolverSpecific(IntegratorSpecific& integ, 
00036                  base::initial_condition_type& init,
00037                  base::boundary_conditions_type& bc) : base(integ, init, bc) {
00038     SetLevelTransfer(new F77LevelTransfer<VectorType,DIM>(f_prolong, f_restrict));
00039 #ifdef f_flgout
00040     SetFileOutput(new F77GFMFileOutput<VectorType,FixupType,FlagType,DIM>(*this,f_flgout)); 
00041 #else   
00042     SetFileOutput(new GFMFileOutput<VectorType,FixupType,FlagType,DIM>(*this)); 
00043 #endif
00044     SetFixup(new FixupSpecific(integ));
00045     SetFlagging(new FlaggingSpecific(*this)); 
00046     AddGFM(new GhostFluidMethod<VectorType,DIM>(
00047               new F77GFMBoundary<VectorType,DIM>(f_ibndex,f_itrans),
00048               new F77GFMLevelSet<DataType,DIM>(f_lset)));
00049     AddGFM(new GhostFluidMethod<VectorType,DIM>(
00050               new F77GFMBoundary<VectorType,DIM>(f_ibndrfl,f_itrans),
00051               new F77GFMLevelSet<DataType,DIM>(f_lsetrdi)));
00052     AddGFM(new GhostFluidMethod<VectorType,DIM>(
00053               new F77GFMBoundary<VectorType,DIM>(f_ibndrfl,f_itrans),
00054               new F77GFMLevelSet<DataType,DIM>(f_lsetrfl)));
00055     _Interpolation = new interpolation_type(*this);
00056   }  
00057  
00058   ~SolverSpecific() {
00059     DeleteGFM(_GFM[0]);
00060     DeleteGFM(_GFM[1]);
00061     DeleteGFM(_GFM[2]);
00062     delete _Flagging;
00063     delete _Fixup;
00064     delete _Interpolation;
00065   }
00066 
00067   virtual void SetupData() {
00068     base::SetupData();
00069     _Interpolation->SetupData(base::PGH(), base::NGhosts());
00070   }
00071 
00072   virtual double Tick(int VariableTimeStepping, const double dtv[], const double cflv[],
00073                       int& Rejections) {
00074 
00075     double cfl = base::Tick(VariableTimeStepping, dtv, cflv, Rejections);
00076     return cfl;
00077 
00078 //     int me = MY_PROC; 
00079 //     int Npoints = 100, npos;
00080 //     double pi = 4.0*std::atan(1.0), alpha = 0.0, pmax = 0.0;
00081 //     double shk_pos[10];
00082 //     double fmin = 0.1, fmax = 1.e4, dfmin = 10.;
00083 //     for (npos=0; npos<10; alpha+=5.0, npos++) {
00084 
00085 //       DataType* p = new DataType[Npoints];
00086 //       DataType* r = new DataType[Npoints];
00087 //       DataType* xr = new DataType[Npoints];
00088 //       point_type* xc = new point_type[Npoints];
00089 //       register int n;
00090 
00091 //       for (n=0; n<Npoints; n++) {
00092 //      r[n] = 8.0/Npoints*n;
00093 //      xc[n](0) = r[n]*std::cos(alpha*pi/180.); xc[n](1) = r[n]*std::sin(alpha*pi/180.);
00094 //      xc[n](2) = 0.0;
00095 //       }
00096     
00097 //       for (register int l=0; l<=FineLevel(base::GH()); l++) {
00098 //      int Time = CurrentTime(base::GH(),l);
00099 //      int press_cnt = base::Dim()+4;
00100 //      ((output_type*) _FileOutput)->Transform(base::U(), base::Work(), Time, l, 
00101 //                                              press_cnt, base::t[l]);
00102 //       }
00103 
00104 //       _Interpolation->PointsValues(base::Work(),base::t[0],Npoints,xc,p);
00105 //       _Interpolation->ArrayCombine(VizServer,Npoints,p);
00106 
00107 //       if (me == VizServer) {
00108 //      int nc;
00109 //      for (n=0; n<Npoints; n++) 
00110 //        if (p[n]>pmax) pmax = p[n];
00111 //      if (base::t[0]<0.28) {
00112 //        dfmin = 10.;
00113 //        f_track(Npoints,p,r,xr,nc,fmin,fmax,dfmin);
00114 //        shk_pos[npos] = xr[0];
00115 //      }
00116 //      else {
00117 //        dfmin = 1000.;
00118 //        f_track(Npoints,p,r,xr,nc,fmin,fmax,dfmin);
00119 //        shk_pos[npos] = xr[nc-1];
00120 //      }
00121 //       }
00122       
00123 //       delete [] p;
00124 //       delete [] r;
00125 //       delete [] xr;  
00126 //       delete [] xc;
00127 //     }
00128 
00129 //     if (me == VizServer) {
00130 //       std::ofstream outfile;
00131 //       std::ostream* out;
00132 //       std::string fname = "shk.dat";
00133 //       outfile.open(fname.c_str(), std::ios::out | std::ios::app);
00134 //       out = new std::ostream(outfile.rdbuf());
00135 //       double sum = 0.0;
00136 //       for (npos=0; npos<10; npos++) 
00137 //      sum += shk_pos[npos];
00138 //       *out << base::t[0] << " " << pmax << " " << sum/10.;      
00139 //       for (npos=0; npos<10; npos++) 
00140 //      *out << " " << shk_pos[npos];
00141 //       *out << std::endl;
00142 //       outfile.close();
00143 //       delete out;      
00144 //     }
00145 
00146 //     return cfl;
00147   } 
00148 
00149 protected:
00150   interpolation_type* _Interpolation;