diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index c322c7856faae1accc1c36db8790131b1eb3e5c5..cbaf373a44fa22bb47da862c4460d8a0424f3533 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -226,7 +226,7 @@ label findLower ( const ListType&, typename ListType::const_reference, - const label stary, + const label start, const BinaryOp& bop ); @@ -263,6 +263,15 @@ public: }; +//- Helper class for list to append unique elelements of y onto the end of x +template<class T> +class ListUniqueEqOp +{ +public: + void operator()(List<T>& x, const List<T>& y) const; +}; + + //- Reverse a list. First element becomes last element etc. template<class ListType> ListType reverseList(const ListType& list); diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index 29ea65055121aedf96dc1ac262601134c97e6953..7aabfd796454dba1801db3fe96988e1f87c15957 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -742,6 +742,29 @@ void Foam::ListAppendEqOp<T>::operator()(List<T>& x, const List<T>& y) const } +template<class T> +void Foam::ListUniqueEqOp<T>::operator()(List<T>& x, const List<T>& y) const +{ + if (y.size()) + { + if (x.size()) + { + forAll(y, i) + { + if (findIndex(x, y[i]) == -1) + { + x.append(y[i]); + } + } + } + else + { + x = y; + } + } +} + + template<class ListType> ListType Foam::reverseList(const ListType& list) { diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index 815c9aafcdb6cafd6a7dabc287a95fdb0d54784a..ba72bc8871301d03ff8c96984621874651fa6526 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -101,7 +101,7 @@ inline void Foam::UList<T>::checkIndex(const label i) const if (!size_) { FatalErrorIn("UList<T>::checkIndex(const label)") - << "attempt to access element from zero sized list" + << "attempt to access element " << i << " from zero sized list" << abort(FatalError); } else if (i<0 || i>=size_) diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C index cc54117f8b9e3e3614a126bb64cf47afd7dc9cc9..0d1a2fe63f02b9a18781ef8f2392695c5becff5a 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,6 +43,30 @@ Foam::UPtrList<T>::UPtrList(const label s) {} +template<class T> +Foam::UPtrList<T>::UPtrList(UList<T>& lst) +: + ptrs_(lst.size()) +{ + forAll(lst, i) + { + ptrs_[i] = &lst[i]; + } +} + + +template<class T> +Foam::UPtrList<T>::UPtrList(PtrList<T>& lst) +: + ptrs_(lst.size()) +{ + forAll(lst, i) + { + ptrs_[i] = &lst[i]; + } +} + + template<class T> Foam::UPtrList<T>::UPtrList(const Xfer<UPtrList<T> >& lst) { diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H index cdf32f630ae7b78210a4fa54398801843f8e49b2..4df5a8262732785fa0461eb733c55f29e3f03898 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,6 +42,7 @@ SourceFiles #define UPtrList_H #include "List.H" +#include "PtrList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -109,6 +110,12 @@ public: //- Construct with size specified. explicit UPtrList(const label); + //- Construct from UList + explicit UPtrList(UList<T>&); + + //- Construct from PtrList + explicit UPtrList(PtrList<T>&); + //- Construct by transferring the parameter contents UPtrList(const Xfer<UPtrList<T> >&); diff --git a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C index a7ada172d4f46ca4c3b4da382113428da0641aad..e723e6ad5e1f2aaba5f60a09658f7375dd7c1665 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C +++ b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,6 +58,23 @@ void Foam::CompactIOList<T, BaseType>::readFromStream() } +template<class T, class BaseType> +bool Foam::CompactIOList<T, BaseType>::overflows() const +{ + label size = 0; + forAll(*this, i) + { + label oldSize = size; + size += this->operator[](i).size(); + if (size < oldSize) + { + return true; + } + } + return false; +} + + // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // template<class T, class BaseType> @@ -178,6 +195,29 @@ bool Foam::CompactIOList<T, BaseType>::writeObject return good; } + else if (overflows()) + { + WarningIn + ( + "CompactIOList<T, BaseType>::writeObject" + "(IOstream::streamFormat, IOstream::versionNumber" + ", IOstream::compressionType) const" + ) << "Overall number of elements of CompactIOList of size " + << this->size() << " overflows the representation of a label" + << endl << " Switching to ascii writing" << endl; + + // Change type to be non-compact format type + const word oldTypeName = typeName; + + const_cast<word&>(typeName) = IOList<T>::typeName; + + bool good = regIOobject::writeObject(IOstream::ASCII, ver, cmp); + + // Change type back + const_cast<word&>(typeName) = oldTypeName; + + return good; + } else { return regIOobject::writeObject(fmt, ver, cmp); @@ -264,7 +304,22 @@ Foam::Ostream& Foam::operator<< start[0] = 0; for (label i = 1; i < start.size(); i++) { - start[i] = start[i-1]+L[i-1].size(); + label prev = start[i-1]; + start[i] = prev+L[i-1].size(); + + if (start[i] < prev) + { + FatalIOErrorIn + ( + "operator<<" + "(Ostream& os, const CompactIOList<T, BaseType>&)", + os + ) << "Overall number of elements " << start[i] + << " of CompactIOList of size " + << L.size() << " overflows the representation of a label" + << endl << "Please recompile with a larger representation" + << " for label" << exit(FatalIOError); + } } List<BaseType> elems(start[start.size()-1]); diff --git a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H index dc06092c59758ed0a941f9cf8c6ee19a69d8eda7..fafcdef52f934554cd53a8650caf26092384fbe7 100644 --- a/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H +++ b/src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -79,6 +79,9 @@ class CompactIOList //- Read according to header type void readFromStream(); + //- Has too many elements in it? + bool overflows() const; + public: //- Runtime type information diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/minData.H b/src/meshTools/regionSplit/minData.H similarity index 100% rename from src/parallel/decompose/decompositionMethods/decompositionMethod/minData.H rename to src/meshTools/regionSplit/minData.H diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/minDataI.H b/src/meshTools/regionSplit/minDataI.H similarity index 100% rename from src/parallel/decompose/decompositionMethods/decompositionMethod/minDataI.H rename to src/meshTools/regionSplit/minDataI.H