diff --git a/Allwmake b/Allwmake index 12d1ac6891..0f69c87181 100755 --- a/Allwmake +++ b/Allwmake @@ -1,21 +1,20 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +# Run from OPENFOAM top-level directory only +cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null || { + echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR" + echo " Check your OpenFOAM environment and installation" + exit 1 +} +[ -n "$FOAM_EXT_LIBBIN" ] || { + echo "Error (${0##*/}) : FOAM_EXT_LIBBIN not set" + echo " Check your OpenFOAM environment and installation" + exit 1 +} # Parse arguments for library compilation . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments -wmakeCheckPwd "$WM_PROJECT_DIR" || { - echo "Allwmake error: Current directory is not \$WM_PROJECT_DIR" - echo " The environment variables are inconsistent with the installation." - echo " Check the OpenFOAM entries in your dot-files and source them." - exit 1 -} - -[ -n "$FOAM_EXT_LIBBIN" ] || { - echo "Allwmake error: FOAM_EXT_LIBBIN not set" - echo " Check the OpenFOAM entries in your dot-files and source them." - exit 1 -} +#------------------------------------------------------------------------------ # Compile wmake support applications (cd wmake/src && make) diff --git a/applications/Allwmake b/applications/Allwmake index d851254b23..e78e590f9c 100755 --- a/applications/Allwmake +++ b/applications/Allwmake @@ -1,21 +1,20 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +# Run from OPENFOAM applications/ directory only +cd ${0%/*} && wmakeCheckPwd "$WM_PROJECT_DIR/applications" 2>/dev/null || { + echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR/applications" + echo " Check your OpenFOAM environment and installation" + exit 1 +} +[ -n "$FOAM_EXT_LIBBIN" ] || { + echo "Error (${0##*/}) : FOAM_EXT_LIBBIN not set" + echo " Check your OpenFOAM environment and installation" + exit 1 +} # Parse arguments for library compilation . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments -wmakeCheckPwd "$WM_PROJECT_DIR/applications" || { - echo "Allwmake error: Current directory is not \$WM_PROJECT_DIR/applications" - echo " The environment variables are inconsistent with the installation." - echo " Check the OpenFOAM entries in your dot-files and source them." - exit 1 -} - -[ -n "$FOAM_EXT_LIBBIN" ] || { - echo "Allwmake error: FOAM_EXT_LIBBIN not set" - echo " Check the OpenFOAM entries in your dot-files and source them." - exit 1 -} +#------------------------------------------------------------------------------ wmake -all $targetType solvers wmake -all $targetType utilities diff --git a/applications/test/HashPtrTable/Test-hashPtrTable.C b/applications/test/HashPtrTable/Test-hashPtrTable.C index 4b792bbae4..5133d784b1 100644 --- a/applications/test/HashPtrTable/Test-hashPtrTable.C +++ b/applications/test/HashPtrTable/Test-hashPtrTable.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,15 +31,53 @@ Description using namespace Foam; +template +void printTable(const HashPtrTable& table) +{ + Info<< table.size() << nl << "(" << nl; + + for + ( + typename HashPtrTable::const_iterator iter = table.cbegin(); + iter != table.cend(); + ++iter + ) + { + const T* ptr = *iter; + Info<< iter.key() << " = "; + if (ptr) + { + Info<< *ptr; + } + else + { + Info<< "nullptr"; + } + Info<< nl; + } + + Info<< ")" << endl; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main() { - Foam::HashPtrTable myTable; - myTable.insert("hello", new double(42.1)); + HashPtrTable myTable; + myTable.insert("abc", new double(42.1)); + myTable.insert("def", nullptr); + myTable.insert("ghi", new double(3.14159)); - Info<< myTable << endl; + // Info<< myTable << endl; + printTable(myTable); + + HashPtrTable copy(myTable); + + // Info<< copy << endl; + printTable(copy); + Info<< copy << endl; return 0; } diff --git a/applications/test/HashTable/Test-hashTable.C b/applications/test/HashTable/Test-hashTable.C index f4e16fecf3..dc2f70658e 100644 --- a/applications/test/HashTable/Test-hashTable.C +++ b/applications/test/HashTable/Test-hashTable.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,6 +49,8 @@ int main() {"aec", 10.0} }; + // Info<< "\ntable1: " << table1<< endl; + // Erase by key table1.erase("aaw"); @@ -60,7 +62,7 @@ int main() Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl; table1.printInfo(Info) << "table1 [" << table1.size() << "] " << endl; - forAllIter(HashTable, table1, iter) + forAllConstIter(HashTable, table1, iter) { Info<< iter.key() << " => " << iter() << nl; } @@ -106,7 +108,7 @@ int main() Info<< "\nerase table2 by iterator" << nl; forAllIter(HashTable, table2, iter) { - Info<< "erasing " << iter.key() << " => " << iter() << " ... "; + Info<< "erasing " << iter.key() << " => " << iter.object() << " ... "; table2.erase(iter); Info<< "erased" << endl; } diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 65073700ab..fc8fab5178 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,7 +42,11 @@ See also #include "vector.H" #include "ListOps.H" -#include +#include "labelRange.H" +#include "ListOps.H" +#include "SubList.H" + +#include using namespace Foam; @@ -61,6 +65,19 @@ int main(int argc, char *argv[]) #include "setRootCase.H" + if (false) + { + labelList intlist(IStringStream("(0 1 2)")()); + Info<<"construct from Istream: " << intlist << endl; + + IStringStream("(3 4 5)")() >> static_cast(intlist); + Info<<"is >>: " << intlist << endl; + + IStringStream("(6 7 8)")() >> intlist; + Info<<"is >>: " << intlist << endl; + } + + List list1(IStringStream("1 ((0 1 2))")()); Info<< "list1: " << list1 << endl; diff --git a/applications/test/boundBox/Test-boundBox.C b/applications/test/boundBox/Test-boundBox.C index cb72b9ca87..9c06ccf711 100644 --- a/applications/test/boundBox/Test-boundBox.C +++ b/applications/test/boundBox/Test-boundBox.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,8 +40,8 @@ boundBox cube(scalar start, scalar width) { return boundBox ( - point(start, start, start), - point(start + width, start + width, start + width) + point::uniform(start), + point::uniform(start + width) ); } @@ -59,6 +59,69 @@ int main(int argc, char *argv[]) Info<<"boundBox faces: " << boundBox::faces << endl; Info<<"hex faces: " << hex.modelFaces() << endl; + Info<<"tree-bb faces: " << treeBoundBox::faces << endl; + Info<<"tree-bb edges: " << treeBoundBox::edges << endl; + + boundBox bb = boundBox::greatBox; + Info<<"great box: " << bb << endl; + + // bb.clear(); + // Info<<"zero box: " << bb << endl; + + bb = boundBox::invertedBox; + Info<<"invalid box: " << bb << endl; + Info<< nl << endl; + + if (Pstream::parRun()) + { + bb = cube(Pstream::myProcNo(), 1.1); + Pout<<"box: " << bb << endl; + + bb.reduce(); + Pout<<"reduced: " << bb << endl; + } + else + { + bb = cube(0, 1); + Info<<"starting box: " << bb << endl; + + point pt(Zero); + bb.add(pt); + Info<<"enclose point " << pt << " -> " << bb << endl; + + pt = point(0,1.5,0.5); + bb.add(pt); + Info<<"enclose point " << pt << " -> " << bb << endl; + + pt = point(5,2,-2); + bb.add(pt); + Info<<"enclose point " << pt << " -> " << bb << endl; + + // restart with same points + bb = boundBox::invertedBox; + bb.add(point(1,1,1)); + bb.add(point::zero); + bb.add(point(0,1.5,0.5)); + bb.add(point(5,2,-2)); + + Info<<"repeated " << bb << endl; + + boundBox box1 = cube(0, 1); + boundBox box2 = cube(0, 0.75); + boundBox box3 = cube(0.5, 1); + boundBox box4 = cube(-1, 0.5); + + Info<<"union of " << box1 << " and " << box2 << " => "; + + box1.add(box2); + Info<< box1 << endl; + + box1.add(box3); + Info<<"union with " << box3 << " => " << box1 << endl; + + box1.add(box4); + Info<<"union with " << box4 << " => " << box1 << endl; + } return 0; } diff --git a/applications/test/labelRanges/Test-labelRanges.C b/applications/test/labelRanges/Test-labelRanges.C index 9f2be334d1..dec03a06f0 100644 --- a/applications/test/labelRanges/Test-labelRanges.C +++ b/applications/test/labelRanges/Test-labelRanges.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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,6 +58,7 @@ int main(int argc, char *argv[]) } + labelRange range; labelRanges ranges; bool removeMode = false; @@ -74,14 +75,16 @@ int main(int argc, char *argv[]) continue; } - label start = 0; - label size = 0; + { + label start = 0; + label size = 0; - IStringStream(args[argI])() >> start; - ++argI; - IStringStream(args[argI])() >> size; + IStringStream(args[argI])() >> start; + ++argI; + IStringStream(args[argI])() >> size; - labelRange range(start, size); + range.reset(start, size); + } Info<< "---------------" << nl; if (removeMode) @@ -107,10 +110,11 @@ int main(int argc, char *argv[]) ranges.add(range); } - Info<< "" << ranges << "" << nl; - forAllConstIter(labelRanges, ranges, iter) + Info<< "" << ranges << "" << nl + << "content:"; + for (auto i : ranges) { - Info<< " " << iter(); + Info<< " " << i; } Info<< nl; } diff --git a/applications/test/string/Test-string.C b/applications/test/string/Test-string.C index ec7defadd3..cb6333b3d4 100644 --- a/applications/test/string/Test-string.C +++ b/applications/test/string/Test-string.C @@ -69,6 +69,13 @@ int main(int argc, char *argv[]) Info<<"trimRight: " << stringOps::trimRight(test) << endl; Info<<"trim: " << stringOps::trim(test) << endl; + Info<< nl; + Info<<"camel-case => " << (word("camel") & "case") << nl; + for (const auto& s : { " text with \"spaces'", "08/15 value" }) + { + Info<<"validated \"" << s << "\" => " << word::validated(s) << nl; + } + Info<< nl; // test sub-strings via iterators string::const_iterator iter = test.end(); diff --git a/applications/test/wallDist/Test-wallDist.C b/applications/test/wallDist/Test-wallDist.C index 7a2d4f5cdf..d25bffc006 100644 --- a/applications/test/wallDist/Test-wallDist.C +++ b/applications/test/wallDist/Test-wallDist.C @@ -66,14 +66,14 @@ int main(int argc, char *argv[]) pointField newPoints(mesh.points()); - const point half(0.5*(meshBb.min() + meshBb.max())); + const point half = meshBb.midpoint(); forAll(newPoints, pointi) { point& pt = newPoints[pointi]; // expand around half - pt.y() += pt.y() - half.y(); + pt.y() += pt.y() - half.y(); } mesh.movePoints(newPoints); diff --git a/applications/utilities/mesh/generation/blockMesh/blockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMesh.C index d48980cb8c..c1c5016b35 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMesh.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,6 +49,9 @@ Usage - \par -dict \ Specify alternative dictionary for the block mesh description. + - \par -sets + Write cellZones as cellSets too (for processing purposes) + \*---------------------------------------------------------------------------*/ #include "Time.H" @@ -85,7 +88,11 @@ int main(int argc, char *argv[]) "file", "specify alternative dictionary for the blockMesh description" ); - + argList::addBoolOption + ( + "sets", + "write cellZones as cellSets too (for processing purposes)" + ); argList::addNote ( "Block description\n" @@ -187,7 +194,6 @@ int main(int argc, char *argv[]) IOdictionary meshDict(meshDictIO); blockMesh blocks(meshDict, regionName); - if (args.optionFound("blockTopology")) { // Write mesh as edges. @@ -251,7 +257,6 @@ int main(int argc, char *argv[]) defaultFacesType ); - // Read in a list of dictionaries for the merge patch pairs if (meshDict.found("mergePatchPairs")) { @@ -271,8 +276,7 @@ int main(int argc, char *argv[]) // Set any cellZones (note: cell labelling unaffected by above // mergePatchPairs) - label nZones = blocks.numZonedBlocks(); - + const label nZones = blocks.numZonedBlocks(); if (nZones > 0) { Info<< nl << "Adding cell zones" << endl; @@ -325,11 +329,7 @@ int main(int argc, char *argv[]) } } - List cz(zoneMap.size()); - - Info<< nl << "Writing cell zones as cellSets" << endl; - forAllConstIter(HashTable