data read and write in binary

This commit is contained in:
Hamidreza Norouzi
2023-04-11 22:19:36 -07:00
parent b5572d3f7f
commit c46aaab2db
31 changed files with 873 additions and 442 deletions

View File

@ -83,10 +83,16 @@ bool pFlow::Field<VectorField, T, PropType>::readNonUniform
} }
this->clear(); this->clear();
VectorType::read(is); if(is.isBinary() && !std::is_same_v<T,word>)
{
this->resize(flen);
is.read(reinterpret_cast<char*>(this->data()), this->size()*sizeof(T));
is.readEndStatement("readField");
}
else
{
VectorType::read(is);
is.readEndStatement("readField"); is.readEndStatement("readField");
if( this->size() != flen ) if( this->size() != flen )
{ {
ioErrorInFile( is.name(), is.lineNumber() ) << ioErrorInFile( is.name(), is.lineNumber() ) <<
@ -94,6 +100,7 @@ bool pFlow::Field<VectorField, T, PropType>::readNonUniform
this->size() << " elements in file "<< is.name() <<endl; this->size() << " elements in file "<< is.name() <<endl;
return false; return false;
} }
}
return true; return true;
} }
@ -104,10 +111,18 @@ bool pFlow::Field<VectorField, T, PropType>::readField
( (
iIstream& is, iIstream& is,
const size_t len, const size_t len,
bool resume,
bool readLength bool readLength
) )
{ {
if( !is.findToken(fieldKey_) )
bool tokenFound;
if( resume )
tokenFound = is.findTokenResume(fieldKey_);
else
tokenFound = is.findToken(fieldKey_);
if( !tokenFound )
{ {
ioErrorInFile( is.name(), is.lineNumber() ) << ioErrorInFile( is.name(), is.lineNumber() ) <<
" error in searching for filedkey " << fieldKey_<<endl; " error in searching for filedkey " << fieldKey_<<endl;
@ -152,10 +167,11 @@ bool pFlow::Field<VectorField, T, PropType>::readField
template<template<class, class> class VectorField, class T, class PropType> template<template<class, class> class VectorField, class T, class PropType>
bool pFlow::Field<VectorField, T, PropType>::readField bool pFlow::Field<VectorField, T, PropType>::readField
( (
iIstream& is iIstream& is,
bool resume
) )
{ {
return readField(is, 0, true); return readField(is, 0, resume ,true);
} }
@ -164,7 +180,15 @@ bool pFlow::Field<VectorField, T, PropType>::writeField(iOstream& os)const
{ {
os.writeWordKeyword(fieldKey_) << nonUniform__<<endl; os.writeWordKeyword(fieldKey_) << nonUniform__<<endl;
os<< this->size()<<endl; os<< this->size()<<endl;
if( os.isBinary() && !std::is_same_v<T,word>)
{
os.write(reinterpret_cast<const char*>(this->data()), this->size()*sizeof(T));
}
else
{
VectorType::write(os); VectorType::write(os);
}
os.endEntry(); os.endEntry();
return true; return true;
} }

View File

@ -214,18 +214,18 @@ public:
} }
//// - IO operations //// - IO operations
bool readField(iIstream& is, const size_t len, bool readLength = true); bool readField(iIstream& is, const size_t len, bool resume, bool readLength = true);
bool readField(iIstream& is ); bool readField(iIstream& is, bool resume );
bool writeField(iOstream& os)const; bool writeField(iOstream& os)const;
bool read(iIstream& is) bool read(iIstream& is, bool resume = false)
{ {
return readField(is); return readField(is, resume);
} }
bool write(iOstream& os)const bool write(iOstream& os)const
@ -240,7 +240,7 @@ public:
template<template<class, class> class VectorField, class T, class PropType> template<template<class, class> class VectorField, class T, class PropType>
inline iIstream& operator >> (iIstream & is, Field<VectorField, T, PropType> & ifld ) inline iIstream& operator >> (iIstream & is, Field<VectorField, T, PropType> & ifld )
{ {
if( !ifld.readField(is) ) if( !ifld.readField(is, false) )
{ {
ioErrorInFile (is.name(), is.lineNumber()); ioErrorInFile (is.name(), is.lineNumber());
fatalExit; fatalExit;

View File

@ -24,14 +24,16 @@ Licence:
pFlow::uniquePtr<pFlow::iFstream> pFlow::IOfileHeader::inStream()const pFlow::uniquePtr<pFlow::iFstream> pFlow::IOfileHeader::inStream()const
{ {
if( fileExist() ) if( fileExist() )
return makeUnique<iFstream>(path()); return makeUnique<iFstream>(path(), inFileBinary());
else else
return nullptr; return nullptr;
} }
pFlow::uniquePtr<pFlow::oFstream> pFlow::IOfileHeader::outStream()const pFlow::uniquePtr<pFlow::oFstream> pFlow::IOfileHeader::outStream()const
{ {
auto osPtr = makeUnique<oFstream>(path());
auto osPtr = makeUnique<oFstream>(path(), outFileBinary());
if(osPtr && owner_) if(osPtr && owner_)
{ {
@ -68,6 +70,19 @@ pFlow::fileSystem pFlow::IOfileHeader::path() const
return f; return f;
} }
bool pFlow::IOfileHeader::outFileBinary()const
{
if(owner_)
return owner_->outFileBinary();
else
return false;
}
bool pFlow::IOfileHeader::inFileBinary()const
{
return toUpper(fileFormat_) == "BINARY";
}
bool pFlow::IOfileHeader::headerOk(bool silent) bool pFlow::IOfileHeader::headerOk(bool silent)
{ {
if(!fileExist()) if(!fileExist())
@ -130,6 +145,15 @@ bool pFlow::IOfileHeader::writeHeader(iOstream& os, const word& typeName) const
os.writeWordEntry("objectName", name() ); os.writeWordEntry("objectName", name() );
os.fatalCheck("writing objectName"); os.fatalCheck("writing objectName");
word fileFormat;
if(outFileBinary())
fileFormat = "Binary";
else
fileFormat = "ASCII";
os.writeWordEntry("fileFormat", fileFormat);
os.fatalCheck("writing fileFormat");
writeSeparator(os); writeSeparator(os);
return true; return true;
} }
@ -164,6 +188,18 @@ bool pFlow::IOfileHeader::readHeader(iIstream& is, bool silent)
return false; return false;
} }
if( !is.findTokenAndNextSilent("fileFormat", fileFormat_) )
{
if(!silent)
{
warningInFunction <<
"cannot find/error in reading fileFormat in file "<<
is.name()<<endl;
}
return false;
}
return true; return true;
} }

View File

@ -49,6 +49,9 @@ protected:
// object type read from file // object type read from file
word objectType_; word objectType_;
/// file format read from file
word fileFormat_ = "ASCII";
//// - methods //// - methods
// - input file stream // - input file stream
@ -83,6 +86,10 @@ public:
// - path to file name // - path to file name
fileSystem path() const; fileSystem path() const;
bool outFileBinary()const;
bool inFileBinary()const;
// - should be used for read operations // - should be used for read operations
// check if the file exist, // check if the file exist,
// read the header of the file to check if it is ok // read the header of the file to check if it is ok

View File

@ -64,10 +64,13 @@ bool pFlow::IOobject::read(bool rdHdr)
{ {
if( implyRead() ) if( implyRead() )
{
if( rdHdr )
{ {
if( auto ptrIS = inStream(); ptrIS ) if( auto ptrIS = inStream(); ptrIS )
{ {
return read( ptrIS(), rdHdr); if(!readHeader(ptrIS()))return false;
ptrIS.reset(nullptr);
} }
else else
{ {
@ -76,6 +79,20 @@ bool pFlow::IOobject::read(bool rdHdr)
return false; return false;
} }
} }
if( auto ptrIS = inStream(); ptrIS )
{
if(!read(ptrIS(), rdHdr))return false;
}
else
{
warningInFunction<<
"could not open file " << path() <<endl;
return false;
}
}
return true; return true;
} }

View File

@ -23,6 +23,25 @@ Licence:
#include "dictionary.hpp" #include "dictionary.hpp"
#include "vocabs.hpp" #include "vocabs.hpp"
bool pFlow::Time::readDictionary(const dictionary& dict)
{
auto wF = toUpper(dict.getValOrSet<word>("writeFormat", "ASCII"));
if(wF == "ASCII")
outFormatBinary_ = false;
else if(wF == "BINARY")
outFormatBinary_ = true;
else
{
fatalErrorInFunction<<
"Invalid writeFormat in file "<< dict.name()<<endl;
return false;
}
return true;
}
pFlow::Time::Time pFlow::Time::Time
( (
repository* owner, repository* owner,
@ -45,6 +64,10 @@ pFlow::Time::Time
) )
{ {
if(!readDictionary(setiingsDict))
{
fatalExit;
}
} }
pFlow::Time::Time( pFlow::Time::Time(
@ -75,7 +98,10 @@ pFlow::Time::Time(
this this
) )
{ {
if(!readDictionary(setiingsDict))
{
fatalExit;
}
} }
bool pFlow::Time::write bool pFlow::Time::write

View File

@ -44,12 +44,17 @@ class Time
protected: protected:
bool outFormatBinary_ = false;
// - geometry folder/repository // - geometry folder/repository
repository geometry_; repository geometry_;
// - integration folder/repository // - integration folder/repository
repository integration_; repository integration_;
bool readDictionary(const dictionary& dict);
public: public:
// Constructor with owner and settings dict // Constructor with owner and settings dict
@ -90,6 +95,13 @@ public:
{ {
return integration_; return integration_;
} }
/// Write to the file with binary format?
bool outFileBinary()const override
{
return outFormatBinary_;
}
// override the base write to manage write operation // override the base write to manage write operation
// based on the valid write time intervals // based on the valid write time intervals
virtual bool write(bool verbose = false) const; virtual bool write(bool verbose = false) const;

View File

@ -204,7 +204,15 @@ public:
// list of repository names in this repository // list of repository names in this repository
wordList repositoryNames()const; wordList repositoryNames()const;
//// - IO operations //// - IO operations
virtual bool outFileBinary()const
{
if(owner_)
return owner_->outFileBinary();
else
return false;
}
virtual bool write(bool verbose = false) const; virtual bool write(bool verbose = false) const;
}; };

View File

@ -24,7 +24,7 @@ Licence:
#include "fileStream.hpp" #include "fileStream.hpp"
#include "error.hpp" #include "error.hpp"
#include "streams.hpp"
void pFlow::fileStream::openInFile void pFlow::fileStream::openInFile
( (
@ -39,7 +39,12 @@ void pFlow::fileStream::openInFile
fatalExit; fatalExit;
} }
inStream_ = makeUnique<std::ifstream>( path.wordPath(), std::ios_base::in); if(binary_)
inStream_ = makeUnique<std::ifstream>(
path.wordPath(), std::ios_base::in | std::ios_base::binary);
else
inStream_ = makeUnique<std::ifstream>(
path.wordPath(), std::ios_base::in);
if( !inStream_->is_open()) if( !inStream_->is_open())
{ {
@ -66,7 +71,15 @@ void pFlow::fileStream::openOutFile
dir.createDirs(); dir.createDirs();
} }
outStream_ = makeUnique< std::ofstream>(path.wordPath(), std::ios_base::out); if(binary_)
{
outStream_ = makeUnique< std::ofstream>(
path.wordPath(), std::ios_base::out| std::ios::binary);
}
else
outStream_ = makeUnique< std::ofstream>(
path.wordPath(), std::ios_base::out);
if(!outStream_->is_open()) if(!outStream_->is_open())
{ {
@ -92,11 +105,13 @@ void pFlow::fileStream::close()
pFlow::fileStream::fileStream pFlow::fileStream::fileStream
( (
const fileSystem& path, const fileSystem& path,
bool outStream bool outStream,
bool binary
) )
: :
inStream_(nullptr), inStream_(nullptr),
outStream_(nullptr) outStream_(nullptr),
binary_(binary)
{ {
if(outStream) if(outStream)

View File

@ -43,6 +43,8 @@ protected:
// - out file stream // - out file stream
uniquePtr<std::ofstream> outStream_; uniquePtr<std::ofstream> outStream_;
bool binary_ = false;
// - open input file // - open input file
void openInFile(const fileSystem& path); void openInFile(const fileSystem& path);
@ -56,7 +58,7 @@ public:
// - Constructors // - Constructors
fileStream( const fileSystem& path, bool outStream = false); fileStream( const fileSystem& path, bool outStream = false, bool binary = false);
fileStream(const fileStream&)= delete; fileStream(const fileStream&)= delete;

View File

@ -24,9 +24,17 @@ Licence:
#include "iFstream.hpp" #include "iFstream.hpp"
pFlow::iFstream::iFstream (const fileSystem& path) pFlow::iFstream::iFstream
(
const fileSystem& path,
bool binary)
: :
fileStream(path), fileStream(path, false, binary),
Istream( fileStream::inStream(), path.wordPath()) Istream
(
fileStream::inStream(),
path.wordPath(),
(binary)? BINARY : ASCII
)
{ {
} }

View File

@ -40,7 +40,7 @@ class iFstream
public: public:
// - Constructor // - Constructor
iFstream (const fileSystem& path); iFstream (const fileSystem& path, bool binary = false);
// no copy constructor // no copy constructor
iFstream( const iFstream& src) = delete; iFstream( const iFstream& src) = delete;

View File

@ -24,11 +24,13 @@ Licence:
#include "oFstream.hpp" #include "oFstream.hpp"
pFlow::oFstream::oFstream (const fileSystem& path) pFlow::oFstream::oFstream (const fileSystem& path, bool binary)
: :
fileStream(path, true), fileStream(path, true, binary),
Ostream( fileStream::outStream(), path.wordPath()) Ostream
{ (
fileStream::outStream(),
path.wordPath(),
} (binary)? BINARY : ASCII
)
{}

View File

@ -41,7 +41,7 @@ class oFstream
public: public:
// Constructor // Constructor
oFstream (const fileSystem& path); oFstream (const fileSystem& path, bool binary = false);
// no copy constructor // no copy constructor
oFstream( const oFstream& src) = delete; oFstream( const oFstream& src) = delete;

View File

@ -307,10 +307,11 @@ pFlow::Istream& pFlow::Istream::readVariable(word& str)
pFlow::Istream::Istream pFlow::Istream::Istream
( (
std::istream& is, std::istream& is,
const word& streamName const word& streamName,
writeFormat wf
) )
: :
iIstream(), iIstream(wf),
name_(streamName), name_(streamName),
is_(is) is_(is)
{ {
@ -846,6 +847,26 @@ pFlow::iIstream& pFlow::Istream::read(double& val)
return *this; return *this;
} }
pFlow::iIstream& pFlow::Istream::read
(
char* buffer,
std::streamsize count
)
{
if ( !isBinary() )
{
fatalErrorInFunction<<"stream format is not binray. Stream name is "<<
name()<<'\n';
fatalExit;
}
readBegin("binaryBlock");
is_.read(buffer, count);
readEnd("binaryBlock");
setState(is_.rdstate());
return *this;
}
void pFlow::Istream::rewind() void pFlow::Istream::rewind()
{ {

View File

@ -65,8 +65,7 @@ public:
//- Construct wrapper around std::istream, set stream status //- Construct wrapper around std::istream, set stream status
Istream( std::istream& is, const word& streamName); Istream( std::istream& is, const word& streamName, writeFormat wf = ASCII);
//- Destructor //- Destructor
virtual ~Istream() = default; virtual ~Istream() = default;
@ -150,6 +149,8 @@ public:
//- Read a double //- Read a double
virtual iIstream& read(double& val) override; virtual iIstream& read(double& val) override;
iIstream& read(char* buffer, std::streamsize count) override;
//- Rewind the stream so that it may be read again //- Rewind the stream so that it may be read again
virtual void rewind(); virtual void rewind();

View File

@ -28,10 +28,11 @@ Licence:
pFlow::Ostream::Ostream pFlow::Ostream::Ostream
( (
std::ostream& os, std::ostream& os,
const word& streamName const word& streamName,
writeFormat wF
) )
: :
iOstream(), iOstream(wF),
name_(streamName), name_(streamName),
os_(os) os_(os)
{ {
@ -230,6 +231,29 @@ pFlow::iOstream& pFlow::Ostream::write(const double val)
return *this; return *this;
} }
pFlow::iOstream& pFlow::Ostream::write
(
const char* binaryData,
std::streamsize count
)
{
if ( !isBinary() )
{
fatalErrorInFunction<<"stream format is not binray. Stream name is "<<
name()<<'\n';
fatalExit;
}
os_ << token::BEGIN_LIST;
os_.write(binaryData, count);
os_ << token::END_LIST;
setState(os_.rdstate());
return *this;
}
void pFlow::Ostream::indent() void pFlow::Ostream::indent()

View File

@ -46,7 +46,7 @@ public:
// Constructors // Constructors
Ostream ( std::ostream& os, const word& streamName); Ostream ( std::ostream& os, const word& streamName, writeFormat wf = ASCII);
//- no copy construct //- no copy construct
Ostream(const Ostream&) = delete; Ostream(const Ostream&) = delete;
@ -75,76 +75,77 @@ public:
//- Write token to stream or otherwise handle it. //- Write token to stream or otherwise handle it.
// return false if the token type was not handled by this method // return false if the token type was not handled by this method
virtual bool write(const token& tok)override; bool write(const token& tok)override;
//- Write character //- Write character
virtual iOstream& write(const char c)override; iOstream& write(const char c)override;
//- Write character string //- Write character string
virtual iOstream& write(const char* str)override; iOstream& write(const char* str)override;
//- Write word //- Write word
virtual iOstream& write(const word& str)override; iOstream& write(const word& str)override;
//- Write std::string surrounded by quotes. //- Write std::string surrounded by quotes.
// Optional write without quotes. // Optional write without quotes.
virtual iOstream& writeQuoted ( const word& str, const bool quoted=true )override; iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
//- Write int64 //- Write int64
virtual iOstream& write(const int64 val) override; iOstream& write(const int64 val) override;
//- Write int32 //- Write int32
virtual iOstream& write(const int32 val) override; iOstream& write(const int32 val) override;
//- Write label //- Write label
virtual iOstream& write(const label val) override; iOstream& write(const label val) override;
//- Write uint32 //- Write uint32
virtual iOstream& write(const uint32 val) override; iOstream& write(const uint32 val) override;
//- Write uint16 //- Write uint16
virtual iOstream& write(const uint16 val) override; iOstream& write(const uint16 val) override;
//- Write float //- Write float
virtual iOstream& write(const float val) override; iOstream& write(const float val) override;
//- Write double //- Write double
virtual iOstream& write(const double val) override; iOstream& write(const double val) override;
/// Write a block of binray data
iOstream& write(const char* binaryData, std::streamsize count) override;
//- Add indentation characters //- Add indentation characters
virtual void indent(); void indent() override;
//- Set stream flags //- Set stream flags
virtual ios_base::fmtflags flags(const ios_base::fmtflags f); ios_base::fmtflags flags(const ios_base::fmtflags f) override;
//- Flush stream //- Flush stream
virtual void flush(); void flush() override;
//- Add newline and flush stream //- Add newline and flush stream
virtual void endl(); void endl() override;
//- Get the current padding character //- Get the current padding character
virtual char fill() const; char fill() const override;
//- Set padding character for formatted field up to field width //- Set padding character for formatted field up to field width
// \return previous padding character // \return previous padding character
virtual char fill(const char fillch); char fill(const char fillch) override;
//- Get width of output field //- Get width of output field
virtual int width() const; int width() const override;
//- Set width of output field //- Set width of output field
// \return previous width // \return previous width
virtual int width(const int w); int width(const int w) override;
//- Get precision of output field //- Get precision of output field
virtual int precision() const; int precision() const override;
//- Set precision of output field //- Set precision of output field
// return old precision // return old precision
virtual int precision(const int p); int precision(const int p) override;
//- Access to underlying std::ostream //- Access to underlying std::ostream
virtual std::ostream& stdStream() virtual std::ostream& stdStream()

View File

@ -302,7 +302,15 @@ pFlow::iIstream& pFlow::iTstream::read
return *this; return *this;
} }
pFlow::iIstream& pFlow::iTstream::read
(
char* buffer,
std::streamsize count
)
{
notImplementedFunction;
return *this;
}
void pFlow::iTstream::rewind() void pFlow::iTstream::rewind()
{ {

View File

@ -123,6 +123,8 @@ public:
//- Read a doubleScalar //- Read a doubleScalar
virtual iIstream& read(double&) override; virtual iIstream& read(double&) override;
iIstream& read(char* buffer, std::streamsize count) override;
// - Rewind the stream so that it may be read again // - Rewind the stream so that it may be read again
virtual void rewind(); virtual void rewind();

View File

@ -148,6 +148,15 @@ pFlow::iOstream& pFlow::oTstream::write(const double val)
return *this; return *this;
} }
pFlow::iOstream& pFlow::oTstream::write
(
const char* binaryData,
std::streamsize count
)
{
notImplementedFunction;
return *this;
}
void pFlow::oTstream::append(const token& tok) void pFlow::oTstream::append(const token& tok)

View File

@ -102,6 +102,11 @@ public:
//- Write double //- Write double
virtual iOstream& write(const double val) override; virtual iOstream& write(const double val) override;
/// Write a block of binray data
iOstream& write(
const char* binaryData,
std::streamsize count) override;
// - append token to the stream // - append token to the stream
virtual void append(const token& tok); virtual void append(const token& tok);

View File

@ -50,153 +50,187 @@ public:
enum streamAccess : char enum streamAccess : char
{ {
CLOSED = 0, //!< stream is not open CLOSED = 0, /// stream is not open
OPENED //!< stream is open OPENED /// stream is open
}; };
enum writeFormat: char
{
ASCII = 0,
BINARY
};
//- Default precision /// Default precision, only works for ASCII
static unsigned int precision_; static unsigned int precision_;
protected: protected:
//- Name for any generic stream - normally treat as readonly /// Name for any generic stream - normally treat as readonly
static word staticName_; static word staticName_;
/// Is stream open or closed
streamAccess openClosed_; streamAccess openClosed_;
/// write format
writeFormat writeFormat_ = ASCII;
/// state
ios_base::iostate ioState_; ios_base::iostate ioState_;
//- The file line /// The file line
int32 lineNumber_; int32 lineNumber_;
// Protected Member Functions //- Protected Member Functions
//- Set stream opened /// Set stream opened
void setOpened() void setOpened()
{ {
openClosed_ = OPENED; openClosed_ = OPENED;
} }
//- Set stream closed /// Set stream closed
void setClosed() void setClosed()
{ {
openClosed_ = CLOSED; openClosed_ = CLOSED;
} }
//- Set stream state /// Set stream state
void setState(ios_base::iostate state) void setState(ios_base::iostate state)
{ {
ioState_ = state; ioState_ = state;
} }
//- Set stream to be good void setWriteFormat(writeFormat wF)
{
writeFormat_ = wF;
}
/// Set stream to be good
void setGood() void setGood()
{ {
ioState_ = ios_base::iostate(0); ioState_ = ios_base::iostate(0);
} }
public: public:
// Constructors //- Constructors
/// Default
explicit IOstream(): explicit IOstream():
openClosed_(CLOSED), openClosed_(CLOSED),
writeFormat_(ASCII),
ioState_(ios_base::iostate(0)), ioState_(ios_base::iostate(0)),
lineNumber_(0) lineNumber_(0)
{ {
setBad(); setBad();
} }
/// Construct and set write format
explicit IOstream(writeFormat wF):
openClosed_(CLOSED),
writeFormat_(wF),
ioState_(ios_base::iostate(0)),
lineNumber_(0)
{
setBad();
}
/// Copy
IOstream(const IOstream&) = default; IOstream(const IOstream&) = default;
//- Destructor /// Destructor
virtual ~IOstream() = default; virtual ~IOstream() = default;
//// Member Functions //- Member Functions
//- Return the name of the stream /// Return the name of the stream
virtual const word& name() const; virtual const word& name() const;
//- Return non-const access to the name of the stream /// Return non-const access to the name of the stream
virtual word& name(); virtual word& name();
//- Check IOstream status for given operation. /// Check IOstream status for given operation.
// Print IOstream state or generate a FatalIOError /// Print IOstream state or generate a FatalIOError
// when an error has occurred. /// when an error has occurred.
// The base implementation is a fatalCheck /// The base implementation is a fatalCheck
virtual bool check(const char* operation) const; virtual bool check(const char* operation) const;
//- Check IOstream status for given operation. /// Check IOstream status for given operation.
// Generate a FatalIOError when an error has occurred. /// Generate a FatalIOError when an error has occurred.
bool fatalCheck(const char* operation) const; bool fatalCheck(const char* operation) const;
//- Return true if stream has been opened /// Return true if stream has been opened
bool opened() const bool opened() const
{ {
return openClosed_ == OPENED; return openClosed_ == OPENED;
} }
//- Return true if stream is closed /// Return true if stream is closed
bool closed() const bool closed() const
{ {
return openClosed_ == CLOSED; return openClosed_ == CLOSED;
} }
//- Return true if next operation might succeed /// Return true if stream format is binray
bool isBinary()const
{
return writeFormat_ == BINARY;
}
/// Return true if next operation might succeed
bool good() const bool good() const
{ {
return ioState_ == 0; return ioState_ == 0;
} }
//- Return true if end of input seen /// Return true if end of input seen
bool eof() const bool eof() const
{ {
return ioState_ & ios_base::eofbit; return ioState_ & ios_base::eofbit;
} }
//- Return true if next operation will fail /// Return true if next operation will fail
bool fail() const bool fail() const
{ {
return ioState_ & (ios_base::badbit | ios_base::failbit); return ioState_ & (ios_base::badbit | ios_base::failbit);
} }
//- Return true if stream is corrupted /// Return true if stream is corrupted
bool bad() const bool bad() const
{ {
return ioState_ & ios_base::badbit; return ioState_ & ios_base::badbit;
} }
//- Return true if the stream has not failed /// Return true if the stream has not failed
explicit operator bool() const explicit operator bool() const
{ {
return !fail(); return !fail();
} }
//- Return true if the stream has failed /// Return true if the stream has failed
bool operator!() const bool operator!() const
{ {
return fail(); return fail();
} }
//- Const access to the current stream line number /// Const access to the current stream line number
int32 lineNumber() const int32 lineNumber() const
{ {
return lineNumber_; return lineNumber_;
} }
//- Non-const access to the current stream line number /// Non-const access to the current stream line number
int32& lineNumber() int32& lineNumber()
{ {
return lineNumber_; return lineNumber_;
} }
//- Set the stream line number /// Set the stream line number
// \return the previous value /// return the previous value
int32 lineNumber(const int32 num) int32 lineNumber(const int32 num)
{ {
const int32 old(lineNumber_); const int32 old(lineNumber_);
@ -204,17 +238,17 @@ public:
return old; return old;
} }
//- Return flags of stream /// Return flags of stream
virtual ios_base::fmtflags flags() const = 0; virtual ios_base::fmtflags flags() const = 0;
//- Return the default precision /// Return the default precision
static unsigned int defaultPrecision() static unsigned int defaultPrecision()
{ {
return precision_; return precision_;
} }
//- Reset the default precision /// Reset the default precision
// \return the previous value /// return the previous value
static unsigned int defaultPrecision(unsigned int prec) static unsigned int defaultPrecision(unsigned int prec)
{ {
unsigned int old(precision_); unsigned int old(precision_);
@ -222,34 +256,34 @@ public:
return old; return old;
} }
//- Set stream to have reached eof /// Set stream to have reached eof
void setEof() void setEof()
{ {
ioState_ |= ios_base::eofbit; ioState_ |= ios_base::eofbit;
} }
//- Set stream to have failed /// Set stream to have failed
void setFail() void setFail()
{ {
ioState_ |= ios_base::failbit; ioState_ |= ios_base::failbit;
} }
//- Set stream to be bad /// Set stream to be bad
void setBad() void setBad()
{ {
ioState_ |= ios_base::badbit; ioState_ |= ios_base::badbit;
} }
//- Set flags of stream /// Set flags of stream
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) = 0; virtual ios_base::fmtflags flags(const ios_base::fmtflags f) = 0;
//- Set flags of stream /// Set flags of stream
ios_base::fmtflags setf(const ios_base::fmtflags f) ios_base::fmtflags setf(const ios_base::fmtflags f)
{ {
return flags(flags() | f); return flags(flags() | f);
} }
//- Set flags of given field of stream /// Set flags of given field of stream
ios_base::fmtflags setf ios_base::fmtflags setf
( (
const ios_base::fmtflags f, const ios_base::fmtflags f,
@ -259,7 +293,7 @@ public:
return flags((flags() & ~mask) | (f & mask)); return flags((flags() & ~mask) | (f & mask));
} }
//- Unset flags of stream /// Unset flags of stream
void unsetf(const ios_base::fmtflags f) void unsetf(const ios_base::fmtflags f)
{ {
flags(flags() & ~f); flags(flags() & ~f);
@ -269,7 +303,7 @@ public:
}; // end of IOstream }; // end of IOstream
//- An IOstream manipulator /// An IOstream manipulator
typedef IOstream& (*IOstreamManip)(IOstream&); typedef IOstream& (*IOstreamManip)(IOstream&);
inline IOstream& dec(IOstream& io) inline IOstream& dec(IOstream& io)

View File

@ -60,6 +60,11 @@ bool pFlow::iIstream::peekBack(token& tok)
bool pFlow::iIstream::findToken( const word & w ) bool pFlow::iIstream::findToken( const word & w )
{ {
rewind(); rewind();
return findTokenResume(w);
}
bool pFlow::iIstream::findTokenResume(const word& w)
{
token next; token next;
bool isFirstToken = true; bool isFirstToken = true;
@ -74,8 +79,6 @@ bool pFlow::iIstream::findToken( const word & w )
return false; return false;
} }
if( next.isWord() && isFirstToken) if( next.isWord() && isFirstToken)
{ {
if(next.wordToken() == w ) return true; if(next.wordToken() == w ) return true;
@ -93,6 +96,11 @@ bool pFlow::iIstream::findToken( const word & w )
bool pFlow::iIstream::findTokenSilent( const word & w, int32 limitLine ) bool pFlow::iIstream::findTokenSilent( const word & w, int32 limitLine )
{ {
rewind(); rewind();
return findTokenResumeSilent(w,limitLine);
}
bool pFlow::iIstream::findTokenResumeSilent( const word & w, int32 limitLine )
{
token next; token next;
bool isFirstToken = true; bool isFirstToken = true;

View File

@ -53,6 +53,11 @@ public:
putBack_(false) putBack_(false)
{} {}
iIstream(writeFormat wf):
IOstream(wf),
putBack_(false)
{}
// - Copy construct // - Copy construct
iIstream(const iIstream&) = default; iIstream(const iIstream&) = default;
@ -122,6 +127,8 @@ public:
//- Read a doubleScalar //- Read a doubleScalar
virtual iIstream& read(double&) = 0; virtual iIstream& read(double&) = 0;
virtual iIstream& read(char* buffer, std::streamsize count) =0;
//- Rewind the stream so that it may be read again //- Rewind the stream so that it may be read again
virtual void rewind() = 0; virtual void rewind() = 0;
@ -132,10 +139,18 @@ public:
// - search for all tokesn and find the first word token tbat matchs w // - search for all tokesn and find the first word token tbat matchs w
virtual bool findToken( const word & w ); virtual bool findToken( const word & w );
/// search for all tokesn after the current file position
/// and find the first word token tbat matchs w
virtual bool findTokenResume(const word& w);
// - search for all tokesn and find the first word token that matchs // - search for all tokesn and find the first word token that matchs
virtual bool findTokenSilent( const word & w, int32 limitLine = 100 ); virtual bool findTokenSilent( const word & w, int32 limitLine = 100 );
/// search for all tokesn after the current file position
/// and find the first word token tbat matchs w
virtual bool findTokenResumeSilent( const word & w, int32 limitLine = 100 );
// - search for all tokens and find the first word token and also next word token // - search for all tokens and find the first word token and also next word token
// chekck if it is eneded with end statement ; // chekck if it is eneded with end statement ;
virtual bool findTokenAndNext( const word& w, word& nextW, bool checkEndStatement = true); virtual bool findTokenAndNext( const word& w, word& nextW, bool checkEndStatement = true);

View File

@ -58,161 +58,168 @@ protected:
// Protected Data // Protected Data
//- Indentation of the entry from the start of the keyword /// Indentation of the entry from the start of the keyword
static constexpr const unsigned short entryIndentation_ = 16; static constexpr const unsigned short entryIndentation_ = 16;
//- Number of spaces per indent level /// Number of spaces per indent level
unsigned short indentSize_ = 4; unsigned short indentSize_ = 4;
//- Current indent level /// Current indent level
unsigned short indentLevel_ = 0; unsigned short indentLevel_ = 0;
public: public:
// Constructor // Constructors
/// Default
explicit iOstream() explicit iOstream()
{} {}
//- Copy construct /// Construct from writeFormat
explicit iOstream(writeFormat wF):
IOstream(wF)
{}
/// Copy construct
iOstream(const iOstream&) = default; iOstream(const iOstream&) = default;
//- Destructor /// Destructor
virtual ~iOstream() = default; virtual ~iOstream() = default;
// Write Functions /// Write Functions
//- Write token to stream or otherwise handle it. /// Write token to stream or otherwise handle it.
// \return false if the token type was not handled by this method /// return false if the token type was not handled by this method
virtual bool write(const token& tok) = 0; virtual bool write(const token& tok) = 0;
//- Write character /// Write character
virtual iOstream& write(const char c) = 0; virtual iOstream& write(const char c) = 0;
//- Write character string /// Write character string
virtual iOstream& write(const char* str) = 0; virtual iOstream& write(const char* str) = 0;
//- Write word /// Write word
virtual iOstream& write(const word& str) = 0; virtual iOstream& write(const word& str) = 0;
/// Write std::string surrounded by quotes.
//- Write std::string surrounded by quotes. /// Optional write without quotes.
// Optional write without quotes.
virtual iOstream& writeQuoted virtual iOstream& writeQuoted
( (
const word& str, const word& str,
const bool quoted=true const bool quoted=true
) = 0; ) = 0;
/// Write int64
//- Write int64
virtual iOstream& write(const int64 val) = 0; virtual iOstream& write(const int64 val) = 0;
//- Write int32 /// Write int32
virtual iOstream& write(const int32 val) = 0; virtual iOstream& write(const int32 val) = 0;
//- Write label /// Write label
virtual iOstream& write(const label val) = 0; virtual iOstream& write(const label val) = 0;
//- Write uint32 /// Write uint32
virtual iOstream& write(const uint32 val) = 0; virtual iOstream& write(const uint32 val) = 0;
//- Write uint16 /// Write uint16
virtual iOstream& write(const uint16 val) = 0; virtual iOstream& write(const uint16 val) = 0;
//- Write float /// Write float
virtual iOstream& write(const float val) = 0; virtual iOstream& write(const float val) = 0;
//- Write double /// Write double
virtual iOstream& write(const double val) = 0; virtual iOstream& write(const double val) = 0;
/// Write a block of binray data
virtual iOstream& write(const char* binaryData, std::streamsize count) = 0;
//- Add indentation characters // - Indent
/// Add indentation characters
virtual void indent() = 0; virtual void indent() = 0;
//- Return indent level /// Return indent level
unsigned short indentSize() const unsigned short indentSize() const
{ {
return indentSize_; return indentSize_;
} }
//- Access to indent size /// Access to indent size
unsigned short& indentSize() unsigned short& indentSize()
{ {
return indentSize_; return indentSize_;
} }
//- Return indent level /// Return indent level
unsigned short indentLevel() const unsigned short indentLevel() const
{ {
return indentLevel_; return indentLevel_;
} }
//- Access to indent level /// Access to indent level
unsigned short& indentLevel() unsigned short& indentLevel()
{ {
return indentLevel_; return indentLevel_;
} }
//- Increment the indent level /// Increment the indent level
void incrIndent() void incrIndent()
{ {
++indentLevel_; ++indentLevel_;
} }
//- Decrement the indent level /// Decrement the indent level
void decrIndent(); void decrIndent();
//- Punctuations
/// Write begin block group with a name
/// Increments indentation, adds newline.
//- Write begin block group with a name
// Increments indentation, adds newline.
virtual iOstream& beginBlock(const word& kw); virtual iOstream& beginBlock(const word& kw);
//- Write begin block group without a name /// Write begin block group without a name
// Increments indentation, adds newline. /// Increments indentation, adds newline.
virtual iOstream& beginBlock(); virtual iOstream& beginBlock();
//- Write end block group /// Write end block group
// Decrements indentation, adds newline. /// Decrements indentation, adds newline.
virtual iOstream& endBlock(); virtual iOstream& endBlock();
//- Write begin list "(" /// Write begin list "("
virtual iOstream& beginList(); virtual iOstream& beginList();
//- Write begin list with keyword "kw (" /// Write begin list with keyword "kw ("
virtual iOstream& beginList(const word& kw); virtual iOstream& beginList(const word& kw);
//- Write end list ")" /// Write end list ")"
virtual iOstream& endList(); virtual iOstream& endList();
//- Write begin list "[" /// Write begin list "["
virtual iOstream& beginSquare(); virtual iOstream& beginSquare();
//- Write begin list with keyword "kw [" /// Write begin list with keyword "kw ["
virtual iOstream& beginSquare(const word& kw); virtual iOstream& beginSquare(const word& kw);
//- Write end list "]" /// Write end list "]"
virtual iOstream& endSquare(); virtual iOstream& endSquare();
//- Write end entry (';') followed by newline. /// Write end entry (';') followed by newline.
virtual iOstream& endEntry(); virtual iOstream& endEntry();
//- Write a newLine to stream /// Write a newLine to stream
virtual iOstream& newLine(); virtual iOstream& newLine();
//- Write space to stream /// Write space to stream
virtual iOstream& space(int32 n=1); virtual iOstream& space(int32 n=1);
/// Write the keyword followed by an appropriate indentation
//- Write the keyword followed by an appropriate indentation
virtual iOstream& writeWordKeyword(const word& kw); virtual iOstream& writeWordKeyword(const word& kw);
//- Write a keyword/value entry. /// Write a keyword/value entry.
template<class T> template<class T>
iOstream& writeWordEntry(const word& key, const T& value) iOstream& writeWordEntry(const word& key, const T& value)
{ {
@ -220,38 +227,39 @@ public:
return endEntry(); return endEntry();
} }
//// Stream state functions
//- Flush stream //- Stream state functions
/// Flush stream
virtual void flush() = 0; virtual void flush() = 0;
//- Add newline and flush stream /// Add newline and flush stream
virtual void endl() = 0; virtual void endl() = 0;
//- Get padding character /// Get padding character
virtual char fill() const = 0; virtual char fill() const = 0;
//- Set padding character for formatted field up to field width /// Set padding character for formatted field up to field width
virtual char fill(const char fillch) = 0; virtual char fill(const char fillch) = 0;
//- Get width of output field /// Get width of output field
virtual int width() const = 0; virtual int width() const = 0;
//- Set width of output field (and return old width) /// Set width of output field (and return old width)
virtual int width(const int w) = 0; virtual int width(const int w) = 0;
//- Get precision of output field /// Get precision of output field
virtual int precision() const = 0; virtual int precision() const = 0;
//- Set precision of output field (and return old precision) /// Set precision of output field (and return old precision)
virtual int precision(const int p) = 0; virtual int precision(const int p) = 0;
// Member Operators //- Member Operators
//- Return a non-const reference to const iOstream /// Return a non-const reference to const iOstream
// Needed for write functions where the stream argument is temporary: /// Needed for write functions where the stream argument is temporary:
// e.g. thing thisThing(OFstream("thingFileName")()); /// e.g. thing thisThing(OFstream("thingFileName")());
iOstream& operator()() const iOstream& operator()() const
{ {
return const_cast<iOstream&>(*this); return const_cast<iOstream&>(*this);
@ -260,17 +268,17 @@ public:
//- An iOstream manipulator /// An iOstream manipulator
typedef iOstream& (*iOstreamManip)(iOstream&); typedef iOstream& (*iOstreamManip)(iOstream&);
//- operator<< handling for manipulators without arguments /// operator<< handling for manipulators without arguments
inline iOstream& operator<<(iOstream& os, iOstreamManip f) inline iOstream& operator<<(iOstream& os, iOstreamManip f)
{ {
return f(os); return f(os);
} }
//- operator<< handling for manipulators without arguments /// operator<< handling for manipulators without arguments
inline iOstream& operator<<(iOstream& os, IOstreamManip f) inline iOstream& operator<<(iOstream& os, IOstreamManip f)
{ {
f(os); f(os);
@ -278,21 +286,21 @@ inline iOstream& operator<<(iOstream& os, IOstreamManip f)
} }
//- Indent stream /// Indent stream
inline iOstream& indent(iOstream& os) inline iOstream& indent(iOstream& os)
{ {
os.indent(); os.indent();
return os; return os;
} }
//- Increment the indent level /// Increment the indent level
inline iOstream& incrIndent(iOstream& os) inline iOstream& incrIndent(iOstream& os)
{ {
os.incrIndent(); os.incrIndent();
return os; return os;
} }
//- Decrement the indent level /// Decrement the indent level
inline iOstream& decrIndent(iOstream& os) inline iOstream& decrIndent(iOstream& os)
{ {
os.decrIndent(); os.decrIndent();
@ -300,7 +308,7 @@ inline iOstream& decrIndent(iOstream& os)
} }
//- Flush stream /// Flush stream
inline iOstream& flush(iOstream& os) inline iOstream& flush(iOstream& os)
{ {
os.flush(); os.flush();
@ -308,7 +316,7 @@ inline iOstream& flush(iOstream& os)
} }
//- Add newline and flush stream /// Add newline and flush stream
inline iOstream& endl(iOstream& os) inline iOstream& endl(iOstream& os)
{ {
os.endl(); os.endl();
@ -316,7 +324,7 @@ inline iOstream& endl(iOstream& os)
} }
//- Write begin block group without a name /// Write begin block group without a name
// Increments indentation, adds newline. // Increments indentation, adds newline.
inline iOstream& beginBlock(iOstream& os) inline iOstream& beginBlock(iOstream& os)
{ {
@ -325,7 +333,7 @@ inline iOstream& beginBlock(iOstream& os)
} }
//- Write end block group /// Write end block group
// Decrements indentation, adds newline. // Decrements indentation, adds newline.
inline iOstream& endBlock(iOstream& os) inline iOstream& endBlock(iOstream& os)
{ {
@ -334,7 +342,7 @@ inline iOstream& endBlock(iOstream& os)
} }
//- Write end entry (';') followed by newline. /// Write end entry (';') followed by newline.
inline iOstream& endEntry(iOstream& os) inline iOstream& endEntry(iOstream& os)
{ {
os.endEntry(); os.endEntry();

View File

@ -400,7 +400,7 @@ bool pFlow::pointStructure::readPointStructure
return false; return false;
} }
if(! pointFlag_.read(is)) if(! pointFlag_.read(is, true))
{ {
ioErrorInFile(is.name(), is.lineNumber())<< ioErrorInFile(is.name(), is.lineNumber())<<
"Error in reading pointFlag in pointStructure \n"; "Error in reading pointFlag in pointStructure \n";

View File

@ -214,14 +214,12 @@ bool pFlow::multiTriSurface::readMultiTriSurface
{ {
if( !readTriSurface(is) )return false; if( !readTriSurface(is) )return false;
is >> lastPointIndex_; // from current position
if(!is.check(FUNCTION_NAME) ) return false; if(!lastPointIndex_.read(is, true)) return false;
is >> lastVertexIndex_; if(!lastVertexIndex_.read(is, true) ) return false;
if(!is.check(FUNCTION_NAME) ) return false;
is >> surfaceNames_; if( !surfaceNames_.read(is, true)) return false;
if( !is.check(FUNCTION_NAME)) return false;
calculateVars(); calculateVars();

View File

@ -193,13 +193,15 @@ bool pFlow::triSurface::readTriSurface
) )
{ {
std::cout<<"triSurface file is binary "<< is.isBinary()<<std::endl;
is.fatalCheck(FUNCTION_NAME); is.fatalCheck(FUNCTION_NAME);
is >> points_; // from start of file
is.fatalCheck(FUNCTION_NAME); if(!points_.read(is)) return false;
is >> vertices_; // from the current position
is.fatalCheck(FUNCTION_NAME); if(!vertices_.read(is, true)) return false;
if( !check() ) if( !check() )
{ {

View File

@ -31,12 +31,12 @@ Licence:
namespace pFlow::PFtoVTK namespace pFlow::PFtoVTK
{ {
template<typename IncludeMaskType> template<typename IntType, typename IncludeMaskType>
bool addInt64PointField( bool addIntPointField(
iOstream& os, iOstream& os,
word fieldName, word fieldName,
int32 numActivePoints, int32 numActivePoints,
int64* field, IntType* field,
IncludeMaskType includeMask ); IncludeMaskType includeMask );
template<typename IncludeMaskType> template<typename IncludeMaskType>
@ -76,6 +76,41 @@ bool checkFieldType(word objectType)
} }
bool convertInt32PointField
(
iOstream& os,
const IOfileHeader& header,
const pointStructure& pStruct
)
{
word objectType = header.objectType();
if(!checkFieldType<int32>(objectType))
{
return false;
}
auto objField = IOobject::make<int32PointField_H>
(
header,
pStruct,
static_cast<int64>(0)
);
auto& Field = objField().getObject<int32PointField_H>();
auto* data = Field.hostVectorAll().data();
REPORT(2)<<"writing "<< greenColor <<header.objectName()<<defaultColor<<" field to vtk.\n";
return addIntPointField(
os,
header.objectName(),
pStruct.numActive(),
data,
pStruct.activePointsMaskH() );
}
bool convertIntTypesPointField( bool convertIntTypesPointField(
iOstream& os, iOstream& os,
const IOfileHeader& header, const IOfileHeader& header,
@ -85,7 +120,6 @@ bool convertIntTypesPointField(
if( !(checkFieldType<int8>(objectType) || if( !(checkFieldType<int8>(objectType) ||
checkFieldType<int16>(objectType) || checkFieldType<int16>(objectType) ||
checkFieldType<int32>(objectType) ||
checkFieldType<int64>(objectType) || checkFieldType<int64>(objectType) ||
checkFieldType<uint32>(objectType) || checkFieldType<uint32>(objectType) ||
checkFieldType<label>(objectType)) checkFieldType<label>(objectType))
@ -107,7 +141,7 @@ bool convertIntTypesPointField(
REPORT(2)<<"writing "<< greenColor <<header.objectName()<<defaultColor<<" field to vtk.\n"; REPORT(2)<<"writing "<< greenColor <<header.objectName()<<defaultColor<<" field to vtk.\n";
return addInt64PointField( return addIntPointField(
os, os,
header.objectName(), header.objectName(),
pStruct.numActive(), pStruct.numActive(),
@ -219,12 +253,12 @@ bool addUndstrcuturedGridField(
} }
template<typename IncludeMaskType> template<typename IntType, typename IncludeMaskType>
bool addInt64PointField( bool addIntPointField(
iOstream& os, iOstream& os,
word fieldName, word fieldName,
int32 numActivePoints, int32 numActivePoints,
int64* field, IntType* field,
IncludeMaskType includeMask ) IncludeMaskType includeMask )
{ {
if(numActivePoints==0) return true; if(numActivePoints==0) return true;
@ -346,7 +380,7 @@ bool convertTimeFolderPointFields(
if( fieldHeader.headerOk(true) ) if( fieldHeader.headerOk(true) )
{ {
convertIntTypesPointField(vtk(), fieldHeader, pStruct); convertInt32PointField(vtk(), fieldHeader, pStruct);
convertRealTypePointField(vtk(), fieldHeader, pStruct); convertRealTypePointField(vtk(), fieldHeader, pStruct);
convertRealx3TypePointField(vtk(), fieldHeader, pStruct); convertRealx3TypePointField(vtk(), fieldHeader, pStruct);
} }

View File

@ -96,6 +96,119 @@ int main( int argc, char* argv[] )
auto& cpDict = objCPDict().getObject<dictionary>(); auto& cpDict = objCPDict().getObject<dictionary>();
pointStructure* pStructPtr = nullptr;
if(!setOnly)
{
// position particles based on the dict content
REPORT(0)<< "Positioning points . . . \n"<<endREPORT;
auto pointPosition = positionParticles::create(cpDict.subDict("positionParticles"));
fileSystem pStructPath = Control.time().path()+pointStructureFile__;
auto finalPos = pointPosition().getFinalPosition();
auto& pStruct = Control.time().emplaceObject<pointStructure>
(
objectFile
(
pointStructureFile__,
Control.time().path(),
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
),
finalPos
);
pStructPtr = &pStruct;
REPORT(1)<< "Created pStruct with "<< pStruct.size() << " points and capacity "<<
pStruct.capacity()<<" . . ."<< endREPORT;
REPORT(1)<< "Writing pStruct to " << Control.time().path()+ pointStructureFile__<< endREPORT<<endl<<endl;
if( !Control.time().write())
{
fatalErrorInFunction<<
"ERRor in writing to file. \n ";
return 1;
}
}else
{
auto& pStruct = Control.time().emplaceObject<pointStructure>
(
objectFile
(
pointStructureFile__,
Control.time().path(),
objectFile::READ_NEVER,
objectFile::WRITE_ALWAYS
)
);
pStructPtr = &pStruct;
}
if(!positionOnly)
{
auto& pStruct = *pStructPtr;
auto& sfDict = cpDict.subDict("setFields");
setFieldList defValueList(sfDict.subDict("defaultValue"));
for(auto& sfEntry: defValueList)
{
if( !sfEntry.setPointFieldDefaultValueNewAll(Control.time(), pStruct, true))
{
ERR<< "\n error occured in setting default value fields.\n"<<endERR;
return 1;
}
}
output<<endl;
auto& selectorsDict = sfDict.subDict("selectors");
auto selNames = selectorsDict.dictionaryKeywords();
for(auto name: selNames)
{
REPORT(1)<< "Applying selector " << greenText(name) <<endREPORT;
if(
!applySelector(Control, pStruct, selectorsDict.subDict(name))
)
{
ERR<<"\n error occured in setting selector. \n"<<endERR;
return 1;
}
output<<endl;
}
}
Control.time().write(true);
REPORT(0)<< greenText("\nFinished successfully.\n")<<endREPORT;
// this should be palced in each main
#include "finalize.hpp"
return 0;
}
/*
uniquePtr<IOobject> pStructObj{nullptr}; uniquePtr<IOobject> pStructObj{nullptr};
if(!setOnly) if(!setOnly)
@ -189,13 +302,4 @@ int main( int argc, char* argv[] )
output<<endl; output<<endl;
} }
} }
*/
Control.time().write(true);
REPORT(0)<< greenText("\nFinished successfully.\n")<<endREPORT;
// this should be palced in each main
#include "finalize.hpp"
return 0;
}