1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #ifndef AMDIS_ARH_READER2_H #define AMDIS_ARH_READER2_H /** \file Arh2Reader.h */ #include "AMDiS_fwd.h" #include "Global.h" #ifdef HAVE_PARALLEL_DOMAIN_AMDIS #define WRITE_PARALLEL true #else #define WRITE_PARALLEL false #endif namespace AMDiS { namespace io { /** \ingroup Input * \brief Reader for the AMDiS ARH-format - version 2 * * A collection of methods to read to various container types from * ARH-files. **/ namespace Arh2Reader { const uint8_t MAJOR = 2;  Siqi Ling committed Feb 01, 2014 27  const uint8_t MINOR = 1;  28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48  /** * \brief Read MeshStructure, refine the mesh and read dof values to sysVec by order. * When reading dof values, it puts the data into the correspond DOFVector * (according to their order in the sysVec and in the file, which is the same as the old ArhReader). * Normally, just use the default value of \ref writeParallel and \ref nProcs. * * You should notice these: * 1. DOFVectors in SystemVector are not allowed to have identical name. * 2. The length of DOFVectors in SystemVector is less than the length of values in the file. * 3. Nullptr of DOFVector is allowed in SystemVector. But all the non-null DOFvector have the same fespace * (number of Dofs per position) as the correspond value in the file. * * \param writeParallel * the default value in Sequential Model is false. * the default value in Parallel Model is true. * if the value is set to false, no matter in sequential or parallel mode, the processor(s) will * read the file of the same given name, without adding thier process numbers: for example: "-p1-". * if the value is set to true, in Parallel Model, the behavior depends on \ref nProcs. * But in Sequential Model, an error will be thrown. * \param nProcs  Siqi Ling committed May 09, 2014 49  * It only affects when \ref writeParallel is set to true.  50 51  * If nProcs is -1, and it's in Parallel Model, every processor reads their own filename (with processor * numbers). But in Sequential Model, an error will be thrown.  Siqi Ling committed May 09, 2014 52 53 54  * And you can also set nProcs to the number of the arh files created last time. Then every * processor will read all the files to search their own data block, which is useful for restart from * a different partition.  55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187  */ void readFile(std::string filename, SystemVector* sysVec, bool writeParallel = WRITE_PARALLEL, int nProcs = -1); inline void readFile(std::string filename, SystemVector& sysVec, bool writeParallel = WRITE_PARALLEL, int nProcs = -1) { readFile(filename, &sysVec, writeParallel, nProcs); } /// Read MeshStructure, refine the mesh and read dof values to vec0, vec1 and vec2 by order. /// the behavior is equal to readFile(string filename, SystemVector* sysVec). void readFile(std::string filename, DOFVector* vec0 = nullptr, DOFVector* vec1 = nullptr, DOFVector* vec2 = nullptr, bool writeParallel = WRITE_PARALLEL, int nProcs = -1); inline void readFile(std::string filename, DOFVector& vec0, bool writeParallel = WRITE_PARALLEL, int nProcs = -1) { readFile(filename, &vec0, nullptr, nullptr, writeParallel, nProcs); } /// Read MeshStructure, refine the mesh and read dof values to vecs by order. /// the behavior is equal to readFile(string filename, SystemVector* sysVec). void readFile(std::string filename, std::vector*> vecs, bool writeParallel = WRITE_PARALLEL, int nProcs = -1); /// Read MeshStructure and refine the mesh from arh file. void readFile(std::string filename, Mesh* mesh, bool writeParallel = WRITE_PARALLEL, int nProcs = -1); inline void readFile(std::string filename, Mesh& mesh, bool writeParallel = WRITE_PARALLEL, int nProcs = -1) { readFile(filename, &mesh, writeParallel, nProcs); } /** * \brief Read MeshStructure, refine the mesh and read dof values to sysVec by name. * It traverses all the values in the file to get the first matching value with the same name * and fespace, and then reads the data. If it doesn't find any matching, an error will be thrown. * Normally, just use the default value of \ref writeParallel and \ref nProcs. See readFile for * detail information. * * You should notice these: * 1. DOFVectors in SystemVector are not allowed to have identical name. * 2. The length of SystemVector is less than the length of values in the file. * 3. There is at least one value in the file has the same name and fespace as the DOFVector in SystemVector. */ void readByName(std::string filename, SystemVector *sysVec, bool writeParallel = WRITE_PARALLEL, int nProcs = -1); /// Read MeshStructure, refine the mesh and read dof values to vecs by name. /// the behavior is equal to readByName(string filename, SystemVector* sysVec). void readByName(std::string filename, std::vector*> vecs, bool writeParallel = WRITE_PARALLEL, int nProcs = -1); /// Read MeshStructure, refine the mesh and read dof values to vec by name. /// the behavior is equal to readByName(string filename, SystemVector* sysVec). void readByName(std::string filename, DOFVector& vec, bool writeParallel = WRITE_PARALLEL, int nProcs = -1); /// Read MeshStructure, refine the mesh and read dof values to vec by name. /// the behavior is equal to readByName(string filename, SystemVector* sysVec). void readByName(std::string filename, DOFVector* vec, bool writeParallel = WRITE_PARALLEL, int nProcs = -1); /// the behavior is equal to readMeta(string filename, vector(DOFvector*) vecs). void readMeta(std::string filename, DOFVector* vec0 = nullptr, DOFVector* vec1 = nullptr, DOFVector* vec2 = nullptr); /** * \brief first read a meta ARH file and get \ref elInRank. And then uses the elInRank map * to find all the arh files that contains the dof value vecs needs and sets data into vecs by order. * \param filename the name of meta ARH file. * \param vecs the vector of DOFVectors which you want to get value. */ void readMeta(std::string filename, std::vector*> vecs); /** * \brief Read meta data from a meta ARH file and put the information into \ref elInRank * and \ref elCodeSize and \ref arhPrefix. * \param elInRank map of macro index and the rank it belongs to. * \param elCodeSize map of macro index and the code size of MeshStructure of the macro. * \param arhPrefix the prefix of arh file which the meta data file comes from. * \return the number of subdomains a meta ARH file is defined for. */ int readMetaData(std::string filename, std::map &elInRank, std::map &elCodeSize, std::string &arhPrefix); ///Read meta data from a meta ARH file and put the information into \ref elInRank ///and \ref elCodeSize. And return the number of subdomains a meta ARH file is defined for. inline int readMetaData(std::string filename, std::map &elInRank, std::map &elCodeSize) { std::string tmp; return readMetaData(filename, elInRank, elCodeSize, tmp); }  Backofen, Rainer committed May 08, 2014 188 189 190 191 192  /// Same as readMetaData but collects inform^ation from a set of ARH-files int readMetaFromArh(std::string filename, std::map &elInRank, std::map &elCodeSize);  193 194 195 196  /// Only returns just the number of subdomains a meta ARH file is defined for. int readMetaData(std::string filename);  Siqi Ling committed May 09, 2014 197 198 199  /// Please make sure the number of processors matches the the number of parallel arh files /// when calling the following functions.  200 201 202 203 204 205 206 207 208 209 210 211 212 213  /// Returns the number of value vectors in the file. int readNumOfValueVectors(std::string filename, bool writeParallel = WRITE_PARALLEL); /// Returns the Header size of the file. int readHeaderSize(std::string filename, bool writeParallel = WRITE_PARALLEL); /// If the current version Arh2Reader can read the file, return true, else false. bool isReadable(std::string filename, bool writeParallel = WRITE_PARALLEL); } // end namespace Arh2Reader } } // end namespace io, AMDiS #endif