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
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / 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
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -26,6 +26,7 @@ License
|
|||||||
#include "writeObjects.H"
|
#include "writeObjects.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
|
#include "ListOps.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -127,25 +128,33 @@ bool Foam::functionObjects::writeObjects::write()
|
|||||||
obr_.time().writeTimeDict();
|
obr_.time().writeTimeDict();
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicList<word> allNames(obr_.toc().size());
|
// Get selection
|
||||||
for (const wordRe& objName : objectNames_)
|
const wordList selectedNames(obr_.sortedNames<regIOobject>(objectNames_));
|
||||||
{
|
|
||||||
wordList names(obr_.names<regIOobject>(objName));
|
|
||||||
|
|
||||||
if (names.size())
|
// Warning if anything was missed
|
||||||
|
bitSet missed(objectNames_.size());
|
||||||
|
|
||||||
|
label index = 0;
|
||||||
|
for (const wordRe& select : objectNames_)
|
||||||
|
{
|
||||||
|
if (!ListOps::found(selectedNames, select))
|
||||||
{
|
{
|
||||||
allNames.append(std::move(names));
|
missed.set(index);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WarningInFunction
|
|
||||||
<< "Object " << objName << " not found in "
|
|
||||||
<< "database. Available objects:" << nl << obr_.sortedToc()
|
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
|
++index;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const word& objName : allNames)
|
if (missed.any())
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "No corresponding selection for "
|
||||||
|
<< flatOutput(subset(missed, objectNames_)) << nl
|
||||||
|
<< "Available objects in database:"
|
||||||
|
<< nl << obr_.sortedToc()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const word& objName : selectedNames)
|
||||||
{
|
{
|
||||||
regIOobject& obj = obr_.lookupObjectRef<regIOobject>(objName);
|
regIOobject& obj = obr_.lookupObjectRef<regIOobject>(objName);
|
||||||
|
|
||||||
@ -181,6 +190,9 @@ bool Foam::functionObjects::writeObjects::write()
|
|||||||
<< ". Valid writeOption types are "
|
<< ". Valid writeOption types are "
|
||||||
<< writeOptionNames_
|
<< writeOptionNames_
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user