ESYS13
Revision_
|
00001 00002 /******************************************************* 00003 * 00004 * Copyright (c) 2003-2012 by University of Queensland 00005 * Earth Systems Science Computational Center (ESSCC) 00006 * http://www.uq.edu.au/esscc 00007 * 00008 * Primary Business: Queensland, Australia 00009 * Licensed under the Open Software License version 3.0 00010 * http://www.opensource.org/licenses/osl-3.0.php 00011 * 00012 *******************************************************/ 00013 00014 #ifndef __WEIPA_ESCRIPTDATASET_H__ 00015 #define __WEIPA_ESCRIPTDATASET_H__ 00016 00017 #include <weipa/weipa.h> 00018 00019 #include <ostream> 00020 00021 class DBfile; 00022 00023 namespace escript { 00024 class AbstractDomain; 00025 class Data; 00026 } 00027 00028 00029 namespace weipa { 00030 00031 typedef std::vector<DataVar_ptr> DataChunks; 00032 typedef std::vector<DomainChunk_ptr> DomainChunks; 00033 00034 struct VarInfo { 00035 std::string varName; 00036 std::string units; 00037 DataChunks dataChunks; 00038 IntVec sampleDistribution; 00039 bool valid; 00040 }; 00041 00042 typedef std::vector<VarInfo> VarVector; 00043 00044 00047 // 00059 class WEIPA_DLL_API EscriptDataset 00060 { 00061 public: 00063 EscriptDataset(); 00064 00065 #if HAVE_MPI 00066 00067 EscriptDataset(MPI_Comm comm); 00068 #endif 00069 00071 ~EscriptDataset(); 00072 00079 bool setDomain(const escript::AbstractDomain* domain); 00080 00083 // setDomain(), otherwise you will get undefined behaviour later! 00084 bool addData(escript::Data& data, const std::string name, 00085 const std::string units = ""); 00086 00097 bool loadNetCDF(const std::string domainFilePattern, 00098 const StringVec& varFiles, const StringVec& varNames, 00099 int nChunks); 00100 00103 bool loadNetCDF(const DomainChunks& domain, const StringVec& varFiles, 00104 const StringVec& varNames); 00105 00107 void setCycleAndTime(int c, double t) { cycle=c; time=t; } 00108 00110 int getCycle() const { return cycle; } 00111 00113 double getTime() const { return time; } 00114 00117 void setMeshLabels(const std::string x, const std::string y, const std::string z=""); 00118 00121 void setMeshUnits(const std::string x, const std::string y, const std::string z=""); 00122 00125 void setMetadataSchemaString(const std::string schema, 00126 const std::string metadata) 00127 { mdSchema=schema; mdString=metadata; } 00128 00130 void setSaveMeshData(bool flag) { wantsMeshVars=flag; } 00131 00133 bool saveSilo(const std::string fileName, bool useMultiMesh=true); 00134 00136 bool saveVTK(const std::string fileName); 00137 00139 DomainChunks getConvertedDomain() { return domainChunks; } 00140 00142 const VarVector& getVariables() const { return variables; } 00143 00145 const VarVector& getMeshVariables() const { return meshVariables; } 00146 00147 #if HAVE_MPI 00148 MPI_Comm 00149 #else 00150 void* 00151 #endif 00152 getMPIComm() { return mpiComm; } 00153 00154 private: 00155 bool loadDomain(const std::string filePattern, int nChunks); 00156 bool setExternalDomain(const DomainChunks& domain); 00157 bool loadData(const std::string filePattern, const std::string name, 00158 const std::string units); 00159 00160 void convertMeshVariables(); 00161 void updateSampleDistribution(VarInfo& vi); 00162 void putSiloMultiMesh(DBfile* dbfile, const std::string& meshName); 00163 void putSiloMultiTensor(DBfile* dbfile, const VarInfo& vi); 00164 void putSiloMultiVar(DBfile* dbfile, const VarInfo& vi, 00165 bool useMeshFile = false); 00166 bool saveVTKsingle(const std::string& fileName, 00167 const std::string& meshName, const VarVector& vars); 00168 void writeVarToVTK(const VarInfo& varInfo, std::ostream& os); 00169 00170 int cycle; 00171 double time; 00172 std::string mdSchema, mdString; 00173 StringVec meshLabels, meshUnits; 00174 bool externalDomain, wantsMeshVars; 00175 DomainChunks domainChunks; 00176 VarVector variables, meshVariables; 00177 int mpiRank, mpiSize; 00178 #if HAVE_MPI 00179 MPI_Comm mpiComm; 00180 #else 00181 void* mpiComm; 00182 #endif 00183 }; 00184 00185 } // namespace weipa 00186 00187 #endif // __WEIPA_ESCRIPTDATASET_H__ 00188