Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

Commit aeadcd83 authored by Siqi Ling's avatar Siqi Ling
Browse files

fix arh2file version backward compatibility problem

parent 81146d61
......@@ -24,7 +24,7 @@ namespace AMDiS { namespace io {
namespace Arh2Reader
{
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.
......
......@@ -16,7 +16,7 @@ namespace AMDiS { namespace io {
namespace Arh2Writer
{
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
......
......@@ -22,7 +22,7 @@ namespace AMDiS { namespace io {
namespace detail
{
void firstRead(ifstream& file)
uint8_t firstRead(ifstream& file)
{
FUNCNAME("Arh2Reader::detail::firstRead");
......@@ -42,6 +42,7 @@ namespace AMDiS { namespace io {
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",
AMDiS::io::Arh2Reader::MINOR, minor);
return minor;
}
void setDofValues(int macroElIndex, Mesh *mesh,
......@@ -215,8 +216,12 @@ namespace AMDiS { namespace io {
file.open(filename.c_str(), ios::in | ios::binary);
TEST_EXIT(file.is_open())
("Cannot open file %s\n", filename.c_str());
file.seekg (0, file.end);
int fileSize = file.tellg();
file.seekg (0, file.beg);
string cps(4, ' ');
string cps = "null";
uint32_t headerLen = 0;
uint32_t nMacroElements = 0;
uint32_t nValueVectors = 0;
......@@ -224,7 +229,7 @@ namespace AMDiS { namespace io {
uint32_t dim = 0, dow = 0;
// Read fixed header
firstRead(file);
uint8_t minor = firstRead(file);
file.read(reinterpret_cast<char*>(&headerLen), 4);
file.read(reinterpret_cast<char*>(&dow), 4);
......@@ -232,7 +237,9 @@ namespace AMDiS { namespace io {
file.read(reinterpret_cast<char*>(&nFeSpaces), 4);
file.read(reinterpret_cast<char*>(&nValueVectors), 4);
file.read(reinterpret_cast<char*>(&nMacroElements), 4);
file.read(const_cast<char*>(cps.data()), 4);
if(minor >= 1)
file.read(const_cast<char*>(cps.data()), 4);
#ifdef HAVE_COMPRESSION
TEST_EXIT(cps == "null" || cps == "zlib")
......@@ -351,11 +358,14 @@ namespace AMDiS { namespace io {
}
}
}
// Read data: meshstructure and dof values
for (unsigned int i = 0; i < nMacroElements; i++) {
stringstream dataStream(ios::out | ios::in | ios::binary);
int size = macroElSize[i];
int size = 0;
if(minor >= 1)
size = macroElSize[i];
else
size = (i != nMacroElements - 1) ? macroElSize[i + 1] - macroElSize[i] : fileSize - macroElSize[i];
char* buffer = new char[size];
file.read(buffer, size);
dataStream.write(buffer, size);
......@@ -391,6 +401,7 @@ namespace AMDiS { namespace io {
{
uint32_t nValuesPerVector = 0;
dataStream.read(reinterpret_cast<char*>(&nValuesPerVector), 4);
for(size_t k = 0; k < sortedFeSpaces[j].size(); k++)
{
values[valuePos + k].resize(nValuesPerVector);
......@@ -448,7 +459,6 @@ namespace AMDiS { namespace io {
WARNING("You haven't specified the target, no mesh or DOFVectors is given.\n");
return;
}
if (writeParallel) {
using boost::lexical_cast;
int sPos = filename.find(".arh");
......
......@@ -21,8 +21,9 @@ namespace AMDiS { namespace io {
* 1. the type of file is equal to "arh2".
* 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.
* return value: minor version
*/
void firstRead(std::ifstream& file);
uint8_t firstRead(std::ifstream& file);
void setDofValues(int macroElIndex, Mesh *mesh,
std::vector<std::vector<double> >& values,
......
Markdown is supported
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