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