diff --git a/.gitignore b/.gitignore index 4a7188cdfb..96c3093b71 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/solvers/combustion/PDRFoam/PDRModels/XiEqModels/basicXiSubXiEq/basicXiSubXiEq.H b/applications/solvers/combustion/PDRFoam/PDRModels/XiEqModels/basicXiSubXiEq/basicXiSubXiEq.H index 04cc2a83ca..335012c868 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/XiEqModels/basicXiSubXiEq/basicXiSubXiEq.H +++ b/applications/solvers/combustion/PDRFoam/PDRModels/XiEqModels/basicXiSubXiEq/basicXiSubXiEq.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - basicSubGrid + Foam::XiEqModels::basicSubGrid Description Basic sub-grid obstacle flame-wrinking enhancement factor model. diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/XiGModels/basicXiSubG/basicXiSubG.H b/applications/solvers/combustion/PDRFoam/PDRModels/XiGModels/basicXiSubG/basicXiSubG.H index a455fd28b4..d844dca34e 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/XiGModels/basicXiSubG/basicXiSubG.H +++ b/applications/solvers/combustion/PDRFoam/PDRModels/XiGModels/basicXiSubG/basicXiSubG.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - basicSubGrid + Foam::XiGModel::basicSubGrid Description diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H index 3448d1166c..7177fca847 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModel.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - PDRDragModel + Foam::PDRDragModel Description Base-class for sub-grid obstacle drag models. diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.H b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.H index 05ec433919..889cd57fd6 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.H +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - basic + Foam::PDRDragModels::basic Description Basic sub-grid obstacle drag model. diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.H b/applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.H index b35ef9151e..b370c0b035 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.H +++ b/applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - PDRkEpsilon + Foam::compressible::RASModels::PDRkEpsilon Description Standard k-epsilon turbulence model with additional source terms diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/Gulder/Gulder.H b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/Gulder/Gulder.H index d8bc58b170..c361e81946 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/Gulder/Gulder.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/Gulder/Gulder.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Gulder + Foam::XiEqModels::Gulder Description Simple Gulder model for XiEq based on Gulders correlation diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEBlendXiEq/SCOPEBlendXiEq.H b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEBlendXiEq/SCOPEBlendXiEq.H index b9a45ffb63..589060895c 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEBlendXiEq/SCOPEBlendXiEq.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEBlendXiEq/SCOPEBlendXiEq.H @@ -23,10 +23,10 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - SCOPEBlend + Foam::XiEqModels::SCOPEBlend Description - + SourceFiles SCOPEBlend.C diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.H b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.H index b2b2b35edf..e8c4dea23c 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - SCOPEXiEq + Foam::XiEqModel::SCOPEXiEq Description Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModel.H b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModel.H index 2c35877f5e..9cbdcbe3da 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModel.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModel.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - XiEqModel + Foam::XiEqModel Description Base-class for all XiEq models used by the b-XiEq combustion model. diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/instabilityXiEq/instabilityXiEq.H b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/instabilityXiEq/instabilityXiEq.H index 455635dc08..b57cda5e28 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/instabilityXiEq/instabilityXiEq.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/instabilityXiEq/instabilityXiEq.H @@ -23,10 +23,10 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - instability + Foam::XiEqModels::instability Description - + SourceFiles instability.C diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/KTS/KTS.H b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/KTS/KTS.H index 8884c00deb..93562557e9 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/KTS/KTS.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/KTS/KTS.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - KTS + Foam::XiGModels::KTS Description Simple Kolmogorov time-scale model for the flame-wrinling generation rate. diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModel.H b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModel.H index 908dc3a623..803644261e 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModel.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModel.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - XiGModel + Foam::XiGModel Description Base-class for all Xi generation models used by the b-Xi combustion model. diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/instabilityG/instabilityG.H b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/instabilityG/instabilityG.H index 596e86229b..fa6935382c 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/instabilityG/instabilityG.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/instabilityG/instabilityG.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - instabilityG + Foam::XiGModels::instabilityG Description Flame-surface instabilityG flame-wrinking generation rate coefficient model. diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModel.H b/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModel.H index 2b76f9bc92..2447263f7b 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModel.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModel.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - XiModel + Foam::XiModel Description Base-class for all Xi models used by the b-Xi combustion model. @@ -102,8 +102,6 @@ namespace Foam Class XiModel Declaration \*---------------------------------------------------------------------------*/ - - class XiModel { diff --git a/applications/solvers/combustion/PDRFoam/XiModels/algebraic/algebraic.H b/applications/solvers/combustion/PDRFoam/XiModels/algebraic/algebraic.H index 9da38cf00d..70fde4a510 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/algebraic/algebraic.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/algebraic/algebraic.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - algebraic + Foam::XiModels::algebraic Description Simple algebraic model for Xi based on Gulders correlation diff --git a/applications/solvers/combustion/PDRFoam/XiModels/fixed/fixed.H b/applications/solvers/combustion/PDRFoam/XiModels/fixed/fixed.H index 64c44fdff4..3a9919259d 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/fixed/fixed.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/fixed/fixed.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - fixed + Foam::XiModels::fixed Description Fixed value model for Xi. diff --git a/applications/solvers/combustion/PDRFoam/XiModels/transport/transport.H b/applications/solvers/combustion/PDRFoam/XiModels/transport/transport.H index db2a7255aa..3023ce272f 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/transport/transport.H +++ b/applications/solvers/combustion/PDRFoam/XiModels/transport/transport.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - transport + Foam::XiModels::transport Description Simple transport model for Xi based on Gulders correlation diff --git a/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.H b/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.H index 8c65453b94..029d31f25d 100644 --- a/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.H +++ b/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - SCOPE + Foam::laminarFlameSpeedModels::SCOPE Description Laminar flame speed obtained from the SCOPE correlation. diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C index 11a1809575..e24de6658d 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/compressibleInterDyMFoam.C @@ -74,24 +74,26 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); - - // Do any mesh changes - mesh.update(); - - if (mesh.changing()) { - Info<< "Execution time for mesh.update() = " - << runTime.elapsedCpuTime() - timeBeforeMeshUpdate - << " s" << endl; + // Store divU from the previous mesh for the correctPhi + volScalarField divU = fvc::div(phi); - gh = g & mesh.C(); - ghf = g & mesh.Cf(); - } + scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); - if (mesh.changing() && correctPhi) - { - //***HGW#include "correctPhi.H" + // Do any mesh changes + mesh.update(); + + if (mesh.changing()) + { + Info<< "Execution time for mesh.update() = " + << runTime.elapsedCpuTime() - timeBeforeMeshUpdate + << " s" << endl; + } + + if (mesh.changing() && correctPhi) + { + #include "correctPhi.H" + } } // Make the fluxes relative to the mesh motion @@ -102,6 +104,12 @@ int main(int argc, char *argv[]) #include "meshCourantNo.H" } + if (mesh.changing()) + { + gh = g & mesh.C(); + ghf = g & mesh.Cf(); + } + turbulence->correct(); // --- Outer-corrector loop diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H b/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H new file mode 100644 index 0000000000..4152105784 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H @@ -0,0 +1,39 @@ +{ + #include "continuityErrs.H" + + volScalarField pcorr + ( + IOobject + ( + "pcorr", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("pcorr", pd.dimensions(), 0.0), + pcorrTypes + ); + + dimensionedScalar rAUf("(1|A(U))", dimTime/rho.dimensions(), 1.0); + + adjustPhi(phi, U, pcorr); + + for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pcorrEqn + ( + fvm::laplacian(rAUf, pcorr) == fvc::div(phi) - divU + ); + + pcorrEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi -= pcorrEqn.flux(); + } + } + + #include "continuityErrs.H" +} diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H b/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H index 1f579d245b..dc04fb4546 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H @@ -150,3 +150,14 @@ ( incompressible::turbulenceModel::New(U, phi, twoPhaseProperties) ); + + + wordList pcorrTypes(pd.boundaryField().types()); + + for (label i=0; i 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 ade3907264..9bbd32d4fd 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; - Dictionary& dict2 = *dictPtr; + Dictionary 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 << "Bye." << endl; + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << dict2 << endl; + + Dictionary newDict; + newDict.transfer(dict2); + + Info<< nl << "source: " << dict2 << nl + << "keys: " << dict2.toc() << nl + << "target: " << newDict << nl + << "keys: " << newDict.toc() << endl; + + + PtrDictionary 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::const_iterator iter = scalarDict.begin(); + iter != scalarDict.end(); + ++iter + ) + { + Info<< " = " << iter() << endl; + } + + PtrDictionary 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::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 << "Done." << endl; return 0; } diff --git a/applications/test/ISLList/ISLListTest.C b/applications/test/ISLList/ISLListTest.C index 60590d1eaf..f33f811c1a 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 newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + Info<< nl << "Bye." << endl; return 0; } diff --git a/applications/test/NamedEnum/Make/files b/applications/test/NamedEnum/Make/files index a06d4ba5a9..a6601226fa 100644 --- a/applications/test/NamedEnum/Make/files +++ b/applications/test/NamedEnum/Make/files @@ -1,4 +1,3 @@ - namedEnumTest.C -EXE = $(FOAM_APPBIN)/NamedEnum +EXE = $(FOAM_USER_APPBIN)/NamedEnum diff --git a/applications/test/PtrList/Make/files b/applications/test/PtrList/Make/files new file mode 100644 index 0000000000..4bfd49bde0 --- /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/PtrList/PtrListTest.C b/applications/test/PtrList/PtrListTest.C new file mode 100644 index 0000000000..8de64a9d3c --- /dev/null +++ b/applications/test/PtrList/PtrListTest.C @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Application + +Description + +\*---------------------------------------------------------------------------*/ + +#include "OSspecific.H" + +#include "scalar.H" +#include "IOstreams.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[]) +{ + PtrList list1(10); + PtrList 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<<"list1: " << list1 << endl; + + Info<< nl << "Done." << endl; + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/SLList/SLListTest.C b/applications/test/SLList/SLListTest.C index 3bd9af2b67..f55f7b4edf 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 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 5caea16dad..247fc98cbb 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 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/callback/Make/files b/applications/test/callback/Make/files index 788abb0467..bd1eab1e8a 100644 --- a/applications/test/callback/Make/files +++ b/applications/test/callback/Make/files @@ -1,3 +1,3 @@ callbackTest.C -EXE = $(FOAM_APPBIN)/callbackTest +EXE = $(FOAM_USER_APPBIN)/callbackTest diff --git a/applications/test/dataEntry/Make/files b/applications/test/dataEntry/Make/files index abbd55d349..b32b5bd950 100644 --- a/applications/test/dataEntry/Make/files +++ b/applications/test/dataEntry/Make/files @@ -1,3 +1,3 @@ testDataEntry.C -EXE = $(FOAM_APPBIN)/testDataEntry +EXE = $(FOAM_USER_APPBIN)/testDataEntry diff --git a/applications/test/dictionary/dictionaryTest.C b/applications/test/dictionary/dictionaryTest.C index 37ae9bd90c..558ec7fec6 100644 --- a/applications/test/dictionary/dictionaryTest.C +++ b/applications/test/dictionary/dictionaryTest.C @@ -30,6 +30,7 @@ Description \*---------------------------------------------------------------------------*/ #include "IOstreams.H" +#include "IOobject.H" #include "IFstream.H" #include "dictionary.H" @@ -40,30 +41,46 @@ using namespace Foam; int main(int argc, char *argv[]) { - IFstream dictStream("testDict"); - dictionary testDict(dictStream); + { + dictionary dict(IFstream("testDict")()); + Info<< "dict: " << dict << nl + << "toc: " << dict.toc() << nl + << "keys: " << dict.keys() << nl + << "patterns: " << dict.keys(true) << endl; + } - Info<< testDict << endl; + + IOobject::writeDivider(Info); { - dictionary someDict; - someDict.add(keyType("a.*", true), "subdictValue"); + dictionary dict(IFstream("testDictRegex")()); + dict.add(keyType("fooba[rz]", true), "anything"); - dictionary dict; - dict.add("someDict", someDict); - dict.add(keyType(".*", true), "parentValue"); + Info<< "dict:" << dict << nl + << "toc: " << dict.toc() << nl + << "keys: " << dict.keys() << nl + << "patterns: " << dict.keys(true) << endl; - Info<< "dict:" << dict << 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 pattern find \"foo\" in sub directory : " + << dict.subDict("someDict").lookup("foo", true) + << endl; + Info<< "Recursive pattern find \"fooz\" in sub directory : " + << dict.subDict("someDict").lookup("fooz", true) + << endl; + Info<< "Recursive pattern find \"bar\" in sub directory : " + << dict.subDict("someDict").lookup("bar", true) + << endl; + Info<< "Recursive pattern find \"xxx\" in sub directory : " + << dict.subDict("someDict").lookup("xxx", true) + << endl; } return 0; diff --git a/applications/test/dictionary/testDictRegex b/applications/test/dictionary/testDictRegex new file mode 100644 index 0000000000..01d4274ba8 --- /dev/null +++ b/applications/test/dictionary/testDictRegex @@ -0,0 +1,36 @@ +/*-------------------------------*- C++ -*---------------------------------*\ +| ========= | +| \\ / OpenFOAM | +| \\ / | +| \\ / The Open Source CFD Toolbox | +| \\/ http://www.OpenFOAM.org | +\*-------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object testDictRegex; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#inputMode merge + +".*" parentValue1; +"[n-z].*" parentValue2; +"f.*" parentValue3; +keyX parentValue4; +keyY parentValue5; + +"(.*)Dict" +{ + foo subdictValue0; + bar $f.*; // should this really match 'foo'? + + // result is dependent on insert order! + "a.*c" subdictValue3; + "ab.*" subdictValue2; + "a.*" subdictValue1; + abcd \1; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/fileName/fileNameTest.C b/applications/test/fileName/fileNameTest.C index 99642333c6..c3a36f49e1 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/findTimes/findTimes.C b/applications/test/findTimes/findTimes.C index db22507b4f..2acc6e756c 100644 --- a/applications/test/findTimes/findTimes.C +++ b/applications/test/findTimes/findTimes.C @@ -28,6 +28,7 @@ Description #include "argList.H" #include "Time.H" +#include "timeSelector.H" using namespace Foam; @@ -36,13 +37,19 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::noParallel(); + // timeSelector::addOptions(); + timeSelector::addOptions(true, true); # include "setRootCase.H" # include "createTime.H" - Info<< runTime.times() << endl; + Info<< "Times found:" << runTime.times() << endl; - Info << "End\n" << endl; + instantList timeDirs = timeSelector::select0(runTime, args); + + Info<< "Times selected:" << timeDirs << endl; + Info<< "\nEnd\n" << endl; return 0; } diff --git a/applications/test/getRoots/Make/files b/applications/test/getRoots/Make/files deleted file mode 100644 index 01385a7731..0000000000 --- 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 4e772fdf9d..0000000000 --- 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 2cc985b169..0000000000 --- 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 > rawList(IFstream("testRegexps")()); + Info<< "input list:" << rawList << endl; + IOobject::writeDivider(Info); + Info<< endl; + + List groups; + + // report matches: + forAll(rawList, elemI) + { + const string& pat = rawList[elemI].first(); + const string& str = rawList[elemI].second(); + regExp re(pat); + + Info<< str << " =~ m/" << pat.c_str() << "/ == "; + + if (re.match(str, groups)) + { + Info<< "true"; + if (re.ngroups()) + { + Info<< groups; + } + } + else + { + Info<< "false"; + if (re.match(str, true)) + { + Info<< " partial match"; + } + } + 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/regex/testRegexps b/applications/test/regex/testRegexps new file mode 100644 index 0000000000..eeae1d865a --- /dev/null +++ b/applications/test/regex/testRegexps @@ -0,0 +1,20 @@ +/*-------------------------------*- C++ -*---------------------------------*\ +| ========= | +| \\ / OpenFOAM | +| \\ / | +| \\ / The Open Source CFD Toolbox | +| \\/ http://www.OpenFOAM.org | +\*-------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// pattern, string +( + ( "a.*" "abc" ) + ( "a.*" "bac" ) + ( "a.*" "abcd" ) + ( "a.*" "def" ) + ( "d(.*)f" "def" ) +) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/router/Gather/Gather.C b/applications/test/router/Gather/Gather.C index 968f45b936..1f2bc56c44 100644 --- a/applications/test/router/Gather/Gather.C +++ b/applications/test/router/Gather/Gather.C @@ -59,23 +59,24 @@ Gather::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::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/test/stringList/stringListTest.C b/applications/test/stringList/stringListTest.C index 045ca1fe72..2c7da0d5e9 100644 --- a/applications/test/stringList/stringListTest.C +++ b/applications/test/stringList/stringListTest.C @@ -26,7 +26,7 @@ Description \*---------------------------------------------------------------------------*/ -#include "stringList.H" +#include "stringListOps.H" #include "IOstreams.H" using namespace Foam; diff --git a/applications/test/xfer/Make/files b/applications/test/xfer/Make/files index 92414c039e..d3c1cd8ac2 100644 --- a/applications/test/xfer/Make/files +++ b/applications/test/xfer/Make/files @@ -1,4 +1,3 @@ xferListTest.C -/* EXE = $(FOAM_USER_APPBIN)/xferListTest */ -EXE = ./xferListTest +EXE = $(FOAM_USER_APPBIN)/xferListTest diff --git a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C index f290e7fa42..f9337bad0e 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 e99bca0af1..cf9d5e8237 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/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 5777ae8a8a..43d550f406 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -292,6 +292,7 @@ meshQualityControls minFlatness 0.5; //- Minimum pyramid volume. Is absolute volume of cell pyramid. + // Set to a sensible fraction of the smallest cell volume expected. // Set to very negative number (e.g. -1E30) to disable. minVol 1e-13; diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index 50818f4db9..3b5fca211e 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -45,8 +45,10 @@ Description int main(int argc, char *argv[]) { + // enable -constant ... if someone really wants it + // enable -zeroTime to prevent accidentally trashing the initial fields + timeSelector::addOptions(true, true); argList::noParallel(); - timeSelector::addOptions(); # include "addRegionOption.H" argList::validOptions.insert("fields", "\"(list of fields)\""); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C index c8a7d89df2..05501a904d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C @@ -74,7 +74,9 @@ using namespace Foam; int main(int argc, char *argv[]) { - // with -constant and -zeroTime + // enable -constant + // probably don't need -zeroTime though, since the fields are vetted + // afterwards anyhow timeSelector::addOptions(true, false); argList::noParallel(); argList::validOptions.insert("ascii", ""); diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt index 01d4f5a9fe..17be614da4 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 d7db62e441..898f3572e0 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/preProcessing/foamUpgradeFvSolution/Make/files b/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files new file mode 100644 index 0000000000..f667ed655e --- /dev/null +++ b/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files @@ -0,0 +1,3 @@ +foamUpgradeFvSolution.C + +EXE = $(FOAM_APPBIN)/foamUpgradeFvSolution diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/options b/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/options new file mode 100644 index 0000000000..e69de29bb2 diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C b/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C new file mode 100644 index 0000000000..9128ad3d5c --- /dev/null +++ b/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Application + foamUpgradeFvSolution + +Description + Simple tool to upgrade the syntax of system/fvSolution::solvers + +Usage + + - foamUpgradeFvSolution [OPTION] + + @param -test \n + Suppress writing the updated fvSolution file + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "IOdictionary.H" +#include "solution.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noParallel(); + argList::validOptions.insert("test", ""); + +# include "setRootCase.H" +# include "createTime.H" + + IOdictionary solutionDict + ( + IOobject + ( + "fvSolution", + runTime.system(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + label nChanged = 0; + entry* e = solutionDict.lookupEntryPtr("solvers", false, false); + if (e && e->isDict()) + { + nChanged = solution::upgradeSolverDict(e->dict(), true); + } + + Info<< nChanged << " solver settings changed" << nl << endl; + if (nChanged) + { + if (args.options().found("test")) + { + Info<< "-test option: no changes made" << nl << endl; + } + else + { + mv + ( + solutionDict.objectPath(), + solutionDict.objectPath() + ".old" + ); + + solutionDict.writeObject + ( + IOstream::ASCII, + IOstream::currentVersion, + IOstream::UNCOMPRESSED + ); + + Info<< "Backup to " << (solutionDict.objectPath() + ".old") << nl + << "Write to " << solutionDict.objectPath() << nl << endl; + } + } + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C b/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C index 3d494b6cc0..be274ec4ce 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 56767eecb3..444570046a 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 c3ee5e81fd..392c2e062f 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 db5ce4641b..0000000000 --- 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 0000000000..707287a981 --- /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</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/paraFoam b/bin/paraFoam index 101bba1674..4fc5c3cb9f 100755 --- a/bin/paraFoam +++ b/bin/paraFoam @@ -31,19 +31,19 @@ # #------------------------------------------------------------------------------ usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat</dev/null || usage "directory does not exist: '$caseDir'" - ;; - -region) - [ "$#" -ge 2 ] || usage "'-region' option requires an argument" - regionName=$2 - shift 2 - ;; - -touch) - touchOnly=1 - shift - ;; - *) - usage "unknown option/argument: '$*'" - ;; - esac + case "$1" in + -h | -help) + usage + ;; + -case) + [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + cd "$2" 2>/dev/null || usage "directory does not exist: '$2'" + shift 2 + ;; + -region) + [ "$#" -ge 2 ] || usage "'$1' option requires an argument" + regionName=$2 + shift 2 + ;; + -touch) + touchOnly=true + shift + ;; + *) + usage "unknown option/argument: '$*'" + ;; + esac done # get a sensible caseName caseName=${PWD##*/} caseFile="$caseName.OpenFOAM" +fvControls="system" + if [ -n "$regionName" ] then - caseFile="$caseName{$regionName}.OpenFOAM" + caseFile="$caseName{$regionName}.OpenFOAM" + fvControls="$fvControls/$regionName" fi -if [ -n "$touchOnly" ]; +if [ -n "$touchOnly" ] then - touch "$caseFile" - echo "created '$caseFile'" - exit 0 + touch "$caseFile" + echo "created '$caseFile'" + exit 0 fi # parent directory for normal or parallel results case "$caseName" in - processor*) parentDir=".." ;; - *) parentDir="." ;; + processor*) parentDir=".." ;; + *) parentDir="." ;; esac # check existence of essential files -for check in system/controlDict system/fvSchemes system/fvSolution +for check in system/controlDict $fvControls/fvSchemes $fvControls/fvSolution do - [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" + [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" done case "$ParaView_VERSION" in 2*) - trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT - touch $caseFile + trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT + touch "$caseFile" - # since we are now in the cwd, %CASE% is '$PWD/$caseFile' - sed -e s@%CASE%@$PWD/$caseFile@g \ - $WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs + # since we are now in the cwd, %CASE% is '$PWD/$caseFile' + sed -e s@%CASE%@$PWD/$caseFile@g \ + $WM_PROJECT_DIR/bin/tools/paraFoam.pvs > paraFoam.pvs - paraview paraFoam.pvs - ;; + paraview paraFoam.pvs + ;; *) - # only create/remove caseFile if it doesn't exist - [ -e $caseFile ] || { - trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT - touch "$caseFile" - echo "created temporary '$caseFile'" - } + # only create/remove caseFile if it didn't already exist + [ -e $caseFile ] || { + trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT + touch "$caseFile" + echo "created temporary '$caseFile'" + } - paraview --data="$caseFile" - ;; + paraview --data="$caseFile" + ;; esac #------------------------------------------------------------------------------ diff --git a/bin/tools/README b/bin/tools/README index c99723b20e..2b98a9702f 100644 --- a/bin/tools/README +++ b/bin/tools/README @@ -1,2 +1,2 @@ -Misc. tools for building applications, etc that are useful to have -but which don't really need to be in the PATH. +Misc. tools, scripts, templates that are useful (eg, for building applications) +but don't need to be in the PATH. 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 1f95596f3c..87b993d539 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</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 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 + 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 - } + [ -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 + 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 - } + [ -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 - } + # 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 + 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" + 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 + 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 + # 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 + 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 + [ -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 + # 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() { - fileSpec=$1 - string=$2 - envName=$3 + envName=$1 + string=$2 + shift 2 - 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 + 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() +{ + 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 || exit 1 # change to build folder + echo " Installing ParaView to $ParaView_DIR" - cd $ParaView_DIR + echo "disabled 'make install' for now, just use links" - echo " Replacing path hard 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 - # Replace local ParaView_INST_DIR path with ParaView_INST_DIR - # environment variable - fixCMakeHardLinks '*.cmake' "$ParaView_INST_DIR" ParaView_INST_DIR +cat<< INFO + --- + Installation complete + Set environment variables: - # 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 " ---" + 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/bin/paraFoam.pvs b/bin/tools/paraFoam.pvs similarity index 100% rename from bin/paraFoam.pvs rename to bin/tools/paraFoam.pvs diff --git a/etc/apps/paraview3/bashrc b/etc/apps/paraview3/bashrc index 8ff8781051..cfa2f11337 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 636b10eb75..875d0d1655 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 +set paraviewMajor=paraview-3.5 +setenv ParaView_VERSION 3.5-cvs -setenv ParaView_VERSION 3.3-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 ec96457be2..35044f5b01 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 35b8f55b88..c451cff8dd 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -2,6 +2,9 @@ cd ${0%/*} || exit 1 # run from this directory set -x +# 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 Pstream/Allwmake diff --git a/src/OSspecific/Unix/Make/files b/src/OSspecific/Unix/Make/files index 39c40b74c4..f83513ac4a 100644 --- a/src/OSspecific/Unix/Make/files +++ b/src/OSspecific/Unix/Make/files @@ -2,6 +2,7 @@ signals/sigFpe.C signals/sigSegv.C signals/sigInt.C signals/sigQuit.C +regExp.C timer.C fileStat.C Unix.C diff --git a/src/OSspecific/Unix/Unix.C b/src/OSspecific/Unix/Unix.C index 8f4ddafdb8..271d4a442b 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 new file mode 100644 index 0000000000..e3ad4a11af --- /dev/null +++ b/src/OSspecific/Unix/regExp.C @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 +#include "regExp.H" +#include "label.H" +#include "string.H" +#include "List.H" +#include "IOstreams.H" + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +void Foam::regExp::compile(const char* pat) const +{ + clear(); + + // avoid NULL and zero-length patterns + if (pat && *pat) + { + preg_ = new regex_t; + + if (regcomp(preg_, pat, REG_EXTENDED) != 0) + { + FatalErrorIn + ( + "regExp::compile(const char*)" + ) << "Failed to compile regular expression '" << pat << "'" + << exit(FatalError); + } + } +} + + +void Foam::regExp::clear() const +{ + if (preg_) + { + regfree(preg_); + delete preg_; + preg_ = 0; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::regExp::regExp() +: + preg_(0) +{} + + +Foam::regExp::regExp(const string& pat) +: + preg_(0) +{ + compile(pat.c_str()); +} + + +Foam::regExp::regExp(const char* pat) +: + preg_(0) +{ + compile(pat); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::regExp::~regExp() +{ + clear(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +int Foam::regExp::ngroups() const +{ + return preg_ ? preg_->re_nsub : 0; +} + + +bool Foam::regExp::match +( + const string& str, + bool partialMatch +) const +{ + if (preg_ && str.size()) + { + size_t nmatch = 1; + 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 + && + ( + partialMatch + || (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size())) + ) + ) + { + return true; + } + } + + return false; +} + + +bool Foam::regExp::match +( + const string& str, + List& groups, + bool partialMatch +) const +{ + if (preg_ && str.size()) + { + size_t nmatch = ngroups() + 1; + 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 + && + ( + partialMatch + || (pmatch[0].rm_so == 0 && pmatch[0].rm_eo == label(str.size())) + ) + ) + { + groups.setSize(ngroups()); + label groupI = 0; + + for (size_t matchI = 1; matchI < nmatch; matchI++) + { + if (pmatch[matchI].rm_so != -1 && pmatch[matchI].rm_eo != -1) + { + groups[groupI] = str.substr + ( + pmatch[matchI].rm_so, + pmatch[matchI].rm_eo - pmatch[matchI].rm_so + ); + } + else + { + groups[groupI].clear(); + } + groupI++; + } + + return true; + } + } + + groups.clear(); + return false; +} + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // + +void Foam::regExp::operator=(const string& pat) +{ + compile(pat.c_str()); +} + + +void Foam::regExp::operator=(const char* pat) +{ + compile(pat); +} + + +// ************************************************************************* // diff --git a/src/OSspecific/Unix/regularExpression.H b/src/OSspecific/Unix/regExp.H similarity index 56% rename from src/OSspecific/Unix/regularExpression.H rename to src/OSspecific/Unix/regExp.H index fed14379ad..60ac68a3c2 100644 --- a/src/OSspecific/Unix/regularExpression.H +++ b/src/OSspecific/Unix/regExp.H @@ -23,94 +23,108 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::regularExpression + Foam::regExp Description - Wrapper around regular expressions. + Wrapper around POSIX extended regular expressions. + + The beginning-of-line (^) and the end-of-line ($) anchors are implicit + by default. + +SeeAlso + The manpage regex(7) for more information about POSIX regular expressions. + These differ somewhat from @c Perl and @c sed regular expressions. SourceFiles + regExp.C \*---------------------------------------------------------------------------*/ -#ifndef regularExpression_H -#define regularExpression_H +#ifndef regExp_H +#define regExp_H -#include #include -#include "string.H" -#include "IOstreams.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +// Forward declaration of classes +class string; +template class List; + /*---------------------------------------------------------------------------*\ - Class regularExpression Declaration + Class regExp Declaration \*---------------------------------------------------------------------------*/ -class regularExpression +class regExp { // Private data //- Precompiled regular expression - regex_t* preg_; - + mutable regex_t* preg_; // Private member functions + //- release allocated space + void clear() const; + + //- compile into a regular expression + void compile(const char*) const; + //- Disallow default bitwise copy construct - regularExpression(const regularExpression&); + regExp(const regExp&); //- Disallow default bitwise assignment - void operator=(const regularExpression&); + void operator=(const regExp&); public: - // Constructors + //- Construct null + regExp(); + //- Construct from string - inline regularExpression(const string& s) - { - preg_ = new regex_t; - - if (regcomp(preg_, s.c_str(), REG_EXTENDED) != 0) - { - FatalErrorIn - ( - "regularExpression::regularExpression(const char*)" - ) << "Failed to compile regular expression " << s - << exit(FatalError); - } - } + regExp(const string&); + //- Construct from character array + regExp(const char*); // Destructor - //- Construct from string - inline ~regularExpression() - { - if (preg_) - { - regfree(preg_); - delete preg_; - } - } - + ~regExp(); // Member functions - //- Matches? - inline bool matches(const string& s) const - { - size_t nmatch = 1; - regmatch_t pmatch[1]; + //- Return the number of (groups) + int ngroups() const; - int errVal = regexec(preg_, s.c_str(), nmatch, pmatch, 0); + //- Return true if it matches, partial matches are optional + bool match + ( + const string&, + bool partialMatch=false + ) const; + + //- Return true if it matches and sets the sub-groups matched, + // partial matches are optional + bool match + ( + const string&, + List& groups, + bool partialMatch=false + ) const; + + // Member Operators + + //- Assign from a string + void operator=(const string&); + + //- Assign from a character array + void operator=(const char*); - return (errVal == 0 && pmatch[0].rm_eo == label(s.size())); - } }; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index e24fd6b5ec..9162050cc0 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -289,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 33d7fd3723..b6e52f4686 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 -Dictionary::Dictionary() +Foam::Dictionary::Dictionary() {} -// Copy constructor template -Dictionary::Dictionary(const Dictionary& dict) +Foam::Dictionary::Dictionary(const Dictionary& dict) : DictionaryBase, T>(dict) {} @@ -52,10 +45,10 @@ Dictionary::Dictionary(const Dictionary& dict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -bool Dictionary::erase(const word& Keyword) +bool Foam::Dictionary::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::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 3b985482e7..90af1383f4 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 \. + associated with it. + + It is derived from DictionaryBase instantiated on a memory managed form + of intrusive doubly-linked list of \. SourceFiles Dictionary.C @@ -47,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class Dictionary Declaration + Class Dictionary Declaration \*---------------------------------------------------------------------------*/ template @@ -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 4349973c3c..9511271208 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 -void DictionaryBase::addEntries() +void Foam::DictionaryBase::addEntries() { for ( @@ -51,12 +46,15 @@ void DictionaryBase::addEntries() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -DictionaryBase::DictionaryBase() +Foam::DictionaryBase::DictionaryBase() {} template -DictionaryBase::DictionaryBase(const DictionaryBase& dict) +Foam::DictionaryBase::DictionaryBase +( + const DictionaryBase& dict +) : IDLListType(dict) { @@ -66,17 +64,20 @@ DictionaryBase::DictionaryBase(const DictionaryBase& dict) template template -DictionaryBase::DictionaryBase(Istream& is, const INew& inewt) +Foam::DictionaryBase::DictionaryBase +( + Istream& is, + const INew& iNew +) : - IDLListType(is, inewt) + IDLListType(is, iNew) { addEntries(); } -// Istream constructor template -DictionaryBase::DictionaryBase(Istream& is) +Foam::DictionaryBase::DictionaryBase(Istream& is) : IDLListType(is) { @@ -88,25 +89,60 @@ DictionaryBase::DictionaryBase(Istream& is) // Find and return T template -bool DictionaryBase::found(const word& keyword) const +bool Foam::DictionaryBase::found(const word& keyword) const { return hashedTs_.found(keyword); } -// Find and return T* +// Find and return T*, return NULL if not found template -const T* DictionaryBase::lookup(const word& keyword) const +const T* Foam::DictionaryBase::lookupPtr +( + const word& keyword +) const +{ + typename HashTable::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 +T* Foam::DictionaryBase::lookupPtr(const word& keyword) +{ + typename HashTable::iterator iter = hashedTs_.find(keyword); + + if (iter != hashedTs_.end()) + { + return *iter; + } + else + { + return NULL; + } +} + + +// Find and return T*, FatalError if keyword not found +template +const T* Foam::DictionaryBase::lookup(const word& keyword) const { typename HashTable::const_iterator iter = hashedTs_.find(keyword); if (iter == hashedTs_.end()) { - // If keyword not found print error message ... FatalErrorIn ( - "DictionaryBase::" - "lookup(const word& keyword) const" + "DictionaryBase::lookup(const word&) const" ) << keyword << " is undefined" << exit(FatalError); } @@ -115,18 +151,17 @@ const T* DictionaryBase::lookup(const word& keyword) const } -// Find and return T* +// Find and return T*, FatalError if keyword not found template -T* DictionaryBase::lookup(const word& keyword) +T* Foam::DictionaryBase::lookup(const word& keyword) { typename HashTable::iterator iter = hashedTs_.find(keyword); if (iter == hashedTs_.end()) { - // If keyword not found print error message ... FatalErrorIn ( - "DictionaryBase::lookup(const word& keyword)" + "DictionaryBase::lookup(const word&)" ) << keyword << " is undefined" << exit(FatalError); } @@ -137,7 +172,7 @@ T* DictionaryBase::lookup(const word& keyword) // Return the table of contents template -wordList DictionaryBase::toc() const +Foam::wordList Foam::DictionaryBase::toc() const { wordList keywords(this->size()); @@ -158,26 +193,28 @@ wordList DictionaryBase::toc() const // Add at head of dictionary template -void DictionaryBase::insert(const word& keyword, T* tPtr) +void Foam::DictionaryBase::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 -void DictionaryBase::append(const word& keyword, T* tPtr) +void Foam::DictionaryBase::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 -T* DictionaryBase::remove(const word& Keyword) +T* Foam::DictionaryBase::remove(const word& keyword) { - typename HashTable::iterator iter = hashedTs_.find(Keyword); + typename HashTable::iterator iter = hashedTs_.find(keyword); if (iter != hashedTs_.end()) { @@ -192,19 +229,29 @@ T* DictionaryBase::remove(const word& Keyword) } -//- Clear the dictionary template -void DictionaryBase::clear() +void Foam::DictionaryBase::clear() { IDLListType::clear(); hashedTs_.clear(); } +template +void Foam::DictionaryBase::transfer +( + DictionaryBase& dict +) +{ + IDLListType::transfer(dict); + hashedTs_.transfer(dict.hashedTs_); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -void DictionaryBase::operator= +void Foam::DictionaryBase::operator= ( const DictionaryBase& dict ) @@ -218,25 +265,11 @@ void DictionaryBase::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 8288cdf5cf..f14785bcd5 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&); /*---------------------------------------------------------------------------*\ - Class DictionaryBase Declaration + Class DictionaryBase Declaration \*---------------------------------------------------------------------------*/ template @@ -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 hashedTs_; @@ -99,10 +99,10 @@ public: //- Construct from Istream using given Istream constructor class template - 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&); // Member operators diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C index 15854c515b..6af2b1622d 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 -Ostream& operator<<(Ostream& os, const DictionaryBase& dict) +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const DictionaryBase& dict) { for ( @@ -53,7 +51,7 @@ Ostream& operator<<(Ostream& os, const DictionaryBase& 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& dict) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C index b2b7861eb4..4b0a48ac90 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 -PtrDictionary::PtrDictionary() +Foam::PtrDictionary::PtrDictionary() {} template -PtrDictionary::PtrDictionary(const PtrDictionary& dict) +Foam::PtrDictionary::PtrDictionary(const PtrDictionary& dict) : DictionaryBase, T>(dict) {} @@ -47,14 +42,14 @@ PtrDictionary::PtrDictionary(const PtrDictionary& dict) template template -PtrDictionary::PtrDictionary(Istream& is, const INew& iNew) +Foam::PtrDictionary::PtrDictionary(Istream& is, const INew& iNew) : DictionaryBase, T>(is, iNew) {} template -PtrDictionary::PtrDictionary(Istream& is) +Foam::PtrDictionary::PtrDictionary(Istream& is) : DictionaryBase, T>(is) {} @@ -62,6 +57,4 @@ PtrDictionary::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 3396236515..9c7da2f4de 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 diff --git a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C index 9712b74735..8f29af262b 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 -UDictionary::UDictionary() +Foam::UDictionary::UDictionary() {} -// Copy constructor template -UDictionary::UDictionary(const UDictionary& dict) +Foam::UDictionary::UDictionary(const UDictionary& dict) : DictionaryBase, T>(dict) {} @@ -49,6 +42,4 @@ UDictionary::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 fb30237d40..5cc4d301f4 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 diff --git a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C index 3a4686fbf6..6aa7da72ab 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 -UPtrDictionary::UPtrDictionary() +Foam::UPtrDictionary::UPtrDictionary() {} -// Copy constructor template -UPtrDictionary::UPtrDictionary(const UPtrDictionary& dict) +Foam::UPtrDictionary::UPtrDictionary(const UPtrDictionary& dict) : DictionaryBase, T>(dict) {} @@ -49,6 +42,4 @@ UPtrDictionary::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 2caac9efac..99aee0ac56 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 \. + associated with it. + + It is derived from DictionaryBase instantiated on a non-memory managed + form of intrusive doubly-linked list of \. SourceFiles UPtrDictionary.C @@ -47,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class UPtrDictionary Declaration + Class UPtrDictionary Declaration \*---------------------------------------------------------------------------*/ template diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index d9d74fd1ad..37c595222e 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -456,6 +456,14 @@ void HashTable::clear() } +template +void HashTable::clearStorage() +{ + clear(); + resize(0); +} + + template void HashTable::transfer(HashTable& ht) { diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 701d845615..798dad6367 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -54,6 +54,7 @@ template class List; template class HashTable; +template class HashPtrTable; template 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 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&); @@ -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&); @@ -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 670a3116a4..565cac9493 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 -ILList::ILList(const ILList& slpl) +Foam::ILList::ILList(const ILList& lst) : UILList() { for ( - typename UILList::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -53,9 +48,9 @@ ILList::ILList(const ILList& slpl) #ifndef __INTEL_COMPILER template template -ILList::ILList +Foam::ILList::ILList ( - const ILList& slpl, + const ILList& lst, const CloneArg& cloneArg ) : @@ -63,8 +58,8 @@ ILList::ILList { for ( - typename UILList::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -77,7 +72,7 @@ ILList::ILList // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // template -ILList::~ILList() +Foam::ILList::~ILList() { this->clear(); } @@ -85,9 +80,8 @@ ILList::~ILList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Return and remove head template -bool ILList::eraseHead() +bool Foam::ILList::eraseHead() { T* tPtr; if ((tPtr = this->removeHead())) @@ -101,9 +95,8 @@ bool ILList::eraseHead() } } -//- Return and remove element template -bool ILList::erase(T* p) +bool Foam::ILList::erase(T* p) { T* tPtr; if ((tPtr = remove(p))) @@ -119,7 +112,7 @@ bool ILList::erase(T* p) template -void ILList::clear() +void Foam::ILList::clear() { label oldSize = this->size(); for (label i=0; i::clear() } +template +void Foam::ILList::transfer(ILList& lst) +{ + clear(); + LListBase::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -void ILList::operator=(const ILList& slpl) +void Foam::ILList::operator=(const ILList& lst) { this->clear(); for ( - typename UILList::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -149,11 +150,6 @@ void ILList::operator=(const ILList& 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 074a54a259..401a8b6038 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 - 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 - ILList(const ILList& slpl, const CloneArg& cloneArg) + ILList(const ILList& lst, const CloneArg& cloneArg) #ifdef __INTEL_COMPILER : UILList() @@ -104,8 +104,8 @@ public: for ( typename UILList::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 - 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&); + // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C index 8d2ac68c27..a467da11dc 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 template -void ILList::read(Istream& is, const INew& inewt) +void Foam::ILList::read(Istream& is, const INew& iNew) { - is.fatalCheck("operator>>(Istream& is, ILList& L)"); + is.fatalCheck("operator>>(Istream&, ILList&)"); token firstToken(is); is.fatalCheck ( - "operator>>(Istream& is, ILList& L) : reading first token" + "operator>>(Istream&, ILList&) : reading first token" ); if (firstToken.isLabel()) @@ -63,26 +58,26 @@ void ILList::read(Istream& is, const INew& inewt) { for (label i=0; i>(Istream& is, ILList& L) : " + "operator>>(Istream&, ILList&) : " "reading entry" ); } } else { - T* tPtr = inewt(is).ptr(); + T* tPtr = iNew(is).ptr(); append(tPtr); is.fatalCheck ( - "operator>>(Istream& is, ILList& L) : " + "operator>>(Istream&, ILList&) : " "reading entry" ); - + for (label i=1; i::read(Istream& is, const INew& inewt) { FatalIOErrorIn ( - "operator>>(Istream& is, ILList& L)", + "operator>>(Istream&, ILList&)", is ) << "incorrect first token, '(', found " << firstToken.info() << exit(FatalIOError); } token lastToken(is); - is.fatalCheck("operator>>(Istream& is, ILList& L)"); + is.fatalCheck("operator>>(Istream&, ILList&)"); while ( @@ -117,36 +112,34 @@ void ILList::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& L)"); + is.fatalCheck("operator>>(Istream&, ILList&)"); } } else { - FatalIOErrorIn("operator>>(Istream& is, ILList& L)", is) + FatalIOErrorIn("operator>>(Istream&, ILList&)", is) << "incorrect first token, expected or '(', found " << firstToken.info() << exit(FatalIOError); } - is.fatalCheck("operator>>(Istream& is, ILList& L)"); + is.fatalCheck("operator>>(Istream&, ILList&)"); } -//- Construct from Istream using given Istream constructor class template template -ILList::ILList(Istream& is, const INew& inewt) +Foam::ILList::ILList(Istream& is, const INew& iNew) { - read(is, inewt); + read(is, iNew); } -// Construct from Istream template -ILList::ILList(Istream& is) +Foam::ILList::ILList(Istream& is) { read(is, INew()); } @@ -155,7 +148,7 @@ ILList::ILList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template -Istream& operator>>(Istream& is, ILList& L) +Foam::Istream& Foam::operator>>(Istream& is, ILList& L) { L.clear(); L.read(is, INew()); @@ -166,6 +159,4 @@ Istream& operator>>(Istream& is, ILList& 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 94512eeabd..1c93142b41 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 -LList::LList(const LList& slpl) +Foam::LList::LList(const LList& 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::LList(const LList& slpl) template -LList::~LList() +Foam::LList::~LList() { this->clear(); } @@ -59,7 +53,7 @@ LList::~LList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -void LList::clear() +void Foam::LList::clear() { label oldSize = this->size(); for (label i=0; i::clear() } +template +void Foam::LList::transfer(LList& lst) +{ + clear(); + LListBase::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -void LList::operator=(const LList& slpl) +void Foam::LList::operator=(const LList& 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 a9bc0bccae..4c422f7ccb 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 @@ -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&); // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C index 32dbaf3f17..3165850781 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 -LList::LList(Istream& is) +Foam::LList::LList(Istream& is) { operator>>(is, *this); } @@ -48,18 +42,18 @@ LList::LList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template -Istream& operator>>(Istream& is, LList& L) +Foam::Istream& Foam::operator>>(Istream& is, LList& L) { // Anull list L.clear(); - is.fatalCheck(" operator>>(Istream& is, LList& L)"); + is.fatalCheck(" operator>>(Istream&, LList&)"); token firstToken(is); is.fatalCheck ( - " operator>>(Istream& is, LList& L) : reading first token" + " operator>>(Istream&, LList&) : reading first token" ); if (firstToken.isLabel()) @@ -101,14 +95,14 @@ Istream& operator>>(Istream& is, LList& L) { FatalIOErrorIn ( - " operator>>(Istream& is, LList& L)", + " operator>>(Istream&, LList&)", is ) << "incorrect first token, '(', found " << firstToken.info() << exit(FatalIOError); } token lastToken(is); - is.fatalCheck(" operator>>(Istream& is, LList& L)"); + is.fatalCheck(" operator>>(Istream&, LList&)"); while ( @@ -124,19 +118,19 @@ Istream& operator>>(Istream& is, LList& L) L.append(element); is >> lastToken; - is.fatalCheck(" operator>>(Istream& is, LList& L)"); + is.fatalCheck(" operator>>(Istream&, LList&)"); } } else { - FatalIOErrorIn(" operator>>(Istream& is, LList& L)", is) + FatalIOErrorIn(" operator>>(Istream&, LList&)", is) << "incorrect first token, expected or '(', found " << firstToken.info() << exit(FatalIOError); } // Check state of IOstream - is.fatalCheck(" operator>>(Istream& is, LList& L)"); + is.fatalCheck(" operator>>(Istream&, LList&)"); return is; } @@ -145,19 +139,19 @@ Istream& operator>>(Istream& is, LList& L) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template -Ostream& operator<<(Ostream& os, const LList& ll) +Foam::Ostream& Foam::operator<<(Ostream& os, const LList& 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::const_iterator iter = ll.begin(); - iter != ll.end(); + typename LList::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -168,14 +162,10 @@ Ostream& operator<<(Ostream& os, const LList& ll) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const LList&)"); + os.check("Ostream& operator<<(Ostream&, const LList&)"); 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 bf29f1d450..935e68292c 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 -LPtrList::LPtrList(const LPtrList& slpl) +Foam::LPtrList::LPtrList(const LPtrList& lst) : LList() { - 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::LPtrList(const LPtrList& slpl) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template -LPtrList::~LPtrList() +Foam::LPtrList::~LPtrList() { clear(); } @@ -56,9 +51,8 @@ LPtrList::~LPtrList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Return and remove head template -bool LPtrList::eraseHead() +bool Foam::LPtrList::eraseHead() { T* tPtr; if ((tPtr = this->removeHead())) @@ -74,7 +68,7 @@ bool LPtrList::eraseHead() template -void LPtrList::clear() +void Foam::LPtrList::clear() { label oldSize = this->size(); for (label i=0; i::clear() } +template +void Foam::LPtrList::transfer(LPtrList& lst) +{ + clear(); + LList::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -void LPtrList::operator=(const LPtrList& slpl) +void Foam::LPtrList::operator=(const LPtrList& 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 601d26f876..fdb59ea27c 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&); + // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C index e5bd9c907d..c7bb16c4e2 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 template -void LPtrList::read(Istream& is, const INew& inewt) +void Foam::LPtrList::read(Istream& is, const INew& iNew) { is.fatalCheck ( @@ -66,8 +61,8 @@ void LPtrList::read(Istream& is, const INew& inewt) { for (label i=0; i::read(Istream&, const INew&) : " @@ -77,7 +72,7 @@ void LPtrList::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::read(Istream& is, const INew& inewt) "LPtrList::read(Istream&, const INew&) : " "reading entry" ); - + for (label i=1; iclone().ptr()); @@ -120,7 +115,7 @@ void LPtrList::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::read(Istream& is, const INew& inewt) template template -LPtrList::LPtrList(Istream& is, const INew& inewt) +Foam::LPtrList::LPtrList(Istream& is, const INew& iNew) { - read(is, inewt); + read(is, iNew); } template -LPtrList::LPtrList(Istream& is) +Foam::LPtrList::LPtrList(Istream& is) { read(is, INew()); } @@ -164,11 +159,10 @@ LPtrList::LPtrList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template -Istream& operator>>(Istream& is, LPtrList& L) +Foam::Istream& Foam::operator>>(Istream& is, LPtrList& L) { - // Anull list L.clear(); - + L.read(is, INew()); return is; } @@ -177,19 +171,19 @@ Istream& operator>>(Istream& is, LPtrList& L) // * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * // template -Ostream& operator<<(Ostream& os, const LPtrList& slpl) +Foam::Ostream& Foam::operator<<(Ostream& os, const LPtrList& 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::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename LPtrList::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -200,14 +194,9 @@ Ostream& operator<<(Ostream& os, const LPtrList& slpl) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const LPtrList&)"); + os.check("Ostream& operator<<(Ostream&, const LPtrList&)"); 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 ab6392094a..1c10434c9a 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 -UILList::UILList(const UILList& slpl) +Foam::UILList::UILList(const UILList& 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::UILList(const UILList& slpl) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -void UILList::operator=(const UILList& slpl) +void Foam::UILList::operator=(const UILList& 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 -bool UILList::operator==(const UILList& slpl) const +bool Foam::UILList::operator== +( + const UILList& rhs +) const { - if (this->size() != slpl.size()) + if (this->size() != rhs.size()) { return false; } @@ -71,7 +68,7 @@ bool UILList::operator==(const UILList& 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::operator==(const UILList& slpl) const // Comparison for inequality template -bool UILList::operator!=(const UILList& slpl) const +bool Foam::UILList::operator!= +( + const UILList& 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 d10c1c3949..cab57ed326 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 (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&) const; diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C index 62459551c6..d3ce739772 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 -Ostream& operator<<(Ostream& os, const UILList& ill) +Foam::Ostream& Foam::operator<<(Ostream& os, const UILList& 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::const_iterator iter = ill.begin(); - iter != ill.end(); + typename UILList::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -61,14 +56,9 @@ Ostream& operator<<(Ostream& os, const UILList& ill) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const UILList&)"); + os.check("Ostream& operator<<(Ostream&, const UILList&)"); 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 ba25e663b3..b3e21c4225 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(static_cast(DLListBase())) ); -DLListBase::const_iterator DLListBase::endConstIter +Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter ( static_cast(DLListBase()), reinterpret_cast(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 8fd2c55bc1..33df2b87c7 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 eb9c00d3f8..a9414fa387 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 0098ff685f..44e50a3666 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(static_cast(SLListBase())) ); -SLListBase::const_iterator SLListBase::endConstIter +Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter ( static_cast(SLListBase()), reinterpret_cast(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 cfd8afe4a9..f802e69142 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 3a1125924b..594fc6f098 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 90b78aabfc..20425b8a7d 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -31,13 +31,22 @@ License template 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 577494aa1c..98752700a1 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(s)); + return write(static_cast(kw)); } else { - return write(static_cast(s)); + return write(static_cast(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 Foam::timeSelector::select } } + // determine latestTime selection (if any) + // this must appear before the -time option processing + label latestIdx = -1; + if (args.options().found("latestTime")) + { + selectTimes = false; + latestIdx = timeDirs.size() - 1; + + // avoid false match on constant/ + if (latestIdx == constantIdx) + { + latestIdx = -1; + } + } + if (args.options().found("time")) { + // can match 0/, but can never match constant/ selectTimes = timeSelector ( IStringStream(args.options()["time"])() ).selected(timeDirs); } - else if (args.options().found("latestTime")) - { - selectTimes = false; - const label latestIdx = timeDirs.size() - 1; - // avoid false match on constant/ or 0/ - if (latestIdx != constantIdx && latestIdx != zeroIdx) - { - selectTimes[latestIdx] = true; - } + + // add in latestTime (if selected) + if (latestIdx >= 0) + { + selectTimes[latestIdx] = true; } - // special treatment for constant/ if (constantIdx >= 0) { + // only add constant/ if specifically requested selectTimes[constantIdx] = args.options().found("constant"); } @@ -197,10 +209,12 @@ Foam::List Foam::timeSelector::select { if (args.options().found("noZero")) { + // exclude 0/ if specifically requested selectTimes[zeroIdx] = false; } else if (argList::validOptions.found("zeroTime")) { + // with -zeroTime enabled, drop 0/ unless specifically requested selectTimes[zeroIdx] = args.options().found("zeroTime"); } } diff --git a/src/OpenFOAM/db/Time/timeSelector.H b/src/OpenFOAM/db/Time/timeSelector.H index 7d1f15fda1..6afa92ee06 100644 --- a/src/OpenFOAM/db/Time/timeSelector.H +++ b/src/OpenFOAM/db/Time/timeSelector.H @@ -60,8 +60,9 @@ Description @endverbatim The first argument avoids adding the @b -constant option. The second - argument adds an additional @b -zeroTime option and prevents the @c 0/ - directory from being included in the default time range. + argument adds an additional @b -zeroTime option and also prevents the + @c 0/ directory from being included in the default time range and in the + @b -latestTime selection. SourceFiles timeSelector.C @@ -121,14 +122,17 @@ public: // // @param constant // Add the @b -constant option to include the @c constant/ directory + // // @param zeroTime - // Additional to the @b -noZero option (explicitly exclude the - // @c 0/ directory), add the @b -zeroTime option to include the - // @c 0/ directory. The @b -noZero option has precedence. + // Enable the @b -zeroTime option and alter the normal time selection + // behaviour (and @b -latestTime behaviour) to exclude the @c 0/ + // directory. The @c 0/ directory will only be included when + // @b -zeroTime is specified. + // The @b -noZero option has precedence over the @b -zeroTime option. static void addOptions ( - const bool constant = true, - const bool zeroTime = false + const bool constant=true, + const bool zeroTime=false ); //- Return the set of times selected based on the argList options diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index 265a2944cb..5d0ee2af65 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -27,7 +27,7 @@ License #include "dictionary.H" #include "primitiveEntry.H" #include "dictionaryEntry.H" -#include "regularExpression.H" +#include "regExp.H" /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ @@ -38,26 +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::const_iterator& wcLink, - DLList >::const_iterator& reLink + DLList >::const_iterator& reLink ) const { - if (wildCardEntries_.size() > 0) + if (patternEntries_.size() > 0) { - //wcLink = wildCardEntries_.begin(); - //reLink = wildCardRegexps_.end(); - - while (wcLink != wildCardEntries_.end()) + while (wcLink != patternEntries_.end()) { - if (!wildCardMatch && wcLink()->keyword() == Keyword) - { - return true; - } - else if (wildCardMatch && reLink()->matches(Keyword)) + if + ( + patternMatch ? reLink()->match(Keyword) + : wcLink()->keyword() == Keyword + ) { return true; } @@ -71,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::iterator& wcLink, - DLList >::iterator& reLink + DLList >::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()->matches(Keyword)) + if + ( + patternMatch ? reLink()->match(Keyword) + : wcLink()->keyword() == Keyword + ) { return true; } @@ -128,15 +125,12 @@ 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 - ( - new regularExpression(iter().keyword()) - ) + autoPtr(new regExp(iter().keyword())) ); } } @@ -161,15 +155,12 @@ 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 - ( - new regularExpression(iter().keyword()) - ) + autoPtr(new regExp(iter().keyword())) ); } } @@ -226,14 +217,14 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const } else { - if (wildCardEntries_.size() > 0) + if (patternEntries_.size() > 0) { - DLList::const_iterator wcLink = wildCardEntries_.begin(); - DLList >::const_iterator reLink = - wildCardRegexps_.begin(); + DLList::const_iterator wcLink = patternEntries_.begin(); + DLList >::const_iterator reLink = + 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; } @@ -255,22 +246,22 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr ( const word& keyword, bool recursive, - bool wildCardMatch + bool patternMatch ) const { HashTable::const_iterator iter = hashedEntries_.find(keyword); if (iter == hashedEntries_.end()) { - if (wildCardMatch && wildCardEntries_.size() > 0) + if (patternMatch && patternEntries_.size() > 0) { DLList::const_iterator wcLink = - wildCardEntries_.begin(); - DLList >::const_iterator reLink = - wildCardRegexps_.begin(); + patternEntries_.begin(); + DLList >::const_iterator reLink = + 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(); } @@ -278,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 { @@ -294,21 +285,22 @@ Foam::entry* Foam::dictionary::lookupEntryPtr ( const word& keyword, bool recursive, - bool wildCardMatch + bool patternMatch ) { HashTable::iterator iter = hashedEntries_.find(keyword); if (iter == hashedEntries_.end()) { - if (wildCardMatch && wildCardEntries_.size() > 0) + if (patternMatch && patternEntries_.size() > 0) { DLList::iterator wcLink = - wildCardEntries_.begin(); - DLList >::iterator reLink = - wildCardRegexps_.begin(); - // Find in wildcards using regular expressions only - if (findInWildcards(wildCardMatch, keyword, wcLink, reLink)) + patternEntries_.begin(); + DLList >::iterator reLink = + patternRegexps_.begin(); + + // Find in patterns using regular expressions only + if (findInPatterns(patternMatch, keyword, wcLink, reLink)) { return wcLink(); } @@ -320,7 +312,7 @@ Foam::entry* Foam::dictionary::lookupEntryPtr ( keyword, recursive, - wildCardMatch + patternMatch ); } else @@ -337,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) { @@ -361,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) @@ -439,7 +431,7 @@ Foam::wordList Foam::dictionary::toc() const { wordList keys(size()); - label i = 0; + label nKeys = 0; for ( IDLList::const_iterator iter = begin(); @@ -447,13 +439,36 @@ Foam::wordList Foam::dictionary::toc() const ++iter ) { - keys[i++] = iter().keyword(); + keys[nKeys++] = iter().keyword(); } return keys; } +Foam::List Foam::dictionary::keys(bool patterns) const +{ + List keys(size()); + + label nKeys = 0; + for + ( + IDLList::const_iterator iter = begin(); + iter != end(); + ++iter + ) + { + if (iter().keyword().isPattern() ? patterns : !patterns) + { + keys[nKeys++] = iter().keyword(); + } + } + keys.setSize(nKeys); + + return keys; +} + + bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) { HashTable::iterator iter = hashedEntries_.find @@ -482,15 +497,12 @@ 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 - ( - new regularExpression(entryPtr->keyword()) - ) + autoPtr(new regExp(entryPtr->keyword())) ); } @@ -514,15 +526,12 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) entryPtr->name() = name_ + "::" + entryPtr->keyword(); IDLList::append(entryPtr); - if (entryPtr->keyword().isWildCard()) + if (entryPtr->keyword().isPattern()) { - wildCardEntries_.insert(entryPtr); - wildCardRegexps_.insert + patternEntries_.insert(entryPtr); + patternRegexps_.insert ( - autoPtr - ( - new regularExpression(entryPtr->keyword()) - ) + autoPtr(new regExp(entryPtr->keyword())) ); } @@ -612,17 +621,15 @@ bool Foam::dictionary::remove(const word& Keyword) if (iter != hashedEntries_.end()) { - // Delete from wildcards first - DLList::iterator wcLink = - wildCardEntries_.begin(); - DLList >::iterator reLink = - wildCardRegexps_.begin(); + // Delete from patterns first + DLList::iterator wcLink = patternEntries_.begin(); + DLList >::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::remove(iter()); @@ -659,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); } @@ -678,26 +685,26 @@ bool Foam::dictionary::changeKeyword { if (forceOverwrite) { - if (iter2()->keyword().isWildCard()) + if (iter2()->keyword().isPattern()) { - // Delete from wildcards first + // Delete from patterns first DLList::iterator wcLink = - wildCardEntries_.begin(); - DLList >::iterator reLink = - wildCardRegexps_.begin(); + patternEntries_.begin(); + DLList >::iterator reLink = + 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); } } IDLList::replace(iter2(), iter()); delete iter2(); hashedEntries_.erase(iter2); - + } else { @@ -717,15 +724,12 @@ 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 - ( - new regularExpression(newKeyword) - ) + autoPtr(new regExp(newKeyword)) ); } @@ -789,6 +793,8 @@ void Foam::dictionary::clear() { IDLList::clear(); hashedEntries_.clear(); + patternEntries_.clear(); + patternRegexps_.clear(); } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index b1d0d186f6..a4020b6f32 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 @@ -67,7 +67,7 @@ namespace Foam { // Forward declaration of friend functions and operators -class regularExpression; +class regExp; class dictionary; Istream& operator>>(Istream&, dictionary&); Ostream& operator<<(Ostream&, const dictionary&); @@ -92,32 +92,30 @@ class dictionary //- Parent dictionary const dictionary& parent_; - //- Wildcard entries - DLList wildCardEntries_; + //- Entries of matching patterns + DLList patternEntries_; - //- Wildcard precompiled regex - DLList > wildCardRegexps_; + //- Patterns as precompiled regular expressions + DLList > 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::const_iterator& wcLink, - DLList >::const_iterator& reLink + DLList >::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::iterator& wcLink, - DLList >::iterator& reLink + DLList >::iterator& reLink ); @@ -163,16 +161,16 @@ public: dictionary(Istream&); //- Construct as copy given the parent dictionary - dictionary(const dictionary& parentDict, const dictionary& dict); + dictionary(const dictionary& parentDict, const dictionary&); //- Construct top-level dictionary as copy - dictionary(const dictionary& dict); + dictionary(const dictionary&); //- Construct and return clone Foam::autoPtr clone() const; //- Construct top-level dictionary on freestore from Istream - static Foam::autoPtr New(Istream& is); + static Foam::autoPtr New(Istream&); // Destructor @@ -210,83 +208,88 @@ public: // Search and lookup //- Search dictionary for given keyword - // If recursive search parent dictionaries - bool found(const word& keyword, bool recursive=false) const; + // 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 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 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 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 keys(bool patterns=false) const; + // Editing //- Add a new entry @@ -331,13 +337,13 @@ public: //- Add a scalar entry // optionally overwrite an existing entry - void add (const keyType&, const scalar, bool overwrite=false); + void add(const keyType&, const scalar, bool overwrite=false); //- Add a dictionary entry // optionally merge with an existing sub-dictionary void add ( - const keyType& keyword, + const keyType&, const dictionary&, bool mergeEntry=false ); @@ -345,7 +351,7 @@ public: //- Add a T entry // optionally overwrite an existing entry template - void add(const keyType& keyword, const T&, bool overwrite=false); + void add(const keyType&, const T&, bool overwrite=false); //- Assign a new entry, overwrite any existing entry void set(entry*); @@ -354,14 +360,14 @@ public: void set(const entry&); //- Assign a dictionary entry, overwrite any existing entry - void set(const keyType& keyword, const dictionary&); + void set(const keyType&, const dictionary&); //- Assign a T entry, overwrite any existing entry template - void set(const keyType& keyword, const T&); + void set(const keyType&, const T&); //- Remove an entry specified by keyword - bool remove(const word& keyword); + bool remove(const word&); //- Change the keyword for an entry, // optionally forcing overwrite of an existing entry @@ -369,7 +375,7 @@ public: ( const keyType& oldKeyword, const keyType& newKeyword, - bool forceOverwrite = false + bool forceOverwrite=false ); //- Merge entries from the given dictionary. @@ -382,7 +388,7 @@ public: // Write - void write(Ostream& os, bool subDict = true) const; + void write(Ostream&, bool subDict=true) const; // Member Operators @@ -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 1909f4851d..2b86c53d01 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 clone(const dictionary& parentDict) const @@ -158,10 +158,8 @@ public: }; -#if defined (__GNUC__) template<> -#endif -Ostream& operator<<(Ostream& os, const InfoProxy& ip); +Ostream& operator<<(Ostream&, const InfoProxy&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index cb04194915..35746ea665 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -27,7 +27,7 @@ License #include "dictionary.H" #include "IFstream.H" #include "inputModeEntry.H" -#include "regularExpression.H" +#include "regExp.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -137,9 +137,6 @@ Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict) functionEntries::inputModeEntry::clear(); dict.clear(); - dict.hashedEntries_.clear(); - dict.wildCardEntries_.clear(); - dict.wildCardRegexps_.clear(); dict.read(is); return is; diff --git a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C index a47a976814..65883ba535 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(entryPtr->stream()); } else { - return pTraits(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(entryPtr->stream()); } else { - return pTraits(entryPtr->stream()); + add(new primitiveEntry(keyword, deflt)); + return deflt; } } @@ -80,20 +80,20 @@ 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) - { - return false; - } - else + if (entryPtr) { entryPtr->stream() >> val; return true; } + else + { + return false; + } } diff --git a/src/OpenFOAM/db/dictionary/entry/entry.H b/src/OpenFOAM/db/dictionary/entry/entry.H index 5ed8b929b6..61eafc7c8a 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 clone + virtual autoPtr clone ( const dictionary& parentDict ) const = 0; //- Construct on freestore as copy // Note: the parent directory is set to dictionary::null - virtual Foam::autoPtr clone() const; + virtual autoPtr 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 New(Istream& is); + static autoPtr New(Istream& is); // Destructor diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H index 86d8afd61d..1e5858abaf 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& ip); +Ostream& operator<<(Ostream&, const InfoProxy&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjectList/functionObjectList.C index 760cf83a2a..8bb900edfd 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