00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef delphin5_outputH
00019 #define delphin5_outputH
00020
00021 #include <string>
00022 #include <vector>
00023 #include <utility>
00024 #include <iosfwd>
00025 #include <cstdio>
00026
00027 #include "delphin_output_lib_types.h"
00028
00030 namespace DELPHIN {
00031
00050 class Delphin5OutputData {
00051 public:
00053 enum type_t {
00054 T_FIELD_OUTPUT,
00055 T_FLUX_OUTPUT,
00056 NUM_T
00057 };
00058
00059 enum spaceType_t {
00060 ST_SINGLE,
00061 ST_MEAN,
00062 ST_INTEGRAL,
00063 NUM_ST
00064 };
00065
00066 enum timeType_t {
00067 TT_NONE,
00068 TT_MEAN,
00069 TT_INTEGRAL,
00070 NUM_TT
00071 };
00072
00074 enum dataFormat_t {
00075 DF_2D,
00076 DF_3D,
00077 DF_4D,
00078 DF_4D_FLUX,
00079 NUM_DF
00080 };
00081
00083 Delphin5OutputData() { clear(); }
00085 void clear();
00086
00100 bool read(const std::string& fname, bool header_only, std::string& errmsg,
00101 bool generate_postproc_info=true, ReadNotification * notify = NULL);
00102
00115 bool writeHeader(std::ostream& out, bool write_geometry, std::string& errmsg) const;
00116
00119 bool write(std::ostream& out, std::string& errmsg);
00120
00122 bool generatePostprocInfo(std::string& errmsg);
00123
00126 std::vector<LineData> & constructionLines();
00127
00130 std::vector<LineData> & boundaryLines();
00131
00132
00133
00135 std::string m_filename;
00136
00137
00138
00139 type_t m_type;
00140 std::string m_projectFile;
00141 std::string m_quantity;
00142 spaceType_t m_spaceType;
00143 timeType_t m_timeType;
00144 std::string m_valueUnit;
00145 std::string m_timeUnit;
00146 bool m_isBinary;
00147
00148
00149
00150 std::vector<MaterialDef> m_matDefs;
00151 Grid m_grid;
00152 std::vector<ElementGeometry> m_elementsVec;
00153 std::vector<SidesGeometry> m_sidesVec;
00154
00155
00156
00157 std::vector<int> m_nums;
00158
00159 std::vector<double> m_timepoints;
00160 std::vector< std::vector<double> > m_values;
00161
00162
00163
00164
00168 dataFormat_t m_dataFormat;
00169
00176 std::vector< std::vector<int> > m_elementMapping;
00177
00183 std::vector< std::vector<int> > m_valueMapping;
00184
00187 rectangle<unsigned int> m_gridLocation;
00188
00191 rectangle<double> m_coordinateLimits;
00192
00193
00194 private:
00199 bool readData(std::istream& in, std::string& errmsg, ReadNotification * notify);
00200
00207 bool readHeader(std::istream& in,
00208 std::string& errmsg, bool generate_postproc_info, ReadNotification * notify);
00209
00211 bool readBinaryHeader(std::istream& in,
00212 std::string& errmsg, bool generate_postproc_info, ReadNotification * notify);
00213
00216 bool parseHeader(std::istream& in, std::string& geometry_data, std::string& errmsg, ReadNotification * notify);
00218 bool parseHeader(std::FILE * in, char* geometry_data, size_t size, ReadNotification * notify);
00220 bool parseGeometryData(std::istream& in, std::string& errmsg, ReadNotification * notify);
00222 bool parseGeometryData(const char * geodata, std::string& errmsg, ReadNotification * notify);
00225 void writeGeometryData(std::ostream& out) const;
00227 bool readBinaryGeometryData(std::istream& in, std::string& errmsg, ReadNotification * notify);
00229 void writeBinaryGeometryData(std::ostream& out) const;
00230
00232 void generateConstructionLines();
00233
00234 std::vector<LineData> m_constructionLines;
00235 std::vector<LineData> m_boundaryLines;
00236
00237 std::size_t m_fileSize;
00238 std::string m_binaryFileVersion;
00239 };
00240
00242 std::ostream& operator<<(std::ostream& out, Delphin5OutputData::type_t t);
00243 void string2type(const std::string& str, Delphin5OutputData::type_t & t);
00244
00246 std::ostream& operator<<(std::ostream& out, Delphin5OutputData::spaceType_t t);
00247 void string2spaceType(const std::string& str, Delphin5OutputData::spaceType_t & t);
00248
00250 std::ostream& operator<<(std::ostream& out, Delphin5OutputData::timeType_t t);
00251 void string2timeType(const std::string& str, Delphin5OutputData::timeType_t & t);
00252
00253 }
00254
00285
00286 #endif // delphin5_output_h
00287