mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: avoid double write triggering in writeObjects functionObject
- in the previous version, a specification such as (U "U.*") would have selected the field name twice for writing
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "writeObjects.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "ListOps.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -127,25 +128,33 @@ bool Foam::functionObjects::writeObjects::write()
|
||||
obr_.time().writeTimeDict();
|
||||
}
|
||||
|
||||
DynamicList<word> allNames(obr_.toc().size());
|
||||
for (const wordRe& objName : objectNames_)
|
||||
{
|
||||
wordList names(obr_.names<regIOobject>(objName));
|
||||
// Get selection
|
||||
const wordList selectedNames(obr_.sortedNames<regIOobject>(objectNames_));
|
||||
|
||||
if (names.size())
|
||||
// Warning if anything was missed
|
||||
bitSet missed(objectNames_.size());
|
||||
|
||||
label index = 0;
|
||||
for (const wordRe& select : objectNames_)
|
||||
{
|
||||
allNames.append(std::move(names));
|
||||
if (!ListOps::found(selectedNames, select))
|
||||
{
|
||||
missed.set(index);
|
||||
}
|
||||
else
|
||||
++index;
|
||||
}
|
||||
|
||||
if (missed.any())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Object " << objName << " not found in "
|
||||
<< "database. Available objects:" << nl << obr_.sortedToc()
|
||||
<< "No corresponding selection for "
|
||||
<< flatOutput(subset(missed, objectNames_)) << nl
|
||||
<< "Available objects in database:"
|
||||
<< nl << obr_.sortedToc()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
for (const word& objName : allNames)
|
||||
for (const word& objName : selectedNames)
|
||||
{
|
||||
regIOobject& obj = obr_.lookupObjectRef<regIOobject>(objName);
|
||||
|
||||
@ -181,6 +190,9 @@ bool Foam::functionObjects::writeObjects::write()
|
||||
<< ". Valid writeOption types are "
|
||||
<< writeOptionNames_
|
||||
<< exit(FatalError);
|
||||
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user