• VTF
  • FSI
  • AMROC
  • SFC
  • Motion
  • STLIB
  • Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

amroc/weno/WENOF77FileOutput.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2003-2007 California Institute of Technology
00004 // Ralf Deiterding, Carlos Pantano
00005 
00006 #ifndef AMROC_WENO_F77_FILEOUTPUT_H
00007 #define AMROC_WENO_F77_FILEOUTPUT_H
00008 
00016 #include "F77Interfaces/F77FileOutput.h"
00017 
00025 template <class VectorType, int dim>
00026 class WENOF77FileOutput : public F77OutBase<VectorType,dim>,
00027   public FileOutput<VectorType,dim> {
00028   typedef typename VectorType::InternalDataType DataType;
00029   typedef FileOutput<VectorType,dim> base;
00030   typedef F77OutBase<VectorType,dim> out_base;
00031 public:
00032   typedef typename base::vec_grid_fct_type vec_grid_fct_type;  
00033   typedef typename base::vec_grid_data_type vec_grid_data_type;  
00034   typedef typename base::grid_fct_type grid_fct_type;
00035   typedef typename base::grid_data_type grid_data_type;
00036   typedef typename out_base::generic_func_type generic_func_type;
00037 
00038   typedef void (*out_1_func_type) ( FI(1,VectorType), FI(1,DataType), BI, 
00039                                     const INTEGER& meqn, 
00040                                     const INTEGER& cnt, const DOUBLE& t );
00041   typedef void (*out_2_func_type) ( FI(2,VectorType), FI(2,DataType), BI, 
00042                                     const INTEGER& meqn, 
00043                                     const INTEGER& cnt, const DOUBLE& t );
00044   typedef void (*out_3_func_type) ( FI(3,VectorType), FI(3,DataType), BI, 
00045                                     const INTEGER& meqn, 
00046                                     const INTEGER& cnt, const DOUBLE& t );
00047 
00048    typedef void (*bnds_func_type) (INTEGER ix[], DOUBLE lbc[], DOUBLE ubc[], 
00049                                   DOUBLE dx[], const DOUBLE* bnd, 
00050                                   const INTEGER& mb, const INTEGER per[]);
00051 
00052   WENOF77FileOutput(generic_func_type out, generic_func_type bnds = 0) : 
00053     out_base(out), f_bnds(bnds) {}
00054 
00055   virtual ~WENOF77FileOutput() {}
00056   
00057   virtual void WriteOut(vec_grid_fct_type& u, grid_fct_type& IOfunc) {
00058     if (!out_base::f_out) return;    
00059     for (int cnt=1; cnt<=base::Ncnt(); cnt++) { 
00060       if (base::CompName[cnt-1].c_str()[0] == '-') 
00061         continue;
00062       for (int lev=0; lev<=FineLevel(base::GH()); lev++) {
00063         int Time = CurrentTime(base::GH(),lev); 
00064         double t = GetPhysicalTime(u,Time,lev);
00065         Transform(u,IOfunc,Time,lev,cnt,t);
00066         base::WriteOut(IOfunc,base::CompName[cnt-1].c_str(),Time,lev,t);
00067       }
00068 #ifndef DAGH_NO_MPI
00069       MPI_Barrier(comm_service::comm()); 
00070 #endif
00071     }
00072   }
00073 
00074   virtual void WriteOut(grid_fct_type& IOfunc, const char* name) 
00075   { base::WriteOut(IOfunc,name); }  
00076 
00077   virtual void WriteOut(grid_fct_type& IOfunc, const char* name, 
00078                         const int& Time, const int& Level, const double& t) 
00079   { base::WriteOut(IOfunc,name,Time,Level,t); }
00080 
00081   virtual void WriteOut(grid_data_type& IOdata, const char* name, 
00082                         const int& Time, const int& Level, const double& t) {
00083     base::WriteOut(IOdata,name,Time,Level,t);
00084   }
00085 
00086   virtual void Transform(vec_grid_fct_type& u, grid_fct_type& work, 
00087                          const int Time, const int& Level, 
00088                          const int cnt, const double& t) {
00089     if (!out_base::f_out) return;
00090     
00091     forall(u,Time,Level,c)
00092       vec_grid_data_type& u_old = u(Time, Level, c);
00093       BBox bb = u_old.bbox();
00094     
00095       if (f_bnds) {
00096         int mx[dim], d, per[dim];
00097         Coords ex = u_old.extents();
00098         for (d=0; d<dim; d++) { 
00099           mx[d] = ex(d)-2*base::NGhosts();
00100           per[d] = base::GH().periodicboundary(d);
00101         }
00102         
00103         DCoords dx = base::GH().worldStep(u_old.stepsize());
00104         DCoords lbc = base::GH().worldCoords(u_old.lower(), u_old.stepsize());
00105         DCoords ubc = base::GH().worldCoords(u_old.upper(), u_old.stepsize());
00106         
00107         ((bnds_func_type) f_bnds)(mx,lbc(),ubc(),dx(),base::GH().wholebndry(),
00108                                   base::GH().nbndry(),per);
00109       }
00110       
00111       if (dim == 1) 
00112         ((out_1_func_type) out_base::f_out)(FA(1,u(Time,Level,c)),
00113                                   FA(1,work(Time,Level,c)),
00114                                   BOUNDING_BOX(bb),out_base::_Equations,cnt,t);
00115       else if (dim == 2) 
00116         ((out_2_func_type) out_base::f_out)(FA(2,u(Time,Level,c)),
00117                                   FA(2,work(Time,Level,c)),
00118                                   BOUNDING_BOX(bb),out_base::_Equations,cnt,t);
00119       else if (dim == 3) 
00120         ((out_3_func_type) out_base::f_out)(FA(3,u(Time,Level,c)),
00121                                   FA(3,work(Time,Level,c)),
00122                                   BOUNDING_BOX(bb),out_base::_Equations,cnt,t);
00123     end_forall 
00124   }
00125 protected:
00126 generic_func_type f_bnds;
00127 };
00128 
00129 #endif