Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (12)
Showing
with 570 additions and 437 deletions
......@@ -49,10 +49,31 @@ void reportDetail(const IOobjectList& objects)
for (const word& key : objects.sortedNames())
{
IOobject* io = objects.lookup(key);
// Canonical method name (NOV-2018)
IOobject* io = objects.findObject(key);
label count = 0;
// Test deprecated alternatives
{
// (const char*)
IOobject* ptr = objects.lookup("SomeNonExistentName");
if (ptr) ++count;
}
{
// (const word&)
IOobject* ptr = objects.lookup(key);
if (ptr) ++count;
}
Info<< key << " (" << io->headerClassName()
<< ") = addr " << long(io) << nl;
if (count != 1)
{
Warning
<< key << " had incorrect lookup?" << nl;
}
}
Info<<"====" << nl;
......
......@@ -26,6 +26,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "stringListOps.H"
#include "FlatOutput.H"
#include "IOstreams.H"
#include "StringStream.H"
......@@ -64,7 +65,10 @@ int main(int argc, char *argv[])
matches = findStrings(reLst, strLst);
Info<< "matches found for " << reLst << nl << matches << nl;
Info<< "matching " << flatOutput(reLst) << " => "
<< reLst.matching(strLst) << nl;
Info<< "matches found for " << flatOutput(reLst) << " => "
<< matches << nl;
forAll(matches, i)
{
Info<< " -> " << strLst[matches[i]] << nl;
......
......@@ -43,7 +43,6 @@ Description
#include "refinementFeatures.H"
#include "shellSurfaces.H"
#include "decompositionMethod.H"
#include "noDecomp.H"
#include "fvMeshDistribute.H"
#include "wallPolyPatch.H"
#include "refinementParameters.H"
......
......@@ -183,50 +183,56 @@ structuredCoeffs
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Decomposition constraints
//constraints
//{
// preserveBaffles
// {
// //- Keep owner and neighbour of baffles on same processor (i.e.
// // keep it detectable as a baffle). Baffles are two boundary face
// // sharing the same points
// type preserveBaffles;
// }
// preserveFaceZones
// {
// //- Keep owner and neighbour on same processor for faces in zones
// type preserveFaceZones;
// zones (".*");
// }
// preservePatches
// {
// //- Keep owner and neighbour on same processor for faces in patches
// // (only makes sense for cyclic patches. Not suitable for e.g.
// // cyclicAMI since these are not coupled on the patch level. Use
// // singleProcessorFaceSets for those)
// type preservePatches;
// patches (".*");
// }
// singleProcessorFaceSets
// {
// //- Keep all of faceSet on a single processor. This puts all cells
// // connected with a point, edge or face on the same processor.
// // (just having face connected cells might not guarantee a balanced
// // decomposition)
// // The processor can be -1 (the decompositionMethod chooses the
// // processor for a good load balance) or explicitly provided (upsets
// // balance)
// type singleProcessorFaceSets;
// singleProcessorFaceSets ((f1 -1));
// }
// refinementHistory
// {
// //- Decompose cells such that all cell originating from single cell
// // end up on same processor
// type refinementHistory;
// }
//}
/*
constraints
{
baffles
{
//- Keep owner and neighbour of baffles on same processor (i.e.
// keep it detectable as a baffle). Baffles are two boundary face
// sharing the same points
type preserveBaffles;
enabled false;
}
faces
{
//- Keep owner and neighbour on same processor for faces in zones
type preserveFaceZones;
zones (".*");
enabled false;
}
patches
{
//- Keep owner and neighbour on same processor for faces in patches
// (only makes sense for cyclic patches. Not suitable for e.g.
// cyclicAMI since these are not coupled on the patch level. Use
// singleProcessorFaceSets for those)
type preservePatches;
patches (".*");
enabled false;
}
processors
{
//- Keep all of faceSet on a single processor. This puts all cells
// connected with a point, edge or face on the same processor.
// (just having face connected cells might not guarantee a balanced
// decomposition)
// The processor can be -1 (the decompositionMethod chooses the
// processor for a good load balance) or explicitly provided (upsets
// balance)
type singleProcessorFaceSets;
sets ((f1 -1));
enabled false;
}
refinement
{
//- Decompose cells such that all cell originating from single cell
// end up on same processor
type refinementHistory;
enabled false;
}
}
*/
// Deprecated form of specifying decomposition constraints:
//- Keep owner and neighbour on same processor for faces in zones:
......@@ -251,5 +257,4 @@ structuredCoeffs
// same points.
//preserveBaffles true;
// ************************************************************************* //
......@@ -412,7 +412,7 @@ int main(int argc, char *argv[])
const word& fieldName = fieldIter.key();
const word& fieldType = fieldIter.object();
IOobject *fieldObject = cloudObjs.lookup(fieldName);
IOobject *fieldObject = cloudObjs.findObject(fieldName);
if (!fieldObject)
{
......
......@@ -32,7 +32,7 @@ bool Foam::fieldOk(const IOobjectList& cloudObjs, const word& name)
{
IOobjectList objects(cloudObjs.lookupClass(IOField<Type>::typeName));
return (objects.lookup(name) != nullptr);
return (objects.findObject(name) != nullptr);
}
......@@ -45,7 +45,7 @@ Foam::tmp<Foam::Field<Type>> Foam::readParticleField
{
IOobjectList objects(cloudObjs.lookupClass(IOField<Type>::typeName));
const IOobject* obj = objects.lookup(name);
const IOobject* obj = objects.findObject(name);
if (obj != nullptr)
{
IOField<Type> newField(*obj);
......@@ -72,7 +72,7 @@ void Foam::readFields
forAll(fieldNames, j)
{
const IOobject* obj = objects.lookup(fieldNames[j]);
const IOobject* obj = objects.findObject(fieldNames[j]);
if (obj != nullptr)
{
Info<< " reading field " << fieldNames[j] << endl;
......@@ -158,7 +158,7 @@ void Foam::processFields
DynamicList<word> fieldNames(objects.size());
forAll(userFieldNames, i)
{
IOobject* obj = objects.lookup(userFieldNames[i]);
IOobject* obj = objects.findObject(userFieldNames[i]);
if (obj != nullptr)
{
fieldNames.append(obj->name());
......
......@@ -141,7 +141,7 @@ int main(int argc, char *argv[])
// Pressure field
autoPtr<volScalarField> pField
= loadField<volScalarField>(mesh, objects.lookup("p"));
= loadField<volScalarField>(mesh, objects.findObject("p"));
// The forces per zone
if (movement().forcesAndMoments(mesh, forces, moments))
......
......@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
"uniform"
);
IOobject* ioptr = objects.lookup(profilingFileName);
IOobject* ioptr = objects.findObject(profilingFileName);
if (ioptr)
{
IOdictionary dict(*ioptr);
......
......@@ -518,7 +518,8 @@ int main(int argc, char *argv[])
patchNames[patchi] = surf.patches()[patchi].name();
}
labelList indices = findStrings(baffleSelect, patchNames);
labelList indices(baffleSelect.matching(patchNames));
for (const label patchId : indices)
{
surfBaffleRegions[patchId] = true;
......
......@@ -33,8 +33,8 @@ Description
processor has all triangles that overlap its mesh.
Note
- best decomposition option is hierarchGeomDecomp since
guarantees square decompositions.
- best decomposition option is hierarchical since it guarantees
square decompositions.
- triangles might be present on multiple processors.
- merging uses geometric tolerance so take care with writing precision.
......
......@@ -628,7 +628,6 @@ fields/cloud/cloud.C
Fields = fields/Fields
$(Fields)/Field/FieldBase.C
$(Fields)/fieldTypes.C
$(Fields)/labelField/labelField.C
$(Fields)/labelField/labelIOField.C
$(Fields)/labelField/labelFieldIOField.C
......@@ -659,6 +658,7 @@ $(Fields)/triadField/triadField.C
$(Fields)/triadField/triadIOField.C
$(Fields)/complexFields/complexFields.C
$(Fields)/transformField/transformField.C
$(Fields)/fieldTypes.C
pointPatchFields = fields/pointPatchFields
......
......@@ -561,8 +561,8 @@ public:
// Housekeeping
//- Identical to toc()
// \deprecated compatibility name for PackedBoolList (APR-2018)
//- \deprecated(2018-04) compatibility name for PackedBoolList
// \deprecated(2018-04) - use toc() method
inline labelList used() const { return toc(); }
};
......
......@@ -55,10 +55,10 @@ SourceFiles
namespace Foam
{
//- Return reference to zero-sized list.
//- Deprecated(2018-07) reference to zero-sized list.
// Compare to List::null() which returns null pointer cast as list reference.
//
// \deprecated This cast is disallowed with many modern compilers (JUL-2018)
// \deprecated(2018-07) This cast is disallowed with many modern compilers
template<class T>
static const List<T>& emptyList()
{
......@@ -376,9 +376,9 @@ List<OutputIntListType> invertManyToMany
// Optionally with an alternative start index, so that (map[i] == i+start)
labelList identity(const label len, label start=0);
//- Linear search to find the first occurence of the given element.
//- Deprecated(2017-10) search for first occurence of the given element.
// \return The index found or return -1 if not found.
// \deprecated prefer UList find/found methods (deprecated Oct 2017)
// \deprecated(2017-10) - use the UList find/found methods
template<class ListType>
label findIndex
(
......
......@@ -359,6 +359,16 @@ public:
inline bool& globalObject();
// Checks
//- Test if headerClassName() equals the given class name
inline bool isHeaderClassName(const word& clsName) const;
//- Test if headerClassName() equals Type::typeName
template<class Type>
inline bool isHeaderClassName() const;
// Read/write options
//- The read option
......@@ -488,6 +498,14 @@ public:
};
//- Specialization for \c void always returns true (no headerClassName check).
template<>
inline bool IOobject::isHeaderClassName<void>() const
{
return true;
}
template<>
Ostream& operator<<(Ostream& os, const InfoProxy<IOobject>& ip);
......
......@@ -107,6 +107,21 @@ inline bool& Foam::IOobject::globalObject()
}
// Checks
inline bool Foam::IOobject::isHeaderClassName(const word& clsName) const
{
return (clsName == headerClassName_);
}
template<class Type>
inline bool Foam::IOobject::isHeaderClassName() const
{
return (Type::typeName == headerClassName_);
}
// Read/write options
inline Foam::IOobject::readOption Foam::IOobject::readOpt() const
......
......@@ -74,10 +74,13 @@ bool Foam::IOobject::readHeader(Istream& is)
headerDict.get<float>("version")
)
);
is.format(headerDict.get<word>("format"));
headerClassName_ = headerDict.get<word>("class");
const word headerObject(headerDict.get<word>("object"));
if (IOobject::debug && headerObject != name())
{
IOWarningInFunction(is)
......
......@@ -25,169 +25,51 @@ License
#include "IOobjectList.H"
#include "Time.H"
#include "OSspecific.H"
#include "IOList.H"
#include "predicates.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
namespace Foam
bool Foam::IOobjectList::checkNames(wordList& masterNames, const bool syncPar)
{
// Templated implementation for lookup() - file-scope
template<class UnaryMatchPredicate>
static IOobjectList lookupImpl
(
const IOobjectList& list,
const UnaryMatchPredicate& matcher
)
{
IOobjectList results(list.size());
forAllConstIters(list, iter)
{
const word& key = iter.key();
const IOobject* io = iter.object();
if (matcher(key))
{
if (IOobject::debug)
{
InfoInFunction << "Found " << key << endl;
}
results.set(key, new IOobject(*io));
}
}
return results;
}
// Sort for consistent order on all processors
Foam::sort(masterNames);
// Templated implementation for lookupClass() - file-scope
template<class UnaryMatchPredicate>
static IOobjectList lookupClassImpl
(
const IOobjectList& list,
const word& clsName,
const UnaryMatchPredicate& matcher
)
if (syncPar && Pstream::parRun())
{
IOobjectList results(list.size());
const wordList localNames(masterNames);
Pstream::scatter(masterNames);
forAllConstIters(list, iter)
if (localNames != masterNames)
{
const word& key = iter.key();
const IOobject* io = iter.object();
if (clsName == io->headerClassName() && matcher(key))
{
if (IOobject::debug)
{
InfoInFunction << "Found " << key << endl;
}
results.set(key, new IOobject(*io));
}
FatalErrorInFunction
<< "Objects not synchronised across processors." << nl
<< "Master has " << flatOutput(masterNames) << nl
<< "Processor " << Pstream::myProcNo()
<< " has " << flatOutput(localNames)
<< exit(FatalError);
return false;
}
return results;
}
// Templated implementation for classes() - file-scope
template<class UnaryMatchPredicate>
static HashTable<wordHashSet> classesImpl
(
const IOobjectList& list,
const UnaryMatchPredicate& matcher
)
{
HashTable<wordHashSet> summary(2*list.size());
// Summary (key,val) = (class-name, object-names)
forAllConstIters(list, iter)
{
const word& key = iter.key();
const IOobject* io = iter.object();
if (matcher(key))
{
// Create entry (if needed) and insert
summary(io->headerClassName()).insert(key);
}
}
return summary;
}
// Templated implementation for names(), sortedNames() - file-scope
template<class UnaryMatchPredicate>
static wordList namesImpl
(
const IOobjectList& list,
const word& clsName,
const UnaryMatchPredicate& matcher,
const bool doSort
)
{
wordList objNames(list.size());
label count = 0;
forAllConstIters(list, iter)
{
const word& key = iter.key();
const IOobject* io = iter.object();
if (clsName == io->headerClassName() && matcher(key))
{
objNames[count] = key;
++count;
}
}
objNames.resize(count);
if (doSort)
{
Foam::sort(objNames);
}
return objNames;
}
return true;
}
// With syncPar = true, check that object names are the same on
// all processors. Trigger FatalError if not.
//
// The object names are sorted as a side-effect, since this is
// required for consistent ordering across all processors.
static bool checkNames(wordList& masterNames, const bool syncPar)
void Foam::IOobjectList::syncNames(wordList& objNames)
{
if (Pstream::parRun())
{
Foam::sort(masterNames);
if (syncPar && Pstream::parRun())
{
const wordList localNames(masterNames);
Pstream::scatter(masterNames);
if (localNames != masterNames)
{
FatalErrorInFunction
<< "Objects not synchronised across processors." << nl
<< "Master has " << flatOutput(masterNames) << nl
<< "Processor " << Pstream::myProcNo()
<< " has " << flatOutput(localNames)
<< exit(FatalError);
return false;
}
}
return true;
// Synchronize names
Pstream::combineGather(objNames, ListOps::uniqueEqOp<word>());
Pstream::combineScatter(objNames);
}
} // End namespace Foam
// Sort for consistent order on all processors
Foam::sort(objNames);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -354,15 +236,17 @@ bool Foam::IOobjectList::remove(const IOobject& io)
}
Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::IOobject* Foam::IOobjectList::findObject(const word& objName) const
{
const_iterator iter = cfind(name);
const_iterator iter = cfind(objName);
if (iter.found())
{
if (IOobject::debug)
{
InfoInFunction << "Found " << name << endl;
InfoInFunction << "Found " << objName << endl;
}
return const_cast<IOobject*>(*iter);
......@@ -370,33 +254,16 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const
if (IOobject::debug)
{
InfoInFunction << "Could not find " << name << endl;
InfoInFunction << "Could not find " << objName << endl;
}
return nullptr;
}
Foam::IOobjectList Foam::IOobjectList::lookup(const wordRe& matcher) const
Foam::IOobjectList Foam::IOobjectList::lookupClass(const char* clsName) const
{
return lookupImpl(*this, matcher);
}
Foam::IOobjectList Foam::IOobjectList::lookup(const wordRes& matcher) const
{
return lookupImpl(*this, matcher);
}
Foam::IOobjectList Foam::IOobjectList::lookup(const wordHashSet& matcher) const
{
return lookupImpl(*this, matcher);
}
Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& clsName) const
{
return lookupClassImpl(*this, clsName, predicates::always());
// No nullptr check - only called with string literals
return lookupClass(static_cast<word>(clsName));
}
......@@ -406,39 +273,12 @@ Foam::HashTable<Foam::wordHashSet> Foam::IOobjectList::classes() const
}
Foam::HashTable<Foam::wordHashSet>
Foam::IOobjectList::classes(const wordRe& matcher) const
{
return classesImpl(*this, matcher);
}
Foam::HashTable<Foam::wordHashSet>
Foam::IOobjectList::classes(const wordRes& matcher) const
{
return classesImpl(*this, matcher);
}
Foam::HashTable<Foam::wordHashSet>
Foam::IOobjectList::classes(const wordHashSet& matcher) const
{
return classesImpl(*this, matcher);
}
Foam::wordList Foam::IOobjectList::names() const
{
return HashPtrTable<IOobject>::toc();
}
Foam::wordList Foam::IOobjectList::sortedNames() const
{
return HashPtrTable<IOobject>::sortedToc();
}
Foam::wordList Foam::IOobjectList::names(const bool syncPar) const
{
wordList objNames(HashPtrTable<IOobject>::toc());
......@@ -453,16 +293,8 @@ Foam::wordList Foam::IOobjectList::names
const word& clsName
) const
{
return namesImpl(*this, clsName, predicates::always(), false);
}
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& clsName
) const
{
return namesImpl(*this, clsName, predicates::always(), true);
// sort/sync: false, false
return namesImpl(*this, clsName, predicates::always(), false, false);
}
......@@ -472,112 +304,47 @@ Foam::wordList Foam::IOobjectList::names
const bool syncPar
) const
{
wordList objNames(namesImpl(*this, clsName, predicates::always(), false));
checkNames(objNames, syncPar);
return objNames;
// sort: false
return namesImpl(*this, clsName, predicates::always(), false, syncPar);
}
Foam::wordList Foam::IOobjectList::names
(
const word& clsName,
const wordRe& matcher
) const
Foam::wordList Foam::IOobjectList::sortedNames() const
{
return namesImpl(*this, clsName, matcher, false);
return HashPtrTable<IOobject>::sortedToc();
}
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& clsName,
const wordRe& matcher
) const
{
return namesImpl(*this, clsName, matcher, true);
}
Foam::wordList Foam::IOobjectList::names
(
const word& clsName,
const wordRe& matcher,
const bool syncPar
) const
{
wordList objNames(namesImpl(*this, clsName, matcher, false));
wordList objNames(HashPtrTable<IOobject>::sortedToc());
checkNames(objNames, syncPar);
return objNames;
}
Foam::wordList Foam::IOobjectList::names
(
const word& clsName,
const wordRes& matcher
) const
{
return namesImpl(*this, clsName, matcher, false);
}
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& clsName,
const wordRes& matcher
) const
{
return namesImpl(*this, clsName, matcher, true);
}
Foam::wordList Foam::IOobjectList::names
(
const word& clsName,
const wordRes& matcher,
const bool syncPar
) const
{
wordList objNames(namesImpl(*this, clsName, matcher, false));
checkNames(objNames, syncPar);
return objNames;
}
Foam::wordList Foam::IOobjectList::names
(
const word& clsName,
const wordHashSet& matcher
const word& clsName
) const
{
return namesImpl(*this, clsName, matcher, false);
// sort/sync: true, false
return namesImpl(*this, clsName, predicates::always(), true, false);
}
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& clsName,
const wordHashSet& matcher
) const
{
return namesImpl(*this, clsName, matcher, true);
}
Foam::wordList Foam::IOobjectList::names
(
const word& clsName,
const wordHashSet& matcher,
const bool syncPar
) const
{
wordList objNames(namesImpl(*this, clsName, matcher, false));
checkNames(objNames, syncPar);
return objNames;
// sort: true
return namesImpl(*this, clsName, predicates::always(), true, syncPar);
}
......
......@@ -29,6 +29,7 @@ Description
SourceFiles
IOobjectList.C
IOobjectListTemplates.C
\*---------------------------------------------------------------------------*/
......@@ -45,11 +46,6 @@ SourceFiles
namespace Foam
{
// Forward declarations
class IOobjectList;
Ostream& operator<<(Ostream& os, const IOobjectList& list);
/*---------------------------------------------------------------------------*\
Class IOobjectList Declaration
\*---------------------------------------------------------------------------*/
......@@ -58,6 +54,57 @@ class IOobjectList
:
public HashPtrTable<IOobject>
{
// Private Member Functions
//- Check name consistency on all processors
//
// With syncPar = true, check that object names are the same on
// all processors. Trigger FatalError if not.
//
// When syncPar is used, the object names are sorted as a side-effect,
// since this is required for consistent ordering across processors.
static bool checkNames(wordList& masterNames, const bool syncPar);
//- Combine names from all processors and sort
static void syncNames(wordList& objNames);
//- Templated implementation for classes()
template<class MatchPredicate>
static HashTable<wordHashSet> classesImpl
(
const IOobjectList& list,
const MatchPredicate& matchName
);
//- Templated implementation for names(), sortedNames()
template<class MatchPredicate1, class MatchPredicate2>
static wordList namesImpl
(
const IOobjectList& list,
const MatchPredicate1& matchClass,
const MatchPredicate2& matchName,
const bool doSort,
const bool syncPar
);
//- Templated implementation for lookup()
template<class MatchPredicate>
static IOobjectList lookupImpl
(
const IOobjectList& list,
const MatchPredicate& matchName
);
//- Templated implementation for lookupClass()
template<class MatchPredicate1, class MatchPredicate2>
static IOobjectList lookupClassImpl
(
const IOobjectList& list,
const MatchPredicate1& matchClass,
const MatchPredicate2& matchName
);
public:
// Constructors
......@@ -90,7 +137,7 @@ public:
~IOobjectList() = default;
// Member functions
// Member Functions
// Basic methods
......@@ -125,22 +172,25 @@ public:
bool remove(const IOobject& io);
// Lookup
// Lookup single item
//- Locate an object by name
// \return IOobject ptr if found else nullptr
IOobject* findObject(const word& objName) const;
//- Lookup a given name and return IOobject ptr if found else nullptr
IOobject* lookup(const word& name) const;
//- The list of all IOobjects with matching names
IOobjectList lookup(const wordRe& matcher) const;
// Lookup multiple items
//- The list of all IOobjects with matching names
IOobjectList lookup(const wordRes& matcher) const;
//- The list of all IOobjects that have a matching object name.
template<class MatchPredicate>
IOobjectList lookup(const MatchPredicate& matchName) const;
//- The list of all IOobjects with matching names
IOobjectList lookup(const wordHashSet& matcher) const;
//- The list of all IOobjects with the given headerClassName
IOobjectList lookupClass(const char* clsName) const;
//- The list of all IOobjects with the given class name
IOobjectList lookupClass(const word& clsName) const;
//- The list of all IOobjects with matching headerClassName
template<class MatchPredicate>
IOobjectList lookupClass(const MatchPredicate& matchClass) const;
// Summary of classes
......@@ -212,108 +262,94 @@ public:
//
// Of course, there are many other ways to use and manipulate the
// summary information.
//
// \return HashTable of class-names for keys and wordHashSet of
// of object-names for the values.
HashTable<wordHashSet> classes() const;
//- A summary hash of classes used and their associated object names
// restricted to objects with names that satisfy the input matcher
HashTable<wordHashSet> classes(const wordRe& matcher) const;
//- A summary hash of classes used and their associated object names
// restricted to objects with names that satisfy the input matcher
HashTable<wordHashSet> classes(const wordRes& matcher) const;
//- A summary hash of classes used and their associated object names
// restricted to objects with names that satisfy the input matcher
HashTable<wordHashSet> classes(const wordHashSet& matcher) const;
//- A summary hash of classes used and their associated object names,
//- restricted to objects that have a matching object name.
template<class MatchPredicate>
HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
// Summary of names
//- A list of names of the IOobjects
//- The names of the IOobjects
wordList names() const;
//- The names of IOobjects with the given class name
wordList names(const word& clsName) const;
//- The names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
wordList names(const word& clsName, const wordRe& matcher) const;
//- The names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
wordList names(const word& clsName, const wordRes& matcher) const;
//- The names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
wordList names(const word& clsName, const wordHashSet& matcher) const;
//- A sorted list of names of the IOobjects.
// With syncPar = true, triggers FatalError if the names are
// not consistent on all processors.
//- The names of the IOobjects.
// With syncPar = true, sorts the names and triggers FatalError
// if the names are not consistent on all processors.
wordList names(const bool syncPar) const;
//- A sorted list of names of the IOobjects
// With syncPar = true, triggers FatalError if the names are
// not consistent on all processors.
//- The names of IOobjects with the given class
wordList names(const word& clsName) const;
//- The names of the IOobjects with the given headerClassName
// With syncPar = true, sorts the names and triggers FatalError
// if the names are not consistent on all processors.
wordList names(const word& clsName, const bool syncPar) const;
//- The sorted names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
// With syncPar = true, triggers FatalError if the names are
// not consistent on all processors.
//- The names of IOobjects with the given headerClassName
//- that also have a matching object name.
template<class MatchPredicate>
wordList names
(
const word& clsName,
const wordRe& matcher,
const bool syncPar
const MatchPredicate& matchName
) const;
//- The sorted names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
// With syncPar = true, triggers FatalError if the names are
// not consistent on all processors.
//- The names of the IOobjects with the given headerClassName
//- that also have a matching object name.
// With syncPar = true, sorts the names and triggers FatalError
// if the names are not consistent on all processors.
template<class MatchPredicate>
wordList names
(
const word& clsName,
const wordRes& matcher,
const bool syncPar
) const;
//- The sorted names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
// With syncPar = true, triggers FatalError if the names are
// not consistent on all processors.
wordList names
(
const word& cls,
const wordHashSet& matcher,
const MatchPredicate& matchName,
const bool syncPar
) const;
// Summary of names (sorted)
//- A sorted list of names of the IOobjects
//- The sorted names of the IOobjects
wordList sortedNames() const;
//- The sorted names of IOobjects with the given class name
//- The sorted names of the IOobjects
// With syncPar = true, a FatalError is
// triggered if the names are not consistent on all processors.
wordList sortedNames(const bool syncPar) const;
//- The sorted names of IOobjects with the given headerClassName
wordList sortedNames(const word& clsName) const;
//- The sorted names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
wordList sortedNames(const word& clsName, const wordRe& matcher) const;
//- The sorted names of the IOobjects with the given headerClassName
// With syncPar = true, sorts the names and triggers FatalError
// if the names are not consistent on all processors.
wordList sortedNames(const word& clsName, const bool syncPar) const;
//- The sorted names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
wordList sortedNames(const word& clsName, const wordRes& matcher) const;
//- The sorted names of IOobjects with the given headerClassName
//- that also have a matching object name.
template<class MatchPredicate>
wordList sortedNames
(
const word& clsName,
const MatchPredicate& matchName
) const;
//- The sorted names of IOobjects with the given class name that also
//- have a name satisfying the input matcher
//- The sorted names of the IOobjects with the given headerClassName
//- that also have a matching object name.
// With syncPar = true, sorts the names and triggers FatalError
// if the names are not consistent on all processors.
template<class MatchPredicate>
wordList sortedNames
(
const word& clsName,
const wordHashSet& matcher
const MatchPredicate& matchName,
const bool syncPar
) const;
......@@ -326,18 +362,42 @@ public:
void operator=(IOobjectList&& list);
// Ostream Operator
// Housekeeping
//- Deprecated(2018-11) Locate an object by name (c-string).
//- Disambiguated from multiple-lookup version by calling parameter.
// \deprecated(2018-11) use findObject() for non-ambiguous resolution
IOobject* lookup(const char* objName) const
{
return findObject(objName);
}
friend Ostream& operator<<(Ostream& os, const IOobjectList& list);
//- Deprecated(2018-11) Locate an object by name (const word&).
//- Disambiguated from multiple-lookup version by calling parameter.
// \deprecated(2018-11) use findObject() for non-ambiguous resolution
IOobject* lookup(const word& objName) const
{
return findObject(objName);
}
};
// Ostream operator
Ostream& operator<<(Ostream& os, const IOobjectList& list);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "IOobjectListTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "IOobjectList.H"
#include "predicates.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Templated implementation for classes()
template<class MatchPredicate>
Foam::HashTable<Foam::wordHashSet> Foam::IOobjectList::classesImpl
(
const IOobjectList& list,
const MatchPredicate& matchName
)
{
HashTable<wordHashSet> summary(2*list.size());
// Summary (key,val) = (class-name, object-names)
forAllConstIters(list, iter)
{
const word& key = iter.key();
const IOobject* io = iter.object();
if (matchName(key))
{
// Create entry (if needed) and insert
summary(io->headerClassName()).insert(key);
}
}
return summary;
}
// Templated implementation for names(), sortedNames()
template<class MatchPredicate1, class MatchPredicate2>
Foam::wordList Foam::IOobjectList::namesImpl
(
const IOobjectList& list,
const MatchPredicate1& matchClass,
const MatchPredicate2& matchName,
const bool doSort,
const bool syncPar
)
{
wordList objNames(list.size());
label count = 0;
forAllConstIters(list, iter)
{
const word& key = iter.key();
const IOobject* io = iter.object();
if (matchClass(io->headerClassName()) && matchName(key))
{
objNames[count] = key;
++count;
}
}
objNames.setSize(count);
if (doSort)
{
Foam::sort(objNames);
}
checkNames(objNames, syncPar);
return objNames;
}
// Templated implementation for lookup()
template<class MatchPredicate>
Foam::IOobjectList Foam::IOobjectList::lookupImpl
(
const IOobjectList& list,
const MatchPredicate& matchName
)
{
IOobjectList results(list.size());
forAllConstIters(list, iter)
{
const word& key = iter.key();
const IOobject* io = iter.object();
if (matchName(key))
{
if (IOobject::debug)
{
InfoInFunction << "Found " << key << endl;
}
results.set(key, new IOobject(*io));
}
}
return results;
}
// Templated implementation for lookupClass()
template<class MatchPredicate1, class MatchPredicate2>
Foam::IOobjectList Foam::IOobjectList::lookupClassImpl
(
const IOobjectList& list,
const MatchPredicate1& matchClass,
const MatchPredicate2& matchName
)
{
IOobjectList results(list.size());
forAllConstIters(list, iter)
{
const word& key = iter.key();
const IOobject* io = iter.object();
if (matchClass(io->headerClassName()) && matchName(key))
{
if (IOobject::debug)
{
InfoInFunction << "Found " << key << endl;
}
results.set(key, new IOobject(*io));
}
}
return results;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class MatchPredicate>
Foam::IOobjectList Foam::IOobjectList::lookup
(
const MatchPredicate& matchName
) const
{
return lookupImpl(*this, matchName);
}
template<class MatchPredicate>
Foam::IOobjectList Foam::IOobjectList::lookupClass
(
const MatchPredicate& matchClass
) const
{
return lookupClassImpl(*this, matchClass, predicates::always());
}
template<class MatchPredicate>
Foam::HashTable<Foam::wordHashSet>
Foam::IOobjectList::classes
(
const MatchPredicate& matchName
) const
{
return classesImpl(*this, matchName);
}
template<class MatchPredicate>
Foam::wordList Foam::IOobjectList::names
(
const word& clsName,
const MatchPredicate& matchName
) const
{
// sort/sync: false, false
return namesImpl(*this, clsName, matchName, false, false);
}
template<class MatchPredicate>
Foam::wordList Foam::IOobjectList::names
(
const word& clsName,
const MatchPredicate& matchName,
const bool syncPar
) const
{
// sort: false
return namesImpl(*this, clsName, matchName, false, syncPar);
}
template<class MatchPredicate>
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& clsName,
const MatchPredicate& matchName
) const
{
// sort/sync: true, false
return namesImpl(*this, clsName, matchName, true, false);
}
template<class MatchPredicate>
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& clsName,
const MatchPredicate& matchName,
const bool syncPar
) const
{
// sort: true
return namesImpl(*this, clsName, matchName, true, syncPar);
}
// ************************************************************************* //
......@@ -209,15 +209,14 @@ public:
{}
// Member functions
// Housekeeping
//- Clear the SHA1 calculation
// \deprecated use reset instead (deprecated Jul 2017)
//- Deprecated(2017-07) clear the SHA1 calculation
// \deprecated(2017-07) - use reset() method
void rewind()
{
sha1().clear();
}
};
......