mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
OpenFOAM field reading: Automated the handling of <field>.orig files
Now if a <field> file does not exist first the compressed <field>.gz file is searched for and if that also does not exist the <field>.orig file is searched for. This simplifies case setup and run scripts as now setField for example can read the <field>.orig file directly and generate the <field> file from it which is then read by the solver. Additionally the cleanCase function used by foamCleanCase and the Allclean scripts automatically removed <field> files if there is a corresponding <field>.orig file. So now there is no need for the Allrun scripts to copy <field>.orig files into <field> or for the Allclean scripts to explicitly remove them.
This commit is contained in:
@ -563,9 +563,11 @@ bool Foam::isFile
|
||||
error::printStack(Pout);
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
S_ISREG(mode(name, followLink))
|
||||
|| (checkGzip && S_ISREG(mode(name + ".gz", followLink)));
|
||||
|| (checkGzip && S_ISREG(mode(name + ".gz", followLink)))
|
||||
|| (checkGzip && S_ISREG(mode(name + ".orig", followLink)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -53,20 +53,29 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
||||
ifPtr_ = new ifstream(pathname.c_str());
|
||||
|
||||
// If the file is compressed, decompress it before reading.
|
||||
if (!ifPtr_->good() && isFile(pathname + ".gz", false))
|
||||
if (!ifPtr_->good())
|
||||
{
|
||||
if (IFstream::debug)
|
||||
if (isFile(pathname + ".gz", false))
|
||||
{
|
||||
InfoInFunction << "Decompressing " << pathname + ".gz" << endl;
|
||||
delete ifPtr_;
|
||||
|
||||
if (IFstream::debug)
|
||||
{
|
||||
InfoInFunction << "Decompressing " << pathname + ".gz" << endl;
|
||||
}
|
||||
|
||||
ifPtr_ = new igzstream((pathname + ".gz").c_str());
|
||||
|
||||
if (ifPtr_->good())
|
||||
{
|
||||
compression_ = IOstream::COMPRESSED;
|
||||
}
|
||||
}
|
||||
|
||||
delete ifPtr_;
|
||||
|
||||
ifPtr_ = new igzstream((pathname + ".gz").c_str());
|
||||
|
||||
if (ifPtr_->good())
|
||||
else if (isFile(pathname + ".orig", false))
|
||||
{
|
||||
compression_ = IOstream::COMPRESSED;
|
||||
delete ifPtr_;
|
||||
|
||||
ifPtr_ = new ifstream((pathname + ".orig").c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user