bug fix for binary file read when dealing with multiple Fields reading from a single file

This commit is contained in:
HRN 2024-05-24 22:02:46 +03:30
parent 32a2c20613
commit 6a66f1edfd
4 changed files with 19 additions and 10 deletions

View File

@ -21,12 +21,16 @@ Licence:
template<class T, class MemorySpace> template<class T, class MemorySpace>
bool pFlow::Field<T, MemorySpace>::read bool pFlow::Field<T, MemorySpace>::read
( (
iIstream& is iIstream& is,
bool resume
) )
{ {
bool tokenFound = true; bool tokenFound = true;
if(resume)
tokenFound = is.findTokenResume(fieldKey_);
else
tokenFound = is.findToken(fieldKey_); tokenFound = is.findToken(fieldKey_);
if( !tokenFound ) if( !tokenFound )
@ -53,14 +57,21 @@ template<class T, class MemorySpace>
bool pFlow::Field<T, MemorySpace>::read bool pFlow::Field<T, MemorySpace>::read
( (
iIstream& is, iIstream& is,
const IOPattern& iop const IOPattern& iop,
bool resume
) )
{ {
bool tokenFound = true; bool tokenFound = true;
if(iop.thisProcReadData()) if(iop.thisProcReadData())
{
if(resume)
tokenFound = is.findTokenResume(fieldKey_);
else
tokenFound = is.findToken(fieldKey_); tokenFound = is.findToken(fieldKey_);
}
if( !tokenFound ) if( !tokenFound )
{ {

View File

@ -197,12 +197,12 @@ public:
//// - IO operations //// - IO operations
bool read(iIstream& is); bool read(iIstream& is, bool resume = false);
bool write(iOstream& os)const; bool write(iOstream& os)const;
bool read(iIstream& is, const IOPattern& iop); bool read(iIstream& is, const IOPattern& iop, bool resume = false);
bool write(iOstream& os, const IOPattern& iop )const; bool write(iOstream& os, const IOPattern& iop )const;

View File

@ -126,7 +126,6 @@ bool pFlow::IOobject::writeObject() const
{ {
if(auto ptrOS = outStream(); ptrOS ) if(auto ptrOS = outStream(); ptrOS )
{ {
pOutput<<"Should write field "<<name() <<" file "<<ptrOS->name()<<endl;
return writeObject(ptrOS()); return writeObject(ptrOS());
} }
else else
@ -141,7 +140,6 @@ bool pFlow::IOobject::writeObject() const
if(auto ptrOS = dummyOutStream(); ptrOS ) if(auto ptrOS = dummyOutStream(); ptrOS )
{ {
pOutput<<"Should write field "<< name()<< " file " <<ptrOS->name()<<endl;
return writeObject(ptrOS()); return writeObject(ptrOS());
} }
else else

View File

@ -257,7 +257,7 @@ pFlow::triSurface::triSurface
bool pFlow::triSurface::read(iIstream &is, const IOPattern &iop) bool pFlow::triSurface::read(iIstream &is, const IOPattern &iop)
{ {
points_.clear(); points_.clear();
if(!points_.read(is, iop)) if(!points_.read(is, iop, true))
{ {
ioErrorInFile(is.name(), is.lineNumber())<< ioErrorInFile(is.name(), is.lineNumber())<<
" when reading field "<< points_.name()<<endl; " when reading field "<< points_.name()<<endl;
@ -265,7 +265,7 @@ bool pFlow::triSurface::read(iIstream &is, const IOPattern &iop)
} }
vertices_.clear(); vertices_.clear();
if(!vertices_.read(is, iop)) if(!vertices_.read(is, iop, true))
{ {
ioErrorInFile(is.name(), is.lineNumber())<< ioErrorInFile(is.name(), is.lineNumber())<<
" when reading field "<< vertices_.name()<<endl; " when reading field "<< vertices_.name()<<endl;