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_FARRAYBOX_H
00024 #define BL_FARRAYBOX_H
00025
00026
00027
00028
00029
00030 #include <Pointers.H>
00031 #include <Box.H>
00032 #include <BaseFab.H>
00033 #include <REAL.H>
00034 #include <SPACE.H>
00035
00036 class FArrayBox;
00037
00038
00039
00041
00055 class FABio
00056 {
00057 public:
00064 enum Precision
00065 {
00066 FAB_FLOAT = 0,
00067 FAB_DOUBLE
00068 };
00089 enum Format
00090 {
00091 FAB_ASCII = 0,
00092 FAB_IEEE,
00093 FAB_NATIVE,
00094
00095
00096
00097
00098 FAB_8BIT = 4,
00099 FAB_IEEE_32
00100 };
00108 enum Ordering
00109 {
00110 FAB_NORMAL_ORDER,
00111 FAB_REVERSE_ORDER,
00112 FAB_REVERSE_ORDER_2
00113 };
00114
00115
00116
00117
00118
00119
00120
00121
00122 virtual ~FABio ();
00123
00124
00125
00126
00127
00128 virtual void read (std::istream& is,
00129 FArrayBox& fb) const = 0;
00130
00131
00132
00133
00134
00135
00136
00137 virtual void write (std::ostream& os,
00138 const FArrayBox& fb,
00139 int comp,
00140 int num_comp) const = 0;
00141
00142
00143
00144
00145
00146
00147 virtual void skip (std::istream& is,
00148 FArrayBox& f) const = 0;
00149
00150 virtual void skip (std::istream& is,
00151 FArrayBox& f,
00152 int nCompToSkip) const = 0;
00153
00154
00155
00156
00157 virtual void write_header (std::ostream& os,
00158 const FArrayBox& f,
00159 int nvar) const;
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 static FABio* read_header (std::istream& is,
00172 FArrayBox& f);
00173
00174
00175
00176
00177 static FABio* read_header (std::istream& is,
00178 FArrayBox& f,
00179 int compIndex,
00180 int& nCompAvailable);
00181 };
00182
00183
00185
00225 class FArrayBox
00226 :
00227 public BaseFab<Real>
00228 {
00229
00230
00231
00232 friend class FABio;
00233 public:
00234
00236
00237 FArrayBox ();
00238
00243 explicit FArrayBox (const Box& b,
00244 int ncomp=1);
00245
00246 FArrayBox (const FArrayBox&);
00247
00248 FArrayBox& operator= (const FArrayBox&);
00249 FArrayBox& operator= (const Real& r);
00250
00252
00253 ~FArrayBox ();
00254
00255
00256
00257 void resize (const Box& b,
00258 int N = 1);
00259
00266 Real norm (int p = 2,
00267 int scomp = 0,
00268 int ncomp = 1) const;
00269
00271
00272 Real norm (const Box& subbox,
00273 int p = 2,
00274 int scomp = 0,
00275 int ncomp = 1) const;
00276
00278
00279 friend std::ostream& operator<< (std::ostream& os,
00280 const FArrayBox& fb);
00281
00283
00284 friend std::istream& operator>> (std::istream& is,
00285 FArrayBox& fb);
00286
00290 void writeOn (std::ostream& of) const;
00291
00302 void writeOn (std::ostream& of,
00303 int comp,
00304 int num_comp=1) const;
00305
00307
00308 void readFrom (std::istream& is);
00309
00315 int readFrom (std::istream& is, int compIndex);
00316
00321 static Box skipFAB (std::istream& is,
00322 int& num_comp);
00323
00325
00326 static void skipFAB (std::istream& is);
00327
00334 static void setFormat (FABio::Format fmt);
00335
00337
00338 static FABio::Format getFormat ();
00339
00350 static void setOrdering (FABio::Ordering ordering);
00351
00356 static FABio::Ordering getOrdering ();
00357
00361 static void setPrecision (FABio::Precision precision);
00362
00367 static FABio::Precision getPrecision ();
00368
00370
00371 static const FABio& getFABio ();
00372
00376 static void setFABio (FABio* rd);
00377
00378 static bool set_do_initval (bool tf);
00379 static bool get_do_initval ();
00380 static Real set_initval (Real iv);
00381 static Real get_initval ();
00382
00383
00384
00385 static void Initialize ();
00386 static void Finalize ();
00387
00388 protected:
00389
00390
00391
00392
00393 static FABio::Format format;
00394 static FABio::Ordering ordering;
00395
00396
00397
00398 static FABio* fabio;
00399
00400
00401
00402 static bool do_initval;
00403 static Real initval;
00404 };
00405
00406 #endif