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

@ -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-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -238,11 +238,7 @@ Foam::patchProbes::patchProbes
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchProbes::~patchProbes()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::patchProbes::write()
{
@ -269,9 +265,10 @@ bool Foam::patchProbes::read(const dictionary& dict)
{
if (!dict.readIfPresent("patches", patchNames_))
{
word patchName(dict.lookup("patch"));
patchNames_ = wordReList(1, wordRe(patchName));
patchNames_.setSize(1);
patchNames_[0] = wordRe(word(dict.lookup("patch")));
}
return probes::read(dict);
}

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.
@ -96,7 +96,7 @@ protected:
// Protected data
//- Patches to sample
wordReList patchNames_;
wordRes patchNames_;
// Protected Member Functions
@ -173,7 +173,7 @@ public:
);
//- Destructor
virtual ~patchProbes();
virtual ~patchProbes() = default;
//- Public members

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -313,11 +313,6 @@ Foam::probes::probes
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::probes::~probes()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

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-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,7 +85,7 @@ SourceFiles
#include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H"
#include "surfaceMesh.H"
#include "wordReList.H"
#include "wordRes.H"
using namespace Foam::functionObjects;
@ -141,7 +141,7 @@ protected:
// Read from dictonary
//- Names of fields to probe
wordReList fieldSelection_;
wordRes fieldSelection_;
//- Fixed locations, default = yes
// Note: set to false for moving mesh calculations where locations
@ -254,13 +254,13 @@ public:
//- Destructor
virtual ~probes();
virtual ~probes() = default;
// Member Functions
//- Return names of fields to probe
virtual const wordReList& fieldNames() const
virtual const wordRes& fieldNames() const
{
return fieldSelection_;
}

View File

@ -314,10 +314,4 @@ Foam::patchCloudSet::patchCloudSet
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchCloudSet::~patchCloudSet()
{}
// ************************************************************************* //

View File

@ -112,7 +112,7 @@ public:
//- Destructor
virtual ~patchCloudSet();
virtual ~patchCloudSet() = default;
};

View File

@ -364,10 +364,4 @@ Foam::patchSeedSet::patchSeedSet
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchSeedSet::~patchSeedSet()
{}
// ************************************************************************* //

View File

@ -103,7 +103,7 @@ public:
//- Destructor
virtual ~patchSeedSet();
virtual ~patchSeedSet() = default;
};

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -209,12 +209,6 @@ Foam::sampledSets::sampledSets
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledSets::~sampledSets()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sampledSets::verbose(const bool verbosity)

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) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,7 +43,7 @@ SourceFiles
#include "interpolation.H"
#include "coordSet.H"
#include "writer.H"
#include "wordReList.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -175,7 +175,7 @@ class sampledSets
// Read from dictonary
//- Names of fields to sample
wordReList fieldSelection_;
wordRes fieldSelection_;
//- Interpolation scheme to use
word interpolationScheme_;
@ -273,7 +273,7 @@ public:
//- Destructor
virtual ~sampledSets();
virtual ~sampledSets() = default;
// Member Functions

View File

