00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef AMROC_F77_FILEOUTPUT_H
00010 #define AMROC_F77_FILEOUTPUT_H
00011
00019 #include "FileOutput.h"
00020
00021 template <class VectorType, int dim>
00022 class F77OutBase {
00023 typedef typename VectorType::InternalDataType DataType;
00024 typedef GridFunction<VectorType,dim> vec_grid_fct_type;
00025 typedef GridFunction<DataType,dim> grid_fct_type;
00026
00027 public:
00028 typedef generic_fortran_func generic_func_type;
00029
00030 typedef void (*out_1_func_type) ( FI(1,VectorType), FI(1,DataType), BI, const INTEGER& meqn,
00031 const INTEGER& cnt, const DOUBLE& t );
00032 typedef void (*out_2_func_type) ( FI(2,VectorType), FI(2,DataType), BI, const INTEGER& meqn,
00033 const INTEGER& cnt, const DOUBLE& t );
00034 typedef void (*out_3_func_type) ( FI(3,VectorType), FI(3,DataType), BI, const INTEGER& meqn,
00035 const INTEGER& cnt, const DOUBLE& t );
00036
00037 F77OutBase(generic_func_type out) : f_out(out), _Equations(VectorType::Length()) {}
00038
00039 virtual ~F77OutBase() {}
00040
00041 virtual void Transform(vec_grid_fct_type& u, grid_fct_type& work, const int Time, const int& Level,
00042 const int cnt, const double& t) {
00043 if (!f_out) return;
00044 forall(u,Time,Level,c)
00045 BBox bb = u(Time,Level,c).bbox();
00046 if (dim == 1)
00047 ((out_1_func_type) f_out)(FA(1,u(Time,Level,c)),FA(1,work(Time,Level,c)),
00048 BOUNDING_BOX(bb),_Equations,cnt,t);
00049 else if (dim == 2)
00050 ((out_2_func_type) f_out)(FA(2,u(Time,Level,c)),FA(2,work(Time,Level,c)),
00051 BOUNDING_BOX(bb),_Equations,cnt,t);
00052 else if (dim == 3)
00053 ((out_3_func_type) f_out)(FA(3,u(Time,Level,c)),FA(3,work(Time,Level,c)),
00054 BOUNDING_BOX(bb),_Equations,cnt,t);
00055 end_forall
00056 }
00057
00058 inline void SetOutFunc(generic_func_type out) { f_out = out; }
00059 generic_func_type GetOutFunc() const { return f_out; }
00060
00061 protected:
00062 generic_func_type f_out;
00063 int _Equations;
00064 };
00065
00066
00075 template <class VectorType, int dim>
00076 class F77FileOutput : public F77OutBase<VectorType,dim>,
00077 public FileOutput<VectorType,dim> {
00078 typedef typename VectorType::InternalDataType DataType;
00079 typedef FileOutput<VectorType,dim> base;
00080 typedef F77OutBase<VectorType,dim> out_base;
00081 public:
00082 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00083 typedef typename base::grid_fct_type grid_fct_type;
00084 typedef typename base::grid_data_type grid_data_type;
00085 typedef typename out_base::generic_func_type generic_func_type;
00086
00087 F77FileOutput(generic_func_type out) : out_base(out), base() {}
00088
00089 virtual ~F77FileOutput() {}
00090
00091 virtual void WriteOut(vec_grid_fct_type& u, grid_fct_type& IOfunc) {
00092 if (!out_base::f_out) return;
00093 for (int cnt=1; cnt<=base::Ncnt(); cnt++) {
00094 if (base::CompName[cnt-1].c_str()[0] == '-')
00095 continue;
00096 for (int lev=0; lev<=FineLevel(base::GH()); lev++) {
00097 int Time = CurrentTime(base::GH(),lev);
00098 double t = GetPhysicalTime(u,Time,lev);
00099 this->Transform(u,IOfunc,Time,lev,cnt,t);
00100 base::WriteOut(IOfunc,base::CompName[cnt-1].c_str(),Time,lev,t);
00101 }
00102 #ifndef DAGH_NO_MPI
00103 MPI_Barrier(comm_service::comm());
00104 #endif
00105 }
00106 }
00107
00108 virtual void WriteOut(grid_fct_type& IOfunc, const char* name)
00109 { base::WriteOut(IOfunc,name); }
00110
00111 virtual void WriteOut(grid_fct_type& IOfunc, const char* name,
00112 const int& Time, const int& Level, const double& t)
00113 { base::WriteOut(IOfunc,name,Time,Level,t); }
00114
00115 virtual void WriteOut(grid_data_type& IOdata, const char* name,
00116 const int& Time, const int& Level, const double& t) {
00117 base::WriteOut(IOdata,name,Time,Level,t);
00118 }
00119 };
00120
00121 #endif