00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef BL_VISMF_H
00024 #define BL_VISMF_H
00025
00026
00027
00028 #include <MultiFab.H>
00029
00030
00031
00033
00038 class VisMF
00039 {
00040 public:
00041
00043
00044 enum How { OneFilePerCPU };
00045
00050 explicit VisMF (const std::string& mf_name);
00051
00053
00054 struct FabOnDisk
00055 {
00056
00058
00059 FabOnDisk ();
00060
00062
00063 FabOnDisk (const std::string& name, long offset);
00064
00065
00066
00067 std::string m_name;
00068 long m_head;
00069
00070
00071
00072 static const std::string Prefix;
00073 };
00074
00076
00077 struct Header
00078 {
00079
00080
00081
00082 enum { Version = 1 };
00083
00085
00086 Header ();
00087
00089
00090 Header (const MultiFab& mf, How how);
00091
00092
00093
00094 int m_vers;
00095 How m_how;
00096 int m_ncomp;
00097 int m_ngrow;
00098 BoxArray m_ba;
00099 Array< FabOnDisk > m_fod;
00100 Array< Array<Real> > m_min;
00101 Array< Array<Real> > m_max;
00102 };
00103
00105
00106 int nComp () const;
00107
00109
00110 int nGrow () const;
00111
00113
00114 int size () const;
00115
00117
00118 const BoxArray& boxArray () const;
00119
00121
00122 Real min (int fabIndex,
00123 int nComp) const;
00124
00126
00127 Real max (int fabIndex,
00128 int nComp) const;
00129
00134 const FArrayBox& GetFab (int fabIndex,
00135 int compIndex) const;
00136
00138
00139 void clear (int fabIndex,
00140 int compIndex);
00141
00143
00144 void clear (int fabIndex);
00145
00147
00148 void clear ();
00149
00156 static long Write (const MultiFab& mf,
00157 const std::string& name,
00158 VisMF::How how = OneFilePerCPU,
00159 bool set_ghost = false);
00160
00165 static void Read (MultiFab& mf,
00166 const std::string& name);
00167
00169
00170 enum { IO_Buffer_Size = 40960 * 32 };
00171
00172
00173
00174 #ifdef BL_SETBUF_SIGNED_CHAR
00175 typedef signed char Setbuf_Char_Type;
00176 #else
00177 typedef char Setbuf_Char_Type;
00178 #endif
00179
00181
00182 typedef Array<Setbuf_Char_Type> IO_Buffer;
00183
00185
00186 static long FileOffset (std::ostream& os);
00187
00189
00190 FArrayBox* readFAB (int fabIndex,
00191 const std::string& mfName);
00192
00194
00195 FArrayBox* readFAB (int fabIndex,
00196 int ncomp);
00197
00198 private:
00199
00200
00201
00202 VisMF (const VisMF&);
00203 VisMF& operator= (const VisMF&);
00204
00205 static FabOnDisk Write (const FArrayBox& fab,
00206 const std::string& filename,
00207 std::ostream& os,
00208 long& bytes);
00209
00210 static long WriteHeader (const std::string& mf_name,
00211 VisMF::Header& hdr);
00212
00213
00214
00215
00216
00217
00218 static FArrayBox* readFAB (int fabIndex,
00219 const std::string& mf_name,
00220 const Header& hdr,
00221 int ncomp = -1);
00222
00223 static std::string DirName (const std::string& filename);
00224
00225 static std::string BaseName (const std::string& filename);
00226
00227
00228
00229 static const std::string FabFileSuffix;
00230
00231
00232
00233 static const std::string MultiFabHdrFileSuffix;
00234
00235
00236
00237 std::string m_mfname;
00238
00239
00240
00241 Header m_hdr;
00242
00243
00244
00245 mutable Array< Array<FArrayBox*> > m_pa;
00246 };
00247
00248
00249
00250 std::ostream& operator<< (std::ostream& os, const VisMF::FabOnDisk& fod);
00251
00252
00253
00254 std::istream& operator>> (std::istream& is, VisMF::FabOnDisk& fod);
00255
00256
00257
00258 std::ostream& operator<< (std::ostream& os, const Array<VisMF::FabOnDisk>& fa);
00259
00260
00261
00262 std::istream& operator>> (std::istream& is, Array<VisMF::FabOnDisk>& fa);
00263
00264
00265
00266 std::ostream& operator<< (std::ostream& os, const VisMF::Header& hd);
00267
00268
00269
00270 std::istream& operator>> (std::istream& is, VisMF::Header& hd);
00271
00272 #endif