Skip to content
Snippets Groups Projects
Commit edc55c09 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Fixed some small ARH issues, add a small tool to generate arh meta files.

parent f94e0e7c
No related branches found
No related tags found
No related merge requests found
...@@ -31,16 +31,13 @@ namespace AMDiS { ...@@ -31,16 +31,13 @@ namespace AMDiS {
bool writeParallel, bool writeParallel,
int nProcs) int nProcs)
{ {
size_t nValueVectors = getNumValueVectors(filename);
vector<DOFVector<double>*> vecs(0); vector<DOFVector<double>*> vecs(0);
if (nValueVectors > 0) if (vec0)
vecs.push_back(vec0); vecs.push_back(vec0);
if (nValueVectors > 1) if (vec1)
vecs.push_back(vec1); vecs.push_back(vec1);
if (nValueVectors > 2) if (vec2)
vecs.push_back(vec2); vecs.push_back(vec2);
for (size_t i = 3; i < nValueVectors; i++)
vecs.push_back(NULL);
ArhReader::read(filename, mesh, vecs, writeParallel, nProcs); ArhReader::read(filename, mesh, vecs, writeParallel, nProcs);
} }
...@@ -141,7 +138,7 @@ namespace AMDiS { ...@@ -141,7 +138,7 @@ namespace AMDiS {
if (macroInMesh.count(elIndex) == 1) if (macroInMesh.count(elIndex) == 1)
elementStructure.fitMeshToStructure(mesh, refManager, false, elIndex); elementStructure.fitMeshToStructure(mesh, refManager, false, elIndex);
if(nValueVectors > 0){ if (nValueVectors > 0) {
uint32_t nValuesPerVector = 0; uint32_t nValuesPerVector = 0;
file.read(reinterpret_cast<char*>(&nValuesPerVector), 4); file.read(reinterpret_cast<char*>(&nValuesPerVector), 4);
...@@ -189,14 +186,33 @@ namespace AMDiS { ...@@ -189,14 +186,33 @@ namespace AMDiS {
} }
int ArhReader::getNumValueVectors(string filename)
{
ifstream file;
file.open(filename.c_str(), ios::in | ios::binary);
string typeId = "";
uint32_t nMacroElements = 0;
uint32_t nValueVectors = 0;
file.read(const_cast<char*>(typeId.data()), 4);
file.read(reinterpret_cast<char*>(&nMacroElements), 4);
file.read(reinterpret_cast<char*>(&nValueVectors), 4);
file.close();
return nValueVectors;
}
//the following three functions are identical to read/readfile except that they read from //the following three functions are identical to read/readfile except that they read from
//a block of memory instead of from a file //a block of memory instead of from a file
void ArhReader::readFromMemoryBlock(vector<char> &data, Mesh *mesh, void ArhReader::readFromMemoryBlock(vector<char> &data, Mesh *mesh,
DOFVector<double>* vec0, DOFVector<double>* vec0,
DOFVector<double>* vec1, DOFVector<double>* vec1,
DOFVector<double>* vec2, DOFVector<double>* vec2,
bool writeParallel, bool writeParallel,
int nProcs) int nProcs)
{ {
uint32_t nValueVectors; uint32_t nValueVectors;
memcpy(reinterpret_cast<char*>(&nValueVectors), &data[8], 4); memcpy(reinterpret_cast<char*>(&nValueVectors), &data[8], 4);
...@@ -215,9 +231,9 @@ namespace AMDiS { ...@@ -215,9 +231,9 @@ namespace AMDiS {
void ArhReader::readFromMemoryBlock(vector<char> &data, Mesh *mesh, void ArhReader::readFromMemoryBlock(vector<char> &data, Mesh *mesh,
vector<DOFVector<double>*> vecs, vector<DOFVector<double>*> vecs,
bool writeParallel, bool writeParallel,
int nProcs) int nProcs)
{ {
FUNCNAME("ArhReader::readFromMemoryBlock()"); FUNCNAME("ArhReader::readFromMemoryBlock()");
...@@ -230,8 +246,8 @@ namespace AMDiS { ...@@ -230,8 +246,8 @@ namespace AMDiS {
void ArhReader::readBlock(vector<char> &data, void ArhReader::readBlock(vector<char> &data,
Mesh *mesh, Mesh *mesh,
vector<DOFVector<double>*> vecs) vector<DOFVector<double>*> vecs)
{ {
FUNCNAME("ArhReader::readBlock()"); FUNCNAME("ArhReader::readBlock()");
......
...@@ -53,44 +53,26 @@ namespace AMDiS { ...@@ -53,44 +53,26 @@ namespace AMDiS {
int nProcs = -1); int nProcs = -1);
static void readFromMemoryBlock(vector<char> &data, Mesh *mesh, static void readFromMemoryBlock(vector<char> &data, Mesh *mesh,
DOFVector<double>* vec0 = NULL, DOFVector<double>* vec0 = NULL,
DOFVector<double>* vec1 = NULL, DOFVector<double>* vec1 = NULL,
DOFVector<double>* vec2 = NULL, DOFVector<double>* vec2 = NULL,
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
bool writeParallel = true, bool writeParallel = true,
#else #else
bool writeParallel = false, bool writeParallel = false,
#endif #endif
int nProcs = -1); int nProcs = -1);
static void readFromMemoryBlock(vector<char> &data, Mesh *mesh, static void readFromMemoryBlock(vector<char> &data, Mesh *mesh,
vector<DOFVector<double>*> vecs, vector<DOFVector<double>*> vecs,
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
bool writeParallel = true, bool writeParallel = true,
#else #else
bool writeParallel = false, bool writeParallel = false,
#endif #endif
int nProcs = -1); int nProcs = -1);
static int getNumValueVectors(string filename) static int getNumValueVectors(string filename);
{
ifstream file;
file.open(filename.c_str(), ios::in | ios::binary);
string typeId = "";
uint32_t nMacroElements = 0;
uint32_t nValueVectors = 0;
//uint32_t nAllValues = 0;
file.read(const_cast<char*>(typeId.data()), 4);
file.read(reinterpret_cast<char*>(&nMacroElements), 4);
file.read(reinterpret_cast<char*>(&nValueVectors), 4);
//file.read(reinterpret_cast<char*>(&nAllValues), 4);
file.close();
return nValueVectors;
}
private: private:
...@@ -102,8 +84,8 @@ namespace AMDiS { ...@@ -102,8 +84,8 @@ namespace AMDiS {
vector<double>& values, DOFVector<double>* vec); vector<double>& values, DOFVector<double>* vec);
static void readBlock(vector<char> &data, static void readBlock(vector<char> &data,
Mesh *mesh, Mesh *mesh,
vector<DOFVector<double>*> vecs); vector<DOFVector<double>*> vecs);
}; };
} }
......
...@@ -127,8 +127,11 @@ namespace AMDiS { ...@@ -127,8 +127,11 @@ namespace AMDiS {
void ArhWriter::writeMacroElement(ofstream &file, void ArhWriter::writeMacroElement(ofstream &file,
MeshStructure &code, MeshStructure &code,
vector<vector<double> >& values, vector<vector<double> >& values,
int32_t elIndex) uint32_t elIndex)
{ {
FUNCNAME("ArhWriter::writeMacroElement()");
MSG("WRITE INDEX: %d\n", elIndex);
file.write(reinterpret_cast<char*>(&elIndex), 4); file.write(reinterpret_cast<char*>(&elIndex), 4);
uint32_t nStructureCodes = code.getCode().size(); uint32_t nStructureCodes = code.getCode().size();
...@@ -140,7 +143,7 @@ namespace AMDiS { ...@@ -140,7 +143,7 @@ namespace AMDiS {
file.write(reinterpret_cast<char*>(&(const_cast<vector<uint64_t>&>(code.getCode())[0])), file.write(reinterpret_cast<char*>(&(const_cast<vector<uint64_t>&>(code.getCode())[0])),
8 * nStructureCodes); 8 * nStructureCodes);
if(values.size() > 0){ if (values.size() > 0) {
uint32_t nValuesPerVector = values[0].size(); uint32_t nValuesPerVector = values[0].size();
file.write(reinterpret_cast<char*>(&nValuesPerVector), 4); file.write(reinterpret_cast<char*>(&nValuesPerVector), 4);
......
...@@ -75,7 +75,7 @@ namespace AMDiS { ...@@ -75,7 +75,7 @@ namespace AMDiS {
static void writeMacroElement(std::ofstream &file, static void writeMacroElement(std::ofstream &file,
MeshStructure &code, MeshStructure &code,
std::vector<std::vector<double> >& values, std::vector<std::vector<double> >& values,
int32_t elIndex); uint32_t elIndex);
}; };
} }
......
...@@ -191,7 +191,7 @@ namespace AMDiS { ...@@ -191,7 +191,7 @@ namespace AMDiS {
} }
if (writeArhFormat) if (writeArhFormat)
ArhWriter::write(fn + ".arh", feSpace->getMesh(), solutionVecs); ArhWriter::write(paraFilename + ".arh", feSpace->getMesh(), solutionVecs);
#ifdef HAVE_PNG #ifdef HAVE_PNG
if (writePngFormat) { if (writePngFormat) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment