• VTF
  • FSI
  • AMROC
  • SFC
  • Motion
  • STLIB
  • Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • combl.f
  • cuser.i
  • fdisc.f
  • init2.f
  • Makefile.am
  • physbd2.f
  • FluidProblem.h
  • ip2eurfl.f
  • rpn2euhll.f
  • rpt2eu.f
  • chk2eu.f
  • rec2eu.f
  • flx2eu.f
  • flgout2eu.f
  • amr_beam_main.C
  • File List
  • File Members

fsi/beam-amroc/VibratingBeam/src/FluidProblem.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2003-2007 California Institute of Technology
00004 // Ralf Deiterding, ralf@cacr.caltech.edu
00005 
00006 #ifndef AMROC_FLUIDPROBLEM_H
00007 #define AMROC_FLUIDPROBLEM_H
00008 
00009 #include "euler2.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         int Time = CurrentTime(base::GH(),l);
00075         ((output_type*) _FileOutput)->Transform(base::U(), base::Work(), Time,
00076                                                 l, base::Dim()+4, base::t[l]);
00077         if (CurrentTime(base::GH(),base::CouplingLevel) != Time) 
00078           ((output_type*) _FileOutput)->Transform(base::U(), base::Work(), Time+TimeStep(base::U(),l),
00079                                                   l, base::Dim()+4, base::t[l]+base::dt[l]);      
00080       }
00081     END_WATCH(FLUID_CPL_PRESSURE_CALCULATE)
00082     base::SendBoundaryData();
00083   }
00084 
00085   virtual void Advance(double& t, double& dt) {
00086     base::Advance(t,dt);
00087     if (_NIntPoints<=0 || _NIntPoints>MaxIntPoints) return;
00088 
00089     int me = MY_PROC;
00090     // Calculate pressure
00091     for (register int l=0; l<=FineLevel(base::GH()); l++) {
00092       int Time = CurrentTime(base::GH(),l);
00093       int press_cnt = base::Dim()+4;
00094       ((output_type*) _FileOutput)->Transform(base::U(), base::Work(), Time, l, 
00095                                               press_cnt, base::t[l]);
00096     }
00097 
00098     DataType* p = new DataType[_NIntPoints];
00099     _Interpolation->PointsValues(base::Work(),base::t[0],_NIntPoints,_IntPoints,p);
00100     _Interpolation->ArrayCombine(VizServer,_NIntPoints,p);
00101 
00102     // Append to output file only on processor VizServer
00103     if (me == VizServer) {
00104       std::ofstream outfile;
00105       std::ostream* out;
00106       outfile.open(_IntName.c_str(), std::ios::out | std::ios::app);
00107       out = new std::ostream(outfile.rdbuf());
00108       *out << base::t[0];
00109       for (int ns=0; ns<_NIntPoints; ns++)
00110         *out << " " << p[ns]; 
00111       *out << std::endl;
00112       outfile.close();
00113       delete out;      
00114     }
00115 
00116     delete [] p;
00117   } 
00118 
00119 protected:
00120   IntegratorSpecific _IntegratorSpecific;
00121   InitialConditionSpecific _InitialConditionSpecific;
00122   BoundaryConditionsSpecific _BoundaryConditionsSpecific;
00123   interpolation_type* _Interpolation; 
00124   ControlDevice IntCtrl;
00125   int _NIntPoints;
00126   point_type _IntPoints[MaxIntPoints];
00127   std::string _IntName; 
00128 };