The saveAsciiData function I found in the post “postprocessing 3D fields in matlab” is really a convient way to save data in ascii code. However, I found the output data file is different from the way I used before.
Before I use the saveAsciiData, the following method is taken to save Pressure and velocity, and the data can be analysed in Tecplot:
(A)
//=============================================================================================
if (iter%converter.nStep(fSave)==0 && iter>0) {
ofstream myfile;
myfile.open (“outputPressure.dat” ) ;
cout << "Outputing data...";
myfile << "variables=\"X\",\"Y\",\"P\" " << endl;
myfile << "ZONE, I=" << GridNx << "," << " J=" << GridNy << endl;
for (int ly=0; ly<GridNy; ++ly) {
for (int lx=0; lx<GridNx; ++lx) {
double pressure;
pressure = lattice.getDataAnalysis().getPressure().get(lx,ly);
myfile << setw(5) << (double)(lx+1) <<
setw(5) << (double)(ly+1) <<
setw(15) << pressure << endl;
}
}
myfile.close();
cout << "Done." << endl;
}
//=============================================================================================
However, after I use the saveAsciiData to save ascii data, take pressure for example, the following “pressure.dat” seems not the same with the file “outputPressure.dat” obtained above.
(B )
if (iT%converter.nStep(imSave)==0 && iT>0) {
cout << “Saving Pressure.dat…”;
saveAsciiData(lattice.getDataAnalysis().getPressure(), “pressure.dat” ) ;
cout << “Done.” << endl;
}
Dear all, could you tell why the two files obtained by
(A)pressure = lattice.getDataAnalysis().getPressure().get(lx,ly);
and
(B )saveAsciiData(lattice.getDataAnalysis().getPressure(), “pressure.dat” ) ;
are different?
PS: And if I use saveAsciiData(lattice, “lattice.dat” ) ; , what kind of structure is the “lattice.dat”, how should I understand the content in the file?
PS: the content of function saveAsciiData:
//=============================================================================================
template
void saveAsciiData(Serializable const& object, std::string fName) {
std :: ofstream* ostr = 0;
if (singleton::mpi().isMainProcessor()) {
ostr = new std :: ofstream(fName.c_str());
OLB_PRECONDITION( ostr );
}
DataSerializer const& serializer = object.getSerializer(IndexOrdering::memorySaving);
while (!serializer.isEmpty()) {
int bufferSize;
const T dataBuffer = serializer.getNextDataBuffer(bufferSize);
if (singleton::mpi().isMainProcessor()) {
for (int iData=0; iData<bufferSize; ++iData) {
*ostr << dataBuffer[iData] << endl;
}
}
}
delete ostr;
}
//=============================================================================================