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