Commit 2a48e331 authored by Siqi Ling's avatar Siqi Ling
Browse files

arh2 file reader uses minor to backward compatible

parent 934e8243
...@@ -24,7 +24,7 @@ namespace AMDiS { namespace io { ...@@ -24,7 +24,7 @@ namespace AMDiS { namespace io {
namespace Arh2Reader namespace Arh2Reader
{ {
const uint8_t MAJOR = 2; const uint8_t MAJOR = 2;
const uint8_t MINOR = 0; const uint8_t MINOR = 1;
/** /**
* \brief Read MeshStructure, refine the mesh and read dof values to sysVec by order. * \brief Read MeshStructure, refine the mesh and read dof values to sysVec by order.
......
...@@ -16,7 +16,7 @@ namespace AMDiS { namespace io { ...@@ -16,7 +16,7 @@ namespace AMDiS { namespace io {
namespace Arh2Writer namespace Arh2Writer
{ {
const uint8_t MAJOR = 2; const uint8_t MAJOR = 2;
const uint8_t MINOR = 0; const uint8_t MINOR = 1;
/** /**
* \brief write the meshstructure and the dof values of DOFVectors in sysVec * \brief write the meshstructure and the dof values of DOFVectors in sysVec
......
...@@ -22,7 +22,7 @@ namespace AMDiS { namespace io { ...@@ -22,7 +22,7 @@ namespace AMDiS { namespace io {
namespace detail namespace detail
{ {
void firstRead(ifstream& file) uint8_t firstRead(ifstream& file)
{ {
FUNCNAME("Arh2Reader::detail::firstRead"); FUNCNAME("Arh2Reader::detail::firstRead");
...@@ -42,6 +42,7 @@ namespace AMDiS { namespace io { ...@@ -42,6 +42,7 @@ namespace AMDiS { namespace io {
TEST_EXIT(minor <= AMDiS::io::Arh2Reader::MINOR) TEST_EXIT(minor <= AMDiS::io::Arh2Reader::MINOR)
("Cannot read Arh2 format: Arh2Reader minor version is %i is smaller than the file minor version %i.\n", ("Cannot read Arh2 format: Arh2Reader minor version is %i is smaller than the file minor version %i.\n",
AMDiS::io::Arh2Reader::MINOR, minor); AMDiS::io::Arh2Reader::MINOR, minor);
return minor;
} }
void setDofValues(int macroElIndex, Mesh *mesh, void setDofValues(int macroElIndex, Mesh *mesh,
...@@ -224,7 +225,7 @@ namespace AMDiS { namespace io { ...@@ -224,7 +225,7 @@ namespace AMDiS { namespace io {
uint32_t dim = 0, dow = 0; uint32_t dim = 0, dow = 0;
// Read fixed header // Read fixed header
firstRead(file); uint8_t minor = firstRead(file);
file.read(reinterpret_cast<char*>(&headerLen), 4); file.read(reinterpret_cast<char*>(&headerLen), 4);
file.read(reinterpret_cast<char*>(&dow), 4); file.read(reinterpret_cast<char*>(&dow), 4);
...@@ -232,7 +233,16 @@ namespace AMDiS { namespace io { ...@@ -232,7 +233,16 @@ namespace AMDiS { namespace io {
file.read(reinterpret_cast<char*>(&nFeSpaces), 4); file.read(reinterpret_cast<char*>(&nFeSpaces), 4);
file.read(reinterpret_cast<char*>(&nValueVectors), 4); file.read(reinterpret_cast<char*>(&nValueVectors), 4);
file.read(reinterpret_cast<char*>(&nMacroElements), 4); file.read(reinterpret_cast<char*>(&nMacroElements), 4);
file.read(const_cast<char*>(cps.data()), 4); switch(minor) {
case 0:
cps = "null";break;
case 1:
file.read(const_cast<char*>(cps.data()), 4);
break;
default:
ERROR_EXIT("Should not happen.\n");
break;
}
#ifdef HAVE_COMPRESSION #ifdef HAVE_COMPRESSION
TEST_EXIT(cps == "null" || cps == "zlib") TEST_EXIT(cps == "null" || cps == "zlib")
......
...@@ -21,8 +21,9 @@ namespace AMDiS { namespace io { ...@@ -21,8 +21,9 @@ namespace AMDiS { namespace io {
* 1. the type of file is equal to "arh2". * 1. the type of file is equal to "arh2".
* 2. the major version of Arh2Reader is equal to the one in the file. * 2. the major version of Arh2Reader is equal to the one in the file.
* 3. the minor version of Arh2Reader is bigger than the one in the file. * 3. the minor version of Arh2Reader is bigger than the one in the file.
* return: minor version
*/ */
void firstRead(std::ifstream& file); uint8_t firstRead(std::ifstream& file);
void setDofValues(int macroElIndex, Mesh *mesh, void setDofValues(int macroElIndex, Mesh *mesh,
std::vector<std::vector<double> >& values, std::vector<std::vector<double> >& values,
...@@ -70,4 +71,4 @@ namespace AMDiS { namespace io { ...@@ -70,4 +71,4 @@ namespace AMDiS { namespace io {
} // end namespace Arh2Reader } // end namespace Arh2Reader
} } // end namespace io, AMDiS } } // end namespace io, AMDiS
#endif #endif
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment