00001
00002
00003
00004
00005
00006 #ifndef SCHEME_FILEOUTPUT_H
00007 #define SCHEME_FILEOUTPUT_H
00008
00015 #include "FileOutput.h"
00016
00017 template <class SchemeType, int dim>
00018 class SchemeOutBase {
00019 typedef typename SchemeType::VectorType VectorType;
00020 typedef typename VectorType::InternalDataType DataType;
00021 typedef GridFunction<VectorType,dim> vec_grid_fct_type;
00022 typedef GridFunction<DataType,dim> grid_fct_type;
00023
00024 public:
00025 SchemeOutBase(SchemeType &scheme) : _scheme(scheme) {}
00026
00027 virtual ~SchemeOutBase() {}
00028
00029 virtual void Transform(vec_grid_fct_type& u, grid_fct_type& work, const int Time, const int& Level,
00030 const int cnt, const double& t) {
00031 forall(u,Time,Level,c)
00032 Scheme().Output(u(Time,Level,c),work(Time,Level,c),cnt,0);
00033 end_forall
00034 }
00035
00036 inline SchemeType& Scheme() { return _scheme; }
00037 inline const SchemeType& Scheme() const { return _scheme; }
00038
00039 protected:
00040 SchemeType &_scheme;
00041 };
00042
00043
00050 template <class SchemeType, int dim>
00051 class SchemeFileOutput : public SchemeOutBase<SchemeType,dim>,
00052 public FileOutput<typename SchemeType::VectorType,dim> {
00053 typedef typename SchemeType::VectorType VectorType;
00054 typedef typename VectorType::InternalDataType DataType;
00055 typedef FileOutput<VectorType,dim> base;
00056 typedef SchemeOutBase<SchemeType,dim> out_base;
00057 public:
00058 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00059 typedef typename base::grid_fct_type grid_fct_type;
00060 typedef typename base::grid_data_type grid_data_type;
00061
00062 SchemeFileOutput(SchemeType &scheme) : out_base(scheme), base() {}
00063
00064 virtual ~SchemeFileOutput() {}
00065
00066 virtual void WriteOut(vec_grid_fct_type& u, grid_fct_type& IOfunc) {
00067 for (int cnt=1; cnt<=base::Ncnt(); cnt++) {
00068 if (base::CompName[cnt-1].c_str()[0] == '-')
00069 continue;
00070 for (int lev=0; lev<=FineLevel(base::GH()); lev++) {
00071 int Time = CurrentTime(base::GH(),lev);
00072 double t = GetPhysicalTime(u,Time,lev);
00073 this->Transform(u,IOfunc,Time,lev,cnt,t);
00074 base::WriteOut(IOfunc,base::CompName[cnt-1].c_str(),Time,lev,t);
00075 }
00076 #ifndef DAGH_NO_MPI
00077 MPI_Barrier(comm_service::comm());
00078 #endif
00079 }
00080 }
00081
00082 virtual void WriteOut(grid_fct_type& IOfunc, const char* name)
00083 { base::WriteOut(IOfunc,name); }
00084
00085 virtual void WriteOut(grid_fct_type& IOfunc, const char* name,
00086 const int& Time, const int& Level, const double& t)
00087 { base::WriteOut(IOfunc,name,Time,Level,t); }
00088
00089 virtual void WriteOut(grid_data_type& IOdata, const char* name,
00090 const int& Time, const int& Level, const double& t) {
00091 base::WriteOut(IOdata,name,Time,Level,t);
00092 }
00093 };
00094
00095 #endif