Commit 65481c8d authored by Thomas Witkowski's avatar Thomas Witkowski

Fixed first nice bug in arh files support.

parent 231692b5
......@@ -8,7 +8,7 @@ namespace AMDiS {
using namespace std;
void ArhReader::read(string filename, Mesh *mesh)
void ArhReader::read(string filename, Mesh *mesh, bool ignoreFinerMesh)
{
FUNCNAME("ArhReader::read()");
......@@ -28,36 +28,36 @@ namespace AMDiS {
file.open(filename.c_str(), ios::in | ios::binary);
string typeId = "";
long nMacroElements = 0;
long nValueVectors = 0;
long nAllValues = 0;
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);
for (long i = 0; i < nMacroElements; i++) {
long elIndex = 0;
long nStructureCodes = 0;
long codeSize = 0;
for (unsigned int i = 0; i < nMacroElements; i++) {
uint32_t elIndex = 0;
uint32_t nStructureCodes = 0;
uint32_t codeSize = 0;
file.read(reinterpret_cast<char*>(&elIndex), 4);
file.read(reinterpret_cast<char*>(&nStructureCodes), 4);
file.read(reinterpret_cast<char*>(&codeSize), 4);
vector<unsigned long> structureCode(nStructureCodes);
file.read(reinterpret_cast<char*>(&(structureCode[0])), 4 * nStructureCodes);
file.read(reinterpret_cast<char*>(&(structureCode[0])), 8 * nStructureCodes);
MeshStructure elementStructure;
elementStructure.init(structureCode, codeSize);
elementStructure.fitMeshToStructure(mesh, refManager,
false, false, elIndex, true);
elementStructure.fitMeshToStructure(mesh, refManager, false,
false, elIndex, ignoreFinerMesh);
long nValuesPerVector = 0;
uint32_t nValuesPerVector = 0;
file.read(reinterpret_cast<char*>(&nValuesPerVector), 4);
for (long j = 0; j < nValuesPerVector * nValueVectors; j++) {
for (unsigned int j = 0; j < nValuesPerVector * nValueVectors; j++) {
double value = 0.0;
file.read(reinterpret_cast<char*>(&value), 8);
}
......
......@@ -29,7 +29,8 @@ namespace AMDiS {
class ArhReader
{
public:
static void read(std::string filename, Mesh *mesh);
static void read(std::string filename, Mesh *mesh,
bool ignoreFinerMesh = true);
};
}
......
......@@ -19,7 +19,7 @@ namespace AMDiS {
string typeId = "arhS";
file.write(typeId.c_str(), 4);
long nMacroElements = 0;
uint32_t nMacroElements = 0;
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirst(mesh, 0, Mesh::CALL_EL_LEVEL);
while (elInfo) {
......@@ -29,14 +29,14 @@ namespace AMDiS {
file.write(reinterpret_cast<char*>(&nMacroElements), 4);
long nValueVectors = 0;
uint32_t nValueVectors = 0;
file.write(reinterpret_cast<char*>(&nValueVectors), 4);
long nAllValues = 0;
uint32_t nAllValues = 0;
file.write(reinterpret_cast<char*>(&nAllValues), 4);
MeshStructure elementStructure;
long macroElIndex = -1;
int32_t macroElIndex = -1;
elInfo = stack.traverseFirst(mesh, -1, Mesh::CALL_EVERY_EL_PREORDER);
while (elInfo) {
......@@ -67,20 +67,20 @@ namespace AMDiS {
void ArhWriter::writeMacroElement(std::ofstream &file,
MeshStructure &code,
long elIndex)
int32_t elIndex)
{
file.write(reinterpret_cast<char*>(&elIndex), 4);
long nStructureCodes = code.getCode().size();
uint32_t nStructureCodes = code.getCode().size();
file.write(reinterpret_cast<char*>(&nStructureCodes), 4);
long codeSize = code.getNumElements();
uint32_t codeSize = code.getNumElements();
file.write(reinterpret_cast<char*>(&codeSize), 4);
file.write(reinterpret_cast<char*>(&(const_cast<vector<unsigned long int>&>(code.getCode())[0])),
4 * nStructureCodes);
8 * nStructureCodes);
long nValuesPerVector = 0;
uint32_t nValuesPerVector = 0;
file.write(reinterpret_cast<char*>(&nValuesPerVector), 4);
}
......
......@@ -37,7 +37,7 @@ namespace AMDiS {
protected:
static void writeMacroElement(std::ofstream &file,
MeshStructure &code,
long elIndex);
int32_t elIndex);
};
}
......
......@@ -257,8 +257,8 @@ namespace AMDiS {
elInfo = stack.traverseNext(elInfo);
} else {
TEST_EXIT(element->isLeaf())
("Mesh is finer than strucutre code! (Element index: %d\n",
element->getIndex());
("Mesh is finer than strucutre code! (Element index: %d Macro element index: %d)\n",
element->getIndex(), elInfo->getMacroElement()->getIndex());
}
}
......
......@@ -598,7 +598,7 @@ namespace AMDiS {
DegreeOfFreedom *edge[2];
if (el_info->getElement()->getMark() <= 0)
return el_info; /* element may not be refined */
return el_info; // element may not be refined
// === Get memory for a list of all elements at the refinement edge. ===
......
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