00001
00002
00003
00004
00005
00006 #ifndef AMROC_PROBLEM_H
00007 #define AMROC_PROBLEM_H
00008
00009 #include "eulerznd2.h"
00010
00011 #undef NAUX
00012 #define NAUX 4
00013
00014 #include "ClpProblem.h"
00015
00016 #define OWN_AMRSOLVER
00017 #include "ClpStdProblem.h"
00018 #include "SpecialOutput/AMRGridAccumulation.h"
00019
00020 #define f_rcveloc FORTRAN_NAME(rcveloc, RCVELOC)
00021 extern "C" {
00022 void f_rcveloc(const DOUBLE v[]);
00023 }
00024
00025 class SolverSpecific :
00026 public AMRSolver<VectorType,FixupType,FlagType,DIM> {
00027 typedef VectorType::InternalDataType DataType;
00028 typedef AMRSolver<VectorType,FixupType,FlagType,DIM> base;
00029 typedef AMRGridAccumulation<DataType,DIM> accumulation_type;
00030 typedef F77FileOutput<VectorType,DIM> output_type;
00031 public:
00032 SolverSpecific(IntegratorSpecific& integ,
00033 base::initial_condition_type& init,
00034 base::boundary_conditions_type& bc) :
00035 AMRSolver<VectorType,FixupType,FlagType,DIM>(integ, init, bc) {
00036 SetLevelTransfer(new F77LevelTransfer<VectorType,DIM>(f_prolong, f_restrict));
00037 SetFileOutput(new F77FileOutput<VectorType,DIM>(f_flgout));
00038 SetFixup(new FixupSpecific(integ));
00039 SetFlagging(new FlaggingSpecific(*this));
00040 _Accumulation = new accumulation_type(f_rcveloc);
00041 MaxType = 1;
00042 }
00043
00044 ~SolverSpecific() {
00045 delete _LevelTransfer;
00046 delete _Flagging;
00047 delete _Fixup;
00048 delete _FileOutput;
00049 delete _Accumulation;
00050 }
00051
00052 virtual void register_at(ControlDevice& Ctrl) { base::register_at(Ctrl); }
00053 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00054 base::register_at(Ctrl, prefix);
00055 RegisterAt(base::LocCtrl,"MaxType",MaxType);
00056 _Accumulation->register_at(base::LocCtrl, prefix);
00057 }
00058
00059 virtual void SetupData() {
00060 base::SetupData();
00061 _Accumulation->SetupData(base::PGH(), base::NGhosts());
00062 }
00063
00064 virtual void Initialize_(const double& dt_start) {
00065 base::Initialize_(dt_start);
00066 _Accumulation->Initialize();
00067 }
00068
00069 virtual void Output() {
00070 int Time = CurrentTime(base::GH(),0);
00071 if (Time == base::LastOutputTime()) return;
00072 _Accumulation->GridCombine(VizServer);
00073 int me = MY_PROC;
00074 if (me == VizServer) {
00075 int Level = _Accumulation->AccLevel();
00076 base::FileOutput_().WriteOut(_Accumulation->AccGrid(),_Accumulation->AccName(),
00077 Time,Level,base::t[0]);
00078 }
00079 base::Output();
00080 }
00081
00082 virtual void Checkpointing_(const char* CheckpointFile) {
00083 base::Checkpointing_(CheckpointFile);
00084 _Accumulation->Checkpointing();
00085 }
00086
00087 virtual bool Restart_(const char* CheckpointFile) {
00088 if (base::Restart_(CheckpointFile)) {
00089 _Accumulation->Restart();
00090 return true;
00091 }
00092 else
00093 return false;
00094 }
00095
00096 virtual void AdvanceLevel(const int Level, int RegridEvery, bool RegridDone,
00097 bool ShadowAllowed, bool DoFixup,
00098 bool RecomposeBaseLev, bool RecomposeHighLev) {
00099
00100 base::AdvanceLevel(Level,RegridEvery,RegridDone,ShadowAllowed,
00101 DoFixup,RecomposeBaseLev,RecomposeHighLev);
00102
00103 int Time = CurrentTime(base::GH(),Level);
00104 if (MaxType) {
00105 AdaptiveBoundaryUpdate(base::U(),Time,Level);
00106 Sync(base::U(),Time,Level);
00107 ExternalBoundaryUpdate(base::U(),Time,Level);
00108
00109 int irho = 1;
00110 int iu = 2;
00111 int iv = 3;
00112 int TStep = TimeStep(base::U(),Level);
00113 forall (base::U(),Time,Level,c)
00114 ((output_type*) base::_FileOutput)->Transform(base::U(), base::Work(), Time+TStep,
00115 Level, irho, base::t[Level]);
00116 Coords ss(base::U()(Time,Level,c).bbox().stepsize());
00117 BBox bbi(base::U().interiorbbox(Time,Level,c));
00118 BeginFastIndex2(U, base::U()(Time,Level,c).bbox(),
00119 base::U()(Time,Level,c).data(), VectorType);
00120 BeginFastIndex2(Work, Work()(Time,Level,c).bbox(),
00121 Work()(Time,Level,c).data(), DataType);
00122 BeginFastIndex2(WorkN, Work()(Time+TStep,Level,c).bbox(),
00123 Work()(Time+TStep,Level,c).data(), DataType);
00124 DataType uy, vx;
00125 DCoords dx = base::GH().worldStep(ss);
00126 for_2 (i, j, bbi, ss)
00127 vx = (FastIndex2(U,i+ss(0),j)(iv)/FastIndex2(WorkN,i+ss(0),j)-
00128 FastIndex2(U,i-ss(0),j)(iv)/FastIndex2(WorkN,i-ss(0),j))/(2.0*dx(0));
00129 uy = (FastIndex2(U,i,j+ss(1))(iu)/FastIndex2(WorkN,i,j+ss(1))-
00130 FastIndex2(U,i,j-ss(1))(iu)/FastIndex2(WorkN,i,j-ss(1)))/(2.0*dx(1));
00131 FastIndex2(Work,i,j) = std::fabs(vx-uy);
00132 end_for
00133 EndFastIndex2(U);
00134 EndFastIndex2(Work);
00135 EndFastIndex2(WorkN);
00136 end_forall
00137 }
00138 else {
00139 forall (base::U(),Time,Level,c)
00140 int ipress = base::Dim()+4;
00141 ((output_type*) base::_FileOutput)->Transform(base::U(), base::Work(), Time, Level,
00142 ipress, base::t[Level]);
00143 end_forall
00144 }
00145
00146 _Accumulation->Accumulate(base::Work(), Time, Level, base::t[Level]);
00147 }
00148 private:
00149 int MaxType;
00150 accumulation_type* _Accumulation;