diff --git a/.gitignore b/.gitignore index 4a7188cdfbaaa032b0025983cdc81649a20f8aa5..96c3093b718b9a8ee6d711583018ae836555158a 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,9 @@ doc/[Dd]oxygen/man *.tar.gz *.tgz +# ignore the persistent .build tag in the main directory +/.build + # ignore .timeStamp in the main directory /.timeStamp diff --git a/applications/test/DLList/DLListTest.C b/applications/test/DLList/DLListTest.C index 12913ce8666f661fdd693bc76e1775c090e7a59b..2929efc1ce8d2940aed11d007c9d7b474bef437b 100644 --- a/applications/test/DLList/DLListTest.C +++ b/applications/test/DLList/DLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -48,7 +48,6 @@ int main(int argc, char *argv[]) } myList.append(100.3); - myList.append(500.3); Info<< nl << "And again using STL iterator: " << nl << endl; @@ -120,7 +119,18 @@ int main(int argc, char *argv[]) Info<< "element:" << *iter << endl; } - Info<< nl << "Bye." << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + DLList<scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + + + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/Dictionary/DictionaryTest.C b/applications/test/Dictionary/DictionaryTest.C index ade39072642b83f14e516106797c059676e0ff4f..9bbd32d4fdd2868e60850703ab05320fc9e0268b 100644 --- a/applications/test/Dictionary/DictionaryTest.C +++ b/applications/test/Dictionary/DictionaryTest.C @@ -23,15 +23,18 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ #include "OSspecific.H" +#include "scalar.H" + #include "IOstreams.H" #include "Dictionary.H" +#include "PtrDictionary.H" using namespace Foam; @@ -63,6 +66,36 @@ public: }; +class Scalar +{ + scalar data_; + +public: + + Scalar() + : + data_(0) + {} + + Scalar(scalar val) + : + data_(val) + {} + + ~Scalar() + { + Info <<"delete Scalar: " << data_ << endl; + } + + friend Ostream& operator<<(Ostream& os, const Scalar& val) + { + os << val.data_; + return os; + } +}; + + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -92,12 +125,11 @@ int main(int argc, char *argv[]) Info<< "element : " << *iter; } - Info<< dict.toc() << endl; + Info<< "keys: " << dict.toc() << endl; delete dictPtr; - dictPtr = new Dictionary<ent>; - Dictionary<ent>& dict2 = *dictPtr; + Dictionary<ent> dict2; for (int i = 0; i<10; i++) { @@ -106,9 +138,79 @@ int main(int argc, char *argv[]) dict2.swapUp(ePtr); } - Info<< dict2 << endl; + Info<< "dict:\n" << dict2 << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << dict2 << endl; + + Dictionary<ent> newDict; + newDict.transfer(dict2); + + Info<< nl << "source: " << dict2 << nl + << "keys: " << dict2.toc() << nl + << "target: " << newDict << nl + << "keys: " << newDict.toc() << endl; + + + PtrDictionary<Scalar> scalarDict; + for (int i = 0; i<10; i++) + { + word key("ent" + name(i)); + scalarDict.insert(key, new Scalar(1.3*i)); + } + + Info<< nl << "scalarDict1: " << endl; + for + ( + PtrDictionary<Scalar>::const_iterator iter = scalarDict.begin(); + iter != scalarDict.end(); + ++iter + ) + { + Info<< " = " << iter() << endl; + } + + PtrDictionary<Scalar> scalarDict2; + for (int i = 8; i<15; i++) + { + word key("ent" + name(i)); + scalarDict2.insert(key, new Scalar(1.3*i)); + } + Info<< nl << "scalarDict2: " << endl; + for + ( + PtrDictionary<Scalar>::const_iterator iter = scalarDict2.begin(); + iter != scalarDict2.end(); + ++iter + ) + { + Info<< "elem = " << *iter << endl; + } + + scalarDict.transfer(scalarDict2); + + + Scalar* p = scalarDict.lookupPtr("ent8"); + + // This does not (yet) work + // Scalar* q = scalarDict.remove("ent10"); + + if (p) + { + Info << "found: " << *p << endl; + } + else + { + Info << "no p: " << endl; + } + + scalarDict.clear(); + + // Info<< " = " << *iter << endl; + + - Info<< nl << "Bye." << endl; + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/ISLList/ISLListTest.C b/applications/test/ISLList/ISLListTest.C index 60590d1eafc26468d19167b0e4792ca271381a3c..f33f811c1a4bfa3b705ddacbfef0d734d0771326 100644 --- a/applications/test/ISLList/ISLListTest.C +++ b/applications/test/ISLList/ISLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -52,6 +52,13 @@ public: : data_(s) {} + + friend Ostream& operator<<(Ostream& os, const Scalar& s) + { + os << s.data_; + return os; + } + }; @@ -68,10 +75,8 @@ int main(int argc, char *argv[]) } myList.append(new Scalar(100.3)); - myList.append(new Scalar(500.3)); - Info<< nl << "And again using STL iterator: " << nl << endl; for @@ -99,6 +104,15 @@ int main(int argc, char *argv[]) } + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + ISLList<Scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + Info<< nl << "Bye." << endl; return 0; } diff --git a/applications/test/PtrList/Make/files b/applications/test/PtrList/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..4bfd49bde04e8d290f2aa7041966dfc8b3dc6c04 --- /dev/null +++ b/applications/test/PtrList/Make/files @@ -0,0 +1,3 @@ +PtrListTest.C + +EXE = $(FOAM_USER_APPBIN)/PtrListTest diff --git a/applications/test/hmm/Make/options b/applications/test/PtrList/Make/options similarity index 100% rename from applications/test/hmm/Make/options rename to applications/test/PtrList/Make/options diff --git a/applications/test/hmm/dictionaryTest.C b/applications/test/PtrList/PtrListTest.C similarity index 56% rename from applications/test/hmm/dictionaryTest.C rename to applications/test/PtrList/PtrListTest.C index a57a16e552f533f34457e90d9906eff91c3909e6..8de64a9d3cdfb6a7f2250a7059caacd0c40350f6 100644 --- a/applications/test/hmm/dictionaryTest.C +++ b/applications/test/PtrList/PtrListTest.C @@ -23,27 +23,88 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ +#include "OSspecific.H" + +#include "scalar.H" #include "IOstreams.H" -#include "IFstream.H" -#include "dictionary.H" +#include "PtrList.H" using namespace Foam; +class Scalar +{ + scalar data_; + +public: + + Scalar() + : + data_(0) + {} + + Scalar(scalar val) + : + data_(val) + {} + + ~Scalar() + { + Info <<"delete Scalar: " << data_ << endl; + } + + friend Ostream& operator<<(Ostream& os, const Scalar& val) + { + os << val.data_; + return os; + } +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: int main(int argc, char *argv[]) { - IFstream dictStream("testDict"); - dictionary testDict(dictStream); + PtrList<Scalar> list1(10); + PtrList<Scalar> list2(15); + + forAll(list1, i) + { + list1.set(i, new Scalar(1.3*i)); + } + + forAll(list2, i) + { + list2.set(i, new Scalar(10 + 1.3*i)); + } + + + Info<<"list1: " << list1 << endl; + Info<<"list2: " << list2 << endl; + + Info<<"indirectly delete some items via set(.., 0) :" << endl; + for (label i = 0; i < 3; i++) + { + list1.set(i, 0); + } + + Info<<"transfer list2 -> list1:" << endl; + list1.transfer(list2); + + Info<<"list1: " << list1 << endl; + Info<<"list2: " << list2 << endl; + + Info<<"indirectly delete some items via setSize :" << endl; + list1.setSize(4); - Info<< testDict << endl; + Info<<"list1: " << list1 << endl; + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/SLList/SLListTest.C b/applications/test/SLList/SLListTest.C index 3bd9af2b6723a72d8be0f25c1ac76427ecda5977..f55f7b4edf58f533e5f1c242b08bfbbb79beef73 100644 --- a/applications/test/SLList/SLListTest.C +++ b/applications/test/SLList/SLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -48,10 +48,8 @@ int main(int argc, char *argv[]) } myList.append(100.3); - myList.append(500.3); - Info<< nl << "And again using STL iterator: " << nl << endl; for @@ -99,7 +97,27 @@ int main(int argc, char *argv[]) Info<< "element:" << *iter2 << endl; } - Info<< nl << "Bye." << endl; + + + for (int i = 0; i<10; i++) + { + myList.append(1.3*i); + } + + myList.append(100.3); + myList.append(500.3); + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + SLList<scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + + + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/UDictionary/UDictionaryTest.C b/applications/test/UDictionary/UDictionaryTest.C index 5caea16dad9e959c73d5c7911b938a300df9f8ec..247fc98cbb6b0d20e0c8111881d21606631fad2a 100644 --- a/applications/test/UDictionary/UDictionaryTest.C +++ b/applications/test/UDictionary/UDictionaryTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -113,7 +113,20 @@ int main(int argc, char *argv[]) Info<< dict2 << endl; - Info<< nl << "Bye." << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << dict2 << endl; + + UDictionary<ent> newDict; + newDict.transfer(dict2); + + Info<< nl << "source: " << dict2 << nl + << "keys: " << dict2.toc() << nl + << "target: " << newDict << nl + << "keys: " << newDict.toc() << endl; + + Info<< nl << "Done." << endl; + return 0; } diff --git a/applications/test/dictionary/dictionaryTest.C b/applications/test/dictionary/dictionaryTest.C index d8580bdf5429c851e9907b387cfaa4e18080af79..558ec7fec68d34878e0b4b7a09574aa02acd5f5f 100644 --- a/applications/test/dictionary/dictionaryTest.C +++ b/applications/test/dictionary/dictionaryTest.C @@ -41,34 +41,44 @@ using namespace Foam; int main(int argc, char *argv[]) { - Info<< dictionary(IFstream("testDict")()) << endl; + { + dictionary dict(IFstream("testDict")()); + Info<< "dict: " << dict << nl + << "toc: " << dict.toc() << nl + << "keys: " << dict.keys() << nl + << "patterns: " << dict.keys(true) << endl; + } + IOobject::writeDivider(Info); { dictionary dict(IFstream("testDictRegex")()); + dict.add(keyType("fooba[rz]", true), "anything"); - Info<< "dict:" << dict << endl; + Info<< "dict:" << dict << nl + << "toc: " << dict.toc() << nl + << "keys: " << dict.keys() << nl + << "patterns: " << dict.keys(true) << endl; - // Wildcard find. - Info<< "Wildcard find \"abc\" in top directory : " + Info<< "Pattern find \"abc\" in top directory : " << dict.lookup("abc") << endl; - Info<< "Wildcard find \"abc\" in sub directory : " + Info<< "Pattern find \"abc\" in sub directory : " << dict.subDict("someDict").lookup("abc") << endl; - Info<< "Recursive wildcard find \"def\" in sub directory : " + Info<< "Recursive pattern find \"def\" in sub directory : " << dict.subDict("someDict").lookup("def", true) << endl; - Info<< "Recursive wildcard find \"foo\" in sub directory : " + Info<< "Recursive pattern find \"foo\" in sub directory : " << dict.subDict("someDict").lookup("foo", true) << endl; - Info<< "Recursive wildcard find \"fooz\" in sub directory : " + Info<< "Recursive pattern find \"fooz\" in sub directory : " << dict.subDict("someDict").lookup("fooz", true) << endl; - Info<< "Recursive wildcard find \"bar\" in sub directory : " + Info<< "Recursive pattern find \"bar\" in sub directory : " << dict.subDict("someDict").lookup("bar", true) << endl; - Info<< "Recursive wildcard find \"xxx\" in sub directory : " + Info<< "Recursive pattern find \"xxx\" in sub directory : " << dict.subDict("someDict").lookup("xxx", true) << endl; } diff --git a/applications/test/dictionary/testDictRegex b/applications/test/dictionary/testDictRegex index d4252cd3bee069ada8a5ec37a7e8d694670786ec..01d4274ba8dad8147a4b62e254317b0ae1cd7f38 100644 --- a/applications/test/dictionary/testDictRegex +++ b/applications/test/dictionary/testDictRegex @@ -18,8 +18,10 @@ FoamFile ".*" parentValue1; "[n-z].*" parentValue2; "f.*" parentValue3; +keyX parentValue4; +keyY parentValue5; -someDict +"(.*)Dict" { foo subdictValue0; bar $f.*; // should this really match 'foo'? @@ -28,7 +30,7 @@ someDict "a.*c" subdictValue3; "ab.*" subdictValue2; "a.*" subdictValue1; - abcd subdictValue4; + abcd \1; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/fileName/fileNameTest.C b/applications/test/fileName/fileNameTest.C index 99642333c6117d786b85832ed8d403fe62f6e992..c3a36f49e1a35156c14185287a5285bc40dc6c08 100644 --- a/applications/test/fileName/fileNameTest.C +++ b/applications/test/fileName/fileNameTest.C @@ -32,6 +32,7 @@ Description #include "fileName.H" #include "IOstreams.H" +#include "OSspecific.H" using namespace Foam; @@ -57,7 +58,16 @@ int main() Info<< "pathName.components() = " << pathName.components() << endl; Info<< "pathName.component(2) = " << pathName.component(2) << endl; - Info<< "end" << endl; + + // test findEtcFile + Info<< "\n\nfindEtcFile tests:" << nl + << " controlDict => " << findEtcFile("controlDict") << nl + << " badName => " << findEtcFile("badName") << endl; + Info<< "This should emit a fatal error:" << endl; + Info<< " badName(die) => " << findEtcFile("badName", true) << nl + << endl; + + Info<< "\nEnd" << endl; return 0; } diff --git a/applications/test/getRoots/Make/files b/applications/test/getRoots/Make/files deleted file mode 100644 index 01385a77312922d0dc59e319abc7c8e38d8f25cf..0000000000000000000000000000000000000000 --- a/applications/test/getRoots/Make/files +++ /dev/null @@ -1,2 +0,0 @@ -getRoots.C -EXE = $(FOAM_USER_APPBIN)/getRoots diff --git a/applications/test/getRoots/Make/options b/applications/test/getRoots/Make/options deleted file mode 100644 index 4e772fdf9d7bc94221d127458f9d2ca32850fe69..0000000000000000000000000000000000000000 --- a/applications/test/getRoots/Make/options +++ /dev/null @@ -1,2 +0,0 @@ -/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */ -/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/getRoots/getRoots.C b/applications/test/getRoots/getRoots.C deleted file mode 100644 index 2cc985b1697d890aa135679c7b856f3e3d1a0a92..0000000000000000000000000000000000000000 --- a/applications/test/getRoots/getRoots.C +++ /dev/null @@ -1,30 +0,0 @@ -#include "dictionary.H" -#include "fileNameList.H" -#include "IFstream.H" -#include "OSspecific.H" - -using namespace Foam; - -int main() -{ - Info << "\nReading Roots" << endl; - - IFstream rootsFile(home()/".foam/apps/openDX/roots"); - fileNameList rootsList(dictionary(rootsFile).lookup("roots")); - - char** rootsStrings = new char*[rootsList.size() + 1]; - rootsStrings[rootsList.size()] = 0; - - if (rootsList.size()) - { - for (int i=0; i<rootsList.size(); i++) - { - rootsStrings[i] = new char[rootsList[i].size() + 1]; - strcpy(rootsStrings[i], rootsList[i].c_str()); - - Info<< rootsStrings[i] << endl; - } - } - - return 0; -} diff --git a/applications/test/hmm/Make/files b/applications/test/hmm/Make/files deleted file mode 100644 index 759804fcfa6cf2737cd9599f8aeba508687cf353..0000000000000000000000000000000000000000 --- a/applications/test/hmm/Make/files +++ /dev/null @@ -1,4 +0,0 @@ -calcEntry/calcEntry.C -dictionaryTest.C - -EXE = $(FOAM_USER_APPBIN)/dictionaryTest diff --git a/applications/test/hmm/calcEntry/calcEntry.C b/applications/test/hmm/calcEntry/calcEntry.C deleted file mode 100644 index 8801a5255519333336312a2eea45bef2fcdfcaaa..0000000000000000000000000000000000000000 --- a/applications/test/hmm/calcEntry/calcEntry.C +++ /dev/null @@ -1,88 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "calcEntry.H" -#include "dictionary.H" -#include "IStringStream.H" -#include "OStringStream.H" -#include "addToMemberFunctionSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -namespace functionEntries -{ - defineTypeNameAndDebug(calcEntry, 0); - - addToMemberFunctionSelectionTable - ( - functionEntry, - calcEntry, - insert, - primitiveEntryIstream - ); - - addToMemberFunctionSelectionTable - ( - functionEntry, - calcEntry, - insert, - dictionaryIstream - ); -} -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionEntries::calcEntry::insert -( - const dictionary& parentDict, - primitiveEntry& entry, - Istream& is -) -{ - dictionary args(parentDict, is); - OStringStream resultStream; - resultStream - << (args.lookup("x")[0].number() + args.lookup("y")[0].number()); - entry.read(parentDict, IStringStream(resultStream.str())()); - return true; -} - - -bool Foam::functionEntries::calcEntry::insert -( - dictionary& parentDict, - Istream& is -) -{ - return true; -} - - -// ************************************************************************* // diff --git a/applications/test/hmm/testDict b/applications/test/hmm/testDict deleted file mode 100644 index 70f6885e7ef345028a910a08c2691d2e7d6a6a82..0000000000000000000000000000000000000000 --- a/applications/test/hmm/testDict +++ /dev/null @@ -1,55 +0,0 @@ -FoamFile -{ - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object testDict; -} - - -dimensions [ 0 2 -2 0 0 0 0 ]; -internalField uniform 1; - -active -{ - type turbulentIntensityKineticEnergyInlet; - intensity 0.1; - value $internalField; -} - - -inactive -{ - type zeroGradient; -} - - -boundaryField -{ - Default_Boundary_Region - { - type zeroGradient; - } - - inlet_1 { $active } - inlet_2 { $inactive } - inlet_3 { $inactive } - - #include "testDictInc" - - outlet - { - type inletOutlet; - inletValue $internalField; - value #include "value"; - x 5; - y 6; - another #calc{x $x; y $y;}; - } -} diff --git a/applications/test/hmm/testDictInc b/applications/test/hmm/testDictInc deleted file mode 100644 index a0814c18339e71c5c438eea2985d2f149e25dc63..0000000000000000000000000000000000000000 --- a/applications/test/hmm/testDictInc +++ /dev/null @@ -1,6 +0,0 @@ - inlet_4 - { - type inletOutlet; - inletValue $internalField; - value $internalField; - } diff --git a/applications/test/hmm/value b/applications/test/hmm/value deleted file mode 100644 index 196f9d3d0a639b5120ba76846b0612094b137245..0000000000000000000000000000000000000000 --- a/applications/test/hmm/value +++ /dev/null @@ -1 +0,0 @@ -uniform 2 diff --git a/applications/test/regex/Make/options b/applications/test/regex/Make/options index 0eb7b642835fcec4c4b72727cdc17c7e7825fe70..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/applications/test/regex/Make/options +++ b/applications/test/regex/Make/options @@ -1,3 +0,0 @@ -EXE_LIBS = \ - $(FOAM_LIBBIN)/libOSspecific.o - diff --git a/applications/test/regex/regexTest.C b/applications/test/regex/regexTest.C index 51c07b9ceecea77332a64730bd12807689bff171..0463891dc1ef24d4914fa0bb285b03ef4ff200a1 100644 --- a/applications/test/regex/regexTest.C +++ b/applications/test/regex/regexTest.C @@ -76,6 +76,36 @@ int main(int argc, char *argv[]) Info << endl; } + Info<<"test regExp(const char*) ..." << endl; + string me("Mark"); + + if (regExp("[Mm]ar[ck]").match(me)) + { + Info<< "matched: " << me << endl; + } + else + { + Info<< "no match" << endl; + } + + if (regExp("").match(me)) + { + Info<< "matched: " << me << endl; + } + else + { + Info<< "no match" << endl; + } + + if (regExp(NULL).match(me)) + { + Info<< "matched: " << me << endl; + } + else + { + Info<< "no match" << endl; + } + Info<< endl; return 0; diff --git a/applications/test/router/Gather/Gather.C b/applications/test/router/Gather/Gather.C index 968f45b9361a9cb0d449e93217d2aff0a6468e7b..1f2bc56c44a8cb4e7c8a24e92f151cb1076fa637 100644 --- a/applications/test/router/Gather/Gather.C +++ b/applications/test/router/Gather/Gather.C @@ -59,23 +59,24 @@ Gather<T0>::Gather(const T0& localData, const bool redistribute) // Receive data for ( - int slave=Pstream::firstSlave(), procIndex = 1; - slave<=Pstream::lastSlave(); + int slave = Pstream::firstSlave(), procIndex = 1; + slave <= Pstream::lastSlave(); slave++, procIndex++ ) { - IPstream fromSlave(slave); + IPstream fromSlave(Pstream::scheduled, slave); fromSlave >> this->operator[](procIndex); } + // Send data for ( - int slave=Pstream::firstSlave(), procIndex = 1; - slave<=Pstream::lastSlave(); + int slave = Pstream::firstSlave(), procIndex = 1; + slave <= Pstream::lastSlave(); slave++, procIndex++ ) { - OPstream toSlave(slave); + OPstream toSlave(Pstream::scheduled, slave); if (redistribute) { @@ -92,12 +93,13 @@ Gather<T0>::Gather(const T0& localData, const bool redistribute) { // Slave: send my local data to master { - OPstream toMaster(Pstream::masterNo()); + OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); toMaster << localData; } + // Receive data from master { - IPstream fromMaster(Pstream::masterNo()); + IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); if (redistribute) { fromMaster >> *this; diff --git a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C index f290e7fa42d0e609a3730f9e85db9589108b9c93..f9337bad0e863d08691b255ef86d5dbba05689db 100644 --- a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C +++ b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C @@ -289,9 +289,7 @@ int main(int argc, char *argv[]) << patchNames[patchI] << "\t\t" << allPatchFaces[patchI].size() << endl; - allPatchFaces[patchI].shrink(); patchFaces[patchI].transfer(allPatchFaces[patchI]); - allPatchFaces[patchI].clear(); } Info<< endl; diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C index e99bca0af1db9e80bc4bc06afb5d5cbd2e3b054e..cf9d5e82379e15897b4ecd6985875462c6bd7cef 100644 --- a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C +++ b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C @@ -461,7 +461,7 @@ int main(int argc, char *argv[]) } } - + // Trim boundaryFaces.setSize(faceI); boundaryPatch.setSize(faceI); @@ -515,7 +515,7 @@ int main(int argc, char *argv[]) Info<< " " << patchNames[patchI] << " : " << allPatchFaces[patchI].size() << endl; - patchFaces[patchI].transfer(allPatchFaces[patchI].shrink()); + patchFaces[patchI].transfer(allPatchFaces[patchI]); } Info<< endl; @@ -548,7 +548,6 @@ int main(int argc, char *argv[]) meshPtr().write(); - Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt index 01d4f5a9fe0031eb8b03760bcb3cb294de083c82..17be614da4d2e9db4390f247b195c4f92f351bd9 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt @@ -7,6 +7,8 @@ # the pqReader.xml file contains xml defining readers with their # file extensions and descriptions. +cmake_minimum_required(VERSION 2.4) + FIND_PACKAGE(ParaView REQUIRED) INCLUDE(${PARAVIEW_USE_FILE}) diff --git a/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.C b/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.C index d7db62e441c93b1fbb3bca9fb550f01cba246b2a..898f3572e0af5c62992d296e45599359b36edd94 100644 --- a/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.C +++ b/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.C @@ -74,10 +74,7 @@ void Foam::readerDatabase::getPolyHedra() } } - polys.shrink(); - Info<< "Found " << polys.size() << " polyhedral cells " << endl; - polys_.transfer(polys); } diff --git a/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C b/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C index 3d494b6cc0315b35633d3ea3a447a67426e0a8b7..be274ec4ce8da98eb3a6af1cfca2678c8a189864 100644 --- a/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C +++ b/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) Info<< nl << "Reading Burcat data dictionary" << endl; - fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); + fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData")); // Construct control dictionary IFstream BurcatCpDataFile(BurcatCpDataFileName); diff --git a/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C b/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C index 56767eecb3e95504d3c0c327bfc817ebf86572ec..444570046ae0d41578a5b0026aa20ac1ebaf7bca 100644 --- a/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C +++ b/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) Info<< nl << "Reading Burcat data dictionary" << endl; - fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); + fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData")); // Construct control dictionary IFstream BurcatCpDataFile(BurcatCpDataFileName); diff --git a/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C b/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C index c3ee5e81fda16b78c7d7b00d3133e8634415e906..392c2e062fd7e474e8ca64d33e0feb01acc7f3f6 100644 --- a/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C +++ b/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) Info<< nl << "Reading Burcat data dictionary" << endl; - fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); + fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData")); // Construct control dictionary IFstream BurcatCpDataFile(BurcatCpDataFileName); diff --git a/bin/buildParaView3.3-cvs-python b/bin/buildParaView3.3-cvs-python deleted file mode 120000 index db5ce4641b139ff974bcef01ee90a13c71a117d6..0000000000000000000000000000000000000000 --- a/bin/buildParaView3.3-cvs-python +++ /dev/null @@ -1 +0,0 @@ -buildParaView3.3-cvs \ No newline at end of file diff --git a/bin/buildParaView3.5-cvs b/bin/buildParaView3.5-cvs new file mode 100755 index 0000000000000000000000000000000000000000..707287a981873b253e26911f116fb0639fc70d53 --- /dev/null +++ b/bin/buildParaView3.5-cvs @@ -0,0 +1,192 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# Script +# buildParaView3.5-cvs +# +# Description +# Build and install ParaView +# - run from folder above ParaView source folder or place the +# ParaView source under $WM_THIRD_PARTY_DIR +# +#------------------------------------------------------------------------------ +. $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions + +PARAVIEW_SRC=paraview-3.5-cvs +PARAVIEW_MAJOR_VERSION=3.5 + +# User options: +# ~~~~~~~~~~~~~ + +# MPI support: +WITH_MPI=OFF +MPI_MAX_PROCS=32 + +# Python support: +# note: script will try to determine the appropriate python library. +# If it fails, specify the path using the PYTHON_LIBRARY variable +WITH_PYTHON=OFF +PYTHON_LIBRARY="" +# PYTHON_LIBRARY="/usr/lib64/libpython2.5.so.1.0" + +# MESA graphics support: +WITH_MESA=OFF + +# +# No further editing below this line +#------------------------------------------------------------------------------ +Script=${0##*/} + +usage() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE + +usage: ${0##*/} [OPTION] +options: + -fast for repeated builds (-make -install) *use with caution* + -mpi with mpi (if not already enabled) + -python with python (if not already enabled) + -mesa with mesa (if not already enabled) + -verbose verbose output in Makefiles + -help + +For finer control, the build stages can be also selected individually +(mutually exclusive) + -config + -make + -makedoc + -install + [-envpath] alter absolute paths in CMake files to use env variables + +Build and install $PARAVIEW_SRC + - run from folder above the ParaView source folder or place the + ParaView source under \$WM_THIRD_PARTY_DIR + +USAGE + exit 1 +} + +# add options based on script name: +case "$Script" in *-mpi*) WITH_MPI=ON;; esac +case "$Script" in *-python*) WITH_PYTHON=ON;; esac +case "$Script" in *-mesa*) WITH_MESA=ON;; esac + +runCONFIG=true +runMAKE=true +runMAKEDOC=true +runINSTALL=true +runENVPATH=false + +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -config) # stage 1: config only + runCONFIG=true + runMAKE=false + runMAKEDOC=false + runINSTALL=false + shift + ;; + -make) # stage 2: make only + runCONFIG=false + runMAKE=true + runMAKEDOC=false + runINSTALL=false + shift + ;; + -makedoc) # stage 3: generate html documentation + runCONFIG=false + runMAKE=false + runMAKEDOC=true + runINSTALL=false + shift + ;; + -install) # stage 4: install only + runCONFIG=false + runMAKE=false + runMAKEDOC=false + runINSTALL=true + shift + ;; + -envpath) # optional: change cmake files to use env variables + runCONFIG=false + runMAKE=false + runMAKEDOC=false + runINSTALL=false + runENVPATH=true + shift + ;; + -fast) # shortcut for rebuild + runCONFIG=false + runMAKE=true + runMAKEDOC=false + runINSTALL=true + shift + ;; + -mpi) + WITH_MPI=ON + shift + ;; + -python) + WITH_PYTHON=ON + shift + ;; + -mesa) + WITH_MESA=ON + shift + ;; + -verbose) + VERBOSE=ON + shift + ;; + *) + usage "unknown option/argument: '$*'" + ;; + esac +done + +# Set configure options +#~~~~~~~~~~~~~~~~~~~~~~ +addVerbosity # verbose makefiles +addMpiSupport # set MPI-specific options +addPythonSupport # set Python-specific options +addMesaSupport # set MESA-specific options + +getPaths # discover where things are or should be put + +# Build and install +# ~~~~~~~~~~~~~~~~~ +[ $runCONFIG = true ] && configParaView +[ $runMAKE = true ] && makeParaView +[ $runMAKEDOC = true ] && makeDocs +[ $runINSTALL = true ] && installParaView +[ $runENVPATH = true ] && fixCMakeFiles + +echo "done" +#------------------------------------------------------------------------------ diff --git a/bin/buildParaView3.5-cvs-python b/bin/buildParaView3.5-cvs-python new file mode 120000 index 0000000000000000000000000000000000000000..d3ed3924a892abffc145149dd53de0b9819d6272 --- /dev/null +++ b/bin/buildParaView3.5-cvs-python @@ -0,0 +1 @@ +buildParaView3.5-cvs \ No newline at end of file diff --git a/bin/foamUpdateCaseFileHeader b/bin/foamUpdateCaseFileHeader index f4340fc53c7957cb2a60a9806b44b24dac7da713..311cb21e8238471db0205051c3acc083fbfeb0d3 100755 --- a/bin/foamUpdateCaseFileHeader +++ b/bin/foamUpdateCaseFileHeader @@ -45,8 +45,8 @@ options: -h help Updates the header of application files and removes consecutive blank lines. - By default, writes current version in the header. - An alternative version can be specified with -v option. + By default, writes current OpenFOAM version in the header. + An alternative version can be specified with the -v option. USAGE exit 1 @@ -59,8 +59,8 @@ printHeader() { | ========= | | | \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\\\ / O peration | Version: ${foamVersion} | -| \\\\ / A nd | Web: http://www.OpenFOAM.org | -| \\\\/ M anipulation | | +| \\\\ / A nd | | +| \\\\/ M anipulation | www.OpenFOAM.org | \\*---------------------------------------------------------------------------*/ FoamFile { @@ -84,13 +84,13 @@ FoamFileAttribute() { # # OPTIONS # -OPTS=`getopt hv: $*` +opts=$(getopt hv: $*) if [ $? -ne 0 ] then echo "Aborting due to invalid option" usage fi -eval set -- '$OPTS' +eval set -- '$opts' while [ "$1" != "--" ] do case $1 in @@ -110,11 +110,13 @@ shift # constant width for version -foamVersion=`printf %-36s $foamVersion` +foamVersion=$(printf %-36s $foamVersion) # # MAIN # +unset NOTE + for caseFile do if grep FoamFile $caseFile >/dev/null 2>&1 @@ -122,16 +124,17 @@ do echo "Updating case file: $caseFile" sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp - CLASS=`FoamFileAttribute class FoamFile.tmp` - OBJECT=`FoamFileAttribute object FoamFile.tmp` - FORMAT=`FoamFileAttribute format FoamFile.tmp` + FORMAT=$(FoamFileAttribute format FoamFile.tmp) + CLASS=$(FoamFileAttribute class FoamFile.tmp) + OBJECT=$(FoamFileAttribute object FoamFile.tmp) + # extract NOTE? printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp # use cat to avoid removing/replace soft-links [ -s FoamFile.tmp ] && cat FoamFile.tmp >| $caseFile - rm FoamFile.tmp + rm -f FoamFile.tmp 2>/dev/null else echo " Invalid case file: $caseFile" 1>&2 fi diff --git a/bin/buildParaView3.3-cvs b/bin/tools/buildParaView3.4 similarity index 54% rename from bin/buildParaView3.3-cvs rename to bin/tools/buildParaView3.4 index 1f95596f3c56c6e1d9cf87b3b28efce845109719..87b993d539c9f5f95cf7d53c076a9f9f0b789154 100755 --- a/bin/buildParaView3.3-cvs +++ b/bin/tools/buildParaView3.4 @@ -34,8 +34,8 @@ #------------------------------------------------------------------------------ . $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions -PARAVIEW_SRC="ParaView3.3-cvs" -PARAVIEW_MAJOR_VERSION="3.3" +PARAVIEW_SRC=paraview-3.4 +PARAVIEW_MAJOR_VERSION=3.4 # User options: # ~~~~~~~~~~~~~ @@ -45,7 +45,7 @@ WITH_MPI=OFF MPI_MAX_PROCS=32 # Python support: -# note: script will try to determine python library. +# note: script will try to determine the appropriate python library. # If it fails, specify the path using the PYTHON_LIBRARY variable WITH_PYTHON=OFF PYTHON_LIBRARY="" @@ -60,18 +60,26 @@ WITH_MESA=OFF Script=${0##*/} usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<<USAGE + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE usage: ${0##*/} [OPTION] options: - -fast skip cmake for repeated builds - use with caution + -fast for repeated builds (-make -install) *use with caution* -mpi with mpi (if not already enabled) -python with python (if not already enabled) -mesa with mesa (if not already enabled) - -verbose verbose cmake output + -verbose verbose output in Makefiles -help +For finer control, the build stages can be also selected individually +(mutually exclusive) + -config + -make + -makedoc + -install + [-envpath] alter absolute paths in CMake files to use env variables + Build and install $PARAVIEW_SRC - run from folder above the ParaView source folder or place the ParaView source under \$WM_THIRD_PARTY_DIR @@ -80,57 +88,105 @@ USAGE exit 1 } -# options based on the script name: -case "$Script" in *-fast*) CMAKE_SKIP=ON;; esac +# add options based on script name: case "$Script" in *-mpi*) WITH_MPI=ON;; esac case "$Script" in *-python*) WITH_PYTHON=ON;; esac case "$Script" in *-mesa*) WITH_MESA=ON;; esac +runCONFIG=true +runMAKE=true +runMAKEDOC=true +runINSTALL=true +runENVPATH=false + # parse options while [ "$#" -gt 0 ] do - case "$1" in - -h | -help) - usage - ;; - -fast) - CMAKE_SKIP=YES - shift - ;; - -mpi) - WITH_MPI=ON - shift - ;; - -python) - WITH_PYTHON=ON - shift - ;; - -mesa) - WITH_MESA=ON - shift - ;; - -verbose) - VERBOSE=ON - shift - ;; - *) - usage "unknown option/argument: '$*'" - ;; - esac + case "$1" in + -h | -help) + usage + ;; + -config) # stage 1: config only + runCONFIG=true + runMAKE=false + runMAKEDOC=false + runINSTALL=false + shift + ;; + -make) # stage 2: make only + runCONFIG=false + runMAKE=true + runMAKEDOC=false + runINSTALL=false + shift + ;; + -makedoc) # stage 3: generate html documentation + runCONFIG=false + runMAKE=false + runMAKEDOC=true + runINSTALL=false + shift + ;; + -install) # stage 4: install only + runCONFIG=false + runMAKE=false + runMAKEDOC=false + runINSTALL=true + shift + ;; + -envpath) # optional: change cmake files to use env variables + runCONFIG=false + runMAKE=false + runMAKEDOC=false + runINSTALL=false + runENVPATH=true + shift + ;; + -fast) # shortcut for rebuild + runCONFIG=false + runMAKE=true + runMAKEDOC=false + runINSTALL=true + shift + ;; + -mpi) + WITH_MPI=ON + shift + ;; + -python) + WITH_PYTHON=ON + shift + ;; + -mesa) + WITH_MESA=ON + shift + ;; + -verbose) + VERBOSE=ON + shift + ;; + *) + usage "unknown option/argument: '$*'" + ;; + esac done # Set configure options #~~~~~~~~~~~~~~~~~~~~~~ -addVerbosity # set CMake verbosity +addVerbosity # verbose makefiles addMpiSupport # set MPI-specific options addPythonSupport # set Python-specific options addMesaSupport # set MESA-specific options +getPaths # discover where things are or should be put + # Build and install # ~~~~~~~~~~~~~~~~~ -buildParaView -installParaView +[ $runCONFIG = true ] && configParaView +[ $runMAKE = true ] && makeParaView +[ $runENVPATH = true ] && fixCMakeFiles +[ $runMAKEDOC = true ] && makeDocs +[ $runINSTALL = true ] && installParaView echo "done" - #------------------------------------------------------------------------------ diff --git a/bin/tools/buildParaViewFunctions b/bin/tools/buildParaViewFunctions index ef5a25923a0ab4d605cd2d4ab40a1720b23e0580..e3662ac19f62a001c97766a6b7436325c1baa4e8 100644 --- a/bin/tools/buildParaViewFunctions +++ b/bin/tools/buildParaViewFunctions @@ -31,299 +31,366 @@ #------------------------------------------------------------------------------ # ParaView_INST_DIR : location of the original sources -# ParaView_DIR : location of the compiled output +# ParaView_DIR : location of the build (for the ParaViewConfig.cmake) +# and the installed program + +# +# set CMake cache variables +# addCMakeVariable() { - while [ -n "$1" ] - do - CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1" - shift - done + while [ -n "$1" ] + do + CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1" + shift + done } +# +# verbose makefiles +# addVerbosity() { - [ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE + [ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE } +# +# define options for mpi support +# addMpiSupport() { - [ "$WITH_MPI" = ON ] || return - OBJ_ADD="$OBJ_ADD-mpi" - - addCMakeVariable PARAVIEW_USE_MPI=ON - addCMakeVariable VTK_USE_MPI=ON - addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include - addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so - addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun - addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS + [ "$WITH_MPI" = ON ] || return + OBJ_ADD="$OBJ_ADD-mpi" + + addCMakeVariable PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON + addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include + addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so + addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun + addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS } +# +# define options for python support +# addPythonSupport() { - [ "$WITH_PYTHON" = ON ] || return - OBJ_ADD="$OBJ_ADD-py" - - if pythonBin=$(which python 2>/dev/null) - then - if [ -n "$PYTHON_LIBRARY" ] - then - # check $PYTHON_LIBRARY if it has been set - if [ ! -e "$PYTHON_LIBRARY" ] - then - echo "*** Error: libpython not found at location specified " \ - "by PYTHON_LIBRARY=$PYTHON_LIBRARY" - fi - else - # Try to get $PYTHON_LIBRARY from dynamically linked binary - PYTHON_LIBRARY=$(ldd $pythonBin | \ - sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p') - - if [ ! -e "$PYTHON_LIBRARY" ] - then - echo "*** Error: Unable to determine path to python library." - fi - fi - - [ -e "$PYTHON_LIBRARY" ] || { - echo " Please set the variable PYTHON_LIBRARY to the full" - echo " path to (and including) libpython, or deactivate" - echo " python support by setting WITH_PYTHON=OFF" - exit 1 - } - - pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/') - pythonInclude=/usr/include/python$pythonMajor - - [ -e "$PYTHON_LIBRARY" ] || { - echo " Please set the variable PYTHON_LIBRARY to the full" - echo " path to (and including) libpython, or deactivate" - echo " python support by setting WITH_PYTHON=OFF" - exit 1 - } - - # note - we could also allow for a PYTHON_INCLUDE variable ... - [ -e "$pythonInclude" ] || { - echo " No python include headers found" - echo " Please install python headers or deactivate " - echo " python support by setting WITH_PYTHON=OFF" - exit 1 - } - - addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON - addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude - addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY - - echo "----" - echo "Python information:" - echo " executable : $pythonBin" - echo " version : $pythonMajor" - echo " include path : $pythonInclude" - echo " library : $PYTHON_LIBRARY" - - unset pythonBin pythonInclude pythonMajor - else - echo "*** Error: python not installed" - echo "*** Deactivate python support by setting WITH_PYTHON=OFF" - exit 1 - fi + [ "$WITH_PYTHON" = ON ] || return + OBJ_ADD="$OBJ_ADD-py" + + if pythonBin=$(which python 2>/dev/null) + then + if [ -n "$PYTHON_LIBRARY" ] + then + # check $PYTHON_LIBRARY if it has been set + if [ ! -e "$PYTHON_LIBRARY" ] + then + echo "*** Error: libpython not found at location specified " \ + "by PYTHON_LIBRARY=$PYTHON_LIBRARY" + fi + else + # Try to get $PYTHON_LIBRARY from dynamically linked binary + PYTHON_LIBRARY=$(ldd $pythonBin | \ + sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p') + + if [ ! -e "$PYTHON_LIBRARY" ] + then + echo "*** Error: Unable to determine path to python library." + fi + fi + + [ -e "$PYTHON_LIBRARY" ] || { + echo " Please set the variable PYTHON_LIBRARY to the full" + echo " path to (and including) libpython, or deactivate" + echo " python support by setting WITH_PYTHON=OFF" + exit 1 + } + + pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/') + pythonInclude=/usr/include/python$pythonMajor + + [ -e "$PYTHON_LIBRARY" ] || { + echo " Please set the variable PYTHON_LIBRARY to the full" + echo " path to (and including) libpython, or deactivate" + echo " python support by setting WITH_PYTHON=OFF" + exit 1 + } + + # note - we could also allow for a PYTHON_INCLUDE variable ... + [ -e "$pythonInclude" ] || { + echo " No python include headers found" + echo " Please install python headers or deactivate " + echo " python support by setting WITH_PYTHON=OFF" + exit 1 + } + + addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON + addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude + addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY + + echo "----" + echo "Python information:" + echo " executable : $pythonBin" + echo " version : $pythonMajor" + echo " include path : $pythonInclude" + echo " library : $PYTHON_LIBRARY" + + unset pythonBin pythonInclude pythonMajor + else + echo "*** Error: python not installed" + echo "*** Deactivate python support by setting WITH_PYTHON=OFF" + exit 1 + fi } +# +# define options for mesa support +# addMesaSupport() { - [ "$WITH_MESA" = ON ] || return + [ "$WITH_MESA" = ON ] || return - MESA_INCLUDE_DIR=/usr/include/GL - MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so + MESA_INCLUDE_DIR=/usr/include/GL + MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so - if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ] - then - OBJ_ADD="$OBJ_ADD-mesa" + if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ] + then + OBJ_ADD="$OBJ_ADD-mesa" - addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON - addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR - addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY + addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON + addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR + addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY - else - echo "*** Error: no MESA information found" - exit 1 - fi + else + echo "*** Error: no MESA information found" + exit 1 + fi } -buildParaView() +# +# discover where things are or should be put +# +getPaths() { - # set paraview environment - for i in $PWD $WM_THIRD_PARTY_DIR - do - ParaView_INST_DIR=$i/$PARAVIEW_SRC - [ -d $ParaView_INST_DIR ] && break - done - - if [ ! -d "$ParaView_INST_DIR" ] - then - # last chance: maybe already in the paraview directory - [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD - - [ -d "$ParaView_INST_DIR" ] || { - echo "did not find $PARAVIEW_SRC in these directories:" - echo " PWD=$PWD" - echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR" - echo "abort build" - exit 1 - } - fi - - - # ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD - ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER - - # shortcut for repeated builds - use with caution - if [ "$CMAKE_SKIP" = YES ] - then - - # change to build/install folder - cd $ParaView_DIR || exit 1 - - else - - # remove any existing build folder and recreate - rm -rf $ParaView_DIR - mkdir -p $ParaView_DIR - cd $ParaView_DIR - - echo "----" - echo "Building $PARAVIEW_SRC" - echo " MPI support : $WITH_MPI" - echo " Python support : $WITH_PYTHON" - echo " MESA support : $WITH_MESA" - echo " Source : $ParaView_INST_DIR" - echo " Target : $ParaView_DIR" - echo "----" - - # make paraview - cmake \ - -DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR \ - $CMAKE_VARIABLES \ - $ParaView_INST_DIR - fi - - # change to build folder - echo " Starting make" - - if [ -r /proc/cpuinfo ] - then - WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l) - - if [ $WM_NCOMPPROCS -gt 8 ] - then - WM_NCOMPPROCS=8 - fi - - make -j $WM_NCOMPPROCS - else - make - fi + # set paraview environment + for i in $PWD $WM_THIRD_PARTY_DIR + do + ParaView_INST_DIR=$i/$PARAVIEW_SRC + [ -d $ParaView_INST_DIR ] && break + done + + if [ ! -d "$ParaView_INST_DIR" ] + then + # last chance: maybe already in the paraview directory + [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD + + [ -d "$ParaView_INST_DIR" ] || { + echo "did not find $PARAVIEW_SRC in these directories:" + echo " PWD=$PWD" + echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR" + echo "abort build" + exit 1 + } + fi + + # ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD + ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER + echo "ParaView_DIR=$ParaView_DIR" } -# adjust hard-links +# +# configure via cmake, but don't actually build anything +# +configParaView() +{ + # remove any existing build folder and recreate + if [ -d $ParaView_DIR ] + then + echo "removing old build/install directory" + rm -rf $ParaView_DIR + fi + mkdir -p $ParaView_DIR + + cd $ParaView_DIR + + echo "----" + echo "Configuring $PARAVIEW_SRC" + echo " MPI support : $WITH_MPI" + echo " Python support : $WITH_PYTHON" + echo " MESA support : $WITH_MESA" + echo " Source : $ParaView_INST_DIR" + echo " Target : $ParaView_DIR" + echo "----" + echo + echo cmake \ + -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \ + $CMAKE_VARIABLES \ + ../.. + echo + echo "----" + echo + + # run cmake to create Makefiles + cmake \ + -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \ + $CMAKE_VARIABLES \ + ../.. + +} + + +# +# invoke make +# also link bin/ to lib/paraview-* for development without installation +# +makeParaView() +{ + cd $ParaView_DIR || exit 1 # change to build folder + echo " Starting make" + + if [ -r /proc/cpuinfo ] + then + WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l) + [ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8 + + time make -j $WM_NCOMPPROCS + else + time make + fi + echo " Done make" + + echo " For quicker development, linking lib/paraview-$PARAVIEW_MAJOR_VERSION/ -> bin/" + rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION + mkdir lib 2>/dev/null + ( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION ) +} + + +# +# adjust hard-links (internal function) # Note: use loop with grep to avoid touching too many files -fixCMakeHardLinks() +# +fixHardLinks() +{ + envName=$1 + string=$2 + shift 2 + + echo "-- Replacing path hard links for \$$envName" + + for fileSpec + do + echo -n " $fileSpec: " + for i in $(find . -type f -iname "$fileSpec") + do + if grep -q "$string" $i + then + echo -n "#" + sed -i "s,$string,\$ENV{$envName},g" $i + fi + done + echo + done +} + + +# +# replace absolute paths with environment variables +# This triggers a partial (or even a full) rebuild, but might let us +# find our files later if we relocate the build +# +fixCMakeFiles() { - fileSpec=$1 - string=$2 - envName=$3 - - echo -n " for \$$envName " - for i in $(find . -type f -iname "$fileSpec") - do - if grep -q "$string" $i - then - echo -n "#" - sed -i "s,$string,\$ENV{$envName},g" $i - fi - done - echo + cd $ParaView_DIR || exit 1 # change to build folder + + # Replace path with env variable: ParaView_DIR + fixHardLinks ParaView_DIR "$ParaView_DIR" '*.cmake' + + # Replace path with env variable: ParaView_INST_DIR + fixHardLinks ParaView_INST_DIR "$ParaView_INST_DIR" '*.cmake' + + # Replace path with env variable: MPI_ARCH_PATH + if [ "$WITH_MPI" = ON ] + then + fixHardLinks MPI_ARCH_PATH "$MPI_ARCH_PATH" '*.cmake' + fi + + # Replace path with env variable: CMAKE_HOME + if [ -r "$CMAKE_HOME" ] + then + fixHardLinks CMAKE_HOME "$CMAKE_HOME" '*cmake*' + fi + + # Replace path with env variable: WM_COMPILER_DIR + # (include cmake.check_cache) + # This triggers a complete rebuild (with cmake-2.6.2), but is likely + # needed when redistributing files + fixHardLinks WM_COMPILER_DIR "$WM_COMPILER_DIR" '*cmake*' } +# +# make html documentation (mostly just for the readers/writers) +# +makeDocs() +{ + cd $ParaView_DIR || exit 1 # change to build folder + echo " Creating html documentation" + + make HTMLDocumentation +} + + +# +# actually install the program +# installParaView() { - if [ ! -e "$ParaView_DIR/bin/paraview" ] - then - echo " Cannot install - no paraview binary found" - return - fi - echo " Build complete" - - cd $ParaView_DIR - - echo " Replacing path hard links" - - # Replace local ParaView_INST_DIR path with ParaView_INST_DIR - # environment variable - fixCMakeHardLinks '*.cmake' "$ParaView_INST_DIR" ParaView_INST_DIR - - # Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH - # environment variable - if [ "$WITH_MPI" = ON ] - then - fixCMakeHardLinks '*.cmake' "$MPI_ARCH_PATH" MPI_ARCH_PATH - fi - - # Replace local CMAKE_HOME path with CMAKE_HOME - # environment variable - if [ -r "$CMAKE_HOME" ] - then - fixCMakeHardLinks '*cmake*' "$CMAKE_HOME" CMAKE_HOME - fi - - # Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR - # environment variable - fixCMakeHardLinks '*cmake*' "$WM_COMPILER_DIR" WM_COMPILER_DIR - - # create a softlink to the $ParaView_DIR/bin folder - # - workaround for chosen install location - echo " Creating lib/paraview-$PARAVIEW_MAJOR_VERSION soft link to 'bin'" - rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION - [ -d lib ] || mkdir lib - ( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION ) - - # info on symlinks to screen - echo "" - echo " ---" - echo " Installation complete" - echo " Set environment variables:" - echo " - ParaView_INST_DIR to $ParaView_INST_DIR" - echo " - ParaView_DIR to $ParaView_DIR" - echo " - PV_PLUGIN_PATH to $FOAM_LIBBIN" - echo " Add $ParaView_DIR/bin to PATH" - # echo " Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH" - echo " ---" + cd $ParaView_DIR || exit 1 # change to build folder + echo " Installing ParaView to $ParaView_DIR" + + echo "disabled 'make install' for now, just use links" + + # about.txt may be missing + paraviewLibDir="$ParaView_DIR/lib/paraview-$PARAVIEW_MAJOR_VERSION" + if [ -d "$paraviewLibDir" -a ! -e "$paraviewLibDir/about.txt" ] + then + echo "paraview-$PARAVIEW_MAJOR_VERSION installed - $(date)" > $paraviewLibDir/about.txt + fi + +cat<< INFO + --- + Installation complete + Set environment variables: + + export ParaView_INST_DIR=$ParaView_INST_DIR + export ParaView_DIR=$ParaView_DIR + export PV_PLUGIN_PATH=$FOAM_LIBBIN + export PATH=\$ParaView_DIR/bin:\$PATH + --- +INFO } # clear all the variables used before using any of the functions - unset VERBOSE -unset WITH_MPI -unset WITH_MESA -unset WITH_PYTHON -unset PYTHON_LIBRARY +unset WITH_MPI WITH_MESA +unset WITH_PYTHON PYTHON_LIBRARY unset CMAKE_VARIABLES -unset CMAKE_SKIP unset OBJ_ADD # start with these general settings addCMakeVariable VTK_USE_TK=FALSE -addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON -addCMakeVariable VTK_USE_RPATH:BOOL=OFF +addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON VTK_USE_RPATH:BOOL=OFF addCMakeVariable CMAKE_BUILD_TYPE:STRING=Release +# include development files in "make install" +addCMakeVariable PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON + # ----------------------------------------------------------------- end-of-file diff --git a/etc/apps/paraview3/bashrc b/etc/apps/paraview3/bashrc index 8ff878105138c45aa083e88fd34dedd9a741384e..cfa2f113376bddbb38f35bc43722575f7f2c4f62 100644 --- a/etc/apps/paraview3/bashrc +++ b/etc/apps/paraview3/bashrc @@ -26,38 +26,49 @@ # paraview3/bashrc # # Description -# Setup file for ParaView3. +# Setup file for paraview-3.x # Sourced from OpenFOAM-?.?/etc/bashrc # +# Note +# The env. variable 'ParaView_DIR' is required for building plugins #------------------------------------------------------------------------------ -export CMAKE_HOME=$WM_THIRD_PARTY_DIR/cmake-2.4.6/platforms/$WM_ARCH +# determine the cmake to be used +unset CMAKE_HOME +for cmake in cmake-2.6.2 cmake-2.4.6 +do + cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH + if [ -r $cmake ] + then + export CMAKE_HOME=$cmake + export PATH=$CMAKE_HOME/bin:$PATH + break + fi +done -if [ -r $CMAKE_HOME ] -then - export PATH=$CMAKE_HOME/bin:$PATH -else - unset CMAKE_HOME -fi +paraviewMajor=paraview-3.5 +export ParaView_VERSION=3.5-cvs -export ParaView_VERSION="3.3-cvs" - -export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION +export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER -if [ "$PYTHONPATH" ] +# add in python libraries if required +paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping +if [ -r $paraviewPython ] then - export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 -else - export PYTHONPATH=$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 + if [ "$PYTHONPATH" ] + then + export PYTHONPATH=$PYTHONPATH:$paraviewPython:$ParaView_DIR/lib/$paraviewMajor + else + export PYTHONPATH=$paraviewPython:$ParaView_DIR/lib/$paraviewMajor + fi fi - if [ -r $ParaView_DIR ] then export PATH=$ParaView_DIR/bin:$PATH - export LD_LIBRARY_PATH=$ParaView_DIR/bin:$LD_LIBRARY_PATH export PV_PLUGIN_PATH=$FOAM_LIBBIN fi +unset cmake paraviewMajor paraviewPython # ----------------------------------------------------------------------------- diff --git a/etc/apps/paraview3/cshrc b/etc/apps/paraview3/cshrc index 636b10eb75d0b806d0844653c26d6e8c37c6498d..875d0d1655f5a8c1bcfcb4312609953710aa8a0a 100644 --- a/etc/apps/paraview3/cshrc +++ b/etc/apps/paraview3/cshrc @@ -26,34 +26,44 @@ # paraview3/cshrc # # Description -# Startup File for Paraview3 +# Startup File for paraview-3.x # Sourced from OpenFOAM-?.?/etc/cshrc # +# Note +# The env. variable 'ParaView_DIR' is required for building plugins #------------------------------------------------------------------------------ -setenv CMAKE_HOME $WM_THIRD_PARTY_DIR/cmake-2.4.6/platforms/$WM_ARCH +# determine the cmake to be used +unsetenv CMAKE_HOME +foreach cmake ( cmake-2.6.2 cmake-2.4.6 ) + set cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH + if ( -r $cmake ) then + setenv CMAKE_HOME $cmake + set path=($CMAKE_HOME/bin $path) + break + endif +end -if ( -r $CMAKE_HOME ) then - set path=($CMAKE_HOME/bin $path) -else - unsetenv CMAKE_HOME -endif - -setenv ParaView_VERSION 3.3-cvs +set paraviewMajor=paraview-3.5 +setenv ParaView_VERSION 3.5-cvs -setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION +setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION setenv ParaView_DIR $ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER -if ($?PYTHONPATH) then - setenv PYTHONPATH ${PYTHONPATH}:$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 -else - setenv PYTHONPATH $ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 +# add in python libraries if required +set paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping +if ( -r $paraviewPython ) then + if ($?PYTHONPATH) then + setenv PYTHONPATH ${PYTHONPATH}:$paraviewPython:$ParaView_DIR/lib/${paraviewMajor} + else + setenv PYTHONPATH $paraviewPython:$ParaView_DIR/lib/${paraviewMajor} + endif endif if ( -r $ParaView_INST_DIR ) then set path=($ParaView_DIR/bin $path) - setenv LD_LIBRARY_PATH $ParaView_DIR/bin:$LD_LIBRARY_PATH setenv PV_PLUGIN_PATH $FOAM_LIBBIN endif +unset cmake paraviewMajor paraviewPython # ----------------------------------------------------------------------------- diff --git a/etc/bashrc b/etc/bashrc index ec96457be247718cd103bef4fe42eac681bcb145..35044f5b019600d90f81a57c7f03496f7a071e25 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -91,7 +91,7 @@ export WM_COMPILER_LIB_ARCH= # WM_JAVAC_OPTION = Opt | Debug : ${WM_JAVAC_OPTION:=Opt}; export WM_JAVAC_OPTION -# WM_MPLIB = | OPENMPI| LAM | MPICH | MPICH-GM | HPMPI | GAMMA | MPI +# WM_MPLIB = | OPENMPI | LAM | MPICH | MPICH-GM | HPMPI | GAMMA | MPI : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB diff --git a/src/Allwmake b/src/Allwmake index f6e7907e32721347fec0d57a42d1210ae88c93c2..c451cff8dd569337fee1e93b2aea9af6d559547c 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -2,11 +2,8 @@ cd ${0%/*} || exit 1 # run from this directory set -x -# update version string if under Git -git describe 2> /dev/null | \ -(read project_string \ - && sed -e 's/WM_PROJECT_VERSION/\"'"${project_string}"'"/' \ - OpenFOAM/global/global_raw.C >OpenFOAM/global/global.C) +# force update of Foam::FOAMversion string (git tag or $WM_PROJECT_VERSION) +/bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null wmakeLnInclude -f OpenFOAM wmakeLnInclude -f OSspecific/$WM_OS diff --git a/src/OSspecific/Unix/Unix.C b/src/OSspecific/Unix/Unix.C index 8f4ddafdb827b6b63e7524764478a2fd0c93ff7e..271d4a442b57ead63fdb449c16efedb505c5c34d 100644 --- a/src/OSspecific/Unix/Unix.C +++ b/src/OSspecific/Unix/Unix.C @@ -211,7 +211,7 @@ bool Foam::chDir(const fileName& dir) } -Foam::fileName Foam::dotFoam(const fileName& name) +Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory) { // Search user files: // ~~~~~~~~~~~~~~~~~~ @@ -268,6 +268,15 @@ Foam::fileName Foam::dotFoam(const fileName& name) } // Not found + // abort if the file is mandatory, otherwise return null + if (mandatory) + { + cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :" + " could not find mandatory file\n '" + << name.c_str() << "'\n\n" << std::endl; + ::exit(1); + } + return fileName::null; } diff --git a/src/OSspecific/Unix/regExp.C b/src/OSspecific/Unix/regExp.C index 62c69512b712f65639008e14bac85a3b2c8d8b96..e3ad4a11af4cb6e7b1e5cf553fcfe62a3255e923 100644 --- a/src/OSspecific/Unix/regExp.C +++ b/src/OSspecific/Unix/regExp.C @@ -37,15 +37,20 @@ License void Foam::regExp::compile(const char* pat) const { clear(); - preg_ = new regex_t; - if (regcomp(preg_, pat, REG_EXTENDED) != 0) + // avoid NULL and zero-length patterns + if (pat && *pat) { - FatalErrorIn - ( - "regExp::compile(const char*)" - ) << "Failed to compile regular expression '" << pat << "'" - << exit(FatalError); + preg_ = new regex_t; + + if (regcomp(preg_, pat, REG_EXTENDED) != 0) + { + FatalErrorIn + ( + "regExp::compile(const char*)" + ) << "Failed to compile regular expression '" << pat << "'" + << exit(FatalError); + } } } @@ -60,6 +65,7 @@ void Foam::regExp::clear() const } } + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::regExp::regExp() @@ -83,6 +89,7 @@ Foam::regExp::regExp(const char* pat) compile(pat); } + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::regExp::~regExp() @@ -90,6 +97,7 @@ Foam::regExp::~regExp() clear(); } + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // int Foam::regExp::ngroups() const @@ -110,6 +118,7 @@ bool Foam::regExp::match regmatch_t pmatch[1]; // match and also verify that the entire string was matched + // pmatch[0] is the entire match if ( regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0 @@ -141,6 +150,8 @@ bool Foam::regExp::match regmatch_t pmatch[nmatch]; // match and also verify that the entire string was matched + // pmatch[0] is the entire match + // pmatch[1..] are the (...) sub-groups if ( regexec(preg_, str.c_str(), nmatch, pmatch, 0) == 0 @@ -179,8 +190,8 @@ bool Foam::regExp::match return false; } -// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // void Foam::regExp::operator=(const string& pat) { @@ -193,4 +204,5 @@ void Foam::regExp::operator=(const char* pat) compile(pat); } + // ************************************************************************* // diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index a9708a3c30773a099382a2d87d624b088bb40406..9162050cc0a60e7d85f254bf9348a8b8078d9a1c 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -1,5 +1,4 @@ -global/global.C - +global/global.Cver global/dimensionedConstants/dimensionedConstants.C global/argList/argList.C global/clock/clock.C @@ -290,7 +289,6 @@ $(tetCell)/tetCell.C cellModeller = $(meshShapes)/cellModeller $(cellModeller)/cellModeller.C -$(cellModeller)/cellModellerIO.C cellModel = $(meshShapes)/cellModel $(cellModel)/cellModel.C diff --git a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.C b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.C index 33d7fd3723255e24f6aa7207db3e678b309fdc93..b6e52f46860ae265acae8ce0eef7040fd5b8a394 100644 --- a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.C @@ -28,22 +28,15 @@ Description #include "Dictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Null constructor template<class T> -Dictionary<T>::Dictionary() +Foam::Dictionary<T>::Dictionary() {} -// Copy constructor template<class T> -Dictionary<T>::Dictionary(const Dictionary& dict) +Foam::Dictionary<T>::Dictionary(const Dictionary& dict) : DictionaryBase<IDLList<T>, T>(dict) {} @@ -52,10 +45,10 @@ Dictionary<T>::Dictionary(const Dictionary& dict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class T> -bool Dictionary<T>::erase(const word& Keyword) +bool Foam::Dictionary<T>::erase(const word& keyword) { T* tPtr; - if ((tPtr = this->remove(Keyword))) + if (tPtr = this->remove(keyword)) { delete tPtr; return true; @@ -69,6 +62,4 @@ bool Dictionary<T>::erase(const word& Keyword) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H index 3b985482e7bdbec929388d8d4dd62c9efbb10094..90af1383f4a485307b002ee9fcd71c32e4ea9eeb 100644 --- a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H @@ -27,8 +27,10 @@ Class Description Gerneral purpose template dictionary class which manages the storage - associated with it. It is derived from DictionaryBase instantiated on - a memory managed form of intrusive doubly-linked list of \<T\>. + associated with it. + + It is derived from DictionaryBase instantiated on a memory managed form + of intrusive doubly-linked list of \<T\>. SourceFiles Dictionary.C @@ -47,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class Dictionary Declaration + Class Dictionary Declaration \*---------------------------------------------------------------------------*/ template<class T> @@ -69,11 +71,9 @@ public: // Member functions - // Editing - - //- Remove an entry specified by keyword from the dictionary - // and delete it - bool erase(const word& keyword); + //- Remove an entry specified by keyword and delete the pointer. + // Returns true if the keyword was found + bool erase(const word& keyword); }; diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C index 4349973c3ce236f4077046a70a95ee50639534dc..95112712081129e65f9331a7592fcb89ab9429ad 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C @@ -26,15 +26,10 @@ License #include "DictionaryBase.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::addEntries() +void Foam::DictionaryBase<IDLListType, T>::addEntries() { for ( @@ -51,12 +46,15 @@ void DictionaryBase<IDLListType, T>::addEntries() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class IDLListType, class T> -DictionaryBase<IDLListType, T>::DictionaryBase() +Foam::DictionaryBase<IDLListType, T>::DictionaryBase() {} template<class IDLListType, class T> -DictionaryBase<IDLListType, T>::DictionaryBase(const DictionaryBase& dict) +Foam::DictionaryBase<IDLListType, T>::DictionaryBase +( + const DictionaryBase& dict +) : IDLListType(dict) { @@ -66,17 +64,20 @@ DictionaryBase<IDLListType, T>::DictionaryBase(const DictionaryBase& dict) template<class IDLListType, class T> template<class INew> -DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is, const INew& inewt) +Foam::DictionaryBase<IDLListType, T>::DictionaryBase +( + Istream& is, + const INew& iNew +) : - IDLListType(is, inewt) + IDLListType(is, iNew) { addEntries(); } -// Istream constructor template<class IDLListType, class T> -DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is) +Foam::DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is) : IDLListType(is) { @@ -88,25 +89,60 @@ DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is) // Find and return T template<class IDLListType, class T> -bool DictionaryBase<IDLListType, T>::found(const word& keyword) const +bool Foam::DictionaryBase<IDLListType, T>::found(const word& keyword) const { return hashedTs_.found(keyword); } -// Find and return T* +// Find and return T*, return NULL if not found template<class IDLListType, class T> -const T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) const +const T* Foam::DictionaryBase<IDLListType, T>::lookupPtr +( + const word& keyword +) const +{ + typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword); + + if (iter != hashedTs_.end()) + { + return *iter; + } + else + { + return NULL; + } +} + + +// Find and return T*, return NULL if not found +template<class IDLListType, class T> +T* Foam::DictionaryBase<IDLListType, T>::lookupPtr(const word& keyword) +{ + typename HashTable<T*>::iterator iter = hashedTs_.find(keyword); + + if (iter != hashedTs_.end()) + { + return *iter; + } + else + { + return NULL; + } +} + + +// Find and return T*, FatalError if keyword not found +template<class IDLListType, class T> +const T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword) const { typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword); if (iter == hashedTs_.end()) { - // If keyword not found print error message ... FatalErrorIn ( - "DictionaryBase<IDLListType, T>::" - "lookup(const word& keyword) const" + "DictionaryBase<IDLListType, T>::lookup(const word&) const" ) << keyword << " is undefined" << exit(FatalError); } @@ -115,18 +151,17 @@ const T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) const } -// Find and return T* +// Find and return T*, FatalError if keyword not found template<class IDLListType, class T> -T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) +T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword) { typename HashTable<T*>::iterator iter = hashedTs_.find(keyword); if (iter == hashedTs_.end()) { - // If keyword not found print error message ... FatalErrorIn ( - "DictionaryBase<IDLListType, T>::lookup(const word& keyword)" + "DictionaryBase<IDLListType, T>::lookup(const word&)" ) << keyword << " is undefined" << exit(FatalError); } @@ -137,7 +172,7 @@ T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) // Return the table of contents template<class IDLListType, class T> -wordList DictionaryBase<IDLListType, T>::toc() const +Foam::wordList Foam::DictionaryBase<IDLListType, T>::toc() const { wordList keywords(this->size()); @@ -158,26 +193,28 @@ wordList DictionaryBase<IDLListType, T>::toc() const // Add at head of dictionary template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr) +void Foam::DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr) { - IDLListType::insert(tPtr); + // NOTE: we should probably check that HashTable::insert actually worked hashedTs_.insert(keyword, tPtr); + IDLListType::insert(tPtr); } // Add at tail of dictionary template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr) +void Foam::DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr) { - IDLListType::append(tPtr); + // NOTE: we should probably check that HashTable::insert actually worked hashedTs_.insert(keyword, tPtr); + IDLListType::append(tPtr); } template<class IDLListType, class T> -T* DictionaryBase<IDLListType, T>::remove(const word& Keyword) +T* Foam::DictionaryBase<IDLListType, T>::remove(const word& keyword) { - typename HashTable<T*>::iterator iter = hashedTs_.find(Keyword); + typename HashTable<T*>::iterator iter = hashedTs_.find(keyword); if (iter != hashedTs_.end()) { @@ -192,19 +229,29 @@ T* DictionaryBase<IDLListType, T>::remove(const word& Keyword) } -//- Clear the dictionary template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::clear() +void Foam::DictionaryBase<IDLListType, T>::clear() { IDLListType::clear(); hashedTs_.clear(); } +template<class IDLListType, class T> +void Foam::DictionaryBase<IDLListType, T>::transfer +( + DictionaryBase<IDLListType, T>& dict +) +{ + IDLListType::transfer(dict); + hashedTs_.transfer(dict.hashedTs_); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::operator= +void Foam::DictionaryBase<IDLListType, T>::operator= ( const DictionaryBase<IDLListType, T>& dict ) @@ -218,25 +265,11 @@ void DictionaryBase<IDLListType, T>::operator= } IDLListType::operator=(dict); - this->hashedTs_.clear(); - - for - ( - typename IDLListType::iterator iter = this->begin(); - iter != this->end(); - ++iter - ) - { - this->hashedTs_.insert((*iter).keyword(), &(*iter)); - } + this->addEntries(); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "DictionaryBaseIO.C" diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H index 8288cdf5cfbf5f28feddfe19c73bcb3e249a2b34..f14785bcd555ae5a8737623024e6d15de146d82f 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H @@ -29,12 +29,12 @@ Description Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it holds. - The double templating allows for the instantiation of forms with and + The double templating allows for the instantiation of forms with or without storage management. Note The IDLListType parameter should itself be a template but this confused - gcc 2.95.2 so it has to be instantiated for T when an intantiation of + gcc 2.95.2 so it has to be instantiated for T when an instantiation of DictionaryBase is requested See Also @@ -67,7 +67,7 @@ Ostream& operator<<(Ostream&, const DictionaryBase<IDLListType, T>&); /*---------------------------------------------------------------------------*\ - Class DictionaryBase Declaration + Class DictionaryBase Declaration \*---------------------------------------------------------------------------*/ template<class IDLListType, class T> @@ -77,7 +77,7 @@ class DictionaryBase { // Private data - //- HashTable of the enries held on the DL-list for quick lookup + //- HashTable of the entries held on the IDLListType for quick lookup HashTable<T*> hashedTs_; @@ -99,10 +99,10 @@ public: //- Construct from Istream using given Istream constructor class template<class INew> - DictionaryBase(Istream& is, const INew& inewt); + DictionaryBase(Istream&, const INew&); - //- Construct from Istream - DictionaryBase(Istream& is); + //- Construct from Istream using default Istream constructor class + DictionaryBase(Istream&); // Member functions @@ -110,7 +110,13 @@ public: // Search and lookup //- Search DictionaryBase for given keyword - bool found(const word& keyword) const; + bool found(const word&) const; + + //- Find and return an entry if present, otherwise return NULL + const T* lookupPtr(const word&) const; + + //- Find and return an entry if present, otherwise return NULL + T* lookupPtr(const word&); //- Find and return entry const T* lookup(const word&) const; @@ -125,17 +131,21 @@ public: // Editing //- Add at head of dictionary - void insert(const word& keyword, T*); + void insert(const word&, T*); //- Add at tail of dictionary - void append(const word& keyword, T*); + void append(const word&, T*); - //- Remove and return entry specified by keyword - T* remove(const word& keyword); + //- Remove and return entry specified by keyword. + // Return NULL if the keyword was not found. + T* remove(const word&); //- Clear the dictionary void clear(); + //- Transfer the contents of the argument into this DictionaryBase + // and annull the argument. + void transfer(DictionaryBase<IDLListType, T>&); // Member operators diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C index 15854c515bf653dcb8a09ee0377dd59585be5673..6af2b1622dcc46f760622704bcfffba39c995b40 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C @@ -30,15 +30,13 @@ Description #include "DictionaryBase.H" #include "IOstreams.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * // template<class IDLListType, class T> -Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict) +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const DictionaryBase<IDLListType, T>& dict) { for ( @@ -53,7 +51,7 @@ Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict) if (!os.good()) { Info - << "operator<<(Ostream& os, const DictionaryBase&) : " + << "operator<<(Ostream&, const DictionaryBase&) : " << "Can't write entry for DictionaryBase" << endl; @@ -67,6 +65,4 @@ Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C index b2b7861eb4f00e3f4bee21689a5f36fc2df18465..4b0a48ac900002db096e6f544e8aa9b742306a97 100644 --- a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C @@ -26,20 +26,15 @@ License #include "PtrDictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class T> -PtrDictionary<T>::PtrDictionary() +Foam::PtrDictionary<T>::PtrDictionary() {} template<class T> -PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict) +Foam::PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict) : DictionaryBase<DLPtrList<T>, T>(dict) {} @@ -47,14 +42,14 @@ PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict) template<class T> template<class INew> -PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew) +Foam::PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew) : DictionaryBase<DLPtrList<T>, T>(is, iNew) {} template<class T> -PtrDictionary<T>::PtrDictionary(Istream& is) +Foam::PtrDictionary<T>::PtrDictionary(Istream& is) : DictionaryBase<DLPtrList<T>, T>(is) {} @@ -62,6 +57,4 @@ PtrDictionary<T>::PtrDictionary(Istream& is) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H index 3396236515c1a1ec08ef83318e32532703e9b5e8..9c7da2f4de329a18c8aa06c98041d169a32eb521 100644 --- a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H @@ -27,8 +27,10 @@ Class Description Template dictionary class which does not manages the storage - associated with it. It is derived from DictionaryBase instantiated on - a non-memory managed form of intrusive doubly-linked list of T. + associated with it. + + It is derived from DictionaryBase instantiated on a non-memory managed + form of intrusive doubly-linked list of T. SourceFiles PtrDictionary.C @@ -47,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class PtrDictionary Declaration + Class PtrDictionary Declaration \*---------------------------------------------------------------------------*/ template<class T> diff --git a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C index 9712b747351431b59989a0ba9d88a97239fbd773..8f29af262bc361ddef8e5ebc9b25e6887e0c1460 100644 --- a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C @@ -26,22 +26,15 @@ License #include "UDictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Null constructor template<class T> -UDictionary<T>::UDictionary() +Foam::UDictionary<T>::UDictionary() {} -// Copy constructor template<class T> -UDictionary<T>::UDictionary(const UDictionary& dict) +Foam::UDictionary<T>::UDictionary(const UDictionary& dict) : DictionaryBase<UIDLList<T>, T>(dict) {} @@ -49,6 +42,4 @@ UDictionary<T>::UDictionary(const UDictionary& dict) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.H b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.H index fb30237d40d91768a8b9ba850bfe51e35ddd98ac..5cc4d301f4e3f2aab7d1558d337111b6ce9077a4 100644 --- a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.H @@ -49,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class UDictionary Declaration + Class UDictionary Declaration \*---------------------------------------------------------------------------*/ template<class T> diff --git a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C index 3a4686fbf6aa659ad4c5e9d8046099de1e7a4ffd..6aa7da72abd4c50cbcca4ca9c2d37cf796f0c6a3 100644 --- a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C @@ -26,22 +26,15 @@ License #include "UPtrDictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Null constructor template<class T> -UPtrDictionary<T>::UPtrDictionary() +Foam::UPtrDictionary<T>::UPtrDictionary() {} -// Copy constructor template<class T> -UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict) +Foam::UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict) : DictionaryBase<DLList<T*>, T>(dict) {} @@ -49,6 +42,4 @@ UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.H b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.H index 2caac9efac685a5e5e88658f73edbc897a6e1980..99aee0ac562ce84c04c8ef25b823cca530d9e3b7 100644 --- a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.H @@ -27,8 +27,10 @@ Class Description Template dictionary class which does not manages the storage - associated with it. It is derived from DictionaryBase instantiated on - a non-memory managed form of intrusive doubly-linked list of \<T\>. + associated with it. + + It is derived from DictionaryBase instantiated on a non-memory managed + form of intrusive doubly-linked list of \<T\>. SourceFiles UPtrDictionary.C @@ -47,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class UPtrDictionary Declaration + Class UPtrDictionary Declaration \*---------------------------------------------------------------------------*/ template<class T> diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index d9d74fd1ad4fbcb79040a38183b1e1b357c03c62..37c595222e5c1f6a2aca308cdb356f538b7a0092 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -456,6 +456,14 @@ void HashTable<T, Key, Hash>::clear() } +template<class T, class Key, class Hash> +void HashTable<T, Key, Hash>::clearStorage() +{ + clear(); + resize(0); +} + + template<class T, class Key, class Hash> void HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht) { diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 701d8456156572dd54f878b5dc7748636505a7be..798dad6367882f2bee2e94d12e2ac74b395b7508 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -54,6 +54,7 @@ template<class T> class List; template<class T, class Key, class Hash> class HashTable; +template<class T, class Key, class Hash> class HashPtrTable; template<class T, class Key, class Hash> Istream& operator>> ( @@ -102,7 +103,7 @@ class HashTable //- Construct given key, next pointer and object inline hashedEntry ( - const Key& key, + const Key&, hashedEntry* next, const T& newEntry ); @@ -127,7 +128,7 @@ class HashTable // Private Member Functions //- Assign a new hashedEntry to a possibly already existing key - bool set(const Key& key, const T& newElmt, bool protect); + bool set(const Key&, const T& newElmt, bool protect); public: @@ -173,15 +174,15 @@ public: inline label size() const; //- Return true if hashedEntry is found in table - bool found(const Key& key) const; + bool found(const Key&) const; //- Find and return an iterator set at the hashedEntry // If not found iterator = end() - iterator find(const Key& key); + iterator find(const Key&); //- Find and return an const_iterator set at the hashedEntry // If not found iterator = end() - const_iterator find(const Key& key) const; + const_iterator find(const Key&) const; //- Return the table of contents List<Key> toc() const; @@ -190,16 +191,16 @@ public: // Edit //- Insert a new hashedEntry - inline bool insert(const Key& key, const T& newElmt); + inline bool insert(const Key&, const T& newElmt); //- Assign a new hashedEntry, overwriting existing entries - inline bool set(const Key& key, const T& newElmt); + inline bool set(const Key&, const T& newElmt); //- Erase an hashedEntry specified by given iterator - bool erase(const iterator& it); + bool erase(const iterator&); //- Erase an hashedEntry specified by given key if in table - bool erase(const Key& key); + bool erase(const Key&); //- Resize the hash table for efficiency void resize(const label newSize); @@ -207,6 +208,10 @@ public: //- Clear all entries from table void clear(); + //- Clear the table entries and the table itself. + // Equivalent to clear() followed by resize(0) + void clearStorage(); + //- Transfer the contents of the argument table into this table // and annull the argument table. void transfer(HashTable<T, Key, Hash>&); @@ -215,14 +220,14 @@ public: // Member Operators //- Find and return an hashedEntry - inline T& operator[](const Key& key); + inline T& operator[](const Key&); //- Find and return an hashedEntry - inline const T& operator[](const Key& key) const; + inline const T& operator[](const Key&) const; //- Find and return an hashedEntry and // if it is not present create it null. - inline T& operator()(const Key& key); + inline T& operator()(const Key&); //- Assignment void operator=(const HashTable<T, Key, Hash>&); @@ -290,13 +295,13 @@ public: // Member operators - inline void operator=(const iterator& iter); + inline void operator=(const iterator&); - inline bool operator==(const iterator& iter) const; - inline bool operator!=(const iterator& iter) const; + inline bool operator==(const iterator&) const; + inline bool operator!=(const iterator&) const; - inline bool operator==(const const_iterator& iter) const; - inline bool operator!=(const const_iterator& iter) const; + inline bool operator==(const const_iterator&) const; + inline bool operator!=(const const_iterator&) const; inline T& operator*(); inline T& operator()(); @@ -352,13 +357,13 @@ public: // Member operators - inline void operator=(const const_iterator& iter); + inline void operator=(const const_iterator&); - inline bool operator==(const const_iterator& iter) const; - inline bool operator!=(const const_iterator& iter) const; + inline bool operator==(const const_iterator&) const; + inline bool operator!=(const const_iterator&) const; - inline bool operator==(const iterator& iter) const; - inline bool operator!=(const iterator& iter) const; + inline bool operator==(const iterator&) const; + inline bool operator!=(const iterator&) const; inline const T& operator*(); inline const T& operator()(); diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C index 670a3116a4221db6204764f42870bff1078c9f29..565cac9493810d3b7cfead47a795897161318677 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C @@ -26,22 +26,17 @@ License #include "ILList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl) +Foam::ILList<LListBase, T>::ILList(const ILList<LListBase, T>& lst) : UILList<LListBase, T>() { for ( - typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -53,9 +48,9 @@ ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl) #ifndef __INTEL_COMPILER template<class LListBase, class T> template<class CloneArg> -ILList<LListBase, T>::ILList +Foam::ILList<LListBase, T>::ILList ( - const ILList<LListBase, T>& slpl, + const ILList<LListBase, T>& lst, const CloneArg& cloneArg ) : @@ -63,8 +58,8 @@ ILList<LListBase, T>::ILList { for ( - typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -77,7 +72,7 @@ ILList<LListBase, T>::ILList // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // template<class LListBase, class T> -ILList<LListBase, T>::~ILList() +Foam::ILList<LListBase, T>::~ILList() { this->clear(); } @@ -85,9 +80,8 @@ ILList<LListBase, T>::~ILList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Return and remove head template<class LListBase, class T> -bool ILList<LListBase, T>::eraseHead() +bool Foam::ILList<LListBase, T>::eraseHead() { T* tPtr; if ((tPtr = this->removeHead())) @@ -101,9 +95,8 @@ bool ILList<LListBase, T>::eraseHead() } } -//- Return and remove element template<class LListBase, class T> -bool ILList<LListBase, T>::erase(T* p) +bool Foam::ILList<LListBase, T>::erase(T* p) { T* tPtr; if ((tPtr = remove(p))) @@ -119,7 +112,7 @@ bool ILList<LListBase, T>::erase(T* p) template<class LListBase, class T> -void ILList<LListBase, T>::clear() +void Foam::ILList<LListBase, T>::clear() { label oldSize = this->size(); for (label i=0; i<oldSize; i++) @@ -131,17 +124,25 @@ void ILList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::ILList<LListBase, T>::transfer(ILList<LListBase, T>& lst) +{ + clear(); + LListBase::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl) +void Foam::ILList<LListBase, T>::operator=(const ILList<LListBase, T>& lst) { this->clear(); for ( - typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -149,11 +150,6 @@ void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl) } } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "ILListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H index 074a54a259125065fbb724bf20fd320949e554bd..401a8b60388100bb60273a2afe0490c8f22b0eb1 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H @@ -71,7 +71,7 @@ class ILList //- Read from Istream using given Istream constructor class template<class INew> - void read(Istream&, const INew& inewt); + void read(Istream&, const INew&); public: @@ -96,7 +96,7 @@ public: //- Copy constructor with additional argument for clone template<class CloneArg> - ILList(const ILList<LListBase, T>& slpl, const CloneArg& cloneArg) + ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg) #ifdef __INTEL_COMPILER : UILList<LListBase, T>() @@ -104,8 +104,8 @@ public: for ( typename UILList<LListBase, T>::const_iterator iter = - slpl.begin(); - iter != slpl.end(); + lst.begin(); + iter != lst.end(); ++iter ) { @@ -118,7 +118,7 @@ public: //- Construct from Istream using given Istream constructor class template<class INew> - ILList(Istream&, const INew& inewt); + ILList(Istream&, const INew&); // Destructor @@ -139,6 +139,10 @@ public: //- Clear the contents of the list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(ILList<LListBase, T>&); + // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C index 8d2ac68c27e4396053e3c5dcc91c5463943db606..a467da11dc87779ba93f3e38df6ddb14e37b8fd0 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C @@ -30,24 +30,19 @@ Description #include "Istream.H" #include "INew.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> template<class INew> -void ILList<LListBase, T>::read(Istream& is, const INew& inewt) +void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew) { - is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); + is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)"); token firstToken(is); is.fatalCheck ( - "operator>>(Istream& is, ILList<LListBase, T>& L) : reading first token" + "operator>>(Istream&, ILList<LListBase, T>&) : reading first token" ); if (firstToken.isLabel()) @@ -63,26 +58,26 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt) { for (label i=0; i<s; i++) { - append(inewt(is).ptr()); - + append(iNew(is).ptr()); + is.fatalCheck ( - "operator>>(Istream& is, ILList<LListBase, T>& L) : " + "operator>>(Istream&, ILList<LListBase, T>&) : " "reading entry" ); } } else { - T* tPtr = inewt(is).ptr(); + T* tPtr = iNew(is).ptr(); append(tPtr); is.fatalCheck ( - "operator>>(Istream& is, ILList<LListBase, T>& L) : " + "operator>>(Istream&, ILList<LListBase, T>&) : " "reading entry" ); - + for (label i=1; i<s; i++) { append(new T(*tPtr)); @@ -99,14 +94,14 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt) { FatalIOErrorIn ( - "operator>>(Istream& is, ILList<LListBase, T>& L)", + "operator>>(Istream&, ILList<LListBase, T>&)", is ) << "incorrect first token, '(', found " << firstToken.info() << exit(FatalIOError); } token lastToken(is); - is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); + is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)"); while ( @@ -117,36 +112,34 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt) ) { is.putBack(lastToken); - append(inewt(is).ptr()); + append(iNew(is).ptr()); is >> lastToken; - is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); + is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)"); } } else { - FatalIOErrorIn("operator>>(Istream& is, ILList<LListBase, T>& L)", is) + FatalIOErrorIn("operator>>(Istream&, ILList<LListBase, T>&)", is) << "incorrect first token, expected <int> or '(', found " << firstToken.info() << exit(FatalIOError); } - is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); + is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)"); } -//- Construct from Istream using given Istream constructor class template<class LListBase, class T> template<class INew> -ILList<LListBase, T>::ILList(Istream& is, const INew& inewt) +Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& iNew) { - read(is, inewt); + read(is, iNew); } -// Construct from Istream template<class LListBase, class T> -ILList<LListBase, T>::ILList(Istream& is) +Foam::ILList<LListBase, T>::ILList(Istream& is) { read(is, INew<T>()); } @@ -155,7 +148,7 @@ ILList<LListBase, T>::ILList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Istream& operator>>(Istream& is, ILList<LListBase, T>& L) +Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& L) { L.clear(); L.read(is, INew<T>()); @@ -166,6 +159,4 @@ Istream& operator>>(Istream& is, ILList<LListBase, T>& L) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C index 94512eeabda6a65145daf02cd712783d13cf5ef1..1c93142b416245af36a84dfb12d6880ef3b0b111 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C @@ -27,22 +27,16 @@ Description \*---------------------------------------------------------------------------*/ #include "error.H" - #include "LList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -LList<LListBase, T>::LList(const LList<LListBase, T>& slpl) +Foam::LList<LListBase, T>::LList(const LList<LListBase, T>& lst) : LListBase() { - for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(iter()); } @@ -50,7 +44,7 @@ LList<LListBase, T>::LList(const LList<LListBase, T>& slpl) template<class LListBase, class T> -LList<LListBase, T>::~LList() +Foam::LList<LListBase, T>::~LList() { this->clear(); } @@ -59,7 +53,7 @@ LList<LListBase, T>::~LList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class LListBase, class T> -void LList<LListBase, T>::clear() +void Foam::LList<LListBase, T>::clear() { label oldSize = this->size(); for (label i=0; i<oldSize; i++) @@ -71,24 +65,28 @@ void LList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::LList<LListBase, T>::transfer(LList<LListBase, T>& lst) +{ + clear(); + LListBase::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void LList<LListBase, T>::operator=(const LList<LListBase, T>& slpl) +void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst) { this->clear(); - for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(iter()); } } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "LListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H index a9bc0bccae46bfdef4d1523beacf08fffc4e4dfd..4c422f7ccb2ae01f59add91906f1f33bd49d2ccf 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H @@ -67,7 +67,7 @@ Ostream& operator<< /*---------------------------------------------------------------------------*\ - Class LList Declaration + Class LList Declaration \*---------------------------------------------------------------------------*/ template<class LListBase, class T> @@ -200,6 +200,9 @@ public: //- Delete contents of list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(LList<LListBase, T>&); // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C index 32dbaf3f17fa1aa09dea5fd8eb8b8bc38ed0cff9..316585078186b627688b2b0d330ab4d7ba9078fb 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C @@ -30,16 +30,10 @@ Description #include "Istream.H" #include "Ostream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from Istream template<class LListBase, class T> -LList<LListBase, T>::LList(Istream& is) +Foam::LList<LListBase, T>::LList(Istream& is) { operator>>(is, *this); } @@ -48,18 +42,18 @@ LList<LListBase, T>::LList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Istream& operator>>(Istream& is, LList<LListBase, T>& L) +Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L) { // Anull list L.clear(); - is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)"); + is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)"); token firstToken(is); is.fatalCheck ( - " operator>>(Istream& is, LList<LListBase, T>& L) : reading first token" + " operator>>(Istream&, LList<LListBase, T>&) : reading first token" ); if (firstToken.isLabel()) @@ -101,14 +95,14 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L) { FatalIOErrorIn ( - " operator>>(Istream& is, LList<LListBase, T>& L)", + " operator>>(Istream&, LList<LListBase, T>&)", is ) << "incorrect first token, '(', found " << firstToken.info() << exit(FatalIOError); } token lastToken(is); - is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)"); + is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)"); while ( @@ -124,19 +118,19 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L) L.append(element); is >> lastToken; - is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)"); + is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)"); } } else { - FatalIOErrorIn(" operator>>(Istream& is, LList<LListBase, T>& L)", is) + FatalIOErrorIn(" operator>>(Istream&, LList<LListBase, T>&)", is) << "incorrect first token, expected <int> or '(', found " << firstToken.info() << exit(FatalIOError); } // Check state of IOstream - is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)"); + is.fatalCheck(" operator>>(Istream&, LList<LListBase,>&)"); return is; } @@ -145,19 +139,19 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Ostream& operator<<(Ostream& os, const LList<LListBase, T>& ll) +Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& lst) { - // Write size of LList - os << nl << ll.size(); + // Write size + os << nl << lst.size(); // Write beginning of contents os << nl << token::BEGIN_LIST << nl; - // Write LList contents + // Write contents for ( - typename LList<LListBase, T>::const_iterator iter = ll.begin(); - iter != ll.end(); + typename LList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -168,14 +162,10 @@ Ostream& operator<<(Ostream& os, const LList<LListBase, T>& ll) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const LList&)"); + os.check("Ostream& operator<<(Ostream&, const LList<LListBase, T>&)"); return os; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C index bf29f1d45050eeef9fdd5437c1ed7a87643110dd..935e68292c080d89d4203548ec0d17c479d50c8b 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C @@ -26,19 +26,14 @@ License #include "LPtrList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& slpl) +Foam::LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst) : LList<LListBase, T*>() { - for(const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(iter().clone().ptr()); } @@ -48,7 +43,7 @@ LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& slpl) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class LListBase, class T> -LPtrList<LListBase, T>::~LPtrList() +Foam::LPtrList<LListBase, T>::~LPtrList() { clear(); } @@ -56,9 +51,8 @@ LPtrList<LListBase, T>::~LPtrList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Return and remove head template<class LListBase, class T> -bool LPtrList<LListBase, T>::eraseHead() +bool Foam::LPtrList<LListBase, T>::eraseHead() { T* tPtr; if ((tPtr = this->removeHead())) @@ -74,7 +68,7 @@ bool LPtrList<LListBase, T>::eraseHead() template<class LListBase, class T> -void LPtrList<LListBase, T>::clear() +void Foam::LPtrList<LListBase, T>::clear() { label oldSize = this->size(); for (label i=0; i<oldSize; i++) @@ -86,24 +80,28 @@ void LPtrList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::LPtrList<LListBase, T>::transfer(LPtrList<LListBase, T>& lst) +{ + clear(); + LList<LListBase, T*>::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& slpl) +void Foam::LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& lst) { clear(); - for(const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(iter().clone().ptr()); } } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "LPtrListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H index 601d26f87617ee3943e658d7be6e928d0972eaa1..fdb59ea27cd1cc553e5121ca8b543e07e588876d 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H @@ -149,12 +149,16 @@ public: // Edit - //- Remove the head element specified from the list and delete it + //- Remove the head element from the list and delete the pointer bool eraseHead(); - //- Remove the specified element from the list and delete it + //- Clear the contents of the list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(LPtrList<LListBase, T>&); + // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C index e5bd9c907ddad88c51c550a237e83d1223dcabdc..c7bb16c4e2a87b5191e0a47791c66a7b3a447cb0 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C @@ -29,16 +29,11 @@ License #include "Ostream.H" #include "INew.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // template<class LListBase, class T> template<class INew> -void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) +void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew) { is.fatalCheck ( @@ -66,8 +61,8 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) { for (label i=0; i<s; i++) { - append(inewt(is).ptr()); - + append(iNew(is).ptr()); + is.fatalCheck ( "LPtrList<LListBase, T>::read(Istream&, const INew&) : " @@ -77,7 +72,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) } else { - T* tPtr = inewt(is).ptr(); + T* tPtr = iNew(is).ptr(); append(tPtr); is.fatalCheck @@ -85,7 +80,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) "LPtrList<LListBase, T>::read(Istream&, const INew&) : " "reading entry" ); - + for (label i=1; i<s; i++) { append(tPtr->clone().ptr()); @@ -120,7 +115,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) ) { is.putBack(lastToken); - append(inewt(is).ptr()); + append(iNew(is).ptr()); is >> lastToken; is.fatalCheck @@ -148,14 +143,14 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) template<class LListBase, class T> template<class INew> -LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& inewt) +Foam::LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& iNew) { - read(is, inewt); + read(is, iNew); } template<class LListBase, class T> -LPtrList<LListBase, T>::LPtrList(Istream& is) +Foam::LPtrList<LListBase, T>::LPtrList(Istream& is) { read(is, INew<T>()); } @@ -164,11 +159,10 @@ LPtrList<LListBase, T>::LPtrList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Istream& operator>>(Istream& is, LPtrList<LListBase, T>& L) +Foam::Istream& Foam::operator>>(Istream& is, LPtrList<LListBase, T>& L) { - // Anull list L.clear(); - + L.read(is, INew<T>()); return is; } @@ -177,19 +171,19 @@ Istream& operator>>(Istream& is, LPtrList<LListBase, T>& L) // * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * // template<class LListBase, class T> -Ostream& operator<<(Ostream& os, const LPtrList<LListBase, T>& slpl) +Foam::Ostream& Foam::operator<<(Ostream& os, const LPtrList<LListBase, T>& lst) { - // Write size of LPtrList - os << nl << slpl.size(); + // Write size + os << nl << lst.size(); // Write beginning of contents os << nl << token::BEGIN_LIST << nl; - // Write LPtrList contents + // Write contents for ( - typename LPtrList<LListBase, T>::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename LPtrList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -200,14 +194,9 @@ Ostream& operator<<(Ostream& os, const LPtrList<LListBase, T>& slpl) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const LPtrList&)"); + os.check("Ostream& operator<<(Ostream&, const LPtrList<LListBase, T>&)"); return os; } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.C index ab6392094ab17d866cdeecf920dcc162b9f69ecb..1c10434c9ac21e4fec97ea44dcbdd92f9f4665cb 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.C @@ -28,17 +28,12 @@ Description #include "UILList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -UILList<LListBase, T>::UILList(const UILList<LListBase, T>& slpl) +Foam::UILList<LListBase, T>::UILList(const UILList<LListBase, T>& lst) { - for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(&iter()); } @@ -48,22 +43,24 @@ UILList<LListBase, T>::UILList(const UILList<LListBase, T>& slpl) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void UILList<LListBase, T>::operator=(const UILList<LListBase, T>& slpl) +void Foam::UILList<LListBase, T>::operator=(const UILList<LListBase, T>& rhs) { LListBase::clear(); - for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) { append(&iter()); } } -// Comparison for equality template<class LListBase, class T> -bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const +bool Foam::UILList<LListBase, T>::operator== +( + const UILList<LListBase, T>& rhs +) const { - if (this->size() != slpl.size()) + if (this->size() != rhs.size()) { return false; } @@ -71,7 +68,7 @@ bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const bool equal = true; const_iterator iter1 = this->begin(); - const_iterator iter2 = slpl.begin(); + const_iterator iter2 = rhs.begin(); for (; iter1 != this->end(); ++iter1, ++iter2) { @@ -84,16 +81,15 @@ bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const // Comparison for inequality template<class LListBase, class T> -bool UILList<LListBase, T>::operator!=(const UILList<LListBase, T>& slpl) const +bool Foam::UILList<LListBase, T>::operator!= +( + const UILList<LListBase, T>& rhs +) const { - return !operator==(slpl); + return !operator==(rhs); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "UILListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H index d10c1c3949d2003cbb6ea43d47260431cf9cdc1d..cab57ed3268a2b559da7bce189b9e696a4fc4b3e 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H @@ -245,7 +245,7 @@ public: const T& operator*() { - return + return static_cast<const T&> (LListBase_const_iterator::operator*()); } @@ -266,7 +266,7 @@ public: // STL member operators //- Equality operation on ULists of the same type. - // Returns true when the ULists are elementwise equal + // Returns true when the ULists are element-wise equal // (using UList::value_type::operator==). Takes linear time. bool operator==(const UILList<LListBase, T>&) const; diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C index 62459551c642a80c68eefa0c500f74533f847b55..d3ce739772a8bfab6570815f89f20a10ed1bae55 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C @@ -30,27 +30,22 @@ Description #include "Ostream.H" #include "token.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Ostream& operator<<(Ostream& os, const UILList<LListBase, T>& ill) +Foam::Ostream& Foam::operator<<(Ostream& os, const UILList<LListBase, T>& lst) { - // Write size of UILList - os << nl << ill.size(); + // Write size + os << nl << lst.size(); // Write beginning of contents os << nl << token::BEGIN_LIST << nl; - // Write UILList contents + // Write contents for ( - typename UILList<LListBase, T>::const_iterator iter = ill.begin(); - iter != ill.end(); + typename UILList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -61,14 +56,9 @@ Ostream& operator<<(Ostream& os, const UILList<LListBase, T>& ill) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const UILList&)"); + os.check("Ostream& operator<<(Ostream&, const UILList<LListBase, T>&)"); return os; } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C index ba25e663b3bcc2974270a7d29a84e329e2819d3d..b3e21c42258df2e463ec246f110c6a336b7f78ac 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C @@ -32,17 +32,12 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -DLListBase::iterator DLListBase::endIter +Foam::DLListBase::iterator Foam::DLListBase::endIter ( const_cast<DLListBase&>(static_cast<const DLListBase&>(DLListBase())) ); -DLListBase::const_iterator DLListBase::endConstIter +Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter ( static_cast<const DLListBase&>(DLListBase()), reinterpret_cast<const link*>(NULL) @@ -51,7 +46,7 @@ DLListBase::const_iterator DLListBase::endConstIter // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void DLListBase::insert(DLListBase::link* a) +void Foam::DLListBase::insert(DLListBase::link* a) { nElmts_++; @@ -71,7 +66,7 @@ void DLListBase::insert(DLListBase::link* a) } -void DLListBase::append(DLListBase::link* a) +void Foam::DLListBase::append(DLListBase::link* a) { nElmts_++; @@ -91,7 +86,7 @@ void DLListBase::append(DLListBase::link* a) } -bool DLListBase::swapUp(DLListBase::link* a) +bool Foam::DLListBase::swapUp(DLListBase::link* a) { if (first_ != a) { @@ -132,7 +127,7 @@ bool DLListBase::swapUp(DLListBase::link* a) } -bool DLListBase::swapDown(DLListBase::link* a) +bool Foam::DLListBase::swapDown(DLListBase::link* a) { if (last_ != a) { @@ -173,7 +168,7 @@ bool DLListBase::swapDown(DLListBase::link* a) } -DLListBase::link* DLListBase::removeHead() +Foam::DLListBase::link* Foam::DLListBase::removeHead() { nElmts_--; @@ -197,7 +192,7 @@ DLListBase::link* DLListBase::removeHead() } -DLListBase::link* DLListBase::remove(DLListBase::link* l) +Foam::DLListBase::link* Foam::DLListBase::remove(DLListBase::link* l) { nElmts_--; @@ -229,7 +224,7 @@ DLListBase::link* DLListBase::remove(DLListBase::link* l) } -DLListBase::link* DLListBase::replace +Foam::DLListBase::link* Foam::DLListBase::replace ( DLListBase::link* oldLink, DLListBase::link* newLink @@ -266,8 +261,4 @@ DLListBase::link* DLListBase::replace } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index 8fd2c55bc19592d8f3caf2876efccc29b5aa5e16..33df2b87c711a76b3e6517a7e106947490f735ef 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -167,6 +167,9 @@ public: //- Clear the list inline void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + inline void transfer(DLListBase&); // STL iterator diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H index eb9c00d3f8c5da40d0cfd3616476973e1ba0c2d8..a9414fa3876c6adaacabaf664043694bac9f357d 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H @@ -26,21 +26,16 @@ License #include "error.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -inline DLListBase::link::link() +inline Foam::DLListBase::link::link() : prev_(0), next_(0) {} -inline DLListBase::DLListBase() +inline Foam::DLListBase::DLListBase() : first_(0), last_(0), @@ -48,7 +43,7 @@ inline DLListBase::DLListBase() {} -inline DLListBase::DLListBase(link* a) +inline Foam::DLListBase::DLListBase(link* a) : first_(a), last_(a), @@ -61,32 +56,33 @@ inline DLListBase::DLListBase(link* a) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -inline DLListBase::~DLListBase() +inline Foam::DLListBase::~DLListBase() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline bool DLListBase::link::registered() const +inline bool Foam::DLListBase::link::registered() const { return prev_ != 0 && next_ != 0; } -inline void DLListBase::link::deregister() +inline void Foam::DLListBase::link::deregister() { prev_ = 0; next_ = 0; } -inline label DLListBase::size() const +inline Foam::label Foam::DLListBase::size() const { return nElmts_; } -inline DLListBase::link* DLListBase::first() +inline Foam::DLListBase::link* +Foam::DLListBase::first() { if (!nElmts_) { @@ -98,7 +94,8 @@ inline DLListBase::link* DLListBase::first() } -inline const DLListBase::link* DLListBase::first() const +inline const Foam::DLListBase::link* +Foam::DLListBase::first() const { if (!nElmts_) { @@ -110,7 +107,8 @@ inline const DLListBase::link* DLListBase::first() const } -inline DLListBase::link* DLListBase::last() +inline Foam::DLListBase::link* +Foam::DLListBase::last() { if (!nElmts_) { @@ -122,7 +120,8 @@ inline DLListBase::link* DLListBase::last() } -inline const DLListBase::link* DLListBase::last() const +inline const Foam::DLListBase::link* +Foam::DLListBase::last() const { if (!nElmts_) { @@ -134,21 +133,36 @@ inline const DLListBase::link* DLListBase::last() const } -inline void DLListBase::clear() +inline void Foam::DLListBase::clear() { - nElmts_ = 0; first_ = 0; - last_ = 0; + last_ = 0; + nElmts_ = 0; } -inline DLListBase::link* DLListBase::remove(DLListBase::iterator& it) +inline void Foam::DLListBase::transfer(DLListBase& lst) +{ + first_ = lst.first_; + last_ = lst.last_; + nElmts_ = lst.nElmts_; + + lst.clear(); +} + + +inline Foam::DLListBase::link* +Foam::DLListBase::remove +( + DLListBase::iterator& it +) { return remove(it.curElmt_); } -inline DLListBase::link* DLListBase::replace +inline Foam::DLListBase::link* +Foam::DLListBase::replace ( DLListBase::iterator& oldIter, DLListBase::link* newLink @@ -160,7 +174,7 @@ inline DLListBase::link* DLListBase::replace // * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * // -inline DLListBase::iterator::iterator(DLListBase& s, link* elmt) +inline Foam::DLListBase::iterator::iterator(DLListBase& s, link* elmt) : curList_(s), curElmt_(elmt), @@ -168,7 +182,7 @@ inline DLListBase::iterator::iterator(DLListBase& s, link* elmt) {} -inline DLListBase::iterator::iterator(DLListBase& s) +inline Foam::DLListBase::iterator::iterator(DLListBase& s) : curList_(s), curElmt_(NULL), @@ -176,32 +190,34 @@ inline DLListBase::iterator::iterator(DLListBase& s) {} -inline void DLListBase::iterator::operator=(const iterator& iter) +inline void Foam::DLListBase::iterator::operator=(const iterator& iter) { curElmt_ = iter.curElmt_; curLink_ = iter.curLink_; } -inline bool DLListBase::iterator::operator==(const iterator& iter) const +inline bool Foam::DLListBase::iterator::operator==(const iterator& iter) const { return curElmt_ == iter.curElmt_; } -inline bool DLListBase::iterator::operator!=(const iterator& iter) const +inline bool Foam::DLListBase::iterator::operator!=(const iterator& iter) const { return curElmt_ != iter.curElmt_; } -inline DLListBase::link& DLListBase::iterator::operator*() +inline Foam::DLListBase::link& +Foam::DLListBase::iterator::operator*() { return *curElmt_; } -inline DLListBase::iterator& DLListBase::iterator::operator++() +inline Foam::DLListBase::iterator& +Foam::DLListBase::iterator::operator++() { // Check if the curElmt_ is the last element (if it points to itself) // or if the list is empty because the last element may have been removed @@ -219,7 +235,8 @@ inline DLListBase::iterator& DLListBase::iterator::operator++() } -inline DLListBase::iterator DLListBase::iterator::operator++(int) +inline Foam::DLListBase::iterator +Foam::DLListBase::iterator::operator++(int) { iterator tmp = *this; ++*this; @@ -227,7 +244,8 @@ inline DLListBase::iterator DLListBase::iterator::operator++(int) } -inline DLListBase::iterator DLListBase::begin() +inline Foam::DLListBase::iterator +Foam::DLListBase::begin() { if (size()) { @@ -240,7 +258,7 @@ inline DLListBase::iterator DLListBase::begin() } -inline const DLListBase::iterator& DLListBase::end() +inline const Foam::DLListBase::iterator& Foam::DLListBase::end() { return endIter; } @@ -248,7 +266,7 @@ inline const DLListBase::iterator& DLListBase::end() // * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * // -inline DLListBase::const_iterator::const_iterator +inline Foam::DLListBase::const_iterator::const_iterator ( const DLListBase& s, const link* elmt @@ -259,20 +277,23 @@ inline DLListBase::const_iterator::const_iterator {} -inline DLListBase::const_iterator::const_iterator(const iterator& iter) +inline Foam::DLListBase::const_iterator::const_iterator(const iterator& iter) : curList_(iter.curList_), curElmt_(iter.curElmt_) {} -inline void DLListBase::const_iterator::operator=(const const_iterator& iter) +inline void Foam::DLListBase::const_iterator::operator= +( + const const_iterator& iter +) { curElmt_ = iter.curElmt_; } -inline bool DLListBase::const_iterator::operator== +inline bool Foam::DLListBase::const_iterator::operator== ( const const_iterator& iter ) const @@ -281,7 +302,7 @@ inline bool DLListBase::const_iterator::operator== } -inline bool DLListBase::const_iterator::operator!= +inline bool Foam::DLListBase::const_iterator::operator!= ( const const_iterator& iter ) const @@ -290,13 +311,15 @@ inline bool DLListBase::const_iterator::operator!= } -inline const DLListBase::link& DLListBase::const_iterator::operator*() +inline const Foam::DLListBase::link& +Foam::DLListBase::const_iterator::operator*() { return *curElmt_; } -inline DLListBase::const_iterator& DLListBase::const_iterator::operator++() +inline Foam::DLListBase::const_iterator& +Foam::DLListBase::const_iterator::operator++() { if (curElmt_ == curList_.last_) { @@ -311,7 +334,8 @@ inline DLListBase::const_iterator& DLListBase::const_iterator::operator++() } -inline DLListBase::const_iterator DLListBase::const_iterator::operator++(int) +inline Foam::DLListBase::const_iterator +Foam::DLListBase::const_iterator::operator++(int) { const_iterator tmp = *this; ++*this; @@ -319,7 +343,8 @@ inline DLListBase::const_iterator DLListBase::const_iterator::operator++(int) } -inline DLListBase::const_iterator DLListBase::begin() const +inline Foam::DLListBase::const_iterator +Foam::DLListBase::begin() const { if (size()) { @@ -332,14 +357,11 @@ inline DLListBase::const_iterator DLListBase::begin() const } -inline const DLListBase::const_iterator& DLListBase::end() const +inline const Foam::DLListBase::const_iterator& +Foam::DLListBase::end() const { return endConstIter; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C index 0098ff685faeed240a195d1edd0517d6b92d916d..44e50a3666277007a7f69e45b877a9262ec5024f 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C @@ -25,22 +25,16 @@ License \*---------------------------------------------------------------------------*/ #include "error.H" - #include "SLListBase.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -SLListBase::iterator SLListBase::endIter +Foam::SLListBase::iterator Foam::SLListBase::endIter ( const_cast<SLListBase&>(static_cast<const SLListBase&>(SLListBase())) ); -SLListBase::const_iterator SLListBase::endConstIter +Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter ( static_cast<const SLListBase&>(SLListBase()), reinterpret_cast<const link*>(NULL) @@ -49,7 +43,7 @@ SLListBase::const_iterator SLListBase::endConstIter // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void SLListBase::insert(SLListBase::link* a) +void Foam::SLListBase::insert(SLListBase::link* a) { nElmts_++; @@ -66,7 +60,7 @@ void SLListBase::insert(SLListBase::link* a) } -void SLListBase::append(SLListBase::link* a) +void Foam::SLListBase::append(SLListBase::link* a) { nElmts_++; @@ -82,7 +76,7 @@ void SLListBase::append(SLListBase::link* a) } -SLListBase::link* SLListBase::removeHead() +Foam::SLListBase::link* Foam::SLListBase::removeHead() { nElmts_--; @@ -108,7 +102,7 @@ SLListBase::link* SLListBase::removeHead() } -SLListBase::link* SLListBase::remove(SLListBase::link* it) +Foam::SLListBase::link* Foam::SLListBase::remove(SLListBase::link* it) { SLListBase::iterator iter = begin(); SLListBase::link *prev = &(*iter); @@ -143,8 +137,4 @@ SLListBase::link* SLListBase::remove(SLListBase::link* it) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H index cfd8afe4a902a72b65fb72ac96bcd1c958982423..f802e6914297e6110498d54c04a64682fc2ba261 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H @@ -152,6 +152,9 @@ public: //- Clear the list inline void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + inline void transfer(SLListBase&); // STL iterator diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H index 3a1125924bc52cf9da74d8c11eba13bb8274bf3f..594fc6f098f151e8fde2397ae65cbc613e9cdc49 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H @@ -29,33 +29,28 @@ Description #include "error.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -inline SLListBase::link::link() +inline Foam::SLListBase::link::link() : next_(0) {} -inline SLListBase::link::link(link* p) +inline Foam::SLListBase::link::link(link* p) : next_(p) {} -inline SLListBase::SLListBase() +inline Foam::SLListBase::SLListBase() : last_(0), nElmts_(0) {} -inline SLListBase::SLListBase(link* a) +inline Foam::SLListBase::SLListBase(link* a) : last_(a->next_ = a), nElmts_(1) @@ -64,19 +59,20 @@ inline SLListBase::SLListBase(link* a) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -inline SLListBase::~SLListBase() +inline Foam::SLListBase::~SLListBase() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline label SLListBase::size() const +inline Foam::label Foam::SLListBase::size() const { return nElmts_; } -inline SLListBase::link* SLListBase::first() +inline Foam::SLListBase::link* +Foam::SLListBase::first() { if (!nElmts_) { @@ -88,7 +84,8 @@ inline SLListBase::link* SLListBase::first() } -inline const SLListBase::link* SLListBase::first() const +inline const Foam::SLListBase::link* +Foam::SLListBase::first() const { if (!nElmts_) { @@ -100,7 +97,8 @@ inline const SLListBase::link* SLListBase::first() const } -inline SLListBase::link* SLListBase::last() +inline Foam::SLListBase::link* +Foam::SLListBase::last() { if (!nElmts_) { @@ -112,7 +110,8 @@ inline SLListBase::link* SLListBase::last() } -inline const SLListBase::link* SLListBase::last() const +inline const Foam::SLListBase::link* +Foam::SLListBase::last() const { if (!nElmts_) { @@ -124,14 +123,26 @@ inline const SLListBase::link* SLListBase::last() const } -inline void SLListBase::clear() +inline void Foam::SLListBase::clear() { - nElmts_ = 0; last_ = 0; + nElmts_ = 0; } -inline SLListBase::link* SLListBase::remove(SLListBase::iterator& it) +inline void Foam::SLListBase::transfer(SLListBase& lst) +{ + last_ = lst.last_; + nElmts_ = lst.nElmts_; + + lst.clear(); +} + + +inline Foam::SLListBase::link* Foam::SLListBase::remove +( + SLListBase::iterator& it +) { return remove(it.curElmt_); } @@ -139,7 +150,7 @@ inline SLListBase::link* SLListBase::remove(SLListBase::iterator& it) // * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * // -inline SLListBase::iterator::iterator(SLListBase& s, link* elmt) +inline Foam::SLListBase::iterator::iterator(SLListBase& s, link* elmt) : curList_(s), curElmt_(elmt), @@ -147,7 +158,7 @@ inline SLListBase::iterator::iterator(SLListBase& s, link* elmt) {} -inline SLListBase::iterator::iterator(SLListBase& s) +inline Foam::SLListBase::iterator::iterator(SLListBase& s) : curList_(s), curElmt_(NULL), @@ -155,32 +166,32 @@ inline SLListBase::iterator::iterator(SLListBase& s) {} -inline void SLListBase::iterator::operator=(const iterator& iter) +inline void Foam::SLListBase::iterator::operator=(const iterator& iter) { curElmt_ = iter.curElmt_; curLink_ = iter.curLink_; } -inline bool SLListBase::iterator::operator==(const iterator& iter) const +inline bool Foam::SLListBase::iterator::operator==(const iterator& iter) const { return curElmt_ == iter.curElmt_; } -inline bool SLListBase::iterator::operator!=(const iterator& iter) const +inline bool Foam::SLListBase::iterator::operator!=(const iterator& iter) const { return curElmt_ != iter.curElmt_; } -inline SLListBase::link& SLListBase::iterator::operator*() +inline Foam::SLListBase::link& Foam::SLListBase::iterator::operator*() { return *curElmt_; } -inline SLListBase::iterator& SLListBase::iterator::operator++() +inline Foam::SLListBase::iterator& Foam::SLListBase::iterator::operator++() { if (curElmt_ == curList_.last_ || curList_.last_ == 0) { @@ -196,7 +207,8 @@ inline SLListBase::iterator& SLListBase::iterator::operator++() } -inline SLListBase::iterator SLListBase::iterator::operator++(int) +inline Foam::SLListBase::iterator +Foam::SLListBase::iterator::operator++(int) { iterator tmp = *this; ++*this; @@ -204,7 +216,8 @@ inline SLListBase::iterator SLListBase::iterator::operator++(int) } -inline SLListBase::iterator SLListBase::begin() +inline Foam::SLListBase::iterator +Foam::SLListBase::begin() { if (size()) { @@ -217,7 +230,8 @@ inline SLListBase::iterator SLListBase::begin() } -inline const SLListBase::iterator& SLListBase::end() +inline const Foam::SLListBase::iterator& +Foam::SLListBase::end() { return endIter; } @@ -225,7 +239,7 @@ inline const SLListBase::iterator& SLListBase::end() // * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * // -inline SLListBase::const_iterator::const_iterator +inline Foam::SLListBase::const_iterator::const_iterator ( const SLListBase& s, const link* elmt @@ -236,20 +250,23 @@ inline SLListBase::const_iterator::const_iterator {} -inline SLListBase::const_iterator::const_iterator(const iterator& iter) +inline Foam::SLListBase::const_iterator::const_iterator(const iterator& iter) : curList_(iter.curList_), curElmt_(iter.curElmt_) {} -inline void SLListBase::const_iterator::operator=(const const_iterator& iter) +inline void Foam::SLListBase::const_iterator::operator= +( + const const_iterator& iter +) { curElmt_ = iter.curElmt_; } -inline bool SLListBase::const_iterator::operator== +inline bool Foam::SLListBase::const_iterator::operator== ( const const_iterator& iter ) const @@ -258,7 +275,7 @@ inline bool SLListBase::const_iterator::operator== } -inline bool SLListBase::const_iterator::operator!= +inline bool Foam::SLListBase::const_iterator::operator!= ( const const_iterator& iter ) const @@ -267,13 +284,15 @@ inline bool SLListBase::const_iterator::operator!= } -inline const SLListBase::link& SLListBase::const_iterator::operator*() +inline const Foam::SLListBase::link& +Foam::SLListBase::const_iterator::operator*() { return *curElmt_; } -inline SLListBase::const_iterator& SLListBase::const_iterator::operator++() +inline Foam::SLListBase::const_iterator& +Foam::SLListBase::const_iterator::operator++() { if (curElmt_ == curList_.last_) { @@ -288,7 +307,8 @@ inline SLListBase::const_iterator& SLListBase::const_iterator::operator++() } -inline SLListBase::const_iterator SLListBase::const_iterator::operator++(int) +inline Foam::SLListBase::const_iterator +Foam::SLListBase::const_iterator::operator++(int) { const_iterator tmp = *this; ++*this; @@ -296,7 +316,8 @@ inline SLListBase::const_iterator SLListBase::const_iterator::operator++(int) } -inline SLListBase::const_iterator SLListBase::begin() const +inline Foam::SLListBase::const_iterator +Foam::SLListBase::begin() const { if (size()) { @@ -309,14 +330,11 @@ inline SLListBase::const_iterator SLListBase::begin() const } -inline const SLListBase::const_iterator& SLListBase::end() const +inline const Foam::SLListBase::const_iterator& +Foam::SLListBase::end() const { return endConstIter; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/user/DLList/DLList.H b/src/OpenFOAM/containers/LinkedLists/user/DLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/DLList/DLList.H rename to src/OpenFOAM/containers/LinkedLists/user/DLList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/DLPtrList/DLPtrList.H b/src/OpenFOAM/containers/LinkedLists/user/DLPtrList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/DLPtrList/DLPtrList.H rename to src/OpenFOAM/containers/LinkedLists/user/DLPtrList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/FIFOStack/FIFOStack.H b/src/OpenFOAM/containers/LinkedLists/user/FIFOStack.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/FIFOStack/FIFOStack.H rename to src/OpenFOAM/containers/LinkedLists/user/FIFOStack.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/IDLList/IDLList.H b/src/OpenFOAM/containers/LinkedLists/user/IDLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/IDLList/IDLList.H rename to src/OpenFOAM/containers/LinkedLists/user/IDLList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/ISLList/ISLList.H b/src/OpenFOAM/containers/LinkedLists/user/ISLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/ISLList/ISLList.H rename to src/OpenFOAM/containers/LinkedLists/user/ISLList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/LIFOStack/LIFOStack.H b/src/OpenFOAM/containers/LinkedLists/user/LIFOStack.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/LIFOStack/LIFOStack.H rename to src/OpenFOAM/containers/LinkedLists/user/LIFOStack.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/SLList/SLList.H b/src/OpenFOAM/containers/LinkedLists/user/SLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/SLList/SLList.H rename to src/OpenFOAM/containers/LinkedLists/user/SLList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/SLPtrList/SLPtrList.H b/src/OpenFOAM/containers/LinkedLists/user/SLPtrList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/SLPtrList/SLPtrList.H rename to src/OpenFOAM/containers/LinkedLists/user/SLPtrList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/UIDLList/UIDLList.H b/src/OpenFOAM/containers/LinkedLists/user/UIDLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/UIDLList/UIDLList.H rename to src/OpenFOAM/containers/LinkedLists/user/UIDLList.H diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H index 90b78aabfc5123e65d58906f4461289b42d3674b..20425b8a7db0bf67d646aba77b687f468d49cab5 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -31,13 +31,22 @@ License template<class Stream> inline void Foam::IOobject::writeBanner(Stream& os, bool noHint) { - static bool spacesSet = false; + static bool spacesSet(false); static char spaces[40]; if (!spacesSet) { memset(spaces, ' ', 40); - spaces[38 - strlen(Foam::FOAMversion)] = '\0'; + + size_t len = strlen(Foam::FOAMversion); + if (len < 38) + { + spaces[38 - len] = '\0'; + } + else + { + spaces[0] = '\0'; + } spacesSet = true; } @@ -56,8 +65,8 @@ inline void Foam::IOobject::writeBanner(Stream& os, bool noHint) "| ========= | |\n" "| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n" "| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n" - "| \\\\ / A nd | Web: http://www.OpenFOAM.org |\n" - "| \\\\/ M anipulation | |\n" + "| \\\\ / A nd | |\n" + "| \\\\/ M anipulation | www.OpenFOAM.org |\n" "\\*---------------------------------------------------------------------------*/\n"; } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C index 577494aa1cf435019fb43d7d770e5f511e31e987..98752700a1be835cbea82c1c9a29e6a0985ba7c9 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C @@ -32,22 +32,22 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Write keyType -Foam::Ostream& Foam::Ostream::write(const keyType& s) +// Write keyType +Foam::Ostream& Foam::Ostream::write(const keyType& kw) { - // Write as word? - if (s.isWildCard()) + // Write as word or string + if (kw.isPattern()) { - return write(static_cast<const string&>(s)); + return write(static_cast<const string&>(kw)); } else { - return write(static_cast<const word&>(s)); + return write(static_cast<const word&>(kw)); } } -//- Decrememt the indent level +// Decrement the indent level void Foam::Ostream::decrIndent() { if (indentLevel_ == 0) @@ -62,15 +62,26 @@ void Foam::Ostream::decrIndent() } -// Write the keyword to the Ostream followed by appropriate indentation -Foam::Ostream& Foam::Ostream::writeKeyword(const Foam::keyType& keyword) +// Write the keyword followed by appropriate indentation +Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw) { indent(); - write(keyword); + write(kw); - label nSpaces = max(entryIndentation_ - label(keyword.size()), 1); + label nSpaces = entryIndentation_ - label(kw.size()); - for (label i=0; i<nSpaces; i++) + // pattern is surrounded by quotes + if (kw.isPattern()) + { + nSpaces -= 2; + } + + if (nSpaces < 1) + { + nSpaces = 1; + } + + while (nSpaces--) { write(char(token::SPACE)); } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index 6dc7df259aef54ecbc44da928f4f99f0f89883f7..32fe3fd7f5db00bda7a83729dfed14fc4b141a4f 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -60,12 +60,11 @@ protected: //- Number of spaces per indent level static const unsigned short indentSize_ = 4; - //- Current indent level - unsigned short indentLevel_; - //- Indentation of the entry from the start of the keyword static const unsigned short entryIndentation_ = 16; + //- Current indent level + unsigned short indentLevel_; public: @@ -148,9 +147,8 @@ public: //- Decrememt the indent level void decrIndent(); - //- Write the keyword to the Ostream followed by - // appropriate indentation - Ostream& writeKeyword(const keyType& keyword); + //- Write the keyword followed by an appropriate indentation + Ostream& writeKeyword(const keyType&); // Stream state functions diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H index 6041ba202a5caa6773a5a98677d4f11572cf22d2..386781c35bb96d84631e29494e9b7cc93a036abd 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H @@ -47,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class OPstream Declaration + Class OPstream Declaration \*---------------------------------------------------------------------------*/ class OPstream @@ -160,7 +160,7 @@ public: void flush() {} - //- Add '\n' and flush stream + //- Add newline and flush stream void endl() {} diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H index cd3a03ec0cb4531299379539835d86fec7cc74c5..9fd9d988246f185df2d8cfb1b87813062853cc21 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H @@ -48,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class OSstream Declaration + Class OSstream Declaration \*---------------------------------------------------------------------------*/ class OSstream @@ -162,20 +162,20 @@ public: //- Flush stream virtual void flush(); - //- Add '\n' and flush stream + //- Add newline and flush stream virtual void endl(); //- Get width of output field virtual int width() const; //- Set width of output field (and return old width) - virtual int width(const int w); + virtual int width(const int); //- Get precision of output field virtual int precision() const; //- Set precision of output field (and return old precision) - virtual int precision(const int p); + virtual int precision(const int); // Print diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index d54f1bc3d23481c36ba77583a5475e28c3de6716..5d0ee2af6581447c7151a04b4864392d9a8973ce 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -38,23 +38,23 @@ const Foam::dictionary Foam::dictionary::null; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::dictionary::findInWildcards +bool Foam::dictionary::findInPatterns ( - const bool wildCardMatch, + const bool patternMatch, const word& Keyword, DLList<entry*>::const_iterator& wcLink, DLList<autoPtr<regExp> >::const_iterator& reLink ) const { - if (wildCardEntries_.size() > 0) + if (patternEntries_.size() > 0) { - while (wcLink != wildCardEntries_.end()) + while (wcLink != patternEntries_.end()) { - if (!wildCardMatch && wcLink()->keyword() == Keyword) - { - return true; - } - else if (wildCardMatch && reLink()->match(Keyword)) + if + ( + patternMatch ? reLink()->match(Keyword) + : wcLink()->keyword() == Keyword + ) { return true; } @@ -68,23 +68,23 @@ bool Foam::dictionary::findInWildcards } -bool Foam::dictionary::findInWildcards +bool Foam::dictionary::findInPatterns ( - const bool wildCardMatch, + const bool patternMatch, const word& Keyword, DLList<entry*>::iterator& wcLink, DLList<autoPtr<regExp> >::iterator& reLink ) { - if (wildCardEntries_.size() > 0) + if (patternEntries_.size() > 0) { - while (wcLink != wildCardEntries_.end()) + while (wcLink != patternEntries_.end()) { - if (!wildCardMatch && wcLink()->keyword() == Keyword) - { - return true; - } - else if (wildCardMatch && reLink()->match(Keyword)) + if + ( + patternMatch ? reLink()->match(Keyword) + : wcLink()->keyword() == Keyword + ) { return true; } @@ -125,10 +125,10 @@ Foam::dictionary::dictionary { hashedEntries_.insert(iter().keyword(), &iter()); - if (iter().keyword().isWildCard()) + if (iter().keyword().isPattern()) { - wildCardEntries_.insert(&iter()); - wildCardRegexps_.insert + patternEntries_.insert(&iter()); + patternRegexps_.insert ( autoPtr<regExp>(new regExp(iter().keyword())) ); @@ -155,10 +155,10 @@ Foam::dictionary::dictionary { hashedEntries_.insert(iter().keyword(), &iter()); - if (iter().keyword().isWildCard()) + if (iter().keyword().isPattern()) { - wildCardEntries_.insert(&iter()); - wildCardRegexps_.insert + patternEntries_.insert(&iter()); + patternRegexps_.insert ( autoPtr<regExp>(new regExp(iter().keyword())) ); @@ -217,14 +217,14 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const } else { - if (wildCardEntries_.size() > 0) + if (patternEntries_.size() > 0) { - DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin(); + DLList<entry*>::const_iterator wcLink = patternEntries_.begin(); DLList<autoPtr<regExp> >::const_iterator reLink = - wildCardRegexps_.begin(); + patternRegexps_.begin(); - // Find in wildcards using regular expressions only - if (findInWildcards(true, keyword, wcLink, reLink)) + // Find in patterns using regular expressions only + if (findInPatterns(true, keyword, wcLink, reLink)) { return true; } @@ -246,22 +246,22 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr ( const word& keyword, bool recursive, - bool wildCardMatch + bool patternMatch ) const { HashTable<entry*>::const_iterator iter = hashedEntries_.find(keyword); if (iter == hashedEntries_.end()) { - if (wildCardMatch && wildCardEntries_.size() > 0) + if (patternMatch && patternEntries_.size() > 0) { DLList<entry*>::const_iterator wcLink = - wildCardEntries_.begin(); + patternEntries_.begin(); DLList<autoPtr<regExp> >::const_iterator reLink = - wildCardRegexps_.begin(); + patternRegexps_.begin(); - // Find in wildcards using regular expressions only - if (findInWildcards(wildCardMatch, keyword, wcLink, reLink)) + // Find in patterns using regular expressions only + if (findInPatterns(patternMatch, keyword, wcLink, reLink)) { return wcLink(); } @@ -269,7 +269,7 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr if (recursive && &parent_ != &dictionary::null) { - return parent_.lookupEntryPtr(keyword, recursive, wildCardMatch); + return parent_.lookupEntryPtr(keyword, recursive, patternMatch); } else { @@ -285,21 +285,22 @@ Foam::entry* Foam::dictionary::lookupEntryPtr ( const word& keyword, bool recursive, - bool wildCardMatch + bool patternMatch ) { HashTable<entry*>::iterator iter = hashedEntries_.find(keyword); if (iter == hashedEntries_.end()) { - if (wildCardMatch && wildCardEntries_.size() > 0) + if (patternMatch && patternEntries_.size() > 0) { DLList<entry*>::iterator wcLink = - wildCardEntries_.begin(); + patternEntries_.begin(); DLList<autoPtr<regExp> >::iterator reLink = - wildCardRegexps_.begin(); - // Find in wildcards using regular expressions only - if (findInWildcards(wildCardMatch, keyword, wcLink, reLink)) + patternRegexps_.begin(); + + // Find in patterns using regular expressions only + if (findInPatterns(patternMatch, keyword, wcLink, reLink)) { return wcLink(); } @@ -311,7 +312,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr ( keyword, recursive, - wildCardMatch + patternMatch ); } else @@ -328,10 +329,10 @@ const Foam::entry& Foam::dictionary::lookupEntry ( const word& keyword, bool recursive, - bool wildCardMatch + bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch); + const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); if (entryPtr == NULL) { @@ -352,16 +353,16 @@ Foam::ITstream& Foam::dictionary::lookup ( const word& keyword, bool recursive, - bool wildCardMatch + bool patternMatch ) const { - return lookupEntry(keyword, recursive, wildCardMatch).stream(); + return lookupEntry(keyword, recursive, patternMatch).stream(); } bool Foam::dictionary::isDict(const word& keyword) const { - // Find non-recursive with wildcards + // Find non-recursive with patterns const entry* entryPtr = lookupEntryPtr(keyword, false, true); if (entryPtr) @@ -430,7 +431,26 @@ Foam::wordList Foam::dictionary::toc() const { wordList keys(size()); - label i = 0; + label nKeys = 0; + for + ( + IDLList<entry>::const_iterator iter = begin(); + iter != end(); + ++iter + ) + { + keys[nKeys++] = iter().keyword(); + } + + return keys; +} + + +Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const +{ + List<keyType> keys(size()); + + label nKeys = 0; for ( IDLList<entry>::const_iterator iter = begin(); @@ -438,8 +458,12 @@ Foam::wordList Foam::dictionary::toc() const ++iter ) { - keys[i++] = iter().keyword(); + if (iter().keyword().isPattern() ? patterns : !patterns) + { + keys[nKeys++] = iter().keyword(); + } } + keys.setSize(nKeys); return keys; } @@ -473,10 +497,10 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) { entryPtr->name() = name_ + "::" + entryPtr->keyword(); - if (entryPtr->keyword().isWildCard()) + if (entryPtr->keyword().isPattern()) { - wildCardEntries_.insert(entryPtr); - wildCardRegexps_.insert + patternEntries_.insert(entryPtr); + patternRegexps_.insert ( autoPtr<regExp>(new regExp(entryPtr->keyword())) ); @@ -502,10 +526,10 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) entryPtr->name() = name_ + "::" + entryPtr->keyword(); IDLList<entry>::append(entryPtr); - if (entryPtr->keyword().isWildCard()) + if (entryPtr->keyword().isPattern()) { - wildCardEntries_.insert(entryPtr); - wildCardRegexps_.insert + patternEntries_.insert(entryPtr); + patternRegexps_.insert ( autoPtr<regExp>(new regExp(entryPtr->keyword())) ); @@ -597,16 +621,15 @@ bool Foam::dictionary::remove(const word& Keyword) if (iter != hashedEntries_.end()) { - // Delete from wildcards first - DLList<entry*>::iterator wcLink = - wildCardEntries_.begin(); - DLList<autoPtr<regExp> >::iterator reLink = wildCardRegexps_.begin(); + // Delete from patterns first + DLList<entry*>::iterator wcLink = patternEntries_.begin(); + DLList<autoPtr<regExp> >::iterator reLink = patternRegexps_.begin(); - // Find in wildcards using exact match only - if (findInWildcards(false, Keyword, wcLink, reLink)) + // Find in pattern using exact match only + if (findInPatterns(false, Keyword, wcLink, reLink)) { - wildCardEntries_.remove(wcLink); - wildCardRegexps_.remove(reLink); + patternEntries_.remove(wcLink); + patternRegexps_.remove(reLink); } IDLList<entry>::remove(iter()); @@ -643,14 +666,14 @@ bool Foam::dictionary::changeKeyword return false; } - if (iter()->keyword().isWildCard()) + if (iter()->keyword().isPattern()) { FatalErrorIn ( "dictionary::changeKeyword(const word&, const word&, bool)" ) << "Old keyword "<< oldKeyword - << " is a wildcard." - << "Wildcard replacement not yet implemented." + << " is a pattern." + << "Pattern replacement not yet implemented." << exit(FatalError); } @@ -662,19 +685,19 @@ bool Foam::dictionary::changeKeyword { if (forceOverwrite) { - if (iter2()->keyword().isWildCard()) + if (iter2()->keyword().isPattern()) { - // Delete from wildcards first + // Delete from patterns first DLList<entry*>::iterator wcLink = - wildCardEntries_.begin(); + patternEntries_.begin(); DLList<autoPtr<regExp> >::iterator reLink = - wildCardRegexps_.begin(); + patternRegexps_.begin(); - // Find in wildcards using exact match only - if (findInWildcards(false, iter2()->keyword(), wcLink, reLink)) + // Find in patterns using exact match only + if (findInPatterns(false, iter2()->keyword(), wcLink, reLink)) { - wildCardEntries_.remove(wcLink); - wildCardRegexps_.remove(reLink); + patternEntries_.remove(wcLink); + patternRegexps_.remove(reLink); } } @@ -701,10 +724,10 @@ bool Foam::dictionary::changeKeyword hashedEntries_.erase(oldKeyword); hashedEntries_.insert(newKeyword, iter()); - if (newKeyword.isWildCard()) + if (newKeyword.isPattern()) { - wildCardEntries_.insert(iter()); - wildCardRegexps_.insert + patternEntries_.insert(iter()); + patternRegexps_.insert ( autoPtr<regExp>(new regExp(newKeyword)) ); @@ -770,8 +793,8 @@ void Foam::dictionary::clear() { IDLList<entry>::clear(); hashedEntries_.clear(); - wildCardEntries_.clear(); - wildCardRegexps_.clear(); + patternEntries_.clear(); + patternRegexps_.clear(); } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 1d87a08fd64d7505d4628c0cd2740dd6eb12db82..a4020b6f32f6d2c0aa5bddb54eceae944c385c0c 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -27,12 +27,12 @@ Class Description A list of keyword definitions, which are a keyword followed by any number - of values (e.g. words and numbers). The keywords can represent wildcards + of values (e.g. words and numbers). The keywords can represent patterns which are matched using Posix regular expressions. The general order for - searching is + searching is as follows: - exact match - - wildcard match (in reverse order) - - optional recursion into subdictionaries + - pattern match (in reverse order) + - optional recursion into the enclosing (parent) dictionaries The dictionary class is the base class for IOdictionary. It also serves as a bootstrap dictionary for the objectRegistry data @@ -92,29 +92,27 @@ class dictionary //- Parent dictionary const dictionary& parent_; - //- Wildcard entries - DLList<entry*> wildCardEntries_; + //- Entries of matching patterns + DLList<entry*> patternEntries_; - //- Wildcard precompiled regular expressions - DLList<autoPtr<regExp> > wildCardRegexps_; + //- Patterns as precompiled regular expressions + DLList<autoPtr<regExp> > patternRegexps_; // Private Member Functions - //- Search wildcard table either for exact match or for regular - // expression match. - bool findInWildcards + //- Search patterns table for exact match or regular expression match + bool findInPatterns ( - const bool wildCardMatch, + const bool patternMatch, const word& Keyword, DLList<entry*>::const_iterator& wcLink, DLList<autoPtr<regExp> >::const_iterator& reLink ) const; - //- Search wildcard table either for exact match or for regular - // expression match. - bool findInWildcards + //- Search patterns table for exact match or regular expression match + bool findInPatterns ( - const bool wildCardMatch, + const bool patternMatch, const word& Keyword, DLList<entry*>::iterator& wcLink, DLList<autoPtr<regExp> >::iterator& reLink @@ -210,83 +208,88 @@ public: // Search and lookup //- Search dictionary for given keyword - // If recursive search parent dictionaries + // If recursive, search parent dictionaries bool found(const word&, bool recursive=false) const; //- Find and return an entry data stream pointer if present // otherwise return NULL. - // If recursive search parent dictionaries. - // If wildCardMatch use wildcards. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions const entry* lookupEntryPtr ( const word&, bool recursive, - bool wildCardMatch + bool patternMatch ) const; //- Find and return an entry data stream pointer for manipulation // if present otherwise return NULL. - // If recursive search parent dictionaries. - // If wildCardMatch use wildcards. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. entry* lookupEntryPtr ( const word&, bool recursive, - bool wildCardMatch + bool patternMatch ); //- Find and return an entry data stream if present otherwise error. - // If recursive search parent dictionaries. - // If wildCardMatch use wildcards. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. const entry& lookupEntry ( const word&, bool recursive, - bool wildCardMatch + bool patternMatch ) const; //- Find and return an entry data stream - // If recursive search parent dictionaries + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. ITstream& lookup ( const word&, bool recursive=false, - bool wildCardMatch=true + bool patternMatch=true ) const; //- Find and return a T, // if not found return the given default value - // If recursive search parent dictionaries + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. template<class T> T lookupOrDefault ( const word&, const T&, bool recursive=false, - bool wildCardMatch=true + bool patternMatch=true ) const; //- Find and return a T, if not found return the given // default value, and add to dictionary. - // If recursive search parent dictionaries + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. template<class T> T lookupOrAddDefault ( const word&, const T&, bool recursive=false, - bool wildCardMatch=true + bool patternMatch=true ); //- Find an entry if present, and assign to T - // Returns true if the entry was found + // Returns true if the entry was found. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. template<class T> bool readIfPresent ( const word&, T&, bool recursive=false, - bool wildCardMatch=true + bool patternMatch=true ) const; //- Check if entry is a sub-dictionary @@ -305,6 +308,9 @@ public: //- Return the table of contents wordList toc() const; + //- Return the list of available keys or patterns + List<keyType> keys(bool patterns=false) const; + // Editing //- Add a new entry @@ -393,7 +399,7 @@ public: void operator=(const dictionary&); //- Include entries from the given dictionary. - // Warn, but do not overwrite existing entries + // Warn, but do not overwrite existing entries. void operator+=(const dictionary&); //- Conditionally include entries from the given dictionary. @@ -417,13 +423,13 @@ public: // Global Operators -//- Combine dictionaries starting from the entries in dict1 and then including -// those from dict2. +//- Combine dictionaries. +// Starting from the entries in dict1 and then including those from dict2. // Warn, but do not overwrite the entries from dict1. dictionary operator+(const dictionary& dict1, const dictionary& dict2); -//- Combine dictionaries starting from the entries in dict1 and then including -// those from dict2. +//- Combine dictionaries. +// Starting from the entries in dict1 and then including those from dict2. // Do not overwrite the entries from dict1. dictionary operator|(const dictionary& dict1, const dictionary& dict2); diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H index 1909f4851ddc4bbdae66a9586965102ef613d7a9..2b86c53d01329de349ee0277248c4092510687a4 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H +++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H @@ -74,20 +74,20 @@ public: // Constructors //- Construct from the parent dictionary and Istream - dictionaryEntry(const dictionary& parentDict, Istream& is); + dictionaryEntry(const dictionary& parentDict, Istream&); //- Construct from the keyword, parent dictionary and a Istream dictionaryEntry ( - const keyType& keyword, + const keyType&, const dictionary& parentDict, - Istream& is + Istream& ); //- Construct from the keyword, parent dictionary and a dictionary dictionaryEntry ( - const keyType& keyword, + const keyType&, const dictionary& parentDict, const dictionary& dict ); @@ -96,7 +96,7 @@ public: dictionaryEntry ( const dictionary& parentDict, - const dictionaryEntry& dictEnt + const dictionaryEntry& ); autoPtr<entry> clone(const dictionary& parentDict) const @@ -158,10 +158,8 @@ public: }; -#if defined (__GNUC__) template<> -#endif -Ostream& operator<<(Ostream& os, const InfoProxy<dictionaryEntry>& ip); +Ostream& operator<<(Ostream&, const InfoProxy<dictionaryEntry>&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index a47a97681472c2d47d42b035f7504c9171a5ffa7..65883ba535be0bc8bda2fd444635c4e0d927534b 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -35,18 +35,18 @@ T Foam::dictionary::lookupOrDefault const word& keyword, const T& deflt, bool recursive, - bool wildCardMatch + bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch); + const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); - if (entryPtr == NULL) + if (entryPtr) { - return deflt; + return pTraits<T>(entryPtr->stream()); } else { - return pTraits<T>(entryPtr->stream()); + return deflt; } } @@ -57,19 +57,19 @@ T Foam::dictionary::lookupOrAddDefault const word& keyword, const T& deflt, bool recursive, - bool wildCardMatch + bool patternMatch ) { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch); + const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); - if (entryPtr == NULL) + if (entryPtr) { - add(new primitiveEntry(keyword, deflt)); - return deflt; + return pTraits<T>(entryPtr->stream()); } else { - return pTraits<T>(entryPtr->stream()); + add(new primitiveEntry(keyword, deflt)); + return deflt; } } @@ -80,19 +80,19 @@ bool Foam::dictionary::readIfPresent const word& k, T& val, bool recursive, - bool wildCardMatch + bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(k, recursive, wildCardMatch); + const entry* entryPtr = lookupEntryPtr(k, recursive, patternMatch); - if (entryPtr == NULL) + if (entryPtr) { - return false; + entryPtr->stream() >> val; + return true; } else { - entryPtr->stream() >> val; - return true; + return false; } } diff --git a/src/OpenFOAM/db/dictionary/entry/entry.H b/src/OpenFOAM/db/dictionary/entry/entry.H index 5ed8b929b6993d64db10a3ebce69047bdb83c64f..61eafc7c8a91bbd27934083befb5c6ec2a97ac80 100644 --- a/src/OpenFOAM/db/dictionary/entry/entry.H +++ b/src/OpenFOAM/db/dictionary/entry/entry.H @@ -92,20 +92,20 @@ public: //- Construct on freestore as copy with reference to the // dictionary the copy belongs to - virtual Foam::autoPtr<entry> clone + virtual autoPtr<entry> clone ( const dictionary& parentDict ) const = 0; //- Construct on freestore as copy // Note: the parent directory is set to dictionary::null - virtual Foam::autoPtr<entry> clone() const; + virtual autoPtr<entry> clone() const; //- Construct from Istream and insert into dictionary static bool New(dictionary& parentDict, Istream& is); //- Construct on freestore from Istream and return - static Foam::autoPtr<entry> New(Istream& is); + static autoPtr<entry> New(Istream& is); // Destructor diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H index 86d8afd61daad8a3d4a1dce09fabd93fd0f1a75a..1e5858abafcc1b5fc2ec9714cfb81c296c80a172 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H @@ -75,32 +75,32 @@ public: void append ( const token& currToken, - const dictionary& dict, - Istream& is + const dictionary&, + Istream& ); //- Append the given tokens starting at the current tokenIndex - void append(const tokenList& varTokens); + void append(const tokenList&); //- Expand the given variable (keyword starts with $) - bool expandVariable(const word& keyword, const dictionary& dict); + bool expandVariable(const word&, const dictionary&); //- Expand the given function (keyword starts with #) bool expandFunction ( - const word& keyword, - const dictionary& dict, - Istream& is + const word&, + const dictionary&, + Istream& ); //- Read tokens from the given stream - bool read(const dictionary& dict, Istream&); + bool read(const dictionary&, Istream&); //- Read the complete entry from the given stream - void readEntry(const dictionary& dict, Istream&); + void readEntry(const dictionary&, Istream&); //- Insert the given tokens at token i - void insert(const tokenList& varTokens, const label i); + void insert(const tokenList&, const label i); public: @@ -108,13 +108,13 @@ public: // Constructors //- Construct from keyword and a Istream - primitiveEntry(const keyType& keyword, Istream&); + primitiveEntry(const keyType&, Istream&); - //- Construct from keyword, parent dictionary and a Istream - primitiveEntry(const keyType& keyword, const dictionary&, Istream&); + //- Construct from keyword, parent dictionary and Istream + primitiveEntry(const keyType&, const dictionary& parentDict, Istream&); //- Construct from keyword and a ITstream - primitiveEntry(const keyType& keyword, const ITstream&); + primitiveEntry(const keyType&, const ITstream&); //- Construct from keyword and a token primitiveEntry(const keyType&, const token&); @@ -182,7 +182,7 @@ public: template<> -Ostream& operator<<(Ostream& os, const InfoProxy<primitiveEntry>& ip); +Ostream& operator<<(Ostream&, const InfoProxy<primitiveEntry>&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjectList/functionObjectList.C index 760cf83a2a51907a7dc1ae7ecc5ae06dbdabc5a1..8bb900edfd083eb66740c56ee0289a57a62f22e6 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjectList/functionObjectList.C @@ -27,6 +27,26 @@ License #include "functionObjectList.H" #include "Time.H" +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +Foam::functionObject* Foam::functionObjectList::remove(const word& key) +{ + functionObject* ptr = 0; + + // Find index of existing functionObject + HashTable<label>::iterator fnd = indices_.find(key); + + if (fnd != indices_.end()) + { + // remove the pointer from the old list + ptr = functions_.set(fnd(), 0).ptr(); + indices_.erase(fnd); + } + + return ptr; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjectList::functionObjectList @@ -35,24 +55,28 @@ Foam::functionObjectList::functionObjectList const bool execution ) : - HashPtrTable<functionObject>(), + functions_(), + indices_(), time_(t), - foDict_(t.controlDict()), - execution_(execution) + parentDict_(t.controlDict()), + execution_(execution), + updated_(false) {} Foam::functionObjectList::functionObjectList ( const Time& t, - const dictionary& foDict, + const dictionary& parentDict, const bool execution ) : - HashPtrTable<functionObject>(), + functions_(), + indices_(), time_(t), - foDict_(foDict), - execution_(execution) + parentDict_(parentDict), + execution_(execution), + updated_(false) {} @@ -66,52 +90,28 @@ Foam::functionObjectList::~functionObjectList() bool Foam::functionObjectList::start() { - if (execution_) - { - bool ok = false; - - if (foDict_.found("functions")) - { - HashPtrTable<functionObject> functions - ( - foDict_.lookup("functions"), - functionObject::iNew(time_) - ); - - transfer(functions); - - forAllIter(HashPtrTable<functionObject>, *this, iter) - { - ok = iter()->start() && ok; - } - } - - return ok; - } - else - { - return true; - } + return read(); } bool Foam::functionObjectList::execute() { + bool ok = true; + if (execution_) { - bool ok = false; - - forAllIter(HashPtrTable<functionObject>, *this, iter) + if (!updated_) { - ok = iter()->execute() && ok; + read(); } - return ok; - } - else - { - return true; + forAllIter(PtrList<functionObject>, functions_, iter) + { + ok = iter().execute() && ok; + } } + + return ok; } @@ -129,46 +129,108 @@ void Foam::functionObjectList::off() bool Foam::functionObjectList::read() { - bool read = false; + bool ok = true; + updated_ = execution_; + + // avoid reading/initializing if execution is off + if (!execution_) + { + return ok; + } - if (foDict_.found("functions")) + // Update existing and add new functionObjects + const entry* entryPtr = parentDict_.lookupEntryPtr("functions",false,false); + if (entryPtr) { - HashPtrTable<dictionary> functionDicts(foDict_.lookup("functions")); + PtrList<functionObject> newPtrs; + HashTable<label> newIndices; - // Update existing and add new functionObjects - forAllConstIter(HashPtrTable<dictionary>, functionDicts, iter) - { - if (found(iter.key())) - { - read = find(iter.key())()->read(*iter()) && read; - } - else - { - functionObject* functionObjectPtr = - functionObject::New(iter.key(), time_, *iter()).ptr(); + label nFunc = 0; - functionObjectPtr->start(); + if (entryPtr->isDict()) + { + // a dictionary of functionObjects + const dictionary& functionDicts = entryPtr->dict(); + newPtrs.setSize(functionDicts.size()); - insert(iter.key(), functionObjectPtr); + forAllConstIter(dictionary, functionDicts, iter) + { + // safety: + if (!iter().isDict()) + { + continue; + } + const word& key = iter().keyword(); + const dictionary& dict = iter().dict(); + + functionObject* objPtr = remove(key); + if (objPtr) + { + // existing functionObject + ok = objPtr->read(dict) && ok; + } + else + { + // new functionObject + objPtr = functionObject::New(key, time_, dict).ptr(); + ok = objPtr->start() && ok; + } + + newPtrs.set(nFunc, objPtr); + newIndices.insert(key, nFunc); + nFunc++; } } - - // Remove deleted functionObjects - forAllIter(HashPtrTable<functionObject>, *this, iter) + else { - if (!functionDicts.found(iter.key())) + // a list of functionObjects + PtrList<entry> functionDicts(entryPtr->stream()); + newPtrs.setSize(functionDicts.size()); + + forAllIter(PtrList<entry>, functionDicts, iter) { - erase(iter); + // safety: + if (!iter().isDict()) + { + continue; + } + const word& key = iter().keyword(); + const dictionary& dict = iter().dict(); + + functionObject* objPtr = remove(key); + if (objPtr) + { + // existing functionObject + ok = objPtr->read(dict) && ok; + } + else + { + // new functionObject + objPtr = functionObject::New(key, time_, dict).ptr(); + ok = objPtr->start() && ok; + } + + newPtrs.set(nFunc, objPtr); + newIndices.insert(key, nFunc); + nFunc++; } } + + // safety: + newPtrs.setSize(nFunc); + + // update PtrList of functionObjects + // also deletes existing, unused functionObjects + functions_.transfer(newPtrs); + indices_.transfer(newIndices); } else { - clear(); - read = true; + functions_.clear(); + indices_.clear(); } - return read; + return ok; } diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjectList/functionObjectList.H index 78462b653bef92507b97496d6b552c26cbc89cc4..1b0d51c066f8907504a7bf9ce96aaf14cc99eba6 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjectList/functionObjectList.H @@ -26,8 +26,8 @@ Class Foam::functionObjectList Description - List of function objects with execute function which is called for - each object. + List of function objects with execute() function that is called for each + object. See Also Foam::functionObject and Foam::OutputFilterFunctionObject @@ -41,7 +41,8 @@ SourceFiles #define functionObjectList_H #include "functionObject.H" -#include "HashPtrTable.H" +#include "HashTable.H" +#include "PtrList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,26 +50,41 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class functionObjectList Declaration + Class functionObjectList Declaration \*---------------------------------------------------------------------------*/ class functionObjectList -: - public HashPtrTable<functionObject> { // Private data + //- A list of function objects + // Avoid 'is-a' relationship for protection + PtrList<functionObject> functions_; + + //- Quick lookup of the index into the PtrList<functionObject> + // Currently only used to manage rereading/deletion + HashTable<label> indices_; + const Time& time_; - //- Dictionary containing the list of function object specifications - const dictionary& foDict_; + //- Dictionary containing the "functions" entry + // This entry can either be a list or a dictionary of + // functionObject specifications. + const dictionary& parentDict_; //- Switch for the execution of the functionObjects bool execution_; + //- Tracks if read() was called while execution was turned off + bool updated_; + // Private Member Functions + //- Remove and return the function object pointer by name. + // Return NULL if it didn't exist. + functionObject* remove(const word&); + //- Disallow default bitwise copy construct functionObjectList(const functionObjectList&); @@ -85,17 +101,17 @@ public: functionObjectList ( const Time&, - const bool execution = true + const bool execution=true ); - //- Construct from Time, functionObject dictionary and the execution - // setting + //- Construct from Time, dictionary with "functions" entry + // and the execution setting functionObjectList ( const Time&, - const dictionary& foDict, - const bool execution = true + const dictionary& parentDict, + const bool execution=true ); @@ -118,7 +134,7 @@ public: //- Switch the function objects off virtual void off(); - //- Read and set the function objects if their data has changed + //- Read and set the function objects if their data have changed virtual bool read(); }; diff --git a/src/OpenFOAM/db/scalarRange/scalarRanges.C b/src/OpenFOAM/db/scalarRange/scalarRanges.C index d2bf1c830256143be0a9a4554481cb5879e3d79c..f0cf5d5a844d72f0e7357f52fc2b979f61f353fd 100644 --- a/src/OpenFOAM/db/scalarRange/scalarRanges.C +++ b/src/OpenFOAM/db/scalarRange/scalarRanges.C @@ -51,7 +51,6 @@ Foam::scalarRanges::scalarRanges(Istream& is) } } - lst.shrink(); transfer(lst); } diff --git a/src/OpenFOAM/global/debug/debug.C b/src/OpenFOAM/global/debug/debug.C index 82ec7d7eaf13f226563e0170e44c8e45261b3980..3a3274a1e20fa9b48dea3b78cbdbd1bcb5ae79ef 100644 --- a/src/OpenFOAM/global/debug/debug.C +++ b/src/OpenFOAM/global/debug/debug.C @@ -36,19 +36,16 @@ Description namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace debug { +//! @cond ignoreDocumentation - local scope dictionary* controlDictPtr_(NULL); dictionary* debugSwitchesPtr_(NULL); dictionary* infoSwitchesPtr_(NULL); dictionary* optimisationSwitchesPtr_(NULL); -//- Class to ensure controlDictPtr_ is deleted at the end of the run -// @cond ignore documentation for this class +// to ensure controlDictPtr_ is deleted at the end of the run class deleteControlDictPtr { public: @@ -61,135 +58,110 @@ public: if (controlDictPtr_) { delete controlDictPtr_; + controlDictPtr_ = 0; } } }; -//! @endcond deleteControlDictPtr deleteControlDictPtr_; +//! @endcond ignoreDocumentation -dictionary& switchSet(const char* switchSetName, dictionary* switchSetPtr) -{ - if (!switchSetPtr) - { - if (!controlDict().found(switchSetName)) - { - cerr<< "debug::switchSet(const char*, dictionary*): " << std::endl - << " Cannot find " << switchSetName - << " in dictionary " << controlDictPtr_->name().c_str() - << std::endl << std::endl; - - ::exit(1); - } - - switchSetPtr = - const_cast<dictionary*>(&(controlDict().subDict(switchSetName))); - } - - return *switchSetPtr; -} +} // End namespace debug +} // End namespace Foam +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -int debugSwitch -( - dictionary& switchSet, - const char* switchName, - const int defaultValue -) +Foam::dictionary& Foam::debug::controlDict() { - if (switchSet.found(switchName)) - { - return readInt(switchSet.lookup(switchName)); - } - else + if (!controlDictPtr_) { - switchSet.add(switchName, defaultValue); - return defaultValue; + controlDictPtr_ = new dictionary + ( + IFstream(findEtcFile("controlDict", true))() + ); } -} + return *controlDictPtr_; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dictionary& debug::controlDict() +Foam::dictionary& Foam::debug::switchSet +( + const char* subDictName, + dictionary*& subDictPtr +) { - if (!controlDictPtr_) + if (!subDictPtr) { - fileName controlDictFileName(dotFoam("controlDict")); - - IFstream dictFile(controlDictFileName); + entry* ePtr = controlDict().lookupEntryPtr + ( + subDictName, false, false + ); - if (!dictFile.good()) + if (!ePtr || !ePtr->isDict()) { - cerr<< "debug::controlDict(): " - << "Cannot open essential file " << controlDictFileName.c_str() + cerr<< "debug::switchSet(const char*, dictionary*&):\n" + << " Cannot find " << subDictName << " in dictionary " + << controlDict().name().c_str() << std::endl << std::endl; + ::exit(1); } - controlDictPtr_ = new dictionary(dictFile); + subDictPtr = &ePtr->dict(); } - return *controlDictPtr_; + return *subDictPtr; } -dictionary& debug::debugSwitches() +Foam::dictionary& Foam::debug::debugSwitches() { return switchSet("DebugSwitches", debugSwitchesPtr_); } -int debug::debugSwitch(const char* switchName, const int defaultValue) +Foam::dictionary& Foam::debug::infoSwitches() { - return debugSwitch - ( - debugSwitches(), - switchName, - defaultValue - ); + return switchSet("InfoSwitches", infoSwitchesPtr_); } -dictionary& debug::infoSwitches() +Foam::dictionary& Foam::debug::optimisationSwitches() { - return switchSet("InfoSwitches", infoSwitchesPtr_); + return switchSet("OptimisationSwitches", optimisationSwitchesPtr_); } -int debug::infoSwitch(const char* switchName, const int defaultValue) +int Foam::debug::debugSwitch(const char* name, const int defaultValue) { - return debugSwitch + return debugSwitches().lookupOrAddDefault ( - infoSwitches(), - switchName, - defaultValue + name, defaultValue, false, false ); } -dictionary& debug::optimisationSwitches() +int Foam::debug::infoSwitch(const char* name, const int defaultValue) { - return switchSet("OptimisationSwitches", optimisationSwitchesPtr_); + return infoSwitches().lookupOrAddDefault + ( + name, defaultValue, false, false + ); } -int debug::optimisationSwitch(const char* switchName, const int defaultValue) +int Foam::debug::optimisationSwitch(const char* name, const int defaultValue) { - return debugSwitch + return optimisationSwitches().lookupOrAddDefault ( - optimisationSwitches(), - switchName, - defaultValue + name, defaultValue, false, false ); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/global/debug/debug.H b/src/OpenFOAM/global/debug/debug.H index 8787f3397da1ec1851ed87eab3a15606bfde2cfa..9431a4f78b9933dfb03e90a6825a21925ec34804 100644 --- a/src/OpenFOAM/global/debug/debug.H +++ b/src/OpenFOAM/global/debug/debug.H @@ -41,44 +41,40 @@ SourceFiles namespace Foam { +// Forward declaration of classes class dictionary; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace debug { + //- The central control dictionary. + // Located in ~/.OpenFOAM/VERSION or $WM_PROJECT_DIR/etc + // @sa Foam::findEtcFile() dictionary& controlDict(); - - dictionary& switchSet(const char* switchSetName, dictionary* switchSetPtr); - - + //- The DebugSwitches sub-dictionary in the central controlDict. dictionary& debugSwitches(); - int debugSwitch - ( - const char* switchName, - const int defaultValue = 0 - ); + //- The InfoSwitches sub-dictionary in the central controlDict. + dictionary& infoSwitches(); + //- The OptimisationSwitches sub-dictionary in the central controlDict. + dictionary& optimisationSwitches(); - dictionary& infoSwitches(); + //- Lookup debug switch or add default value. + int debugSwitch(const char* name, const int defaultValue=0); - int infoSwitch - ( - const char* switchName, - const int defaultValue = 0 - ); + //- Lookup info switch or add default value. + int infoSwitch(const char* name, const int defaultValue=0); + //- Lookup optimisation switch or add default value. + int optimisationSwitch(const char* name, const int defaultValue=0); - dictionary& optimisationSwitches(); + //- Internal function to lookup a sub-dictionary from controlDict. + dictionary& switchSet(const char* subDictName, dictionary*& subDictPtr); - int optimisationSwitch - ( - const char* switchName, - const int defaultValue = 0 - ); -} +} // End namespace debug // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/global.C b/src/OpenFOAM/global/global.C deleted file mode 100644 index 38f900ef4efa8ce214a9edbb801843a70f6231d0..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/global/global.C +++ /dev/null @@ -1,78 +0,0 @@ -/*-------------------------------*- C++ -*-----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Description - Define the globals used in the FOAM library. It is important that these - are constructed in the appropriate order to avoid the use of unconstructed - data in the global namespace. - - This file gets preprocessed by the Allwmake script to replace - PROJECT_VERSION with the appropriate version number string. - -\*---------------------------------------------------------------------------*/ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "foamVersion.H" - -const char* const Foam::FOAMversion = "dev_2008-10-29-197-gc1bfee3"; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Setup an error handler for the global new operator - -#include "new.C" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Global IO streams - -#include "IOstreams.C" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "JobInfo.H" -bool Foam::JobInfo::constructed = false; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Global error definitions (initialised by construction) - -#include "messageStream.C" -#include "error.C" -#include "IOerror.C" -#include "token.C" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Read the debug and info switches - -#include "debug.C" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Read and set cell models - -#include "globalCellModeller.C" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Create the jobInfo file in the $FOAM_JOB_DIR/runningJobs directory - -#include "JobInfo.C" - -// ************************************************************************* // diff --git a/src/OpenFOAM/global/global_raw.C b/src/OpenFOAM/global/global.Cver similarity index 94% rename from src/OpenFOAM/global/global_raw.C rename to src/OpenFOAM/global/global.Cver index 29c67cf3e0b02cde9e0870b1b27df1d8cbb76d93..e67b67b22a8352e2c27cb78564f6505f461cbb83 100644 --- a/src/OpenFOAM/global/global_raw.C +++ b/src/OpenFOAM/global/global.Cver @@ -27,8 +27,9 @@ Description are constructed in the appropriate order to avoid the use of unconstructed data in the global namespace. - This file gets preprocessed by the Allwmake script to replace - PROJECT_VERSION with the appropriate version number string. + This file has the extension .ver to force it to be parsed by the script + which converts WM_PROJECT_VERSION into the appropriate version number + string. \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index 9bfb08b0692450efcd19d9cdbeb61b0940b1aa82..169620865ec08bdfac2e208058a67f24e535eabc 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -102,7 +102,8 @@ bool chDir(const fileName& dir); // - $WM_PROJECT_DIR/etc/ // // @return the full path name or fileName::null if the name cannot be found -fileName dotFoam(const fileName& name); +// Optionally abort if the file cannot be found +fileName findEtcFile(const fileName& name, bool mandatory=false); //- Make a directory and return an error if it could not be created // and does not already exist diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C index 0fadb614bb2df69591b306503ec79e874bdf5e3b..e545798895a2bca973b9425f3300b3283608438f 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C @@ -27,14 +27,9 @@ License #include "cellModel.H" #include "pyramid.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -vector cellModel::centre +Foam::vector Foam::cellModel::centre ( const labelList& pointLabels, const pointField& points @@ -91,7 +86,7 @@ vector cellModel::centre } -scalar cellModel::mag +Foam::scalar Foam::cellModel::mag ( const labelList& pointLabels, const pointField& points @@ -143,9 +138,4 @@ scalar cellModel::mag return v; } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C index a2656f838433e68bf5feb520d980327801708b56..7d69b5238c8160f72bb66d98e45d9b12d3024b41 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C @@ -29,12 +29,58 @@ Description #include "cellModeller.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -namespace Foam +Foam::cellModeller::cellModeller() { + if (modelPtrs_.size()) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "attempt to re-construct cellModeller when it already exists" + << exit(FatalError); + } + + label maxIndex = 0; + forAll(models_, i) + { + if (models_[i].index() > maxIndex) maxIndex = models_[i].index(); + } + + modelPtrs_.setSize(maxIndex + 1); + modelPtrs_ = NULL; -cellModeller::~cellModeller() + // For all the words in the wordlist, set the details of the model + // to those specified by the word name and the other parameters + // given. This should result in an automatic 'read' of the model + // from its File (see cellModel class). + forAll(models_, i) + { + if (modelPtrs_[models_[i].index()]) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "more than one model share the index " + << models_[i].index() + << exit(FatalError); + } + + modelPtrs_[models_[i].index()] = &models_[i]; + + if (modelDictionary_.found(models_[i].name())) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "more than one model share the name " + << models_[i].name() + << exit(FatalError); + } + + modelDictionary_.insert(models_[i].name(), &models_[i]); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cellModeller::~cellModeller() {} @@ -43,9 +89,9 @@ cellModeller::~cellModeller() // Returns a pointer to a model which matches the string symbol // supplied. A null pointer is returned if there is no suitable match. -const cellModel* cellModeller::lookup(const word& symbol) +const Foam::cellModel* Foam::cellModeller::lookup(const word& name) { - HashTable<const cellModel*>::iterator iter = modelDictionary_.find(symbol); + HashTable<const cellModel*>::iterator iter = modelDictionary_.find(name); if (iter != modelDictionary_.end()) { @@ -57,9 +103,7 @@ const cellModel* cellModeller::lookup(const word& symbol) } } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H index 4f6f2ee70f679976bd23d599a8fde26f23ea0bb7..11e642d2d4d7df78b519a12ff00ad07efcf3100c 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H @@ -48,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class cellModeller Declaration + Class cellModeller Declaration \*---------------------------------------------------------------------------*/ class cellModeller @@ -69,10 +69,9 @@ public: // Constructors - //- Construct given file name + //- Construct from central "cellModels" file cellModeller(); - // Destructor ~cellModeller(); @@ -80,12 +79,10 @@ public: // Member functions - //- Look up a model given name and return ptr to model if good - // else zero + //- Look up a model by name and return a pointer to the model or NULL static const cellModel* lookup(const word&); - //- Look up a model given label and return ptr to model if good - // else zero + //- Look up a model by index and return a pointer to the model or NULL static const cellModel* lookup(const label i) { return modelPtrs_[i]; diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C deleted file mode 100644 index ef3eb17df26f7637d860b1ace079f61aafe5f08c..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C +++ /dev/null @@ -1,91 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Description - Reads the data portion of a model catalogue File. - -\*---------------------------------------------------------------------------*/ - -#include "cellModeller.H" -#include "dictionary.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -cellModeller::cellModeller() -{ - if (modelPtrs_.size()) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "attempt to re-construct cellModeller when it already exists" - << exit(FatalError); - } - - label maxIndex = 0; - forAll(models_, i) - { - if (models_[i].index() > maxIndex) maxIndex = models_[i].index(); - } - - modelPtrs_.setSize(maxIndex + 1); - modelPtrs_ = NULL; - - // For all the words in the wordlist, set the details of the model - // to those specified by the word name and the other parameters - // given. This should result in an automatic 'read' of the model - // from its File (see cellModel class). - forAll(models_, i) - { - if (modelPtrs_[models_[i].index()]) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "more than one model share the index " - << models_[i].index() - << exit(FatalError); - } - - modelPtrs_[models_[i].index()] = &models_[i]; - - if (modelDictionary_.found(models_[i].name())) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "more than one model share the name " - << models_[i].name() - << exit(FatalError); - } - - modelDictionary_.insert(models_[i].name(), &models_[i]); - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C index 54e73f855b5fa593094d104ebeb93de9fa485bf7..7f5b6274513c714f46229cb6a606bf7c2f009a33 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C @@ -23,6 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description + cellModeller global initializations \*---------------------------------------------------------------------------*/ @@ -30,24 +31,25 @@ Description #include "OSspecific.H" #include "IFstream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * * // + // PtrList of models -PtrList<cellModel> cellModeller::models_ +Foam::PtrList<Foam::cellModel> Foam::cellModeller::models_ ( - (IFstream(dotFoam("cellModels"))()) + IFstream(findEtcFile("cellModels", true))() ); // List of model pointers -List<cellModel*> cellModeller::modelPtrs_; +Foam::List<Foam::cellModel*> Foam::cellModeller::modelPtrs_; // HashTable of model pointers -HashTable<const cellModel*> cellModeller::modelDictionary_; +Foam::HashTable<const Foam::cellModel*> Foam::cellModeller::modelDictionary_; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ // Construct a dummy cellModeller which reads the models and fills // the above tables diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 8fdee370a05e9b06c5b7a8b1b67503ee4cb72063..0650dcc87978e069a19474db29a945a208c33e30 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -393,12 +393,11 @@ void Foam::globalMeshData::calcSharedEdges() const } } } - dynSharedEdgeLabels.shrink(); + sharedEdgeLabelsPtr_ = new labelList(); labelList& sharedEdgeLabels = *sharedEdgeLabelsPtr_; sharedEdgeLabels.transfer(dynSharedEdgeLabels); - dynSharedEdgeAddr.shrink(); sharedEdgeAddrPtr_ = new labelList(); labelList& sharedEdgeAddr = *sharedEdgeAddrPtr_; sharedEdgeAddr.transfer(dynSharedEdgeAddr); diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C index 6cf680ca70f3ebc4765aca9af3418d4dcc7cef15..93382ec2a43e5b4cd6f1741207ef01c5c9f790c9 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C @@ -467,10 +467,8 @@ void Foam::globalPoints::remove(const Map<label>& directNeighbours) Map<label> oldMeshToProcPoint(meshToProcPoint_); meshToProcPoint_.clear(); - procPoints_.shrink(); List<procPointList> oldProcPoints; oldProcPoints.transfer(procPoints_); - procPoints_.clear(); // Go through all equivalences for @@ -535,7 +533,7 @@ void Foam::globalPoints::remove(const Map<label>& directNeighbours) { // This happens for 'wedge' like cyclics where the two halves // come together in the same point so share the same meshPoint. - // So this meshPoint will have info of size one only. + // So this meshPoint will have info of size one only. if ( pointInfo[0][0] != Pstream::myProcNo() @@ -968,7 +966,7 @@ Foam::globalPoints::globalPoints(const polyMesh& mesh) // Pout<< " pointI:" << meshPointI << ' ' // << mesh.points()[meshPointI] // << " connected to proc " << pointInfo[i][0] - // << " point:" << pointInfo[i][1] + // << " point:" << pointInfo[i][1] // << endl; // } //} diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index 19418a23114dcf02aa3c7c1e56b29de242a5afc2..a004cfa8e279d85344ea9efd17608f77ceb16c98 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -64,7 +64,7 @@ Foam::labelListList Foam::polyMesh::cellShapePointCells forAll (pc, pointI) { - pointCellAddr[pointI].transfer(pc[pointI].shrink()); + pointCellAddr[pointI].transfer(pc[pointI]); } return pointCellAddr; diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C index 825af4cb706757fe69614ceeb264cd00208e164d..36ebdc8324e675d9010efe379256ad59b7140d11 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C @@ -298,7 +298,7 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing() forAll (faceFaces, faceI) { - faceFaces[faceI].transfer(ff[faceI].shrink()); + faceFaces[faceI].transfer(ff[faceI]); } diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C index 0f2d45ebf2bc15a902507c834869f1dcbf919010..f9a74e01990ca32d4977a5f1ff1426bde840b0f3 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C @@ -151,8 +151,6 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcEdgeLoops() while (currentEdgeI != -1); // Done all for current loop. Transfer to edgeLoops. - loop.shrink(); - edgeLoops[loopI].transfer(loop); loopI++; diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C index 47d6343f16e42639aa8f5bd9c1f277d73f773e13..d12cf2ca5da134e725ad44ea7c6935f49738a607 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C @@ -108,7 +108,7 @@ void Foam::primitiveMesh::calcCellEdges() const // reset the size forAll (ce, cellI) { - cellEdgeAddr[cellI].transfer(ce[cellI].shrink()); + cellEdgeAddr[cellI].transfer(ce[cellI]); } } } diff --git a/src/OpenFOAM/primitives/strings/keyType/keyType.H b/src/OpenFOAM/primitives/strings/keyType/keyType.H index 4d4c358d5d172f3cb831884246d9411872d0721c..6525a5404c8e119a0e1b3200378ff3baf07417b5 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyType.H +++ b/src/OpenFOAM/primitives/strings/keyType/keyType.H @@ -28,8 +28,8 @@ Class Description A class for handling keywords in dictionaries. - A keyType is the keyword of a dictionary. It differs from word in that - it accepts wildcards. + A keyType is the keyword of a dictionary. + It differs from word in that it accepts patterns (regular expressions). SourceFiles keyType.C @@ -53,7 +53,7 @@ class Ostream; /*---------------------------------------------------------------------------*\ - Class keyType Declaration + Class keyType Declaration \*---------------------------------------------------------------------------*/ class keyType @@ -62,7 +62,8 @@ class keyType { // Private member data - bool isWildCard_; + //- Is the keyType a pattern (regular expression) + bool isPattern_; // Private Member Functions @@ -78,22 +79,22 @@ public: inline keyType(); //- Construct as copy - inline keyType(const keyType& s); + inline keyType(const keyType&); //- Construct as copy of word - inline keyType(const word& s); + inline keyType(const word&); //- Construct as copy of string. Expect it to be regular expression. - inline keyType(const string& s); + inline keyType(const string&); //- Construct as copy of character array - inline keyType(const char* s); + inline keyType(const char*); //- Construct as copy of std::string - inline keyType(const std::string& s, const bool isWildCard); + inline keyType(const std::string&, const bool isPattern); //- Construct from Istream - keyType(Istream& is); + keyType(Istream&); // Member functions @@ -101,29 +102,25 @@ public: //- Is this character valid for a keyType inline static bool valid(char c); - //- Is the type a wildcard? - inline bool isWildCard() const; - + //- Should be treated as a match rather than a literal string + inline bool isPattern() const; // Member operators // Assignment - inline void operator=(const keyType& s); + inline void operator=(const keyType&); + inline void operator=(const word&); //- Assign from regular expression. - inline void operator=(const string& s); - - inline void operator=(const word& s); - + inline void operator=(const string&); inline void operator=(const char*); // IOstream operators - friend Istream& operator>>(Istream& is, keyType& w); - - friend Ostream& operator<<(Ostream& os, const keyType& w); + friend Istream& operator>>(Istream&, keyType&); + friend Ostream& operator<<(Ostream&, const keyType&); }; diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H index f3785ebbffe68b68d0093a79cc55f7e70d2e47c8..d76205d795776d624c94367e01c7db76f8babc77 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H +++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H @@ -30,43 +30,40 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -//- Construct null inline Foam::keyType::keyType() : word(), - isWildCard_(false) + isPattern_(false) {} -//- Construct as copy inline Foam::keyType::keyType(const keyType& s) : word(s, false), - isWildCard_(s.isWildCard()) + isPattern_(s.isPattern()) {} -//- Construct as copy of word inline Foam::keyType::keyType(const word& s) : word(s, false), - isWildCard_(false) + isPattern_(false) {} -//- Construct as copy of string. Expect it to be regular expression +// Construct as copy of string. Expect it to be regular expression inline Foam::keyType::keyType(const string& s) : word(s, false), - isWildCard_(true) + isPattern_(true) {} -//- Construct as copy of character array +// Construct as copy of character array inline Foam::keyType::keyType(const char* s) : word(s, false), - isWildCard_(false) + isPattern_(false) {} @@ -74,11 +71,11 @@ inline Foam::keyType::keyType(const char* s) inline Foam::keyType::keyType ( const std::string& s, - const bool isWildCard + const bool isPattern ) : word(s, false), - isWildCard_(isWildCard) + isPattern_(isPattern) {} @@ -90,9 +87,9 @@ inline bool Foam::keyType::valid(char c) } -bool Foam::keyType::isWildCard() const +bool Foam::keyType::isPattern() const { - return isWildCard_; + return isPattern_; } @@ -102,14 +99,14 @@ inline void Foam::keyType::operator=(const keyType& s) { // Bypass checking string::operator=(s); - isWildCard_ = s.isWildCard(); + isPattern_ = s.isPattern_; } inline void Foam::keyType::operator=(const word& s) { word::operator=(s); - isWildCard_ = false; + isPattern_ = false; } @@ -117,7 +114,7 @@ inline void Foam::keyType::operator=(const string& s) { // Bypass checking string::operator=(s); - isWildCard_ = true; + isPattern_ = true; } @@ -125,7 +122,7 @@ inline void Foam::keyType::operator=(const char* s) { // Bypass checking string::operator=(s); - isWildCard_ = false; + isPattern_ = false; } diff --git a/src/OpenFOAM/primitives/strings/string/string.C b/src/OpenFOAM/primitives/strings/string/string.C index b3c218eacd1b2cef3586c4de36d7b4a1045e8f58..38393bfca7302740cded5dc6dca205d8ef88ca84 100644 --- a/src/OpenFOAM/primitives/strings/string/string.C +++ b/src/OpenFOAM/primitives/strings/string/string.C @@ -202,7 +202,7 @@ Foam::string& Foam::string::expand() // otherwise add extra test if (user == "OpenFOAM") { - *this = dotFoam(file); + *this = findEtcFile(file); } else { diff --git a/src/OpenFOAM/primitives/strings/string/string.H b/src/OpenFOAM/primitives/strings/string/string.H index 82cc904ef48f3fb01d87d8bcdbea4d238c0fb5d6..13e996b5110aa98f2a1f1c0190e202118397ba4e 100644 --- a/src/OpenFOAM/primitives/strings/string/string.H +++ b/src/OpenFOAM/primitives/strings/string/string.H @@ -34,7 +34,7 @@ Description Used as a base class for word and fileName. See Also - Foam::dotFoam() for information about the site/user OpenFOAM + Foam::findEtcFile() for information about the site/user OpenFOAM configuration directory SourceFiles @@ -176,7 +176,7 @@ public: // - leading "~OpenFOAM" : site/user OpenFOAM configuration directory // // @sa - // Foam::dotFoam + // Foam::findEtcFile string& expand(); //- Remove repeated characters returning true if string changed diff --git a/src/OpenFOAM/primitives/strings/word/word.H b/src/OpenFOAM/primitives/strings/word/word.H index 6565c28b4f8ede3a084ac9c56fc67513e8ac6052..96d2c73cfb864fc6349e50e2577b29a363f35210 100644 --- a/src/OpenFOAM/primitives/strings/word/word.H +++ b/src/OpenFOAM/primitives/strings/word/word.H @@ -87,7 +87,7 @@ public: inline word(const word&); //- Construct as copy of character array - inline word(const char*, const bool doStripInvalid = true); + inline word(const char*, const bool doStripInvalid=true); //- Construct as copy with a maximum number of characters inline word @@ -98,10 +98,10 @@ public: ); //- Construct as copy of string - inline word(const string&, const bool doStripInvalid = true); + inline word(const string&, const bool doStripInvalid=true); //- Construct as copy of std::string - inline word(const std::string&, const bool doStripInvalid = true); + inline word(const std::string&, const bool doStripInvalid=true); //- Construct from Istream word(Istream&); diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index 25886fbfaca1614b56d2ef07de7f5570aaac3205..f43c2b1a30a3f05be9019deb965bf619c95f203e 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -5,7 +5,11 @@ set -x wmake libso dummy case "$WM_MPLIB" in -LAM | OPENMPI | MPI | MPICH | MPICH-GM | HPMPI ) +GAMMA) + wmake libso gamma + ;; + +LAM | *MPI* ) export WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB set +x echo @@ -13,10 +17,6 @@ LAM | OPENMPI | MPI | MPICH | MPICH-GM | HPMPI ) set -x wmake libso mpi ;; - -GAMMA) - wmake libso gamma - ;; esac # ----------------------------------------------------------------- end-of-file diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index 6d98bdfebc0701197152ed8094d5df595572a4d5..8b3e527d37d2a1aae45681b4d5e9b06fed051f8e 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -546,7 +546,7 @@ void Foam::meshRefinement::calcLocalRegions } } } - localCc.shrink(); + localPoints.transfer(localCc); if (localPoints.size() != globalToLocalRegion.size()) diff --git a/src/conversion/polyDualMesh/polyDualMesh.C b/src/conversion/polyDualMesh/polyDualMesh.C index 9b310d2bf4843589658fc4f61e76fcb7861a2dac..73ca981f98a8f58b85b3c650af77a7a84d8868bf 100644 --- a/src/conversion/polyDualMesh/polyDualMesh.C +++ b/src/conversion/polyDualMesh/polyDualMesh.C @@ -412,11 +412,9 @@ void Foam::polyDualMesh::collectPatchInternalFace } } - dualFace2.transfer(dualFace.shrink()); - dualFace.clear(); + dualFace2.transfer(dualFace); - featEdgeIndices2.transfer(featEdgeIndices.shrink()); - featEdgeIndices.clear(); + featEdgeIndices2.transfer(featEdgeIndices); if (reverseFace) { @@ -1590,8 +1588,7 @@ void Foam::polyDualMesh::calcFeatures allFeaturePoints.append(allBoundary.meshPoints()[pointI]); } } - featurePoints.transfer(allFeaturePoints.shrink()); - allFeaturePoints.clear(); + featurePoints.transfer(allFeaturePoints); if (debug) { @@ -1633,8 +1630,7 @@ void Foam::polyDualMesh::calcFeatures allFeatureEdges.append(meshEdges[edgeI]); } } - featureEdges.transfer(allFeatureEdges.shrink()); - allFeatureEdges.clear(); + featureEdges.transfer(allFeatureEdges); } diff --git a/src/decompositionAgglomeration/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/decompositionAgglomeration/decompositionMethods/decompositionMethod/decompositionMethod.C index 071a63affc0641b003f16673c745696141ce1a75..f2b929c6567ffef4b8e57f489657d8b03785c2ef 100644 --- a/src/decompositionAgglomeration/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/decompositionAgglomeration/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -165,8 +165,7 @@ void Foam::decompositionMethod::calcCellCells cellCells.setSize(dynCellCells.size()); forAll(dynCellCells, coarseI) { - cellCells[coarseI].transfer(dynCellCells[coarseI].shrink()); - dynCellCells[coarseI].clear(); + cellCells[coarseI].transfer(dynCellCells[coarseI]); } } diff --git a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C index 8b3092f08f6ea860ca0133b9acd49009ce7cab3a..0df751b6ded31c1f900f6fe509314f0d8c31545e 100644 --- a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C +++ b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C @@ -794,8 +794,7 @@ Foam::labelList Foam::parMetisDecomp::decompose globalRegionRegions.setSize(dynRegionRegions.size()); forAll(dynRegionRegions, i) { - globalRegionRegions[i].transfer(dynRegionRegions[i].shrink()); - dynRegionRegions[i].clear(); + globalRegionRegions[i].transfer(dynRegionRegions[i]); } } @@ -859,7 +858,7 @@ Foam::labelList Foam::parMetisDecomp::decompose // Check for user supplied weights and decomp options if (decompositionDict_.found("metisCoeffs")) { - const dictionary& metisCoeffs = + const dictionary& metisCoeffs = decompositionDict_.subDict("metisCoeffs"); word weightsFile; diff --git a/src/dynamicMesh/boundaryMesh/boundaryMesh.C b/src/dynamicMesh/boundaryMesh/boundaryMesh.C index 76201ff987c91e29e48f6b5710a3fb1c398ad849..817317a62e7483417b8caa231a4dc1565a0564be 100644 --- a/src/dynamicMesh/boundaryMesh/boundaryMesh.C +++ b/src/dynamicMesh/boundaryMesh/boundaryMesh.C @@ -1503,17 +1503,13 @@ void Foam::boundaryMesh::setExtraEdges(const label edgeI) { labelList minDistance(mesh().nEdges(), -1); - // All edge labels encountered - + // All edge labels encountered DynamicList<label> visitedEdges; // Floodfill from edgeI starting from distance 0. Stop at distance. markEdges(8, edgeI, 0, minDistance, visitedEdges); - visitedEdges.shrink(); - // Set edge labels to display - //? Allowed to transfer from DynamicList to List extraEdges_.transfer(visitedEdges); } diff --git a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C index 39be5d1d2f375aaa7cfcafa5c584edbdffbd1ed3..2a6630333f59b6248c8fb802aef10ad241f99e4b 100644 --- a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C @@ -787,9 +787,6 @@ bool Foam::topoCellLooper::cut } else { - localLoop.shrink(); - localLoopWeights.shrink(); - loop.transfer(localLoop); loopWeights.transfer(localLoopWeights); @@ -799,17 +796,16 @@ bool Foam::topoCellLooper::cut else { // Let parent handle poly case. - return - hexCellLooper::cut - ( - refDir, - cellI, - vertIsCut, - edgeIsCut, - edgeWeight, - loop, - loopWeights - ); + return hexCellLooper::cut + ( + refDir, + cellI, + vertIsCut, + edgeIsCut, + edgeWeight, + loop, + loopWeights + ); } } } diff --git a/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C b/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C index 391b513758e9cdcbfe63db653040af07e92bfda9..34912f8c27cee49cb097f55d9d7db45541a1a02d 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C +++ b/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C @@ -131,11 +131,8 @@ Foam::face Foam::boundaryCutter::addEdgeCutsToFace } } - newFace.shrink(); - face returnFace; returnFace.transfer(newFace); - newFace.clear(); if (debug) { @@ -361,9 +358,7 @@ bool Foam::boundaryCutter::splitFace { // Enough vertices to create a face from. face tmpFace; - newFace.shrink(); tmpFace.transfer(newFace); - newFace.clear(); // Add face tmpFace addFace(faceI, tmpFace, modifiedFace, meshMod); @@ -381,9 +376,7 @@ bool Foam::boundaryCutter::splitFace { // Enough vertices to create a face from. face tmpFace; - newFace.shrink(); tmpFace.transfer(newFace); - newFace.clear(); // Add face tmpFace addFace(faceI, tmpFace, modifiedFace, meshMod); diff --git a/src/dynamicMesh/meshCut/wallLayerCells/wallLayerCells.C b/src/dynamicMesh/meshCut/wallLayerCells/wallLayerCells.C index 9632618c8a60b577e6d4ba0b2c22d729550d0c6c..c46266496f5c19a18dc21d6981744faf0039201d 100644 --- a/src/dynamicMesh/meshCut/wallLayerCells/wallLayerCells.C +++ b/src/dynamicMesh/meshCut/wallLayerCells/wallLayerCells.C @@ -222,8 +222,6 @@ Foam::wallLayerCells::wallLayerCells } } - refineCells.shrink(); - // Transfer refineCells storage to this. transfer(refineCells); } diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C index b7edb38f2bb8af1b0eb0e925b562290f92fdaf16..b59d97f19db59665e481d69bb2228317d9e6294e 100644 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C +++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C @@ -489,7 +489,6 @@ void Foam::polyMeshAdder::insertVertices if (workFace.size() != allF.size()) { - workFace.shrink(); allF.transfer(workFace); } } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C index 8b510a706467c081c0f56f4f90feab541a151181..4a9ebbaf7d3e9d6faed74c7362e7532890bbe5c1 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C @@ -1079,8 +1079,7 @@ Foam::label Foam::hexRef8::storeMidPointInfo } face newFace; - newFace.transfer(newFaceVerts.shrink()); - newFaceVerts.clear(); + newFace.transfer(newFaceVerts); label anchorCell0 = getAnchorCell ( @@ -3687,8 +3686,7 @@ Foam::labelListList Foam::hexRef8::setRefinement ); // Convert dynamiclist to face. - newFace.transfer(faceVerts.shrink()); - faceVerts.clear(); + newFace.transfer(faceVerts); //Pout<< "Split face:" << faceI << " verts:" << f // << " into quad:" << newFace << endl; @@ -3811,8 +3809,7 @@ Foam::labelListList Foam::hexRef8::setRefinement } face newFace; - newFace.transfer(newFaceVerts.shrink()); - + newFace.transfer(newFaceVerts); // The point with the lowest level should be an anchor // point of the neighbouring cells. @@ -3993,10 +3990,8 @@ Foam::labelListList Foam::hexRef8::setRefinement } } - pointLevel_.transfer(newPointLevel.shrink()); - newPointLevel.clear(); - cellLevel_.transfer(newCellLevel.shrink()); - newCellLevel.clear(); + pointLevel_.transfer(newPointLevel); + cellLevel_.transfer(newCellLevel); // Mark files as changed setInstance(mesh_.facesInstance()); diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 6ed3f0c14f5fd9cdd6506ede3ef1afbc859c83c6..e22ca0cd69fdcb5d4effe0b4b39cca3a08a4dbc8 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -1964,21 +1964,15 @@ void Foam::polyTopoChange::compactAndReorder // Clear inflation info { - faceFromPoint_.clear(); - faceFromPoint_.resize(0); - faceFromEdge_.clear(); - faceFromEdge_.resize(0); + faceFromPoint_.clearStorage(); + faceFromEdge_.clearStorage(); - cellFromPoint_.clear(); - cellFromPoint_.resize(0); - cellFromEdge_.clear(); - cellFromEdge_.resize(0); - cellFromFace_.clear(); - cellFromFace_.resize(0); + cellFromPoint_.clearStorage(); + cellFromEdge_.clearStorage(); + cellFromFace_.clearStorage(); } - const polyBoundaryMesh& boundary = mesh.boundaryMesh(); // Grab patch mesh point maps @@ -2092,10 +2086,8 @@ void Foam::polyTopoChange::clear() points_.clearStorage(); pointMap_.clearStorage(); reversePointMap_.clearStorage(); - pointZone_.clear(); - pointZone_.resize(0); - retiredPoints_.clear(); - retiredPoints_.resize(0); + pointZone_.clearStorage(); + retiredPoints_.clearStorage(); faces_.clearStorage(); region_.clearStorage(); @@ -2103,27 +2095,19 @@ void Foam::polyTopoChange::clear() faceNeighbour_.clearStorage(); faceMap_.clearStorage(); reverseFaceMap_.clearStorage(); - faceFromPoint_.clear(); - faceFromPoint_.resize(0); - faceFromEdge_.clear(); - faceFromEdge_.resize(0); - flipFaceFlux_.clear(); - flipFaceFlux_.resize(0); - faceZone_.clear(); - faceZone_.resize(0); - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); + faceFromPoint_.clearStorage(); + faceFromEdge_.clearStorage(); + flipFaceFlux_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); nActiveFaces_ = 0; cellMap_.clearStorage(); reverseCellMap_.clearStorage(); cellZone_.clearStorage(); - cellFromPoint_.clear(); - cellFromPoint_.resize(0); - cellFromEdge_.clear(); - cellFromEdge_.resize(0); - cellFromFace_.clear(); - cellFromFace_.resize(0); + cellFromPoint_.clearStorage(); + cellFromEdge_.clearStorage(); + cellFromFace_.clearStorage(); } @@ -2996,8 +2980,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh // Clear out primitives { - retiredPoints_.clear(); - retiredPoints_.resize(0); + retiredPoints_.clearStorage(); region_.clearStorage(); } @@ -3053,15 +3036,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh // Clear zone info { - pointZone_.clear(); - pointZone_.resize(0); - - faceZone_.clear(); - faceZone_.resize(0); - - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); - + pointZone_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); cellZone_.clearStorage(); } @@ -3227,8 +3204,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh // Clear out primitives { - retiredPoints_.clear(); - retiredPoints_.resize(0); + retiredPoints_.clearStorage(); region_.clearStorage(); } @@ -3346,15 +3322,9 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh // Clear zone info { - pointZone_.clear(); - pointZone_.resize(0); - - faceZone_.clear(); - faceZone_.resize(0); - - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); - + pointZone_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); cellZone_.clearStorage(); } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C index 32cb3c5b823a0bb07da241ca8a62d4a733fe1ca2..df0197873c759772e56b437b5adb686eab915d4f 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C @@ -365,8 +365,7 @@ void Foam::removeFaces::mergeFaces } face mergedFace; - mergedFace.transfer(faceVerts.shrink()); - faceVerts.clear(); + mergedFace.transfer(faceVerts); if (reverseLoop) { @@ -574,7 +573,7 @@ Foam::removeFaces::removeFaces // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Removing face connects cells. This function works out a consistent set of -// cell regions. +// cell regions. // - returns faces to remove. Can be extended with additional faces // (if owner would become neighbour) // - sets cellRegion to -1 or to region number @@ -693,7 +692,7 @@ Foam::label Foam::removeFaces::compatibleRemoves // Various checks - // - master is lowest numbered in any region + // - master is lowest numbered in any region // - regions have more than 1 cell { labelList nCells(regionMaster.size(), 0); @@ -763,8 +762,7 @@ Foam::label Foam::removeFaces::compatibleRemoves } } - newFacesToRemove.transfer(allFacesToRemove.shrink()); - allFacesToRemove.clear(); + newFacesToRemove.transfer(allFacesToRemove); return nUsedRegions; } @@ -1102,7 +1100,7 @@ void Foam::removeFaces::setRefinement else if (nFacesPerEdge[edgeI] == 1) { // 1: illegal. Tested above. - } + } else if (nFacesPerEdge[edgeI] == 2) { // 2: merge faces. @@ -1219,7 +1217,7 @@ void Foam::removeFaces::setRefinement << "The other side has region:" << nbrRegion << endl << "(region -1 means face is to be deleted)" - << abort(FatalError); + << abort(FatalError); } } else if (toNbrRegion[myRegion] == -1) @@ -1240,9 +1238,9 @@ void Foam::removeFaces::setRefinement << " with coupled neighbouring regions:" << toNbrRegion[myRegion] << " and " << nbrRegion - << abort(FatalError); + << abort(FatalError); } - } + } } } @@ -1358,7 +1356,7 @@ void Foam::removeFaces::setRefinement pointsToRemove ) ); - + // // Now we know // - faceLabels : faces to remove (sync since no boundary faces) @@ -1367,7 +1365,7 @@ void Foam::removeFaces::setRefinement // - faceRegion : connected face region of faces to be merged (sync) // - affectedFace : faces with points removed and/or owner/neighbour // changed (non sync) - + // Start modifying mesh and keep track of faces changed. diff --git a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C index cce2f1cd4437aba58d989fea2413cd13168f599e..2a36d3b778d9ca5d30cd4d2d40d04548f993ed9a 100644 --- a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C +++ b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C @@ -372,7 +372,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // sliding intergace coupling in order to allow the point // projection to be done separately from the actual cutting. // Please change consistently with slidingInterfaceProjectPoints.C - // + // if (debug) { Pout << "Processing slave edges " << endl; @@ -543,7 +543,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const forAll (curFaces, faceI) { // Pout<< "face: " << curFaces[faceI] << " " -// << masterPatch[curFaces[faceI]] +// << masterPatch[curFaces[faceI]] // << " local: " // << masterPatch.localFaces()[curFaces[faceI]] // << endl; @@ -566,7 +566,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // The edge cutting code is repeated in // slidingInterface::modifyMotionPoints. This is done for // efficiency reasons and avoids multiple creation of cutting - // planes. Please update both simultaneously. + // planes. Please update both simultaneously. const point& a = projectedSlavePoints[curEdge.start()]; const point& b = projectedSlavePoints[curEdge.end()]; @@ -623,7 +623,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const if (slaveCut.hit()) { // Strict checking of slave cut to avoid capturing - // end points. + // end points. scalar cutOnSlave = ( ( @@ -747,14 +747,14 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const forAll (pointsIntoMasterEdges, i) { - pime[i].transfer(pointsIntoMasterEdges[i].shrink()); + pime[i].transfer(pointsIntoMasterEdges[i]); } labelListList pise(pointsIntoSlaveEdges.size()); forAll (pointsIntoSlaveEdges, i) { - pise[i].transfer(pointsIntoSlaveEdges[i].shrink()); + pise[i].transfer(pointsIntoSlaveEdges[i]); } // Prepare the enriched faces @@ -1398,7 +1398,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const } face newFace; - newFace.transfer(newFaceLabels.shrink()); + newFace.transfer(newFaceLabels); // Pout << "Modifying master stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl; @@ -1683,7 +1683,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const } face newFace; - newFace.transfer(newFaceLabels.shrink()); + newFace.transfer(newFaceLabels); // Pout << "Modifying slave stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl; diff --git a/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C index ce08c9a8bff50ef37a691c783d13d5bffe9c3277..ec620bd69d53f1cd8569c5404dcf9fe7f25d049d 100644 --- a/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C +++ b/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C @@ -227,7 +227,7 @@ void Foam::slidingInterface::decoupleInterface } face newFace; - newFace.transfer(newFaceLabels.shrink()); + newFace.transfer(newFaceLabels); // Pout << "Modifying master stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl; @@ -350,7 +350,7 @@ void Foam::slidingInterface::decoupleInterface } face newFace; - newFace.transfer(newFaceLabels.shrink()); + newFace.transfer(newFaceLabels); // Pout << "Modifying slave stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl; diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C index b056193d72c28fe02103466145ba51fc9dd8dc27..8afb49c049414cc66872f55d18eab032495d2b56 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C @@ -133,7 +133,7 @@ void Foam::enrichedPatch::calcCutFaces() const // The seed edges include all the edges of the original face + all edges // of other faces that have been used in the construction of the // facet. Edges from other faces can be considered as - // internal to the current face if used only once. + // internal to the current face if used only once. // Track the edge usage to avoid duplicate faces and reset it to unused boolList usedFaceEdges(curLocalFace.size(), false); @@ -304,12 +304,12 @@ void Foam::enrichedPatch::calcCutFaces() const // Append the face face cutFaceGlobal; - cutFaceGlobal.transfer(cutFaceGlobalPoints.shrink()); + cutFaceGlobal.transfer(cutFaceGlobalPoints); cf.append(cutFaceGlobal); face cutFaceLocal; - cutFaceLocal.transfer(cutFaceLocalPoints.shrink()); + cutFaceLocal.transfer(cutFaceLocalPoints); // Pout << "\ncutFaceLocal: " << cutFaceLocal.points(lp) << endl; // Go through all edges of the cut faces. // If the edge corresponds to a starting face edge, @@ -358,7 +358,7 @@ void Foam::enrichedPatch::calcCutFaces() const edgeSeeds.append(curCutFaceEdge.reverseEdge()); } } - + // Find out what the other side is @@ -596,20 +596,19 @@ void Foam::enrichedPatch::calcCutFaces() const // Re-pack the list into compact storage cutFacesPtr_ = new faceList(); - cutFacesPtr_->transfer(cf.shrink()); + cutFacesPtr_->transfer(cf); cutFaceMasterPtr_ = new labelList(); - cutFaceMasterPtr_->transfer(cfMaster.shrink()); + cutFaceMasterPtr_->transfer(cfMaster); cutFaceSlavePtr_ = new labelList(); - cutFaceSlavePtr_->transfer(cfSlave.shrink()); + cutFaceSlavePtr_->transfer(cfSlave); } void Foam::enrichedPatch::clearCutFaces() { deleteDemandDrivenData(cutFacesPtr_); - deleteDemandDrivenData(cutFaceMasterPtr_); deleteDemandDrivenData(cutFaceSlavePtr_); } diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C index 5d9f6d6ca2e23e28a07b6936e34782f5fdc3a468..7e2ba2ef7cae585c5c9dd072edeb6c11d7dbdb3c 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C @@ -80,7 +80,7 @@ void Foam::enrichedPatch::calcEnrichedFaces // For correct functioning of the enrichedPatch class, the slave // faces need to be inserted first. See comments in - // enrichedPatch.H + // enrichedPatch.H // Get reference to the point merge map const Map<label>& pmm = pointMergeMap(); @@ -233,10 +233,10 @@ void Foam::enrichedPatch::calcEnrichedFaces } } } -// Info << "New slave face " << faceI << ": " << newFace << endl; + // Info<< "New slave face " << faceI << ": " << newFace << endl; // Add the new face to the list - enrichedFaces[nEnrichedFaces].transfer(newFace.shrink()); + enrichedFaces[nEnrichedFaces].transfer(newFace); nEnrichedFaces++; } @@ -384,10 +384,10 @@ void Foam::enrichedPatch::calcEnrichedFaces } } } -// Info << "New master face: " << newFace << endl; + // Info<< "New master face: " << newFace << endl; // Add the new face to the list - enrichedFaces[nEnrichedFaces].transfer(newFace.shrink()); + enrichedFaces[nEnrichedFaces].transfer(newFace); nEnrichedFaces++; } diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C index 43dcc0e1807b45e69b1e653071e3f4be354f7ab4..01b623cff9414c73c2e9aefab8febd48c175a045 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C @@ -138,11 +138,11 @@ void Foam::enrichedPatch::calcMasterPointFaces() const forAll (mpfToc, mpfTocI) { labelList l; - l.transfer(mpf.find(mpfToc[mpfTocI])().shrink()); + l.transfer(mpf.find(mpfToc[mpfTocI])()); masterPointFaceAddr.insert(mpfToc[mpfTocI], l); } -// Pout << "masterPointFaceAddr: " << masterPointFaceAddr << endl; + // Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl; } diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C index 42f580cb9bb3495652cb1e05b9f153a729f7023b..a20336b876802fc7c577ee02f98ad42aec77246d 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C @@ -110,7 +110,7 @@ void Foam::enrichedPatch::calcPointPoints() const forAll (pp, pointI) { - ppAddr[pointI].transfer(pp[pointI].shrink()); + ppAddr[pointI].transfer(pp[pointI]); } } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C index 3783df0723b9cab9939f4bd43e3f98f3e2448015..f7a1eee8e88cdd618987585860333c2dce0eccbb 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C @@ -26,29 +26,55 @@ License #include "pressureGradientExplicitSource.H" #include "volFields.H" +#include "IFstream.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::pressureGradientExplicitSource::writeGradP() const +{ + // Only write on output time + if (mesh_.time().outputTime()) + { + IOdictionary propsDict + ( + IOobject + ( + sourceName_ + "Properties", + mesh_.time().timeName(), + "uniform", + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ); + propsDict.add("gradient", gradP_); + propsDict.regIOobject::write(); + } +} + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::pressureGradientExplicitSource::pressureGradientExplicitSource ( const word& sourceName, - const fvMesh& mesh, volVectorField& U ) : + sourceName_(sourceName), + mesh_(U.mesh()), + U_(U), dict_ ( IOobject ( sourceName + "Properties", - mesh.time().constant(), - mesh, + mesh_.time().constant(), + mesh_, IOobject::MUST_READ, IOobject::NO_WRITE ) ), - mesh_(mesh), - U_(U), Ubar_(dict_.lookup("Ubar")), gradPini_(readScalar(dict_.lookup("gradPini"))), gradP_(gradPini_), @@ -59,15 +85,15 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource topoSetSource::New ( cellSource_, - mesh, + mesh_, dict_.subDict(cellSource_ + "Coeffs") ) ), selectedCellSet_ ( - mesh, - "pressureGradientExplicitSourceCellSet", - mesh.nCells()/10 + 1 // Reasonable size estimate. + mesh_, + sourceName_ + "CellSet", + mesh_.nCells()/10 + 1 // Reasonable size estimate. ) { // Create the cell set @@ -78,9 +104,24 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource ); // Give some feedback - Info<< "pressureGradientExplicitSource(" << sourceName << ")" << nl - << "Selected " << returnReduce(selectedCellSet_.size(), sumOp<label>()) - << " cells." << endl; + Info<< " Selected " + << returnReduce(selectedCellSet_.size(), sumOp<label>()) + << " cells" << endl; + + // Read the initial pressure gradient from file if it exists + IFstream propsFile + ( + mesh_.time().timeName()/"uniform"/(sourceName_ + "Properties") + ); + + if (propsFile.good()) + { + Info<< " Reading pressure gradient from file" << endl; + dictionary propsDict(dictionary::null, propsFile); + propsDict.lookup("gradient") >> gradP_; + } + + Info<< " Initial pressure gradient = " << gradP_ << endl; } @@ -95,7 +136,7 @@ Foam::pressureGradientExplicitSource::Su() const ( IOobject ( - "pressureGradientExplicitSource", + sourceName_, mesh_.time().timeName(), mesh_, IOobject::NO_READ, @@ -164,6 +205,8 @@ void Foam::pressureGradientExplicitSource::update() Info<< "Uncorrected Ubar = " << magUbarAve << tab << "Pressure gradient = " << gradP_ << endl; + + writeGradP(); } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H index 9c518dc8acd679ce04c63248e5f40769749601bd..fb278ef443cdb21639fe7494466e7cc7c5f7dd3b 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H @@ -57,8 +57,8 @@ class pressureGradientExplicitSource { // Private data - //- Properties dictionary - IOdictionary dict_; + //- Name of the source + const word sourceName_; //- Reference to the mesh const fvMesh& mesh_; @@ -66,6 +66,9 @@ class pressureGradientExplicitSource //- Reference to the velocity field volVectorField& U_; + //- Properties dictionary + IOdictionary dict_; + //- Average velocity vector Ubar_; @@ -90,6 +93,9 @@ class pressureGradientExplicitSource // Private Member Functions + //- Write the pressure gradient to file (for restarts etc) + void writeGradP() const; + //- Disallow default bitwise copy construct pressureGradientExplicitSource(const pressureGradientExplicitSource&); @@ -105,7 +111,6 @@ public: pressureGradientExplicitSource ( const word& sourceName, - const fvMesh& mesh, volVectorField& U ); diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index 47ef5eb98fd05bdb4e5d1b280ab52224b5d5171a..ca0ef6c0380a4b0dd804f6ad5771e888f0cd6153 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -269,8 +269,8 @@ void Foam::MULES::implicitSolve } else { - Info<< "max(" + psi.name() + " - 1 = " << maxPsiM1 << endl; - Info<< "min(" + psi.name() + ") = " << minPsi << endl; + Info<< "MULES: max(" << psi.name() << " - 1) = " << maxPsiM1 + << " min(" << psi.name() << ") = " << minPsi << endl; phiBD = psiConvectionDiffusion.flux(); diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 99587f8d3c07989d6e6af07e0766db4f9df8c4f7..86d1fe3ddb7b3ba9d88cd2735e351cb79327fecd 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -87,6 +87,7 @@ $(cellSources)/nearestToCell/nearestToCell.C $(cellSources)/nbrToCell/nbrToCell.C $(cellSources)/zoneToCell/zoneToCell.C $(cellSources)/sphereToCell/sphereToCell.C +$(cellSources)/cylinderToCell/cylinderToCell.C faceSources = sets/faceSources $(faceSources)/faceToFace/faceToFace.C diff --git a/src/meshTools/cellFeatures/cellFeatures.C b/src/meshTools/cellFeatures/cellFeatures.C index 3107dc79b0d36c09477ee30eb4259e34e969f8d7..b4838a7addf20e6761835bc03f39b7f2d23f3b2a 100644 --- a/src/meshTools/cellFeatures/cellFeatures.C +++ b/src/meshTools/cellFeatures/cellFeatures.C @@ -369,8 +369,6 @@ void Foam::cellFeatures::calcSuperFaces() const } else { - superFace.shrink(); - faces[superFaceI].transfer(superFace); } } diff --git a/src/meshTools/indexedOctree/indexedOctree.C b/src/meshTools/indexedOctree/indexedOctree.C index b8b18401df14a35a14a0143fb6ea6afdd1639fbc..dab1353dd38f72873474f259fc55802112d277a7 100644 --- a/src/meshTools/indexedOctree/indexedOctree.C +++ b/src/meshTools/indexedOctree/indexedOctree.C @@ -183,9 +183,7 @@ void indexedOctree<Type>::divide result.setSize(8); for (direction octant = 0; octant < subIndices.size(); octant++) { - subIndices[octant].shrink(); result[octant].transfer(subIndices[octant]); - subIndices[octant].clear(); } } diff --git a/src/meshTools/regionSplit/regionSplit.C b/src/meshTools/regionSplit/regionSplit.C index 0b500536a85dc170f26fb443600f26abdb75db0d..e93674ca7dde79f1be007523e30cc4834dfab6cb 100644 --- a/src/meshTools/regionSplit/regionSplit.C +++ b/src/meshTools/regionSplit/regionSplit.C @@ -250,8 +250,7 @@ void Foam::regionSplit::fillSeedMask // << newChangedFaces.size() << endl; //} - changedFaces.transfer(newChangedFaces.shrink()); - newChangedFaces.clear(); + changedFaces.transfer(newChangedFaces); } } diff --git a/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C b/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C index e3c42e77beea8e9e198d48e601dba2746ba2f409..63b85e1d686fc66aa514e80b30612d1371b4a5c2 100644 --- a/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C +++ b/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C @@ -239,12 +239,11 @@ Foam::distributedTriSurfaceMesh::constructSegments sendMap.setSize(Pstream::nProcs()); forAll(sendMap, procI) { - dynSendMap[procI].shrink(); sendMap[procI].transfer(dynSendMap[procI]); } - allSegments.transfer(dynAllSegments.shrink()); - allSegmentMap.transfer(dynAllSegmentMap.shrink()); + allSegments.transfer(dynAllSegments); + allSegmentMap.transfer(dynAllSegmentMap); } @@ -704,13 +703,12 @@ Foam::distributedTriSurfaceMesh::calcLocalQueries sendMap.setSize(Pstream::nProcs()); forAll(sendMap, procI) { - dynSendMap[procI].shrink(); sendMap[procI].transfer(dynSendMap[procI]); } - allCentres.transfer(dynAllCentres.shrink()); - allRadiusSqr.transfer(dynAllRadiusSqr.shrink()); - allSegmentMap.transfer(dynAllSegmentMap.shrink()); + allCentres.transfer(dynAllCentres); + allRadiusSqr.transfer(dynAllRadiusSqr); + allSegmentMap.transfer(dynAllSegmentMap); } diff --git a/src/meshTools/searchableSurface/searchableBox.C b/src/meshTools/searchableSurface/searchableBox.C index 34e3faec99b2c04976ea4701d33d07696f49c2f4..3ed3b90c6e1b5429f0b41d46cf01964ed5fd55dd 100644 --- a/src/meshTools/searchableSurface/searchableBox.C +++ b/src/meshTools/searchableSurface/searchableBox.C @@ -482,7 +482,6 @@ void Foam::searchableBox::findLineAll pt = inter.hitPoint() + smallVec[pointI]; } - hits.shrink(); info[pointI].transfer(hits); } else diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index e8b7c0681ffc3550aa9d3d1ac6336e0a781a29dd..fe9e0c58f9a7306f1a57a94a70ddf0892dbe9927 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -449,7 +449,6 @@ void Foam::triSurfaceMesh::findLineAll pt = inter.hitPoint() + smallVec[pointI]; } - hits.shrink(); info[pointI].transfer(hits); } else diff --git a/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C new file mode 100644 index 0000000000000000000000000000000000000000..63e461145831a1d49e3e755eadd20d512bf7d0d0 --- /dev/null +++ b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "cylinderToCell.H" +#include "polyMesh.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cylinderToCell, 0); + addToRunTimeSelectionTable(topoSetSource, cylinderToCell, word); + addToRunTimeSelectionTable(topoSetSource, cylinderToCell, istream); +} + + +Foam::topoSetSource::addToUsageTable Foam::cylinderToCell::usage_ +( + cylinderToCell::typeName, + "\n Usage: cylinderToCell (p1X p1Y p1Z) (p2X p2Y p2Z) radius\n\n" + " Select all cells with cell centre within bounding cylinder\n\n" +); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::cylinderToCell::combine(topoSet& set, const bool add) const +{ + const vector axis = p2_ - p1_; + const scalar rad2 = sqr(radius_); + const scalar magAxis2 = magSqr(axis); + + const pointField& ctrs = mesh_.cellCentres(); + + forAll(ctrs, cellI) + { + vector d = ctrs[cellI] - p1_; + scalar magD = d & axis; + + if ((magD > 0) && (magD < magAxis2)) + { + scalar d2 = (d & d) - sqr(magD)/magAxis2; + if (d2 < rad2) + { + addOrDelete(set, cellI, add); + } + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cylinderToCell::cylinderToCell +( + const polyMesh& mesh, + const vector& p1, + const vector& p2, + const scalar radius +) +: + topoSetSource(mesh), + p1_(p1), + p2_(p2), + radius_(radius) +{} + + +Foam::cylinderToCell::cylinderToCell +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + p1_(dict.lookup("p1")), + p2_(dict.lookup("p2")), + radius_(readScalar(dict.lookup("radius"))) +{} + + +// Construct from Istream +Foam::cylinderToCell::cylinderToCell +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + p1_(checkIs(is)), + p2_(checkIs(is)), + radius_(readScalar(checkIs(is))) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cylinderToCell::~cylinderToCell() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::cylinderToCell::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding cells with centre within cylinder, with p1 = " + << p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl; + + combine(set, true); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing cells with centre within sphere, with p1 = " + << p1_ << ", p2 = " << p2_ << " and radius = " << radius_ << endl; + + combine(set, false); + } +} + + +// ************************************************************************* // diff --git a/applications/test/hmm/calcEntry/calcEntry.H b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H similarity index 59% rename from applications/test/hmm/calcEntry/calcEntry.H rename to src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H index ced8516f388b9bcff3d4e034d233c2c78f3d87f5..0401e3f3efdd39af81eb2f7017d56a5364978bda 100644 --- a/applications/test/hmm/calcEntry/calcEntry.H +++ b/src/meshTools/sets/cellSources/cylinderToCell/cylinderToCell.H @@ -23,70 +23,105 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::functionEntries::calcEntry + Foam::cylinderToCell Description + A topoSetSource to select cells based on cell centres inside a cylinder. SourceFiles - calcEntry.C + cylinderToCell.C \*---------------------------------------------------------------------------*/ -#ifndef calcEntry_H -#define calcEntry_H +#ifndef cylinderToCell_H +#define cylinderToCell_H -#include "functionEntry.H" +#include "topoSetSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -namespace functionEntries -{ /*---------------------------------------------------------------------------*\ - Class calcEntry Declaration + Class cylinderToCell Declaration \*---------------------------------------------------------------------------*/ -class calcEntry +class cylinderToCell : - public functionEntry + public topoSetSource { - // Private Member Functions - //- Disallow default bitwise copy construct - calcEntry(const calcEntry&); + // Private data + + //- Add usage string + static addToUsageTable usage_; - //- Disallow default bitwise assignment - void operator=(const calcEntry&); + //- First point on cylinder axis + vector p1_; + + //- Second point on cylinder axis + vector p2_; + + //- Radius + scalar radius_; + + + // Private Member Functions + + void combine(topoSet& set, const bool add) const; public: //- Runtime type information - TypeName("calc"); + TypeName("cylinderToCell"); - // Member Functions + // Constructors + + //- Construct from components + cylinderToCell + ( + const polyMesh& mesh, + const vector& p1, + const vector& p2, + const scalar radius + ); - static bool insert + //- Construct from dictionary + cylinderToCell ( - const dictionary& parentDict, - primitiveEntry& entry, - Istream& is + const polyMesh& mesh, + const dictionary& dict ); - static bool insert + //- Construct from Istream + cylinderToCell ( - dictionary& parentDict, - Istream& is + const polyMesh& mesh, + Istream& ); + + + // Destructor + + virtual ~cylinderToCell(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace functionEntries } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/triSurface/booleanOps/intersectedSurface/edgeSurface.C b/src/meshTools/triSurface/booleanOps/intersectedSurface/edgeSurface.C index 577d004982f6469a5743d41454bbee724d35f52e..58a86810b13624cd22fe0abb24ac8ffd9d5b85a8 100644 --- a/src/meshTools/triSurface/booleanOps/intersectedSurface/edgeSurface.C +++ b/src/meshTools/triSurface/booleanOps/intersectedSurface/edgeSurface.C @@ -287,18 +287,12 @@ Foam::edgeSurface::edgeSurface } // Transfer. - allEdges.shrink(); edges_.transfer(allEdges); - - allParentEdges.shrink(); parentEdges_.transfer(allParentEdges); forAll(allFaceEdges, faceI) { - DynamicList<label>& allFEdges = allFaceEdges[faceI]; - - allFEdges.shrink(); - faceEdges_[faceI].transfer(allFEdges); + faceEdges_[faceI].transfer(allFaceEdges[faceI]); } diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C index 3d07e99a93cb27a60c4db5428a2b738421948408..f46508642548d1c4c1ddc53b9454dca79e6f5b42 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C @@ -218,14 +218,8 @@ void Foam::edgeIntersections::intersectEdges // Done current edge. Transfer all data into *this - currentIntersections.shrink(); - currentIntersectionTypes.shrink(); - operator[](edgeI).transfer(currentIntersections); classification_[edgeI].transfer(currentIntersectionTypes); - - currentIntersections.clear(); - currentIntersectionTypes.clear(); } if (debug) @@ -651,7 +645,7 @@ Foam::label Foam::edgeIntersections::removeDegenerates offsetPerturb ( surf1, - surf2, + surf2, edgeI, rndGen, points1, diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersectionTemplates.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersectionTemplates.C index fd06704ab1ccaa853eb39aa3f90547f96696f0de..ce5851cf169af0ac2b042328c6013db2a7f645e1 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersectionTemplates.C +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersectionTemplates.C @@ -38,7 +38,6 @@ void Foam::surfaceIntersection::transfer List<T>& lList ) { - dList.shrink(); lList.transfer(dList); } diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index 1732fb45d62f25fa19dcc6b4b51c75b43e512e7d..de668b54d1b225fa65f792a183d28481ff31f01b 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -197,7 +197,7 @@ void Foam::surfaceFeatures::calcFeatPoints(const List<edgeStatus>& edgeStat) featurePoints.append(pointI); } } - featurePoints.shrink(); + featurePoints_.transfer(featurePoints); } diff --git a/src/sampling/sampledSurface/isoSurface/isoSurface.C b/src/sampling/sampledSurface/isoSurface/isoSurface.C index e4a11cc71d938708731494ae9417604e1d61a278..5d77290b0f2be3a8ba809df3503e3894868d581e 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/isoSurface.C @@ -815,8 +815,8 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints } } - triMap.transfer(newToOldTri.shrink()); - tris.transfer(dynTris.shrink()); + triMap.transfer(newToOldTri); + tris.transfer(dynTris); } @@ -875,7 +875,7 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints } } - triMap.transfer(newToOldTri.shrink()); + triMap.transfer(newToOldTri); tris.setSize(newTriI); } } diff --git a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C index 5cffcdf0ddf4b8f21c8f2f2f01363ad97ec43df9..6557112012114f2cd64ab819e2d01b0184786e59 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C @@ -434,7 +434,7 @@ void Foam::isoSurfaceCell::calcSnappedCc } else { - // Need to analyse + // Need to analyse forAll(cFaces, cFaceI) { const face& f = mesh_.faces()[cFaces[cFaceI]]; @@ -747,7 +747,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint ( false, // do not check for duplicate tris localTriPoints, - triPointReverseMap, + triPointReverseMap, triMap ) ); @@ -871,8 +871,8 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints } } - triMap.transfer(newToOldTri.shrink()); - tris.transfer(dynTris.shrink()); + triMap.transfer(newToOldTri); + tris.transfer(dynTris); } @@ -930,7 +930,7 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints } } - triMap.transfer(newToOldTri.shrink()); + triMap.transfer(newToOldTri); tris.setSize(newTriI); } } @@ -1062,7 +1062,7 @@ void Foam::isoSurfaceCell::calcAddressing faceEdges[triI][1] = oldToMerged[edgeI++]; faceEdges[triI][2] = oldToMerged[edgeI++]; } - + // Determine edgeFaces edgeFace0.setSize(mergedCentres.size()); @@ -1137,7 +1137,7 @@ void Foam::isoSurfaceCell::walkOrientation forAll(fEdges, fp) { label edgeI = fEdges[fp]; - + // my points: label p0 = tri[fp]; label p1 = tri[tri.fcIndex(fp)]; @@ -1174,7 +1174,7 @@ void Foam::isoSurfaceCell::walkOrientation changedFaces.transfer(newChangedFaces); } -} +} void Foam::isoSurfaceCell::orientSurface @@ -1199,7 +1199,7 @@ void Foam::isoSurfaceCell::orientSurface for ( ; - seedTriI < surf.size() && flipState[seedTriI] != -1; + seedTriI < surf.size() && flipState[seedTriI] != -1; seedTriI++ ) {} @@ -1473,14 +1473,13 @@ Foam::isoSurfaceCell::isoSurfaceCell snappedCc = -1; } - snappedPoints.shrink(); - if (debug) { Pout<< "isoSurfaceCell : shifted " << snappedPoints.size() << " cell centres to intersection." << endl; } + snappedPoints.shrink(); label nCellSnaps = snappedPoints.size(); // Per point -1 or a point inside snappedPoints. diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C index 49e48578f510fa922268b77a8d470aafc4451cce..3409b2c42115df69101f36380531c15b0472e977 100644 --- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C +++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C @@ -135,26 +135,27 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read label regionI = 0; label lineLabel, shapeId, nLabels, cellTableId, typeId; - labelList starLabels(64); + DynamicList<label> vertexLabels(64); while ((is >> lineLabel).good()) { is >> shapeId >> nLabels >> cellTableId >> typeId; - if (nLabels > starLabels.size()) - { - starLabels.setSize(nLabels); - } - starLabels = -1; + vertexLabels.clear(); + vertexLabels.reserve(nLabels); // read indices - max 8 per line for (label i = 0; i < nLabels; ++i) { + label vrtId; if ((i % 8) == 0) { is >> lineLabel; } - is >> starLabels[i]; + is >> vrtId; + + // convert original vertex id to point label + vertexLabels.append(mapPointId[vrtId]); } if (typeId == starcdShellType_) @@ -178,14 +179,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read dynSizes.append(0); } - SubList<label> vertices(starLabels, nLabels); - - // convert orig vertex id to point label - forAll(vertices, i) - { - vertices[i] = mapPointId[vertices[i]]; - } - + SubList<label> vertices(vertexLabels, vertexLabels.size()); if (mustTriangulate && nLabels > 3) { face f(vertices); diff --git a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C index c1114dff6755577b7b74f6f90ba1403c0bf78967..40e624214a2784979d126fa57b68ef3d46e5d202 100644 --- a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C +++ b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C @@ -175,7 +175,7 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read } } // truncate addressed size - dynSizes.setSize(nPatch); + dynSizes.setCapacity(nPatch); // transfer to normal lists points_.transfer(dynPoints); diff --git a/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.C b/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.C index 5b7e4299c0424da370f0254735c77a4d26f1445e..8a99a9f0ed3a604565909a5aeee30eb9ad305079 100644 --- a/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.C +++ b/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.C b/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.C index 2deb4001fc8e99632ed4053714be9159ca6e5c32..0020f9f7458440ea23e884ed127457fc7e6eccc1 100644 --- a/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.C +++ b/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.H b/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.H index 4c286518879884a819d08de4445356fdcdfd3291..b665999b46e7208d706f11102f07cc500d4e3ade 100644 --- a/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.H +++ b/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.H @@ -1,25 +1,37 @@ -// The FOAM Project // File: iC3H8O/iC3H8O.H -/* -------------------------------------------------------------------------------- - ========= | Class Interface - \\ / | - \\ / | Name: iC3H8O - \\ / | Family: iC3H8O - \\/ | - F ield | FOAM version: 2.2 - O peration | - A and | Copyright (C) 1991-2000 Nabla Ltd. - M anipulation | All Rights Reserved. +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | ------------------------------------------------------------------------------- -CLASS - iC3H8O +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. -DESCRIPTION + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::iC3H8O + +Description iso-propanol +SourceFiles + iC3H8O.C -*/ -// ------------------------------------------------------------------------- // +\*---------------------------------------------------------------------------*/ #ifndef iC3H8O_H #define iC3H8O_H diff --git a/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.C b/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.C index dd6e3ea75492164af7c58ea9b829cf8c0b76b32d..96df4a11cc9c1caaf7703e639c253cfb49bfee6d 100644 --- a/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.C +++ b/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2005 OpenCFD Ltd. + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.H b/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.H index 2278e5dda24bf82804824398c81c903fc7eff92c..2f0079646967b0692fad76730bc7462d25cae16b 100644 --- a/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.H +++ b/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.H @@ -1,23 +1,37 @@ -/* -------------------------------------------------------------------------------- - ========= | Class Interface - \\ / | - \\ / | Name: nC3H8O - \\ / | Family: nC3H8O - \\/ | - F ield | FOAM version: 2.2 - O peration | - A and | Copyright (C) 1991-2000 Nabla Ltd. - M anipulation | All Rights Reserved. +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | ------------------------------------------------------------------------------- -CLASS - nC3H8O +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. -DESCRIPTION - propanol + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ -// ------------------------------------------------------------------------- // +Class + Foam::nC3H8O + +Description + propanol + +SourceFiles + nC3H8O.C + +\*---------------------------------------------------------------------------*/ #ifndef nC3H8O_H #define nC3H8O_H diff --git a/src/turbulenceModels/incompressible/LES/vanDriestDelta/vanDriestDelta.C b/src/turbulenceModels/incompressible/LES/vanDriestDelta/vanDriestDelta.C index da55d3518bc770e5a8f95141073477ccca629dc5..0979890dbf080d377f36b7692367ed0252d8ee81 100644 --- a/src/turbulenceModels/incompressible/LES/vanDriestDelta/vanDriestDelta.C +++ b/src/turbulenceModels/incompressible/LES/vanDriestDelta/vanDriestDelta.C @@ -115,6 +115,10 @@ vanDriestDelta::vanDriestDelta Cdelta_ ( dd.subDict(type() + "Coeffs").lookupOrDefault<scalar>("Cdelta", 0.158) + ), + calcInterval_ + ( + dd.subDict(type() + "Coeffs").lookupOrDefault<label>("calcInterval", 1) ) { delta_ = geometricDelta_(); @@ -131,14 +135,18 @@ void vanDriestDelta::read(const dictionary& d) d.readIfPresent<scalar>("kappa", kappa_); dd.readIfPresent<scalar>("Aplus", Aplus_); dd.readIfPresent<scalar>("Cdelta", Cdelta_); + dd.readIfPresent<label>("calcInterval", calcInterval_); calcDelta(); } void vanDriestDelta::correct() { - geometricDelta_().correct(); - calcDelta(); + if (mesh().time().timeIndex() % calcInterval_ == 0) + { + geometricDelta_().correct(); + calcDelta(); + } } diff --git a/src/turbulenceModels/incompressible/LES/vanDriestDelta/vanDriestDelta.H b/src/turbulenceModels/incompressible/LES/vanDriestDelta/vanDriestDelta.H index 66fe691c103e777002e4545611acd8d3bea58012..854fa181bb493941ba30aa870d8381b52826539b 100644 --- a/src/turbulenceModels/incompressible/LES/vanDriestDelta/vanDriestDelta.H +++ b/src/turbulenceModels/incompressible/LES/vanDriestDelta/vanDriestDelta.H @@ -61,6 +61,7 @@ class vanDriestDelta scalar kappa_; scalar Aplus_; scalar Cdelta_; + label calcInterval_; // Private Member Functions diff --git a/wmake/rules/General/standard b/wmake/rules/General/standard index 82d2a6c11ebe2317bb6fde241c7d481782b9613a..8e5e436d32aa2754691dbb1ad89418083daceb95 100644 --- a/wmake/rules/General/standard +++ b/wmake/rules/General/standard @@ -1,3 +1,5 @@ +include $(GENERAL_RULES)/version + include $(GENERAL_RULES)/sourceToDep include $(GENERAL_RULES)/java diff --git a/wmake/rules/General/version b/wmake/rules/General/version new file mode 100644 index 0000000000000000000000000000000000000000..0d74179f8cc78c80b4c40ad0155622558d887d9e --- /dev/null +++ b/wmake/rules/General/version @@ -0,0 +1,11 @@ +.SUFFIXES: .Cver + +# +# update version string +# +Cvertoo = \ + sed s/WM_PROJECT_VERSION/\"$(shell wmakePrintBuild)\"/ $$SOURCE > $*.C; \ + $(CC) $(c++FLAGS) -c $*.C -o $@ + +.Cver.dep: + $(MAKE_DEP) diff --git a/bin/tools/buildParaView3.2.1 b/wmake/wmakePrintBuild similarity index 54% rename from bin/tools/buildParaView3.2.1 rename to wmake/wmakePrintBuild index 904682581df68d664661819d29b88fe4a24bfc7d..61e9b80790f40146ccf2a67fb795134d5a58901b 100755 --- a/bin/tools/buildParaView3.2.1 +++ b/wmake/wmakePrintBuild @@ -5,7 +5,7 @@ # \\ / O peration | # \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. # \\/ M anipulation | -#------------------------------------------------------------------------------ +#------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. # @@ -24,52 +24,72 @@ # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script -# buildParaView3.2.1 +# wmakePrintBuild # # Description -# Build and install ParaView -# - run from folder above ParaView source folder or place the -# ParaView source under $WM_PROJECT_INST_DIR +# Print the version used when building the project. # #------------------------------------------------------------------------------ -. $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions +Script=${0##*/} -PARAVIEW_SRC="ParaView3.2.1" -PARAVIEW_MAJOR_VERSION="3.2" +usage() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE +usage: $Script -# User options: -# ~~~~~~~~~~~~~ +Print the version used when building the project, in this order of precedence: + * git description + * \$WM_PROJECT_DIR/.build + * \$WM_PROJECT_VERSION -WITH_MPI=ON -MPI_MAX_PROCS=32 -WITH_PYTHON=ON -PYTHON_LIBRARY="" -WITH__MESA=OFF +USAGE + exit 1 +} +#------------------------------------------------------------------------------ + +# provide immediate help +if [ "$1" = "-h" -o "$1" = "-help" ] +then + usage +fi -# -# No further editing below this line #------------------------------------------------------------------------------ -# shortcut for repeated builds - use with caution -if [ "$1" = "-fast" ] +# +# persistent build tag +# +build="$WM_PROJECT_DIR/.build" +previous=$(tail -1 $build 2>/dev/null) + +# +# building under git +# note: could also use --abbrev=32 for maximum resolution +# +version=$(git describe --always --tags 2>/dev/null) +if [ $? -eq 0 ] then - CMAKE_SKIP=YES -elif [ "$#" -gt 0 ] + # update persistent build tag (this could be made optional or removed) + if [ "$version" != "$previous" ] + then + if [ -w "$build" -a \( -w "$WM_PROJECT_DIR" -o ! -e "$build" \) ] + then + echo $version >| "$build" 2>/dev/null + fi + fi + + echo $version + +elif [ -n "$previous" ] then - echo "$0: only supports a -fast option" - exit 1 -fi -# Set configure options -#~~~~~~~~~~~~~~~~~~~~~~ -addVerbosity # set cmake verbosity -addMpiSupport # set MPI-specific options -addPythonSupport # set Python-specific options -addMesaSupport # set MESA-specific options + # use previous build tag + echo $previous -buildParaView -installParaView +else -echo "done" + # fallback to WM_PROJECT_VERSION + echo ${WM_PROJECT_VERSION:-unknown} + +fi #------------------------------------------------------------------------------