ENH: for-range, forAllIters() ... in OpenFOAM/

- reduced clutter when iterating over containers
This commit is contained in:
Mark Olesen
2019-01-07 09:20:51 +01:00
committed by Andrew Heather
parent a43eb01b7e
commit 5f42b5df9f
33 changed files with 316 additions and 452 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -32,12 +32,7 @@ License
template<class IDLListType, class T>
void Foam::DictionaryBase<IDLListType, T>::addEntries()
{
for
(
typename IDLListType::iterator iter = this->begin();
iter != this->end();
++iter
)
for (auto iter = this->begin(); iter != this->end(); ++iter)
{
this->hashedTs_.insert((*iter).keyword(), &(*iter));
}
@ -103,41 +98,37 @@ const T* Foam::DictionaryBase<IDLListType, T>::lookupPtr
const word& keyword
) const
{
typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword);
const auto iter = hashedTs_.cfind(keyword);
if (iter != hashedTs_.end())
if (iter.found())
{
return *iter;
}
else
{
return nullptr;
}
return nullptr;
}
template<class IDLListType, class T>
T* Foam::DictionaryBase<IDLListType, T>::lookupPtr(const word& keyword)
{
typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
auto iter = hashedTs_.find(keyword);
if (iter != hashedTs_.end())
if (iter.found())
{
return *iter;
}
else
{
return nullptr;
}
return nullptr;
}
template<class IDLListType, class T>
const T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword) const
{
typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword);
const auto iter = hashedTs_.cfind(keyword);
if (iter == hashedTs_.end())
if (!iter.found())
{
FatalErrorInFunction
<< "'" << keyword << "' not found"
@ -151,9 +142,9 @@ const T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword) const
template<class IDLListType, class T>
T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword)
{
typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
auto iter = hashedTs_.find(keyword);
if (iter == hashedTs_.end())
if (!iter.found())
{
FatalErrorInFunction
<< "'" << keyword << "' not found"
@ -170,12 +161,7 @@ Foam::wordList Foam::DictionaryBase<IDLListType, T>::toc() const
wordList keywords(this->size());
label i = 0;
for
(
typename IDLListType::const_iterator iter = this->begin();
iter != this->end();
++iter
)
for (auto iter = this->cbegin(); iter != this->cend(); ++iter)
{
keywords[i++] = iter().keyword();
}
@ -223,18 +209,16 @@ void Foam::DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr)
template<class IDLListType, class T>
T* Foam::DictionaryBase<IDLListType, T>::remove(const word& keyword)
{
typename HashTable<T*>::iterator iter = hashedTs_.find(keyword);
auto iter = hashedTs_.find(keyword);
if (iter != hashedTs_.end())
if (iter.found())
{
T* tPtr = IDLListType::remove(iter());
T* ptr = IDLListType::remove(iter());
hashedTs_.erase(iter);
return tPtr;
}
else
{
return nullptr;
return ptr;
}
return nullptr;
}
@ -265,7 +249,6 @@ void Foam::DictionaryBase<IDLListType, T>::operator=
const DictionaryBase<IDLListType, T>& dict
)
{
// Check for assignment to self
if (this == &dict)
{
FatalErrorInFunction

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
@ -42,7 +42,7 @@ Foam::CallbackRegistry<CallbackType>::CallbackRegistry()
template<class CallbackType>
Foam::CallbackRegistry<CallbackType>::~CallbackRegistry()
{
forAllIter(typename CallbackRegistry<CallbackType>, *this, iter)
forAllIters(*this, iter)
{
iter().Callback<CallbackType>::checkOut();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -290,7 +290,7 @@ void Foam::Time::readDict()
IStringStream dummyIs("");
forAllConstIter(simpleObjectRegistry, objs, iter)
forAllConstIters(objs, iter)
{
const List<simpleRegIOobject*>& objects = *iter;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2012 OpenFOAM Foundation
@ -49,7 +49,7 @@ void MapDimensionedFields(const MeshMapper& mapper)
TableType fields(mapper.thisDb().template lookupClass<FieldType>(true));
forAllConstIter(typename TableType, fields, fieldIter)
forAllConstIters(fields, fieldIter)
{
FieldType& field = const_cast<FieldType&>(*fieldIter());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -87,7 +87,7 @@ void MapGeometricFields
// old-time-level field is mapped before the field itself, sizes
// will not match.
forAllConstIter(typename HashTable<const FieldType*>, fields, fieldIter)
forAllConstIters(fields, fieldIter)
{
FieldType& field = const_cast<FieldType&>(*fieldIter());
@ -99,7 +99,7 @@ void MapGeometricFields
}
}
forAllConstIter(typename HashTable<const FieldType*>, fields, fieldIter)
forAllConstIters(fields, fieldIter)
{
FieldType& field = const_cast<FieldType&>(*fieldIter());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
@ -51,7 +51,7 @@ inline void mapClouds(const objectRegistry& db, const mapPolyMesh& mapper)
{
HashTable<const cloud*> clouds(db.lookupClass<cloud>());
forAllIter(HashTable<const cloud*>, clouds, iter)
forAllIters(clouds, iter)
{
cloud& c = const_cast<cloud&>(*iter());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2017-2018 OpenFOAM Foundation
@ -261,7 +261,7 @@ void Foam::OFstreamCollator::waitForBufferSpace(const off_t wantedSize) const
{
std::lock_guard<std::mutex> guard(mutex_);
forAllConstIter(FIFOStack<writeData*>, objects_, iter)
forAllConstIters(objects_, iter)
{
totalSize += iter()->size();
}

View File

@ -258,12 +258,11 @@ Foam::fileOperation::lookupAndCacheProcessorsPath
{
const fileName procPath(path/pDir);
HashTable<dirIndexList>::const_iterator iter =
procsDirs_.find(procPath);
const auto iter = procsDirs_.cfind(procPath);
if (iter != procsDirs_.end())
if (iter.found())
{
return iter();
return iter.val();
}
// Read all directories to see any beginning with processor

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2017-2018 OpenFOAM Foundation
@ -254,14 +254,9 @@ Foam::fileOperations::masterUncollatedFileOperation::filePathInfo
// Check for approximately same time. E.g. if time = 1e-2 and
// directory is 0.01 (due to different time formats)
HashPtrTable<instantList>::const_iterator pathFnd
(
times_.find
(
io.time().path()
)
);
if (search && (pathFnd != times_.end()))
const auto pathFnd = times_.cfind(io.time().path());
if (search && pathFnd.found())
{
newInstancePath = findInstancePath
(
@ -2307,8 +2302,8 @@ Foam::instantList Foam::fileOperations::masterUncollatedFileOperation::findTimes
const word& constantName
) const
{
HashPtrTable<instantList>::const_iterator iter = times_.find(directory);
if (iter != times_.end())
const auto iter = times_.cfind(directory);
if (iter.found())
{
if (debug)
{
@ -2358,8 +2353,8 @@ void Foam::fileOperations::masterUncollatedFileOperation::setTime
return;
}
HashPtrTable<instantList>::const_iterator iter = times_.find(tm.path());
if (iter != times_.end())
const auto iter = times_.cfind(tm.path());
if (iter.found())
{
instantList& times = *iter();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
@ -197,7 +197,7 @@ void Foam::graph::setXRange(const scalar x0, const scalar x1)
scalarField xNew(SubField<scalar>(x_, nX, i0));
x_.transfer(xNew);
forAllIter(HashPtrTable<curve>, *this, iter)
forAllIters(*this, iter)
{
curve* c = iter();
scalarField cNew(SubField<scalar>(*c, nX, i0));
@ -254,7 +254,7 @@ void Foam::graph::writeTable(Ostream& os) const
{
os << setw(10) << x_[xi];
forAllConstIter(graph, *this, iter)
forAllConstIters(*this, iter)
{
os << token::SPACE << setw(10) << (*iter())[xi];
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2012 OpenFOAM Foundation
@ -53,7 +53,7 @@ void Foam::gnuplotGraph::write(const graph& g, Ostream& os) const
bool firstField = true;
forAllConstIter(graph, g, iter)
forAllConstIters(g, iter)
{
if (!firstField)
{
@ -66,7 +66,7 @@ void Foam::gnuplotGraph::write(const graph& g, Ostream& os) const
os << "; pause -1" << endl;
forAllConstIter(graph, g, iter)
forAllConstIters(g, iter)
{
os << endl;
writeXY(g.x(), *iter(), os);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -49,7 +49,7 @@ void Foam::jplotGraph::write(const graph& g, Ostream& os) const
label fieldi = 0;
forAllConstIter(graph, g, iter)
forAllConstIters(g, iter)
{
os << "# column " << fieldi + 2 << ": " << (*iter()).name() << endl;
fieldi++;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -50,7 +50,7 @@ void Foam::xmgrGraph::write(const graph& g, Ostream& os) const
label fieldi = 0;
forAllConstIter(graph, g, iter)
forAllConstIters(g, iter)
{
os << "@s" << fieldi << " legend "
<< iter()->name() << nl

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -682,23 +682,23 @@ void Foam::GAMGAgglomeration::calculateRegionMaster
forAll(procAgglomMap, proci)
{
label coarseI = procAgglomMap[proci];
const label coarsei = procAgglomMap[proci];
Map<label>::iterator fnd = agglomToMaster.find(coarseI);
if (fnd == agglomToMaster.end())
auto iter = agglomToMaster.find(coarsei);
if (iter.found())
{
agglomToMaster.insert(coarseI, proci);
iter.val() = min(iter.val(), proci);
}
else
{
fnd() = min(fnd(), proci);
agglomToMaster.insert(coarsei, proci);
}
}
masterProcs.setSize(agglomToMaster.size());
forAllConstIter(Map<label>, agglomToMaster, iter)
forAllConstIters(agglomToMaster, iter)
{
masterProcs[iter.key()] = iter();
masterProcs[iter.key()] = iter.val();
}
@ -709,6 +709,7 @@ void Foam::GAMGAgglomeration::calculateRegionMaster
// Get all processors agglomerating to the same coarse
// processor
agglomProcIDs = findIndices(procAgglomMap, myAgglom);
// Make sure the master is the first element.
const label index =
agglomProcIDs.find(agglomToMaster[myAgglom]);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2016 OpenFOAM Foundation
@ -104,7 +104,7 @@ Foam::procFacesGAMGProcAgglomeration::singleCellMesh
// Add all the higher processors
nbrs.clear();
weights.clear();
forAllConstIter(Map<label>, neighbours, iter)
forAllConstIters(neighbours, iter)
{
if (iter.key() > proci)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -124,9 +124,14 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface
);
}
labelPairLookup::const_iterator fnd = cellsToCoarseFace.find(cellPair);
const auto fnd = cellsToCoarseFace.cfind(cellPair);
if (fnd == cellsToCoarseFace.end())
if (fnd.found())
{
// Already have coarse face
dynFaceRestrictAddressing.append(fnd.val());
}
else
{
// New coarse face
label coarseI = dynFaceCells.size();
@ -134,11 +139,6 @@ Foam::cyclicGAMGInterface::cyclicGAMGInterface
dynFaceCells.append(localRestrictAddressing[ffi]);
cellsToCoarseFace.insert(cellPair, coarseI);
}
else
{
// Already have coarse face
dynFaceRestrictAddressing.append(fnd());
}
}
faceCells_.transfer(dynFaceCells);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -112,9 +112,14 @@ Foam::processorGAMGInterface::processorGAMGInterface
);
}
labelPairLookup::const_iterator fnd = cellsToCoarseFace.find(cellPair);
const auto fnd = cellsToCoarseFace.cfind(cellPair);
if (fnd == cellsToCoarseFace.end())
if (fnd.found())
{
// Already have coarse face
dynFaceRestrictAddressing.append(fnd.val());
}
else
{
// New coarse face
label coarseI = dynFaceCells.size();
@ -122,11 +127,6 @@ Foam::processorGAMGInterface::processorGAMGInterface
dynFaceCells.append(localRestrictAddressing[ffi]);
cellsToCoarseFace.insert(cellPair, coarseI);
}
else
{
// Already have coarse face
dynFaceRestrictAddressing.append(fnd());
}
}
faceCells_.transfer(dynFaceCells);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -72,10 +72,8 @@ void Foam::solution::read(const dictionary& dict)
// backwards compatibility
fieldRelaxDict_.clear();
const wordList entryNames(relaxDict.toc());
forAll(entryNames, i)
for (const word& e : relaxDict.toc())
{
const word& e = entryNames[i];
scalar value = relaxDict.get<scalar>(e);
if (e.startsWith("p"))
@ -98,15 +96,12 @@ void Foam::solution::read(const dictionary& dict)
eqnRelaxDefault_ =
eqnRelaxDict_.lookupOrDefault<scalar>("default", 0.0);
if (debug)
{
Info<< "Relaxation factors:" << nl
<< "fields: " << fieldRelaxDict_ << nl
<< "equations: " << eqnRelaxDict_ << endl;
}
DebugInfo
<< "Relaxation factors:" << nl
<< "fields: " << fieldRelaxDict_ << nl
<< "equations: " << eqnRelaxDict_ << endl;
}
if (dict.found("solvers"))
{
solvers_ = dict.subDict("solvers");
@ -171,11 +166,11 @@ Foam::label Foam::solution::upgradeSolverDict
// backward compatibility:
// recast primitive entries into dictionary entries
forAllIter(dictionary, dict, iter)
for (const entry& dEntry : dict)
{
if (!iter().isDict())
if (!dEntry.isDict())
{
Istream& is = iter().stream();
Istream& is = dEntry.stream();
word name(is);
dictionary subdict;
@ -210,13 +205,13 @@ Foam::label Foam::solution::upgradeSolverDict
if (verbose && Pstream::master())
{
Info<< "// using new solver syntax:\n"
<< iter().keyword() << subdict << endl;
<< dEntry.keyword() << subdict << endl;
}
// overwrite with dictionary entry
dict.set(iter().keyword(), subdict);
dict.set(dEntry.keyword(), subdict);
nChanged++;
++nChanged;
}
}
@ -228,10 +223,8 @@ bool Foam::solution::cache(const word& name) const
{
if (caching_)
{
if (debug)
{
Info<< "Cache: find entry for " << name << endl;
}
DebugInfo
<< "Cache: find entry for " << name << endl;
return cache_.found(name);
}
@ -242,12 +235,9 @@ bool Foam::solution::cache(const word& name) const
bool Foam::solution::relaxField(const word& name) const
{
if (debug)
{
Info<< "Field relaxation factor for " << name
<< " is " << (fieldRelaxDict_.found(name) ? "set" : "unset")
<< endl;
}
DebugInfo
<< "Field relaxation factor for " << name
<< " is " << (fieldRelaxDict_.found(name) ? "set" : "unset") << endl;
return fieldRelaxDict_.found(name) || fieldRelaxDict_.found("default");
}
@ -255,10 +245,8 @@ bool Foam::solution::relaxField(const word& name) const
bool Foam::solution::relaxEquation(const word& name) const
{
if (debug)
{
Info<< "Find equation relaxation factor for " << name << endl;
}
DebugInfo
<< "Find equation relaxation factor for " << name << endl;
return eqnRelaxDict_.found(name) || eqnRelaxDict_.found("default");
}
@ -266,10 +254,8 @@ bool Foam::solution::relaxEquation(const word& name) const
Foam::scalar Foam::solution::fieldRelaxationFactor(const word& name) const
{
if (debug)
{
Info<< "Lookup variable relaxation factor for " << name << endl;
}
DebugInfo
<< "Lookup variable relaxation factor for " << name << endl;
if (fieldRelaxDict_.found(name))
{
@ -279,24 +265,20 @@ Foam::scalar Foam::solution::fieldRelaxationFactor(const word& name) const
{
return fieldRelaxDefault_;
}
else
{
FatalIOErrorInFunction(fieldRelaxDict_)
<< "Cannot find variable relaxation factor for '" << name
<< "' or a suitable default value."
<< exit(FatalIOError);
return 0;
}
FatalIOErrorInFunction(fieldRelaxDict_)
<< "Cannot find variable relaxation factor for '" << name
<< "' or a suitable default value." << nl
<< exit(FatalIOError);
return 0;
}
Foam::scalar Foam::solution::equationRelaxationFactor(const word& name) const
{
if (debug)
{
Info<< "Lookup equation relaxation factor for " << name << endl;
}
DebugInfo
<< "Lookup equation relaxation factor for " << name << endl;
if (eqnRelaxDict_.found(name))
{
@ -306,15 +288,13 @@ Foam::scalar Foam::solution::equationRelaxationFactor(const word& name) const
{
return eqnRelaxDefault_;
}
else
{
FatalIOErrorInFunction(eqnRelaxDict_)
<< "Cannot find equation relaxation factor for '" << name
<< "' or a suitable default value."
<< exit(FatalIOError);
return 0;
}
FatalIOErrorInFunction(eqnRelaxDict_)
<< "Cannot find equation relaxation factor for '" << name
<< "' or a suitable default value."
<< exit(FatalIOError);
return 0;
}
@ -331,10 +311,8 @@ const Foam::dictionary& Foam::solution::solutionDict() const
const Foam::dictionary& Foam::solution::solverDict(const word& name) const
{
if (debug)
{
Info<< "Lookup solver for " << name << endl;
}
DebugInfo
<< "Lookup solver for " << name << endl;
return solvers_.subDict(name);
}
@ -342,10 +320,8 @@ const Foam::dictionary& Foam::solution::solverDict(const word& name) const
const Foam::dictionary& Foam::solution::solver(const word& name) const
{
if (debug)
{
Info<< "Lookup solver for " << name << endl;
}
DebugInfo
<< "Lookup solver for " << name << endl;
return solvers_.subDict(name);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2015 OpenFOAM Foundation
@ -179,11 +179,11 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
label otherPatchID = -1;
forAllConstIter(HashTable<const polyMesh*>, meshSet, iter)
forAllConstIters(meshSet, iter)
{
const polyMesh& mesh = *iter();
label patchID = findOtherPatchID(mesh, thisPatch);
const label patchID = findOtherPatchID(mesh, thisPatch);
if (patchID != -1)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2017 OpenFOAM Foundation
@ -119,9 +119,9 @@ Foam::label Foam::lduPrimitiveMesh::totalSize
{
label size = 0;
forAll(meshes, i)
for (const lduPrimitiveMesh& msh : meshes)
{
size += meshes[i].lduAddr().size();
size += msh.lduAddr().size();
}
return size;
}
@ -437,21 +437,10 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
nCoupledFaces[procMeshI] += ldui.faceCells().size();
}
EdgeMap<labelPairList>::iterator iter =
mergedMap.find(procEdge);
if (iter != mergedMap.end())
{
iter().append(labelPair(procMeshI, intI));
}
else
{
mergedMap.insert
(
procEdge,
labelPairList(1, labelPair(procMeshI, intI))
);
}
mergedMap(procEdge).append
(
labelPair(procMeshI, intI)
);
}
else
{
@ -464,21 +453,10 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
<< endl;
}
EdgeMap<labelPairList>::iterator iter =
unmergedMap.find(procEdge);
if (iter != unmergedMap.end())
{
iter().append(labelPair(procMeshI, intI));
}
else
{
unmergedMap.insert
(
procEdge,
labelPairList(1, labelPair(procMeshI, intI))
);
}
unmergedMap(procEdge).append
(
labelPair(procMeshI, intI)
);
}
}
else
@ -490,7 +468,7 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
<< " of unhandled type " << interfaces[intI].type()
<< exit(FatalError);
nOtherInterfaces++;
++nOtherInterfaces;
}
}
}
@ -501,10 +479,10 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
if (debug)
{
Pout<< "Remaining interfaces:" << endl;
forAllConstIter(EdgeMap<labelPairList>, unmergedMap, iter)
forAllConstIters(unmergedMap, iter)
{
Pout<< " agglom procEdge:" << iter.key() << endl;
const labelPairList& elems = iter();
const labelPairList& elems = iter.val();
forAll(elems, i)
{
label procMeshI = elems[i][0];
@ -530,10 +508,10 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
if (debug)
{
Pout<< "Merged interfaces:" << endl;
forAllConstIter(EdgeMap<labelPairList>, mergedMap, iter)
forAllConstIters(mergedMap, iter)
{
Pout<< " agglom procEdge:" << iter.key() << endl;
const labelPairList& elems = iter();
const labelPairList& elems = iter.val();
forAll(elems, i)
{
@ -631,13 +609,13 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
// I am 'master' since my cell numbers will be lower
// since cells get added in procMeshI order.
label agglom0 = procAgglomMap[myP];
label agglom1 = procAgglomMap[nbrP];
const label agglom0 = procAgglomMap[myP];
const label agglom1 = procAgglomMap[nbrP];
EdgeMap<labelPairList>::const_iterator fnd =
mergedMap.find(edge(agglom0, agglom1));
const auto fnd =
mergedMap.cfind(edge(agglom0, agglom1));
if (fnd != mergedMap.end())
if (fnd.found())
{
const labelPairList& elems = fnd();
@ -796,9 +774,9 @@ Foam::lduPrimitiveMesh::lduPrimitiveMesh
label allInterfacei = 0;
forAllConstIter(EdgeMap<labelPairList>, unmergedMap, iter)
forAllConstIters(unmergedMap, iter)
{
const labelPairList& elems = iter();
const labelPairList& elems = iter.val();
// Sort processors in increasing order so both sides walk through in
// same order.

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -55,16 +55,14 @@ Foam::cellMatcher::cellMatcher
cellModelName_(cellModelName),
cellModelPtr_(nullptr)
{
forAll(localFaces_, facei)
for (face& f : localFaces_)
{
face& f = localFaces_[facei];
f.setSize(maxVertPerFace);
}
forAll(pointFaceIndex_, verti)
for (labelList& faceIndices : pointFaceIndex_)
{
pointFaceIndex_[verti].setSize(facePerCell);
faceIndices.setSize(facePerCell);
}
}
@ -94,10 +92,15 @@ Foam::label Foam::cellMatcher::calcLocalFaces
forAll(f, localVertI)
{
label vertI = f[localVertI];
const label vertI = f[localVertI];
Map<label>::iterator iter = localPoint_.find(vertI);
if (iter == localPoint_.end())
const auto iter = localPoint_.cfind(vertI);
if (iter.found())
{
// Reuse local vertex number.
localFace[localVertI] = iter.val();
}
else
{
// Not found. Assign local vertex number.
@ -111,11 +114,6 @@ Foam::label Foam::cellMatcher::calcLocalFaces
localPoint_.insert(vertI, newVertI);
newVertI++;
}
else
{
// Reuse local vertex number.
localFace[localVertI] = *iter;
}
}
// Create face from localvertex labels
@ -123,10 +121,9 @@ Foam::label Foam::cellMatcher::calcLocalFaces
}
// Create local to global vertex mapping
forAllConstIter(Map<label>, localPoint_, iter)
forAllConstIters(localPoint_, iter)
{
const label fp = iter();
pointMap_[fp] = iter.key();
pointMap_[iter.val()] = iter.key();
}
////debug
@ -188,10 +185,8 @@ void Foam::cellMatcher::calcEdgeAddressing(const label numVert)
void Foam::cellMatcher::calcPointFaceIndex()
{
// Fill pointFaceIndex_ with -1
forAll(pointFaceIndex_, i)
for (labelList& faceIndices : pointFaceIndex_)
{
labelList& faceIndices = pointFaceIndex_[i];
faceIndices = -1;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -89,10 +89,8 @@ void Foam::globalMeshData::initProcAddr()
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
// Send indices of my processor patches to my neighbours
forAll(processorPatches_, i)
for (const label patchi : processorPatches_)
{
label patchi = processorPatches_[i];
UOPstream toNeighbour
(
refCast<const processorPolyPatch>
@ -107,10 +105,8 @@ void Foam::globalMeshData::initProcAddr()
pBufs.finishedSends();
forAll(processorPatches_, i)
for (const label patchi : processorPatches_)
{
label patchi = processorPatches_[i];
UIPstream fromNeighbour
(
refCast<const processorPolyPatch>
@ -254,13 +250,22 @@ void Foam::globalMeshData::countSharedEdges
)
{
// Count occurrences of procSharedEdges in global shared edges table.
forAllConstIter(EdgeMap<labelList>, procSharedEdges, iter)
forAllConstIters(procSharedEdges, iter)
{
const edge& e = iter.key();
EdgeMap<label>::iterator globalFnd = globalShared.find(e);
auto globalFnd = globalShared.find(e);
if (globalFnd == globalShared.end())
if (globalFnd.found())
{
if (globalFnd() == -1)
{
// Second time occurence of this edge.
// Assign proper edge label.
globalFnd() = sharedEdgeI++;
}
}
else
{
// First time occurrence of this edge. Check how many we are adding.
if (iter().size() == 1)
@ -275,15 +280,6 @@ void Foam::globalMeshData::countSharedEdges
globalShared.insert(e, sharedEdgeI++);
}
}
else
{
if (globalFnd() == -1)
{
// Second time occurence of this edge. Assign proper
// edge label.
globalFnd() = sharedEdgeI++;
}
}
}
}
@ -329,13 +325,13 @@ void Foam::globalMeshData::calcSharedEdges() const
{
const edge& e = edges[edgeI];
Map<label>::const_iterator e0Fnd = meshToShared.find(e[0]);
const auto e0Fnd = meshToShared.cfind(e[0]);
if (e0Fnd != meshToShared.end())
if (e0Fnd.found())
{
Map<label>::const_iterator e1Fnd = meshToShared.find(e[1]);
const auto e1Fnd = meshToShared.cfind(e[1]);
if (e1Fnd != meshToShared.end())
if (e1Fnd.found())
{
// Found edge which uses shared points. Probably shared.
@ -347,10 +343,9 @@ void Foam::globalMeshData::calcSharedEdges() const
sharedPtAddr[e1Fnd()]
);
EdgeMap<labelList>::iterator iter =
localShared.find(sharedEdge);
auto iter = localShared.find(sharedEdge);
if (iter == localShared.end())
if (!iter.found())
{
// First occurrence of this point combination. Store.
localShared.insert(sharedEdge, labelList(1, edgeI));
@ -360,7 +355,7 @@ void Foam::globalMeshData::calcSharedEdges() const
// Add this edge to list of edge labels.
labelList& edgeLabels = iter();
label sz = edgeLabels.size();
const label sz = edgeLabels.size();
edgeLabels.setSize(sz+1);
edgeLabels[sz] = edgeI;
}
@ -425,7 +420,7 @@ void Foam::globalMeshData::calcSharedEdges() const
globalShared.clear();
forAllConstIter(EdgeMap<label>, oldSharedEdges, iter)
forAllConstIters(oldSharedEdges, iter)
{
if (iter() != -1)
{
@ -487,22 +482,22 @@ void Foam::globalMeshData::calcSharedEdges() const
DynamicList<label> dynSharedEdgeLabels(globalShared.size());
DynamicList<label> dynSharedEdgeAddr(globalShared.size());
forAllConstIter(EdgeMap<labelList>, localShared, iter)
forAllConstIters(localShared, iter)
{
const edge& e = iter.key();
EdgeMap<label>::const_iterator edgeFnd = globalShared.find(e);
const auto edgeFnd = globalShared.cfind(e);
if (edgeFnd != globalShared.end())
if (edgeFnd.found())
{
// My local edge is indeed a shared one. Go through all local edge
// labels with this point combination.
const labelList& edgeLabels = iter();
forAll(edgeLabels, i)
for (const label edgei : edgeLabels)
{
// Store label of local mesh edge
dynSharedEdgeLabels.append(edgeLabels[i]);
dynSharedEdgeLabels.append(edgei);
// Store label of shared edge
dynSharedEdgeAddr.append(edgeFnd());
@ -1238,25 +1233,18 @@ void Foam::globalMeshData::calcPointBoundaryFaces
labelList nPointFaces(coupledPatch().nPoints(), Zero);
forAll(bMesh, patchi)
for (const polyPatch& pp : bMesh)
{
const polyPatch& pp = bMesh[patchi];
if (!pp.coupled())
{
forAll(pp, i)
for (const face& f : pp)
{
const face& f = pp[i];
forAll(f, fp)
{
Map<label>::const_iterator iter = meshPointMap.find
(
f[fp]
);
if (iter != meshPointMap.end())
const auto iter = meshPointMap.cfind(f[fp]);
if (iter.found())
{
nPointFaces[iter()]++;
nPointFaces[iter.val()]++;
}
}
}
@ -1287,11 +1275,9 @@ void Foam::globalMeshData::calcPointBoundaryFaces
const face& f = pp[i];
forAll(f, fp)
{
Map<label>::const_iterator iter = meshPointMap.find
(
f[fp]
);
if (iter != meshPointMap.end())
const auto iter = meshPointMap.cfind(f[fp]);
if (iter.found())
{
label bFacei =
pp.start() + i - mesh_.nInternalFaces();
@ -1525,10 +1511,10 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
forAll(pCells, i)
{
label celli = pCells[i];
Map<label>::iterator fnd = meshCellMap.find(celli);
const label celli = pCells[i];
const auto fnd = meshCellMap.cfind(celli);
if (fnd != meshCellMap.end())
if (fnd.found())
{
bCells[i] = fnd();
}
@ -2568,9 +2554,9 @@ Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
{
label meshPointi = meshPoints[patchPointi];
Map<label>::const_iterator iter = cpp.meshPointMap().find(meshPointi);
const auto iter = cpp.meshPointMap().cfind(meshPointi);
if (iter != cpp.meshPointMap().end())
if (iter.found())
{
patchToCoupled[patchPointi] = iter();
coupledToGlobalPatch[iter()] = globalPPoints.toGlobal(patchPointi);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -48,9 +48,8 @@ Foam::label Foam::globalPoints::countPatchPoints
{
label nTotPoints = 0;
forAll(patches, patchi)
for (const polyPatch& pp : patches)
{
const polyPatch& pp = patches[patchi];
if (pp.coupled())
{
nTotPoints += pp.nPoints();
@ -279,11 +278,11 @@ bool Foam::globalPoints::mergeInfo
label infoChanged = false;
// Get the index into the procPoints list.
Map<label>::iterator iter = meshToProcPoint_.find(localPointi);
const auto iter = meshToProcPoint_.cfind(localPointi);
if (iter != meshToProcPoint_.end())
if (iter.found())
{
if (mergeInfo(nbrInfo, localPointi, procPoints_[iter()]))
if (mergeInfo(nbrInfo, localPointi, procPoints_[iter.val()]))
{
infoChanged = true;
}
@ -328,11 +327,11 @@ bool Foam::globalPoints::storeInitialInfo
label infoChanged = false;
// Get the index into the procPoints list.
Map<label>::iterator iter = meshToProcPoint_.find(localPointi);
const auto iter = meshToProcPoint_.find(localPointi);
if (iter != meshToProcPoint_.end())
if (iter.found())
{
if (mergeInfo(nbrInfo, localPointi, procPoints_[iter()]))
if (mergeInfo(nbrInfo, localPointi, procPoints_[iter.val()]))
{
infoChanged = true;
}
@ -681,10 +680,9 @@ void Foam::globalPoints::receivePatchPoints
// Do we have information on pointA?
Map<label>::iterator procPointA =
meshToProcPoint_.find(localA);
const auto procPointA = meshToProcPoint_.cfind(localA);
if (procPointA != meshToProcPoint_.end())
if (procPointA.found())
{
const labelPairList infoA = addSendTransform
(
@ -699,10 +697,9 @@ void Foam::globalPoints::receivePatchPoints
}
// Same for info on pointB
Map<label>::iterator procPointB =
meshToProcPoint_.find(localB);
const auto procPointB = meshToProcPoint_.cfind(localB);
if (procPointB != meshToProcPoint_.end())
if (procPointB.found())
{
const labelPairList infoB = addSendTransform
(
@ -968,11 +965,11 @@ void Foam::globalPoints::calculateSharedPoints
//Pout<< "**ALL** connected points:" << endl;
//forAllConstIter(Map<label>, meshToProcPoint_, iter)
//forAllConstIters(meshToProcPoint_, iter)
//{
// label localI = iter.key();
// const labelPairList& pointInfo = procPoints_[iter()];
// Pout<< "pointi:" << localI << " index:" << iter()
// const labelPairList& pointInfo = procPoints_[iter.val()];
// Pout<< "pointi:" << localI << " index:" << iter.val()
// << " coord:"
// << mesh_.points()[localToMeshPoint(patchToMeshPoint, localI)]
// << endl;
@ -992,9 +989,9 @@ void Foam::globalPoints::calculateSharedPoints
// the master the first element on all processors.
// Note: why not sort in decreasing order? Give more work to higher
// processors.
forAllConstIter(Map<label>, meshToProcPoint_, iter)
forAllConstIters(meshToProcPoint_, iter)
{
labelPairList& pointInfo = procPoints_[iter()];
labelPairList& pointInfo = procPoints_[iter.val()];
sort(pointInfo, globalIndexAndTransform::less(globalTransforms_));
}
@ -1005,9 +1002,10 @@ void Foam::globalPoints::calculateSharedPoints
pointPoints_.setSize(globalIndices_.localSize());
List<labelPairList> transformedPoints(globalIndices_.localSize());
forAllConstIter(Map<label>, meshToProcPoint_, iter)
forAllConstIters(meshToProcPoint_, iter)
{
const labelPairList& pointInfo = procPoints_[iter()];
const labelPairList& pointInfo = procPoints_[iter.val()];
if (pointInfo.size() >= 2)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -280,6 +280,7 @@ public:
fld = vt.invTransformPosition(pfld);
}
}
void operator()
(
const vectorTensorTransform& vt,
@ -287,31 +288,33 @@ public:
List<List<point>>& flds
) const
{
forAll(flds, i)
for (List<point>& fld : flds)
{
operator()(vt, forward, flds[i]);
operator()(vt, forward, fld);
}
}
//- Transform patch-based field
void operator()(const coupledPolyPatch& cpp, pointField& fld) const
{
cpp.transformPosition(fld);
}
template<template<class> class Container>
void operator()(const coupledPolyPatch& cpp, Container<point>& map)
const
{
Field<point> fld(map.size());
label i = 0;
forAllConstIter(typename Container<point>, map, iter)
forAllConstIters(map, iter)
{
fld[i++] = iter();
fld[i++] = *iter;
}
cpp.transformPosition(fld);
i = 0;
forAllIter(typename Container<point>, map, iter)
forAllIters(map, iter)
{
iter() = fld[i++];
*iter = fld[i++];
}
}
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2016, 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2015-2017 OpenFOAM Foundation
@ -293,13 +293,11 @@ void Foam::mapDistributeBase::calcCompactAddressing
// Count all (non-local) elements needed. Just for presizing map.
labelList nNonLocal(Pstream::nProcs(), Zero);
forAll(elements, i)
for (const label globalIdx : elements)
{
label globalIndex = elements[i];
if (globalIndex != -1 && !globalNumbering.isLocal(globalIndex))
if (globalIdx != -1 && !globalNumbering.isLocal(globalIdx))
{
label proci = globalNumbering.whichProcID(globalIndex);
label proci = globalNumbering.whichProcID(globalIdx);
nNonLocal[proci]++;
}
}
@ -315,14 +313,12 @@ void Foam::mapDistributeBase::calcCompactAddressing
// Collect all (non-local) elements needed.
forAll(elements, i)
for (const label globalIdx : elements)
{
label globalIndex = elements[i];
if (globalIndex != -1 && !globalNumbering.isLocal(globalIndex))
if (globalIdx != -1 && !globalNumbering.isLocal(globalIdx))
{
label proci = globalNumbering.whichProcID(globalIndex);
label index = globalNumbering.toLocal(proci, globalIndex);
label proci = globalNumbering.whichProcID(globalIdx);
label index = globalNumbering.toLocal(proci, globalIdx);
label nCompact = compactMap[proci].size();
compactMap[proci].insert(index, nCompact);
}
@ -342,17 +338,13 @@ void Foam::mapDistributeBase::calcCompactAddressing
// Count all (non-local) elements needed. Just for presizing map.
labelList nNonLocal(Pstream::nProcs(), Zero);
forAll(cellCells, cellI)
for (const labelList& cCells : cellCells)
{
const labelList& cCells = cellCells[cellI];
forAll(cCells, i)
for (const label globalIdx : cCells)
{
label globalIndex = cCells[i];
if (globalIndex != -1 && !globalNumbering.isLocal(globalIndex))
if (globalIdx != -1 && !globalNumbering.isLocal(globalIdx))
{
label proci = globalNumbering.whichProcID(globalIndex);
label proci = globalNumbering.whichProcID(globalIdx);
nNonLocal[proci]++;
}
}
@ -369,18 +361,14 @@ void Foam::mapDistributeBase::calcCompactAddressing
// Collect all (non-local) elements needed.
forAll(cellCells, cellI)
for (const labelList& cCells : cellCells)
{
const labelList& cCells = cellCells[cellI];
forAll(cCells, i)
for (const label globalIdx : cCells)
{
label globalIndex = cCells[i];
if (globalIndex != -1 && !globalNumbering.isLocal(globalIndex))
if (globalIdx != -1 && !globalNumbering.isLocal(globalIdx))
{
label proci = globalNumbering.whichProcID(globalIndex);
label index = globalNumbering.toLocal(proci, globalIndex);
label proci = globalNumbering.whichProcID(globalIdx);
label index = globalNumbering.toLocal(proci, globalIdx);
label nCompact = compactMap[proci].size();
compactMap[proci].insert(index, nCompact);
}
@ -439,9 +427,9 @@ void Foam::mapDistributeBase::exchangeAddressing
remoteElem.setSize(compactMap[proci].size());
localElem.setSize(compactMap[proci].size());
label i = 0;
forAllIter(Map<label>, compactMap[proci], iter)
forAllIters(compactMap[proci], iter)
{
const label compactI = compactStart[proci] + iter();
const label compactI = compactStart[proci] + iter.val();
remoteElem[i] = iter.key();
localElem[i] = compactI;
iter() = compactI;
@ -460,9 +448,9 @@ void Foam::mapDistributeBase::exchangeAddressing
);
// Renumber elements
forAll(elements, i)
for (label& elem : elements)
{
elements[i] = renumber(globalNumbering, compactMap, elements[i]);
elem = renumber(globalNumbering, compactMap, elem);
}
}
@ -516,9 +504,9 @@ void Foam::mapDistributeBase::exchangeAddressing
remoteElem.setSize(compactMap[proci].size());
localElem.setSize(compactMap[proci].size());
label i = 0;
forAllIter(Map<label>, compactMap[proci], iter)
forAllIters(compactMap[proci], iter)
{
const label compactI = compactStart[proci] + iter();
const label compactI = compactStart[proci] + iter.val();
remoteElem[i] = iter.key();
localElem[i] = compactI;
iter() = compactI;
@ -537,13 +525,11 @@ void Foam::mapDistributeBase::exchangeAddressing
);
// Renumber elements
forAll(cellCells, cellI)
for (labelList& cCells : cellCells)
{
labelList& cCells = cellCells[cellI];
forAll(cCells, i)
for (label& celli : cCells)
{
cCells[i] = renumber(globalNumbering, compactMap, cCells[i]);
celli = renumber(globalNumbering, compactMap, celli);
}
}
}
@ -706,8 +692,7 @@ Foam::mapDistributeBase::mapDistributeBase
//
// forAll(sorted, i)
// {
// Map<label>::iterator iter = globalMap.find(sorted[i]);
// iter() = i;
// globalMap(sorted[i]) = i;
// }
// }
//}
@ -766,8 +751,7 @@ Foam::mapDistributeBase::mapDistributeBase
//
// forAll(sorted, i)
// {
// Map<label>::iterator iter = globalMap.find(sorted[i]);
// iter() = i;
// globalMap(sorted[i]) = i;
// }
// }
//}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
@ -373,7 +373,7 @@ Foam::polyBoundaryMesh::neighbourEdges() const
// Edge in mesh points.
edge meshEdge(pp.meshPoints()[e[0]], pp.meshPoints()[e[1]]);
EdgeMap<labelPair>::iterator fnd = pointsToEdge.find(meshEdge);
auto fnd = pointsToEdge.find(meshEdge);
if (!fnd.found())
{

View File

@ -382,7 +382,7 @@ bool Foam::polyMesh::checkEdgeAlignment
if (setPtr)
{
setPtr->resize(2*edgesInError.size());
forAllConstIter(EdgeMap<label>, edgesInError, iter)
forAllConstIters(edgesInError, iter)
{
setPtr->insert(iter.key()[0]);
setPtr->insert(iter.key()[1]);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -1094,10 +1094,8 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const
// Build map from points on *this (A) to points on neighbourpatch (B)
Map<label> aToB(2*pointCouples.size());
forAll(pointCouples, i)
for (const edge& e : pointCouples)
{
const edge& e = pointCouples[i];
aToB.insert(e[0], e[1]);
}
@ -1108,18 +1106,16 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const
{
const labelList& fEdges = faceEdges()[patchFacei];
forAll(fEdges, i)
for (const label edgeI : fEdges)
{
label edgeI = fEdges[i];
const edge& e = edges()[edgeI];
// Convert edge end points to corresponding points on B side.
Map<label>::const_iterator fnd0 = aToB.find(e[0]);
if (fnd0 != aToB.end())
const auto fnd0 = aToB.cfind(e[0]);
if (fnd0.found())
{
Map<label>::const_iterator fnd1 = aToB.find(e[1]);
if (fnd1 != aToB.end())
const auto fnd1 = aToB.cfind(e[1]);
if (fnd1.found())
{
edgeMap.insert(edge(fnd0(), fnd1()), edgeI);
}
@ -1134,7 +1130,6 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const
const labelList& mp = meshPoints();
coupledEdgesPtr_ = new edgeList(edgeMap.size());
edgeList& coupledEdges = *coupledEdgesPtr_;
label coupleI = 0;
@ -1143,18 +1138,16 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const
{
const labelList& fEdges = neighbPatch.faceEdges()[patchFacei];
forAll(fEdges, i)
for (const label edgeI : fEdges)
{
label edgeI = fEdges[i];
const edge& e = neighbPatch.edges()[edgeI];
// Look up A edge from HashTable.
EdgeMap<label>::iterator iter = edgeMap.find(e);
auto iter = edgeMap.find(e);
if (iter != edgeMap.end())
if (iter.found())
{
label edgeA = iter();
const label edgeA = iter.val();
const edge& eA = edges()[edgeA];
// Store correspondence. Filter out edges on wedge axis.
@ -1202,10 +1195,8 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const
Pout<< "Writing file " << str.name() << " with centres of "
<< "coupled edges" << endl;
forAll(coupledEdges, i)
for (const edge& e : coupledEdges)
{
const edge& e = coupledEdges[i];
const point& a = edges()[e[0]].centre(localPoints());
const point& b = neighbPatch.edges()[e[1]].centre
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -56,17 +56,14 @@ void Foam::PatchTools::matchPoints
forAll(p1.meshPoints(), pointi)
{
label meshPointi = p1.meshPoints()[pointi];
const label meshPointi = p1.meshPoints()[pointi];
Map<label>::const_iterator iter = p2.meshPointMap().find
(
meshPointi
);
const auto iter = p2.meshPointMap().cfind(meshPointi);
if (iter != p2.meshPointMap().end())
if (iter.found())
{
p1PointLabels[nMatches] = pointi;
p2PointLabels[nMatches] = iter();
p2PointLabels[nMatches] = iter.val();
nMatches++;
}
}
@ -120,11 +117,11 @@ void Foam::PatchTools::matchEdges
const edge& e = p2.edges()[edgeI];
const edge meshE(p2.meshPoints()[e[0]], p2.meshPoints()[e[1]]);
EdgeMap<label>::const_iterator iter = edgeToIndex.find(meshE);
const auto iter = edgeToIndex.cfind(meshE);
if (iter != edgeToIndex.end())
if (iter.found())
{
p1EdgeLabels[nMatches] = iter();
p1EdgeLabels[nMatches] = iter.val();
p2EdgeLabels[nMatches] = edgeI;
sameOrientation.set(nMatches, (meshE[0] == iter.key()[0]));
++nMatches;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -55,8 +55,6 @@ Foam::PatchTools::pointNormals
globalData.globalTransforms();
// Combine normals. Note: do on all master points. Cannot just use
// patch points since the master point does not have to be on the
// patch!
@ -68,11 +66,12 @@ Foam::PatchTools::pointNormals
List<List<point>> pointFaceNormals(map.constructSize());
forAll(p.meshPoints(), patchPointi)
{
label meshPointi = p.meshPoints()[patchPointi];
Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointi);
if (fnd != coupledPatchMP.end())
const label meshPointi = p.meshPoints()[patchPointi];
const auto fnd = coupledPatchMP.cfind(meshPointi);
if (fnd.found())
{
label coupledPointi = fnd();
const label coupledPointi = fnd.val();
List<point>& pNormals = pointFaceNormals[coupledPointi];
const labelList& pFaces = p.pointFaces()[patchPointi];
@ -182,11 +181,12 @@ Foam::PatchTools::pointNormals
// 2. Override patch normals on coupled points
forAll(p.meshPoints(), patchPointi)
{
label meshPointi = p.meshPoints()[patchPointi];
Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointi);
if (fnd != coupledPatchMP.end())
const label meshPointi = p.meshPoints()[patchPointi];
const auto fnd = coupledPatchMP.cfind(meshPointi);
if (fnd.found())
{
label coupledPointi = fnd();
const label coupledPointi = fnd.val();
extrudeN[patchPointi] = coupledPointNormals[coupledPointi];
}
}
@ -220,12 +220,12 @@ Foam::PatchTools::edgeNormals
const labelListList& edgeFaces = p.edgeFaces();
const vectorField& faceNormals = p.faceNormals();
forAll(edgeFaces, edgeI)
forAll(edgeFaces, edgei)
{
const labelList& eFaces = edgeFaces[edgeI];
forAll(eFaces, i)
const labelList& eFaces = edgeFaces[edgei];
for (const label facei : eFaces)
{
edgeNormals[edgeI] += faceNormals[eFaces[i]];
edgeNormals[edgei] += faceNormals[facei];
}
}
edgeNormals /= mag(edgeNormals)+VSMALL;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -32,7 +32,6 @@ Description
#include "SLList.H"
#include "ListOps.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
@ -46,10 +45,8 @@ void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointEdges() const
{
if (debug)
{
InfoInFunction << "Calculating pointEdges" << endl;
}
DebugInFunction
<< "Calculating pointEdges" << endl;
if (pointEdgesPtr_)
{
@ -65,10 +62,8 @@ calcPointEdges() const
invertManyToMany(pe.size(), edges(), pe);
if (debug)
{
Info<< " Finished." << endl;
}
DebugInfo
<< " Finished." << endl;
}
@ -83,10 +78,8 @@ void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointFaces() const
{
if (debug)
{
InfoInFunction << "Calculating pointFaces" << endl;
}
DebugInFunction
<< "Calculating pointFaces" << endl;
if (pointFacesPtr_)
{
@ -105,9 +98,9 @@ calcPointFaces() const
{
const Face& curPoints = f[facei];
forAll(curPoints, pointi)
for (const label pointi : curPoints)
{
pointFcs[curPoints[pointi]].append(facei);
pointFcs[pointi].append(facei);
}
}
@ -121,16 +114,14 @@ calcPointFaces() const
pf[pointi].setSize(pointFcs[pointi].size());
label i = 0;
forAllIter(SLList<label>, pointFcs[pointi], curFacesIter)
for (const label facei : pointFcs[pointi])
{
pf[pointi][i++] = curFacesIter();
pf[pointi][i++] = facei;
}
}
if (debug)
{
Info<< " Finished." << endl;
}
DebugInfo
<< " Finished." << endl;
}

View File

@ -811,7 +811,7 @@ bool Foam::primitiveMesh::checkFaceFlatness
}
if (nWarped> 0)
if (nWarped > 0)
{
if (debug || report)
{
@ -1352,7 +1352,7 @@ bool Foam::primitiveMesh::checkDuplicateFaces
{
bool error = false;
forAllConstIter(Map<label>, nCommonPoints, iter)
forAllConstIters(nCommonPoints, iter)
{
label nbFacei = iter.key();
label nCommon = iter();
@ -1392,7 +1392,7 @@ bool Foam::primitiveMesh::checkCommonOrder
{
bool error = false;
forAllConstIter(Map<label>, nCommonPoints, iter)
forAllConstIters(nCommonPoints, iter)
{
label nbFacei = iter.key();
label nCommon = iter();
@ -1583,18 +1583,7 @@ bool Foam::primitiveMesh::checkFaceFaces
if (facei < nbFacei)
{
// Only check once for each combination of two faces.
Map<label>::iterator fnd = nCommonPoints.find(nbFacei);
if (fnd == nCommonPoints.end())
{
// First common vertex found.
nCommonPoints.insert(nbFacei, 1);
}
else
{
fnd()++;
}
++(nCommonPoints(nbFacei, 0));
}
}
}

View File

@ -142,6 +142,4 @@ const Foam::labelList& Foam::primitiveMesh::pointPoints
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //