00001
00002
00003
00004
00005
00006 #ifndef AMROC_PROBLEM_H
00007 #define AMROC_PROBLEM_H
00008
00009 #include "eulerznd1.h"
00010 #include "ClpProblem.h"
00011 #define OWN_AMRSOLVER
00012 #include "ClpStdProblem.h"
00013 #include "AMRInterpolation.h"
00014
00015 #define MaxIntPoints (20)
00016
00017 class SolverSpecific :
00018 public AMRSolver<VectorType,FixupType,FlagType,DIM> {
00019 typedef AMRSolver<VectorType,FixupType,FlagType,DIM> base;
00020 typedef VectorType::InternalDataType DataType;
00021 public:
00022 typedef AMRInterpolation<VectorType,DIM> interpolation_type;
00023 typedef F77FileOutput<VectorType,DIM> output_type;
00024 typedef interpolation_type::point_type point_type;
00025
00026 SolverSpecific(IntegratorSpecific& integ,
00027 base::initial_condition_type& init,
00028 base::boundary_conditions_type& bc) :
00029 AMRSolver<VectorType,FixupType,FlagType,DIM>(integ, init, bc) {
00030 SetLevelTransfer(new F77LevelTransfer<VectorType,DIM>(f_prolong, f_restrict));
00031 #ifdef f_flgout
00032 SetFileOutput(new F77FileOutput<VectorType,DIM>(f_flgout));
00033 #else
00034 SetFileOutput(new FileOutput<VectorType,DIM>());
00035 #endif
00036 SetFixup(new FixupSpecific(integ));
00037 SetFlagging(new FlaggingSpecific(*this));
00038 _Interpolation = new interpolation_type();
00039 _NIntPoints = 0;
00040 _IntName = "ptrack.txt";
00041 }
00042
00043 ~SolverSpecific() {
00044 delete _LevelTransfer;
00045 delete _Flagging;
00046 delete _Fixup;
00047 delete _FileOutput;
00048 delete _Interpolation;
00049 }
00050
00051 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00052 base::register_at(Ctrl,prefix);
00053 IntCtrl = base::LocCtrl.getSubDevice("TrackPressure");
00054 RegisterAt(IntCtrl,"NPoints",_NIntPoints);
00055 char VariableName[32];
00056 for (int nc=0; nc<MaxIntPoints; nc++) {
00057 for (int d=0; d<base::Dim(); d++) {
00058 std::sprintf(VariableName,"Point(%d,%d)",nc+1,d+1);
00059 RegisterAt(IntCtrl,VariableName,_IntPoints[nc](d));
00060 _IntPoints[nc](d) = 0.0;
00061 }
00062 }
00063 RegisterAt(IntCtrl,"FileName",_IntName);
00064 }
00065 virtual void register_at(ControlDevice& Ctrl) {
00066 base::register_at(Ctrl);
00067 }
00068
00069 virtual void SetupData() {
00070 base::SetupData();
00071 _Interpolation->SetupData(base::PGH(), base::NGhosts());
00072 }
00073
00074 virtual void Advance(double& t, double& dt) {
00075 base::Advance(t,dt);
00076 if (_NIntPoints<=0 || _NIntPoints>MaxIntPoints) return;
00077
00078 int me = MY_PROC;
00079
00080 for (register int l=0; l<=FineLevel(base::GH()); l++) {
00081 int Time = CurrentTime(base::GH(),l);
00082 int press_cnt = base::Dim()+4;
00083 ((output_type*) _FileOutput)->Transform(base::U(), base::Work(), Time, l,
00084 press_cnt, base::t[l]);
00085 }
00086
00087 DataType* p = new DataType[_NIntPoints];
00088 _Interpolation->PointsValues(base::Work(),base::t[0],_NIntPoints,_IntPoints,p);
00089 _Interpolation->ArrayCombine(VizServer,_NIntPoints,p);
00090
00091
00092 if (me == VizServer) {
00093 std::ofstream outfile;
00094 std::ostream* out;
00095 outfile.open(_IntName.c_str(), std::ios::out | std::ios::app);
00096 out = new std::ostream(outfile.rdbuf());
00097 *out << base::t[0];
00098 for (int ns=0; ns<_NIntPoints; ns++)
00099 *out << " " << p[ns];
00100 *out << std::endl;
00101 outfile.close();
00102 delete out;
00103 }
00104
00105 delete [] p;
00106 }
00107
00108 protected:
00109 interpolation_type* _Interpolation;
00110 ControlDevice IntCtrl;
00111 int _NIntPoints;
00112 point_type _IntPoints[MaxIntPoints];
00113 std::string _IntName;
00114 };
00115