diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/oneWayVTK/oneWayVTK.C b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/oneWayVTK/oneWayVTK.C index 6eb33021..4a2774df 100644 --- a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/oneWayVTK/oneWayVTK.C +++ b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/oneWayVTK/oneWayVTK.C @@ -71,10 +71,6 @@ oneWayVTK::oneWayVTK maxNumberOfParticles_ = readScalar(propsDict_.lookup("maxNumberOfParticles")); setNumberOfParticles(maxNumberOfParticles_); - // make a const char* from word - string HH=string(filename_); - charFilename_=HH.c_str(); - Info << "relativePath_" << relativePath_ << endl; } @@ -94,107 +90,100 @@ void oneWayVTK::getData label step ) const { -if (type == "scalar-atom") -{ - // get path to particle VTK files - char index[100]; - sprintf(index, charFilename_, step); - //fileName H(particleCloud_.mesh().time().path()/".."/"DEM"/"post"/index); - fileName H(particleCloud_.mesh().time().path()/relativePath_/index); - Info << "opening file: " <> just_read; //read until we read "name" - *inputPtr >> just_read; // skip text for dataType - *inputPtr >> just_read; // skip text for "1" - *inputPtr >> just_read; // skip text for "LookUp" - *inputPtr >> just_read; // skip text for "default" - for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) + // get path to particle VTK files + char index[100]; + sprintf(index, filename_.c_str(), step); + fileName paricleFilePath(particleCloud_.mesh().time().path()/relativePath_/index); + Info << "opening file: " << paricleFilePath << endl; + + // open file + ifstream input(paricleFilePath.c_str()); + + if (!input.is_open()) cerr << "File not found!, " << paricleFilePath << endl; + + if (name == "radius") { - *inputPtr >> field[index][0]; + // read data + string just_read; + while (just_read.compare(name) != 0) input >> just_read; //read until we read "name" + input >> just_read; // skip text for dataType + input >> just_read; // skip text for "1" + input >> just_read; // skip text for "LookUp" + input >> just_read; // skip text for "default" + for (int index = 0; index> field[index][0]; + } } + else + { + // read data + string just_read; + while (just_read.compare(name) != 0) input >> just_read; //read until we read "name" + input >> just_read; // skip text for dataType + for (int index = 0; index> field[index][0]; + } + } + + // close inputStream + input.close(); + } + else if (type == "vector-atom") + { + // get path to particle VTK files + char index[100]; + sprintf(index, filename_.c_str(), step); + fileName paricleFilePath(particleCloud_.mesh().time().path()/relativePath_/index); + Info << "opening file: " << paricleFilePath << endl; + + // open file + ifstream input(paricleFilePath.c_str()); + + if (!input.is_open()) cerr << "File not found!, " << paricleFilePath << endl; + + // read position data from VTK file + //NP: special case as position data has no "name" in the vtk file + if (name == "x") + { + int numberOfParticles; // remove this? + string just_read; + while (just_read.compare("POINTS") != 0) input >> just_read; // read until we read "POINTS" + input >> numberOfParticles; // this is now the number of points in the file + input >> just_read; // skip text for dataType + + // give nr of particles to cloud + setNumberOfParticles(numberOfParticles); + + // re-allocate arrays of cloud + particleCloud_.reAllocArrays(); + + for (int index = 0; index> field[index][0] >> field[index][1] >> field[index][2]; + } + } + else + { + string just_read; + while (just_read.compare(name) != 0) input >> just_read; // read until we read "name" + input >> just_read; // skip text for dataType + for (int index = 0; index> field[index][0] >> field[index][1] >> field[index][2]; + } + } + + // close inputStream + input.close(); } else { - // read data - string just_read = " "; - while(just_read.compare(name) != 0) *inputPtr >> just_read; //read until we read "name" - *inputPtr >> just_read; // skip text for dataType - for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) - { - *inputPtr >> field[index][0]; - } + Info << "unknown type in getData!!!" << endl; } - - // clean up inputStream - delete inputPtr; -} else if (type == "vector-atom") -{ - // get path to particle VTK files - char index[100]; - sprintf(index, charFilename_, step); - //fileName H(particleCloud_.mesh().time().path()/".."/"DEM"/"post"/index); - fileName H(particleCloud_.mesh().time().path()/relativePath_/index); - Info << "opening file: " <> just_read; //read until we read "POINTS" - *inputPtr >> numberOfParticles; //this is now the number of points in the file - *inputPtr >> just_read; // skip text for dataType - - // give nr of particles to cloud - setNumberOfParticles(numberOfParticles); - - // re-allocate arrays of cloud - particleCloud_.reAllocArrays(); - - for(int index = 0;index < numberOfParticles; ++index) - { - *inputPtr >> field[index][0] >> field[index][1] >> field[index][2]; - } - } - else - { - string just_read = " "; - while(just_read.compare(name) != 0) *inputPtr >> just_read; //read until we read "name" - *inputPtr >> just_read; // skip text for dataType - for(int index = 0;index < particleCloud_.numberOfParticles(); ++index) - { - *inputPtr >> field[index][0] >> field[index][1] >> field[index][2]; - } - } - - // clean up inputStream - delete inputPtr; -} -else -{ - Info << "unknown type in getData!!!" << endl; -} - - } void oneWayVTK::giveData diff --git a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/oneWayVTK/oneWayVTK.H b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/oneWayVTK/oneWayVTK.H index bd6d7937..c8e0cfdf 100644 --- a/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/oneWayVTK/oneWayVTK.H +++ b/src/lagrangian/cfdemParticle/subModels/dataExchangeModel/oneWayVTK/oneWayVTK.H @@ -64,8 +64,6 @@ private: fileName relativePath_; - const char* charFilename_; - public: //- Runtime type information @@ -102,7 +100,7 @@ public: int ** const& field, label step ) const - {}; + {} void giveData ( @@ -112,7 +110,7 @@ public: const char* datatype = "" ) const; - word myType() const{return typeName; }; + word myType() const{ return typeName; } };