ENH: change wordRes to be a List of wordRe instead of a wrapper (issue #259)

- this permits direct storage of a list with additional matcher
  capabilities

- provide wordRes::matcher class for similar behaviour as previously
This commit is contained in:
Mark Olesen
2018-02-21 10:05:30 +01:00
parent 03b287ed24
commit c126464d1c
113 changed files with 572 additions and 801 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,7 +26,6 @@ License
#include "ensightWrite.H"
#include "Time.H"
#include "polyMesh.H"
#include "wordRes.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -109,23 +108,20 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
//
// writer options
//
writeOpts_.noPatches
(
dict.lookupOrDefault<Switch>("noPatches", false)
);
writeOpts_.noPatches(dict.lookupOrDefault("noPatches", false));
if (dict.found("patches"))
{
wordReList lst(dict.lookup("patches"));
wordRes::inplaceUniq(lst);
wordRes lst(dict.lookup("patches"));
lst.uniq();
writeOpts_.patchSelection(lst);
}
if (dict.found("faceZones"))
{
wordReList lst(dict.lookup("faceZones"));
wordRes::inplaceUniq(lst);
wordRes lst(dict.lookup("faceZones"));
lst.uniq();
writeOpts_.faceZoneSelection(lst);
}
@ -137,21 +133,21 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
caseOpts_.width(dict.lookupOrDefault<label>("width", 8));
// remove existing output directory
caseOpts_.overwrite(dict.lookupOrDefault<Switch>("overwrite", false));
caseOpts_.overwrite(dict.lookupOrDefault("overwrite", false));
//
// other options
//
dict.readIfPresent("directory", dirName_);
consecutive_ = dict.lookupOrDefault<Switch>("consecutive", false);
consecutive_ = dict.lookupOrDefault("consecutive", false);
//
// output fields
//
dict.lookup("fields") >> selectFields_;
wordRes::inplaceUniq(selectFields_);
selectFields_.uniq();
return true;
}
@ -228,9 +224,8 @@ bool Foam::functionObjects::ensightWrite::write()
DynamicList<word> ignored(selectFields_.size());
// check exact matches first
forAll(selectFields_, i)
for (const wordRe& select : selectFields_)
{
const wordRe& select = selectFields_[i];
if (!select.isPattern())
{
const word& fieldName = static_cast<const word&>(select);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -90,7 +90,6 @@ SourceFiles
#include "ensightCase.H"
#include "ensightMesh.H"
#include "wordReList.H"
#include "interpolation.H"
#include "volFields.H"
#include "surfaceFields.H"
@ -121,7 +120,7 @@ class ensightWrite
ensightCase::options caseOpts_;
//- Name of fields to process
wordReList selectFields_;
wordRes selectFields_;
//- Output directory name
fileName dirName_;

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,7 +106,7 @@ bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
// output fields
//
dict.lookup("fields") >> selectFields_;
wordRes::inplaceUniq(selectFields_);
selectFields_.uniq();
return true;
}
@ -137,7 +137,7 @@ bool Foam::functionObjects::vtkWrite::write()
if (Pstream::parRun())
{
// Strip off leading casename, leaving just processor_DDD ending.
string::size_type i = vtkName.rfind("processor");
const auto i = vtkName.rfind("processor");
if (i != string::npos)
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,7 +101,7 @@ class vtkWrite
vtk::outputOptions writeOpts_;
//- Name of fields to process
wordReList selectFields_;
wordRes selectFields_;
//- Output directory name
fileName dirName_;

View File

@ -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 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -81,12 +81,6 @@ Foam::functionObjects::writeObjects::writeObjects
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::writeObjects::~writeObjects()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
@ -134,29 +128,26 @@ bool Foam::functionObjects::writeObjects::write()
}
DynamicList<word> allNames(obr_.toc().size());
forAll(objectNames_, i)
for (const wordRe& objName : objectNames_)
{
wordList names(obr_.names<regIOobject>(objectNames_[i]));
wordList names(obr_.names<regIOobject>(objName));
if (names.size())
{
allNames.append(names);
allNames.append(std::move(names));
}
else
{
WarningInFunction
<< "Object " << objectNames_[i] << " not found in "
<< "Object " << objName << " not found in "
<< "database. Available objects:" << nl << obr_.sortedToc()
<< endl;
}
}
forAll(allNames, i)
for (const word& objName : allNames)
{
regIOobject& obj = const_cast<regIOobject&>
(
obr_.lookupObject<regIOobject>(allNames[i])
);
regIOobject& obj = obr_.lookupObjectRef<regIOobject>(objName);
switch (writeOption_)
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -132,7 +132,7 @@ private:
writeOption writeOption_;
//- Names of objects to control
wordReList objectNames_;
wordRes objectNames_;
// Private Member Functions
@ -162,7 +162,7 @@ public:
//- Destructor
virtual ~writeObjects();
virtual ~writeObjects() = default;
// Member Functions