diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H index ff6e106377aff725f21da957a762a980549a0516..8e803839905de31e8726b7834182413c3c4d384d 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -79,6 +79,9 @@ public: class const_iterator; friend class const_iterator; + class const_reverse_iterator; + friend class const_reverse_iterator; + // Constructors @@ -254,6 +257,48 @@ public: }; + // STL const_reverse_iterator + + typedef typename LListBase::const_reverse_iterator + LListBase_const_reverse_iterator; + + //- An STL-conforming const_reverse_iterator + class const_reverse_iterator + : + public LListBase_const_reverse_iterator + { + + public: + + //- Construct from base const_reverse_iterator + const_reverse_iterator(LListBase_const_reverse_iterator baseIter) + : + LListBase_const_reverse_iterator(baseIter) + {} + + + // Member operators + + const T& operator*() + { + return + static_cast<const T&> + (LListBase_const_reverse_iterator::operator*()); + } + + const T& operator()() + { + return operator*(); + } + + const_reverse_iterator& operator++() + { + LListBase_const_reverse_iterator::operator++(); + return *this; + } + }; + + // STL member operators //- Equality operation on ULists of the same type. diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C index 95476fd89a7a15f71cf9bd8d6f78596cfcbec95d..4757dbb0f7f9d3f69001bba8cd38699486f8c607 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,6 +42,12 @@ Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter_ reinterpret_cast<const link*>(0) ); +Foam::DLListBase::const_reverse_iterator Foam::DLListBase::endConstRevIter_ +( + static_cast<const DLListBase&>(DLListBase()), + reinterpret_cast<const link*>(0) +); + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index 3af1b2b1bcb2059998106459585bec95ac840f24..2894931bcee5ebbed869a88aee243fb272de8874 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -100,6 +100,9 @@ public: class const_iterator; friend class const_iterator; + class const_reverse_iterator; + friend class const_reverse_iterator; + // Constructors @@ -260,6 +263,43 @@ public: inline const_iterator begin() const; inline const const_iterator& end() const; + // STL const_reverse_iterator + + //- An STL-conforming const_reverse_iterator + class const_reverse_iterator + { + // Private data + + //- Reference to the list this is an reverse_iterator for + const DLListBase& curList_; + + //- Current element + const link* curElmt_; + + public: + + //- Construct for a given DLListBase and link + inline const_reverse_iterator(const DLListBase&, const link*); + + // Member operators + + inline void operator=(const const_reverse_iterator&); + + inline bool operator==(const const_reverse_iterator&) const; + inline bool operator!=(const const_reverse_iterator&) const; + + inline const link& operator*(); + + inline const_reverse_iterator& operator++(); + inline const_reverse_iterator operator++(int); + }; + + inline const_reverse_iterator crbegin() const; + inline const const_reverse_iterator& crend() const; + + inline const_reverse_iterator rbegin() const; + inline const const_reverse_iterator& rend() const; + private: //- iterator returned by end() @@ -268,6 +308,9 @@ private: //- const_iterator returned by end() static const_iterator endConstIter_; + //- const_reverse_iterator returned by end() + static const_reverse_iterator endConstRevIter_; + }; diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H index 9e7eeacd233e29b34d6c38e1268008b552c7e028..fd33c5efacf0d9072a236dee8e0094c5ce9f57c5 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -383,4 +383,111 @@ Foam::DLListBase::end() const } +// * * * * * * * * * * STL const_reverse_iterator * * * * * * * * * * * * * // + +inline Foam::DLListBase::const_reverse_iterator::const_reverse_iterator +( + const DLListBase& s, + const link* elmt +) +: + curList_(s), + curElmt_(elmt) +{} + + +inline void Foam::DLListBase::const_reverse_iterator::operator= +( + const const_reverse_iterator& iter +) +{ + curElmt_ = iter.curElmt_; +} + + +inline bool Foam::DLListBase::const_reverse_iterator::operator== +( + const const_reverse_iterator& iter +) const +{ + return curElmt_ == iter.curElmt_; +} + + +inline bool Foam::DLListBase::const_reverse_iterator::operator!= +( + const const_reverse_iterator& iter +) const +{ + return curElmt_ != iter.curElmt_; +} + + +inline const Foam::DLListBase::link& +Foam::DLListBase::const_reverse_iterator::operator*() +{ + return *curElmt_; +} + + +inline Foam::DLListBase::const_reverse_iterator& +Foam::DLListBase::const_reverse_iterator::operator++() +{ + if (curElmt_ == curList_.first_) + { + curElmt_ = 0; + } + else + { + curElmt_ = curElmt_->prev_; + } + + return *this; +} + + +inline Foam::DLListBase::const_reverse_iterator +Foam::DLListBase::const_reverse_iterator::operator++(int) +{ + const_reverse_iterator tmp = *this; + ++*this; + return tmp; +} + + +inline Foam::DLListBase::const_reverse_iterator +Foam::DLListBase::crbegin() const +{ + if (size()) + { + return const_reverse_iterator(*this, last()); + } + else + { + return endConstRevIter_; + } +} + + +inline const Foam::DLListBase::const_reverse_iterator& +Foam::DLListBase::crend() const +{ + return endConstRevIter_; +} + + +inline Foam::DLListBase::const_reverse_iterator +Foam::DLListBase::rbegin() const +{ + return this->crbegin(); +} + + +inline const Foam::DLListBase::const_reverse_iterator& +Foam::DLListBase::rend() const +{ + return endConstRevIter_; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index c024d98389b64ee3d8b573ba119c58e3f6a0cb96..a13a24b0d466c66a03478401620311cb6249f718 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -50,7 +50,8 @@ readField } - // 1. Handle explicit patch names + // 1. Handle explicit patch names. Note that there can be only one explicit + // patch name since is key of dictionary. forAllConstIter(dictionary, dict, iter) { if (iter().isDict() && !iter().keyword().isPattern()) @@ -76,33 +77,45 @@ readField // 2. Patch-groups. (using non-wild card entries of dictionaries) // (patchnames already matched above) - // Note: in order of entries in the dictionary (first patchGroups wins) - forAllConstIter(dictionary, dict, iter) + // Note: in reverse order of entries in the dictionary (last + // patchGroups wins). This is so is consistent with dictionary wildcard + // behaviour + if (dict.size()) { - if (iter().isDict() && !iter().keyword().isPattern()) + for + ( + IDLList<entry>::const_reverse_iterator iter = dict.rbegin(); + iter != dict.rend(); + ++iter + ) { - const labelList patchIDs = bmesh_.findIndices - ( - iter().keyword(), - true // use patchGroups - ); + const entry& e = iter(); - forAll(patchIDs, i) + if (e.isDict() && !e.keyword().isPattern()) { - label patchi = patchIDs[i]; + const labelList patchIDs = bmesh_.findIndices + ( + e.keyword(), + true // use patchGroups + ); - if (!this->set(patchi)) + forAll(patchIDs, i) { - this->set - ( - patchi, - PatchField<Type>::New + label patchi = patchIDs[i]; + + if (!this->set(patchi)) + { + this->set ( - bmesh_[patchi], - field, - iter().dict() - ) - ); + patchi, + PatchField<Type>::New + ( + bmesh_[patchi], + field, + e.dict() + ) + ); + } } } }