Commit 1889ea83 authored by mattijs's avatar mattijs
Browse files

Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

parents 3cf78201 8728e835
......@@ -924,8 +924,8 @@ int main(int argc, char *argv[])
}
}
HashTable<labelList,word> cellZones;
HashTable<labelList,word> faceZones;
HashTable<labelList> cellZones;
HashTable<labelList> faceZones;
List<bool> isAPatch(patchNames.size(),true);
if (dofVertIndices.size())
......
......@@ -233,21 +233,16 @@ void Foam::vtkPVFoam::updateInfoPatches
if (meshPtr_)
{
const polyBoundaryMesh& patches = meshPtr_->boundaryMesh();
const HashTable<labelList, word>& groups = patches.groupPatchIDs();
const HashTable<labelList>& groups = patches.groupPatchIDs();
const wordList allPatchNames = patches.names();
// Add patch groups
// ~~~~~~~~~~~~~~~~
for
(
HashTable<labelList, word>::const_iterator iter = groups.begin();
iter != groups.end();
++iter
)
forAllConstIters(groups, iter)
{
const word& groupName = iter.key();
const labelList& patchIDs = iter();
const labelList& patchIDs = iter.object();
label nFaces = 0;
forAll(patchIDs, i)
......@@ -349,7 +344,7 @@ void Foam::vtkPVFoam::updateInfoPatches
// Add (non-zero) patch groups to the list of mesh parts
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HashTable<labelList, word> groups(patchEntries.size());
HashTable<labelList> groups(patchEntries.size());
forAll(patchEntries, patchi)
{
......@@ -360,7 +355,7 @@ void Foam::vtkPVFoam::updateInfoPatches
forAll(groupNames, groupI)
{
HashTable<labelList, word>::iterator iter = groups.find
HashTable<labelList>::iterator iter = groups.find
(
groupNames[groupI]
);
......@@ -375,16 +370,10 @@ void Foam::vtkPVFoam::updateInfoPatches
}
}
for
(
HashTable<labelList, word>::const_iterator iter =
groups.begin();
iter != groups.end();
++iter
)
forAllConstIters(groups, iter)
{
const word& groupName = iter.key();
const labelList& patchIDs = iter();
const labelList& patchIDs = iter.object();
label nFaces = 0;
forAll(patchIDs, i)
......
......@@ -22,7 +22,7 @@
+ Stream output
+ =<<= is always four characters after the start of the stream,
so that the =<<= symbols align, i.e.
#+begin_src c++
#+begin_src C++
Info<< ...
os << ...
#+end_src
......@@ -215,7 +215,7 @@
*** =for= and =while= Loops
#+begin_src C++
for (i = 0; i < maxI; i++)
for (i = 0; i < maxI; ++i)
{
code;
}
......@@ -226,7 +226,7 @@
(
i = 0;
i < maxI;
i++
++i
)
{
code;
......@@ -234,15 +234,22 @@
#+end_src
*not* this (no space between =for= and =(= used)
#+begin_src C++
for(i = 0; i < maxI; i++)
for(i = 0; i < maxI; ++i)
{
code;
}
#+end_src
Range-base for should have a space surrounding the ':'
#+begin_src C++
for (auto i : range)
{
code;
}
#+end_src
Note that when indexing through iterators, it is often slightly more
efficient to use the pre-increment form. Eg, =++iter= instead of =iter++=
Note that when indexing through iterators, it is often more efficient
to use the pre-increment form. Eg, =++iter= instead of =iter++=
*** =forAll=, =forAllIter=, =forAllConstIter=, /etc./ loops
*** =forAll=, =forAllIters=, =forAllConstIters=, /etc./ loops
Like =for= loops, but
#+begin_src C++
forAll(
......@@ -251,15 +258,22 @@
#+begin_src C++
forAll (
#+end_src
Using the =forAllIter= and =forAllConstIter= macros is generally
advantageous - less typing, easier to find later. However, since
they are macros, they will fail if the iterated object contains
any commas /e.g./ following will FAIL!:
In many cases, the new =forAllIters= and =forAllConstIters= macros
provide a good means of cycling through iterators (when a range-base
for doesn't apply). These use the C++11 decltype and work without
explicitly specifying the container class:
#+begin_src C++
forAllIters(myEdgeHash, iter)
#+end_src
Using the older =forAllIter= and =forAllConstIter= macros will
still be seen. However, since they are macros, they will fail if
the iterated object contains any commas /e.g./ following will FAIL!:
#+begin_src C++
forAllIter(HashTable<labelPair, edge, Hash<edge>>, foo, iter)
forAllIter(HashTable<labelPair, edge, Hash<edge>>, myEdgeHash, iter)
#+end_src
These convenience macros are also generally avoided in other
container classes and OpenFOAM primitive classes.
In certain cases, the range-based for can also be used.
*** Splitting Over Multiple Lines
***** Splitting return type and function name
......
......@@ -743,6 +743,24 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
}
const Foam::dictionary& Foam::dictionary::optionalSubDict
(
const word& keyword
) const
{
const entry* entryPtr = lookupEntryPtr(keyword, false, true);
if (entryPtr)
{
return entryPtr->dict();
}
else
{
return *this;
}
}
Foam::wordList Foam::dictionary::toc() const
{
wordList keys(size());
......
......@@ -436,6 +436,10 @@ public:
const bool mustRead = false
) const;
//- Find and return a sub-dictionary if found
// otherwise return this dictionary
const dictionary& optionalSubDict(const word& keyword) const;
//- Return the table of contents
wordList toc() const;
......
......@@ -46,10 +46,10 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
<< exit(FatalError);
}
HashTable<labelList, word>::const_iterator fnd =
HashTable<labelList>::const_iterator fnd =
pbm.groupPatchIDs().find(name());
if (fnd == pbm.groupPatchIDs().end())
if (!fnd.found())
{
if (&mesh == &thisPatch.boundaryMesh().mesh())
{
......@@ -65,7 +65,7 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID
}
// Mesh has patch group
const labelList& patchIDs = fnd();
const labelList& patchIDs = fnd.object();
if (&mesh == &thisPatch.boundaryMesh().mesh())
{
......
......@@ -32,6 +32,7 @@ License
#include "lduSchedule.H"
#include "globalMeshData.H"
#include "stringListOps.H"
#include "EdgeMap.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -287,7 +288,7 @@ Foam::polyBoundaryMesh::neighbourEdges() const
// From mesh edge (expressed as a point pair so as not to construct
// point addressing) to patch + relative edge index.
HashTable<labelPair, edge, Hash<edge>> pointsToEdge(nEdgePairs);
EdgeMap<labelPair> pointsToEdge(nEdgePairs);
forAll(*this, patchi)
{
......@@ -308,10 +309,9 @@ Foam::polyBoundaryMesh::neighbourEdges() const
// Edge in mesh points.
edge meshEdge(pp.meshPoints()[e[0]], pp.meshPoints()[e[1]]);
HashTable<labelPair, edge, Hash<edge>>::iterator fnd =
pointsToEdge.find(meshEdge);
EdgeMap<labelPair>::iterator fnd = pointsToEdge.find(meshEdge);
if (fnd == pointsToEdge.end())
if (!fnd.found())
{
// First occurrence of mesh edge. Store patch and my
// local index.
......@@ -328,7 +328,7 @@ Foam::polyBoundaryMesh::neighbourEdges() const
else
{
// Second occurrence. Store.
const labelPair& edgeInfo = fnd();
const labelPair& edgeInfo = fnd.object();
neighbourEdges[patchi][edgei - pp.nInternalEdges()] =
edgeInfo;
......@@ -413,13 +413,13 @@ const Foam::labelList& Foam::polyBoundaryMesh::patchID() const
}
const Foam::HashTable<Foam::labelList, Foam::word>&
const Foam::HashTable<Foam::labelList>&
Foam::polyBoundaryMesh::groupPatchIDs() const
{
if (!groupPatchIDsPtr_.valid())
{
groupPatchIDsPtr_.reset(new HashTable<labelList, word>(10));
HashTable<labelList, word>& groupPatchIDs = groupPatchIDsPtr_();
groupPatchIDsPtr_.reset(new HashTable<labelList>(10));
HashTable<labelList>& groupPatchIDs = groupPatchIDsPtr_();
const polyBoundaryMesh& bm = *this;
......@@ -431,7 +431,7 @@ Foam::polyBoundaryMesh::groupPatchIDs() const
{
const word& name = groups[i];
HashTable<labelList, word>::iterator iter = groupPatchIDs.find
HashTable<labelList>::iterator iter = groupPatchIDs.find
(
name
);
......@@ -612,10 +612,10 @@ Foam::labelList Foam::polyBoundaryMesh::findIndices
if (usePatchGroups && groupPatchIDs().size())
{
const HashTable<labelList, word>::const_iterator iter =
const HashTable<labelList>::const_iterator iter =
groupPatchIDs().find(key);
if (iter != groupPatchIDs().end())
if (iter.found())
{
labelHashSet indexSet(indices);
......@@ -815,14 +815,8 @@ void Foam::polyBoundaryMesh::matchGroups
// Current set of unmatched patches
nonGroupPatches = labelHashSet(patchIDs);
const HashTable<labelList, word>& groupPatchIDs = this->groupPatchIDs();
for
(
HashTable<labelList,word>::const_iterator iter =
groupPatchIDs.begin();
iter != groupPatchIDs.end();
++iter
)
const HashTable<labelList>& groupPatchIDs = this->groupPatchIDs();
forAllConstIters(groupPatchIDs, iter)
{
// Store currently unmatched patches so we can restore
labelHashSet oldNonGroupPatches(nonGroupPatches);
......
......@@ -70,7 +70,7 @@ class polyBoundaryMesh
mutable autoPtr<labelList> patchIDPtr_;
mutable autoPtr<HashTable<labelList, word>> groupPatchIDsPtr_;
mutable autoPtr<HashTable<labelList>> groupPatchIDsPtr_;
//- Edges of neighbouring patches
mutable autoPtr<List<labelPairList>> neighbourEdgesPtr_;
......@@ -183,8 +183,8 @@ public:
//- Per boundary face label the patch index
const labelList& patchID() const;
//- Per patch group the patch indices
const HashTable<labelList, word>& groupPatchIDs() const;
//- The patch indices per patch group
const HashTable<labelList>& groupPatchIDs() const;
//- Set/add group with patches
void setGroup(const word& groupName, const labelList& patchIDs);
......
......@@ -62,7 +62,7 @@ class hashedWordList
// Private data
//- Hash of words/indices
mutable HashTable<label,word> indices_;
mutable HashTable<label> indices_;
// Private Member Functions
......@@ -141,7 +141,7 @@ public:
inline bool contains(const word& name) const;
//- Return the hash of words/indices for inspection
inline const HashTable<label,word>& lookup() const;
inline const HashTable<label>& lookup() const;
//- Transfer the contents of the argument List into this list
// and annul the argument list,
......
......@@ -134,7 +134,7 @@ inline void Foam::hashedWordList::append
}
inline const Foam::HashTable<Foam::label,Foam::word>&
inline const Foam::HashTable<Foam::label>&
Foam::hashedWordList::lookup() const
{
return indices_;
......
......@@ -869,16 +869,9 @@ void Foam::boundaryCutter::updateMesh(const mapPolyMesh& morphMap)
{
// Create copy since we're deleting entries
HashTable<labelList, edge, Hash<edge>>
newEdgeAddedPoints(edgeAddedPoints_.size());
EdgeMap<labelList> newEdgeAddedPoints(edgeAddedPoints_.size());
for
(
HashTable<labelList, edge, Hash<edge>>::const_iterator iter =
edgeAddedPoints_.begin();
iter != edgeAddedPoints_.end();
++iter
)
forAllConstIters(edgeAddedPoints_, iter)
{
const edge& e = iter.key();
......@@ -888,7 +881,7 @@ void Foam::boundaryCutter::updateMesh(const mapPolyMesh& morphMap)
if (newStart >= 0 && newEnd >= 0)
{
const labelList& addedPoints = iter();
const labelList& addedPoints = iter.object();
labelList newAddedPoints(addedPoints.size());
label newI = 0;
......
......@@ -44,7 +44,7 @@ SourceFiles
#include "Map.H"
#include "labelList.H"
#include "edge.H"
#include "EdgeMap.H"
#include "typeInfo.H"
#include "labelPair.H"
......@@ -71,7 +71,7 @@ class boundaryCutter
const polyMesh& mesh_;
//- Per edge sorted (start to end) list of points added.
HashTable<labelList, edge, Hash<edge>> edgeAddedPoints_;
EdgeMap<labelList> edgeAddedPoints_;
//- Per face the mid point added.
Map<label> faceAddedPoint_;
......@@ -159,8 +159,7 @@ public:
// Access
//- Per edge a sorted list (start to end) of added points.
const HashTable<labelList, edge, Hash<edge>>& edgeAddedPoints()
const
const EdgeMap<labelList>& edgeAddedPoints() const
{
return edgeAddedPoints_;
}
......
......@@ -479,13 +479,13 @@ Foam::face Foam::meshCutAndRemove::addEdgeCutsToFace(const label facei) const
// Check if edge has been cut.
label fp1 = f.fcIndex(fp);
HashTable<label, edge, Hash<edge>>::const_iterator fnd =
EdgeMap<label>::const_iterator fnd =
addedPoints_.find(edge(f[fp], f[fp1]));
if (fnd != addedPoints_.end())
if (fnd.found())
{
// edge has been cut. Introduce new vertex.
newFace[newFp++] = fnd();
newFace[newFp++] = fnd.object();
}
}
......@@ -541,12 +541,12 @@ Foam::face Foam::meshCutAndRemove::loopToFace
if (edgeI != -1)
{
// Existing edge. Insert split-edge point if any.
HashTable<label, edge, Hash<edge>>::const_iterator fnd =
EdgeMap<label>::const_iterator fnd =
addedPoints_.find(mesh().edges()[edgeI]);
if (fnd != addedPoints_.end())
if (fnd.found())
{
newFace[newFacei++] = fnd();
newFace[newFacei++] = fnd.object();
}
}
}
......@@ -1302,24 +1302,17 @@ void Foam::meshCutAndRemove::updateMesh(const mapPolyMesh& map)
}
{
HashTable<label, edge, Hash<edge>> newAddedPoints(addedPoints_.size());
EdgeMap<label> newAddedPoints(addedPoints_.size());
for
(
HashTable<label, edge, Hash<edge>>::const_iterator iter =
addedPoints_.begin();
iter != addedPoints_.end();
++iter
)
forAllConstIters(addedPoints_, iter)
{
const edge& e = iter.key();
const label addedPointi = iter.object();
label newStart = map.reversePointMap()[e.start()];
label newEnd = map.reversePointMap()[e.end()];
label addedPointi = iter();
label newAddedPointi = map.reversePointMap()[addedPointi];
if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointi >= 0))
......
......@@ -40,6 +40,7 @@ SourceFiles
#include "labelList.H"
#include "typeInfo.H"
#include "Map.H"
#include "EdgeMap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -70,7 +71,7 @@ class meshCutAndRemove
//- Points added in last setRefinement. Per split edge label of added
// point
HashTable<label, edge, Hash<edge>> addedPoints_;
EdgeMap<label> addedPoints_;
// Private Static Functions
......@@ -225,7 +226,7 @@ public:
//- Points added. Per split edge label of added point.
// (note: fairly useless across topology changes since one of the
// points of the edge will probably disappear)
const HashTable<label, edge, Hash<edge>>& addedPoints() const
const EdgeMap<label>& addedPoints() const
{
return addedPoints_;
}
......
......@@ -424,13 +424,13 @@ Foam::face Foam::meshCutter::addEdgeCutsToFace(const label facei) const
// Check if edge has been cut.
label fp1 = f.fcIndex(fp);
HashTable<label, edge, Hash<edge>>::const_iterator fnd =
EdgeMap<label>::const_iterator fnd =
addedPoints_.find(edge(f[fp], f[fp1]));
if (fnd != addedPoints_.end())
if (fnd.found())
{
// edge has been cut. Introduce new vertex.
newFace[newFp++] = fnd();
newFace[newFp++] = fnd.object();
}
}
......@@ -483,12 +483,12 @@ Foam::face Foam::meshCutter::loopToFace
if (edgeI != -1)
{
// Existing edge. Insert split-edge point if any.
HashTable<label, edge, Hash<edge>>::const_iterator fnd =
EdgeMap<label>::const_iterator fnd =
addedPoints_.find(mesh().edges()[edgeI]);
if (fnd != addedPoints_.end())
if (fnd.found())
{
newFace[newFacei++] = fnd();
newFace[newFacei++] = fnd.object();
}
}
}
......@@ -1043,24 +1043,17 @@ void Foam::meshCutter::updateMesh(const mapPolyMesh& morphMap)
}
{
HashTable<label, edge, Hash<edge>> newAddedPoints(addedPoints_.size());
EdgeMap<label> newAddedPoints(addedPoints_.size());
for
(
HashTable<label, edge, Hash<edge>>::const_iterator iter =
addedPoints_.begin();
iter != addedPoints_.end();
++iter
)
forAllConstIters(addedPoints_, iter)
{
const edge& e = iter.key();
const label addedPointi = iter.object();
label newStart = morphMap.reversePointMap()[e.start()];
label newEnd = morphMap.reversePointMap()[e.end()];
label addedPointi = iter();
label newAddedPointi = morphMap.reversePointMap()[addedPointi];
if ((newStart >= 0) && (newEnd >= 0) && (newAddedPointi >= 0))
......
......@@ -115,6 +115,7 @@ SourceFiles
#include "labelList.H"
#include "typeInfo.H"
#include "Map.H"
#include "EdgeMap.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -148,7 +149,7 @@ class meshCutter
//- Points added in last setRefinement. Per split edge label of added
// point
HashTable<label, edge, Hash<edge>> addedPoints_;
EdgeMap<label> addedPoints_;
// Private Static Functions
......@@ -307,7 +308,7 @@ public:
}
//- Points added. Per split edge label of added point
const HashTable<label, edge, Hash<edge>>& addedPoints() const
const EdgeMap<label>& addedPoints() const
{
return addedPoints_;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment