diff --git a/applications/test/List/ListTest.C b/applications/test/List/ListTest.C index bc8901b03beacc65c399053ab5c5d49532009edf..d4834cb1db2b02bc79f4d6e8508e9f3b3361c695 100644 --- a/applications/test/List/ListTest.C +++ b/applications/test/List/ListTest.C @@ -43,31 +43,33 @@ using namespace Foam; int main(int argc, char *argv[]) { - List<vector> list(IStringStream("1 ((0 1 2))")()); - Info<< list << endl; + List<vector> list1(IStringStream("1 ((0 1 2))")()); + Info<< "list1: " << list1 << endl; List<vector> list2(IStringStream("((0 1 2) (3 4 5) (6 7 8))")()); - Info<< list2 << endl; + Info<< "list2: " << list2 << endl; + + list1.append(list2); + Info<< "list1.append(list2): " << list1 << endl; Info<< findIndex(list2, vector(3, 4, 5)) << endl; list2.setSize(10, vector(1, 2, 3)); - Info<< list2 << endl; + Info<< "list2: " << list2 << endl; List<vector> list3(list2.xfer()); Info<< "Transferred via the xfer() method" << endl; - Info<< list2 << nl - << list3 << endl; + Info<< "list2: " << list2 << nl + << "list3: " << list3 << endl; // Subset const labelList map(IStringStream("2 (0 2)")()); List<vector> subList3(list3, map); Info<< "Elements " << map << " out of " << list3 - << " : " << subList3 << endl; + << " => " << subList3 << endl; return 0; } - // ************************************************************************* // diff --git a/applications/utilities/surface/surfaceConvert/surfaceConvert.C b/applications/utilities/surface/surfaceConvert/surfaceConvert.C index 311dab28f66f01986d584df1bf96aaa237e8a645..fd7b223827334261083e944fb9d559be218c4106 100644 --- a/applications/utilities/surface/surfaceConvert/surfaceConvert.C +++ b/applications/utilities/surface/surfaceConvert/surfaceConvert.C @@ -115,15 +115,13 @@ int main(int argc, char *argv[]) } Info<< "writing " << exportName; - if (scaleFactor <= 0) + if (scaleFactor > 0) { - Info<< " without scaling" << endl; - } - else - { - Info<< " with scaling " << scaleFactor << endl; + Info<< " with scaling " << scaleFactor; surf.scalePoints(scaleFactor); } + Info<< endl; + surf.write(exportName, sortByRegion); Info<< "\nEnd\n" << endl; diff --git a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C index 3a48a5deda74c71e13ace6dea886cb5b3fa03c35..4f607e89fb15b477ddc6238805068db482c5d80a 100644 --- a/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C +++ b/applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) argList::noParallel(); argList::validArgs.append("inputFile"); argList::validArgs.append("outputFile"); - argList::validOptions.insert("clean", "scale"); + argList::validOptions.insert("clean", ""); argList::validOptions.insert("scaleIn", "scale"); argList::validOptions.insert("scaleOut", "scale"); argList::validOptions.insert("dict", "coordinateSystemsDict"); diff --git a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C index 41c8a43d6dcea882f0d6e4c3c3703d6d11509996..34d93c93ebecb6e0f51f905366c33342b365fde4 100644 --- a/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C +++ b/applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) argList::noParallel(); argList::validArgs.append("outputFile"); argList::validOptions.insert("name", "name"); - argList::validOptions.insert("clean", "scale"); + argList::validOptions.insert("clean", ""); argList::validOptions.insert("scaleIn", "scale"); argList::validOptions.insert("scaleOut", "scale"); argList::validOptions.insert("dict", "coordinateSystemsDict"); diff --git a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C index 01ef15d74e60c8bd81b08b9c8842c2aed9c75d77..0cb131e4ebefded7fb56483c137ed23f55b3fc86 100644 --- a/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C +++ b/applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) argList::noParallel(); argList::validArgs.append("inputFile"); argList::validOptions.insert("name", "name"); - argList::validOptions.insert("clean", "scale"); + argList::validOptions.insert("clean", ""); argList::validOptions.insert("scaleIn", "scale"); argList::validOptions.insert("scaleOut", "scale"); argList::validOptions.insert("dict", "coordinateSystemsDict"); diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 6d20e2b3b72af3b5ec441d8c88668f2c9158b83c..429c91f820675d4ead0d17b1827dcca15fd9fbae 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -404,6 +404,61 @@ void Foam::List<T>::clear() } +template<class T> +void Foam::List<T>::append(const UList<T>& lst) +{ + if (this == &lst) + { + FatalErrorIn + ( + "List<T>::append(const UList<T>&)" + ) << "attempted appending to self" << abort(FatalError); + } + + label nextFree = this->size_; + setSize(nextFree + lst.size()); + + forAll(lst, elemI) + { + this->operator[](nextFree++) = lst[elemI]; + } +} + + +template<class T> +void Foam::List<T>::append(const UIndirectList<T>& lst) +{ + label nextFree = this->size_; + setSize(nextFree + lst.size()); + + forAll(lst, elemI) + { + this->operator[](nextFree++) = lst[elemI]; + } +} + + +template<class T> +void Foam::List<T>::append(const SLList<T>& lst) +{ + if (lst.size()) + { + label nextFree = this->size_; + setSize(nextFree + lst.size()); + + for + ( + typename SLList<T>::const_iterator iter = lst.begin(); + iter != lst.end(); + ++iter + ) + { + this->operator[](nextFree++) = iter(); + } + } +} + + // Transfer the contents of the argument List into this List // and anull the argument list template<class T> @@ -559,12 +614,9 @@ void Foam::List<T>::operator=(const IndirectList<T>& lst) if (this->size_) this->v_ = new T[this->size_]; } - if (this->size_) + forAll(*this, i) { - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } + this->operator[](i) = lst[i]; } } @@ -581,12 +633,9 @@ void Foam::List<T>::operator=(const UIndirectList<T>& lst) if (this->size_) this->v_ = new T[this->size_]; } - if (this->size_) + forAll(*this, i) { - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } + this->operator[](i) = lst[i]; } } @@ -603,12 +652,9 @@ void Foam::List<T>::operator=(const BiIndirectList<T>& lst) if (this->size_) this->v_ = new T[this->size_]; } - if (this->size_) + forAll(*this, i) { - forAll(*this, i) - { - this->operator[](i) = lst[i]; - } + this->operator[](i) = lst[i]; } } diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 86876cff713e4bbba54302df8a51bb127370a9d0..5961ff174793741a484f7955872108c471791d7b 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -109,7 +109,7 @@ public: List(const List<T>&); //- Construct by transferring the parameter contents - List(const Xfer<List<T> >&); + List(const Xfer< List<T> >&); //- Construct as copy or re-use as specified. List(List<T>&, bool reUse); @@ -181,6 +181,15 @@ public: //- Clear the list, i.e. set size to zero. void clear(); + //- Append a List at the end of this list + void append(const UList<T>&); + + //- Append a UIndirectList at the end of this list + void append(const UIndirectList<T>&); + + //- Append a SLList at the end of this list + void append(const SLList<T>&); + //- Transfer the contents of the argument List into this List // and annull the argument list. void transfer(List<T>&); @@ -195,7 +204,7 @@ public: void transfer(SortableList<T>&); //- Transfer contents to the Xfer container - inline Xfer<List<T> > xfer(); + inline Xfer< List<T> > xfer(); //- Return subscript-checked element of UList. inline T& newElmt(const label); diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index af0f5cb5e03940d22f44d0f791650f954430e69e..1e6070e8368ad3a93d765fa112f0febe4ecb9452 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -26,7 +26,7 @@ Class Foam::PackedList Description - A Dynamically allocatable list of packed unsigned ints. + A dynamically allocatable list of packed unsigned integers. The list resizing is similar to DynamicList, thus the methods clear() and setSize() behave like their DynamicList counterparts and the methods @@ -38,7 +38,7 @@ Note In a const context, the '[]' operator simply returns the stored value, with out-of-range elements returned as zero. In a non-const context, the '[]' operator returns an iteratorBase, which - may not have a valid reference for out-of-range elements. + might not have a valid reference for out-of-range elements. The iteratorBase class handles the assignment of new values. Using the iteratorBase as a proxy allows assignment of values @@ -50,11 +50,11 @@ Note @endcode Using get() or the '[]' operator are similarly fast. Looping and reading - with an iterator is approx. 15% slower, but can be more flexible. + via an iterator is approx. 15% slower, but can be more flexible. Using the set() operator (and the '[]' operator) are marginally slower - (approx. 5%) than using an iterator, but the set() method has an - advantage that it also returns a bool if the value changed. This can be + (approx. 5%) than using an iterator, but the set() method has the + advantage of also returning a bool if the value changed. This can be useful for branching on changed values. @code @@ -65,7 +65,7 @@ Note The lazy evaluation used means that reading an out-of-range element returns zero, but does not affect the list size. Even in a non-const - context, only the assigment causes the element to be created. + context, only the assigment itself causes the element to be created. For example, @code list.resize(4); @@ -171,7 +171,7 @@ public: inline PackedList(const PackedList<nBits>&); //- Construct by transferring the parameter contents - inline PackedList(const Xfer<PackedList<nBits> >&); + inline PackedList(const Xfer< PackedList<nBits> >&); //- Construct from a list of labels PackedList(const UList<label>&); @@ -240,7 +240,6 @@ public: //- Reserve allocation space for at least this size. // Never shrinks the allocated size. - // Optionally provide an initialization value for new elements. inline void reserve(const label); //- Clear the list, i.e. set addressable size to zero. @@ -258,7 +257,7 @@ public: inline void transfer(PackedList<nBits>&); //- Transfer contents to the Xfer container - inline Xfer<PackedList<nBits> > xfer(); + inline Xfer< PackedList<nBits> > xfer(); // Member operators @@ -413,7 +412,7 @@ public: //- iterator set to the beginning of the PackedList inline iterator begin(); - //- iterator set to beyond the end of the HashTable + //- iterator set to beyond the end of the PackedList inline iterator end(); diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 8c37d28b427786e3b932ed6bccaf55c5c0fcb1ed..030b3df9ae1296ebc8d42fe69b725e89a29503d4 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -134,7 +134,7 @@ Foam::label Foam::solution::upgradeSolverDict // write out information to help people adjust to the new syntax - if (verbose) + if (verbose && Pstream::master()) { Info<< "// using new solver syntax:\n" << iter().keyword() << subdict << endl; diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C index c86f2f43ebd8d8fe37894d04543c825b2266313a..657dfbb48e629f38f435eb7cbd6d19f5fe48432b 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -64,8 +64,8 @@ tmp<volScalarField> autoCreateAlphat } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; const fvBoundaryMesh& bm = mesh.boundary(); @@ -104,7 +104,7 @@ tmp<volScalarField> autoCreateAlphat ) ); - Info<< " Writing updated " << fieldName << endl; + Info<< " Writing new " << fieldName << endl; alphat().write(); return alphat; @@ -134,8 +134,8 @@ tmp<volScalarField> autoCreateMut } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; const fvBoundaryMesh& bm = mesh.boundary(); @@ -174,7 +174,7 @@ tmp<volScalarField> autoCreateMut ) ); - Info<< " Writing updated " << fieldName << endl; + Info<< " Writing new " << fieldName << endl; mut().write(); return mut; diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index 98c750c71acc40564ea78ce2b0c8b92683280b70..91f739abfb9d6d6624bf3e0a7413dffd58a55eaa 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -26,6 +26,7 @@ License #include "backwardsCompatibilityWallFunctions.H" #include "Time.H" +#include "OSspecific.H" #include "wallPolyPatch.H" @@ -77,27 +78,35 @@ autoCreateWallFunctionField } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Upgrading " << fieldName + << " to employ run-time selectable wall functions" << endl; + + // Read existing field + IOobject ioObj + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); - // Read existing epsilon field tmp<fieldType> fieldOrig ( new fieldType ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), + ioObj, mesh ) ); + // rename file + Info<< " Backup original " << fieldName << " to " + << fieldName << ".old" << endl; + mv(ioObj.objectPath(), ioObj.objectPath() + ".old"); + + PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size()); forAll(newPatchFields, patchI) @@ -145,11 +154,6 @@ autoCreateWallFunctionField ) ); - Info<< " Writing backup of original " << fieldName << " to " - << fieldName << ".old" << endl; - fieldOrig().rename(fieldName + ".old"); - fieldOrig().write(); - Info<< " Writing updated " << fieldName << endl; fieldNew().write(); diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C index 949c33472636b63641a0ce01807d380bd9eb2879..f7b144a03b4bdce4890b2d06eaeb83a278a3b402 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -63,8 +63,8 @@ tmp<volScalarField> autoCreateNut } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Creating " << fieldName + << " to employ run-time selectable wall functions" << endl; const fvBoundaryMesh& bm = mesh.boundary(); @@ -103,7 +103,7 @@ tmp<volScalarField> autoCreateNut ) ); - Info<< " Writing updated " << fieldName << endl; + Info<< " Writing new " << fieldName << endl; nut().write(); return nut; diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C b/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index 563f529d619b43adf41b9ee49338b5b851a2781c..10247d493eae3d934035a20af26b8ea493a30b19 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -26,6 +26,7 @@ License #include "backwardsCompatibilityWallFunctions.H" #include "Time.H" +#include "OSspecific.H" #include "wallPolyPatch.H" @@ -77,27 +78,35 @@ autoCreateWallFunctionField } else { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; + Info<< "--> Upgrading " << fieldName + << " to employ run-time selectable wall functions" << endl; + + // Read existing field + IOobject ioObj + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); - // Read existing epsilon field tmp<fieldType> fieldOrig ( new fieldType ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), + ioObj, mesh ) ); + // rename file + Info<< " Backup original " << fieldName << " to " + << fieldName << ".old" << endl; + mv(ioObj.objectPath(), ioObj.objectPath() + ".old"); + + PtrList<fvPatchField<Type> > newPatchFields(mesh.boundary().size()); forAll(newPatchFields, patchI) @@ -145,11 +154,6 @@ autoCreateWallFunctionField ) ); - Info<< " Writing backup of original " << fieldName << " to " - << fieldName << ".old" << endl; - fieldOrig().rename(fieldName + ".old"); - fieldOrig().write(); - Info<< " Writing updated " << fieldName << endl; fieldNew().write();