mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
functionObjectFile: Use wordList rather than wordHashSet to maintain order
Change based on patch provided by Hassan Kassem Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1796
This commit is contained in:
@ -33,12 +33,12 @@ License
|
||||
const Foam::word Foam::functionObjectFile::outputPrefix = "postProcessing";
|
||||
Foam::label Foam::functionObjectFile::addChars = 7;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjectFile::initStream(Ostream& os) const
|
||||
{
|
||||
os.setf(ios_base::scientific, ios_base::floatfield);
|
||||
// os.precision(IOstream::defaultPrecision());
|
||||
os.width(charWidth());
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ Foam::fileName Foam::functionObjectFile::baseFileDir() const
|
||||
baseDir = baseDir/outputPrefix;
|
||||
}
|
||||
|
||||
// append mesh name if not default region
|
||||
// Append mesh name if not default region
|
||||
if (isA<polyMesh>(obr_))
|
||||
{
|
||||
const polyMesh& mesh = refCast<const polyMesh>(obr_);
|
||||
@ -85,18 +85,16 @@ void Foam::functionObjectFile::createFiles()
|
||||
const word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(wordHashSet, names_, iter)
|
||||
forAll(names_, i)
|
||||
{
|
||||
if (!filePtrs_.set(i))
|
||||
{
|
||||
fileName outputDir(baseFileDir()/prefix_/startTimeName);
|
||||
|
||||
mkDir(outputDir);
|
||||
|
||||
word fName(iter.key());
|
||||
word fName(names_[i]);
|
||||
|
||||
// check if file already exists
|
||||
// Check if file already exists
|
||||
IFstream is(outputDir/(fName + ".dat"));
|
||||
if (is.good())
|
||||
{
|
||||
@ -109,7 +107,6 @@ void Foam::functionObjectFile::createFiles()
|
||||
|
||||
writeFileHeader(i);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -117,9 +114,7 @@ void Foam::functionObjectFile::createFiles()
|
||||
|
||||
|
||||
void Foam::functionObjectFile::writeFileHeader(const label i)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
void Foam::functionObjectFile::write()
|
||||
@ -131,12 +126,12 @@ void Foam::functionObjectFile::write()
|
||||
void Foam::functionObjectFile::resetNames(const wordList& names)
|
||||
{
|
||||
names_.clear();
|
||||
names_.insert(names);
|
||||
names_.append(names);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
filePtrs_.clear();
|
||||
filePtrs_.setSize(names_.toc().size());
|
||||
filePtrs_.setSize(names_.size());
|
||||
|
||||
createFiles();
|
||||
}
|
||||
@ -146,7 +141,7 @@ void Foam::functionObjectFile::resetNames(const wordList& names)
|
||||
void Foam::functionObjectFile::resetName(const word& name)
|
||||
{
|
||||
names_.clear();
|
||||
names_.insert(name);
|
||||
names_.append(name);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
@ -192,14 +187,13 @@ Foam::functionObjectFile::functionObjectFile
|
||||
filePtrs_()
|
||||
{
|
||||
names_.clear();
|
||||
names_.insert(name);
|
||||
|
||||
names_.append(name);
|
||||
if (Pstream::master())
|
||||
{
|
||||
filePtrs_.clear();
|
||||
filePtrs_.setSize(1);
|
||||
|
||||
// cannot create files - need to access virtual function
|
||||
// Cannot create files - need to access virtual function
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,14 +211,13 @@ Foam::functionObjectFile::functionObjectFile
|
||||
filePtrs_()
|
||||
{
|
||||
names_.clear();
|
||||
names_.insert(names);
|
||||
|
||||
names_.append(names);
|
||||
if (Pstream::master())
|
||||
{
|
||||
filePtrs_.clear();
|
||||
filePtrs_.setSize(names_.size());
|
||||
|
||||
// cannot create files - need to access virtual function
|
||||
// Cannot create files - need to access virtual function
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,7 +230,7 @@ Foam::functionObjectFile::~functionObjectFile()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::wordHashSet& Foam::functionObjectFile::names() const
|
||||
const Foam::wordList& Foam::functionObjectFile::names() const
|
||||
{
|
||||
return names_;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -57,8 +57,6 @@ namespace Foam
|
||||
|
||||
class functionObjectFile
|
||||
{
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the database
|
||||
@ -68,7 +66,7 @@ private:
|
||||
const word prefix_;
|
||||
|
||||
//- File names
|
||||
wordHashSet names_;
|
||||
wordList names_;
|
||||
|
||||
//- File pointer
|
||||
PtrList<OFstream> filePtrs_;
|
||||
@ -120,6 +118,7 @@ public:
|
||||
//- Additional characters for writing
|
||||
static label addChars;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
@ -149,7 +148,7 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Return const access to the names
|
||||
const wordHashSet& names() const;
|
||||
const wordList& names() const;
|
||||
|
||||
//- Return access to the file (if only 1)
|
||||
OFstream& file();
|
||||
|
||||
Reference in New Issue
Block a user