mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve IOobjectList functionality (issue #322)
- provide additional filtering methods on names(), sortedNames()
For example,
IOobjectList objects = ...;
wordReList selection = ...;
objects.sortedNames(VolFieldType::typeName, selection);
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 |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "Time.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IOList.H"
|
||||
#include "stringListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -228,7 +229,10 @@ Foam::wordList Foam::IOobjectList::sortedNames() const
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
|
||||
Foam::wordList Foam::IOobjectList::names
|
||||
(
|
||||
const word& ClassName
|
||||
) const
|
||||
{
|
||||
wordList objectNames(size());
|
||||
|
||||
@ -247,7 +251,34 @@ Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::sortedNames(const word& ClassName) const
|
||||
Foam::wordList Foam::IOobjectList::names
|
||||
(
|
||||
const word& ClassName,
|
||||
const wordRe& matcher
|
||||
) const
|
||||
{
|
||||
wordList objNames = names(ClassName);
|
||||
|
||||
return wordList(objNames, findStrings(matcher, objNames));
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::names
|
||||
(
|
||||
const word& ClassName,
|
||||
const wordReList& matcher
|
||||
) const
|
||||
{
|
||||
wordList objNames = names(ClassName);
|
||||
|
||||
return wordList(objNames, findStrings(matcher, objNames));
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::sortedNames
|
||||
(
|
||||
const word& ClassName
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(ClassName);
|
||||
sort(sortedLst);
|
||||
@ -256,4 +287,30 @@ Foam::wordList Foam::IOobjectList::sortedNames(const word& ClassName) const
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::sortedNames
|
||||
(
|
||||
const word& ClassName,
|
||||
const wordRe& matcher
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(ClassName, matcher);
|
||||
sort(sortedLst);
|
||||
|
||||
return sortedLst;
|
||||
}
|
||||
|
||||
|
||||
Foam::wordList Foam::IOobjectList::sortedNames
|
||||
(
|
||||
const word& ClassName,
|
||||
const wordReList& matcher
|
||||
) const
|
||||
{
|
||||
wordList sortedLst = names(ClassName, matcher);
|
||||
sort(sortedLst);
|
||||
|
||||
return sortedLst;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -55,7 +55,7 @@ class IOobjectList
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const IOobjectList&);
|
||||
void operator=(const IOobjectList&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
@ -104,17 +104,35 @@ public:
|
||||
//- Return the list for all IOobjects of a given class
|
||||
IOobjectList lookupClass(const word& className) const;
|
||||
|
||||
//- Return the list of names of the IOobjects
|
||||
|
||||
//- A list of names of the IOobjects
|
||||
wordList names() const;
|
||||
|
||||
//- Return the sorted list of names of the IOobjects
|
||||
wordList sortedNames() const;
|
||||
|
||||
//- Return the list of names of the IOobjects of given class
|
||||
//- A list of names of IOobjects of the given class
|
||||
wordList names(const word& className) const;
|
||||
|
||||
//- Return the sorted list of names of the IOobjects of given class
|
||||
//- A list of names of IOobjects of the given class,
|
||||
// and that also satisfy the input matcher
|
||||
wordList names(const word& className, const wordRe&) const;
|
||||
|
||||
//- A list of names of IOobjects of the given class,
|
||||
// and that also satisfy the input matchers
|
||||
wordList names(const word& className, const wordReList&) const;
|
||||
|
||||
|
||||
//- A sorted list of names of the IOobjects
|
||||
wordList sortedNames() const;
|
||||
|
||||
//- A sorted list of names of IOobjects of given class
|
||||
wordList sortedNames(const word& className) const;
|
||||
|
||||
//- A sorted list of names of IOobjects of the given class,
|
||||
// and that also satisfy the input matcher
|
||||
wordList sortedNames(const word& className, const wordRe&) const;
|
||||
|
||||
//- A sorted list of names of IOobjects of the given class,
|
||||
// and that also satisfy the input matchers
|
||||
wordList sortedNames(const word& className, const wordReList&) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user