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

View File

@ -197,12 +197,12 @@ public:
//// - IO operations
bool read(iIstream& is);
bool read(iIstream& is, bool resume = false);
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;

View File

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

View File

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