@ -47,7 +47,7 @@ Foam::sampledPatch::sampledPatch
(
const word& name,
const polyMesh& mesh,
const wordReList& patchNames,
const UList<wordRe>& patchNames,
const bool triangulate
)
:
@ -72,12 +72,6 @@ Foam::sampledPatch::sampledPatch
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::sampledPatch::~sampledPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::labelList& Foam::sampledPatch::patchIDs() const
@ -126,7 +120,8 @@ bool Foam::sampledPatch::update()
label sz = 0;
forAll(patchIDs(), i)
{
label patchi = patchIDs()[i];
const label patchi = patchIDs()[i];
const polyPatch& pp = mesh().boundaryMesh()[patchi];
if (isA<emptyPolyPatch>(pp))
@ -150,7 +145,7 @@ bool Foam::sampledPatch::update()
forAll(patchIDs(), i)
{
label patchi = patchIDs()[i];
const label patchi = patchIDs()[i];
patchStart_[i] = sz;

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.
@ -37,6 +37,7 @@ SourceFiles
#include "sampledSurface.H"
#include "MeshedSurface.H"
#include "wordRes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,7 +60,7 @@ class sampledPatch
// Private data
//- Name of patches
const wordReList patchNames_;
const wordRes patchNames_;
//- Corresponding patchIDs
mutable labelList patchIDs_;
@ -105,7 +106,7 @@ class sampledPatch
protected:
const wordReList& patchNames() const
const wordRes& patchNames() const
{
return patchNames_;
}
@ -136,7 +137,7 @@ public:
(
const word& name,
const polyMesh& mesh,
const wordReList& patchNames,
const UList<wordRe>& patchNames,
const bool triangulate = false
);
@ -150,7 +151,7 @@ public:
//- Destructor
virtual ~sampledPatch();
virtual ~sampledPatch() = default;
// Member Functions

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) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,7 +87,7 @@ SourceFiles
#include "mergedSurf.H"
#include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H"
#include "wordReList.H"
#include "wordRes.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -133,7 +133,7 @@ class sampledSurfaces
// Read from dictonary
//- Names of fields to sample
wordReList fieldSelection_;
wordRes fieldSelection_;
//- Interpolation scheme to use
word interpolationScheme_;

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
@ -121,12 +121,6 @@ Foam::surfMeshSampler::surfMeshSampler
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfMeshSampler::~surfMeshSampler()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMeshSampler::create() const
@ -177,13 +171,13 @@ const Foam::surfMesh& Foam::surfMeshSampler::surface() const
Foam::label Foam::surfMeshSampler::sample
(
const UList<word>& fields
const UList<word>& fieldNames
) const
{
label count = 0;
forAll(fields, fieldi)
for (const word& fieldName : fieldNames)
{
if (sample(fields[fieldi]))
if (sample(fieldName))
{
++count;
}
@ -193,7 +187,7 @@ Foam::label Foam::surfMeshSampler::sample
}
Foam::label Foam::surfMeshSampler::write(const wordReList& select) const
Foam::label Foam::surfMeshSampler::write(const wordRes& select) const
{
label count =
(

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
@ -111,7 +111,7 @@ protected:
//- Write the given fields
template<class Type>
label writeFields(const wordReList& select) const;
label writeFields(const wordRes& select) const;
public:
@ -198,7 +198,7 @@ public:
//- Destructor
virtual ~surfMeshSampler();
virtual ~surfMeshSampler() = default;
// Member Functions
@ -253,16 +253,16 @@ public:
virtual bool sample(const word& fieldName) const = 0;
//- Sample from volume fields to specified surface fields.
virtual label sample(const UList<word>& fields) const;
virtual label sample(const UList<word>& fieldNames) const;
// Write
//- Write specified fields
virtual label write(const wordReList& fieldSelection) const;
virtual label write(const wordRes& fieldSelection) const;
//- Write
virtual void print(Ostream&) const;
virtual void print(Ostream& os) const;
};

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
@ -106,19 +106,19 @@ Foam::surfMeshSampler::getOrCreateSurfField
template<class Type>
Foam::label Foam::surfMeshSampler::writeFields
(
const wordReList& select
const wordRes& select
) const
{
typedef DimensionedField<Type, surfGeoMesh> SurfFieldType;
const surfMesh& s = surface();
wordList names = s.sortedNames<SurfFieldType>(select);
forAll(names, namei)
const wordList fieldNames = s.sortedNames<SurfFieldType>(select);
for (const word& fieldName : fieldNames)
{
s.lookupObject<SurfFieldType>(names[namei]).write();
s.lookupObject<SurfFieldType>(fieldName).write();
}
return names.size();
return fieldNames.size();
}

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
@ -31,7 +31,6 @@ License
#include "volPointInterpolation.H"
#include "PatchTools.H"
#include "mapPolyMesh.H"
#include "wordRes.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -132,12 +131,6 @@ Foam::surfMeshSamplers::surfMeshSamplers
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfMeshSamplers::~surfMeshSamplers()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMeshSamplers::verbose(const bool verbosity)
@ -279,10 +272,10 @@ bool Foam::surfMeshSamplers::write()
// or elsewhere
// This could be more efficient
wordReList select(fieldSelection_.size() + derivedNames_.size());
wordRes select(fieldSelection_.size() + derivedNames_.size());
label nElem = 0;
for (const auto& item : fieldSelection_)
for (const wordRe& item : fieldSelection_)
{
select[nElem++] = item;
}
@ -291,8 +284,8 @@ bool Foam::surfMeshSamplers::write()
select[nElem++] = derivedName;
}
// avoid duplicate entries
select = wordRes::uniq(select);
// Avoid duplicate entries
select.uniq();
for (const surfMeshSampler& s : surfaces())
{
@ -308,15 +301,13 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
fieldSelection_.clear();
derivedNames_.clear();
const bool createOnRead =
dict.lookupOrDefault<Switch>("createOnRead", false);
const bool createOnRead = dict.lookupOrDefault("createOnRead", false);
if (dict.found("surfaces"))
{
fieldSelection_ = wordRes::uniq
(
wordReList(dict.lookup("fields"))
);
dict.lookup("fields") >> fieldSelection_;
fieldSelection_.uniq();
Info<< type() << " fields: " << fieldSelection_ << nl;
if (dict.readIfPresent("derived", derivedNames_))

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
@ -82,7 +82,7 @@ SourceFiles
#include "surfMeshSampler.H"
#include "volFieldsFwd.H"
#include "surfaceFieldsFwd.H"
#include "wordReList.H"
#include "wordRes.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -119,7 +119,7 @@ class surfMeshSamplers
// Read from dictonary
//- Names of fields to sample
wordReList fieldSelection_;
wordRes fieldSelection_;
//- Names of derived fields to create and sample
wordList derivedNames_;
@ -183,7 +183,7 @@ public:
//- Destructor
virtual ~surfMeshSamplers();
virtual ~surfMeshSamplers() = default;
// Member Functions