00001
00002
00003 #ifndef AMROC_PROBLEM_H
00004 #define AMROC_PROBLEM_H
00005
00006 #define DIM 2
00007
00008
00009 #define OWN_AMRSOLVER
00010 #include "WENOProblem.h"
00011
00012 #define f_exact FORTRAN_NAME(exact, EXACT)
00013
00014 extern "C" {
00015 void f_exact();
00016 }
00017
00018 #ifdef SYNCTIME
00019 #include "WENOStdSyncTimeProblem.h"
00020 #else
00021 #include "WENOStdProblem.h"
00022 #endif
00023 #include "F77Interfaces/F77ExactSolution.h"
00024
00025 class SolverSpecific :
00026 #ifdef SYNCTIME
00027 public AMRPreAdaptSolverSyncTime<VectorType,FixupType,FlagType,DIM> {
00028 typedef AMRPreAdaptSolverSyncTime<VectorType,FixupType,FlagType,DIM> base;
00029 #else
00030 public AMRPreAdaptSolver<VectorType,FixupType,FlagType,DIM> {
00031 typedef AMRPreAdaptSolver<VectorType,FixupType,FlagType,DIM> base;
00032 #endif
00033 typedef AMRSolver<VectorType,FixupType,FlagType,DIM> bbase;
00034 typedef WENOIntegrator<VectorType,DIM> weno_integ_type;
00035 typedef VectorType::InternalDataType DataType;
00036 public:
00037 SolverSpecific(IntegratorSpecific& integ,
00038 bbase::initial_condition_type& init,
00039 bbase::boundary_conditions_type& bc) :
00040 #ifdef SYNCTIME
00041 AMRPreAdaptSolverSyncTime<VectorType,FixupType,FlagType,DIM>(integ, init, bc) {
00042 #else
00043 AMRPreAdaptSolver<VectorType,FixupType,FlagType,DIM>(integ, init, bc) {
00044 #endif
00045 SetLevelTransfer(new F77LevelTransfer<VectorType,DIM>(f_prolong, f_restrict));
00046 #ifdef f_flgout
00047 SetFileOutput(new F77FileOutput<VectorType,DIM>(f_flgout));
00048 #else
00049 SetFileOutput(new FileOutput<VectorType,DIM>());
00050 #endif
00051 SetFixup(new FixupSpecific());
00052 SetFlagging(new FlaggingSpecific(*this));
00053
00054 SetExactSolution(new F77ExactSolution<VectorType,DIM>(f_exact));
00055 }
00056
00057 ~SolverSpecific() {
00058 delete _LevelTransfer;
00059 delete _Flagging;
00060 delete _Fixup;
00061 delete _FileOutput;
00062 }
00063
00064 virtual void Initialize_(const double& dt_start) {
00065 base::Initialize_(dt_start);
00066 CalculateCurrentMass(mass_old);
00067 }
00068
00069 virtual double Tick(int VariableTimeStepping, const double dtv[],
00070 const double cflv[], int& Rejections) {
00071
00072 double cfl = base::Tick(VariableTimeStepping,dtv,cflv,Rejections);
00073
00074 VectorType mass_new;
00075 CalculateCurrentMass(mass_new);
00076
00077
00078 int me = MY_PROC;
00079 if (me == VizServer) {
00080 std::ofstream outfile;
00081 std::ostream* out;
00082 std::string fname = "mass.dat";
00083 outfile.open(fname.c_str(), std::ios::out | std::ios::app);
00084 out = new std::ostream(outfile.rdbuf());
00085 *out << base::t[0];
00086 for (int n=0; n<base::NEquations(); n++)
00087 *out << " " << mass_old[n]-mass_new[n];
00088 *out << std::endl;
00089 outfile.close();
00090 delete out;
00091 }
00092
00093 return cfl;
00094 }
00095
00096 void CalculateCurrentMass(VectorType& mass) {
00097 int Level=0;
00098 int Time = CurrentTime(base::GH(),Level);
00099 int TStep = TimeStep(base::U(),Level);
00100 forall (base::U(),Time,Level,c)
00101 base::U()(Time+TStep,Level,c).equals(base::U()(Time,Level,c));
00102 end_forall
00103
00104 DCoords dx = base::GH().worldStep(base::U().GF_StepSize(Level));
00105 mass = Sum(base::U(),Time+TStep,Level);
00106 for (int d=0; d<base::Dim(); d++) mass *= dx(d);
00107 }
00108
00109 protected:
00110 VectorType mass_old;
00111 };