Commit 1641e793 authored by Siqi Ling's avatar Siqi Ling
Browse files

change in arh, parh file. update with meshconv

parent 7acfe3ad
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
#include "detail/Arh3Writer.h" #include "detail/Arh3Writer.h"
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#define WRITE_MACRO false #define WRITE_MACRO Macroformat::NONE
#else #else
#define WRITE_MACRO true #define WRITE_MACRO Macroformat::PT_MACROFILE
#endif #endif
namespace AMDiS { namespace io { namespace AMDiS { namespace io {
...@@ -50,9 +50,9 @@ namespace AMDiS { namespace io { ...@@ -50,9 +50,9 @@ namespace AMDiS { namespace io {
inline void writeFile(SystemVector *sysVec, inline void writeFile(SystemVector *sysVec,
std::string filename, std::string filename,
bool writeParallel = true, bool writeParallel = true,
Cpsformat cps = NONE, Cpsformat::Value cps = Cpsformat::NONE,
std::string dataformat = "SF64", std::string dataformat = "SF64",
bool writeMacro = WRITE_MACRO) Macroformat::Value writeMacro = WRITE_MACRO)
{ {
std::vector<DOFVector<double>*> vecs; std::vector<DOFVector<double>*> vecs;
for (int i = 0; i < sysVec->getSize(); i++) for (int i = 0; i < sysVec->getSize(); i++)
...@@ -63,9 +63,9 @@ namespace AMDiS { namespace io { ...@@ -63,9 +63,9 @@ namespace AMDiS { namespace io {
inline void writeFile(SystemVector &sysVec, inline void writeFile(SystemVector &sysVec,
std::string filename, std::string filename,
bool writeParallel = true, bool writeParallel = true,
Cpsformat cps = NONE, Cpsformat::Value cps = Cpsformat::NONE,
std::string dataformat = "SF64", std::string dataformat = "SF64",
bool writeMacro = WRITE_MACRO) Macroformat::Value writeMacro = WRITE_MACRO)
{ {
writeFile(&sysVec, filename, writeParallel, cps, dataformat, writeMacro); writeFile(&sysVec, filename, writeParallel, cps, dataformat, writeMacro);
} }
...@@ -75,9 +75,9 @@ namespace AMDiS { namespace io { ...@@ -75,9 +75,9 @@ namespace AMDiS { namespace io {
inline void writeFile(DOFVector<double>* vec0, inline void writeFile(DOFVector<double>* vec0,
std::string filename, std::string filename,
bool writeParallel = true, bool writeParallel = true,
Cpsformat cps = NONE, Cpsformat::Value cps = Cpsformat::NONE,
std::string dataformat = "SF64", std::string dataformat = "SF64",
bool writeMacro = WRITE_MACRO) Macroformat::Value writeMacro = WRITE_MACRO)
{ {
std::vector<DOFVector<double>*> vecs; std::vector<DOFVector<double>*> vecs;
vecs.push_back(vec0); vecs.push_back(vec0);
...@@ -89,9 +89,9 @@ namespace AMDiS { namespace io { ...@@ -89,9 +89,9 @@ namespace AMDiS { namespace io {
inline void writeFile(DOFVector<double>& vec0, inline void writeFile(DOFVector<double>& vec0,
std::string filename, std::string filename,
bool writeParallel = true, bool writeParallel = true,
Cpsformat cps = NONE, Cpsformat::Value cps = Cpsformat::NONE,
std::string dataformat = "SF64", std::string dataformat = "SF64",
bool writeMacro = WRITE_MACRO) Macroformat::Value writeMacro = WRITE_MACRO)
{ {
writeFile(&vec0, filename, writeParallel, cps, dataformat, writeMacro); writeFile(&vec0, filename, writeParallel, cps, dataformat, writeMacro);
} }
...@@ -101,9 +101,9 @@ namespace AMDiS { namespace io { ...@@ -101,9 +101,9 @@ namespace AMDiS { namespace io {
inline void writeFile(std::vector<DOFVector<double>*> vecs, inline void writeFile(std::vector<DOFVector<double>*> vecs,
std::string filename, std::string filename,
bool writeParallel = true, bool writeParallel = true,
Cpsformat cps = NONE, Cpsformat::Value cps = Cpsformat::NONE,
std::string dataformat = "SF64", std::string dataformat = "SF64",
bool writeMacro = WRITE_MACRO) Macroformat::Value writeMacro = WRITE_MACRO)
{ {
detail::write(filename, NULL, vecs, writeParallel, cps, dataformat, writeMacro); detail::write(filename, NULL, vecs, writeParallel, cps, dataformat, writeMacro);
} }
...@@ -112,9 +112,9 @@ namespace AMDiS { namespace io { ...@@ -112,9 +112,9 @@ namespace AMDiS { namespace io {
inline void writeFile(Mesh *mesh, inline void writeFile(Mesh *mesh,
std::string filename, std::string filename,
bool writeParallel = true, bool writeParallel = true,
Cpsformat cps = NONE, Cpsformat::Value cps = Cpsformat::NONE,
std::string dataformat = "SF64", std::string dataformat = "SF64",
bool writeMacro = WRITE_MACRO) Macroformat::Value writeMacro = WRITE_MACRO)
{ {
std::vector<DOFVector<double>*> vecs; std::vector<DOFVector<double>*> vecs;
detail::write(filename, mesh, vecs, writeParallel, cps, dataformat, writeMacro); detail::write(filename, mesh, vecs, writeParallel, cps, dataformat, writeMacro);
......
...@@ -228,7 +228,7 @@ namespace AMDiS { namespace io { ...@@ -228,7 +228,7 @@ namespace AMDiS { namespace io {
TEST_EXIT(file.is_open()) TEST_EXIT(file.is_open())
("Cannot open file %s\n", filename.c_str()); ("Cannot open file %s\n", filename.c_str());
Cpsformat cps = NONE; Cpsformat::Value cps = Cpsformat::NONE;
uint32_t headerLen = 0; uint32_t headerLen = 0;
uint32_t nMacroElements = 0; uint32_t nMacroElements = 0;
uint32_t nValueVectors = 0; uint32_t nValueVectors = 0;
...@@ -246,15 +246,15 @@ namespace AMDiS { namespace io { ...@@ -246,15 +246,15 @@ namespace AMDiS { namespace io {
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(reinterpret_cast<char*>(&cpsflag), 4); file.read(reinterpret_cast<char*>(&cpsflag), 4);
cps = static_cast<Cpsformat>(cpsflag); cps = static_cast<Cpsformat::Value>(cpsflag);
#ifdef HAVE_COMPRESSION #ifdef HAVE_COMPRESSION
TEST_EXIT(cps == ZLIB || TEST_EXIT(cps == Cpsformat::ZLIB ||
cps == BZIP2 || cps == Cpsformat::BZIP2 ||
cps == NONE) cps == Cpsformat::NONE)
("Cannot read Arh2 file. Currently only support zlib and bzip2 compression.\n"); ("Cannot read Arh2 file. Currently only support zlib and bzip2 compression.\n");
#else #else
TEST_EXIT(cps == NONE) TEST_EXIT(cps == Cpsformat::NONE)
("HAVE_COMPRESSION OFF. Cannot read compressed Arh2 file.\n"); ("HAVE_COMPRESSION OFF. Cannot read compressed Arh2 file.\n");
#endif #endif
...@@ -323,7 +323,7 @@ namespace AMDiS { namespace io { ...@@ -323,7 +323,7 @@ namespace AMDiS { namespace io {
dataformat.push_back(tmpString); dataformat.push_back(tmpString);
} }
// Read macroFile_nl // Read macroFile_nl //TODO
uint32_t macroFile_nl = 0; uint32_t macroFile_nl = 0;
file.read(reinterpret_cast<char*>(&macroFile_nl), 4); file.read(reinterpret_cast<char*>(&macroFile_nl), 4);
if (macroFile_nl > 0) { if (macroFile_nl > 0) {
...@@ -412,13 +412,13 @@ namespace AMDiS { namespace io { ...@@ -412,13 +412,13 @@ namespace AMDiS { namespace io {
boost::iostreams::filtering_streambuf<boost::iostreams::input> in; boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
switch(cps) switch(cps)
{ {
case ZLIB: case Cpsformat::ZLIB:
in.push(boost::iostreams::zlib_decompressor()); in.push(boost::iostreams::zlib_decompressor());
break; break;
case BZIP2: case Cpsformat::BZIP2:
in.push(boost::iostreams::bzip2_decompressor()); in.push(boost::iostreams::bzip2_decompressor());
break; break;
case NONE: case Cpsformat::NONE:
break; break;
default: default:
MSG("NOT correct compression flag.\n"); MSG("NOT correct compression flag.\n");
...@@ -662,7 +662,7 @@ namespace AMDiS { namespace io { ...@@ -662,7 +662,7 @@ namespace AMDiS { namespace io {
uint32_t nValueVectors = 0; uint32_t nValueVectors = 0;
uint32_t nFeSpaces = 0; uint32_t nFeSpaces = 0;
int cpsflag = 0, fileSize = 0; int cpsflag = 0, fileSize = 0;
Cpsformat cps = NONE; Cpsformat::Value cps = Cpsformat::NONE;
firstRead(file, "sarh", MAJOR, MINOR); firstRead(file, "sarh", MAJOR, MINOR);
...@@ -673,12 +673,12 @@ namespace AMDiS { namespace io { ...@@ -673,12 +673,12 @@ namespace AMDiS { namespace io {
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(reinterpret_cast<char*>(&cpsflag), 4); file.read(reinterpret_cast<char*>(&cpsflag), 4);
cps = static_cast<Cpsformat>(cpsflag); cps = static_cast<Cpsformat::Value>(cpsflag);
#ifdef HAVE_COMPRESSION #ifdef HAVE_COMPRESSION
TEST_EXIT(cps == ZLIB || TEST_EXIT(cps == Cpsformat::ZLIB ||
cps == BZIP2 || cps == Cpsformat::BZIP2 ||
cps == NONE) cps == Cpsformat::NONE)
("Cannot read Arh2 file. Currently only support zlib and bzip2 compression.\n"); ("Cannot read Arh2 file. Currently only support zlib and bzip2 compression.\n");
#else #else
TEST_EXIT(cps == NONE) TEST_EXIT(cps == NONE)
...@@ -746,13 +746,13 @@ namespace AMDiS { namespace io { ...@@ -746,13 +746,13 @@ namespace AMDiS { namespace io {
boost::iostreams::filtering_streambuf<boost::iostreams::input> in; boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
switch(cps) switch(cps)
{ {
case ZLIB: case Cpsformat::ZLIB:
in.push(boost::iostreams::zlib_decompressor()); in.push(boost::iostreams::zlib_decompressor());
break; break;
case BZIP2: case Cpsformat::BZIP2:
in.push(boost::iostreams::bzip2_decompressor()); in.push(boost::iostreams::bzip2_decompressor());
break; break;
case NONE: case Cpsformat::NONE:
break; break;
default: default:
MSG("NOT correct compression flag.\n"); MSG("NOT correct compression flag.\n");
...@@ -857,7 +857,7 @@ namespace AMDiS { namespace io { ...@@ -857,7 +857,7 @@ namespace AMDiS { namespace io {
file.read(const_cast<char*>(baseDir.data()), baseDirLen); file.read(const_cast<char*>(baseDir.data()), baseDirLen);
file.read(reinterpret_cast<char*>(&nFiles), 4); file.read(reinterpret_cast<char*>(&nFiles), 4);
file.read(reinterpret_cast<char*>(&macroFile_nl), 4); file.read(reinterpret_cast<char*>(&macroFile_nl), 4);
if (macroFile_nl > 0) { if (macroFile_nl > 0) { //TODO
macroFilename.resize(macroFile_nl, ' '); macroFilename.resize(macroFile_nl, ' ');
file.read(const_cast<char*>(macroFilename.data()), macroFile_nl); file.read(const_cast<char*>(macroFilename.data()), macroFile_nl);
} }
......
...@@ -32,9 +32,9 @@ namespace AMDiS { namespace io { ...@@ -32,9 +32,9 @@ namespace AMDiS { namespace io {
DOFVector<double>* vec1, DOFVector<double>* vec1,
DOFVector<double>* vec2, DOFVector<double>* vec2,
bool writeParallel, bool writeParallel,
Cpsformat cps, Cpsformat::Value cps,
string dataformat, string dataformat,
bool writeMacro) Macroformat::Value writeMacro)
{ {
vector<DOFVector<double>*> vecs(0); vector<DOFVector<double>*> vecs(0);
if (vec0 != NULL) if (vec0 != NULL)
...@@ -97,22 +97,24 @@ namespace AMDiS { namespace io { ...@@ -97,22 +97,24 @@ namespace AMDiS { namespace io {
} }
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
void writeParallelFile(string filename, Mesh* mesh, bool createSubDir, bool writeMacro) void writeParallelFile(string filename, Mesh* mesh, bool createSubDir, Macroformat::Value writeMacro)
{ {
ofstream file; ofstream file;
file.open(filename.c_str(), ios::out | ios::binary | ios::trunc); file.open(filename.c_str(), ios::out | ios::binary | ios::trunc);
string typeId = "parh", macroFilename = "", perFilename = ""; string typeId = "parh", macroFilename = "", perFilename = "";
string baseDir = createSubDir ? "./data/" : "./"; string baseDir = createSubDir ? "./data/" : "./";
string macroFile = "";
uint32_t macroFile_nl = 0;
string macroData = "", periodicData = ""; string macroData = "", periodicData = "";
uint32_t baseDirLen = baseDir.length(); uint32_t baseDirLen = baseDir.length();
Parameters::get(mesh->getName() + "->macro file name", macroFilename); Parameters::get(mesh->getName() + "->macro file name", macroFilename);
Parameters::get(mesh->getName() + "->periodic file", perFilename); Parameters::get(mesh->getName() + "->periodic file", perFilename);
bool hasPeriodic = perFilename.length();
int major = AMDiS::io::Arh3Reader::PARH_MAJOR; int major = AMDiS::io::Arh3Reader::PARH_MAJOR;
int minor = AMDiS::io::Arh3Reader::PARH_MINOR; int minor = AMDiS::io::Arh3Reader::PARH_MINOR;
uint32_t nFiles = MPI::COMM_WORLD.Get_size(); uint32_t nFiles = MPI::COMM_WORLD.Get_size();
uint32_t macroFile_nl = 0;
map<int, int> partitionMap = map<int, int> partitionMap =
Parallel::MeshDistributor::globalMeshDistributor->getPartitionMap(); Parallel::MeshDistributor::globalMeshDistributor->getPartitionMap();
uint32_t nMacros = partitionMap.size(); uint32_t nMacros = partitionMap.size();
...@@ -130,16 +132,26 @@ namespace AMDiS { namespace io { ...@@ -130,16 +132,26 @@ namespace AMDiS { namespace io {
file.write(baseDir.c_str(), baseDirLen); file.write(baseDir.c_str(), baseDirLen);
file.write(reinterpret_cast<char*>(&nFiles), 4); file.write(reinterpret_cast<char*>(&nFiles), 4);
if (writeMacro && macroFilename.length()) { if (writeMacro != Macroformat::NONE && macroFilename.length()) {
macroFile_nl = 13;
readFileToString(macroFilename, macroData);
if (perFilename.length()) { if (writeMacro == Macroformat::PT_MACROFILE) {
macroFile_nl = 27; macroFile = !hasPeriodic ? macroFilename :
readFileToString(perFilename, periodicData); macroFilename + ';' + perFilename;
macroFile_nl = macroFile.length();
} else if (writeMacro == Macroformat::THIS) {
macroFile_nl = 13;
readFileToString(macroFilename, macroData);
if (hasPeriodic) {
macroFile_nl = 27;
readFileToString(perFilename, periodicData);
}
macroFile.resize(macroFile_nl, ' ');
} }
} }
file.write(reinterpret_cast<char*>(&macroFile_nl), 4); file.write(reinterpret_cast<char*>(&macroFile_nl), 4);
file.write(macroFile.c_str(), macroFile_nl);
file.write(reinterpret_cast<char*>(&nMacros), 4); file.write(reinterpret_cast<char*>(&nMacros), 4);
map<int, int>::const_iterator it = partitionMap.begin(); map<int, int>::const_iterator it = partitionMap.begin();
...@@ -150,12 +162,12 @@ namespace AMDiS { namespace io { ...@@ -150,12 +162,12 @@ namespace AMDiS { namespace io {
} }
// write macro and periodic file // write macro and periodic file
if (writeMacro && macroFilename.length()) { if (writeMacro == Macroformat::THIS && macroFilename.length()) {
file.seekp(0, ios_base::end); file.seekp(0, ios_base::end);
long macroPos = file.tellp(), perPos = 0; long macroPos = file.tellp(), perPos = 0;
file.write(macroData.c_str(), macroData.length()); file.write(macroData.c_str(), macroData.length());
if (perFilename.length()) { if (hasPeriodic) {
perPos = file.tellp(); perPos = file.tellp();
file.write(periodicData.c_str(), periodicData.length()); file.write(periodicData.c_str(), periodicData.length());
} }
...@@ -167,9 +179,12 @@ namespace AMDiS { namespace io { ...@@ -167,9 +179,12 @@ namespace AMDiS { namespace io {
4 + //nFiles 4 + //nFiles
4; //macroFile_nl 4; //macroFile_nl
file.seekp(offset); file.seekp(offset);
file << "this:" << macroPos; file.write("this:", 5);
if (perFilename.length()) file.write(reinterpret_cast<char*>(&macroPos), 8);
file << ";this:" << perPos; if (hasPeriodic) {
file.write(";this:", 6);
file.write(reinterpret_cast<char*>(&perPos), 8);
}
} }
} }
#endif #endif
...@@ -178,9 +193,9 @@ namespace AMDiS { namespace io { ...@@ -178,9 +193,9 @@ namespace AMDiS { namespace io {
Mesh* mesh, Mesh* mesh,
vector<DOFVector<double>*> vecs, vector<DOFVector<double>*> vecs,
bool writeParallel, bool writeParallel,
Cpsformat cps, Cpsformat::Value cps,
string dataformat, string dataformat,
bool writeMacro) Macroformat::Value writeMacro)
{ {
FUNCNAME("Arh3Writer::detail::write()"); FUNCNAME("Arh3Writer::detail::write()");
...@@ -257,8 +272,9 @@ namespace AMDiS { namespace io { ...@@ -257,8 +272,9 @@ namespace AMDiS { namespace io {
Mesh *mesh, Mesh *mesh,
vector<DOFVector<double>*> vecs, vector<DOFVector<double>*> vecs,
map<const FiniteElemSpace*, vector<int> >& feSpaces, map<const FiniteElemSpace*, vector<int> >& feSpaces,
Cpsformat cps, Cpsformat::Value cps,
string dataformat) string dataformat,
Macroformat::Value writeMacro)
{ {
FUNCNAME("Arh3Writer::detail::writeHeader()"); FUNCNAME("Arh3Writer::detail::writeHeader()");
// int nbits = boost::lexical_cast<int>(dataformat.substr(2, 2)); // int nbits = boost::lexical_cast<int>(dataformat.substr(2, 2));
...@@ -286,7 +302,26 @@ namespace AMDiS { namespace io { ...@@ -286,7 +302,26 @@ namespace AMDiS { namespace io {
el = st.traverseNext(el); el = st.traverseNext(el);
} }
uint32_t dow = mesh->getGeo(WORLD); string macroFilename = "", perFilename = "";
string macroFile = "";
uint32_t macroFile_nl = 0;
Parameters::get(mesh->getName() + "->macro file name", macroFilename);
Parameters::get(mesh->getName() + "->periodic file", perFilename);
if (writeMacro != Macroformat::NONE && macroFilename.length()) {
if (writeMacro == Macroformat::PT_MACROFILE) {
macroFile = !perFilename.length() ? macroFilename :
macroFilename + ';' + perFilename;
macroFile_nl = macroFile.length();
} else if (writeMacro == Macroformat::THIS) {
macroFile_nl = perFilename.length() ? 27 : 13;
macroFile.resize(macroFile_nl, ' ');
}
}
uint32_t dow = mesh->getGeo(WORLD);
uint32_t dim = mesh->getDim(); uint32_t dim = mesh->getDim();
uint32_t headerLen = 34 + //fixed part of header uint32_t headerLen = 34 + //fixed part of header
nMacroElements * 12 + 12 + //macroElemnts table nMacroElements * 12 + 12 + //macroElemnts table
...@@ -294,7 +329,8 @@ namespace AMDiS { namespace io { ...@@ -294,7 +329,8 @@ namespace AMDiS { namespace io {
nFeSpaces * 20 + //feSpaces table nFeSpaces * 20 + //feSpaces table
valueNamesLen + //value vector table valueNamesLen + //value vector table
nValueVectors * 12 + //also value vector table nValueVectors * 12 + //also value vector table
4; //macroFile_nl 4 + //macroFile_nl
macroFile_nl; //macroFile
string typeId = "sarh"; string typeId = "sarh";
#ifndef HAVE_COMPRESSION #ifndef HAVE_COMPRESSION
cps = NONE; cps = NONE;
...@@ -370,17 +406,17 @@ namespace AMDiS { namespace io { ...@@ -370,17 +406,17 @@ namespace AMDiS { namespace io {
file.write(dataformat.c_str(), 4); file.write(dataformat.c_str(), 4);
} }
uint32_t macroFile_nl = 0;
file.write(reinterpret_cast<char*>(&macroFile_nl), 4); file.write(reinterpret_cast<char*>(&macroFile_nl), 4);
file.write(macroFile.c_str(), macroFile_nl);
return headerLen; return headerLen;
} }
void writeAux(string filename, Mesh *mesh, void writeAux(string filename, Mesh *mesh,
vector<DOFVector<double>*> vecs, vector<DOFVector<double>*> vecs,
bool writeParallel, bool writeParallel,
Cpsformat cps, Cpsformat::Value cps,
string dataformat, string dataformat,
bool writeMacro) Macroformat::Value writeMacro)
{ {
FUNCNAME("Arh3Writer::detail::writeAux()"); FUNCNAME("Arh3Writer::detail::writeAux()");
...@@ -404,7 +440,7 @@ namespace AMDiS { namespace io { ...@@ -404,7 +440,7 @@ namespace AMDiS { namespace io {
vector<std::set<DegreeOfFreedom> > visited(sortedFeSpaces.size()); vector<std::set<DegreeOfFreedom> > visited(sortedFeSpaces.size());
pair<std::set<DegreeOfFreedom>::iterator,bool> ret; pair<std::set<DegreeOfFreedom>::iterator,bool> ret;
//file header information //file header information
int headerLen = writeHeader(file, mesh, vecs, sortedFeSpaces, cps, dataformat); int headerLen = writeHeader(file, mesh, vecs, sortedFeSpaces, cps, dataformat, writeMacro);
//macro elements information //macro elements information
MeshStructure elementStructure; MeshStructure elementStructure;
...@@ -528,8 +564,10 @@ namespace AMDiS { namespace io { ...@@ -528,8 +564,10 @@ namespace AMDiS { namespace io {
TEST_EXIT(macroSize.size() == (unsigned)mesh->getNumberOfMacros())("Should not happen.\n"); TEST_EXIT(macroSize.size() == (unsigned)mesh->getNumberOfMacros())("Should not happen.\n");
//reset the macro positions in file //reset the macro positions in file
setMacrosPos(file, headerLen, macroSize); setMacrosPos(file, headerLen, macroSize);
if (writeMacro)
setMacroFile(file, headerLen, mesh); if (writeMacro == Macroformat::THIS)
setMacroFile(file, headerLen, mesh, writeMacro);
file.close(); file.close();
MSG("ARH file written to: %s\n", filename.c_str()); MSG("ARH file written to: %s\n", filename.c_str());
} }
...@@ -553,18 +591,22 @@ namespace AMDiS { namespace io { ...@@ -553,18 +591,22 @@ namespace AMDiS { namespace io {
file.write(reinterpret_cast<char*>(&startPos), 4); file.write(reinterpret_cast<char*>(&startPos), 4);
} }
void setMacroFile(std::ofstream& file, int headerLen, Mesh* mesh) void setMacroFile(std::ofstream& file, int headerLen, Mesh* mesh, Macroformat::Value writeMacro)
{ {
FUNCNAME("setMacroFile()");
TEST_EXIT(writeMacro == Macroformat::THIS)
("This function should only be called under Macroformat::THIS.\n");
string macroFilename = "", perFilename = ""; string macroFilename = "", perFilename = "";
string macroData = "", periodicData = ""; string macroData = "", periodicData = "";
Parameters::get(mesh->getName() + "->macro file name", macroFilename); Parameters::get(mesh->getName() + "->macro file name", macroFilename);
Parameters::get(mesh->getName() + "->periodic file", perFilename); Parameters::get(mesh->getName() + "->periodic file", perFilename);
bool hasPeriodic = perFilename.length();
if (!macroFilename.length()) { if (!macroFilename.length())
WARNING("macro file not found.\n");
return; return;
}
// write macro file to the end // write macro file to the end
readFileToString(macroFilename, macroData); readFileToString(macroFilename, macroData);
...@@ -573,24 +615,22 @@ namespace AMDiS { namespace io { ...@@ -573,24 +615,22 @@ namespace AMDiS { namespace io {
file.write(macroData.c_str(), macroData.length()); file.write(macroData.c_str(), macroData.length());
// write periodic file to the end // write periodic file to the end
if (perFilename.length()) {