diff --git a/.gitignore b/.gitignore index 4a7188cdfbaaa032b0025983cdc81649a20f8aa5..96c3093b718b9a8ee6d711583018ae836555158a 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,9 @@ doc/[Dd]oxygen/man *.tar.gz *.tgz +# ignore the persistent .build tag in the main directory +/.build + # ignore .timeStamp in the main directory /.timeStamp diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/XiEqModels/basicXiSubXiEq/basicXiSubXiEq.H b/applications/solvers/combustion/PDRFoam/PDRModels/XiEqModels/basicXiSubXiEq/basicXiSubXiEq.H index 04cc2a83cadcee2acdcf9473a7ef40f3c3def1f3..335012c86849793ec51e73a5c003d4cc58096321 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 a455fd28b4963ce6ad2305230fdfee06dde245b3..d844dca34e93b7cfdfbb4a498a0e9d67d554665a 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 3448d1166c4106a1cd50d652df134b75b94100bc..7177fca84761e6811e9a4d18d2c687b7872072bb 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 05ec433919da7a247042a2011aecab79464f7691..889cd57fd69a99a52ca32e8d632043e2a23f7739 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 b35ef9151ea1c7fe633475a459d38a6ded55459d..b370c0b035b1f758efccafdbb85398a7761cf4c6 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 d8bc58b1701a7559dc1741a093c3af7d1800819a..c361e819464be96229c43a8b69a6be67d4c7e59c 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 b9a45ffb636d2a818b0fa5fa7e1d079e9350e734..589060895c4111ae127e6e4e14091003a0867712 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 b2b2b35edf2e5f032d037fa3d6bc7c8afe0b5108..e8c4dea23c71f8558f01f3041db9a3ddaa8c1b94 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 2c35877f5e71b50b5ce8aaf0401fe103d4e9c6cc..9cbdcbe3da505e39a60548cbfcc9408577d8d727 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 455635dc0800c07bc16e3af27d424cbcfe98c9aa..b57cda5e281e637aa0c117caaa7a136923690302 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 8884c00deb8fae91a539be2448d5abe33b3a5c00..93562557e9f901713e746f66b6f14a8531da7b4c 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 908dc3a623d4f764dca24920212b4b40e6034b6c..803644261e271c407b988b36e31fe8fc64e9dce3 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 596e86229b44b2eb733821219e4119a7489d6b91..fa6935382c6d09b04f8cea688c3c661ca3871305 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 2b76f9bc92a498028aa3ee9d48061f415f5c130b..2447263f7bf34a7e8155a8d0ddec4e4869929e83 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 9da38cf00dd51919f3500bb83158c13f17bbddaa..70fde4a510c6cd9df4e8547f0ed8bbaf92340b31 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 64c44fdff4c3819757acf1885afd18e481171e2a..3a9919259db275c355215c32091a8dda48ac05f3 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 db2a7255aafd0cfc590761fcb4f0e9417aacd1f1..3023ce272fb285813485922ba8d2e6fc05ba2b87 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 8c65453b946f51b0b0d2810ea334bd1b13848712..029d31f25d851e8a1ba27c5e79d6718489d4e6d4 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 11a180957567674655948c692551189aaf2a908f..e24de6658d057a4d3e4a34faf06a5537b4578679 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(); + { + // Store divU from the previous mesh for the correctPhi + volScalarField divU = fvc::div(phi); - // Do any mesh changes - mesh.update(); + scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); - if (mesh.changing()) - { - Info<< "Execution time for mesh.update() = " - << runTime.elapsedCpuTime() - timeBeforeMeshUpdate - << " s" << endl; + // Do any mesh changes + mesh.update(); - gh = g & mesh.C(); - ghf = g & mesh.Cf(); - } + if (mesh.changing()) + { + Info<< "Execution time for mesh.update() = " + << runTime.elapsedCpuTime() - timeBeforeMeshUpdate + << " s" << endl; + } - if (mesh.changing() && correctPhi) - { - //***HGW#include "correctPhi.H" + 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 0000000000000000000000000000000000000000..4152105784639530f725c53b7b561841b798c624 --- /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 1f579d245bdcac21f647ac2a90a516b5f612b3c9..dc04fb454680bbeadec55c8946227270601651c7 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<pd.boundaryField().size(); i++) + { + if (pd.boundaryField()[i].fixesValue()) + { + pcorrTypes[i] = fixedValueFvPatchScalarField::typeName; + } + } diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H index 013d8eb05f7e341ee0c8bf9fc5f1511e8d9c6dc6..b0f3378408fb76da41887cee0724a55e77afea11 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/pEqn.H @@ -21,7 +21,7 @@ surfaceScalarField phiU ( "phiU", - (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, rho, U, phi) + (fvc::interpolate(U) & mesh.Sf()) ); phi = phiU + diff --git a/applications/test/DLList/DLListTest.C b/applications/test/DLList/DLListTest.C index 12913ce8666f661fdd693bc76e1775c090e7a59b..2929efc1ce8d2940aed11d007c9d7b474bef437b 100644 --- a/applications/test/DLList/DLListTest.C +++ b/applications/test/DLList/DLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -48,7 +48,6 @@ int main(int argc, char *argv[]) } myList.append(100.3); - myList.append(500.3); Info<< nl << "And again using STL iterator: " << nl << endl; @@ -120,7 +119,18 @@ int main(int argc, char *argv[]) Info<< "element:" << *iter << endl; } - Info<< nl << "Bye." << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + DLList<scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + + + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/Dictionary/DictionaryTest.C b/applications/test/Dictionary/DictionaryTest.C index ade39072642b83f14e516106797c059676e0ff4f..9bbd32d4fdd2868e60850703ab05320fc9e0268b 100644 --- a/applications/test/Dictionary/DictionaryTest.C +++ b/applications/test/Dictionary/DictionaryTest.C @@ -23,15 +23,18 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ #include "OSspecific.H" +#include "scalar.H" + #include "IOstreams.H" #include "Dictionary.H" +#include "PtrDictionary.H" using namespace Foam; @@ -63,6 +66,36 @@ public: }; +class Scalar +{ + scalar data_; + +public: + + Scalar() + : + data_(0) + {} + + Scalar(scalar val) + : + data_(val) + {} + + ~Scalar() + { + Info <<"delete Scalar: " << data_ << endl; + } + + friend Ostream& operator<<(Ostream& os, const Scalar& val) + { + os << val.data_; + return os; + } +}; + + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -92,12 +125,11 @@ int main(int argc, char *argv[]) Info<< "element : " << *iter; } - Info<< dict.toc() << endl; + Info<< "keys: " << dict.toc() << endl; delete dictPtr; - dictPtr = new Dictionary<ent>; - Dictionary<ent>& dict2 = *dictPtr; + Dictionary<ent> dict2; for (int i = 0; i<10; i++) { @@ -106,9 +138,79 @@ int main(int argc, char *argv[]) dict2.swapUp(ePtr); } - Info<< dict2 << endl; + Info<< "dict:\n" << dict2 << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << dict2 << endl; + + Dictionary<ent> newDict; + newDict.transfer(dict2); + + Info<< nl << "source: " << dict2 << nl + << "keys: " << dict2.toc() << nl + << "target: " << newDict << nl + << "keys: " << newDict.toc() << endl; + + + PtrDictionary<Scalar> scalarDict; + for (int i = 0; i<10; i++) + { + word key("ent" + name(i)); + scalarDict.insert(key, new Scalar(1.3*i)); + } + + Info<< nl << "scalarDict1: " << endl; + for + ( + PtrDictionary<Scalar>::const_iterator iter = scalarDict.begin(); + iter != scalarDict.end(); + ++iter + ) + { + Info<< " = " << iter() << endl; + } + + PtrDictionary<Scalar> scalarDict2; + for (int i = 8; i<15; i++) + { + word key("ent" + name(i)); + scalarDict2.insert(key, new Scalar(1.3*i)); + } + Info<< nl << "scalarDict2: " << endl; + for + ( + PtrDictionary<Scalar>::const_iterator iter = scalarDict2.begin(); + iter != scalarDict2.end(); + ++iter + ) + { + Info<< "elem = " << *iter << endl; + } + + scalarDict.transfer(scalarDict2); + + + Scalar* p = scalarDict.lookupPtr("ent8"); + + // This does not (yet) work + // Scalar* q = scalarDict.remove("ent10"); + + if (p) + { + Info << "found: " << *p << endl; + } + else + { + Info << "no p: " << endl; + } + + scalarDict.clear(); + + // Info<< " = " << *iter << endl; + + - Info<< nl << "Bye." << endl; + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/ISLList/ISLListTest.C b/applications/test/ISLList/ISLListTest.C index 60590d1eafc26468d19167b0e4792ca271381a3c..f33f811c1a4bfa3b705ddacbfef0d734d0771326 100644 --- a/applications/test/ISLList/ISLListTest.C +++ b/applications/test/ISLList/ISLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -52,6 +52,13 @@ public: : data_(s) {} + + friend Ostream& operator<<(Ostream& os, const Scalar& s) + { + os << s.data_; + return os; + } + }; @@ -68,10 +75,8 @@ int main(int argc, char *argv[]) } myList.append(new Scalar(100.3)); - myList.append(new Scalar(500.3)); - Info<< nl << "And again using STL iterator: " << nl << endl; for @@ -99,6 +104,15 @@ int main(int argc, char *argv[]) } + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + ISLList<Scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + Info<< nl << "Bye." << endl; return 0; } diff --git a/applications/test/NamedEnum/Make/files b/applications/test/NamedEnum/Make/files index a06d4ba5a9d9605dcaf133706ec8e7ff5d9003d4..a6601226facc6495efcb7f0c1db09e18346489e6 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 0000000000000000000000000000000000000000..4bfd49bde04e8d290f2aa7041966dfc8b3dc6c04 --- /dev/null +++ b/applications/test/PtrList/Make/files @@ -0,0 +1,3 @@ +PtrListTest.C + +EXE = $(FOAM_USER_APPBIN)/PtrListTest diff --git a/applications/test/hmm/Make/options b/applications/test/PtrList/Make/options similarity index 100% rename from applications/test/hmm/Make/options rename to applications/test/PtrList/Make/options diff --git a/applications/test/PtrList/PtrListTest.C b/applications/test/PtrList/PtrListTest.C new file mode 100644 index 0000000000000000000000000000000000000000..8de64a9d3cdfb6a7f2250a7059caacd0c40350f6 --- /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<Scalar> list1(10); + PtrList<Scalar> list2(15); + + forAll(list1, i) + { + list1.set(i, new Scalar(1.3*i)); + } + + forAll(list2, i) + { + list2.set(i, new Scalar(10 + 1.3*i)); + } + + + Info<<"list1: " << list1 << endl; + Info<<"list2: " << list2 << endl; + + Info<<"indirectly delete some items via set(.., 0) :" << endl; + for (label i = 0; i < 3; i++) + { + list1.set(i, 0); + } + + Info<<"transfer list2 -> list1:" << endl; + list1.transfer(list2); + + Info<<"list1: " << list1 << endl; + Info<<"list2: " << list2 << endl; + + Info<<"indirectly delete some items via setSize :" << endl; + list1.setSize(4); + + Info<<"list1: " << list1 << endl; + + Info<< nl << "Done." << endl; + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/SLList/SLListTest.C b/applications/test/SLList/SLListTest.C index 3bd9af2b6723a72d8be0f25c1ac76427ecda5977..f55f7b4edf58f533e5f1c242b08bfbbb79beef73 100644 --- a/applications/test/SLList/SLListTest.C +++ b/applications/test/SLList/SLListTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -48,10 +48,8 @@ int main(int argc, char *argv[]) } myList.append(100.3); - myList.append(500.3); - Info<< nl << "And again using STL iterator: " << nl << endl; for @@ -99,7 +97,27 @@ int main(int argc, char *argv[]) Info<< "element:" << *iter2 << endl; } - Info<< nl << "Bye." << endl; + + + for (int i = 0; i<10; i++) + { + myList.append(1.3*i); + } + + myList.append(100.3); + myList.append(500.3); + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << myList << endl; + + SLList<scalar> newList; + newList.transfer(myList); + + Info<< nl << "source: " << myList << nl + << nl << "target: " << newList << endl; + + + Info<< nl << "Done." << endl; return 0; } diff --git a/applications/test/UDictionary/UDictionaryTest.C b/applications/test/UDictionary/UDictionaryTest.C index 5caea16dad9e959c73d5c7911b938a300df9f8ec..247fc98cbb6b0d20e0c8111881d21606631fad2a 100644 --- a/applications/test/UDictionary/UDictionaryTest.C +++ b/applications/test/UDictionary/UDictionaryTest.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Application - + Description \*---------------------------------------------------------------------------*/ @@ -113,7 +113,20 @@ int main(int argc, char *argv[]) Info<< dict2 << endl; - Info<< nl << "Bye." << endl; + + Info<< nl << "Testing transfer: " << nl << endl; + Info<< "original: " << dict2 << endl; + + UDictionary<ent> newDict; + newDict.transfer(dict2); + + Info<< nl << "source: " << dict2 << nl + << "keys: " << dict2.toc() << nl + << "target: " << newDict << nl + << "keys: " << newDict.toc() << endl; + + Info<< nl << "Done." << endl; + return 0; } diff --git a/applications/test/callback/Make/files b/applications/test/callback/Make/files index 788abb0467427770c15b8416095f0da4e623d918..bd1eab1e8ab1fbd14f99a331a83c9362fdb5d9a8 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 abbd55d3499c65db8c68b8211adf2f94cb93eb67..b32b5bd950a51cac38293e25b1349978d5371d2e 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 37ae9bd90c56ed11d58ee79c3734f5bb74d289be..558ec7fec68d34878e0b4b7a09574aa02acd5f5f 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; - { - dictionary someDict; - someDict.add(keyType("a.*", true), "subdictValue"); + IOobject::writeDivider(Info); - dictionary dict; - dict.add("someDict", someDict); - dict.add(keyType(".*", true), "parentValue"); + { + dictionary dict(IFstream("testDictRegex")()); + dict.add(keyType("fooba[rz]", true), "anything"); - Info<< "dict:" << dict << endl; + Info<< "dict:" << dict << nl + << "toc: " << dict.toc() << nl + << "keys: " << dict.keys() << nl + << "patterns: " << dict.keys(true) << endl; - // Wildcard find. - Info<< "Wildcard find \"abc\" in top directory : " + Info<< "Pattern find \"abc\" in top directory : " << dict.lookup("abc") << endl; - Info<< "Wildcard find \"abc\" in sub directory : " + Info<< "Pattern find \"abc\" in sub directory : " << dict.subDict("someDict").lookup("abc") << endl; - Info<< "Recursive wildcard find \"def\" in sub directory : " + Info<< "Recursive pattern find \"def\" in sub directory : " << dict.subDict("someDict").lookup("def", true) << endl; + Info<< "Recursive 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 0000000000000000000000000000000000000000..01d4274ba8dad8147a4b62e254317b0ae1cd7f38 --- /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 99642333c6117d786b85832ed8d403fe62f6e992..c3a36f49e1a35156c14185287a5285bc40dc6c08 100644 --- a/applications/test/fileName/fileNameTest.C +++ b/applications/test/fileName/fileNameTest.C @@ -32,6 +32,7 @@ Description #include "fileName.H" #include "IOstreams.H" +#include "OSspecific.H" using namespace Foam; @@ -57,7 +58,16 @@ int main() Info<< "pathName.components() = " << pathName.components() << endl; Info<< "pathName.component(2) = " << pathName.component(2) << endl; - Info<< "end" << endl; + + // test findEtcFile + Info<< "\n\nfindEtcFile tests:" << nl + << " controlDict => " << findEtcFile("controlDict") << nl + << " badName => " << findEtcFile("badName") << endl; + Info<< "This should emit a fatal error:" << endl; + Info<< " badName(die) => " << findEtcFile("badName", true) << nl + << endl; + + Info<< "\nEnd" << endl; return 0; } diff --git a/applications/test/findTimes/findTimes.C b/applications/test/findTimes/findTimes.C index db22507b4f0511facbc3a5860714275104bcfac3..2acc6e756c54e0eee38df49eb6ff9d62004744cb 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 01385a77312922d0dc59e319abc7c8e38d8f25cf..0000000000000000000000000000000000000000 --- a/applications/test/getRoots/Make/files +++ /dev/null @@ -1,2 +0,0 @@ -getRoots.C -EXE = $(FOAM_USER_APPBIN)/getRoots diff --git a/applications/test/getRoots/Make/options b/applications/test/getRoots/Make/options deleted file mode 100644 index 4e772fdf9d7bc94221d127458f9d2ca32850fe69..0000000000000000000000000000000000000000 --- a/applications/test/getRoots/Make/options +++ /dev/null @@ -1,2 +0,0 @@ -/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */ -/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/getRoots/getRoots.C b/applications/test/getRoots/getRoots.C deleted file mode 100644 index 2cc985b1697d890aa135679c7b856f3e3d1a0a92..0000000000000000000000000000000000000000 --- a/applications/test/getRoots/getRoots.C +++ /dev/null @@ -1,30 +0,0 @@ -#include "dictionary.H" -#include "fileNameList.H" -#include "IFstream.H" -#include "OSspecific.H" - -using namespace Foam; - -int main() -{ - Info << "\nReading Roots" << endl; - - IFstream rootsFile(home()/".foam/apps/openDX/roots"); - fileNameList rootsList(dictionary(rootsFile).lookup("roots")); - - char** rootsStrings = new char*[rootsList.size() + 1]; - rootsStrings[rootsList.size()] = 0; - - if (rootsList.size()) - { - for (int i=0; i<rootsList.size(); i++) - { - rootsStrings[i] = new char[rootsList[i].size() + 1]; - strcpy(rootsStrings[i], rootsList[i].c_str()); - - Info<< rootsStrings[i] << endl; - } - } - - return 0; -} diff --git a/applications/test/hmm/Make/files b/applications/test/hmm/Make/files deleted file mode 100644 index 759804fcfa6cf2737cd9599f8aeba508687cf353..0000000000000000000000000000000000000000 --- a/applications/test/hmm/Make/files +++ /dev/null @@ -1,4 +0,0 @@ -calcEntry/calcEntry.C -dictionaryTest.C - -EXE = $(FOAM_USER_APPBIN)/dictionaryTest diff --git a/applications/test/hmm/testDict b/applications/test/hmm/testDict deleted file mode 100644 index 70f6885e7ef345028a910a08c2691d2e7d6a6a82..0000000000000000000000000000000000000000 --- a/applications/test/hmm/testDict +++ /dev/null @@ -1,55 +0,0 @@ -FoamFile -{ - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object testDict; -} - - -dimensions [ 0 2 -2 0 0 0 0 ]; -internalField uniform 1; - -active -{ - type turbulentIntensityKineticEnergyInlet; - intensity 0.1; - value $internalField; -} - - -inactive -{ - type zeroGradient; -} - - -boundaryField -{ - Default_Boundary_Region - { - type zeroGradient; - } - - inlet_1 { $active } - inlet_2 { $inactive } - inlet_3 { $inactive } - - #include "testDictInc" - - outlet - { - type inletOutlet; - inletValue $internalField; - value #include "value"; - x 5; - y 6; - another #calc{x $x; y $y;}; - } -} diff --git a/applications/test/hmm/testDictInc b/applications/test/hmm/testDictInc deleted file mode 100644 index a0814c18339e71c5c438eea2985d2f149e25dc63..0000000000000000000000000000000000000000 --- a/applications/test/hmm/testDictInc +++ /dev/null @@ -1,6 +0,0 @@ - inlet_4 - { - type inletOutlet; - inletValue $internalField; - value $internalField; - } diff --git a/applications/test/hmm/value b/applications/test/hmm/value deleted file mode 100644 index 196f9d3d0a639b5120ba76846b0612094b137245..0000000000000000000000000000000000000000 --- a/applications/test/hmm/value +++ /dev/null @@ -1 +0,0 @@ -uniform 2 diff --git a/applications/test/regex/Make/files b/applications/test/regex/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..901da54f0744fcd30dc7985f398d8831fb6e750f --- /dev/null +++ b/applications/test/regex/Make/files @@ -0,0 +1,3 @@ +regexTest.C + +EXE = $(FOAM_USER_APPBIN)/regexTest diff --git a/src/OpenFOAM/global/global.C b/applications/test/regex/Make/options similarity index 100% rename from src/OpenFOAM/global/global.C rename to applications/test/regex/Make/options diff --git a/applications/test/regex/regexTest.C b/applications/test/regex/regexTest.C new file mode 100644 index 0000000000000000000000000000000000000000..0463891dc1ef24d4914fa0bb285b03ef4ff200a1 --- /dev/null +++ b/applications/test/regex/regexTest.C @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + +\*---------------------------------------------------------------------------*/ + +#include "IOstreams.H" +#include "IOobject.H" +#include "IFstream.H" +#include "regExp.H" +#include "List.H" +#include "Tuple2.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + + List<Tuple2<string, string> > rawList(IFstream("testRegexps")()); + Info<< "input list:" << rawList << endl; + IOobject::writeDivider(Info); + Info<< endl; + + List<string> 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 0000000000000000000000000000000000000000..eeae1d865a7006f03a0543e4aece11fe69ee4933 --- /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 968f45b9361a9cb0d449e93217d2aff0a6468e7b..1f2bc56c44a8cb4e7c8a24e92f151cb1076fa637 100644 --- a/applications/test/router/Gather/Gather.C +++ b/applications/test/router/Gather/Gather.C @@ -59,23 +59,24 @@ Gather<T0>::Gather(const T0& localData, const bool redistribute) // Receive data for ( - int slave=Pstream::firstSlave(), procIndex = 1; - slave<=Pstream::lastSlave(); + int slave = Pstream::firstSlave(), procIndex = 1; + slave <= Pstream::lastSlave(); slave++, procIndex++ ) { - IPstream fromSlave(slave); + IPstream fromSlave(Pstream::scheduled, slave); fromSlave >> this->operator[](procIndex); } + // Send data for ( - int slave=Pstream::firstSlave(), procIndex = 1; - slave<=Pstream::lastSlave(); + int slave = Pstream::firstSlave(), procIndex = 1; + slave <= Pstream::lastSlave(); slave++, procIndex++ ) { - OPstream toSlave(slave); + OPstream toSlave(Pstream::scheduled, slave); if (redistribute) { @@ -92,12 +93,13 @@ Gather<T0>::Gather(const T0& localData, const bool redistribute) { // Slave: send my local data to master { - OPstream toMaster(Pstream::masterNo()); + OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); toMaster << localData; } + // Receive data from master { - IPstream fromMaster(Pstream::masterNo()); + IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); if (redistribute) { fromMaster >> *this; diff --git a/applications/test/stringList/stringListTest.C b/applications/test/stringList/stringListTest.C index 045ca1fe72afa2697c524cc2a754943355c57e38..2c7da0d5e9d2d6f21ab8b7be610d91a06684c43e 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 92414c039e1c4213fb72884b447ca821d7a1ec08..d3c1cd8ac2d9e9ca3068acd88f5d079a2bcd82ac 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 f290e7fa42d0e609a3730f9e85db9589108b9c93..f9337bad0e863d08691b255ef86d5dbba05689db 100644 --- a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C +++ b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C @@ -289,9 +289,7 @@ int main(int argc, char *argv[]) << patchNames[patchI] << "\t\t" << allPatchFaces[patchI].size() << endl; - allPatchFaces[patchI].shrink(); patchFaces[patchI].transfer(allPatchFaces[patchI]); - allPatchFaces[patchI].clear(); } Info<< endl; diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C index e99bca0af1db9e80bc4bc06afb5d5cbd2e3b054e..cf9d5e82379e15897b4ecd6985875462c6bd7cef 100644 --- a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C +++ b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C @@ -461,7 +461,7 @@ int main(int argc, char *argv[]) } } - + // Trim boundaryFaces.setSize(faceI); boundaryPatch.setSize(faceI); @@ -515,7 +515,7 @@ int main(int argc, char *argv[]) Info<< " " << patchNames[patchI] << " : " << allPatchFaces[patchI].size() << endl; - patchFaces[patchI].transfer(allPatchFaces[patchI].shrink()); + patchFaces[patchI].transfer(allPatchFaces[patchI]); } Info<< endl; @@ -548,7 +548,6 @@ int main(int argc, char *argv[]) meshPtr().write(); - Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 5777ae8a8a3680e6b502ba363731541fba9d1074..43d550f4068b72c6967430b49c0c63ac1516bc99 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 50818f4db9cdd78a60b23d6b4c2626d023b26018..3b5fca211ee43676feb69539dbbc058bb2f6f3c4 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 c8a7d89df2dafdcedcde44f7a982d6bfd5aaac1a..05501a904d7e545572ebbb7d03ad69d8cce98b39 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 01d4f5a9fe0031eb8b03760bcb3cb294de083c82..17be614da4d2e9db4390f247b195c4f92f351bd9 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt @@ -7,6 +7,8 @@ # the pqReader.xml file contains xml defining readers with their # file extensions and descriptions. +cmake_minimum_required(VERSION 2.4) + FIND_PACKAGE(ParaView REQUIRED) INCLUDE(${PARAVIEW_USE_FILE}) diff --git a/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.C b/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.C index d7db62e441c93b1fbb3bca9fb550f01cba246b2a..898f3572e0af5c62992d296e45599359b36edd94 100644 --- a/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.C +++ b/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.C @@ -74,10 +74,7 @@ void Foam::readerDatabase::getPolyHedra() } } - polys.shrink(); - Info<< "Found " << polys.size() << " polyhedral cells " << endl; - polys_.transfer(polys); } diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files b/applications/utilities/preProcessing/foamUpgradeFvSolution/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..f667ed655e635c2c19b58d0c8adde570766b9e96 --- /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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C b/applications/utilities/preProcessing/foamUpgradeFvSolution/foamUpgradeFvSolution.C new file mode 100644 index 0000000000000000000000000000000000000000..9128ad3d5c303e07c834288647538c0ac3775e14 --- /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 3d494b6cc0315b35633d3ea3a447a67426e0a8b7..be274ec4ce8da98eb3a6af1cfca2678c8a189864 100644 --- a/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C +++ b/applications/utilities/thermophysical/adiabaticFlameT/adiabaticFlameT.C @@ -78,7 +78,7 @@ int main(int argc, char *argv[]) Info<< nl << "Reading Burcat data dictionary" << endl; - fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); + fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData")); // Construct control dictionary IFstream BurcatCpDataFile(BurcatCpDataFileName); diff --git a/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C b/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C index 56767eecb3e95504d3c0c327bfc817ebf86572ec..444570046ae0d41578a5b0026aa20ac1ebaf7bca 100644 --- a/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C +++ b/applications/utilities/thermophysical/equilibriumFlameT/equilibriumFlameT.C @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) Info<< nl << "Reading Burcat data dictionary" << endl; - fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); + fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData")); // Construct control dictionary IFstream BurcatCpDataFile(BurcatCpDataFileName); diff --git a/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C b/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C index c3ee5e81fda16b78c7d7b00d3133e8634415e906..392c2e062fd7e474e8ca64d33e0feb01acc7f3f6 100644 --- a/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C +++ b/applications/utilities/thermophysical/mixtureAdiabaticFlameT/mixtureAdiabaticFlameT.C @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) Info<< nl << "Reading Burcat data dictionary" << endl; - fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData")); + fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData")); // Construct control dictionary IFstream BurcatCpDataFile(BurcatCpDataFileName); diff --git a/bin/buildParaView3.3-cvs-python b/bin/buildParaView3.3-cvs-python deleted file mode 120000 index db5ce4641b139ff974bcef01ee90a13c71a117d6..0000000000000000000000000000000000000000 --- a/bin/buildParaView3.3-cvs-python +++ /dev/null @@ -1 +0,0 @@ -buildParaView3.3-cvs \ No newline at end of file diff --git a/bin/buildParaView3.5-cvs b/bin/buildParaView3.5-cvs new file mode 100755 index 0000000000000000000000000000000000000000..707287a981873b253e26911f116fb0639fc70d53 --- /dev/null +++ b/bin/buildParaView3.5-cvs @@ -0,0 +1,192 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# Script +# buildParaView3.5-cvs +# +# Description +# Build and install ParaView +# - run from folder above ParaView source folder or place the +# ParaView source under $WM_THIRD_PARTY_DIR +# +#------------------------------------------------------------------------------ +. $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions + +PARAVIEW_SRC=paraview-3.5-cvs +PARAVIEW_MAJOR_VERSION=3.5 + +# User options: +# ~~~~~~~~~~~~~ + +# MPI support: +WITH_MPI=OFF +MPI_MAX_PROCS=32 + +# Python support: +# note: script will try to determine the appropriate python library. +# If it fails, specify the path using the PYTHON_LIBRARY variable +WITH_PYTHON=OFF +PYTHON_LIBRARY="" +# PYTHON_LIBRARY="/usr/lib64/libpython2.5.so.1.0" + +# MESA graphics support: +WITH_MESA=OFF + +# +# No further editing below this line +#------------------------------------------------------------------------------ +Script=${0##*/} + +usage() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE + +usage: ${0##*/} [OPTION] +options: + -fast for repeated builds (-make -install) *use with caution* + -mpi with mpi (if not already enabled) + -python with python (if not already enabled) + -mesa with mesa (if not already enabled) + -verbose verbose output in Makefiles + -help + +For finer control, the build stages can be also selected individually +(mutually exclusive) + -config + -make + -makedoc + -install + [-envpath] alter absolute paths in CMake files to use env variables + +Build and install $PARAVIEW_SRC + - run from folder above the ParaView source folder or place the + ParaView source under \$WM_THIRD_PARTY_DIR + +USAGE + exit 1 +} + +# add options based on script name: +case "$Script" in *-mpi*) WITH_MPI=ON;; esac +case "$Script" in *-python*) WITH_PYTHON=ON;; esac +case "$Script" in *-mesa*) WITH_MESA=ON;; esac + +runCONFIG=true +runMAKE=true +runMAKEDOC=true +runINSTALL=true +runENVPATH=false + +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -config) # stage 1: config only + runCONFIG=true + runMAKE=false + runMAKEDOC=false + runINSTALL=false + shift + ;; + -make) # stage 2: make only + runCONFIG=false + runMAKE=true + runMAKEDOC=false + runINSTALL=false + shift + ;; + -makedoc) # stage 3: generate html documentation + runCONFIG=false + runMAKE=false + runMAKEDOC=true + runINSTALL=false + shift + ;; + -install) # stage 4: install only + runCONFIG=false + runMAKE=false + runMAKEDOC=false + runINSTALL=true + shift + ;; + -envpath) # optional: change cmake files to use env variables + runCONFIG=false + runMAKE=false + runMAKEDOC=false + runINSTALL=false + runENVPATH=true + shift + ;; + -fast) # shortcut for rebuild + runCONFIG=false + runMAKE=true + runMAKEDOC=false + runINSTALL=true + shift + ;; + -mpi) + WITH_MPI=ON + shift + ;; + -python) + WITH_PYTHON=ON + shift + ;; + -mesa) + WITH_MESA=ON + shift + ;; + -verbose) + VERBOSE=ON + shift + ;; + *) + usage "unknown option/argument: '$*'" + ;; + esac +done + +# Set configure options +#~~~~~~~~~~~~~~~~~~~~~~ +addVerbosity # verbose makefiles +addMpiSupport # set MPI-specific options +addPythonSupport # set Python-specific options +addMesaSupport # set MESA-specific options + +getPaths # discover where things are or should be put + +# Build and install +# ~~~~~~~~~~~~~~~~~ +[ $runCONFIG = true ] && configParaView +[ $runMAKE = true ] && makeParaView +[ $runMAKEDOC = true ] && makeDocs +[ $runINSTALL = true ] && installParaView +[ $runENVPATH = true ] && fixCMakeFiles + +echo "done" +#------------------------------------------------------------------------------ diff --git a/bin/buildParaView3.5-cvs-python b/bin/buildParaView3.5-cvs-python new file mode 120000 index 0000000000000000000000000000000000000000..d3ed3924a892abffc145149dd53de0b9819d6272 --- /dev/null +++ b/bin/buildParaView3.5-cvs-python @@ -0,0 +1 @@ +buildParaView3.5-cvs \ No newline at end of file diff --git a/bin/foamUpdateCaseFileHeader b/bin/foamUpdateCaseFileHeader index f4340fc53c7957cb2a60a9806b44b24dac7da713..311cb21e8238471db0205051c3acc083fbfeb0d3 100755 --- a/bin/foamUpdateCaseFileHeader +++ b/bin/foamUpdateCaseFileHeader @@ -45,8 +45,8 @@ options: -h help Updates the header of application files and removes consecutive blank lines. - By default, writes current version in the header. - An alternative version can be specified with -v option. + By default, writes current OpenFOAM version in the header. + An alternative version can be specified with the -v option. USAGE exit 1 @@ -59,8 +59,8 @@ printHeader() { | ========= | | | \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\\\ / O peration | Version: ${foamVersion} | -| \\\\ / A nd | Web: http://www.OpenFOAM.org | -| \\\\/ M anipulation | | +| \\\\ / A nd | | +| \\\\/ M anipulation | www.OpenFOAM.org | \\*---------------------------------------------------------------------------*/ FoamFile { @@ -84,13 +84,13 @@ FoamFileAttribute() { # # OPTIONS # -OPTS=`getopt hv: $*` +opts=$(getopt hv: $*) if [ $? -ne 0 ] then echo "Aborting due to invalid option" usage fi -eval set -- '$OPTS' +eval set -- '$opts' while [ "$1" != "--" ] do case $1 in @@ -110,11 +110,13 @@ shift # constant width for version -foamVersion=`printf %-36s $foamVersion` +foamVersion=$(printf %-36s $foamVersion) # # MAIN # +unset NOTE + for caseFile do if grep FoamFile $caseFile >/dev/null 2>&1 @@ -122,16 +124,17 @@ do echo "Updating case file: $caseFile" sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp - CLASS=`FoamFileAttribute class FoamFile.tmp` - OBJECT=`FoamFileAttribute object FoamFile.tmp` - FORMAT=`FoamFileAttribute format FoamFile.tmp` + FORMAT=$(FoamFileAttribute format FoamFile.tmp) + CLASS=$(FoamFileAttribute class FoamFile.tmp) + OBJECT=$(FoamFileAttribute object FoamFile.tmp) + # extract NOTE? printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp # use cat to avoid removing/replace soft-links [ -s FoamFile.tmp ] && cat FoamFile.tmp >| $caseFile - rm FoamFile.tmp + rm -f FoamFile.tmp 2>/dev/null else echo " Invalid case file: $caseFile" 1>&2 fi diff --git a/bin/paraFoam b/bin/paraFoam index 101bba1674e1867ee9ddad85f2acbef9b7cc34bc..4fc5c3cb9fdf8fe65ed74711f79e2816c8cd3532 100755 --- a/bin/paraFoam +++ b/bin/paraFoam @@ -31,19 +31,19 @@ # #------------------------------------------------------------------------------ usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<<USAGE + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE usage: ${0##*/} [OPTION] options: -case dir specify alternative case directory -region name specify mesh region name - -touch create the .OpenFOAM file only and exit + -touch only create the .OpenFOAM file * start paraview $ParaView_VERSION with the OpenFOAM libraries USAGE - exit 1 + exit 1 } unset regionName touchOnly @@ -51,81 +51,83 @@ unset regionName touchOnly # parse options while [ "$#" -gt 0 ] do - case "$1" in - -h | -help) - usage - ;; - -case) - [ "$#" -ge 2 ] || usage "'-case' option requires an argument" - caseDir=$2 - shift 2 - cd "$caseDir" 2>/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'" - } - - paraview --data="$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" + ;; esac #------------------------------------------------------------------------------ diff --git a/bin/tools/README b/bin/tools/README index c99723b20e19efb63e6e9dff7a312d9885a55edb..2b98a9702f3ad030ab7fb44f8075142abe3daa1b 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 1f95596f3c56c6e1d9cf87b3b28efce845109719..87b993d539c9f5f95cf7d53c076a9f9f0b789154 100755 --- a/bin/buildParaView3.3-cvs +++ b/bin/tools/buildParaView3.4 @@ -34,8 +34,8 @@ #------------------------------------------------------------------------------ . $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions -PARAVIEW_SRC="ParaView3.3-cvs" -PARAVIEW_MAJOR_VERSION="3.3" +PARAVIEW_SRC=paraview-3.4 +PARAVIEW_MAJOR_VERSION=3.4 # User options: # ~~~~~~~~~~~~~ @@ -45,7 +45,7 @@ WITH_MPI=OFF MPI_MAX_PROCS=32 # Python support: -# note: script will try to determine python library. +# note: script will try to determine the appropriate python library. # If it fails, specify the path using the PYTHON_LIBRARY variable WITH_PYTHON=OFF PYTHON_LIBRARY="" @@ -60,18 +60,26 @@ WITH_MESA=OFF Script=${0##*/} usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<<USAGE + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE usage: ${0##*/} [OPTION] options: - -fast skip cmake for repeated builds - use with caution + -fast for repeated builds (-make -install) *use with caution* -mpi with mpi (if not already enabled) -python with python (if not already enabled) -mesa with mesa (if not already enabled) - -verbose verbose cmake output + -verbose verbose output in Makefiles -help +For finer control, the build stages can be also selected individually +(mutually exclusive) + -config + -make + -makedoc + -install + [-envpath] alter absolute paths in CMake files to use env variables + Build and install $PARAVIEW_SRC - run from folder above the ParaView source folder or place the ParaView source under \$WM_THIRD_PARTY_DIR @@ -80,57 +88,105 @@ USAGE exit 1 } -# options based on the script name: -case "$Script" in *-fast*) CMAKE_SKIP=ON;; esac +# add options based on script name: case "$Script" in *-mpi*) WITH_MPI=ON;; esac case "$Script" in *-python*) WITH_PYTHON=ON;; esac case "$Script" in *-mesa*) WITH_MESA=ON;; esac +runCONFIG=true +runMAKE=true +runMAKEDOC=true +runINSTALL=true +runENVPATH=false + # parse options while [ "$#" -gt 0 ] do - case "$1" in - -h | -help) - usage - ;; - -fast) - CMAKE_SKIP=YES - shift - ;; - -mpi) - WITH_MPI=ON - shift - ;; - -python) - WITH_PYTHON=ON - shift - ;; - -mesa) - WITH_MESA=ON - shift - ;; - -verbose) - VERBOSE=ON - shift - ;; - *) - usage "unknown option/argument: '$*'" - ;; - esac + case "$1" in + -h | -help) + usage + ;; + -config) # stage 1: config only + runCONFIG=true + runMAKE=false + runMAKEDOC=false + runINSTALL=false + shift + ;; + -make) # stage 2: make only + runCONFIG=false + runMAKE=true + runMAKEDOC=false + runINSTALL=false + shift + ;; + -makedoc) # stage 3: generate html documentation + runCONFIG=false + runMAKE=false + runMAKEDOC=true + runINSTALL=false + shift + ;; + -install) # stage 4: install only + runCONFIG=false + runMAKE=false + runMAKEDOC=false + runINSTALL=true + shift + ;; + -envpath) # optional: change cmake files to use env variables + runCONFIG=false + runMAKE=false + runMAKEDOC=false + runINSTALL=false + runENVPATH=true + shift + ;; + -fast) # shortcut for rebuild + runCONFIG=false + runMAKE=true + runMAKEDOC=false + runINSTALL=true + shift + ;; + -mpi) + WITH_MPI=ON + shift + ;; + -python) + WITH_PYTHON=ON + shift + ;; + -mesa) + WITH_MESA=ON + shift + ;; + -verbose) + VERBOSE=ON + shift + ;; + *) + usage "unknown option/argument: '$*'" + ;; + esac done # Set configure options #~~~~~~~~~~~~~~~~~~~~~~ -addVerbosity # set CMake verbosity +addVerbosity # verbose makefiles addMpiSupport # set MPI-specific options addPythonSupport # set Python-specific options addMesaSupport # set MESA-specific options +getPaths # discover where things are or should be put + # Build and install # ~~~~~~~~~~~~~~~~~ -buildParaView -installParaView +[ $runCONFIG = true ] && configParaView +[ $runMAKE = true ] && makeParaView +[ $runENVPATH = true ] && fixCMakeFiles +[ $runMAKEDOC = true ] && makeDocs +[ $runINSTALL = true ] && installParaView echo "done" - #------------------------------------------------------------------------------ diff --git a/bin/tools/buildParaViewFunctions b/bin/tools/buildParaViewFunctions index ef5a25923a0ab4d605cd2d4ab40a1720b23e0580..e3662ac19f62a001c97766a6b7436325c1baa4e8 100644 --- a/bin/tools/buildParaViewFunctions +++ b/bin/tools/buildParaViewFunctions @@ -31,299 +31,366 @@ #------------------------------------------------------------------------------ # ParaView_INST_DIR : location of the original sources -# ParaView_DIR : location of the compiled output +# ParaView_DIR : location of the build (for the ParaViewConfig.cmake) +# and the installed program + +# +# set CMake cache variables +# addCMakeVariable() { - while [ -n "$1" ] - do - CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1" - shift - done + while [ -n "$1" ] + do + CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1" + shift + done } +# +# verbose makefiles +# addVerbosity() { - [ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE + [ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE } +# +# define options for mpi support +# addMpiSupport() { - [ "$WITH_MPI" = ON ] || return - OBJ_ADD="$OBJ_ADD-mpi" - - addCMakeVariable PARAVIEW_USE_MPI=ON - addCMakeVariable VTK_USE_MPI=ON - addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include - addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so - addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun - addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS + [ "$WITH_MPI" = ON ] || return + OBJ_ADD="$OBJ_ADD-mpi" + + addCMakeVariable PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON + addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include + addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so + addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun + addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS } +# +# define options for python support +# addPythonSupport() { - [ "$WITH_PYTHON" = ON ] || return - OBJ_ADD="$OBJ_ADD-py" - - if pythonBin=$(which python 2>/dev/null) - then - if [ -n "$PYTHON_LIBRARY" ] - then - # check $PYTHON_LIBRARY if it has been set - if [ ! -e "$PYTHON_LIBRARY" ] - then - echo "*** Error: libpython not found at location specified " \ - "by PYTHON_LIBRARY=$PYTHON_LIBRARY" - fi - else - # Try to get $PYTHON_LIBRARY from dynamically linked binary - PYTHON_LIBRARY=$(ldd $pythonBin | \ - sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p') - - if [ ! -e "$PYTHON_LIBRARY" ] - then - echo "*** Error: Unable to determine path to python library." - fi - fi - - [ -e "$PYTHON_LIBRARY" ] || { - echo " Please set the variable PYTHON_LIBRARY to the full" - echo " path to (and including) libpython, or deactivate" - echo " python support by setting WITH_PYTHON=OFF" - exit 1 - } - - pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/') - pythonInclude=/usr/include/python$pythonMajor - - [ -e "$PYTHON_LIBRARY" ] || { - echo " Please set the variable PYTHON_LIBRARY to the full" - echo " path to (and including) libpython, or deactivate" - echo " python support by setting WITH_PYTHON=OFF" - exit 1 - } - - # note - we could also allow for a PYTHON_INCLUDE variable ... - [ -e "$pythonInclude" ] || { - echo " No python include headers found" - echo " Please install python headers or deactivate " - echo " python support by setting WITH_PYTHON=OFF" - exit 1 - } - - addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON - addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude - addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY - - echo "----" - echo "Python information:" - echo " executable : $pythonBin" - echo " version : $pythonMajor" - echo " include path : $pythonInclude" - echo " library : $PYTHON_LIBRARY" - - unset pythonBin pythonInclude pythonMajor - else - echo "*** Error: python not installed" - echo "*** Deactivate python support by setting WITH_PYTHON=OFF" - exit 1 - fi + [ "$WITH_PYTHON" = ON ] || return + OBJ_ADD="$OBJ_ADD-py" + + if pythonBin=$(which python 2>/dev/null) + then + if [ -n "$PYTHON_LIBRARY" ] + then + # check $PYTHON_LIBRARY if it has been set + if [ ! -e "$PYTHON_LIBRARY" ] + then + echo "*** Error: libpython not found at location specified " \ + "by PYTHON_LIBRARY=$PYTHON_LIBRARY" + fi + else + # Try to get $PYTHON_LIBRARY from dynamically linked binary + PYTHON_LIBRARY=$(ldd $pythonBin | \ + sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p') + + if [ ! -e "$PYTHON_LIBRARY" ] + then + echo "*** Error: Unable to determine path to python library." + fi + fi + + [ -e "$PYTHON_LIBRARY" ] || { + echo " Please set the variable PYTHON_LIBRARY to the full" + echo " path to (and including) libpython, or deactivate" + echo " python support by setting WITH_PYTHON=OFF" + exit 1 + } + + pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/') + pythonInclude=/usr/include/python$pythonMajor + + [ -e "$PYTHON_LIBRARY" ] || { + echo " Please set the variable PYTHON_LIBRARY to the full" + echo " path to (and including) libpython, or deactivate" + echo " python support by setting WITH_PYTHON=OFF" + exit 1 + } + + # note - we could also allow for a PYTHON_INCLUDE variable ... + [ -e "$pythonInclude" ] || { + echo " No python include headers found" + echo " Please install python headers or deactivate " + echo " python support by setting WITH_PYTHON=OFF" + exit 1 + } + + addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON + addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude + addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY + + echo "----" + echo "Python information:" + echo " executable : $pythonBin" + echo " version : $pythonMajor" + echo " include path : $pythonInclude" + echo " library : $PYTHON_LIBRARY" + + unset pythonBin pythonInclude pythonMajor + else + echo "*** Error: python not installed" + echo "*** Deactivate python support by setting WITH_PYTHON=OFF" + exit 1 + fi } +# +# define options for mesa support +# addMesaSupport() { - [ "$WITH_MESA" = ON ] || return + [ "$WITH_MESA" = ON ] || return - MESA_INCLUDE_DIR=/usr/include/GL - MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so + MESA_INCLUDE_DIR=/usr/include/GL + MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so - if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ] - then - OBJ_ADD="$OBJ_ADD-mesa" + if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ] + then + OBJ_ADD="$OBJ_ADD-mesa" - addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON - addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR - addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY + addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON + addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR + addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY - else - echo "*** Error: no MESA information found" - exit 1 - fi + else + echo "*** Error: no MESA information found" + exit 1 + fi } -buildParaView() +# +# discover where things are or should be put +# +getPaths() { - # set paraview environment - for i in $PWD $WM_THIRD_PARTY_DIR - do - ParaView_INST_DIR=$i/$PARAVIEW_SRC - [ -d $ParaView_INST_DIR ] && break - done - - if [ ! -d "$ParaView_INST_DIR" ] - then - # last chance: maybe already in the paraview directory - [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD - - [ -d "$ParaView_INST_DIR" ] || { - echo "did not find $PARAVIEW_SRC in these directories:" - echo " PWD=$PWD" - echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR" - echo "abort build" - exit 1 - } - fi - - - # ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD - ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER - - # shortcut for repeated builds - use with caution - if [ "$CMAKE_SKIP" = YES ] - then - - # change to build/install folder - cd $ParaView_DIR || exit 1 - - else - - # remove any existing build folder and recreate - rm -rf $ParaView_DIR - mkdir -p $ParaView_DIR - cd $ParaView_DIR - - echo "----" - echo "Building $PARAVIEW_SRC" - echo " MPI support : $WITH_MPI" - echo " Python support : $WITH_PYTHON" - echo " MESA support : $WITH_MESA" - echo " Source : $ParaView_INST_DIR" - echo " Target : $ParaView_DIR" - echo "----" - - # make paraview - cmake \ - -DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR \ - $CMAKE_VARIABLES \ - $ParaView_INST_DIR - fi - - # change to build folder - echo " Starting make" - - if [ -r /proc/cpuinfo ] - then - WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l) - - if [ $WM_NCOMPPROCS -gt 8 ] - then - WM_NCOMPPROCS=8 - fi - - make -j $WM_NCOMPPROCS - else - make - fi + # set paraview environment + for i in $PWD $WM_THIRD_PARTY_DIR + do + ParaView_INST_DIR=$i/$PARAVIEW_SRC + [ -d $ParaView_INST_DIR ] && break + done + + if [ ! -d "$ParaView_INST_DIR" ] + then + # last chance: maybe already in the paraview directory + [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD + + [ -d "$ParaView_INST_DIR" ] || { + echo "did not find $PARAVIEW_SRC in these directories:" + echo " PWD=$PWD" + echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR" + echo "abort build" + exit 1 + } + fi + + # ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD + ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER + echo "ParaView_DIR=$ParaView_DIR" } -# adjust hard-links +# +# configure via cmake, but don't actually build anything +# +configParaView() +{ + # remove any existing build folder and recreate + if [ -d $ParaView_DIR ] + then + echo "removing old build/install directory" + rm -rf $ParaView_DIR + fi + mkdir -p $ParaView_DIR + + cd $ParaView_DIR + + echo "----" + echo "Configuring $PARAVIEW_SRC" + echo " MPI support : $WITH_MPI" + echo " Python support : $WITH_PYTHON" + echo " MESA support : $WITH_MESA" + echo " Source : $ParaView_INST_DIR" + echo " Target : $ParaView_DIR" + echo "----" + echo + echo cmake \ + -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \ + $CMAKE_VARIABLES \ + ../.. + echo + echo "----" + echo + + # run cmake to create Makefiles + cmake \ + -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \ + $CMAKE_VARIABLES \ + ../.. + +} + + +# +# invoke make +# also link bin/ to lib/paraview-* for development without installation +# +makeParaView() +{ + cd $ParaView_DIR || exit 1 # change to build folder + echo " Starting make" + + if [ -r /proc/cpuinfo ] + then + WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l) + [ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8 + + time make -j $WM_NCOMPPROCS + else + time make + fi + echo " Done make" + + echo " For quicker development, linking lib/paraview-$PARAVIEW_MAJOR_VERSION/ -> bin/" + rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION + mkdir lib 2>/dev/null + ( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION ) +} + + +# +# adjust hard-links (internal function) # Note: use loop with grep to avoid touching too many files -fixCMakeHardLinks() +# +fixHardLinks() +{ + envName=$1 + string=$2 + shift 2 + + echo "-- Replacing path hard links for \$$envName" + + for fileSpec + do + echo -n " $fileSpec: " + for i in $(find . -type f -iname "$fileSpec") + do + if grep -q "$string" $i + then + echo -n "#" + sed -i "s,$string,\$ENV{$envName},g" $i + fi + done + echo + done +} + + +# +# replace absolute paths with environment variables +# This triggers a partial (or even a full) rebuild, but might let us +# find our files later if we relocate the build +# +fixCMakeFiles() { - fileSpec=$1 - string=$2 - envName=$3 - - echo -n " for \$$envName " - for i in $(find . -type f -iname "$fileSpec") - do - if grep -q "$string" $i - then - echo -n "#" - sed -i "s,$string,\$ENV{$envName},g" $i - fi - done - echo + cd $ParaView_DIR || exit 1 # change to build folder + + # Replace path with env variable: ParaView_DIR + fixHardLinks ParaView_DIR "$ParaView_DIR" '*.cmake' + + # Replace path with env variable: ParaView_INST_DIR + fixHardLinks ParaView_INST_DIR "$ParaView_INST_DIR" '*.cmake' + + # Replace path with env variable: MPI_ARCH_PATH + if [ "$WITH_MPI" = ON ] + then + fixHardLinks MPI_ARCH_PATH "$MPI_ARCH_PATH" '*.cmake' + fi + + # Replace path with env variable: CMAKE_HOME + if [ -r "$CMAKE_HOME" ] + then + fixHardLinks CMAKE_HOME "$CMAKE_HOME" '*cmake*' + fi + + # Replace path with env variable: WM_COMPILER_DIR + # (include cmake.check_cache) + # This triggers a complete rebuild (with cmake-2.6.2), but is likely + # needed when redistributing files + fixHardLinks WM_COMPILER_DIR "$WM_COMPILER_DIR" '*cmake*' } +# +# make html documentation (mostly just for the readers/writers) +# +makeDocs() +{ + cd $ParaView_DIR || exit 1 # change to build folder + echo " Creating html documentation" + + make HTMLDocumentation +} + + +# +# actually install the program +# installParaView() { - if [ ! -e "$ParaView_DIR/bin/paraview" ] - then - echo " Cannot install - no paraview binary found" - return - fi - echo " Build complete" - - cd $ParaView_DIR - - echo " Replacing path hard links" - - # Replace local ParaView_INST_DIR path with ParaView_INST_DIR - # environment variable - fixCMakeHardLinks '*.cmake' "$ParaView_INST_DIR" ParaView_INST_DIR - - # Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH - # environment variable - if [ "$WITH_MPI" = ON ] - then - fixCMakeHardLinks '*.cmake' "$MPI_ARCH_PATH" MPI_ARCH_PATH - fi - - # Replace local CMAKE_HOME path with CMAKE_HOME - # environment variable - if [ -r "$CMAKE_HOME" ] - then - fixCMakeHardLinks '*cmake*' "$CMAKE_HOME" CMAKE_HOME - fi - - # Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR - # environment variable - fixCMakeHardLinks '*cmake*' "$WM_COMPILER_DIR" WM_COMPILER_DIR - - # create a softlink to the $ParaView_DIR/bin folder - # - workaround for chosen install location - echo " Creating lib/paraview-$PARAVIEW_MAJOR_VERSION soft link to 'bin'" - rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION - [ -d lib ] || mkdir lib - ( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION ) - - # info on symlinks to screen - echo "" - echo " ---" - echo " Installation complete" - echo " Set environment variables:" - echo " - ParaView_INST_DIR to $ParaView_INST_DIR" - echo " - ParaView_DIR to $ParaView_DIR" - echo " - PV_PLUGIN_PATH to $FOAM_LIBBIN" - echo " Add $ParaView_DIR/bin to PATH" - # echo " Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH" - echo " ---" + cd $ParaView_DIR || exit 1 # change to build folder + echo " Installing ParaView to $ParaView_DIR" + + echo "disabled 'make install' for now, just use links" + + # about.txt may be missing + paraviewLibDir="$ParaView_DIR/lib/paraview-$PARAVIEW_MAJOR_VERSION" + if [ -d "$paraviewLibDir" -a ! -e "$paraviewLibDir/about.txt" ] + then + echo "paraview-$PARAVIEW_MAJOR_VERSION installed - $(date)" > $paraviewLibDir/about.txt + fi + +cat<< INFO + --- + Installation complete + Set environment variables: + + export ParaView_INST_DIR=$ParaView_INST_DIR + export ParaView_DIR=$ParaView_DIR + export PV_PLUGIN_PATH=$FOAM_LIBBIN + export PATH=\$ParaView_DIR/bin:\$PATH + --- +INFO } # clear all the variables used before using any of the functions - unset VERBOSE -unset WITH_MPI -unset WITH_MESA -unset WITH_PYTHON -unset PYTHON_LIBRARY +unset WITH_MPI WITH_MESA +unset WITH_PYTHON PYTHON_LIBRARY unset CMAKE_VARIABLES -unset CMAKE_SKIP unset OBJ_ADD # start with these general settings addCMakeVariable VTK_USE_TK=FALSE -addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON -addCMakeVariable VTK_USE_RPATH:BOOL=OFF +addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON VTK_USE_RPATH:BOOL=OFF addCMakeVariable CMAKE_BUILD_TYPE:STRING=Release +# include development files in "make install" +addCMakeVariable PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON + # ----------------------------------------------------------------- end-of-file diff --git a/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 8ff878105138c45aa083e88fd34dedd9a741384e..cfa2f113376bddbb38f35bc43722575f7f2c4f62 100644 --- a/etc/apps/paraview3/bashrc +++ b/etc/apps/paraview3/bashrc @@ -26,38 +26,49 @@ # paraview3/bashrc # # Description -# Setup file for ParaView3. +# Setup file for paraview-3.x # Sourced from OpenFOAM-?.?/etc/bashrc # +# Note +# The env. variable 'ParaView_DIR' is required for building plugins #------------------------------------------------------------------------------ -export CMAKE_HOME=$WM_THIRD_PARTY_DIR/cmake-2.4.6/platforms/$WM_ARCH +# determine the cmake to be used +unset CMAKE_HOME +for cmake in cmake-2.6.2 cmake-2.4.6 +do + cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH + if [ -r $cmake ] + then + export CMAKE_HOME=$cmake + export PATH=$CMAKE_HOME/bin:$PATH + break + fi +done -if [ -r $CMAKE_HOME ] -then - export PATH=$CMAKE_HOME/bin:$PATH -else - unset CMAKE_HOME -fi +paraviewMajor=paraview-3.5 +export ParaView_VERSION=3.5-cvs -export ParaView_VERSION="3.3-cvs" - -export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION +export ParaView_INST_DIR=$WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER -if [ "$PYTHONPATH" ] +# add in python libraries if required +paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping +if [ -r $paraviewPython ] then - export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 -else - export PYTHONPATH=$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 + if [ "$PYTHONPATH" ] + then + export PYTHONPATH=$PYTHONPATH:$paraviewPython:$ParaView_DIR/lib/$paraviewMajor + else + export PYTHONPATH=$paraviewPython:$ParaView_DIR/lib/$paraviewMajor + fi fi - if [ -r $ParaView_DIR ] then export PATH=$ParaView_DIR/bin:$PATH - export LD_LIBRARY_PATH=$ParaView_DIR/bin:$LD_LIBRARY_PATH export PV_PLUGIN_PATH=$FOAM_LIBBIN fi +unset cmake paraviewMajor paraviewPython # ----------------------------------------------------------------------------- diff --git a/etc/apps/paraview3/cshrc b/etc/apps/paraview3/cshrc index 636b10eb75d0b806d0844653c26d6e8c37c6498d..875d0d1655f5a8c1bcfcb4312609953710aa8a0a 100644 --- a/etc/apps/paraview3/cshrc +++ b/etc/apps/paraview3/cshrc @@ -26,34 +26,44 @@ # paraview3/cshrc # # Description -# Startup File for Paraview3 +# Startup File for paraview-3.x # Sourced from OpenFOAM-?.?/etc/cshrc # +# Note +# The env. variable 'ParaView_DIR' is required for building plugins #------------------------------------------------------------------------------ -setenv CMAKE_HOME $WM_THIRD_PARTY_DIR/cmake-2.4.6/platforms/$WM_ARCH +# determine the cmake to be used +unsetenv CMAKE_HOME +foreach cmake ( cmake-2.6.2 cmake-2.4.6 ) + set cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH + if ( -r $cmake ) then + setenv CMAKE_HOME $cmake + set path=($CMAKE_HOME/bin $path) + break + endif +end -if ( -r $CMAKE_HOME ) then - set path=($CMAKE_HOME/bin $path) -else - unsetenv CMAKE_HOME -endif - -setenv ParaView_VERSION 3.3-cvs +set paraviewMajor=paraview-3.5 +setenv ParaView_VERSION 3.5-cvs -setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/ParaView$ParaView_VERSION +setenv ParaView_INST_DIR $WM_THIRD_PARTY_DIR/paraview-$ParaView_VERSION setenv ParaView_DIR $ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER -if ($?PYTHONPATH) then - setenv PYTHONPATH ${PYTHONPATH}:$ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 -else - setenv PYTHONPATH $ParaView_DIR/Utilities/VTKPythonWrapping:$ParaView_DIR/lib/paraview-3.3 +# add in python libraries if required +set paraviewPython=$ParaView_DIR/Utilities/VTKPythonWrapping +if ( -r $paraviewPython ) then + if ($?PYTHONPATH) then + setenv PYTHONPATH ${PYTHONPATH}:$paraviewPython:$ParaView_DIR/lib/${paraviewMajor} + else + setenv PYTHONPATH $paraviewPython:$ParaView_DIR/lib/${paraviewMajor} + endif endif if ( -r $ParaView_INST_DIR ) then set path=($ParaView_DIR/bin $path) - setenv LD_LIBRARY_PATH $ParaView_DIR/bin:$LD_LIBRARY_PATH setenv PV_PLUGIN_PATH $FOAM_LIBBIN endif +unset cmake paraviewMajor paraviewPython # ----------------------------------------------------------------------------- diff --git a/etc/bashrc b/etc/bashrc index ec96457be247718cd103bef4fe42eac681bcb145..35044f5b019600d90f81a57c7f03496f7a071e25 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -91,7 +91,7 @@ export WM_COMPILER_LIB_ARCH= # WM_JAVAC_OPTION = Opt | Debug : ${WM_JAVAC_OPTION:=Opt}; export WM_JAVAC_OPTION -# WM_MPLIB = | OPENMPI| LAM | MPICH | MPICH-GM | HPMPI | GAMMA | MPI +# WM_MPLIB = | OPENMPI | LAM | MPICH | MPICH-GM | HPMPI | GAMMA | MPI : ${WM_MPLIB:=OPENMPI}; export WM_MPLIB diff --git a/src/Allwmake b/src/Allwmake index 35b8f55b886f902b5dfca438b36a36ba4f7caa93..c451cff8dd569337fee1e93b2aea9af6d559547c 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 39c40b74c4353254e30ea7c50502dcd62e4da309..f83513ac4ac08d08f96d8cdbce23005b58c63584 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 8f4ddafdb827b6b63e7524764478a2fd0c93ff7e..271d4a442b57ead63fdb449c16efedb505c5c34d 100644 --- a/src/OSspecific/Unix/Unix.C +++ b/src/OSspecific/Unix/Unix.C @@ -211,7 +211,7 @@ bool Foam::chDir(const fileName& dir) } -Foam::fileName Foam::dotFoam(const fileName& name) +Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory) { // Search user files: // ~~~~~~~~~~~~~~~~~~ @@ -268,6 +268,15 @@ Foam::fileName Foam::dotFoam(const fileName& name) } // Not found + // abort if the file is mandatory, otherwise return null + if (mandatory) + { + cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :" + " could not find mandatory file\n '" + << name.c_str() << "'\n\n" << std::endl; + ::exit(1); + } + return fileName::null; } diff --git a/src/OSspecific/Unix/regExp.C b/src/OSspecific/Unix/regExp.C new file mode 100644 index 0000000000000000000000000000000000000000..e3ad4a11af4cb6e7b1e5cf553fcfe62a3255e923 --- /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 <sys/types.h> +#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<string>& 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 fed14379ad917906960e587e9d7b67eb648cfa45..60ac68a3c2742183dd0e54238c2b27a0cec38b7d 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 <sys/types.h> #include <regex.h> -#include "string.H" -#include "IOstreams.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +// Forward declaration of classes +class string; +template<class T> 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 from string - inline regularExpression(const string& s) - { - preg_ = new regex_t; + //- Construct null + regExp(); - if (regcomp(preg_, s.c_str(), REG_EXTENDED) != 0) - { - FatalErrorIn - ( - "regularExpression::regularExpression(const char*)" - ) << "Failed to compile regular expression " << s - << exit(FatalError); - } - } + //- Construct from string + 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; + + //- 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<string>& groups, + bool partialMatch=false + ) const; + + // Member Operators + + //- Assign from a string + void operator=(const string&); - int errVal = regexec(preg_, s.c_str(), nmatch, pmatch, 0); + //- 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 e24fd6b5ec4411c30138924dd05fdb3eb94a3959..9162050cc0a60e7d85f254bf9348a8b8078d9a1c 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 33d7fd3723255e24f6aa7207db3e678b309fdc93..b6e52f46860ae265acae8ce0eef7040fd5b8a394 100644 --- a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.C @@ -28,22 +28,15 @@ Description #include "Dictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Null constructor template<class T> -Dictionary<T>::Dictionary() +Foam::Dictionary<T>::Dictionary() {} -// Copy constructor template<class T> -Dictionary<T>::Dictionary(const Dictionary& dict) +Foam::Dictionary<T>::Dictionary(const Dictionary& dict) : DictionaryBase<IDLList<T>, T>(dict) {} @@ -52,10 +45,10 @@ Dictionary<T>::Dictionary(const Dictionary& dict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class T> -bool Dictionary<T>::erase(const word& Keyword) +bool Foam::Dictionary<T>::erase(const word& keyword) { T* tPtr; - if ((tPtr = this->remove(Keyword))) + if (tPtr = this->remove(keyword)) { delete tPtr; return true; @@ -69,6 +62,4 @@ bool Dictionary<T>::erase(const word& Keyword) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H index 3b985482e7bdbec929388d8d4dd62c9efbb10094..90af1383f4a485307b002ee9fcd71c32e4ea9eeb 100644 --- a/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/Dictionary/Dictionary.H @@ -27,8 +27,10 @@ Class Description Gerneral purpose template dictionary class which manages the storage - associated with it. It is derived from DictionaryBase instantiated on - a memory managed form of intrusive doubly-linked list of \<T\>. + associated with it. + + It is derived from DictionaryBase instantiated on a memory managed form + of intrusive doubly-linked list of \<T\>. SourceFiles Dictionary.C @@ -47,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class Dictionary Declaration + Class Dictionary Declaration \*---------------------------------------------------------------------------*/ template<class T> @@ -69,11 +71,9 @@ public: // Member functions - // Editing - - //- Remove an entry specified by keyword from the dictionary - // and delete it - bool erase(const word& keyword); + //- Remove an entry specified by keyword and delete the pointer. + // Returns true if the keyword was found + bool erase(const word& keyword); }; diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C index 4349973c3ce236f4077046a70a95ee50639534dc..95112712081129e65f9331a7592fcb89ab9429ad 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.C @@ -26,15 +26,10 @@ License #include "DictionaryBase.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::addEntries() +void Foam::DictionaryBase<IDLListType, T>::addEntries() { for ( @@ -51,12 +46,15 @@ void DictionaryBase<IDLListType, T>::addEntries() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class IDLListType, class T> -DictionaryBase<IDLListType, T>::DictionaryBase() +Foam::DictionaryBase<IDLListType, T>::DictionaryBase() {} template<class IDLListType, class T> -DictionaryBase<IDLListType, T>::DictionaryBase(const DictionaryBase& dict) +Foam::DictionaryBase<IDLListType, T>::DictionaryBase +( + const DictionaryBase& dict +) : IDLListType(dict) { @@ -66,17 +64,20 @@ DictionaryBase<IDLListType, T>::DictionaryBase(const DictionaryBase& dict) template<class IDLListType, class T> template<class INew> -DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is, const INew& inewt) +Foam::DictionaryBase<IDLListType, T>::DictionaryBase +( + Istream& is, + const INew& iNew +) : - IDLListType(is, inewt) + IDLListType(is, iNew) { addEntries(); } -// Istream constructor template<class IDLListType, class T> -DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is) +Foam::DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is) : IDLListType(is) { @@ -88,25 +89,60 @@ DictionaryBase<IDLListType, T>::DictionaryBase(Istream& is) // Find and return T template<class IDLListType, class T> -bool DictionaryBase<IDLListType, T>::found(const word& keyword) const +bool Foam::DictionaryBase<IDLListType, T>::found(const word& keyword) const { return hashedTs_.found(keyword); } -// Find and return T* +// Find and return T*, return NULL if not found template<class IDLListType, class T> -const T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) const +const T* Foam::DictionaryBase<IDLListType, T>::lookupPtr +( + const word& keyword +) const +{ + typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword); + + if (iter != hashedTs_.end()) + { + return *iter; + } + else + { + return NULL; + } +} + + +// Find and return T*, return NULL if not found +template<class IDLListType, class T> +T* Foam::DictionaryBase<IDLListType, T>::lookupPtr(const word& keyword) +{ + typename HashTable<T*>::iterator iter = hashedTs_.find(keyword); + + if (iter != hashedTs_.end()) + { + return *iter; + } + else + { + return NULL; + } +} + + +// Find and return T*, FatalError if keyword not found +template<class IDLListType, class T> +const T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword) const { typename HashTable<T*>::const_iterator iter = hashedTs_.find(keyword); if (iter == hashedTs_.end()) { - // If keyword not found print error message ... FatalErrorIn ( - "DictionaryBase<IDLListType, T>::" - "lookup(const word& keyword) const" + "DictionaryBase<IDLListType, T>::lookup(const word&) const" ) << keyword << " is undefined" << exit(FatalError); } @@ -115,18 +151,17 @@ const T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) const } -// Find and return T* +// Find and return T*, FatalError if keyword not found template<class IDLListType, class T> -T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) +T* Foam::DictionaryBase<IDLListType, T>::lookup(const word& keyword) { typename HashTable<T*>::iterator iter = hashedTs_.find(keyword); if (iter == hashedTs_.end()) { - // If keyword not found print error message ... FatalErrorIn ( - "DictionaryBase<IDLListType, T>::lookup(const word& keyword)" + "DictionaryBase<IDLListType, T>::lookup(const word&)" ) << keyword << " is undefined" << exit(FatalError); } @@ -137,7 +172,7 @@ T* DictionaryBase<IDLListType, T>::lookup(const word& keyword) // Return the table of contents template<class IDLListType, class T> -wordList DictionaryBase<IDLListType, T>::toc() const +Foam::wordList Foam::DictionaryBase<IDLListType, T>::toc() const { wordList keywords(this->size()); @@ -158,26 +193,28 @@ wordList DictionaryBase<IDLListType, T>::toc() const // Add at head of dictionary template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr) +void Foam::DictionaryBase<IDLListType, T>::insert(const word& keyword, T* tPtr) { - IDLListType::insert(tPtr); + // NOTE: we should probably check that HashTable::insert actually worked hashedTs_.insert(keyword, tPtr); + IDLListType::insert(tPtr); } // Add at tail of dictionary template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr) +void Foam::DictionaryBase<IDLListType, T>::append(const word& keyword, T* tPtr) { - IDLListType::append(tPtr); + // NOTE: we should probably check that HashTable::insert actually worked hashedTs_.insert(keyword, tPtr); + IDLListType::append(tPtr); } template<class IDLListType, class T> -T* DictionaryBase<IDLListType, T>::remove(const word& Keyword) +T* Foam::DictionaryBase<IDLListType, T>::remove(const word& keyword) { - typename HashTable<T*>::iterator iter = hashedTs_.find(Keyword); + typename HashTable<T*>::iterator iter = hashedTs_.find(keyword); if (iter != hashedTs_.end()) { @@ -192,19 +229,29 @@ T* DictionaryBase<IDLListType, T>::remove(const word& Keyword) } -//- Clear the dictionary template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::clear() +void Foam::DictionaryBase<IDLListType, T>::clear() { IDLListType::clear(); hashedTs_.clear(); } +template<class IDLListType, class T> +void Foam::DictionaryBase<IDLListType, T>::transfer +( + DictionaryBase<IDLListType, T>& dict +) +{ + IDLListType::transfer(dict); + hashedTs_.transfer(dict.hashedTs_); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class IDLListType, class T> -void DictionaryBase<IDLListType, T>::operator= +void Foam::DictionaryBase<IDLListType, T>::operator= ( const DictionaryBase<IDLListType, T>& dict ) @@ -218,25 +265,11 @@ void DictionaryBase<IDLListType, T>::operator= } IDLListType::operator=(dict); - this->hashedTs_.clear(); - - for - ( - typename IDLListType::iterator iter = this->begin(); - iter != this->end(); - ++iter - ) - { - this->hashedTs_.insert((*iter).keyword(), &(*iter)); - } + this->addEntries(); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "DictionaryBaseIO.C" diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H index 8288cdf5cfbf5f28feddfe19c73bcb3e249a2b34..f14785bcd555ae5a8737623024e6d15de146d82f 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBase.H @@ -29,12 +29,12 @@ Description Base dictionary class templated on both the form of doubly-linked list it uses as well as the type it holds. - The double templating allows for the instantiation of forms with and + The double templating allows for the instantiation of forms with or without storage management. Note The IDLListType parameter should itself be a template but this confused - gcc 2.95.2 so it has to be instantiated for T when an intantiation of + gcc 2.95.2 so it has to be instantiated for T when an instantiation of DictionaryBase is requested See Also @@ -67,7 +67,7 @@ Ostream& operator<<(Ostream&, const DictionaryBase<IDLListType, T>&); /*---------------------------------------------------------------------------*\ - Class DictionaryBase Declaration + Class DictionaryBase Declaration \*---------------------------------------------------------------------------*/ template<class IDLListType, class T> @@ -77,7 +77,7 @@ class DictionaryBase { // Private data - //- HashTable of the enries held on the DL-list for quick lookup + //- HashTable of the entries held on the IDLListType for quick lookup HashTable<T*> hashedTs_; @@ -99,10 +99,10 @@ public: //- Construct from Istream using given Istream constructor class template<class INew> - DictionaryBase(Istream& is, const INew& inewt); + DictionaryBase(Istream&, const INew&); - //- Construct from Istream - DictionaryBase(Istream& is); + //- Construct from Istream using default Istream constructor class + DictionaryBase(Istream&); // Member functions @@ -110,7 +110,13 @@ public: // Search and lookup //- Search DictionaryBase for given keyword - bool found(const word& keyword) const; + bool found(const word&) const; + + //- Find and return an entry if present, otherwise return NULL + const T* lookupPtr(const word&) const; + + //- Find and return an entry if present, otherwise return NULL + T* lookupPtr(const word&); //- Find and return entry const T* lookup(const word&) const; @@ -125,17 +131,21 @@ public: // Editing //- Add at head of dictionary - void insert(const word& keyword, T*); + void insert(const word&, T*); //- Add at tail of dictionary - void append(const word& keyword, T*); + void append(const word&, T*); - //- Remove and return entry specified by keyword - T* remove(const word& keyword); + //- Remove and return entry specified by keyword. + // Return NULL if the keyword was not found. + T* remove(const word&); //- Clear the dictionary void clear(); + //- Transfer the contents of the argument into this DictionaryBase + // and annull the argument. + void transfer(DictionaryBase<IDLListType, T>&); // Member operators diff --git a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C index 15854c515bf653dcb8a09ee0377dd59585be5673..6af2b1622dcc46f760622704bcfffba39c995b40 100644 --- a/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C +++ b/src/OpenFOAM/containers/Dictionaries/DictionaryBase/DictionaryBaseIO.C @@ -30,15 +30,13 @@ Description #include "DictionaryBase.H" #include "IOstreams.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * // template<class IDLListType, class T> -Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict) +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const DictionaryBase<IDLListType, T>& dict) { for ( @@ -53,7 +51,7 @@ Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict) if (!os.good()) { Info - << "operator<<(Ostream& os, const DictionaryBase&) : " + << "operator<<(Ostream&, const DictionaryBase&) : " << "Can't write entry for DictionaryBase" << endl; @@ -67,6 +65,4 @@ Ostream& operator<<(Ostream& os, const DictionaryBase<IDLListType, T>& dict) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C index b2b7861eb4f00e3f4bee21689a5f36fc2df18465..4b0a48ac900002db096e6f544e8aa9b742306a97 100644 --- a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.C @@ -26,20 +26,15 @@ License #include "PtrDictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class T> -PtrDictionary<T>::PtrDictionary() +Foam::PtrDictionary<T>::PtrDictionary() {} template<class T> -PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict) +Foam::PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict) : DictionaryBase<DLPtrList<T>, T>(dict) {} @@ -47,14 +42,14 @@ PtrDictionary<T>::PtrDictionary(const PtrDictionary& dict) template<class T> template<class INew> -PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew) +Foam::PtrDictionary<T>::PtrDictionary(Istream& is, const INew& iNew) : DictionaryBase<DLPtrList<T>, T>(is, iNew) {} template<class T> -PtrDictionary<T>::PtrDictionary(Istream& is) +Foam::PtrDictionary<T>::PtrDictionary(Istream& is) : DictionaryBase<DLPtrList<T>, T>(is) {} @@ -62,6 +57,4 @@ PtrDictionary<T>::PtrDictionary(Istream& is) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H index 3396236515c1a1ec08ef83318e32532703e9b5e8..9c7da2f4de329a18c8aa06c98041d169a32eb521 100644 --- a/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/PtrDictionary/PtrDictionary.H @@ -27,8 +27,10 @@ Class Description Template dictionary class which does not manages the storage - associated with it. It is derived from DictionaryBase instantiated on - a non-memory managed form of intrusive doubly-linked list of T. + associated with it. + + It is derived from DictionaryBase instantiated on a non-memory managed + form of intrusive doubly-linked list of T. SourceFiles PtrDictionary.C @@ -47,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class PtrDictionary Declaration + Class PtrDictionary Declaration \*---------------------------------------------------------------------------*/ template<class T> diff --git a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C index 9712b747351431b59989a0ba9d88a97239fbd773..8f29af262bc361ddef8e5ebc9b25e6887e0c1460 100644 --- a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.C @@ -26,22 +26,15 @@ License #include "UDictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Null constructor template<class T> -UDictionary<T>::UDictionary() +Foam::UDictionary<T>::UDictionary() {} -// Copy constructor template<class T> -UDictionary<T>::UDictionary(const UDictionary& dict) +Foam::UDictionary<T>::UDictionary(const UDictionary& dict) : DictionaryBase<UIDLList<T>, T>(dict) {} @@ -49,6 +42,4 @@ UDictionary<T>::UDictionary(const UDictionary& dict) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.H b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.H index fb30237d40d91768a8b9ba850bfe51e35ddd98ac..5cc4d301f4e3f2aab7d1558d337111b6ce9077a4 100644 --- a/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/UDictionary/UDictionary.H @@ -49,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class UDictionary Declaration + Class UDictionary Declaration \*---------------------------------------------------------------------------*/ template<class T> diff --git a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C index 3a4686fbf6aa659ad4c5e9d8046099de1e7a4ffd..6aa7da72abd4c50cbcca4ca9c2d37cf796f0c6a3 100644 --- a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C +++ b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.C @@ -26,22 +26,15 @@ License #include "UPtrDictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Null constructor template<class T> -UPtrDictionary<T>::UPtrDictionary() +Foam::UPtrDictionary<T>::UPtrDictionary() {} -// Copy constructor template<class T> -UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict) +Foam::UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict) : DictionaryBase<DLList<T*>, T>(dict) {} @@ -49,6 +42,4 @@ UPtrDictionary<T>::UPtrDictionary(const UPtrDictionary& dict) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.H b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.H index 2caac9efac685a5e5e88658f73edbc897a6e1980..99aee0ac562ce84c04c8ef25b823cca530d9e3b7 100644 --- a/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.H +++ b/src/OpenFOAM/containers/Dictionaries/UPtrDictionary/UPtrDictionary.H @@ -27,8 +27,10 @@ Class Description Template dictionary class which does not manages the storage - associated with it. It is derived from DictionaryBase instantiated on - a non-memory managed form of intrusive doubly-linked list of \<T\>. + associated with it. + + It is derived from DictionaryBase instantiated on a non-memory managed + form of intrusive doubly-linked list of \<T\>. SourceFiles UPtrDictionary.C @@ -47,7 +49,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class UPtrDictionary Declaration + Class UPtrDictionary Declaration \*---------------------------------------------------------------------------*/ template<class T> diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index d9d74fd1ad4fbcb79040a38183b1e1b357c03c62..37c595222e5c1f6a2aca308cdb356f538b7a0092 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -456,6 +456,14 @@ void HashTable<T, Key, Hash>::clear() } +template<class T, class Key, class Hash> +void HashTable<T, Key, Hash>::clearStorage() +{ + clear(); + resize(0); +} + + template<class T, class Key, class Hash> void HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht) { diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 701d8456156572dd54f878b5dc7748636505a7be..798dad6367882f2bee2e94d12e2ac74b395b7508 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -54,6 +54,7 @@ template<class T> class List; template<class T, class Key, class Hash> class HashTable; +template<class T, class Key, class Hash> class HashPtrTable; template<class T, class Key, class Hash> Istream& operator>> ( @@ -102,7 +103,7 @@ class HashTable //- Construct given key, next pointer and object inline hashedEntry ( - const Key& key, + const Key&, hashedEntry* next, const T& newEntry ); @@ -127,7 +128,7 @@ class HashTable // Private Member Functions //- Assign a new hashedEntry to a possibly already existing key - bool set(const Key& key, const T& newElmt, bool protect); + bool set(const Key&, const T& newElmt, bool protect); public: @@ -173,15 +174,15 @@ public: inline label size() const; //- Return true if hashedEntry is found in table - bool found(const Key& key) const; + bool found(const Key&) const; //- Find and return an iterator set at the hashedEntry // If not found iterator = end() - iterator find(const Key& key); + iterator find(const Key&); //- Find and return an const_iterator set at the hashedEntry // If not found iterator = end() - const_iterator find(const Key& key) const; + const_iterator find(const Key&) const; //- Return the table of contents List<Key> toc() const; @@ -190,16 +191,16 @@ public: // Edit //- Insert a new hashedEntry - inline bool insert(const Key& key, const T& newElmt); + inline bool insert(const Key&, const T& newElmt); //- Assign a new hashedEntry, overwriting existing entries - inline bool set(const Key& key, const T& newElmt); + inline bool set(const Key&, const T& newElmt); //- Erase an hashedEntry specified by given iterator - bool erase(const iterator& it); + bool erase(const iterator&); //- Erase an hashedEntry specified by given key if in table - bool erase(const Key& key); + bool erase(const Key&); //- Resize the hash table for efficiency void resize(const label newSize); @@ -207,6 +208,10 @@ public: //- Clear all entries from table void clear(); + //- Clear the table entries and the table itself. + // Equivalent to clear() followed by resize(0) + void clearStorage(); + //- Transfer the contents of the argument table into this table // and annull the argument table. void transfer(HashTable<T, Key, Hash>&); @@ -215,14 +220,14 @@ public: // Member Operators //- Find and return an hashedEntry - inline T& operator[](const Key& key); + inline T& operator[](const Key&); //- Find and return an hashedEntry - inline const T& operator[](const Key& key) const; + inline const T& operator[](const Key&) const; //- Find and return an hashedEntry and // if it is not present create it null. - inline T& operator()(const Key& key); + inline T& operator()(const Key&); //- Assignment void operator=(const HashTable<T, Key, Hash>&); @@ -290,13 +295,13 @@ public: // Member operators - inline void operator=(const iterator& iter); + inline void operator=(const iterator&); - inline bool operator==(const iterator& iter) const; - inline bool operator!=(const iterator& iter) const; + inline bool operator==(const iterator&) const; + inline bool operator!=(const iterator&) const; - inline bool operator==(const const_iterator& iter) const; - inline bool operator!=(const const_iterator& iter) const; + inline bool operator==(const const_iterator&) const; + inline bool operator!=(const const_iterator&) const; inline T& operator*(); inline T& operator()(); @@ -352,13 +357,13 @@ public: // Member operators - inline void operator=(const const_iterator& iter); + inline void operator=(const const_iterator&); - inline bool operator==(const const_iterator& iter) const; - inline bool operator!=(const const_iterator& iter) const; + inline bool operator==(const const_iterator&) const; + inline bool operator!=(const const_iterator&) const; - inline bool operator==(const iterator& iter) const; - inline bool operator!=(const iterator& iter) const; + inline bool operator==(const iterator&) const; + inline bool operator!=(const iterator&) const; inline const T& operator*(); inline const T& operator()(); diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C index 670a3116a4221db6204764f42870bff1078c9f29..565cac9493810d3b7cfead47a795897161318677 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.C @@ -26,22 +26,17 @@ License #include "ILList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl) +Foam::ILList<LListBase, T>::ILList(const ILList<LListBase, T>& lst) : UILList<LListBase, T>() { for ( - typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -53,9 +48,9 @@ ILList<LListBase, T>::ILList(const ILList<LListBase, T>& slpl) #ifndef __INTEL_COMPILER template<class LListBase, class T> template<class CloneArg> -ILList<LListBase, T>::ILList +Foam::ILList<LListBase, T>::ILList ( - const ILList<LListBase, T>& slpl, + const ILList<LListBase, T>& lst, const CloneArg& cloneArg ) : @@ -63,8 +58,8 @@ ILList<LListBase, T>::ILList { for ( - typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -77,7 +72,7 @@ ILList<LListBase, T>::ILList // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // template<class LListBase, class T> -ILList<LListBase, T>::~ILList() +Foam::ILList<LListBase, T>::~ILList() { this->clear(); } @@ -85,9 +80,8 @@ ILList<LListBase, T>::~ILList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Return and remove head template<class LListBase, class T> -bool ILList<LListBase, T>::eraseHead() +bool Foam::ILList<LListBase, T>::eraseHead() { T* tPtr; if ((tPtr = this->removeHead())) @@ -101,9 +95,8 @@ bool ILList<LListBase, T>::eraseHead() } } -//- Return and remove element template<class LListBase, class T> -bool ILList<LListBase, T>::erase(T* p) +bool Foam::ILList<LListBase, T>::erase(T* p) { T* tPtr; if ((tPtr = remove(p))) @@ -119,7 +112,7 @@ bool ILList<LListBase, T>::erase(T* p) template<class LListBase, class T> -void ILList<LListBase, T>::clear() +void Foam::ILList<LListBase, T>::clear() { label oldSize = this->size(); for (label i=0; i<oldSize; i++) @@ -131,17 +124,25 @@ void ILList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::ILList<LListBase, T>::transfer(ILList<LListBase, T>& lst) +{ + clear(); + LListBase::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl) +void Foam::ILList<LListBase, T>::operator=(const ILList<LListBase, T>& lst) { this->clear(); for ( - typename UILList<LListBase, T>::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename UILList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -149,11 +150,6 @@ void ILList<LListBase, T>::operator=(const ILList<LListBase, T>& slpl) } } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "ILListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H index 074a54a259125065fbb724bf20fd320949e554bd..401a8b60388100bb60273a2afe0490c8f22b0eb1 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILList.H @@ -71,7 +71,7 @@ class ILList //- Read from Istream using given Istream constructor class template<class INew> - void read(Istream&, const INew& inewt); + void read(Istream&, const INew&); public: @@ -96,7 +96,7 @@ public: //- Copy constructor with additional argument for clone template<class CloneArg> - ILList(const ILList<LListBase, T>& slpl, const CloneArg& cloneArg) + ILList(const ILList<LListBase, T>& lst, const CloneArg& cloneArg) #ifdef __INTEL_COMPILER : UILList<LListBase, T>() @@ -104,8 +104,8 @@ public: for ( typename UILList<LListBase, T>::const_iterator iter = - slpl.begin(); - iter != slpl.end(); + lst.begin(); + iter != lst.end(); ++iter ) { @@ -118,7 +118,7 @@ public: //- Construct from Istream using given Istream constructor class template<class INew> - ILList(Istream&, const INew& inewt); + ILList(Istream&, const INew&); // Destructor @@ -139,6 +139,10 @@ public: //- Clear the contents of the list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(ILList<LListBase, T>&); + // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C index 8d2ac68c27e4396053e3c5dcc91c5463943db606..a467da11dc87779ba93f3e38df6ddb14e37b8fd0 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/ILList/ILListIO.C @@ -30,24 +30,19 @@ Description #include "Istream.H" #include "INew.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> template<class INew> -void ILList<LListBase, T>::read(Istream& is, const INew& inewt) +void Foam::ILList<LListBase, T>::read(Istream& is, const INew& iNew) { - is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); + is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)"); token firstToken(is); is.fatalCheck ( - "operator>>(Istream& is, ILList<LListBase, T>& L) : reading first token" + "operator>>(Istream&, ILList<LListBase, T>&) : reading first token" ); if (firstToken.isLabel()) @@ -63,26 +58,26 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt) { for (label i=0; i<s; i++) { - append(inewt(is).ptr()); - + append(iNew(is).ptr()); + is.fatalCheck ( - "operator>>(Istream& is, ILList<LListBase, T>& L) : " + "operator>>(Istream&, ILList<LListBase, T>&) : " "reading entry" ); } } else { - T* tPtr = inewt(is).ptr(); + T* tPtr = iNew(is).ptr(); append(tPtr); is.fatalCheck ( - "operator>>(Istream& is, ILList<LListBase, T>& L) : " + "operator>>(Istream&, ILList<LListBase, T>&) : " "reading entry" ); - + for (label i=1; i<s; i++) { append(new T(*tPtr)); @@ -99,14 +94,14 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt) { FatalIOErrorIn ( - "operator>>(Istream& is, ILList<LListBase, T>& L)", + "operator>>(Istream&, ILList<LListBase, T>&)", is ) << "incorrect first token, '(', found " << firstToken.info() << exit(FatalIOError); } token lastToken(is); - is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); + is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)"); while ( @@ -117,36 +112,34 @@ void ILList<LListBase, T>::read(Istream& is, const INew& inewt) ) { is.putBack(lastToken); - append(inewt(is).ptr()); + append(iNew(is).ptr()); is >> lastToken; - is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); + is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)"); } } else { - FatalIOErrorIn("operator>>(Istream& is, ILList<LListBase, T>& L)", is) + FatalIOErrorIn("operator>>(Istream&, ILList<LListBase, T>&)", is) << "incorrect first token, expected <int> or '(', found " << firstToken.info() << exit(FatalIOError); } - is.fatalCheck("operator>>(Istream& is, ILList<LListBase, T>& L)"); + is.fatalCheck("operator>>(Istream&, ILList<LListBase, T>&)"); } -//- Construct from Istream using given Istream constructor class template<class LListBase, class T> template<class INew> -ILList<LListBase, T>::ILList(Istream& is, const INew& inewt) +Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& iNew) { - read(is, inewt); + read(is, iNew); } -// Construct from Istream template<class LListBase, class T> -ILList<LListBase, T>::ILList(Istream& is) +Foam::ILList<LListBase, T>::ILList(Istream& is) { read(is, INew<T>()); } @@ -155,7 +148,7 @@ ILList<LListBase, T>::ILList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Istream& operator>>(Istream& is, ILList<LListBase, T>& L) +Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& L) { L.clear(); L.read(is, INew<T>()); @@ -166,6 +159,4 @@ Istream& operator>>(Istream& is, ILList<LListBase, T>& L) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C index 94512eeabda6a65145daf02cd712783d13cf5ef1..1c93142b416245af36a84dfb12d6880ef3b0b111 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C @@ -27,22 +27,16 @@ Description \*---------------------------------------------------------------------------*/ #include "error.H" - #include "LList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -LList<LListBase, T>::LList(const LList<LListBase, T>& slpl) +Foam::LList<LListBase, T>::LList(const LList<LListBase, T>& lst) : LListBase() { - for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(iter()); } @@ -50,7 +44,7 @@ LList<LListBase, T>::LList(const LList<LListBase, T>& slpl) template<class LListBase, class T> -LList<LListBase, T>::~LList() +Foam::LList<LListBase, T>::~LList() { this->clear(); } @@ -59,7 +53,7 @@ LList<LListBase, T>::~LList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class LListBase, class T> -void LList<LListBase, T>::clear() +void Foam::LList<LListBase, T>::clear() { label oldSize = this->size(); for (label i=0; i<oldSize; i++) @@ -71,24 +65,28 @@ void LList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::LList<LListBase, T>::transfer(LList<LListBase, T>& lst) +{ + clear(); + LListBase::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void LList<LListBase, T>::operator=(const LList<LListBase, T>& slpl) +void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst) { this->clear(); - for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(iter()); } } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "LListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H index a9bc0bccae46bfdef4d1523beacf08fffc4e4dfd..4c422f7ccb2ae01f59add91906f1f33bd49d2ccf 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H @@ -67,7 +67,7 @@ Ostream& operator<< /*---------------------------------------------------------------------------*\ - Class LList Declaration + Class LList Declaration \*---------------------------------------------------------------------------*/ template<class LListBase, class T> @@ -200,6 +200,9 @@ public: //- Delete contents of list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(LList<LListBase, T>&); // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C index 32dbaf3f17fa1aa09dea5fd8eb8b8bc38ed0cff9..316585078186b627688b2b0d330ab4d7ba9078fb 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C @@ -30,16 +30,10 @@ Description #include "Istream.H" #include "Ostream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from Istream template<class LListBase, class T> -LList<LListBase, T>::LList(Istream& is) +Foam::LList<LListBase, T>::LList(Istream& is) { operator>>(is, *this); } @@ -48,18 +42,18 @@ LList<LListBase, T>::LList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Istream& operator>>(Istream& is, LList<LListBase, T>& L) +Foam::Istream& Foam::operator>>(Istream& is, LList<LListBase, T>& L) { // Anull list L.clear(); - is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)"); + is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)"); token firstToken(is); is.fatalCheck ( - " operator>>(Istream& is, LList<LListBase, T>& L) : reading first token" + " operator>>(Istream&, LList<LListBase, T>&) : reading first token" ); if (firstToken.isLabel()) @@ -101,14 +95,14 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L) { FatalIOErrorIn ( - " operator>>(Istream& is, LList<LListBase, T>& L)", + " operator>>(Istream&, LList<LListBase, T>&)", is ) << "incorrect first token, '(', found " << firstToken.info() << exit(FatalIOError); } token lastToken(is); - is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)"); + is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)"); while ( @@ -124,19 +118,19 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L) L.append(element); is >> lastToken; - is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)"); + is.fatalCheck(" operator>>(Istream&, LList<LListBase, T>&)"); } } else { - FatalIOErrorIn(" operator>>(Istream& is, LList<LListBase, T>& L)", is) + FatalIOErrorIn(" operator>>(Istream&, LList<LListBase, T>&)", is) << "incorrect first token, expected <int> or '(', found " << firstToken.info() << exit(FatalIOError); } // Check state of IOstream - is.fatalCheck(" operator>>(Istream& is, LList<LListBase, T>& L)"); + is.fatalCheck(" operator>>(Istream&, LList<LListBase,>&)"); return is; } @@ -145,19 +139,19 @@ Istream& operator>>(Istream& is, LList<LListBase, T>& L) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Ostream& operator<<(Ostream& os, const LList<LListBase, T>& ll) +Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& lst) { - // Write size of LList - os << nl << ll.size(); + // Write size + os << nl << lst.size(); // Write beginning of contents os << nl << token::BEGIN_LIST << nl; - // Write LList contents + // Write contents for ( - typename LList<LListBase, T>::const_iterator iter = ll.begin(); - iter != ll.end(); + typename LList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -168,14 +162,10 @@ Ostream& operator<<(Ostream& os, const LList<LListBase, T>& ll) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const LList&)"); + os.check("Ostream& operator<<(Ostream&, const LList<LListBase, T>&)"); return os; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C index bf29f1d45050eeef9fdd5437c1ed7a87643110dd..935e68292c080d89d4203548ec0d17c479d50c8b 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.C @@ -26,19 +26,14 @@ License #include "LPtrList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& slpl) +Foam::LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& lst) : LList<LListBase, T*>() { - for(const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(iter().clone().ptr()); } @@ -48,7 +43,7 @@ LPtrList<LListBase, T>::LPtrList(const LPtrList<LListBase, T>& slpl) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class LListBase, class T> -LPtrList<LListBase, T>::~LPtrList() +Foam::LPtrList<LListBase, T>::~LPtrList() { clear(); } @@ -56,9 +51,8 @@ LPtrList<LListBase, T>::~LPtrList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Return and remove head template<class LListBase, class T> -bool LPtrList<LListBase, T>::eraseHead() +bool Foam::LPtrList<LListBase, T>::eraseHead() { T* tPtr; if ((tPtr = this->removeHead())) @@ -74,7 +68,7 @@ bool LPtrList<LListBase, T>::eraseHead() template<class LListBase, class T> -void LPtrList<LListBase, T>::clear() +void Foam::LPtrList<LListBase, T>::clear() { label oldSize = this->size(); for (label i=0; i<oldSize; i++) @@ -86,24 +80,28 @@ void LPtrList<LListBase, T>::clear() } +template<class LListBase, class T> +void Foam::LPtrList<LListBase, T>::transfer(LPtrList<LListBase, T>& lst) +{ + clear(); + LList<LListBase, T*>::transfer(lst); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& slpl) +void Foam::LPtrList<LListBase, T>::operator=(const LPtrList<LListBase, T>& lst) { clear(); - for(const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(iter().clone().ptr()); } } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "LPtrListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H index 601d26f87617ee3943e658d7be6e928d0972eaa1..fdb59ea27cd1cc553e5121ca8b543e07e588876d 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrList.H @@ -149,12 +149,16 @@ public: // Edit - //- Remove the head element specified from the list and delete it + //- Remove the head element from the list and delete the pointer bool eraseHead(); - //- Remove the specified element from the list and delete it + //- Clear the contents of the list void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + void transfer(LPtrList<LListBase, T>&); + // Member operators diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C index e5bd9c907ddad88c51c550a237e83d1223dcabdc..c7bb16c4e2a87b5191e0a47791c66a7b3a447cb0 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LPtrList/LPtrListIO.C @@ -29,16 +29,11 @@ License #include "Ostream.H" #include "INew.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // template<class LListBase, class T> template<class INew> -void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) +void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& iNew) { is.fatalCheck ( @@ -66,8 +61,8 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) { for (label i=0; i<s; i++) { - append(inewt(is).ptr()); - + append(iNew(is).ptr()); + is.fatalCheck ( "LPtrList<LListBase, T>::read(Istream&, const INew&) : " @@ -77,7 +72,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) } else { - T* tPtr = inewt(is).ptr(); + T* tPtr = iNew(is).ptr(); append(tPtr); is.fatalCheck @@ -85,7 +80,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) "LPtrList<LListBase, T>::read(Istream&, const INew&) : " "reading entry" ); - + for (label i=1; i<s; i++) { append(tPtr->clone().ptr()); @@ -120,7 +115,7 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) ) { is.putBack(lastToken); - append(inewt(is).ptr()); + append(iNew(is).ptr()); is >> lastToken; is.fatalCheck @@ -148,14 +143,14 @@ void LPtrList<LListBase, T>::read(Istream& is, const INew& inewt) template<class LListBase, class T> template<class INew> -LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& inewt) +Foam::LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& iNew) { - read(is, inewt); + read(is, iNew); } template<class LListBase, class T> -LPtrList<LListBase, T>::LPtrList(Istream& is) +Foam::LPtrList<LListBase, T>::LPtrList(Istream& is) { read(is, INew<T>()); } @@ -164,11 +159,10 @@ LPtrList<LListBase, T>::LPtrList(Istream& is) // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Istream& operator>>(Istream& is, LPtrList<LListBase, T>& L) +Foam::Istream& Foam::operator>>(Istream& is, LPtrList<LListBase, T>& L) { - // Anull list L.clear(); - + L.read(is, INew<T>()); return is; } @@ -177,19 +171,19 @@ Istream& operator>>(Istream& is, LPtrList<LListBase, T>& L) // * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * // template<class LListBase, class T> -Ostream& operator<<(Ostream& os, const LPtrList<LListBase, T>& slpl) +Foam::Ostream& Foam::operator<<(Ostream& os, const LPtrList<LListBase, T>& lst) { - // Write size of LPtrList - os << nl << slpl.size(); + // Write size + os << nl << lst.size(); // Write beginning of contents os << nl << token::BEGIN_LIST << nl; - // Write LPtrList contents + // Write contents for ( - typename LPtrList<LListBase, T>::const_iterator iter = slpl.begin(); - iter != slpl.end(); + typename LPtrList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -200,14 +194,9 @@ Ostream& operator<<(Ostream& os, const LPtrList<LListBase, T>& slpl) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const LPtrList&)"); + os.check("Ostream& operator<<(Ostream&, const LPtrList<LListBase, T>&)"); return os; } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.C index ab6392094ab17d866cdeecf920dcc162b9f69ecb..1c10434c9ac21e4fec97ea44dcbdd92f9f4665cb 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.C @@ -28,17 +28,12 @@ Description #include "UILList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class LListBase, class T> -UILList<LListBase, T>::UILList(const UILList<LListBase, T>& slpl) +Foam::UILList<LListBase, T>::UILList(const UILList<LListBase, T>& lst) { - for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) { append(&iter()); } @@ -48,22 +43,24 @@ UILList<LListBase, T>::UILList(const UILList<LListBase, T>& slpl) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class LListBase, class T> -void UILList<LListBase, T>::operator=(const UILList<LListBase, T>& slpl) +void Foam::UILList<LListBase, T>::operator=(const UILList<LListBase, T>& rhs) { LListBase::clear(); - for (const_iterator iter = slpl.begin(); iter != slpl.end(); ++iter) + for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter) { append(&iter()); } } -// Comparison for equality template<class LListBase, class T> -bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const +bool Foam::UILList<LListBase, T>::operator== +( + const UILList<LListBase, T>& rhs +) const { - if (this->size() != slpl.size()) + if (this->size() != rhs.size()) { return false; } @@ -71,7 +68,7 @@ bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const bool equal = true; const_iterator iter1 = this->begin(); - const_iterator iter2 = slpl.begin(); + const_iterator iter2 = rhs.begin(); for (; iter1 != this->end(); ++iter1, ++iter2) { @@ -84,16 +81,15 @@ bool UILList<LListBase, T>::operator==(const UILList<LListBase, T>& slpl) const // Comparison for inequality template<class LListBase, class T> -bool UILList<LListBase, T>::operator!=(const UILList<LListBase, T>& slpl) const +bool Foam::UILList<LListBase, T>::operator!= +( + const UILList<LListBase, T>& rhs +) const { - return !operator==(slpl); + return !operator==(rhs); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // #include "UILListIO.C" diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H index d10c1c3949d2003cbb6ea43d47260431cf9cdc1d..cab57ed3268a2b559da7bce189b9e696a4fc4b3e 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILList.H @@ -245,7 +245,7 @@ public: const T& operator*() { - return + return static_cast<const T&> (LListBase_const_iterator::operator*()); } @@ -266,7 +266,7 @@ public: // STL member operators //- Equality operation on ULists of the same type. - // Returns true when the ULists are elementwise equal + // Returns true when the ULists are element-wise equal // (using UList::value_type::operator==). Takes linear time. bool operator==(const UILList<LListBase, T>&) const; diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C index 62459551c642a80c68eefa0c500f74533f847b55..d3ce739772a8bfab6570815f89f20a10ed1bae55 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/UILList/UILListIO.C @@ -30,27 +30,22 @@ Description #include "Ostream.H" #include "token.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template<class LListBase, class T> -Ostream& operator<<(Ostream& os, const UILList<LListBase, T>& ill) +Foam::Ostream& Foam::operator<<(Ostream& os, const UILList<LListBase, T>& lst) { - // Write size of UILList - os << nl << ill.size(); + // Write size + os << nl << lst.size(); // Write beginning of contents os << nl << token::BEGIN_LIST << nl; - // Write UILList contents + // Write contents for ( - typename UILList<LListBase, T>::const_iterator iter = ill.begin(); - iter != ill.end(); + typename UILList<LListBase, T>::const_iterator iter = lst.begin(); + iter != lst.end(); ++iter ) { @@ -61,14 +56,9 @@ Ostream& operator<<(Ostream& os, const UILList<LListBase, T>& ill) os << token::END_LIST; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const UILList&)"); + os.check("Ostream& operator<<(Ostream&, const UILList<LListBase, T>&)"); return os; } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C index ba25e663b3bcc2974270a7d29a84e329e2819d3d..b3e21c42258df2e463ec246f110c6a336b7f78ac 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C @@ -32,17 +32,12 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -DLListBase::iterator DLListBase::endIter +Foam::DLListBase::iterator Foam::DLListBase::endIter ( const_cast<DLListBase&>(static_cast<const DLListBase&>(DLListBase())) ); -DLListBase::const_iterator DLListBase::endConstIter +Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter ( static_cast<const DLListBase&>(DLListBase()), reinterpret_cast<const link*>(NULL) @@ -51,7 +46,7 @@ DLListBase::const_iterator DLListBase::endConstIter // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void DLListBase::insert(DLListBase::link* a) +void Foam::DLListBase::insert(DLListBase::link* a) { nElmts_++; @@ -71,7 +66,7 @@ void DLListBase::insert(DLListBase::link* a) } -void DLListBase::append(DLListBase::link* a) +void Foam::DLListBase::append(DLListBase::link* a) { nElmts_++; @@ -91,7 +86,7 @@ void DLListBase::append(DLListBase::link* a) } -bool DLListBase::swapUp(DLListBase::link* a) +bool Foam::DLListBase::swapUp(DLListBase::link* a) { if (first_ != a) { @@ -132,7 +127,7 @@ bool DLListBase::swapUp(DLListBase::link* a) } -bool DLListBase::swapDown(DLListBase::link* a) +bool Foam::DLListBase::swapDown(DLListBase::link* a) { if (last_ != a) { @@ -173,7 +168,7 @@ bool DLListBase::swapDown(DLListBase::link* a) } -DLListBase::link* DLListBase::removeHead() +Foam::DLListBase::link* Foam::DLListBase::removeHead() { nElmts_--; @@ -197,7 +192,7 @@ DLListBase::link* DLListBase::removeHead() } -DLListBase::link* DLListBase::remove(DLListBase::link* l) +Foam::DLListBase::link* Foam::DLListBase::remove(DLListBase::link* l) { nElmts_--; @@ -229,7 +224,7 @@ DLListBase::link* DLListBase::remove(DLListBase::link* l) } -DLListBase::link* DLListBase::replace +Foam::DLListBase::link* Foam::DLListBase::replace ( DLListBase::link* oldLink, DLListBase::link* newLink @@ -266,8 +261,4 @@ DLListBase::link* DLListBase::replace } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index 8fd2c55bc19592d8f3caf2876efccc29b5aa5e16..33df2b87c711a76b3e6517a7e106947490f735ef 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -167,6 +167,9 @@ public: //- Clear the list inline void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + inline void transfer(DLListBase&); // STL iterator diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H index eb9c00d3f8c5da40d0cfd3616476973e1ba0c2d8..a9414fa3876c6adaacabaf664043694bac9f357d 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H @@ -26,21 +26,16 @@ License #include "error.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -inline DLListBase::link::link() +inline Foam::DLListBase::link::link() : prev_(0), next_(0) {} -inline DLListBase::DLListBase() +inline Foam::DLListBase::DLListBase() : first_(0), last_(0), @@ -48,7 +43,7 @@ inline DLListBase::DLListBase() {} -inline DLListBase::DLListBase(link* a) +inline Foam::DLListBase::DLListBase(link* a) : first_(a), last_(a), @@ -61,32 +56,33 @@ inline DLListBase::DLListBase(link* a) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -inline DLListBase::~DLListBase() +inline Foam::DLListBase::~DLListBase() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline bool DLListBase::link::registered() const +inline bool Foam::DLListBase::link::registered() const { return prev_ != 0 && next_ != 0; } -inline void DLListBase::link::deregister() +inline void Foam::DLListBase::link::deregister() { prev_ = 0; next_ = 0; } -inline label DLListBase::size() const +inline Foam::label Foam::DLListBase::size() const { return nElmts_; } -inline DLListBase::link* DLListBase::first() +inline Foam::DLListBase::link* +Foam::DLListBase::first() { if (!nElmts_) { @@ -98,7 +94,8 @@ inline DLListBase::link* DLListBase::first() } -inline const DLListBase::link* DLListBase::first() const +inline const Foam::DLListBase::link* +Foam::DLListBase::first() const { if (!nElmts_) { @@ -110,7 +107,8 @@ inline const DLListBase::link* DLListBase::first() const } -inline DLListBase::link* DLListBase::last() +inline Foam::DLListBase::link* +Foam::DLListBase::last() { if (!nElmts_) { @@ -122,7 +120,8 @@ inline DLListBase::link* DLListBase::last() } -inline const DLListBase::link* DLListBase::last() const +inline const Foam::DLListBase::link* +Foam::DLListBase::last() const { if (!nElmts_) { @@ -134,21 +133,36 @@ inline const DLListBase::link* DLListBase::last() const } -inline void DLListBase::clear() +inline void Foam::DLListBase::clear() { - nElmts_ = 0; first_ = 0; - last_ = 0; + last_ = 0; + nElmts_ = 0; } -inline DLListBase::link* DLListBase::remove(DLListBase::iterator& it) +inline void Foam::DLListBase::transfer(DLListBase& lst) +{ + first_ = lst.first_; + last_ = lst.last_; + nElmts_ = lst.nElmts_; + + lst.clear(); +} + + +inline Foam::DLListBase::link* +Foam::DLListBase::remove +( + DLListBase::iterator& it +) { return remove(it.curElmt_); } -inline DLListBase::link* DLListBase::replace +inline Foam::DLListBase::link* +Foam::DLListBase::replace ( DLListBase::iterator& oldIter, DLListBase::link* newLink @@ -160,7 +174,7 @@ inline DLListBase::link* DLListBase::replace // * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * // -inline DLListBase::iterator::iterator(DLListBase& s, link* elmt) +inline Foam::DLListBase::iterator::iterator(DLListBase& s, link* elmt) : curList_(s), curElmt_(elmt), @@ -168,7 +182,7 @@ inline DLListBase::iterator::iterator(DLListBase& s, link* elmt) {} -inline DLListBase::iterator::iterator(DLListBase& s) +inline Foam::DLListBase::iterator::iterator(DLListBase& s) : curList_(s), curElmt_(NULL), @@ -176,32 +190,34 @@ inline DLListBase::iterator::iterator(DLListBase& s) {} -inline void DLListBase::iterator::operator=(const iterator& iter) +inline void Foam::DLListBase::iterator::operator=(const iterator& iter) { curElmt_ = iter.curElmt_; curLink_ = iter.curLink_; } -inline bool DLListBase::iterator::operator==(const iterator& iter) const +inline bool Foam::DLListBase::iterator::operator==(const iterator& iter) const { return curElmt_ == iter.curElmt_; } -inline bool DLListBase::iterator::operator!=(const iterator& iter) const +inline bool Foam::DLListBase::iterator::operator!=(const iterator& iter) const { return curElmt_ != iter.curElmt_; } -inline DLListBase::link& DLListBase::iterator::operator*() +inline Foam::DLListBase::link& +Foam::DLListBase::iterator::operator*() { return *curElmt_; } -inline DLListBase::iterator& DLListBase::iterator::operator++() +inline Foam::DLListBase::iterator& +Foam::DLListBase::iterator::operator++() { // Check if the curElmt_ is the last element (if it points to itself) // or if the list is empty because the last element may have been removed @@ -219,7 +235,8 @@ inline DLListBase::iterator& DLListBase::iterator::operator++() } -inline DLListBase::iterator DLListBase::iterator::operator++(int) +inline Foam::DLListBase::iterator +Foam::DLListBase::iterator::operator++(int) { iterator tmp = *this; ++*this; @@ -227,7 +244,8 @@ inline DLListBase::iterator DLListBase::iterator::operator++(int) } -inline DLListBase::iterator DLListBase::begin() +inline Foam::DLListBase::iterator +Foam::DLListBase::begin() { if (size()) { @@ -240,7 +258,7 @@ inline DLListBase::iterator DLListBase::begin() } -inline const DLListBase::iterator& DLListBase::end() +inline const Foam::DLListBase::iterator& Foam::DLListBase::end() { return endIter; } @@ -248,7 +266,7 @@ inline const DLListBase::iterator& DLListBase::end() // * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * // -inline DLListBase::const_iterator::const_iterator +inline Foam::DLListBase::const_iterator::const_iterator ( const DLListBase& s, const link* elmt @@ -259,20 +277,23 @@ inline DLListBase::const_iterator::const_iterator {} -inline DLListBase::const_iterator::const_iterator(const iterator& iter) +inline Foam::DLListBase::const_iterator::const_iterator(const iterator& iter) : curList_(iter.curList_), curElmt_(iter.curElmt_) {} -inline void DLListBase::const_iterator::operator=(const const_iterator& iter) +inline void Foam::DLListBase::const_iterator::operator= +( + const const_iterator& iter +) { curElmt_ = iter.curElmt_; } -inline bool DLListBase::const_iterator::operator== +inline bool Foam::DLListBase::const_iterator::operator== ( const const_iterator& iter ) const @@ -281,7 +302,7 @@ inline bool DLListBase::const_iterator::operator== } -inline bool DLListBase::const_iterator::operator!= +inline bool Foam::DLListBase::const_iterator::operator!= ( const const_iterator& iter ) const @@ -290,13 +311,15 @@ inline bool DLListBase::const_iterator::operator!= } -inline const DLListBase::link& DLListBase::const_iterator::operator*() +inline const Foam::DLListBase::link& +Foam::DLListBase::const_iterator::operator*() { return *curElmt_; } -inline DLListBase::const_iterator& DLListBase::const_iterator::operator++() +inline Foam::DLListBase::const_iterator& +Foam::DLListBase::const_iterator::operator++() { if (curElmt_ == curList_.last_) { @@ -311,7 +334,8 @@ inline DLListBase::const_iterator& DLListBase::const_iterator::operator++() } -inline DLListBase::const_iterator DLListBase::const_iterator::operator++(int) +inline Foam::DLListBase::const_iterator +Foam::DLListBase::const_iterator::operator++(int) { const_iterator tmp = *this; ++*this; @@ -319,7 +343,8 @@ inline DLListBase::const_iterator DLListBase::const_iterator::operator++(int) } -inline DLListBase::const_iterator DLListBase::begin() const +inline Foam::DLListBase::const_iterator +Foam::DLListBase::begin() const { if (size()) { @@ -332,14 +357,11 @@ inline DLListBase::const_iterator DLListBase::begin() const } -inline const DLListBase::const_iterator& DLListBase::end() const +inline const Foam::DLListBase::const_iterator& +Foam::DLListBase::end() const { return endConstIter; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C index 0098ff685faeed240a195d1edd0517d6b92d916d..44e50a3666277007a7f69e45b877a9262ec5024f 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.C @@ -25,22 +25,16 @@ License \*---------------------------------------------------------------------------*/ #include "error.H" - #include "SLListBase.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -SLListBase::iterator SLListBase::endIter +Foam::SLListBase::iterator Foam::SLListBase::endIter ( const_cast<SLListBase&>(static_cast<const SLListBase&>(SLListBase())) ); -SLListBase::const_iterator SLListBase::endConstIter +Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter ( static_cast<const SLListBase&>(SLListBase()), reinterpret_cast<const link*>(NULL) @@ -49,7 +43,7 @@ SLListBase::const_iterator SLListBase::endConstIter // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void SLListBase::insert(SLListBase::link* a) +void Foam::SLListBase::insert(SLListBase::link* a) { nElmts_++; @@ -66,7 +60,7 @@ void SLListBase::insert(SLListBase::link* a) } -void SLListBase::append(SLListBase::link* a) +void Foam::SLListBase::append(SLListBase::link* a) { nElmts_++; @@ -82,7 +76,7 @@ void SLListBase::append(SLListBase::link* a) } -SLListBase::link* SLListBase::removeHead() +Foam::SLListBase::link* Foam::SLListBase::removeHead() { nElmts_--; @@ -108,7 +102,7 @@ SLListBase::link* SLListBase::removeHead() } -SLListBase::link* SLListBase::remove(SLListBase::link* it) +Foam::SLListBase::link* Foam::SLListBase::remove(SLListBase::link* it) { SLListBase::iterator iter = begin(); SLListBase::link *prev = &(*iter); @@ -143,8 +137,4 @@ SLListBase::link* SLListBase::remove(SLListBase::link* it) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H index cfd8afe4a902a72b65fb72ac96bcd1c958982423..f802e6914297e6110498d54c04a64682fc2ba261 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBase.H @@ -152,6 +152,9 @@ public: //- Clear the list inline void clear(); + //- Transfer the contents of the argument into this List + // and annull the argument list. + inline void transfer(SLListBase&); // STL iterator diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H index 3a1125924bc52cf9da74d8c11eba13bb8274bf3f..594fc6f098f151e8fde2397ae65cbc613e9cdc49 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/SLListBase/SLListBaseI.H @@ -29,33 +29,28 @@ Description #include "error.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -inline SLListBase::link::link() +inline Foam::SLListBase::link::link() : next_(0) {} -inline SLListBase::link::link(link* p) +inline Foam::SLListBase::link::link(link* p) : next_(p) {} -inline SLListBase::SLListBase() +inline Foam::SLListBase::SLListBase() : last_(0), nElmts_(0) {} -inline SLListBase::SLListBase(link* a) +inline Foam::SLListBase::SLListBase(link* a) : last_(a->next_ = a), nElmts_(1) @@ -64,19 +59,20 @@ inline SLListBase::SLListBase(link* a) // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -inline SLListBase::~SLListBase() +inline Foam::SLListBase::~SLListBase() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline label SLListBase::size() const +inline Foam::label Foam::SLListBase::size() const { return nElmts_; } -inline SLListBase::link* SLListBase::first() +inline Foam::SLListBase::link* +Foam::SLListBase::first() { if (!nElmts_) { @@ -88,7 +84,8 @@ inline SLListBase::link* SLListBase::first() } -inline const SLListBase::link* SLListBase::first() const +inline const Foam::SLListBase::link* +Foam::SLListBase::first() const { if (!nElmts_) { @@ -100,7 +97,8 @@ inline const SLListBase::link* SLListBase::first() const } -inline SLListBase::link* SLListBase::last() +inline Foam::SLListBase::link* +Foam::SLListBase::last() { if (!nElmts_) { @@ -112,7 +110,8 @@ inline SLListBase::link* SLListBase::last() } -inline const SLListBase::link* SLListBase::last() const +inline const Foam::SLListBase::link* +Foam::SLListBase::last() const { if (!nElmts_) { @@ -124,14 +123,26 @@ inline const SLListBase::link* SLListBase::last() const } -inline void SLListBase::clear() +inline void Foam::SLListBase::clear() { - nElmts_ = 0; last_ = 0; + nElmts_ = 0; } -inline SLListBase::link* SLListBase::remove(SLListBase::iterator& it) +inline void Foam::SLListBase::transfer(SLListBase& lst) +{ + last_ = lst.last_; + nElmts_ = lst.nElmts_; + + lst.clear(); +} + + +inline Foam::SLListBase::link* Foam::SLListBase::remove +( + SLListBase::iterator& it +) { return remove(it.curElmt_); } @@ -139,7 +150,7 @@ inline SLListBase::link* SLListBase::remove(SLListBase::iterator& it) // * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * // -inline SLListBase::iterator::iterator(SLListBase& s, link* elmt) +inline Foam::SLListBase::iterator::iterator(SLListBase& s, link* elmt) : curList_(s), curElmt_(elmt), @@ -147,7 +158,7 @@ inline SLListBase::iterator::iterator(SLListBase& s, link* elmt) {} -inline SLListBase::iterator::iterator(SLListBase& s) +inline Foam::SLListBase::iterator::iterator(SLListBase& s) : curList_(s), curElmt_(NULL), @@ -155,32 +166,32 @@ inline SLListBase::iterator::iterator(SLListBase& s) {} -inline void SLListBase::iterator::operator=(const iterator& iter) +inline void Foam::SLListBase::iterator::operator=(const iterator& iter) { curElmt_ = iter.curElmt_; curLink_ = iter.curLink_; } -inline bool SLListBase::iterator::operator==(const iterator& iter) const +inline bool Foam::SLListBase::iterator::operator==(const iterator& iter) const { return curElmt_ == iter.curElmt_; } -inline bool SLListBase::iterator::operator!=(const iterator& iter) const +inline bool Foam::SLListBase::iterator::operator!=(const iterator& iter) const { return curElmt_ != iter.curElmt_; } -inline SLListBase::link& SLListBase::iterator::operator*() +inline Foam::SLListBase::link& Foam::SLListBase::iterator::operator*() { return *curElmt_; } -inline SLListBase::iterator& SLListBase::iterator::operator++() +inline Foam::SLListBase::iterator& Foam::SLListBase::iterator::operator++() { if (curElmt_ == curList_.last_ || curList_.last_ == 0) { @@ -196,7 +207,8 @@ inline SLListBase::iterator& SLListBase::iterator::operator++() } -inline SLListBase::iterator SLListBase::iterator::operator++(int) +inline Foam::SLListBase::iterator +Foam::SLListBase::iterator::operator++(int) { iterator tmp = *this; ++*this; @@ -204,7 +216,8 @@ inline SLListBase::iterator SLListBase::iterator::operator++(int) } -inline SLListBase::iterator SLListBase::begin() +inline Foam::SLListBase::iterator +Foam::SLListBase::begin() { if (size()) { @@ -217,7 +230,8 @@ inline SLListBase::iterator SLListBase::begin() } -inline const SLListBase::iterator& SLListBase::end() +inline const Foam::SLListBase::iterator& +Foam::SLListBase::end() { return endIter; } @@ -225,7 +239,7 @@ inline const SLListBase::iterator& SLListBase::end() // * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * // -inline SLListBase::const_iterator::const_iterator +inline Foam::SLListBase::const_iterator::const_iterator ( const SLListBase& s, const link* elmt @@ -236,20 +250,23 @@ inline SLListBase::const_iterator::const_iterator {} -inline SLListBase::const_iterator::const_iterator(const iterator& iter) +inline Foam::SLListBase::const_iterator::const_iterator(const iterator& iter) : curList_(iter.curList_), curElmt_(iter.curElmt_) {} -inline void SLListBase::const_iterator::operator=(const const_iterator& iter) +inline void Foam::SLListBase::const_iterator::operator= +( + const const_iterator& iter +) { curElmt_ = iter.curElmt_; } -inline bool SLListBase::const_iterator::operator== +inline bool Foam::SLListBase::const_iterator::operator== ( const const_iterator& iter ) const @@ -258,7 +275,7 @@ inline bool SLListBase::const_iterator::operator== } -inline bool SLListBase::const_iterator::operator!= +inline bool Foam::SLListBase::const_iterator::operator!= ( const const_iterator& iter ) const @@ -267,13 +284,15 @@ inline bool SLListBase::const_iterator::operator!= } -inline const SLListBase::link& SLListBase::const_iterator::operator*() +inline const Foam::SLListBase::link& +Foam::SLListBase::const_iterator::operator*() { return *curElmt_; } -inline SLListBase::const_iterator& SLListBase::const_iterator::operator++() +inline Foam::SLListBase::const_iterator& +Foam::SLListBase::const_iterator::operator++() { if (curElmt_ == curList_.last_) { @@ -288,7 +307,8 @@ inline SLListBase::const_iterator& SLListBase::const_iterator::operator++() } -inline SLListBase::const_iterator SLListBase::const_iterator::operator++(int) +inline Foam::SLListBase::const_iterator +Foam::SLListBase::const_iterator::operator++(int) { const_iterator tmp = *this; ++*this; @@ -296,7 +316,8 @@ inline SLListBase::const_iterator SLListBase::const_iterator::operator++(int) } -inline SLListBase::const_iterator SLListBase::begin() const +inline Foam::SLListBase::const_iterator +Foam::SLListBase::begin() const { if (size()) { @@ -309,14 +330,11 @@ inline SLListBase::const_iterator SLListBase::begin() const } -inline const SLListBase::const_iterator& SLListBase::end() const +inline const Foam::SLListBase::const_iterator& +Foam::SLListBase::end() const { return endConstIter; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/user/DLList/DLList.H b/src/OpenFOAM/containers/LinkedLists/user/DLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/DLList/DLList.H rename to src/OpenFOAM/containers/LinkedLists/user/DLList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/DLPtrList/DLPtrList.H b/src/OpenFOAM/containers/LinkedLists/user/DLPtrList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/DLPtrList/DLPtrList.H rename to src/OpenFOAM/containers/LinkedLists/user/DLPtrList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/FIFOStack/FIFOStack.H b/src/OpenFOAM/containers/LinkedLists/user/FIFOStack.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/FIFOStack/FIFOStack.H rename to src/OpenFOAM/containers/LinkedLists/user/FIFOStack.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/IDLList/IDLList.H b/src/OpenFOAM/containers/LinkedLists/user/IDLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/IDLList/IDLList.H rename to src/OpenFOAM/containers/LinkedLists/user/IDLList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/ISLList/ISLList.H b/src/OpenFOAM/containers/LinkedLists/user/ISLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/ISLList/ISLList.H rename to src/OpenFOAM/containers/LinkedLists/user/ISLList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/LIFOStack/LIFOStack.H b/src/OpenFOAM/containers/LinkedLists/user/LIFOStack.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/LIFOStack/LIFOStack.H rename to src/OpenFOAM/containers/LinkedLists/user/LIFOStack.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/SLList/SLList.H b/src/OpenFOAM/containers/LinkedLists/user/SLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/SLList/SLList.H rename to src/OpenFOAM/containers/LinkedLists/user/SLList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/SLPtrList/SLPtrList.H b/src/OpenFOAM/containers/LinkedLists/user/SLPtrList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/SLPtrList/SLPtrList.H rename to src/OpenFOAM/containers/LinkedLists/user/SLPtrList.H diff --git a/src/OpenFOAM/containers/LinkedLists/user/UIDLList/UIDLList.H b/src/OpenFOAM/containers/LinkedLists/user/UIDLList.H similarity index 100% rename from src/OpenFOAM/containers/LinkedLists/user/UIDLList/UIDLList.H rename to src/OpenFOAM/containers/LinkedLists/user/UIDLList.H diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H index 90b78aabfc5123e65d58906f4461289b42d3674b..20425b8a7db0bf67d646aba77b687f468d49cab5 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -31,13 +31,22 @@ License template<class Stream> inline void Foam::IOobject::writeBanner(Stream& os, bool noHint) { - static bool spacesSet = false; + static bool spacesSet(false); static char spaces[40]; if (!spacesSet) { memset(spaces, ' ', 40); - spaces[38 - strlen(Foam::FOAMversion)] = '\0'; + + size_t len = strlen(Foam::FOAMversion); + if (len < 38) + { + spaces[38 - len] = '\0'; + } + else + { + spaces[0] = '\0'; + } spacesSet = true; } @@ -56,8 +65,8 @@ inline void Foam::IOobject::writeBanner(Stream& os, bool noHint) "| ========= | |\n" "| \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |\n" "| \\\\ / O peration | Version: " << FOAMversion << spaces << "|\n" - "| \\\\ / A nd | Web: http://www.OpenFOAM.org |\n" - "| \\\\/ M anipulation | |\n" + "| \\\\ / A nd | |\n" + "| \\\\/ M anipulation | www.OpenFOAM.org |\n" "\\*---------------------------------------------------------------------------*/\n"; } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C index 577494aa1cf435019fb43d7d770e5f511e31e987..98752700a1be835cbea82c1c9a29e6a0985ba7c9 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C @@ -32,22 +32,22 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//- Write keyType -Foam::Ostream& Foam::Ostream::write(const keyType& s) +// Write keyType +Foam::Ostream& Foam::Ostream::write(const keyType& kw) { - // Write as word? - if (s.isWildCard()) + // Write as word or string + if (kw.isPattern()) { - return write(static_cast<const string&>(s)); + return write(static_cast<const string&>(kw)); } else { - return write(static_cast<const word&>(s)); + return write(static_cast<const word&>(kw)); } } -//- Decrememt the indent level +// Decrement the indent level void Foam::Ostream::decrIndent() { if (indentLevel_ == 0) @@ -62,15 +62,26 @@ void Foam::Ostream::decrIndent() } -// Write the keyword to the Ostream followed by appropriate indentation -Foam::Ostream& Foam::Ostream::writeKeyword(const Foam::keyType& keyword) +// Write the keyword followed by appropriate indentation +Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw) { indent(); - write(keyword); + write(kw); - label nSpaces = max(entryIndentation_ - label(keyword.size()), 1); + label nSpaces = entryIndentation_ - label(kw.size()); - for (label i=0; i<nSpaces; i++) + // pattern is surrounded by quotes + if (kw.isPattern()) + { + nSpaces -= 2; + } + + if (nSpaces < 1) + { + nSpaces = 1; + } + + while (nSpaces--) { write(char(token::SPACE)); } diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index 6dc7df259aef54ecbc44da928f4f99f0f89883f7..32fe3fd7f5db00bda7a83729dfed14fc4b141a4f 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -60,12 +60,11 @@ protected: //- Number of spaces per indent level static const unsigned short indentSize_ = 4; - //- Current indent level - unsigned short indentLevel_; - //- Indentation of the entry from the start of the keyword static const unsigned short entryIndentation_ = 16; + //- Current indent level + unsigned short indentLevel_; public: @@ -148,9 +147,8 @@ public: //- Decrememt the indent level void decrIndent(); - //- Write the keyword to the Ostream followed by - // appropriate indentation - Ostream& writeKeyword(const keyType& keyword); + //- Write the keyword followed by an appropriate indentation + Ostream& writeKeyword(const keyType&); // Stream state functions diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H index 6041ba202a5caa6773a5a98677d4f11572cf22d2..386781c35bb96d84631e29494e9b7cc93a036abd 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H @@ -47,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class OPstream Declaration + Class OPstream Declaration \*---------------------------------------------------------------------------*/ class OPstream @@ -160,7 +160,7 @@ public: void flush() {} - //- Add '\n' and flush stream + //- Add newline and flush stream void endl() {} diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H index cd3a03ec0cb4531299379539835d86fec7cc74c5..9fd9d988246f185df2d8cfb1b87813062853cc21 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H @@ -48,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class OSstream Declaration + Class OSstream Declaration \*---------------------------------------------------------------------------*/ class OSstream @@ -162,20 +162,20 @@ public: //- Flush stream virtual void flush(); - //- Add '\n' and flush stream + //- Add newline and flush stream virtual void endl(); //- Get width of output field virtual int width() const; //- Set width of output field (and return old width) - virtual int width(const int w); + virtual int width(const int); //- Get precision of output field virtual int precision() const; //- Set precision of output field (and return old precision) - virtual int precision(const int p); + virtual int precision(const int); // Print diff --git a/src/OpenFOAM/db/Time/timeSelector.C b/src/OpenFOAM/db/Time/timeSelector.C index 002a0b5beb8910a717e1454e2ce689225ad8bbea..bace90c28ae61bd04d1a16b22ec7559e70fa5949 100644 --- a/src/OpenFOAM/db/Time/timeSelector.C +++ b/src/OpenFOAM/db/Time/timeSelector.C @@ -131,7 +131,7 @@ void Foam::timeSelector::addOptions argList::validOptions.insert("zeroTime", ""); } argList::validOptions.insert("noZero", ""); - argList::validOptions.insert("time", "time"); + argList::validOptions.insert("time", "ranges"); argList::validOptions.insert("latestTime", ""); } @@ -167,28 +167,40 @@ Foam::List<Foam::instant> 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::instant> 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 7d1f15fda1dd18115029487823a587cb2c84272f..6afa92ee0601a346f0e8cb9180029329bdc7b019 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 265a2944cb03bb1f4c2b5f9024ad2c644002d885..5d0ee2af6581447c7151a04b4864392d9a8973ce 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<entry*>::const_iterator& wcLink, - DLList<autoPtr<regularExpression> >::const_iterator& reLink + DLList<autoPtr<regExp> >::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<entry*>::iterator& wcLink, - DLList<autoPtr<regularExpression> >::iterator& reLink + DLList<autoPtr<regExp> >::iterator& reLink ) { - if (wildCardEntries_.size() > 0) + if (patternEntries_.size() > 0) { - while (wcLink != wildCardEntries_.end()) + while (wcLink != patternEntries_.end()) { - if (!wildCardMatch && wcLink()->keyword() == Keyword) - { - return true; - } - else if (wildCardMatch && reLink()->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<regularExpression> - ( - new regularExpression(iter().keyword()) - ) + autoPtr<regExp>(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<regularExpression> - ( - new regularExpression(iter().keyword()) - ) + autoPtr<regExp>(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<entry*>::const_iterator wcLink = wildCardEntries_.begin(); - DLList<autoPtr<regularExpression> >::const_iterator reLink = - wildCardRegexps_.begin(); + DLList<entry*>::const_iterator wcLink = patternEntries_.begin(); + DLList<autoPtr<regExp> >::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<entry*>::const_iterator iter = hashedEntries_.find(keyword); if (iter == hashedEntries_.end()) { - if (wildCardMatch && wildCardEntries_.size() > 0) + if (patternMatch && patternEntries_.size() > 0) { DLList<entry*>::const_iterator wcLink = - wildCardEntries_.begin(); - DLList<autoPtr<regularExpression> >::const_iterator reLink = - wildCardRegexps_.begin(); + patternEntries_.begin(); + DLList<autoPtr<regExp> >::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<entry*>::iterator iter = hashedEntries_.find(keyword); if (iter == hashedEntries_.end()) { - if (wildCardMatch && wildCardEntries_.size() > 0) + if (patternMatch && patternEntries_.size() > 0) { DLList<entry*>::iterator wcLink = - wildCardEntries_.begin(); - DLList<autoPtr<regularExpression> >::iterator reLink = - wildCardRegexps_.begin(); - // Find in wildcards using regular expressions only - if (findInWildcards(wildCardMatch, keyword, wcLink, reLink)) + patternEntries_.begin(); + DLList<autoPtr<regExp> >::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,26 @@ Foam::wordList Foam::dictionary::toc() const { wordList keys(size()); - label i = 0; + label nKeys = 0; + for + ( + IDLList<entry>::const_iterator iter = begin(); + iter != end(); + ++iter + ) + { + keys[nKeys++] = iter().keyword(); + } + + return keys; +} + + +Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const +{ + List<keyType> keys(size()); + + label nKeys = 0; for ( IDLList<entry>::const_iterator iter = begin(); @@ -447,8 +458,12 @@ Foam::wordList Foam::dictionary::toc() const ++iter ) { - keys[i++] = iter().keyword(); + if (iter().keyword().isPattern() ? patterns : !patterns) + { + keys[nKeys++] = iter().keyword(); + } } + keys.setSize(nKeys); return keys; } @@ -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<regularExpression> - ( - new regularExpression(entryPtr->keyword()) - ) + autoPtr<regExp>(new regExp(entryPtr->keyword())) ); } @@ -514,15 +526,12 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry) entryPtr->name() = name_ + "::" + entryPtr->keyword(); IDLList<entry>::append(entryPtr); - if (entryPtr->keyword().isWildCard()) + if (entryPtr->keyword().isPattern()) { - wildCardEntries_.insert(entryPtr); - wildCardRegexps_.insert + patternEntries_.insert(entryPtr); + patternRegexps_.insert ( - autoPtr<regularExpression> - ( - new regularExpression(entryPtr->keyword()) - ) + autoPtr<regExp>(new regExp(entryPtr->keyword())) ); } @@ -612,17 +621,15 @@ bool Foam::dictionary::remove(const word& Keyword) if (iter != hashedEntries_.end()) { - // Delete from wildcards first - DLList<entry*>::iterator wcLink = - wildCardEntries_.begin(); - DLList<autoPtr<regularExpression> >::iterator reLink = - wildCardRegexps_.begin(); + // Delete from patterns first + DLList<entry*>::iterator wcLink = patternEntries_.begin(); + DLList<autoPtr<regExp> >::iterator reLink = patternRegexps_.begin(); - // Find in wildcards using exact match only - if (findInWildcards(false, Keyword, wcLink, reLink)) + // Find in pattern using exact match only + if (findInPatterns(false, Keyword, wcLink, reLink)) { - wildCardEntries_.remove(wcLink); - wildCardRegexps_.remove(reLink); + patternEntries_.remove(wcLink); + patternRegexps_.remove(reLink); } IDLList<entry>::remove(iter()); @@ -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<entry*>::iterator wcLink = - wildCardEntries_.begin(); - DLList<autoPtr<regularExpression> >::iterator reLink = - wildCardRegexps_.begin(); + patternEntries_.begin(); + DLList<autoPtr<regExp> >::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<entry>::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<regularExpression> - ( - new regularExpression(newKeyword) - ) + autoPtr<regExp>(new regExp(newKeyword)) ); } @@ -789,6 +793,8 @@ void Foam::dictionary::clear() { IDLList<entry>::clear(); hashedEntries_.clear(); + patternEntries_.clear(); + patternRegexps_.clear(); } diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index b1d0d186f65c44c4026b7c06489b8164f0b1f277..a4020b6f32f6d2c0aa5bddb54eceae944c385c0c 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -27,12 +27,12 @@ Class Description A list of keyword definitions, which are a keyword followed by any number - of values (e.g. words and numbers). The keywords can represent wildcards + of values (e.g. words and numbers). The keywords can represent patterns which are matched using Posix regular expressions. The general order for - searching is + searching is as follows: - exact match - - wildcard match (in reverse order) - - optional recursion into subdictionaries + - pattern match (in reverse order) + - optional recursion into the enclosing (parent) dictionaries The dictionary class is the base class for IOdictionary. It also serves as a bootstrap dictionary for the objectRegistry data @@ -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<entry*> wildCardEntries_; + //- Entries of matching patterns + DLList<entry*> patternEntries_; - //- Wildcard precompiled regex - DLList<autoPtr<regularExpression> > wildCardRegexps_; + //- Patterns as precompiled regular expressions + DLList<autoPtr<regExp> > patternRegexps_; // Private Member Functions - //- Search wildcard table either for exact match or for regular - // expression match. - bool findInWildcards + //- Search patterns table for exact match or regular expression match + bool findInPatterns ( - const bool wildCardMatch, + const bool patternMatch, const word& Keyword, DLList<entry*>::const_iterator& wcLink, - DLList<autoPtr<regularExpression> >::const_iterator& reLink + DLList<autoPtr<regExp> >::const_iterator& reLink ) const; - //- Search wildcard table either for exact match or for regular - // expression match. - bool findInWildcards + //- Search patterns table for exact match or regular expression match + bool findInPatterns ( - const bool wildCardMatch, + const bool patternMatch, const word& Keyword, DLList<entry*>::iterator& wcLink, - DLList<autoPtr<regularExpression> >::iterator& reLink + DLList<autoPtr<regExp> >::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<dictionary> clone() const; //- Construct top-level dictionary on freestore from Istream - static Foam::autoPtr<dictionary> New(Istream& is); + static Foam::autoPtr<dictionary> 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<class T> T lookupOrDefault ( const word&, const T&, bool recursive=false, - bool wildCardMatch=true + bool patternMatch=true ) const; //- Find and return a T, if not found return the given // default value, and add to dictionary. - // If recursive search parent dictionaries + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. template<class T> T lookupOrAddDefault ( const word&, const T&, bool recursive=false, - bool wildCardMatch=true + bool patternMatch=true ); //- Find an entry if present, and assign to T - // Returns true if the entry was found + // Returns true if the entry was found. + // If recursive, search parent dictionaries. + // If patternMatch, use regular expressions. template<class T> bool readIfPresent ( const word&, T&, bool recursive=false, - bool wildCardMatch=true + bool patternMatch=true ) const; //- Check if entry is a sub-dictionary @@ -305,6 +308,9 @@ public: //- Return the table of contents wordList toc() const; + //- Return the list of available keys or patterns + List<keyType> keys(bool patterns=false) const; + // Editing //- Add a new entry @@ -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<class T> - 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<class T> - 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 1909f4851ddc4bbdae66a9586965102ef613d7a9..2b86c53d01329de349ee0277248c4092510687a4 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H +++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H @@ -74,20 +74,20 @@ public: // Constructors //- Construct from the parent dictionary and Istream - dictionaryEntry(const dictionary& parentDict, Istream& is); + dictionaryEntry(const dictionary& parentDict, Istream&); //- Construct from the keyword, parent dictionary and a Istream dictionaryEntry ( - const keyType& keyword, + const keyType&, const dictionary& parentDict, - Istream& is + Istream& ); //- Construct from the keyword, parent dictionary and a dictionary dictionaryEntry ( - const keyType& keyword, + const keyType&, const dictionary& parentDict, const dictionary& dict ); @@ -96,7 +96,7 @@ public: dictionaryEntry ( const dictionary& parentDict, - const dictionaryEntry& dictEnt + const dictionaryEntry& ); autoPtr<entry> clone(const dictionary& parentDict) const @@ -158,10 +158,8 @@ public: }; -#if defined (__GNUC__) template<> -#endif -Ostream& operator<<(Ostream& os, const InfoProxy<dictionaryEntry>& ip); +Ostream& operator<<(Ostream&, const InfoProxy<dictionaryEntry>&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index cb04194915c19fa99d86dfe1ed32ab9d82e7274c..35746ea66561f6206ddbdfb36a3130319d433ad7 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 a47a97681472c2d47d42b035f7504c9171a5ffa7..65883ba535be0bc8bda2fd444635c4e0d927534b 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryTemplates.C +++ b/src/OpenFOAM/db/dictionary/dictionaryTemplates.C @@ -35,18 +35,18 @@ T Foam::dictionary::lookupOrDefault const word& keyword, const T& deflt, bool recursive, - bool wildCardMatch + bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch); + const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); - if (entryPtr == NULL) + if (entryPtr) { - return deflt; + return pTraits<T>(entryPtr->stream()); } else { - return pTraits<T>(entryPtr->stream()); + return deflt; } } @@ -57,19 +57,19 @@ T Foam::dictionary::lookupOrAddDefault const word& keyword, const T& deflt, bool recursive, - bool wildCardMatch + bool patternMatch ) { - const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch); + const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch); - if (entryPtr == NULL) + if (entryPtr) { - add(new primitiveEntry(keyword, deflt)); - return deflt; + return pTraits<T>(entryPtr->stream()); } else { - return pTraits<T>(entryPtr->stream()); + add(new primitiveEntry(keyword, deflt)); + return deflt; } } @@ -80,19 +80,19 @@ bool Foam::dictionary::readIfPresent const word& k, T& val, bool recursive, - bool wildCardMatch + bool patternMatch ) const { - const entry* entryPtr = lookupEntryPtr(k, recursive, wildCardMatch); + const entry* entryPtr = lookupEntryPtr(k, recursive, patternMatch); - if (entryPtr == NULL) + if (entryPtr) { - return false; + entryPtr->stream() >> val; + return true; } else { - entryPtr->stream() >> val; - return true; + return false; } } diff --git a/src/OpenFOAM/db/dictionary/entry/entry.H b/src/OpenFOAM/db/dictionary/entry/entry.H index 5ed8b929b6993d64db10a3ebce69047bdb83c64f..61eafc7c8a91bbd27934083befb5c6ec2a97ac80 100644 --- a/src/OpenFOAM/db/dictionary/entry/entry.H +++ b/src/OpenFOAM/db/dictionary/entry/entry.H @@ -92,20 +92,20 @@ public: //- Construct on freestore as copy with reference to the // dictionary the copy belongs to - virtual Foam::autoPtr<entry> clone + virtual autoPtr<entry> clone ( const dictionary& parentDict ) const = 0; //- Construct on freestore as copy // Note: the parent directory is set to dictionary::null - virtual Foam::autoPtr<entry> clone() const; + virtual autoPtr<entry> clone() const; //- Construct from Istream and insert into dictionary static bool New(dictionary& parentDict, Istream& is); //- Construct on freestore from Istream and return - static Foam::autoPtr<entry> New(Istream& is); + static autoPtr<entry> New(Istream& is); // Destructor diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H index 86d8afd61daad8a3d4a1dce09fabd93fd0f1a75a..1e5858abafcc1b5fc2ec9714cfb81c296c80a172 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H @@ -75,32 +75,32 @@ public: void append ( const token& currToken, - const dictionary& dict, - Istream& is + const dictionary&, + Istream& ); //- Append the given tokens starting at the current tokenIndex - void append(const tokenList& varTokens); + void append(const tokenList&); //- Expand the given variable (keyword starts with $) - bool expandVariable(const word& keyword, const dictionary& dict); + bool expandVariable(const word&, const dictionary&); //- Expand the given function (keyword starts with #) bool expandFunction ( - const word& keyword, - const dictionary& dict, - Istream& is + const word&, + const dictionary&, + Istream& ); //- Read tokens from the given stream - bool read(const dictionary& dict, Istream&); + bool read(const dictionary&, Istream&); //- Read the complete entry from the given stream - void readEntry(const dictionary& dict, Istream&); + void readEntry(const dictionary&, Istream&); //- Insert the given tokens at token i - void insert(const tokenList& varTokens, const label i); + void insert(const tokenList&, const label i); public: @@ -108,13 +108,13 @@ public: // Constructors //- Construct from keyword and a Istream - primitiveEntry(const keyType& keyword, Istream&); + primitiveEntry(const keyType&, Istream&); - //- Construct from keyword, parent dictionary and a Istream - primitiveEntry(const keyType& keyword, const dictionary&, Istream&); + //- Construct from keyword, parent dictionary and Istream + primitiveEntry(const keyType&, const dictionary& parentDict, Istream&); //- Construct from keyword and a ITstream - primitiveEntry(const keyType& keyword, const ITstream&); + primitiveEntry(const keyType&, const ITstream&); //- Construct from keyword and a token primitiveEntry(const keyType&, const token&); @@ -182,7 +182,7 @@ public: template<> -Ostream& operator<<(Ostream& os, const InfoProxy<primitiveEntry>& ip); +Ostream& operator<<(Ostream&, const InfoProxy<primitiveEntry>&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjectList/functionObjectList.C index 760cf83a2a51907a7dc1ae7ecc5ae06dbdabc5a1..8bb900edfd083eb66740c56ee0289a57a62f22e6 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjectList/functionObjectList.C @@ -27,6 +27,26 @@ License #include "functionObjectList.H" #include "Time.H" +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +Foam::functionObject* Foam::functionObjectList::remove(const word& key) +{ + functionObject* ptr = 0; + + // Find index of existing functionObject + HashTable<label>::iterator fnd = indices_.find(key); + + if (fnd != indices_.end()) + { + // remove the pointer from the old list + ptr = functions_.set(fnd(), 0).ptr(); + indices_.erase(fnd); + } + + return ptr; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjectList::functionObjectList @@ -35,24 +55,28 @@ Foam::functionObjectList::functionObjectList const bool execution ) : - HashPtrTable<functionObject>(), + functions_(), + indices_(), time_(t), - foDict_(t.controlDict()), - execution_(execution) + parentDict_(t.controlDict()), + execution_(execution), + updated_(false) {} Foam::functionObjectList::functionObjectList ( const Time& t, - const dictionary& foDict, + const dictionary& parentDict, const bool execution ) : - HashPtrTable<functionObject>(), + functions_(), + indices_(), time_(t), - foDict_(foDict), - execution_(execution) + parentDict_(parentDict), + execution_(execution), + updated_(false) {} @@ -66,52 +90,28 @@ Foam::functionObjectList::~functionObjectList() bool Foam::functionObjectList::start() { - if (execution_) - { - bool ok = false; - - if (foDict_.found("functions")) - { - HashPtrTable<functionObject> functions - ( - foDict_.lookup("functions"), - functionObject::iNew(time_) - ); - - transfer(functions); - - forAllIter(HashPtrTable<functionObject>, *this, iter) - { - ok = iter()->start() && ok; - } - } - - return ok; - } - else - { - return true; - } + return read(); } bool Foam::functionObjectList::execute() { + bool ok = true; + if (execution_) { - bool ok = false; - - forAllIter(HashPtrTable<functionObject>, *this, iter) + if (!updated_) { - ok = iter()->execute() && ok; + read(); } - return ok; - } - else - { - return true; + forAllIter(PtrList<functionObject>, functions_, iter) + { + ok = iter().execute() && ok; + } } + + return ok; } @@ -129,46 +129,108 @@ void Foam::functionObjectList::off() bool Foam::functionObjectList::read() { - bool read = false; + bool ok = true; + updated_ = execution_; + + // avoid reading/initializing if execution is off + if (!execution_) + { + return ok; + } - if (foDict_.found("functions")) + // Update existing and add new functionObjects + const entry* entryPtr = parentDict_.lookupEntryPtr("functions",false,false); + if (entryPtr) { - HashPtrTable<dictionary> functionDicts(foDict_.lookup("functions")); + PtrList<functionObject> newPtrs; + HashTable<label> newIndices; - // Update existing and add new functionObjects - forAllConstIter(HashPtrTable<dictionary>, functionDicts, iter) - { - if (found(iter.key())) - { - read = find(iter.key())()->read(*iter()) && read; - } - else - { - functionObject* functionObjectPtr = - functionObject::New(iter.key(), time_, *iter()).ptr(); + label nFunc = 0; - functionObjectPtr->start(); + if (entryPtr->isDict()) + { + // a dictionary of functionObjects + const dictionary& functionDicts = entryPtr->dict(); + newPtrs.setSize(functionDicts.size()); - insert(iter.key(), functionObjectPtr); + forAllConstIter(dictionary, functionDicts, iter) + { + // safety: + if (!iter().isDict()) + { + continue; + } + const word& key = iter().keyword(); + const dictionary& dict = iter().dict(); + + functionObject* objPtr = remove(key); + if (objPtr) + { + // existing functionObject + ok = objPtr->read(dict) && ok; + } + else + { + // new functionObject + objPtr = functionObject::New(key, time_, dict).ptr(); + ok = objPtr->start() && ok; + } + + newPtrs.set(nFunc, objPtr); + newIndices.insert(key, nFunc); + nFunc++; } } - - // Remove deleted functionObjects - forAllIter(HashPtrTable<functionObject>, *this, iter) + else { - if (!functionDicts.found(iter.key())) + // a list of functionObjects + PtrList<entry> functionDicts(entryPtr->stream()); + newPtrs.setSize(functionDicts.size()); + + forAllIter(PtrList<entry>, functionDicts, iter) { - erase(iter); + // safety: + if (!iter().isDict()) + { + continue; + } + const word& key = iter().keyword(); + const dictionary& dict = iter().dict(); + + functionObject* objPtr = remove(key); + if (objPtr) + { + // existing functionObject + ok = objPtr->read(dict) && ok; + } + else + { + // new functionObject + objPtr = functionObject::New(key, time_, dict).ptr(); + ok = objPtr->start() && ok; + } + + newPtrs.set(nFunc, objPtr); + newIndices.insert(key, nFunc); + nFunc++; } } + + // safety: + newPtrs.setSize(nFunc); + + // update PtrList of functionObjects + // also deletes existing, unused functionObjects + functions_.transfer(newPtrs); + indices_.transfer(newIndices); } else { - clear(); - read = true; + functions_.clear(); + indices_.clear(); } - return read; + return ok; } diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjectList/functionObjectList.H index 78462b653bef92507b97496d6b552c26cbc89cc4..1b0d51c066f8907504a7bf9ce96aaf14cc99eba6 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjectList/functionObjectList.H @@ -26,8 +26,8 @@ Class Foam::functionObjectList Description - List of function objects with execute function which is called for - each object. + List of function objects with execute() function that is called for each + object. See Also Foam::functionObject and Foam::OutputFilterFunctionObject @@ -41,7 +41,8 @@ SourceFiles #define functionObjectList_H #include "functionObject.H" -#include "HashPtrTable.H" +#include "HashTable.H" +#include "PtrList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,26 +50,41 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class functionObjectList Declaration + Class functionObjectList Declaration \*---------------------------------------------------------------------------*/ class functionObjectList -: - public HashPtrTable<functionObject> { // Private data + //- A list of function objects + // Avoid 'is-a' relationship for protection + PtrList<functionObject> functions_; + + //- Quick lookup of the index into the PtrList<functionObject> + // Currently only used to manage rereading/deletion + HashTable<label> indices_; + const Time& time_; - //- Dictionary containing the list of function object specifications - const dictionary& foDict_; + //- Dictionary containing the "functions" entry + // This entry can either be a list or a dictionary of + // functionObject specifications. + const dictionary& parentDict_; //- Switch for the execution of the functionObjects bool execution_; + //- Tracks if read() was called while execution was turned off + bool updated_; + // Private Member Functions + //- Remove and return the function object pointer by name. + // Return NULL if it didn't exist. + functionObject* remove(const word&); + //- Disallow default bitwise copy construct functionObjectList(const functionObjectList&); @@ -85,17 +101,17 @@ public: functionObjectList ( const Time&, - const bool execution = true + const bool execution=true ); - //- Construct from Time, functionObject dictionary and the execution - // setting + //- Construct from Time, dictionary with "functions" entry + // and the execution setting functionObjectList ( const Time&, - const dictionary& foDict, - const bool execution = true + const dictionary& parentDict, + const bool execution=true ); @@ -118,7 +134,7 @@ public: //- Switch the function objects off virtual void off(); - //- Read and set the function objects if their data has changed + //- Read and set the function objects if their data have changed virtual bool read(); }; diff --git a/src/OpenFOAM/db/scalarRange/scalarRanges.C b/src/OpenFOAM/db/scalarRange/scalarRanges.C index d2bf1c830256143be0a9a4554481cb5879e3d79c..f0cf5d5a844d72f0e7357f52fc2b979f61f353fd 100644 --- a/src/OpenFOAM/db/scalarRange/scalarRanges.C +++ b/src/OpenFOAM/db/scalarRange/scalarRanges.C @@ -51,7 +51,6 @@ Foam::scalarRanges::scalarRanges(Istream& is) } } - lst.shrink(); transfer(lst); } diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index a2faa64133a164011173bf5a2168accea365b3cc..ef8f88bfbd794644997d670791c84cab9b560c86 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -37,19 +37,17 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam -{ - SLList<string> argList::validArgs; - HashTable<string> argList::validOptions; - HashTable<string> argList::validParOptions; -} +Foam::SLList<Foam::string> Foam::argList::validArgs; +Foam::HashTable<Foam::string> Foam::argList::validOptions; +Foam::HashTable<Foam::string> Foam::argList::validParOptions; +bool Foam::argList::bannerEnabled(true); Foam::argList::initValidTables::initValidTables() { - validOptions.insert("case", "dir"); - validOptions.insert("parallel", ""); - validParOptions.insert("parallel", ""); + validOptions.set("case", "dir"); + validOptions.set("parallel", ""); + validParOptions.set("parallel", ""); Pstream::addValidParOptions(validParOptions); } @@ -138,7 +136,7 @@ void Foam::argList::getRootCase() casePath = cwd(); // we could add this back in as '-case'? - // options_.insert("case", casePath); + // options_.set("case", casePath); } rootPath_ = casePath.path(); @@ -285,7 +283,7 @@ Foam::argList::argList string timeString = clock::clockTime(); // Print the banner once only for parallel runs - if (Pstream::master()) + if (Pstream::master() && bannerEnabled) { IOobject::writeBanner(Info, true); Info<< "Exec : " << argListString.c_str() << nl @@ -315,8 +313,6 @@ Foam::argList::argList // For the master if (Pstream::master()) { - fileNameList roots; - // establish rootPath_/globalCase_/case_ for master getRootCase(); @@ -333,45 +329,25 @@ Foam::argList::argList << exit(FatalError); } - dictionary decompositionDict(decompDictStream); - - Switch distributed(false); - - if - ( - decompositionDict.readIfPresent("distributed", distributed) - && distributed - ) - { - decompositionDict.lookup("roots") >> roots; - - if (roots.size() != Pstream::nProcs()-1) - { - FatalError - << "number of entries in decompositionDict::roots" - << " is not equal to the number of slaves " - << Pstream::nProcs()-1 - << exit(FatalError); - } - } - + dictionary decompDict(decompDictStream); label dictNProcs ( readLabel ( - decompositionDict.lookup("numberOfSubdomains") + decompDict.lookup("numberOfSubdomains") ) ); - // Check number of processors. We have nProcs(number of - // actual processes), dictNProcs(wanted number of processes read - // from decompositionDict) and nProcDirs(number of processor - // directories - n/a when running distributed) + // Check number of processors. + // nProcs => number of actual procs + // dictNProcs => number of procs specified in decompositionDict + // nProcDirs => number of processor directories + // (n/a when running distributed) // // - normal running : nProcs = dictNProcs = nProcDirs - // - decomposition to more processors : nProcs = dictNProcs - // - decomposition to less processors : nProcs = nProcDirs + // - decomposition to more processors : nProcs = dictNProcs + // - decomposition to fewer processors : nProcs = nProcDirs if (dictNProcs > Pstream::nProcs()) { FatalError @@ -382,38 +358,23 @@ Foam::argList::argList << exit(FatalError); } - if (!distributed && dictNProcs < Pstream::nProcs()) + // distributed data + if (decompDict.lookupOrDefault<Switch>("distributed", false)) { - // Possibly going to fewer processors. - // Check if all procDirs are there. - label nProcDirs = 0; - while - ( - dir - ( - rootPath_/globalCase_/"processor" - + name(++nProcDirs) - ) - ) - {} + fileNameList roots; + decompDict.lookup("roots") >> roots; - if (nProcDirs != Pstream::nProcs()) + if (roots.size() != Pstream::nProcs()-1) { FatalError - << "number of processor directories = " - << nProcDirs - << " is not equal to the number of processors = " - << Pstream::nProcs() + << "number of entries in decompositionDict::roots" + << " is not equal to the number of slaves " + << Pstream::nProcs()-1 << exit(FatalError); } - } - - // distributed data - if (roots.size()) - { - bool hadOptCase = options_.found("case"); // Distribute the master's argument list (with new root) + bool hadCaseOpt = options_.found("case"); for ( int slave=Pstream::firstSlave(); @@ -421,8 +382,7 @@ Foam::argList::argList slave++ ) { - options_.erase("case"); - options_.insert + options_.set ( "case", fileName(roots[slave-1])/globalCase_ @@ -431,17 +391,42 @@ Foam::argList::argList OPstream toSlave(Pstream::scheduled, slave); toSlave << args_ << options_; } - options_.erase("case"); // restore [-case dir] - if (hadOptCase) + if (hadCaseOpt) { - options_.insert("case", rootPath_/globalCase_); + options_.set("case", rootPath_/globalCase_); } } else { + // Possibly going to fewer processors. + // Check if all procDirs are there. + if (dictNProcs < Pstream::nProcs()) + { + label nProcDirs = 0; + while + ( + dir + ( + rootPath_/globalCase_/"processor" + + name(++nProcDirs) + ) + ) + {} + + if (nProcDirs != Pstream::nProcs()) + { + FatalError + << "number of processor directories = " + << nProcDirs + << " is not equal to the number of processors = " + << Pstream::nProcs() + << exit(FatalError); + } + } + // Distribute the master's argument list (unaltered) for ( @@ -472,7 +457,6 @@ Foam::argList::argList { // establish rootPath_/globalCase_/case_ getRootCase(); - case_ = globalCase_; } @@ -510,21 +494,21 @@ Foam::argList::argList } - if (Pstream::master()) + if (Pstream::master() && bannerEnabled) { Info<< "Case : " << (rootPath_/globalCase_).c_str() << nl << "nProcs : " << nProcs << endl; - } - if (parRunControl_.parRun() && Pstream::master()) - { - Info<< "Slaves : " << slaveProcs << nl - << "Pstream initialized with:" << nl - << " floatTransfer : " << Pstream::floatTransfer << nl - << " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl - << " commsType : " - << Pstream::commsTypeNames[Pstream::defaultCommsType] - << endl; + if (parRunControl_.parRun()) + { + Info<< "Slaves : " << slaveProcs << nl + << "Pstream initialized with:" << nl + << " floatTransfer : " << Pstream::floatTransfer << nl + << " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl + << " commsType : " + << Pstream::commsTypeNames[Pstream::defaultCommsType] + << endl; + } } jobInfo.add("root", rootPath_); @@ -546,7 +530,7 @@ Foam::argList::argList sigQuit_.set(); sigSegv_.set(); - if (Pstream::master()) + if (Pstream::master() && bannerEnabled) { Info<< endl; IOobject::writeDivider(Info); @@ -564,6 +548,12 @@ Foam::argList::~argList() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::argList::noBanner() +{ + bannerEnabled = false; +} + + void Foam::argList::noParallel() { validOptions.erase("parallel"); diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index 648295da842bb5414ecdeeff1d507137d775c4a0..60dd1c01e9000bcbfb52b3905ec32b84e664936b 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -92,6 +92,7 @@ namespace Foam class argList { // Private data + static bool bannerEnabled; stringList args_; HashTable<string> options_; @@ -213,6 +214,9 @@ public: // Edit + //- Disable emitting the banner information + static void noBanner(); + //- Remove the parallel options static void noParallel(); diff --git a/src/OpenFOAM/global/debug/debug.C b/src/OpenFOAM/global/debug/debug.C index 82ec7d7eaf13f226563e0170e44c8e45261b3980..3a3274a1e20fa9b48dea3b78cbdbd1bcb5ae79ef 100644 --- a/src/OpenFOAM/global/debug/debug.C +++ b/src/OpenFOAM/global/debug/debug.C @@ -36,19 +36,16 @@ Description namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace debug { +//! @cond ignoreDocumentation - local scope dictionary* controlDictPtr_(NULL); dictionary* debugSwitchesPtr_(NULL); dictionary* infoSwitchesPtr_(NULL); dictionary* optimisationSwitchesPtr_(NULL); -//- Class to ensure controlDictPtr_ is deleted at the end of the run -// @cond ignore documentation for this class +// to ensure controlDictPtr_ is deleted at the end of the run class deleteControlDictPtr { public: @@ -61,135 +58,110 @@ public: if (controlDictPtr_) { delete controlDictPtr_; + controlDictPtr_ = 0; } } }; -//! @endcond deleteControlDictPtr deleteControlDictPtr_; +//! @endcond ignoreDocumentation -dictionary& switchSet(const char* switchSetName, dictionary* switchSetPtr) -{ - if (!switchSetPtr) - { - if (!controlDict().found(switchSetName)) - { - cerr<< "debug::switchSet(const char*, dictionary*): " << std::endl - << " Cannot find " << switchSetName - << " in dictionary " << controlDictPtr_->name().c_str() - << std::endl << std::endl; - - ::exit(1); - } - - switchSetPtr = - const_cast<dictionary*>(&(controlDict().subDict(switchSetName))); - } - - return *switchSetPtr; -} +} // End namespace debug +} // End namespace Foam +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -int debugSwitch -( - dictionary& switchSet, - const char* switchName, - const int defaultValue -) +Foam::dictionary& Foam::debug::controlDict() { - if (switchSet.found(switchName)) - { - return readInt(switchSet.lookup(switchName)); - } - else + if (!controlDictPtr_) { - switchSet.add(switchName, defaultValue); - return defaultValue; + controlDictPtr_ = new dictionary + ( + IFstream(findEtcFile("controlDict", true))() + ); } -} + return *controlDictPtr_; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dictionary& debug::controlDict() +Foam::dictionary& Foam::debug::switchSet +( + const char* subDictName, + dictionary*& subDictPtr +) { - if (!controlDictPtr_) + if (!subDictPtr) { - fileName controlDictFileName(dotFoam("controlDict")); - - IFstream dictFile(controlDictFileName); + entry* ePtr = controlDict().lookupEntryPtr + ( + subDictName, false, false + ); - if (!dictFile.good()) + if (!ePtr || !ePtr->isDict()) { - cerr<< "debug::controlDict(): " - << "Cannot open essential file " << controlDictFileName.c_str() + cerr<< "debug::switchSet(const char*, dictionary*&):\n" + << " Cannot find " << subDictName << " in dictionary " + << controlDict().name().c_str() << std::endl << std::endl; + ::exit(1); } - controlDictPtr_ = new dictionary(dictFile); + subDictPtr = &ePtr->dict(); } - return *controlDictPtr_; + return *subDictPtr; } -dictionary& debug::debugSwitches() +Foam::dictionary& Foam::debug::debugSwitches() { return switchSet("DebugSwitches", debugSwitchesPtr_); } -int debug::debugSwitch(const char* switchName, const int defaultValue) +Foam::dictionary& Foam::debug::infoSwitches() { - return debugSwitch - ( - debugSwitches(), - switchName, - defaultValue - ); + return switchSet("InfoSwitches", infoSwitchesPtr_); } -dictionary& debug::infoSwitches() +Foam::dictionary& Foam::debug::optimisationSwitches() { - return switchSet("InfoSwitches", infoSwitchesPtr_); + return switchSet("OptimisationSwitches", optimisationSwitchesPtr_); } -int debug::infoSwitch(const char* switchName, const int defaultValue) +int Foam::debug::debugSwitch(const char* name, const int defaultValue) { - return debugSwitch + return debugSwitches().lookupOrAddDefault ( - infoSwitches(), - switchName, - defaultValue + name, defaultValue, false, false ); } -dictionary& debug::optimisationSwitches() +int Foam::debug::infoSwitch(const char* name, const int defaultValue) { - return switchSet("OptimisationSwitches", optimisationSwitchesPtr_); + return infoSwitches().lookupOrAddDefault + ( + name, defaultValue, false, false + ); } -int debug::optimisationSwitch(const char* switchName, const int defaultValue) +int Foam::debug::optimisationSwitch(const char* name, const int defaultValue) { - return debugSwitch + return optimisationSwitches().lookupOrAddDefault ( - optimisationSwitches(), - switchName, - defaultValue + name, defaultValue, false, false ); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/global/debug/debug.H b/src/OpenFOAM/global/debug/debug.H index 8787f3397da1ec1851ed87eab3a15606bfde2cfa..9431a4f78b9933dfb03e90a6825a21925ec34804 100644 --- a/src/OpenFOAM/global/debug/debug.H +++ b/src/OpenFOAM/global/debug/debug.H @@ -41,44 +41,40 @@ SourceFiles namespace Foam { +// Forward declaration of classes class dictionary; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace debug { + //- The central control dictionary. + // Located in ~/.OpenFOAM/VERSION or $WM_PROJECT_DIR/etc + // @sa Foam::findEtcFile() dictionary& controlDict(); - - dictionary& switchSet(const char* switchSetName, dictionary* switchSetPtr); - - + //- The DebugSwitches sub-dictionary in the central controlDict. dictionary& debugSwitches(); - int debugSwitch - ( - const char* switchName, - const int defaultValue = 0 - ); + //- The InfoSwitches sub-dictionary in the central controlDict. + dictionary& infoSwitches(); + //- The OptimisationSwitches sub-dictionary in the central controlDict. + dictionary& optimisationSwitches(); - dictionary& infoSwitches(); + //- Lookup debug switch or add default value. + int debugSwitch(const char* name, const int defaultValue=0); - int infoSwitch - ( - const char* switchName, - const int defaultValue = 0 - ); + //- Lookup info switch or add default value. + int infoSwitch(const char* name, const int defaultValue=0); + //- Lookup optimisation switch or add default value. + int optimisationSwitch(const char* name, const int defaultValue=0); - dictionary& optimisationSwitches(); + //- Internal function to lookup a sub-dictionary from controlDict. + dictionary& switchSet(const char* subDictName, dictionary*& subDictPtr); - int optimisationSwitch - ( - const char* switchName, - const int defaultValue = 0 - ); -} +} // End namespace debug // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index 9bfb08b0692450efcd19d9cdbeb61b0940b1aa82..169620865ec08bdfac2e208058a67f24e535eabc 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -102,7 +102,8 @@ bool chDir(const fileName& dir); // - $WM_PROJECT_DIR/etc/ // // @return the full path name or fileName::null if the name cannot be found -fileName dotFoam(const fileName& name); +// Optionally abort if the file cannot be found +fileName findEtcFile(const fileName& name, bool mandatory=false); //- Make a directory and return an error if it could not be created // and does not already exist diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index 33fcda639db8e0bc5d10ac7118e27cece792139e..c9e797d2d207735714bdaac5b851fc4a80ff33ff 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -259,7 +259,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ), ( fieldName, @@ -267,7 +267,7 @@ public: interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); @@ -282,7 +282,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ), ( fieldName, @@ -290,7 +290,7 @@ public: interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); @@ -304,7 +304,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); // Selectors @@ -317,7 +317,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); @@ -359,7 +359,7 @@ public: //- Read and reset the solver parameters from the given stream - virtual void read(Istream& solverData); + virtual void read(const dictionary&); virtual solverPerformance solve ( @@ -396,6 +396,9 @@ public: public: + //- Find the smoother name (directly or from a sub-dictionary) + static word getName(const dictionary&); + //- Runtime type information virtual const word& type() const = 0; @@ -467,7 +470,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& smootherData + const dictionary& solverControls ); @@ -531,6 +534,9 @@ public: public: + //- Find the preconditioner name (directly or from a sub-dictionary) + static word getName(const dictionary&); + //- Runtime type information virtual const word& type() const = 0; @@ -544,9 +550,9 @@ public: symMatrix, ( const solver& sol, - Istream& preconditionerData + const dictionary& solverControls ), - (sol, preconditionerData) + (sol, solverControls) ); declareRunTimeSelectionTable @@ -556,9 +562,9 @@ public: asymMatrix, ( const solver& sol, - Istream& preconditionerData + const dictionary& solverControls ), - (sol, preconditionerData) + (sol, solverControls) ); @@ -579,7 +585,7 @@ public: static autoPtr<preconditioner> New ( const solver& sol, - Istream& preconditionerData + const dictionary& solverControls ); @@ -593,7 +599,7 @@ public: //- Read and reset the preconditioner parameters // from the given stream - virtual void read(Istream& preconditionerData) + virtual void read(const dictionary&) {} //- Return wA the preconditioned form of residual rA diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C index 82f9a19ac20c59a3a5e4c303cb0f0a5cb7144c33..cb4a645df1c4f30ab96bf174bdb87d8c3025ebf1 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixPreconditioner.C @@ -37,29 +37,66 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +Foam::word +Foam::lduMatrix::preconditioner::getName +( + const dictionary& solverControls +) +{ + word name; + + // handle primitive or dictionary entry + const entry& e = solverControls.lookupEntry("preconditioner", false, false); + if (e.isDict()) + { + e.dict().lookup("preconditioner") >> name; + } + else + { + e.stream() >> name; + } + + return name; +} + + Foam::autoPtr<Foam::lduMatrix::preconditioner> Foam::lduMatrix::preconditioner::New ( const solver& sol, - Istream& preconditionerData + const dictionary& solverControls ) { - word preconditionerName(preconditionerData); + word name; + + // handle primitive or dictionary entry + const entry& e = solverControls.lookupEntry("preconditioner", false, false); + if (e.isDict()) + { + e.dict().lookup("preconditioner") >> name; + } + else + { + e.stream() >> name; + } + + const dictionary& controls = e.isDict() ? e.dict() : dictionary::null; if (sol.matrix().symmetric()) { symMatrixConstructorTable::iterator constructorIter = - symMatrixConstructorTablePtr_->find(preconditionerName); + symMatrixConstructorTablePtr_->find(name); if (constructorIter == symMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::preconditioner::New(const solver&, Istream&)", - preconditionerData + "lduMatrix::preconditioner::New" + "(const solver&, const dictionary&)", + controls ) << "Unknown symmetric matrix preconditioner " - << preconditionerName << endl << endl - << "Valid symmetric matrix preconditioners are :" << endl + << name << nl << nl + << "Valid symmetric matrix preconditioners :" << endl << symMatrixConstructorTablePtr_->toc() << exit(FatalIOError); } @@ -69,24 +106,25 @@ Foam::lduMatrix::preconditioner::New constructorIter() ( sol, - preconditionerData + controls ) ); } else if (sol.matrix().asymmetric()) { asymMatrixConstructorTable::iterator constructorIter = - asymMatrixConstructorTablePtr_->find(preconditionerName); + asymMatrixConstructorTablePtr_->find(name); if (constructorIter == asymMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::preconditioner::New(const solver&, Istream&)", - preconditionerData + "lduMatrix::preconditioner::New" + "(const solver&, const dictionary&)", + controls ) << "Unknown asymmetric matrix preconditioner " - << preconditionerName << endl << endl - << "Valid asymmetric matrix preconditioners are :" << endl + << name << nl << nl + << "Valid asymmetric matrix preconditioners :" << endl << asymMatrixConstructorTablePtr_->toc() << exit(FatalIOError); } @@ -96,7 +134,7 @@ Foam::lduMatrix::preconditioner::New constructorIter() ( sol, - preconditionerData + controls ) ); } @@ -104,9 +142,10 @@ Foam::lduMatrix::preconditioner::New { FatalIOErrorIn ( - "lduMatrix::preconditioner::New(const solver&, Istream&)", - preconditionerData - ) << "cannot preconditione incomplete matrix, " + "lduMatrix::preconditioner::New" + "(const solver&, const dictionary&)", + controls + ) << "cannot solve incomplete matrix, " "no diagonal or off-diagonal coefficient" << exit(FatalIOError); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C index 7554e4085c0e83e493b62f80f9f9ef904e8b867a..a18f65687d3476088a2b9e324c85f1cfa22891a4 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSmoother.C @@ -34,9 +34,31 @@ namespace Foam defineRunTimeSelectionTable(lduMatrix::smoother, asymMatrix); } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +Foam::word +Foam::lduMatrix::smoother::getName +( + const dictionary& solverControls +) +{ + word name; + + // handle primitive or dictionary entry + const entry& e = solverControls.lookupEntry("smoother", false, false); + if (e.isDict()) + { + e.dict().lookup("smoother") >> name; + } + else + { + e.stream() >> name; + } + + return name; +} + + Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New ( const word& fieldName, @@ -44,23 +66,37 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& smootherData + const dictionary& solverControls ) { - word smootherName(smootherData); + word name; + + // handle primitive or dictionary entry + const entry& e = solverControls.lookupEntry("smoother", false, false); + if (e.isDict()) + { + e.dict().lookup("smoother") >> name; + } + else + { + e.stream() >> name; + } + + // not (yet?) needed: + // const dictionary& controls = e.isDict() ? e.dict() : dictionary::null; if (matrix.symmetric()) { symMatrixConstructorTable::iterator constructorIter = - symMatrixConstructorTablePtr_->find(smootherName); + symMatrixConstructorTablePtr_->find(name); if (constructorIter == symMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::smoother::New", smootherData - ) << "Unknown symmetric matrix smoother " << smootherName - << endl << endl + "lduMatrix::smoother::New", solverControls + ) << "Unknown symmetric matrix smoother " + << name << nl << nl << "Valid symmetric matrix smoothers are :" << endl << symMatrixConstructorTablePtr_->toc() << exit(FatalIOError); @@ -81,15 +117,15 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New else if (matrix.asymmetric()) { asymMatrixConstructorTable::iterator constructorIter = - asymMatrixConstructorTablePtr_->find(smootherName); + asymMatrixConstructorTablePtr_->find(name); if (constructorIter == asymMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::smoother::New", smootherData - ) << "Unknown asymmetric matrix smoother " << smootherName - << endl << endl + "lduMatrix::smoother::New", solverControls + ) << "Unknown asymmetric matrix smoother " + << name << nl << nl << "Valid asymmetric matrix smoothers are :" << endl << asymMatrixConstructorTablePtr_->toc() << exit(FatalIOError); @@ -111,8 +147,9 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New { FatalIOErrorIn ( - "lduMatrix::smoother::New", smootherData - ) << "cannot solve incomplete matrix, no off-diagonal coefficients" + "lduMatrix::smoother::New", solverControls + ) << "cannot solve incomplete matrix, " + "no diagonal or off-diagonal coefficient" << exit(FatalIOError); return autoPtr<lduMatrix::smoother>(NULL); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C index 19fd2435a08ecad0afb0b37a487888042ce719eb..4b3b8d97a97f343addee636ffe05f6676e668256 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C @@ -45,10 +45,10 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) { - word solverName(solverData); + word name(solverControls.lookup("solver")); if (matrix.diagonal()) { @@ -61,22 +61,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); } else if (matrix.symmetric()) { symMatrixConstructorTable::iterator constructorIter = - symMatrixConstructorTablePtr_->find(solverName); + symMatrixConstructorTablePtr_->find(name); if (constructorIter == symMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::solver::New", solverData - ) << "Unknown symmetric matrix solver " << solverName - << endl << endl + "lduMatrix::solver::New", solverControls + ) << "Unknown symmetric matrix solver " << name << nl << nl << "Valid symmetric matrix solvers are :" << endl << symMatrixConstructorTablePtr_->toc() << exit(FatalIOError); @@ -91,22 +90,21 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); } else if (matrix.asymmetric()) { asymMatrixConstructorTable::iterator constructorIter = - asymMatrixConstructorTablePtr_->find(solverName); + asymMatrixConstructorTablePtr_->find(name); if (constructorIter == asymMatrixConstructorTablePtr_->end()) { FatalIOErrorIn ( - "lduMatrix::solver::New", solverData - ) << "Unknown asymmetric matrix solver " << solverName - << endl << endl + "lduMatrix::solver::New", solverControls + ) << "Unknown asymmetric matrix solver " << name << nl << nl << "Valid asymmetric matrix solvers are :" << endl << asymMatrixConstructorTablePtr_->toc() << exit(FatalIOError); @@ -121,7 +119,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) ); } @@ -129,7 +127,7 @@ Foam::autoPtr<Foam::lduMatrix::solver> Foam::lduMatrix::solver::New { FatalIOErrorIn ( - "lduMatrix::solver::New", solverData + "lduMatrix::solver::New", solverControls ) << "cannot solve incomplete matrix, " "no diagonal or off-diagonal coefficient" << exit(FatalIOError); @@ -148,7 +146,7 @@ Foam::lduMatrix::solver::solver const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : fieldName_(fieldName), @@ -156,12 +154,7 @@ Foam::lduMatrix::solver::solver interfaceBouCoeffs_(interfaceBouCoeffs), interfaceIntCoeffs_(interfaceIntCoeffs), interfaces_(interfaces), - - controlDict_(solverData), - - maxIter_(1000), - tolerance_(1e-6), - relTol_(0) + controlDict_(solverControls) { readControls(); } @@ -171,16 +164,15 @@ Foam::lduMatrix::solver::solver void Foam::lduMatrix::solver::readControls() { - controlDict_.readIfPresent("maxIter", maxIter_); - controlDict_.readIfPresent("tolerance", tolerance_); - controlDict_.readIfPresent("relTol", relTol_); + maxIter_ = controlDict_.lookupOrDefault<label>("maxIter", 1000); + tolerance_ = controlDict_.lookupOrDefault<scalar>("tolerance", 1e-6); + relTol_ = controlDict_.lookupOrDefault<scalar>("relTol", 0); } -void Foam::lduMatrix::solver::read(Istream& solverData) +void Foam::lduMatrix::solver::read(const dictionary& solverControls) { - word solverName(solverData); - solverData >> controlDict_; + controlDict_ = solverControls; readControls(); } diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.C index 449a992cbe8a9cc0a895635cadbc4caf4cb09fa2..03141b88a610b75abf6ff5e63dd994200eb25bcd 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.C @@ -43,7 +43,7 @@ namespace Foam Foam::DICPreconditioner::DICPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol), diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.H index aa1367a76177a9d3e0137e72f84ddf81155c14e8..61feee478eb4a50bfc291eb09ea480f3b2f69fa6 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DICPreconditioner/DICPreconditioner.H @@ -67,11 +67,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls DICPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.C index 782283879350641090620fcbbbe02c8f3cca1b4e..f8778b0406ac539323cf29e9eb8be5777da89fb9 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.C @@ -43,7 +43,7 @@ namespace Foam Foam::DILUPreconditioner::DILUPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol), diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.H index 8e9776e5cbebe48f78332a9b28b5776b0b3ae1fd..aaaba8918fb98be87951e5062bbe56e3bc4e7a5c 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/DILUPreconditioner/DILUPreconditioner.H @@ -67,11 +67,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls DILUPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); @@ -94,8 +94,7 @@ public: const direction cmpt=0 ) const; - //- Return wT the transpose-matrix preconditioned form of - // residual rT. + //- Return wT the transpose-matrix preconditioned form of residual rT. virtual void preconditionT ( scalarField& wT, diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.C index 8f38f29b047c18122b1311e49326626901188ed0..31574f1718d07bb5ea6e38ba99aeb570b44b6d66 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.C @@ -43,7 +43,7 @@ namespace Foam Foam::FDICPreconditioner::FDICPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol), @@ -164,7 +164,7 @@ void Foam::FDICPreconditioner::precondition __builtin_prefetch (&uPtr[face+96],0,0); __builtin_prefetch (&lPtr[face+96],0,0); __builtin_prefetch (&rDuUpperPtr[face+96],0,0); - __builtin_prefetch (&wAPtr[uPtr[face+32]],0,1); + __builtin_prefetch (&wAPtr[uPtr[face+32]],0,1); __builtin_prefetch (&wAPtr[lPtr[face+32]],0,1); #endif diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.H index 6312b8171f91772d9b4ccd51676faf3bdb23cc7c..53e0caac0f06720766dfbf5de794034e12736324 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/FDICPreconditioner/FDICPreconditioner.H @@ -80,11 +80,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls FDICPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C index cfd2f4513ef64ee6dc58a999459006f520f15e91..3433168e2085618f5c70d49c740458fd79414209 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.C @@ -45,7 +45,7 @@ namespace Foam Foam::GAMGPreconditioner::GAMGPreconditioner ( const lduMatrix::solver& sol, - Istream& preconditionerData + const dictionary& solverControls ) : GAMGSolver @@ -55,7 +55,7 @@ Foam::GAMGPreconditioner::GAMGPreconditioner sol.interfaceBouCoeffs(), sol.interfaceIntCoeffs(), sol.interfaces(), - preconditionerData + solverControls ), lduMatrix::preconditioner(sol), nVcycles_(2) @@ -75,13 +75,7 @@ Foam::GAMGPreconditioner::~GAMGPreconditioner() void Foam::GAMGPreconditioner::readControls() { GAMGSolver::readControls(); - controlDict_.readIfPresent("nVcycles", nVcycles_); -} - - -void Foam::GAMGPreconditioner::read(Istream& solverData) -{ - GAMGSolver::read(solverData); + nVcycles_ = controlDict_.lookupOrDefault<label>("nVcycles", 2); } diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.H index 1e9bfae843aa186b1c448241a1222d2f345136a2..82ca63580b131a45fc2abc2716f367a0b194bcdd 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/GAMGPreconditioner/GAMGPreconditioner.H @@ -55,17 +55,14 @@ class GAMGPreconditioner public GAMGSolver, public lduMatrix::preconditioner { - // Private data +protected: + // Protected data //- Number of V-cycles to perform label nVcycles_; - - // Private member functions - - //- Read control parameters from the control dictionary - void readControls(); - + //- Read the control parameters from the controlDict_ + virtual void readControls(); public: @@ -75,11 +72,11 @@ public: // Constructors - //- Construct for given solver and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls GAMGPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControls ); @@ -90,9 +87,6 @@ public: // Member Functions - //- Read and reset the preconditioner parameters from the given stream - virtual void read(Istream& preconditionerData); - //- Return wA the preconditioned form of residual rA virtual void precondition ( diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.C index 3bce37a2c77e1beb2efd83aa04da4e09c6af480d..04da54f1c46488e83202969217e7f14590639abc 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.C @@ -47,7 +47,7 @@ namespace Foam Foam::diagonalPreconditioner::diagonalPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol), @@ -77,10 +77,6 @@ Foam::diagonalPreconditioner::diagonalPreconditioner // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::diagonalPreconditioner::read(Istream&) -{} - - void Foam::diagonalPreconditioner::precondition ( scalarField& wA, diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.H index cc6f8f82b3406e3ab02d7ae476d66b211fc45279..3a0bcb4b2be92acfca8ec15d4e365ed77790e2c6 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/diagonalPreconditioner/diagonalPreconditioner.H @@ -56,7 +56,7 @@ class diagonalPreconditioner { // Private data - //- The reciprocal diagonal + //- The reciprocal diagonal scalarField rD; @@ -77,11 +77,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls diagonalPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); @@ -93,9 +93,6 @@ public: // Member Functions - //- Read and reset the preconditioner parameters from the given stream - virtual void read(Istream& preconditionerData); - //- Return wA the preconditioned form of residual rA virtual void precondition ( @@ -104,8 +101,7 @@ public: const direction cmpt=0 ) const; - //- Return wT the transpose-matrix preconditioned form of - // residual rT. + //- Return wT the transpose-matrix preconditioned form of residual rT. virtual void preconditionT ( scalarField& wT, @@ -113,7 +109,7 @@ public: const direction cmpt=0 ) const { - return(precondition(wT, rT, cmpt)); + return precondition(wT, rT, cmpt); } }; diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.C b/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.C index 00d1129b5bc306ad4809f17fcc04f3a07ad56d43..1f4fe2b4a4f8a3921f4ea6624ef92e87de7f3a2f 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.C +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.C @@ -47,7 +47,7 @@ namespace Foam Foam::noPreconditioner::noPreconditioner ( const lduMatrix::solver& sol, - Istream& + const dictionary& ) : lduMatrix::preconditioner(sol) @@ -56,10 +56,6 @@ Foam::noPreconditioner::noPreconditioner // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::noPreconditioner::read(Istream&) -{} - - void Foam::noPreconditioner::precondition ( scalarField& wA, diff --git a/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.H b/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.H index bedab173213546b84416ac4159db82eb2c2ed615..9668f217fcac66e8e2441b8cff7c09eabef4744c 100644 --- a/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.H +++ b/src/OpenFOAM/matrices/lduMatrix/preconditioners/noPreconditioner/noPreconditioner.H @@ -68,11 +68,11 @@ public: // Constructors - //- Construct from matrix components and preconditioner data stream + //- Construct from matrix components and preconditioner solver controls noPreconditioner ( - const lduMatrix::solver& sol, - Istream& preconditionerData + const lduMatrix::solver&, + const dictionary& solverControlsUnused ); @@ -84,9 +84,6 @@ public: // Member Functions - //- Read and reset the preconditioner parameters from the given stream - virtual void read(Istream& preconditionerData); - //- Return wA the preconditioned form of residual rA virtual void precondition ( @@ -95,8 +92,7 @@ public: const direction cmpt=0 ) const; - //- Return wT the transpose-matrix preconditioned form of - // residual rT. + //- Return wT the transpose-matrix preconditioned form of residual rT. virtual void preconditionT ( scalarField& wT, @@ -104,7 +100,7 @@ public: const direction cmpt=0 ) const { - return(precondition(wT, rT, cmpt)); + return precondition(wT, rT, cmpt); } }; diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/DIC/DICSmoother.H b/src/OpenFOAM/matrices/lduMatrix/smoothers/DIC/DICSmoother.H index 5a59ac98b369393c51f11acda6ba95dde24c8b4f..11346a51d1e0f5a5b84edf67366199f2042fbb09 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/DIC/DICSmoother.H +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/DIC/DICSmoother.H @@ -27,8 +27,10 @@ Class Description Simplified diagonal-based incomplete Cholesky smoother for symmetric - matrices. In order to improve efficiency the residual is evaluated after - every nSweeps sweeps. + matrices. + + To improve efficiency, the residual is evaluated after every nSweeps + sweeps. SourceFiles DICSmoother.C diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/DICGaussSeidel/DICGaussSeidelSmoother.H b/src/OpenFOAM/matrices/lduMatrix/smoothers/DICGaussSeidel/DICGaussSeidelSmoother.H index 55312c0ef5125d3b2f21f5723eb4419664a115a0..12a9c9c173b66edc3c3f8e60515c8b23cd55fc04 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/DICGaussSeidel/DICGaussSeidelSmoother.H +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/DICGaussSeidel/DICGaussSeidelSmoother.H @@ -26,9 +26,9 @@ Class Foam::DICGaussSeidelSmoother Description - Combined DIC/GaussSeidel smoother for symmetric - matrices in which DIC smoothing is followed by GaussSeidel to ensure that - any "spikes" created by the DIC sweeps are smoothed-out. + Combined DIC/GaussSeidel smoother for symmetric matrices in which DIC + smoothing is followed by GaussSeidel to ensure that any "spikes" created + by the DIC sweeps are smoothed-out. SourceFiles DICGaussSeidelSmoother.C @@ -47,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class DICGaussSeidelSmoother Declaration + Class DICGaussSeidelSmoother Declaration \*---------------------------------------------------------------------------*/ class DICGaussSeidelSmoother @@ -57,6 +57,7 @@ class DICGaussSeidelSmoother // Private data DICSmoother dicSmoother_; + GaussSeidelSmoother gsSmoother_; diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/DILU/DILUSmoother.H b/src/OpenFOAM/matrices/lduMatrix/smoothers/DILU/DILUSmoother.H index f95bd91972a822bbde86f65e754760e9eb20e9e1..a8218973dd2e3a04ab63e2b614b2db776ab0922c 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/DILU/DILUSmoother.H +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/DILU/DILUSmoother.H @@ -27,8 +27,9 @@ Class Description Simplified diagonal-based incomplete LU smoother for asymmetric matrices. - In order to improve efficiency the residual is evaluated after every - nSweeps sweeps. + + To improve efficiency, the residual is evaluated after every nSweeps + sweeps. SourceFiles DILUSmoother.C @@ -46,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class DILUSmoother Declaration + Class DILUSmoother Declaration \*---------------------------------------------------------------------------*/ class DILUSmoother diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/DILUGaussSeidel/DILUGaussSeidelSmoother.H b/src/OpenFOAM/matrices/lduMatrix/smoothers/DILUGaussSeidel/DILUGaussSeidelSmoother.H index 6783280f05183cfad176a79274bbc4ea15758f40..6523e259c25a6c118dcb71b7910243271396bf24 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/DILUGaussSeidel/DILUGaussSeidelSmoother.H +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/DILUGaussSeidel/DILUGaussSeidelSmoother.H @@ -26,9 +26,9 @@ Class Foam::DILUGaussSeidelSmoother Description - Combined DILU/GaussSeidel smoother for asymmetric - matrices in which DILU smoothing is followed by GaussSeidel to ensure that - any "spikes" created by the DILU sweeps are smoothed-out. + Combined DILU/GaussSeidel smoother for asymmetric matrices in which + DILU smoothing is followed by GaussSeidel to ensure that any "spikes" + created by the DILU sweeps are smoothed-out. SourceFiles DILUGaussSeidelSmoother.C @@ -47,7 +47,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class DILUGaussSeidelSmoother Declaration + Class DILUGaussSeidelSmoother Declaration \*---------------------------------------------------------------------------*/ class DILUGaussSeidelSmoother @@ -57,6 +57,7 @@ class DILUGaussSeidelSmoother // Private data DILUSmoother diluSmoother_; + GaussSeidelSmoother gsSmoother_; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C index 7772f7c6a3ced7c9c00daab57545792a4f2967e3..e88b873f9f4ab407096b2bc596c3ee4f5575d3ca 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.C @@ -37,36 +37,31 @@ namespace Foam } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -Foam::IStringStream Foam::BICCG::solverDataStream +Foam::dictionary Foam::BICCG::solverDict ( - const scalar tolerance, + const scalar tol, const scalar relTol -) const +) { - return IStringStream - ( - "{ preconditioner DILU;" - " tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }" - ); + dictionary dict(IStringStream("solver PBiCG; preconditioner DILU;")()); + dict.add("tolerance", tol); + dict.add("relTol", relTol); + + return dict; } -Foam::IStringStream Foam::BICCG::solverDataStream +Foam::dictionary Foam::BICCG::solverDict ( - const word& solverName, - Istream& solverData -) const + Istream& is +) { - scalar tolerance(readScalar(solverData)); - scalar relTol(readScalar(solverData)); + scalar tol(readScalar(is)); + scalar relTol(readScalar(is)); - return IStringStream - ( - solverName + "{ preconditioner DILU;" - " tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }" - ); + return solverDict(tol, relTol); } @@ -79,8 +74,7 @@ Foam::BICCG::BICCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol + const dictionary& solverControls ) : PBiCG @@ -90,7 +84,7 @@ Foam::BICCG::BICCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverDataStream(tolerance, relTol)() + solverControls ) {} @@ -102,7 +96,8 @@ Foam::BICCG::BICCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const scalar tolerance, + const scalar relTol ) : PBiCG @@ -112,18 +107,8 @@ Foam::BICCG::BICCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverDataStream(word::null, solverData)() + solverDict(tolerance, relTol) ) {} - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::BICCG::read(Istream& solverData) -{ - word solverName(solverData); - PBiCG::read(solverDataStream(solverName, solverData)()); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H index c6c140345ce4a6cc94f6a0a92583fdda30f2931a..f3058a9b67dfa96015e93bf9dc715351b8273188 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/BICCG/BICCG.H @@ -32,7 +32,7 @@ Description Deprecated This solver is present for backward-compatibility and the PBiCG solver - should be used for preference. + should be used instead. SourceFiles BICCG.C @@ -65,24 +65,20 @@ class BICCG //- Disallow default bitwise assignment void operator=(const BICCG&); - //- Return the dictionary data-stream constructed from the components. - // Needed for backward compatibility - IStringStream solverDataStream - ( - const scalar tolerance, - const scalar relTol - ) const; +public: - //- Return the dictionary data-stream constructed from the old-style - // data-stream. Needed for backward compatibility - IStringStream solverDataStream - ( - const word& solverName, - Istream& solverData - ) const; + //- Return the dictionary constructed from the components. + // Needed for backward compatibility + static dictionary solverDict + ( + const scalar tol, + const scalar relTol + ); + //- Return the dictionary constructed from the old-style data-stream. + // Needed for backward compatibility + static dictionary solverDict(Istream&); -public: //- Runtime type information TypeName("BICCG"); @@ -90,7 +86,7 @@ public: // Constructors - //- Construct from matrix components and tolerances + //- Construct from matrix components and solver data stream BICCG ( const word& fieldName, @@ -98,11 +94,11 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol = 0.0 + const dictionary& solverControls ); - //- Construct from matrix components and solver data stream + + //- Construct from matrix components and tolerances BICCG ( const word& fieldName, @@ -110,20 +106,15 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const scalar tolerance, + const scalar relTol = 0.0 ); - // Destructor virtual ~BICCG() {} - - // Member Functions - - //- Read and reset the solver parameters from the given stream - void read(Istream& solverData); }; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C index f8a29ba2413738a3820aae190206287e74c314c8..ef838342e8d2f9d6199a4751e4ffe91db60b2c2a 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.C @@ -49,7 +49,7 @@ Foam::GAMGSolver::GAMGSolver const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -59,7 +59,7 @@ Foam::GAMGSolver::GAMGSolver interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ), // Default values for all controls @@ -112,7 +112,7 @@ Foam::GAMGSolver::GAMGSolver "const FieldField<Field, scalar>& interfaceBouCoeffs," "const FieldField<Field, scalar>& interfaceIntCoeffs," "const lduInterfaceFieldPtrsList& interfaces," - "Istream& solverData" + "const dictionary& solverControls" ")" ) << "No coarse levels created, either matrix too small for GAMG" " or nCellsInCoarsestLevel too large.\n" @@ -154,6 +154,7 @@ void Foam::GAMGSolver::readControls() { lduMatrix::solver::readControls(); + // we could also consider supplying defaults here too controlDict_.readIfPresent("cacheAgglomeration", cacheAgglomeration_); controlDict_.readIfPresent("nPreSweeps", nPreSweeps_); controlDict_.readIfPresent("nPostSweeps", nPostSweeps_); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H index 8c4596c888979d6642583d2e66b6599db59955fe..6cbef1f5092bd8ef361fd8ca7d2e4785e2a6a198 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H @@ -212,7 +212,7 @@ public: // Constructors - //- Construct from lduMatrix + //- Construct from lduMatrix and solver controls GAMGSolver ( const word& fieldName, @@ -220,7 +220,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C index 431f2f179f01756a5484f9a13147398ce4ff7d37..e7e2a6339180035768c107e0b29ceb612d7c2f41 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C @@ -374,7 +374,7 @@ void Foam::GAMGSolver::initVcycle interfaceBouCoeffs_, interfaceIntCoeffs_, interfaces_, - controlDict_.lookup("smoother") + controlDict_ ) ); @@ -408,7 +408,7 @@ void Foam::GAMGSolver::initVcycle interfaceLevelsBouCoeffs_[leveli], interfaceLevelsIntCoeffs_[leveli], interfaceLevels_[leveli], - controlDict_.lookup("smoother") + controlDict_ ) ); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C index dbd4ae16d083f2561a49f4a4d5ba4492bd4f40d4..97a03b4f0d1a49afd1c1306c1e675ae7c4a87911 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.C @@ -36,40 +36,33 @@ namespace Foam addICCGSymMatrixConstructorToTable_; } +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -Foam::IStringStream Foam::ICCG::solverDataStream +Foam::dictionary Foam::ICCG::solverDict ( - const scalar tolerance, + const scalar tol, const scalar relTol -) const +) { - return IStringStream - ( - "{ preconditioner DIC;" - " tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }" - ); + dictionary dict(IStringStream("solver PCG; preconditioner DIC;")()); + dict.add("tolerance", tol); + dict.add("relTol", relTol); + + return dict; } -Foam::IStringStream Foam::ICCG::solverDataStream +Foam::dictionary Foam::ICCG::solverDict ( - const word& solverName, - Istream& solverData -) const + Istream& is +) { - scalar tolerance(readScalar(solverData)); - scalar relTol(readScalar(solverData)); + scalar tol(readScalar(is)); + scalar relTol(readScalar(is)); - return IStringStream - ( - solverName + "{ preconditioner DIC;" - " tolerance " + name(tolerance) + "; relTol " + name(relTol) + "; }" - ); + return solverDict(tol, relTol); } - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::ICCG::ICCG @@ -79,8 +72,7 @@ Foam::ICCG::ICCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol + const dictionary& solverControls ) : PCG @@ -90,7 +82,7 @@ Foam::ICCG::ICCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverDataStream(tolerance, relTol)() + solverControls ) {} @@ -102,7 +94,8 @@ Foam::ICCG::ICCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const scalar tolerance, + const scalar relTol ) : PCG @@ -112,18 +105,8 @@ Foam::ICCG::ICCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverDataStream(word::null, solverData)() + solverDict(tolerance, relTol) ) {} - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::ICCG::read(Istream& solverData) -{ - word solverName(solverData); - PCG::read(solverDataStream(solverName, solverData)()); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H index c8f124f87ce35303a90562d242e3fc1f454928ea..850c3f47753698a7be22fc354c38ddbf9707fe27 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/ICCG/ICCG.H @@ -65,24 +65,20 @@ class ICCG //- Disallow default bitwise assignment void operator=(const ICCG&); - //- Return the dictionary data-stream constructed from the components. +public: + + //- Return the dictionary constructed from the components. // Needed for backward compatibility - IStringStream solverDataStream + static dictionary solverDict ( - const scalar tolerance, + const scalar tol, const scalar relTol - ) const; - - //- Return the dictionary data-stream constructed from the old-style - // data-stream. Needed for backward compatibility - IStringStream solverDataStream - ( - const word& solverName, - Istream& solverData - ) const; + ); + //- Return the dictionary constructed from the old-style data-stream. + // Needed for backward compatibility + static dictionary solverDict(Istream&); -public: //- Runtime type information TypeName("ICCG"); @@ -90,7 +86,7 @@ public: // Constructors - //- Construct from matrix components and tolerances + //- Construct from matrix components and solver data stream ICCG ( const word& fieldName, @@ -98,11 +94,10 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - const scalar tolerance, - const scalar relTol = 0.0 + const dictionary& solverControls ); - //- Construct from matrix components and solver data stream + //- Construct from matrix components and tolerances ICCG ( const word& fieldName, @@ -110,20 +105,15 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const scalar tolerance, + const scalar relTol = 0.0 ); - // Destructor virtual ~ICCG() {} - - // Member Functions - - //- Read and reset the solver parameters from the given stream - void read(Istream& solverData); }; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C index 9100ae5777b8815e5d39bb20d09019bf4be7d761..af4137f689634bb1810e67bb75ad31e4dd02585d 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C @@ -46,7 +46,7 @@ Foam::PBiCG::PBiCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -56,7 +56,7 @@ Foam::PBiCG::PBiCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) {} @@ -70,12 +70,10 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve const direction cmpt ) const { - word preconditionerName(controlDict_.lookup("preconditioner")); - // --- Setup class containing solver performance data lduMatrix::solverPerformance solverPerf ( - preconditionerName + typeName, + lduMatrix::preconditioner::getName(controlDict_) + typeName, fieldName_ ); @@ -128,7 +126,7 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve lduMatrix::preconditioner::New ( *this, - controlDict_.lookup("preconditioner") + controlDict_ ); // --- Solver iteration diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H index 07adf0c8e41add0e7b559cadaedcebc61f16a000..6ba96fe9692a1697034398e4bca08ad15b90f236 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H @@ -77,7 +77,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C index a21eeaca15ceda3cf18d2272418e1fd88a3d57ff..ad0ae5a08120b90b6e335416bd5727763843da66 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C @@ -46,7 +46,7 @@ Foam::PCG::PCG const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -56,7 +56,7 @@ Foam::PCG::PCG interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) {} @@ -70,12 +70,10 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve const direction cmpt ) const { - word preconditionerName(controlDict_.lookup("preconditioner")); - // --- Setup class containing solver performance data lduMatrix::solverPerformance solverPerf ( - preconditionerName + typeName, + lduMatrix::preconditioner::getName(controlDict_) + typeName, fieldName_ ); @@ -119,7 +117,7 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve lduMatrix::preconditioner::New ( *this, - controlDict_.lookup("preconditioner") + controlDict_ ); // --- Solver iteration diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H index 6627bd45b1e3dbb3ef3aee245533dcb734c74a18..4e0b5b4e2811b30582a18c4a28ea100c17a78275 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H @@ -27,7 +27,7 @@ Class Description Preconditioned conjugate gradient solver for symmetric lduMatrices - using a run-time selectable preconditiioner. + using a run-time selectable preconditioner. SourceFiles PCG.C @@ -69,7 +69,7 @@ public: // Constructors - //- Construct from matrix components and solver data stream + //- Construct from matrix components and solver controls PCG ( const word& fieldName, @@ -77,7 +77,7 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C index 583a2008e3d5f4e26dbb855fd1d245cbe633f433..3255ca896ae1402fa508b46f021ef797188be5c5 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C @@ -43,7 +43,7 @@ Foam::diagonalSolver::diagonalSolver const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -53,19 +53,13 @@ Foam::diagonalSolver::diagonalSolver interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData + solverControls ) {} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void Foam::diagonalSolver::read(Istream& solverData) -{ - word solverName(solverData); -} - - Foam::lduMatrix::solverPerformance Foam::diagonalSolver::solve ( scalarField& psi, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H index 573f4cc233e2d3ea70d0b7654c613309ffce9126..b4ac77631262dea96216f3d95bfbbdb78008836f 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H @@ -68,7 +68,7 @@ public: // Constructors - //- Construct from matrix + //- Construct from matrix and solver controls diagonalSolver ( const word& fieldName, @@ -76,14 +76,15 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); // Member Functions //- Read and reset the solver parameters from the given stream - void read(Istream& solverData); + void read(const dictionary&) + {} //- Solve the matrix with this solver lduMatrix::solverPerformance solve diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C index 6b7c1cbcc3c66d9c9c33f9c1361f76433ca0602f..503e376bd28991ad8cfd5e9091aa6c8ee841567d 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C @@ -49,7 +49,7 @@ Foam::smoothSolver::smoothSolver const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ) : lduMatrix::solver @@ -59,9 +59,8 @@ Foam::smoothSolver::smoothSolver interfaceBouCoeffs, interfaceIntCoeffs, interfaces, - solverData - ), - nSweeps_(1) + solverControls + ) { readControls(); } @@ -72,7 +71,7 @@ Foam::smoothSolver::smoothSolver void Foam::smoothSolver::readControls() { lduMatrix::solver::readControls(); - controlDict_.readIfPresent("nSweeps", nSweeps_); + nSweeps_ = controlDict_.lookupOrDefault<label>("nSweeps", 1); } @@ -96,7 +95,7 @@ Foam::lduMatrix::solverPerformance Foam::smoothSolver::solve interfaceBouCoeffs_, interfaceIntCoeffs_, interfaces_, - controlDict_.lookup("smoother") + controlDict_ ); smootherPtr->smooth @@ -144,7 +143,7 @@ Foam::lduMatrix::solverPerformance Foam::smoothSolver::solve interfaceBouCoeffs_, interfaceIntCoeffs_, interfaces_, - controlDict_.lookup("smoother") + controlDict_ ); // Smoothing loop diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H index 3d5687a8a93d81172d7b14448546618db1d27ed8..15ddf7bf3b2750b25c07f27d7f3eb537bed4f4b7 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H @@ -66,7 +66,6 @@ protected: //- Read the control parameters from the controlDict_ virtual void readControls(); - public: //- Runtime type information @@ -75,7 +74,7 @@ public: // Constructors - //- Construct from matrix components and solver data stream + //- Construct from matrix components and solver controls smoothSolver ( const word& fieldName, @@ -83,10 +82,15 @@ public: const FieldField<Field, scalar>& interfaceBouCoeffs, const FieldField<Field, scalar>& interfaceIntCoeffs, const lduInterfaceFieldPtrsList& interfaces, - Istream& solverData + const dictionary& solverControls ); + // Destructor + + virtual ~smoothSolver() + {} + // Member Functions //- Solve the matrix with this solver diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 5429a20e8177fe8365fbdff1ebbcc9df2a5f1aee..44ecc4792cbb0592c203733fae129684c7970300 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -27,9 +27,22 @@ License #include "solution.H" #include "Time.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// these are for old syntax compatibility: +#include "BICCG.H" +#include "ICCG.H" +#include "IStringStream.H" -int Foam::solution::debug(Foam::debug::debugSwitch("solution", false)); +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +int Foam::solution::debug(::Foam::debug::debugSwitch("solution", 0)); + +// list of sub-dictionaries to rewrite +//! @cond localScope +static const Foam::List<Foam::word> subDictNames +( + Foam::IStringStream("(preconditioner smoother)")() +); +//! @endcond localScope // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -55,6 +68,84 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::label Foam::solution::upgradeSolverDict +( + dictionary& dict, + const bool verbose +) +{ + label nChanged = 0; + + // backward compatibility: + // recast primitive entries into dictionary entries + forAllIter(dictionary, dict, iter) + { + if (!iter().isDict()) + { + Istream& is = iter().stream(); + word name(is); + dictionary subdict; + + if (name == "BICCG") + { + // special treatment for very old syntax + subdict = BICCG::solverDict(is); + } + else if (name == "ICCG") + { + // special treatment for very old syntax + subdict = ICCG::solverDict(is); + } + else + { + subdict.add("solver", name); + subdict <<= dictionary(is); + + // preconditioner and smoother entries can be + // 1) primitiveEntry w/o settings, + // 2) or a dictionaryEntry. + // transform primitiveEntry with settings -> dictionaryEntry + forAll(subDictNames, dictI) + { + const word& dictName = subDictNames[dictI]; + entry* ePtr = subdict.lookupEntryPtr(dictName,false,false); + + if (ePtr && !ePtr->isDict()) + { + Istream& is = ePtr->stream(); + is >> name; + + if (!is.eof()) + { + dictionary newDict; + newDict.add(dictName, name); + newDict <<= dictionary(is); + + subdict.set(dictName, newDict); + } + } + } + } + + + // write out information to help people adjust to the new syntax + if (verbose) + { + Info<< "// using new solver syntax:\n" + << iter().keyword() << subdict << endl; + } + + // overwrite with dictionary entry + dict.set(iter().keyword(), subdict); + + nChanged++; + } + } + + return nChanged; +} + + bool Foam::solution::read() { if (regIOobject::read()) @@ -69,6 +160,7 @@ bool Foam::solution::read() if (dict.found("solvers")) { solvers_ = dict.subDict("solvers"); + upgradeSolverDict(solvers_); } return true; @@ -97,7 +189,7 @@ bool Foam::solution::relax(const word& name) const { if (debug) { - Info<< "Lookup relax for " << name << endl; + Info<< "Find relax for " << name << endl; } return relaxationFactors_.found(name); @@ -127,7 +219,7 @@ const Foam::dictionary& Foam::solution::solverDict(const word& name) const } -Foam::ITstream& Foam::solution::solver(const word& name) const +const Foam::dictionary& Foam::solution::solver(const word& name) const { if (debug) { @@ -135,7 +227,7 @@ Foam::ITstream& Foam::solution::solver(const word& name) const << "Lookup solver for " << name << endl; } - return solvers_.lookup(name); + return solvers_.subDict(name); } diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index 3d455fdecc31e8f8ee3d18e80a394082e2d2877f..3db89d9fc15b8f73f69854fe71937599a43dc31a 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class solution Declaration + Class solution Declaration \*---------------------------------------------------------------------------*/ class solution @@ -59,7 +59,6 @@ class solution //- Dictionary of solver parameters for all the fields dictionary solvers_; - // Private Member Functions //- Disallow default bitwise copy construct and assignment @@ -69,6 +68,11 @@ class solution public: + //- Update from older solver controls syntax + // Usually verbose, since we want to know about the changes + // Returns the number of settings changed + static label upgradeSolverDict(dictionary& dict, const bool verbose=true); + //- Debug switch static int debug; @@ -84,7 +88,7 @@ public: // Access //- Return the selected sub-dictionary of solvers if the "select" - // keyword is given othewise return the complete dictionary + // keyword is given, otherwise return the complete dictionary const dictionary& solutionDict() const; //- Return true if the relaxation factor is given for the field @@ -93,13 +97,11 @@ public: //- Return the relaxation factor for the given field scalar relaxationFactor(const word& name) const; - //- Return the dictionary of solver parameters for the given field + //- Return the solver controls dictionary for the given field const dictionary& solverDict(const word& name) const; - //- Return the stream of solver parameters for the given field - // @deprecated Backward compatibility only - should use solverDict - ITstream& solver(const word& name) const; - + //- Return the solver controls dictionary for the given field + const dictionary& solver(const word& name) const; // Read diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C index 0fadb614bb2df69591b306503ec79e874bdf5e3b..e545798895a2bca973b9425f3300b3283608438f 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C @@ -27,14 +27,9 @@ License #include "cellModel.H" #include "pyramid.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -vector cellModel::centre +Foam::vector Foam::cellModel::centre ( const labelList& pointLabels, const pointField& points @@ -91,7 +86,7 @@ vector cellModel::centre } -scalar cellModel::mag +Foam::scalar Foam::cellModel::mag ( const labelList& pointLabels, const pointField& points @@ -143,9 +138,4 @@ scalar cellModel::mag return v; } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C index a2656f838433e68bf5feb520d980327801708b56..7d69b5238c8160f72bb66d98e45d9b12d3024b41 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C @@ -29,12 +29,58 @@ Description #include "cellModeller.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -namespace Foam +Foam::cellModeller::cellModeller() { + if (modelPtrs_.size()) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "attempt to re-construct cellModeller when it already exists" + << exit(FatalError); + } + + label maxIndex = 0; + forAll(models_, i) + { + if (models_[i].index() > maxIndex) maxIndex = models_[i].index(); + } + + modelPtrs_.setSize(maxIndex + 1); + modelPtrs_ = NULL; -cellModeller::~cellModeller() + // For all the words in the wordlist, set the details of the model + // to those specified by the word name and the other parameters + // given. This should result in an automatic 'read' of the model + // from its File (see cellModel class). + forAll(models_, i) + { + if (modelPtrs_[models_[i].index()]) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "more than one model share the index " + << models_[i].index() + << exit(FatalError); + } + + modelPtrs_[models_[i].index()] = &models_[i]; + + if (modelDictionary_.found(models_[i].name())) + { + FatalErrorIn("cellModeller::cellModeller(const fileName&)") + << "more than one model share the name " + << models_[i].name() + << exit(FatalError); + } + + modelDictionary_.insert(models_[i].name(), &models_[i]); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cellModeller::~cellModeller() {} @@ -43,9 +89,9 @@ cellModeller::~cellModeller() // Returns a pointer to a model which matches the string symbol // supplied. A null pointer is returned if there is no suitable match. -const cellModel* cellModeller::lookup(const word& symbol) +const Foam::cellModel* Foam::cellModeller::lookup(const word& name) { - HashTable<const cellModel*>::iterator iter = modelDictionary_.find(symbol); + HashTable<const cellModel*>::iterator iter = modelDictionary_.find(name); if (iter != modelDictionary_.end()) { @@ -57,9 +103,7 @@ const cellModel* cellModeller::lookup(const word& symbol) } } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H index 4f6f2ee70f679976bd23d599a8fde26f23ea0bb7..11e642d2d4d7df78b519a12ff00ad07efcf3100c 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H @@ -48,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class cellModeller Declaration + Class cellModeller Declaration \*---------------------------------------------------------------------------*/ class cellModeller @@ -69,10 +69,9 @@ public: // Constructors - //- Construct given file name + //- Construct from central "cellModels" file cellModeller(); - // Destructor ~cellModeller(); @@ -80,12 +79,10 @@ public: // Member functions - //- Look up a model given name and return ptr to model if good - // else zero + //- Look up a model by name and return a pointer to the model or NULL static const cellModel* lookup(const word&); - //- Look up a model given label and return ptr to model if good - // else zero + //- Look up a model by index and return a pointer to the model or NULL static const cellModel* lookup(const label i) { return modelPtrs_[i]; diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C deleted file mode 100644 index ef3eb17df26f7637d860b1ace079f61aafe5f08c..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModellerIO.C +++ /dev/null @@ -1,91 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Description - Reads the data portion of a model catalogue File. - -\*---------------------------------------------------------------------------*/ - -#include "cellModeller.H" -#include "dictionary.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -cellModeller::cellModeller() -{ - if (modelPtrs_.size()) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "attempt to re-construct cellModeller when it already exists" - << exit(FatalError); - } - - label maxIndex = 0; - forAll(models_, i) - { - if (models_[i].index() > maxIndex) maxIndex = models_[i].index(); - } - - modelPtrs_.setSize(maxIndex + 1); - modelPtrs_ = NULL; - - // For all the words in the wordlist, set the details of the model - // to those specified by the word name and the other parameters - // given. This should result in an automatic 'read' of the model - // from its File (see cellModel class). - forAll(models_, i) - { - if (modelPtrs_[models_[i].index()]) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "more than one model share the index " - << models_[i].index() - << exit(FatalError); - } - - modelPtrs_[models_[i].index()] = &models_[i]; - - if (modelDictionary_.found(models_[i].name())) - { - FatalErrorIn("cellModeller::cellModeller(const fileName&)") - << "more than one model share the name " - << models_[i].name() - << exit(FatalError); - } - - modelDictionary_.insert(models_[i].name(), &models_[i]); - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C index 54e73f855b5fa593094d104ebeb93de9fa485bf7..7f5b6274513c714f46229cb6a606bf7c2f009a33 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C @@ -23,6 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description + cellModeller global initializations \*---------------------------------------------------------------------------*/ @@ -30,24 +31,25 @@ Description #include "OSspecific.H" #include "IFstream.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * * // + // PtrList of models -PtrList<cellModel> cellModeller::models_ +Foam::PtrList<Foam::cellModel> Foam::cellModeller::models_ ( - (IFstream(dotFoam("cellModels"))()) + IFstream(findEtcFile("cellModels", true))() ); // List of model pointers -List<cellModel*> cellModeller::modelPtrs_; +Foam::List<Foam::cellModel*> Foam::cellModeller::modelPtrs_; // HashTable of model pointers -HashTable<const cellModel*> cellModeller::modelDictionary_; +Foam::HashTable<const Foam::cellModel*> Foam::cellModeller::modelDictionary_; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ // Construct a dummy cellModeller which reads the models and fills // the above tables diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 8fdee370a05e9b06c5b7a8b1b67503ee4cb72063..0650dcc87978e069a19474db29a945a208c33e30 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -393,12 +393,11 @@ void Foam::globalMeshData::calcSharedEdges() const } } } - dynSharedEdgeLabels.shrink(); + sharedEdgeLabelsPtr_ = new labelList(); labelList& sharedEdgeLabels = *sharedEdgeLabelsPtr_; sharedEdgeLabels.transfer(dynSharedEdgeLabels); - dynSharedEdgeAddr.shrink(); sharedEdgeAddrPtr_ = new labelList(); labelList& sharedEdgeAddr = *sharedEdgeAddrPtr_; sharedEdgeAddr.transfer(dynSharedEdgeAddr); diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C index 6cf680ca70f3ebc4765aca9af3418d4dcc7cef15..93382ec2a43e5b4cd6f1741207ef01c5c9f790c9 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalPoints.C @@ -467,10 +467,8 @@ void Foam::globalPoints::remove(const Map<label>& directNeighbours) Map<label> oldMeshToProcPoint(meshToProcPoint_); meshToProcPoint_.clear(); - procPoints_.shrink(); List<procPointList> oldProcPoints; oldProcPoints.transfer(procPoints_); - procPoints_.clear(); // Go through all equivalences for @@ -535,7 +533,7 @@ void Foam::globalPoints::remove(const Map<label>& directNeighbours) { // This happens for 'wedge' like cyclics where the two halves // come together in the same point so share the same meshPoint. - // So this meshPoint will have info of size one only. + // So this meshPoint will have info of size one only. if ( pointInfo[0][0] != Pstream::myProcNo() @@ -968,7 +966,7 @@ Foam::globalPoints::globalPoints(const polyMesh& mesh) // Pout<< " pointI:" << meshPointI << ' ' // << mesh.points()[meshPointI] // << " connected to proc " << pointInfo[i][0] - // << " point:" << pointInfo[i][1] + // << " point:" << pointInfo[i][1] // << endl; // } //} diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index e7d7567a138da742b2eb21630b1b0866aad718ad..2d5bd5eb972c38a5b2c0f5ad701c4e11171bf30e 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -28,6 +28,7 @@ License #include "polyMesh.H" #include "primitiveMesh.H" #include "processorPolyPatch.H" +#include "stringListOps.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -420,13 +421,13 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet forAll(patchNames, i) { - // Treat the diven patch names as wild-cards and search the set + // Treat the given patch names as wild-cards and search the set // of all patch names for matches labelList patchIDs = findStrings(patchNames[i], allPatchNames); if (patchIDs.size() == 0) { - WarningIn("polyBoundaryMesh::patchSet(const wordList& patchNames)") + WarningIn("polyBoundaryMesh::patchSet(const wordList&)") << "Cannot find any patch names matching " << patchNames[i] << endl; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index 19418a23114dcf02aa3c7c1e56b29de242a5afc2..a004cfa8e279d85344ea9efd17608f77ceb16c98 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -64,7 +64,7 @@ Foam::labelListList Foam::polyMesh::cellShapePointCells forAll (pc, pointI) { - pointCellAddr[pointI].transfer(pc[pointI].shrink()); + pointCellAddr[pointI].transfer(pc[pointI]); } return pointCellAddr; diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C index 825af4cb706757fe69614ceeb264cd00208e164d..36ebdc8324e675d9010efe379256ad59b7140d11 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchAddressing.C @@ -298,7 +298,7 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing() forAll (faceFaces, faceI) { - faceFaces[faceI].transfer(ff[faceI].shrink()); + faceFaces[faceI].transfer(ff[faceI]); } diff --git a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C index 0f2d45ebf2bc15a902507c834869f1dcbf919010..f9a74e01990ca32d4977a5f1ff1426bde840b0f3 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchEdgeLoops.C @@ -151,8 +151,6 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcEdgeLoops() while (currentEdgeI != -1); // Done all for current loop. Transfer to edgeLoops. - loop.shrink(); - edgeLoops[loopI].transfer(loop); loopI++; diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C index 47d6343f16e42639aa8f5bd9c1f277d73f773e13..d12cf2ca5da134e725ad44ea7c6935f49738a607 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellEdges.C @@ -108,7 +108,7 @@ void Foam::primitiveMesh::calcCellEdges() const // reset the size forAll (ce, cellI) { - cellEdgeAddr[cellI].transfer(ce[cellI].shrink()); + cellEdgeAddr[cellI].transfer(ce[cellI]); } } } diff --git a/src/OpenFOAM/primitives/Lists/stringList.H b/src/OpenFOAM/primitives/Lists/stringList.H index 2c02ae1c6f44ecedbb84b3d96ca4dc2d107606af..b3f60e2d1152cfb8fdd975889319c12d7cbae48e 100644 --- a/src/OpenFOAM/primitives/Lists/stringList.H +++ b/src/OpenFOAM/primitives/Lists/stringList.H @@ -34,27 +34,15 @@ Description #define stringList_H #include "string.H" -#include "labelList.H" +#include "List.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { typedef List<string> stringList; - - //- Return the indices of the strings in the list - // that match the given regular expression - template<class StringList> - labelList findStrings(const string& regexp, const StringList&); } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "stringListTemplates.C" -#endif - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/applications/test/hmm/calcEntry/calcEntry.H b/src/OpenFOAM/primitives/Lists/stringListOps.H similarity index 60% rename from applications/test/hmm/calcEntry/calcEntry.H rename to src/OpenFOAM/primitives/Lists/stringListOps.H index ced8516f388b9bcff3d4e034d233c2c78f3d87f5..e814d88e13c27fdf67d212a045bf53bcd582c54c 100644 --- a/applications/test/hmm/calcEntry/calcEntry.H +++ b/src/OpenFOAM/primitives/Lists/stringListOps.H @@ -22,72 +22,46 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Class - Foam::functionEntries::calcEntry +InNamspace + Foam Description + Operations on lists of strings. SourceFiles - calcEntry.C + stringListOpsTemplates.C \*---------------------------------------------------------------------------*/ -#ifndef calcEntry_H -#define calcEntry_H +#ifndef stringListOps_H +#define stringListOps_H -#include "functionEntry.H" +#include "labelList.H" +#include "stringList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -namespace functionEntries -{ - -/*---------------------------------------------------------------------------*\ - Class calcEntry Declaration -\*---------------------------------------------------------------------------*/ - -class calcEntry -: - public functionEntry -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - calcEntry(const calcEntry&); - - //- Disallow default bitwise assignment - void operator=(const calcEntry&); - -public: - - //- Runtime type information - TypeName("calc"); - - - // Member Functions - - static bool insert - ( - const dictionary& parentDict, - primitiveEntry& entry, - Istream& is - ); - - static bool insert - ( - dictionary& parentDict, - Istream& is - ); -}; + //- Return the indices of the strings in the list + // that match the given regular expression + // partial matches are optional + template<class StringType> + labelList findStrings + ( + const string& regexpPattern, + const UList<StringType>&, + bool partialMatch=false + ); +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace functionEntries -} // End namespace Foam +#ifdef NoRepository +# include "stringListOpsTemplates.C" +#endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/Lists/stringListTemplates.C b/src/OpenFOAM/primitives/Lists/stringListOpsTemplates.C similarity index 80% rename from src/OpenFOAM/primitives/Lists/stringListTemplates.C rename to src/OpenFOAM/primitives/Lists/stringListOpsTemplates.C index a93c46e8ac2f0269d44a9577ff885189c6043495..e1075b3ea5f8389951f8c3c535cb61322d00c366 100644 --- a/src/OpenFOAM/primitives/Lists/stringListTemplates.C +++ b/src/OpenFOAM/primitives/Lists/stringListOpsTemplates.C @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "labelList.H" -#include "regularExpression.H" +#include "regExp.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -34,25 +34,28 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template<class StringList> -labelList findStrings(const string& regexp, const StringList& sl) +template<class StringType> +labelList findStrings +( + const string& pattern, + const UList<StringType>& lst, + bool partialMatch +) { - labelList matches(sl.size()); + regExp re(pattern); + labelList matched(lst.size()); - regularExpression re(regexp); - - label matchi = 0; - forAll(sl, i) + label matchI = 0; + forAll(lst, elemI) { - if (re.matches(sl[i])) + if (re.match(lst[elemI], partialMatch)) { - matches[matchi++] = i; + matched[matchI++] = elemI; } } + matched.setSize(matchI); - matches.setSize(matchi); - - return matches; + return matched; } diff --git a/src/OpenFOAM/primitives/strings/keyType/keyType.H b/src/OpenFOAM/primitives/strings/keyType/keyType.H index 4d4c358d5d172f3cb831884246d9411872d0721c..6525a5404c8e119a0e1b3200378ff3baf07417b5 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyType.H +++ b/src/OpenFOAM/primitives/strings/keyType/keyType.H @@ -28,8 +28,8 @@ Class Description A class for handling keywords in dictionaries. - A keyType is the keyword of a dictionary. It differs from word in that - it accepts wildcards. + A keyType is the keyword of a dictionary. + It differs from word in that it accepts patterns (regular expressions). SourceFiles keyType.C @@ -53,7 +53,7 @@ class Ostream; /*---------------------------------------------------------------------------*\ - Class keyType Declaration + Class keyType Declaration \*---------------------------------------------------------------------------*/ class keyType @@ -62,7 +62,8 @@ class keyType { // Private member data - bool isWildCard_; + //- Is the keyType a pattern (regular expression) + bool isPattern_; // Private Member Functions @@ -78,22 +79,22 @@ public: inline keyType(); //- Construct as copy - inline keyType(const keyType& s); + inline keyType(const keyType&); //- Construct as copy of word - inline keyType(const word& s); + inline keyType(const word&); //- Construct as copy of string. Expect it to be regular expression. - inline keyType(const string& s); + inline keyType(const string&); //- Construct as copy of character array - inline keyType(const char* s); + inline keyType(const char*); //- Construct as copy of std::string - inline keyType(const std::string& s, const bool isWildCard); + inline keyType(const std::string&, const bool isPattern); //- Construct from Istream - keyType(Istream& is); + keyType(Istream&); // Member functions @@ -101,29 +102,25 @@ public: //- Is this character valid for a keyType inline static bool valid(char c); - //- Is the type a wildcard? - inline bool isWildCard() const; - + //- Should be treated as a match rather than a literal string + inline bool isPattern() const; // Member operators // Assignment - inline void operator=(const keyType& s); + inline void operator=(const keyType&); + inline void operator=(const word&); //- Assign from regular expression. - inline void operator=(const string& s); - - inline void operator=(const word& s); - + inline void operator=(const string&); inline void operator=(const char*); // IOstream operators - friend Istream& operator>>(Istream& is, keyType& w); - - friend Ostream& operator<<(Ostream& os, const keyType& w); + friend Istream& operator>>(Istream&, keyType&); + friend Ostream& operator<<(Ostream&, const keyType&); }; diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H index f3785ebbffe68b68d0093a79cc55f7e70d2e47c8..d76205d795776d624c94367e01c7db76f8babc77 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H +++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H @@ -30,43 +30,40 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -//- Construct null inline Foam::keyType::keyType() : word(), - isWildCard_(false) + isPattern_(false) {} -//- Construct as copy inline Foam::keyType::keyType(const keyType& s) : word(s, false), - isWildCard_(s.isWildCard()) + isPattern_(s.isPattern()) {} -//- Construct as copy of word inline Foam::keyType::keyType(const word& s) : word(s, false), - isWildCard_(false) + isPattern_(false) {} -//- Construct as copy of string. Expect it to be regular expression +// Construct as copy of string. Expect it to be regular expression inline Foam::keyType::keyType(const string& s) : word(s, false), - isWildCard_(true) + isPattern_(true) {} -//- Construct as copy of character array +// Construct as copy of character array inline Foam::keyType::keyType(const char* s) : word(s, false), - isWildCard_(false) + isPattern_(false) {} @@ -74,11 +71,11 @@ inline Foam::keyType::keyType(const char* s) inline Foam::keyType::keyType ( const std::string& s, - const bool isWildCard + const bool isPattern ) : word(s, false), - isWildCard_(isWildCard) + isPattern_(isPattern) {} @@ -90,9 +87,9 @@ inline bool Foam::keyType::valid(char c) } -bool Foam::keyType::isWildCard() const +bool Foam::keyType::isPattern() const { - return isWildCard_; + return isPattern_; } @@ -102,14 +99,14 @@ inline void Foam::keyType::operator=(const keyType& s) { // Bypass checking string::operator=(s); - isWildCard_ = s.isWildCard(); + isPattern_ = s.isPattern_; } inline void Foam::keyType::operator=(const word& s) { word::operator=(s); - isWildCard_ = false; + isPattern_ = false; } @@ -117,7 +114,7 @@ inline void Foam::keyType::operator=(const string& s) { // Bypass checking string::operator=(s); - isWildCard_ = true; + isPattern_ = true; } @@ -125,7 +122,7 @@ inline void Foam::keyType::operator=(const char* s) { // Bypass checking string::operator=(s); - isWildCard_ = false; + isPattern_ = false; } diff --git a/src/OpenFOAM/primitives/strings/string/string.C b/src/OpenFOAM/primitives/strings/string/string.C index b3c218eacd1b2cef3586c4de36d7b4a1045e8f58..38393bfca7302740cded5dc6dca205d8ef88ca84 100644 --- a/src/OpenFOAM/primitives/strings/string/string.C +++ b/src/OpenFOAM/primitives/strings/string/string.C @@ -202,7 +202,7 @@ Foam::string& Foam::string::expand() // otherwise add extra test if (user == "OpenFOAM") { - *this = dotFoam(file); + *this = findEtcFile(file); } else { diff --git a/src/OpenFOAM/primitives/strings/string/string.H b/src/OpenFOAM/primitives/strings/string/string.H index 82cc904ef48f3fb01d87d8bcdbea4d238c0fb5d6..13e996b5110aa98f2a1f1c0190e202118397ba4e 100644 --- a/src/OpenFOAM/primitives/strings/string/string.H +++ b/src/OpenFOAM/primitives/strings/string/string.H @@ -34,7 +34,7 @@ Description Used as a base class for word and fileName. See Also - Foam::dotFoam() for information about the site/user OpenFOAM + Foam::findEtcFile() for information about the site/user OpenFOAM configuration directory SourceFiles @@ -176,7 +176,7 @@ public: // - leading "~OpenFOAM" : site/user OpenFOAM configuration directory // // @sa - // Foam::dotFoam + // Foam::findEtcFile string& expand(); //- Remove repeated characters returning true if string changed diff --git a/src/OpenFOAM/primitives/strings/word/word.H b/src/OpenFOAM/primitives/strings/word/word.H index 6565c28b4f8ede3a084ac9c56fc67513e8ac6052..96d2c73cfb864fc6349e50e2577b29a363f35210 100644 --- a/src/OpenFOAM/primitives/strings/word/word.H +++ b/src/OpenFOAM/primitives/strings/word/word.H @@ -87,7 +87,7 @@ public: inline word(const word&); //- Construct as copy of character array - inline word(const char*, const bool doStripInvalid = true); + inline word(const char*, const bool doStripInvalid=true); //- Construct as copy with a maximum number of characters inline word @@ -98,10 +98,10 @@ public: ); //- Construct as copy of string - inline word(const string&, const bool doStripInvalid = true); + inline word(const string&, const bool doStripInvalid=true); //- Construct as copy of std::string - inline word(const std::string&, const bool doStripInvalid = true); + inline word(const std::string&, const bool doStripInvalid=true); //- Construct from Istream word(Istream&); diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index 3083370ad766706f4666510cfe47e1f6a0c4a85a..f43c2b1a30a3f05be9019deb965bf619c95f203e 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -5,7 +5,11 @@ set -x wmake libso dummy case "$WM_MPLIB" in -LAM | OPENMPI | MPI | MPICH | MPICH-GM | HPMPI | MPIGAMMA ) +GAMMA) + wmake libso gamma + ;; + +LAM | *MPI* ) export WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB set +x echo @@ -13,10 +17,6 @@ LAM | OPENMPI | MPI | MPICH | MPICH-GM | HPMPI | MPIGAMMA ) set -x wmake libso mpi ;; - -GAMMA) - wmake libso gamma - ;; esac # ----------------------------------------------------------------- end-of-file diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index 6d98bdfebc0701197152ed8094d5df595572a4d5..8b3e527d37d2a1aae45681b4d5e9b06fed051f8e 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -546,7 +546,7 @@ void Foam::meshRefinement::calcLocalRegions } } } - localCc.shrink(); + localPoints.transfer(localCc); if (localPoints.size() != globalToLocalRegion.size()) diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index fdcd15f0e98d548b2d10647e81a3ef7001221a5a..950cc7251b4ae9afc89a1c52faced4e71cc6266d 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -205,7 +205,7 @@ Foam::label Foam::meshRefinement::getBafflePatch WarningIn ( - "meshRefinement::getBafflePatch(const labelList& const label)" + "meshRefinement::getBafflePatch(const labelList&, const label)" ) << "Could not find boundary face neighbouring internal face " << faceI << " with face centre " << mesh_.faceCentres()[faceI] << nl @@ -1854,16 +1854,15 @@ void Foam::meshRefinement::findCellZoneTopo { break; } - } - - // Synchronise regionToCellZone. - // Note: - // - region numbers are identical on all processors - // - keepRegion is identical ,, - // - cellZones are identical ,, - Pstream::listCombineGather(regionToCellZone, maxEqOp<label>()); - Pstream::listCombineScatter(regionToCellZone); + // Synchronise regionToCellZone. + // Note: + // - region numbers are identical on all processors + // - keepRegion is identical ,, + // - cellZones are identical ,, + Pstream::listCombineGather(regionToCellZone, maxEqOp<label>()); + Pstream::listCombineScatter(regionToCellZone); + } forAll(regionToCellZone, regionI) diff --git a/src/conversion/polyDualMesh/polyDualMesh.C b/src/conversion/polyDualMesh/polyDualMesh.C index 9b310d2bf4843589658fc4f61e76fcb7861a2dac..73ca981f98a8f58b85b3c650af77a7a84d8868bf 100644 --- a/src/conversion/polyDualMesh/polyDualMesh.C +++ b/src/conversion/polyDualMesh/polyDualMesh.C @@ -412,11 +412,9 @@ void Foam::polyDualMesh::collectPatchInternalFace } } - dualFace2.transfer(dualFace.shrink()); - dualFace.clear(); + dualFace2.transfer(dualFace); - featEdgeIndices2.transfer(featEdgeIndices.shrink()); - featEdgeIndices.clear(); + featEdgeIndices2.transfer(featEdgeIndices); if (reverseFace) { @@ -1590,8 +1588,7 @@ void Foam::polyDualMesh::calcFeatures allFeaturePoints.append(allBoundary.meshPoints()[pointI]); } } - featurePoints.transfer(allFeaturePoints.shrink()); - allFeaturePoints.clear(); + featurePoints.transfer(allFeaturePoints); if (debug) { @@ -1633,8 +1630,7 @@ void Foam::polyDualMesh::calcFeatures allFeatureEdges.append(meshEdges[edgeI]); } } - featureEdges.transfer(allFeatureEdges.shrink()); - allFeatureEdges.clear(); + featureEdges.transfer(allFeatureEdges); } diff --git a/src/decompositionAgglomeration/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/decompositionAgglomeration/decompositionMethods/decompositionMethod/decompositionMethod.C index 071a63affc0641b003f16673c745696141ce1a75..f2b929c6567ffef4b8e57f489657d8b03785c2ef 100644 --- a/src/decompositionAgglomeration/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/decompositionAgglomeration/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -165,8 +165,7 @@ void Foam::decompositionMethod::calcCellCells cellCells.setSize(dynCellCells.size()); forAll(dynCellCells, coarseI) { - cellCells[coarseI].transfer(dynCellCells[coarseI].shrink()); - dynCellCells[coarseI].clear(); + cellCells[coarseI].transfer(dynCellCells[coarseI]); } } diff --git a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C index 8b3092f08f6ea860ca0133b9acd49009ce7cab3a..0df751b6ded31c1f900f6fe509314f0d8c31545e 100644 --- a/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C +++ b/src/decompositionAgglomeration/parMetisDecomp/parMetisDecomp.C @@ -794,8 +794,7 @@ Foam::labelList Foam::parMetisDecomp::decompose globalRegionRegions.setSize(dynRegionRegions.size()); forAll(dynRegionRegions, i) { - globalRegionRegions[i].transfer(dynRegionRegions[i].shrink()); - dynRegionRegions[i].clear(); + globalRegionRegions[i].transfer(dynRegionRegions[i]); } } @@ -859,7 +858,7 @@ Foam::labelList Foam::parMetisDecomp::decompose // Check for user supplied weights and decomp options if (decompositionDict_.found("metisCoeffs")) { - const dictionary& metisCoeffs = + const dictionary& metisCoeffs = decompositionDict_.subDict("metisCoeffs"); word weightsFile; diff --git a/src/dynamicMesh/boundaryMesh/boundaryMesh.C b/src/dynamicMesh/boundaryMesh/boundaryMesh.C index 76201ff987c91e29e48f6b5710a3fb1c398ad849..817317a62e7483417b8caa231a4dc1565a0564be 100644 --- a/src/dynamicMesh/boundaryMesh/boundaryMesh.C +++ b/src/dynamicMesh/boundaryMesh/boundaryMesh.C @@ -1503,17 +1503,13 @@ void Foam::boundaryMesh::setExtraEdges(const label edgeI) { labelList minDistance(mesh().nEdges(), -1); - // All edge labels encountered - + // All edge labels encountered DynamicList<label> visitedEdges; // Floodfill from edgeI starting from distance 0. Stop at distance. markEdges(8, edgeI, 0, minDistance, visitedEdges); - visitedEdges.shrink(); - // Set edge labels to display - //? Allowed to transfer from DynamicList to List extraEdges_.transfer(visitedEdges); } diff --git a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C index e74a5691e38ba712c8991707660917ed111c2287..2a6630333f59b6248c8fb802aef10ad241f99e4b 100644 --- a/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/topoCellLooper.C @@ -70,7 +70,7 @@ void Foam::topoCellLooper::subsetList << "startI:" << startI << " freeI:" << freeI << " lst:" << lst << abort(FatalError); } - lst.setSize(freeI); + lst.setCapacity(freeI); } else { @@ -88,7 +88,7 @@ void Foam::topoCellLooper::subsetList << " lst:" << lst << abort(FatalError); } - lst.setSize(freeI - startI); + lst.setCapacity(freeI - startI); } } @@ -787,9 +787,6 @@ bool Foam::topoCellLooper::cut } else { - localLoop.shrink(); - localLoopWeights.shrink(); - loop.transfer(localLoop); loopWeights.transfer(localLoopWeights); @@ -799,17 +796,16 @@ bool Foam::topoCellLooper::cut else { // Let parent handle poly case. - return - hexCellLooper::cut - ( - refDir, - cellI, - vertIsCut, - edgeIsCut, - edgeWeight, - loop, - loopWeights - ); + return hexCellLooper::cut + ( + refDir, + cellI, + vertIsCut, + edgeIsCut, + edgeWeight, + loop, + loopWeights + ); } } } diff --git a/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C b/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C index 391b513758e9cdcbfe63db653040af07e92bfda9..34912f8c27cee49cb097f55d9d7db45541a1a02d 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C +++ b/src/dynamicMesh/meshCut/meshModifiers/boundaryCutter/boundaryCutter.C @@ -131,11 +131,8 @@ Foam::face Foam::boundaryCutter::addEdgeCutsToFace } } - newFace.shrink(); - face returnFace; returnFace.transfer(newFace); - newFace.clear(); if (debug) { @@ -361,9 +358,7 @@ bool Foam::boundaryCutter::splitFace { // Enough vertices to create a face from. face tmpFace; - newFace.shrink(); tmpFace.transfer(newFace); - newFace.clear(); // Add face tmpFace addFace(faceI, tmpFace, modifiedFace, meshMod); @@ -381,9 +376,7 @@ bool Foam::boundaryCutter::splitFace { // Enough vertices to create a face from. face tmpFace; - newFace.shrink(); tmpFace.transfer(newFace); - newFace.clear(); // Add face tmpFace addFace(faceI, tmpFace, modifiedFace, meshMod); diff --git a/src/dynamicMesh/meshCut/wallLayerCells/wallLayerCells.C b/src/dynamicMesh/meshCut/wallLayerCells/wallLayerCells.C index 9632618c8a60b577e6d4ba0b2c22d729550d0c6c..c46266496f5c19a18dc21d6981744faf0039201d 100644 --- a/src/dynamicMesh/meshCut/wallLayerCells/wallLayerCells.C +++ b/src/dynamicMesh/meshCut/wallLayerCells/wallLayerCells.C @@ -222,8 +222,6 @@ Foam::wallLayerCells::wallLayerCells } } - refineCells.shrink(); - // Transfer refineCells storage to this. transfer(refineCells); } diff --git a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C index b7edb38f2bb8af1b0eb0e925b562290f92fdaf16..b59d97f19db59665e481d69bb2228317d9e6294e 100644 --- a/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C +++ b/src/dynamicMesh/polyMeshAdder/polyMeshAdder.C @@ -489,7 +489,6 @@ void Foam::polyMeshAdder::insertVertices if (workFace.size() != allF.size()) { - workFace.shrink(); allF.transfer(workFace); } } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C index 8b510a706467c081c0f56f4f90feab541a151181..4a9ebbaf7d3e9d6faed74c7362e7532890bbe5c1 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C @@ -1079,8 +1079,7 @@ Foam::label Foam::hexRef8::storeMidPointInfo } face newFace; - newFace.transfer(newFaceVerts.shrink()); - newFaceVerts.clear(); + newFace.transfer(newFaceVerts); label anchorCell0 = getAnchorCell ( @@ -3687,8 +3686,7 @@ Foam::labelListList Foam::hexRef8::setRefinement ); // Convert dynamiclist to face. - newFace.transfer(faceVerts.shrink()); - faceVerts.clear(); + newFace.transfer(faceVerts); //Pout<< "Split face:" << faceI << " verts:" << f // << " into quad:" << newFace << endl; @@ -3811,8 +3809,7 @@ Foam::labelListList Foam::hexRef8::setRefinement } face newFace; - newFace.transfer(newFaceVerts.shrink()); - + newFace.transfer(newFaceVerts); // The point with the lowest level should be an anchor // point of the neighbouring cells. @@ -3993,10 +3990,8 @@ Foam::labelListList Foam::hexRef8::setRefinement } } - pointLevel_.transfer(newPointLevel.shrink()); - newPointLevel.clear(); - cellLevel_.transfer(newCellLevel.shrink()); - newCellLevel.clear(); + pointLevel_.transfer(newPointLevel); + cellLevel_.transfer(newCellLevel); // Mark files as changed setInstance(mesh_.facesInstance()); diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index d743891f94fc99a1fb16d487b09401640c21c71d..e22ca0cd69fdcb5d4effe0b4b39cca3a08a4dbc8 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -734,25 +734,21 @@ void Foam::polyTopoChange::reorderCompactFaces ) { reorder(oldToNew, faces_); - faces_.setSize(newSize); - faces_.shrink(); + faces_.setCapacity(newSize); reorder(oldToNew, region_); - region_.setSize(newSize); - region_.shrink(); + region_.setCapacity(newSize); reorder(oldToNew, faceOwner_); - faceOwner_.setSize(newSize); - faceOwner_.shrink(); + faceOwner_.setCapacity(newSize); reorder(oldToNew, faceNeighbour_); - faceNeighbour_.setSize(newSize); - faceNeighbour_.shrink(); + faceNeighbour_.setCapacity(newSize); // Update faceMaps. reorder(oldToNew, faceMap_); - faceMap_.setSize(newSize); - faceMap_.shrink(); + faceMap_.setCapacity(newSize); + renumberReverseMap(oldToNew, reverseFaceMap_); renumberKey(oldToNew, faceFromPoint_); @@ -932,13 +928,11 @@ void Foam::polyTopoChange::compact } reorder(localPointMap, points_); - points_.setSize(newPointI); - points_.shrink(); + points_.setCapacity(newPointI); // Update pointMaps reorder(localPointMap, pointMap_); - pointMap_.setSize(newPointI); - pointMap_.shrink(); + pointMap_.setCapacity(newPointI); renumberReverseMap(localPointMap, reversePointMap_); renumberKey(localPointMap, pointZone_); @@ -1038,13 +1032,11 @@ void Foam::polyTopoChange::compact if (orderCells || (newCellI != cellMap_.size())) { reorder(localCellMap, cellMap_); - cellMap_.setSize(newCellI); - cellMap_.shrink(); + cellMap_.setCapacity(newCellI); renumberReverseMap(localCellMap, reverseCellMap_); reorder(localCellMap, cellZone_); - cellZone_.setSize(newCellI); - cellZone_.shrink(); + cellZone_.setCapacity(newCellI); renumberKey(localCellMap, cellFromPoint_); renumberKey(localCellMap, cellFromEdge_); @@ -1972,21 +1964,15 @@ void Foam::polyTopoChange::compactAndReorder // Clear inflation info { - faceFromPoint_.clear(); - faceFromPoint_.resize(0); - faceFromEdge_.clear(); - faceFromEdge_.resize(0); + faceFromPoint_.clearStorage(); + faceFromEdge_.clearStorage(); - cellFromPoint_.clear(); - cellFromPoint_.resize(0); - cellFromEdge_.clear(); - cellFromEdge_.resize(0); - cellFromFace_.clear(); - cellFromFace_.resize(0); + cellFromPoint_.clearStorage(); + cellFromEdge_.clearStorage(); + cellFromFace_.clearStorage(); } - const polyBoundaryMesh& boundary = mesh.boundaryMesh(); // Grab patch mesh point maps @@ -2100,10 +2086,8 @@ void Foam::polyTopoChange::clear() points_.clearStorage(); pointMap_.clearStorage(); reversePointMap_.clearStorage(); - pointZone_.clear(); - pointZone_.resize(0); - retiredPoints_.clear(); - retiredPoints_.resize(0); + pointZone_.clearStorage(); + retiredPoints_.clearStorage(); faces_.clearStorage(); region_.clearStorage(); @@ -2111,27 +2095,19 @@ void Foam::polyTopoChange::clear() faceNeighbour_.clearStorage(); faceMap_.clearStorage(); reverseFaceMap_.clearStorage(); - faceFromPoint_.clear(); - faceFromPoint_.resize(0); - faceFromEdge_.clear(); - faceFromEdge_.resize(0); - flipFaceFlux_.clear(); - flipFaceFlux_.resize(0); - faceZone_.clear(); - faceZone_.resize(0); - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); + faceFromPoint_.clearStorage(); + faceFromEdge_.clearStorage(); + flipFaceFlux_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); nActiveFaces_ = 0; cellMap_.clearStorage(); reverseCellMap_.clearStorage(); cellZone_.clearStorage(); - cellFromPoint_.clear(); - cellFromPoint_.resize(0); - cellFromEdge_.clear(); - cellFromEdge_.resize(0); - cellFromFace_.clear(); - cellFromFace_.resize(0); + cellFromPoint_.clearStorage(); + cellFromEdge_.clearStorage(); + cellFromFace_.clearStorage(); } @@ -2157,9 +2133,9 @@ void Foam::polyTopoChange::addMesh const pointField& points = mesh.points(); const pointZoneMesh& pointZones = mesh.pointZones(); - // Resize - points_.setSize(points_.size() + points.size()); - pointMap_.setSize(pointMap_.size() + points.size()); + // Extend + points_.setCapacity(points_.size() + points.size()); + pointMap_.setCapacity(pointMap_.size() + points.size()); pointZone_.resize(pointZone_.size() + points.size()/100); // Precalc offset zones @@ -2198,11 +2174,11 @@ void Foam::polyTopoChange::addMesh // always equals nCells label nAllCells = mesh.nCells(); - cellMap_.setSize(cellMap_.size() + nAllCells); + cellMap_.setCapacity(cellMap_.size() + nAllCells); cellFromPoint_.resize(cellFromPoint_.size() + nAllCells/100); cellFromEdge_.resize(cellFromEdge_.size() + nAllCells/100); cellFromFace_.resize(cellFromFace_.size() + nAllCells/100); - cellZone_.setSize(cellZone_.size() + nAllCells); + cellZone_.setCapacity(cellZone_.size() + nAllCells); // Precalc offset zones @@ -2258,11 +2234,11 @@ void Foam::polyTopoChange::addMesh // Resize label nAllFaces = mesh.faces().size(); - faces_.setSize(faces_.size() + nAllFaces); - region_.setSize(region_.size() + nAllFaces); - faceOwner_.setSize(faceOwner_.size() + nAllFaces); - faceNeighbour_.setSize(faceNeighbour_.size() + nAllFaces); - faceMap_.setSize(faceMap_.size() + nAllFaces); + faces_.setCapacity(faces_.size() + nAllFaces); + region_.setCapacity(region_.size() + nAllFaces); + faceOwner_.setCapacity(faceOwner_.size() + nAllFaces); + faceNeighbour_.setCapacity(faceNeighbour_.size() + nAllFaces); + faceMap_.setCapacity(faceMap_.size() + nAllFaces); faceFromPoint_.resize(faceFromPoint_.size() + nAllFaces/100); faceFromEdge_.resize(faceFromEdge_.size() + nAllFaces/100); flipFaceFlux_.resize(flipFaceFlux_.size() + nAllFaces/100); @@ -3004,11 +2980,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh // Clear out primitives { - retiredPoints_.clear(); - retiredPoints_.resize(0); - - region_.clear(); - region_.setSize(0); + retiredPoints_.clearStorage(); + region_.clearStorage(); } @@ -3063,17 +3036,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::changeMesh // Clear zone info { - pointZone_.clear(); - pointZone_.resize(0); - - faceZone_.clear(); - faceZone_.resize(0); - - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); - - cellZone_.clear(); - cellZone_.setSize(0); + pointZone_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); + cellZone_.clearStorage(); } @@ -3238,10 +3204,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh // Clear out primitives { - retiredPoints_.clear(); - retiredPoints_.resize(0); - region_.clear(); - region_.setSize(0); + retiredPoints_.clearStorage(); + region_.clearStorage(); } @@ -3358,17 +3322,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh // Clear zone info { - pointZone_.clear(); - pointZone_.resize(0); - - faceZone_.clear(); - faceZone_.resize(0); - - faceZoneFlip_.clear(); - faceZoneFlip_.resize(0); - - cellZone_.clear(); - cellZone_.setSize(0); + pointZone_.clearStorage(); + faceZone_.clearStorage(); + faceZoneFlip_.clearStorage(); + cellZone_.clearStorage(); } // Patch point renumbering diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C index 32cb3c5b823a0bb07da241ca8a62d4a733fe1ca2..df0197873c759772e56b437b5adb686eab915d4f 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeFaces.C @@ -365,8 +365,7 @@ void Foam::removeFaces::mergeFaces } face mergedFace; - mergedFace.transfer(faceVerts.shrink()); - faceVerts.clear(); + mergedFace.transfer(faceVerts); if (reverseLoop) { @@ -574,7 +573,7 @@ Foam::removeFaces::removeFaces // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Removing face connects cells. This function works out a consistent set of -// cell regions. +// cell regions. // - returns faces to remove. Can be extended with additional faces // (if owner would become neighbour) // - sets cellRegion to -1 or to region number @@ -693,7 +692,7 @@ Foam::label Foam::removeFaces::compatibleRemoves // Various checks - // - master is lowest numbered in any region + // - master is lowest numbered in any region // - regions have more than 1 cell { labelList nCells(regionMaster.size(), 0); @@ -763,8 +762,7 @@ Foam::label Foam::removeFaces::compatibleRemoves } } - newFacesToRemove.transfer(allFacesToRemove.shrink()); - allFacesToRemove.clear(); + newFacesToRemove.transfer(allFacesToRemove); return nUsedRegions; } @@ -1102,7 +1100,7 @@ void Foam::removeFaces::setRefinement else if (nFacesPerEdge[edgeI] == 1) { // 1: illegal. Tested above. - } + } else if (nFacesPerEdge[edgeI] == 2) { // 2: merge faces. @@ -1219,7 +1217,7 @@ void Foam::removeFaces::setRefinement << "The other side has region:" << nbrRegion << endl << "(region -1 means face is to be deleted)" - << abort(FatalError); + << abort(FatalError); } } else if (toNbrRegion[myRegion] == -1) @@ -1240,9 +1238,9 @@ void Foam::removeFaces::setRefinement << " with coupled neighbouring regions:" << toNbrRegion[myRegion] << " and " << nbrRegion - << abort(FatalError); + << abort(FatalError); } - } + } } } @@ -1358,7 +1356,7 @@ void Foam::removeFaces::setRefinement pointsToRemove ) ); - + // // Now we know // - faceLabels : faces to remove (sync since no boundary faces) @@ -1367,7 +1365,7 @@ void Foam::removeFaces::setRefinement // - faceRegion : connected face region of faces to be merged (sync) // - affectedFace : faces with points removed and/or owner/neighbour // changed (non sync) - + // Start modifying mesh and keep track of faces changed. diff --git a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C index cce2f1cd4437aba58d989fea2413cd13168f599e..2a36d3b778d9ca5d30cd4d2d40d04548f993ed9a 100644 --- a/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C +++ b/src/dynamicMesh/slidingInterface/coupleSlidingInterface.C @@ -372,7 +372,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // sliding intergace coupling in order to allow the point // projection to be done separately from the actual cutting. // Please change consistently with slidingInterfaceProjectPoints.C - // + // if (debug) { Pout << "Processing slave edges " << endl; @@ -543,7 +543,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const forAll (curFaces, faceI) { // Pout<< "face: " << curFaces[faceI] << " " -// << masterPatch[curFaces[faceI]] +// << masterPatch[curFaces[faceI]] // << " local: " // << masterPatch.localFaces()[curFaces[faceI]] // << endl; @@ -566,7 +566,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const // The edge cutting code is repeated in // slidingInterface::modifyMotionPoints. This is done for // efficiency reasons and avoids multiple creation of cutting - // planes. Please update both simultaneously. + // planes. Please update both simultaneously. const point& a = projectedSlavePoints[curEdge.start()]; const point& b = projectedSlavePoints[curEdge.end()]; @@ -623,7 +623,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const if (slaveCut.hit()) { // Strict checking of slave cut to avoid capturing - // end points. + // end points. scalar cutOnSlave = ( ( @@ -747,14 +747,14 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const forAll (pointsIntoMasterEdges, i) { - pime[i].transfer(pointsIntoMasterEdges[i].shrink()); + pime[i].transfer(pointsIntoMasterEdges[i]); } labelListList pise(pointsIntoSlaveEdges.size()); forAll (pointsIntoSlaveEdges, i) { - pise[i].transfer(pointsIntoSlaveEdges[i].shrink()); + pise[i].transfer(pointsIntoSlaveEdges[i]); } // Prepare the enriched faces @@ -1398,7 +1398,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const } face newFace; - newFace.transfer(newFaceLabels.shrink()); + newFace.transfer(newFaceLabels); // Pout << "Modifying master stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl; @@ -1683,7 +1683,7 @@ void Foam::slidingInterface::coupleInterface(polyTopoChange& ref) const } face newFace; - newFace.transfer(newFaceLabels.shrink()); + newFace.transfer(newFaceLabels); // Pout << "Modifying slave stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl; diff --git a/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C b/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C index ce08c9a8bff50ef37a691c783d13d5bffe9c3277..ec620bd69d53f1cd8569c5404dcf9fe7f25d049d 100644 --- a/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C +++ b/src/dynamicMesh/slidingInterface/decoupleSlidingInterface.C @@ -227,7 +227,7 @@ void Foam::slidingInterface::decoupleInterface } face newFace; - newFace.transfer(newFaceLabels.shrink()); + newFace.transfer(newFaceLabels); // Pout << "Modifying master stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl; @@ -350,7 +350,7 @@ void Foam::slidingInterface::decoupleInterface } face newFace; - newFace.transfer(newFaceLabels.shrink()); + newFace.transfer(newFaceLabels); // Pout << "Modifying slave stick-out face " << curFaceID << " old face: " << oldFace << " new face: " << newFace << endl; diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C index b056193d72c28fe02103466145ba51fc9dd8dc27..8afb49c049414cc66872f55d18eab032495d2b56 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C @@ -133,7 +133,7 @@ void Foam::enrichedPatch::calcCutFaces() const // The seed edges include all the edges of the original face + all edges // of other faces that have been used in the construction of the // facet. Edges from other faces can be considered as - // internal to the current face if used only once. + // internal to the current face if used only once. // Track the edge usage to avoid duplicate faces and reset it to unused boolList usedFaceEdges(curLocalFace.size(), false); @@ -304,12 +304,12 @@ void Foam::enrichedPatch::calcCutFaces() const // Append the face face cutFaceGlobal; - cutFaceGlobal.transfer(cutFaceGlobalPoints.shrink()); + cutFaceGlobal.transfer(cutFaceGlobalPoints); cf.append(cutFaceGlobal); face cutFaceLocal; - cutFaceLocal.transfer(cutFaceLocalPoints.shrink()); + cutFaceLocal.transfer(cutFaceLocalPoints); // Pout << "\ncutFaceLocal: " << cutFaceLocal.points(lp) << endl; // Go through all edges of the cut faces. // If the edge corresponds to a starting face edge, @@ -358,7 +358,7 @@ void Foam::enrichedPatch::calcCutFaces() const edgeSeeds.append(curCutFaceEdge.reverseEdge()); } } - + // Find out what the other side is @@ -596,20 +596,19 @@ void Foam::enrichedPatch::calcCutFaces() const // Re-pack the list into compact storage cutFacesPtr_ = new faceList(); - cutFacesPtr_->transfer(cf.shrink()); + cutFacesPtr_->transfer(cf); cutFaceMasterPtr_ = new labelList(); - cutFaceMasterPtr_->transfer(cfMaster.shrink()); + cutFaceMasterPtr_->transfer(cfMaster); cutFaceSlavePtr_ = new labelList(); - cutFaceSlavePtr_->transfer(cfSlave.shrink()); + cutFaceSlavePtr_->transfer(cfSlave); } void Foam::enrichedPatch::clearCutFaces() { deleteDemandDrivenData(cutFacesPtr_); - deleteDemandDrivenData(cutFaceMasterPtr_); deleteDemandDrivenData(cutFaceSlavePtr_); } diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C index 5d9f6d6ca2e23e28a07b6936e34782f5fdc3a468..7e2ba2ef7cae585c5c9dd072edeb6c11d7dbdb3c 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchFaces.C @@ -80,7 +80,7 @@ void Foam::enrichedPatch::calcEnrichedFaces // For correct functioning of the enrichedPatch class, the slave // faces need to be inserted first. See comments in - // enrichedPatch.H + // enrichedPatch.H // Get reference to the point merge map const Map<label>& pmm = pointMergeMap(); @@ -233,10 +233,10 @@ void Foam::enrichedPatch::calcEnrichedFaces } } } -// Info << "New slave face " << faceI << ": " << newFace << endl; + // Info<< "New slave face " << faceI << ": " << newFace << endl; // Add the new face to the list - enrichedFaces[nEnrichedFaces].transfer(newFace.shrink()); + enrichedFaces[nEnrichedFaces].transfer(newFace); nEnrichedFaces++; } @@ -384,10 +384,10 @@ void Foam::enrichedPatch::calcEnrichedFaces } } } -// Info << "New master face: " << newFace << endl; + // Info<< "New master face: " << newFace << endl; // Add the new face to the list - enrichedFaces[nEnrichedFaces].transfer(newFace.shrink()); + enrichedFaces[nEnrichedFaces].transfer(newFace); nEnrichedFaces++; } diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C index 43dcc0e1807b45e69b1e653071e3f4be354f7ab4..01b623cff9414c73c2e9aefab8febd48c175a045 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchMasterPoints.C @@ -138,11 +138,11 @@ void Foam::enrichedPatch::calcMasterPointFaces() const forAll (mpfToc, mpfTocI) { labelList l; - l.transfer(mpf.find(mpfToc[mpfTocI])().shrink()); + l.transfer(mpf.find(mpfToc[mpfTocI])()); masterPointFaceAddr.insert(mpfToc[mpfTocI], l); } -// Pout << "masterPointFaceAddr: " << masterPointFaceAddr << endl; + // Pout<< "masterPointFaceAddr: " << masterPointFaceAddr << endl; } diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C index 42f580cb9bb3495652cb1e05b9f153a729f7023b..a20336b876802fc7c577ee02f98ad42aec77246d 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchPointPoints.C @@ -110,7 +110,7 @@ void Foam::enrichedPatch::calcPointPoints() const forAll (pp, pointI) { - ppAddr[pointI].transfer(pp[pointI].shrink()); + ppAddr[pointI].transfer(pp[pointI]); } } diff --git a/src/finiteVolume/fields/fvPatchFields/basic/generic/genericFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/generic/genericFvPatchField.C index aad79a3bcfdbb0ae5fa27e1dca92bb54cb466dda..d5f3ef05f294d64459539bf79cb151f22bef5dbc 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/generic/genericFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/generic/genericFvPatchField.C @@ -352,6 +352,96 @@ Foam::genericFvPatchField<Type>::genericFvPatchField << exit(FatalIOError); } } + else if + ( + firstToken.isWord() + && firstToken.wordToken() == "uniform" + ) + { + token fieldToken(is); + + if (!fieldToken.isPunctuation()) + { + scalarFields_.insert + ( + iter().keyword(), + new scalarField + ( + this->size(), + fieldToken.scalarToken() + ) + ); + } + else + { + // Read as scalarList. + is.putBack(fieldToken); + + scalarList l(is); + + if (l.size() == vector::nComponents) + { + vector vs(l[0], l[1], l[2]); + + vectorFields_.insert + ( + iter().keyword(), + new vectorField(this->size(), vs) + ); + } + else if (l.size() == sphericalTensor::nComponents) + { + sphericalTensor vs(l[0]); + + sphericalTensorFields_.insert + ( + iter().keyword(), + new sphericalTensorField(this->size(), vs) + ); + } + else if (l.size() == symmTensor::nComponents) + { + symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]); + + symmTensorFields_.insert + ( + iter().keyword(), + new symmTensorField(this->size(), vs) + ); + } + else if (l.size() == tensor::nComponents) + { + tensor vs + ( + l[0], l[1], l[2], + l[3], l[4], l[5], + l[6], l[7], l[8] + ); + + tensorFields_.insert + ( + iter().keyword(), + new tensorField(this->size(), vs) + ); + } + else + { + FatalIOErrorIn + ( + "genericFvPatchField<Type>::genericFvPatchField" + "(const fvPatch&, const Field<Type>&, " + "const dictionary&)", + dict + ) << "\n unrecognised native type " << l + << "\n on patch " << this->patch().name() + << " of field " + << this->dimensionedInternalField().name() + << " in file " + << this->dimensionedInternalField().objectPath() + << exit(FatalIOError); + } + } + } } } } @@ -557,7 +647,7 @@ void Foam::genericFvPatchField<Type>::rmap HashPtrTable<scalarField>::const_iterator dptfIter = dptf.scalarFields_.find(iter.key()); - if (dptfIter != scalarFields_.end()) + if (dptfIter != dptf.scalarFields_.end()) { iter()->rmap(*dptfIter(), addr); } @@ -573,7 +663,7 @@ void Foam::genericFvPatchField<Type>::rmap HashPtrTable<vectorField>::const_iterator dptfIter = dptf.vectorFields_.find(iter.key()); - if (dptfIter != vectorFields_.end()) + if (dptfIter != dptf.vectorFields_.end()) { iter()->rmap(*dptfIter(), addr); } @@ -590,7 +680,7 @@ void Foam::genericFvPatchField<Type>::rmap HashPtrTable<sphericalTensorField>::const_iterator dptfIter = dptf.sphericalTensorFields_.find(iter.key()); - if (dptfIter != sphericalTensorFields_.end()) + if (dptfIter != dptf.sphericalTensorFields_.end()) { iter()->rmap(*dptfIter(), addr); } @@ -607,7 +697,7 @@ void Foam::genericFvPatchField<Type>::rmap HashPtrTable<symmTensorField>::const_iterator dptfIter = dptf.symmTensorFields_.find(iter.key()); - if (dptfIter != symmTensorFields_.end()) + if (dptfIter != dptf.symmTensorFields_.end()) { iter()->rmap(*dptfIter(), addr); } @@ -623,7 +713,7 @@ void Foam::genericFvPatchField<Type>::rmap HashPtrTable<tensorField>::const_iterator dptfIter = dptf.tensorFields_.find(iter.key()); - if (dptfIter != tensorFields_.end()) + if (dptfIter != dptf.tensorFields_.end()) { iter()->rmap(*dptfIter(), addr); } diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index b8698eb17738d2e5e39adfd6ac0eaa3568356a15..20f36d23497a426acc3a4ab196fc587396a2b844 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -336,8 +336,8 @@ Foam::fvMatrix<Type>::fvMatrix { if (debug) { - Info<< "fvMatrix<Type>(GeometricField<Type, fvPatchField, volMesh>&," - " Istream&) : " + Info<< "fvMatrix<Type>" + "(GeometricField<Type, fvPatchField, volMesh>&, Istream&) : " "constructing fvMatrix<Type> for field " << psi_.name() << endl; } @@ -1257,7 +1257,7 @@ template<class Type> Foam::lduMatrix::solverPerformance Foam::solve ( fvMatrix<Type>& fvm, - Istream& solverControls + const dictionary& solverControls ) { return fvm.solve(solverControls); @@ -1267,7 +1267,7 @@ template<class Type> Foam::lduMatrix::solverPerformance Foam::solve ( const tmp<fvMatrix<Type> >& tfvm, - Istream& solverControls + const dictionary& solverControls ) { lduMatrix::solverPerformance solverPerf = diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index b7663db50f658d41783e1657f2ee401e134daa10..2df42847a20b3039158571066faada6ea23a7f8c 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -220,8 +220,8 @@ public: // Member functions //- Solve returning the solution statistics. - // Solver controls read from Istream - lduMatrix::solverPerformance solve(Istream&); + // Use the given solver controls + lduMatrix::solverPerformance solve(const dictionary&); //- Solve returning the solution statistics. // Solver controls read from fvSolution @@ -359,16 +359,16 @@ public: ); //- Construct and return the solver - // Solver controls read from Istream - autoPtr<fvSolver> solver(Istream&); + // Use the given solver controls + autoPtr<fvSolver> solver(const dictionary&); //- Construct and return the solver // Solver controls read from fvSolution autoPtr<fvSolver> solver(); //- Solve returning the solution statistics. - // Solver controls read from Istream - lduMatrix::solverPerformance solve(Istream&); + // Use the given solver controls + lduMatrix::solverPerformance solve(const dictionary&); //- Solve returning the solution statistics. // Solver controls read from fvSolution @@ -518,16 +518,20 @@ void checkMethod //- Solve returning the solution statistics given convergence tolerance -// Solver controls read Istream +// Use the given solver controls template<class Type> -lduMatrix::solverPerformance solve(fvMatrix<Type>&, Istream&); +lduMatrix::solverPerformance solve(fvMatrix<Type>&, const dictionary&); //- Solve returning the solution statistics given convergence tolerance, // deleting temporary matrix after solution. -// Solver controls read Istream +// Use the given solver controls template<class Type> -lduMatrix::solverPerformance solve(const tmp<fvMatrix<Type> >&, Istream&); +lduMatrix::solverPerformance solve +( + const tmp<fvMatrix<Type> >&, + const dictionary& +); //- Solve returning the solution statistics given convergence tolerance diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 37e3fd8391b344a14c2f53af7a9d04f9ead6e7fd..53183114724c7dfdebb4893f81d799b34c7ed76e 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -53,12 +53,12 @@ void Foam::fvMatrix<Type>::setComponentReference template<class Type> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve ( - Istream& solverControls + const dictionary& solverControls ) { if (debug) { - Info<< "fvMatrix<Type>::solve(Istream& solverControls) : " + Info<< "fvMatrix<Type>::solve(const dictionary& solverControls) : " "solving fvMatrix<Type>" << endl; } @@ -108,7 +108,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve internalCoeffs_.component(cmpt) ); - lduInterfaceFieldPtrsList interfaces = + lduInterfaceFieldPtrsList interfaces = psi_.boundaryField().interfaces(); // Use the initMatrixInterfaces and updateMatrixInterfaces to correct @@ -142,7 +142,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve bouCoeffsCmpt, intCoeffsCmpt, interfaces, - solverControls.rewind() + solverControls )->solve(psiCmpt, sourceCmpt, cmpt); solverPerf.print(); @@ -170,20 +170,20 @@ template<class Type> Foam::autoPtr<typename Foam::fvMatrix<Type>::fvSolver> Foam::fvMatrix<Type>::solver() { - return solver(psi_.mesh().solver(psi_.name())); + return solver(psi_.mesh().solverDict(psi_.name())); } template<class Type> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::fvSolver::solve() { - return solve(psi_.mesh().solver(psi_.name())); + return solve(psi_.mesh().solverDict(psi_.name())); } template<class Type> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve() { - return solve(psi_.mesh().solver(psi_.name())); + return solve(psi_.mesh().solverDict(psi_.name())); } diff --git a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C index ad952b3e78f9b5bf52bc926b0b5982fc87a46c20..be97ac403a6db65de1d258881022e0a54b8a3735 100644 --- a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C +++ b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C @@ -45,7 +45,7 @@ void Foam::fvMatrix<Foam::scalar>::setComponentReference internalCoeffs_[patchi][facei] += diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]]; - boundaryCoeffs_[patchi][facei] += + boundaryCoeffs_[patchi][facei] += diag()[psi_.mesh().boundary()[patchi].faceCells()[facei]] *value; } @@ -57,12 +57,12 @@ template<> Foam::autoPtr<Foam::fvMatrix<Foam::scalar>::fvSolver> Foam::fvMatrix<Foam::scalar>::solver ( - Istream& solverControls + const dictionary& solverControls ) { if (debug) { - Info<< "fvMatrix<scalar>::solver(Istream& solverControls) : " + Info<< "fvMatrix<scalar>::solver(const dictionary& solverControls) : " "solver for fvMatrix<scalar>" << endl; } @@ -96,7 +96,7 @@ Foam::fvMatrix<Foam::scalar>::solver template<> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve ( - Istream& solverControls + const dictionary& solverControls ) { scalarField saveDiag = fvMat_.diag(); @@ -105,8 +105,10 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve scalarField totalSource = fvMat_.source(); fvMat_.addBoundarySource(totalSource, false); + // assign new solver controls solver_->read(solverControls); - lduMatrix::solverPerformance solverPerf = + + lduMatrix::solverPerformance solverPerf = solver_->solve(fvMat_.psi().internalField(), totalSource); solverPerf.print(); @@ -122,12 +124,12 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve template<> Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve ( - Istream& solverControls + const dictionary& solverControls ) { if (debug) { - Info<< "fvMatrix<scalar>::solve(Istream& solverControls) : " + Info<< "fvMatrix<scalar>::solve(const dictionary& solverControls) : " "solving fvMatrix<scalar>" << endl; } diff --git a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H index ff22889d49c2e17bbd7cb746c01f7e8632652cbb..19ec0abb2e84a5d32107098758ef4b3f61db3ad5 100644 --- a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H +++ b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H @@ -23,9 +23,10 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA InClass - Foam::fvScalarMatrix + Foam::fvMatrix Description + A scalar instance of fvMatrix SourceFiles fvScalarMatrix.C @@ -56,13 +57,22 @@ void fvMatrix<scalar>::setComponentReference ); template<> -autoPtr<fvMatrix<scalar>::fvSolver> fvMatrix<scalar>::solver(Istream&); +autoPtr<fvMatrix<scalar>::fvSolver> fvMatrix<scalar>::solver +( + const dictionary& +); template<> -lduMatrix::solverPerformance fvMatrix<scalar>::fvSolver::solve(Istream&); +lduMatrix::solverPerformance fvMatrix<scalar>::fvSolver::solve +( + const dictionary& +); template<> -lduMatrix::solverPerformance fvMatrix<scalar>::solve(Istream&); +lduMatrix::solverPerformance fvMatrix<scalar>::solve +( + const dictionary& +); template<> tmp<scalarField> fvMatrix<scalar>::residual() const; diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index 5ccc7375c61f34d50cecbe6bf0e5d50a2f4a13e1..ca0ef6c0380a4b0dd804f6ad5771e888f0cd6153 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -142,8 +142,8 @@ void Foam::MULES::implicitSolve { const fvMesh& mesh = psi.mesh(); - dictionary MULESSolver(mesh.solver(psi.name())); - const dictionary& MULEScontrols = MULESSolver.subDict("MULESImplicit"); + const dictionary& MULEScontrols = + mesh.solverDict(psi.name()).subDict("MULESImplicit"); label maxIter ( diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C index ba8498bba0524cf072e90856f37b28d2f1b5c356..88a15a4f233b7b72d4ee92eb31e81eea3bd7ad03 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C @@ -55,7 +55,7 @@ namespace Foam Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver ( const polyMesh& mesh, - Istream& msData + Istream& ) : fvMotionSolver(mesh), diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H index 2232dd2e63286894aa5f66c93c6fc485369365c8..3af3d843947cfc038d017568307fb111742f1867 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H @@ -93,8 +93,8 @@ public: //- Construct from polyMesh and data stream displacementSBRStressFvMotionSolver ( - const polyMesh& mesh, - Istream& msData + const polyMesh&, + Istream& msDataUnused ); diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H index 57ba2978bbb1c8323445c0d68b3a15c0ce2abdae..d9d2bfd7edb746c4aa91de6f6203a9c20e5f098d 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.H @@ -107,9 +107,10 @@ public: // Constructors + //- Construct from polyMesh and data stream displacementComponentLaplacianFvMotionSolver ( - const polyMesh& mesh, + const polyMesh&, Istream& msData ); diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C index dae6656380bb2acdf3039f3666c1b7af82baa87c..e7907295e42f7d57a6f2dd9d83a017e48cad28b4 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C @@ -58,7 +58,7 @@ Foam::displacementInterpolationFvMotionSolver:: displacementInterpolationFvMotionSolver ( const polyMesh& mesh, - Istream& msData + Istream& ) : fvMotionSolver(mesh), diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H index 04f3eda5cc15f8e8535afb040da2afc4c864310f..b490634b3ece28efe89b345998e13c434fd03ced 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H @@ -115,10 +115,11 @@ public: // Constructors + //- Construct from polyMesh and data stream displacementInterpolationFvMotionSolver ( - const polyMesh& mesh, - Istream& msData + const polyMesh&, + Istream& msDataUnused ); diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index 02e5f3b5eb157256d3b75ddda605b581dafc37f9..78c1b41355fe52c2238e8da791b2f07ede03d701 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -53,7 +53,7 @@ namespace Foam Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver ( const polyMesh& mesh, - Istream& msData + Istream& ) : fvMotionSolver(mesh), diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H index 47570239ba72b7547e11f1f3b68345813982f501..d9fc9e5758bcd650f25bc2eab655cbc5d0df0311 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H @@ -101,8 +101,8 @@ public: //- Construct from polyMesh and data stream displacementLaplacianFvMotionSolver ( - const polyMesh& mesh, - Istream& msData + const polyMesh&, + Istream& msDataUnused ); diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/velocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H index 223d7ed115280e67d375e5841e872283791dceff..9537b7576ec8387bd045d9c893430f428bb0659d 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.H @@ -93,9 +93,10 @@ public: // Constructors + //- Construct from polyMesh and data stream (provides component) velocityComponentLaplacianFvMotionSolver ( - const polyMesh& mesh, + const polyMesh&, Istream& msData ); diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C index 50a06de548608f435997ff9a21ace84d93aa6ae0..d6cbf1cc18b95a2c323418bed21cedf4de85884a 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C @@ -50,7 +50,7 @@ namespace Foam Foam::velocityLaplacianFvMotionSolver::velocityLaplacianFvMotionSolver ( const polyMesh& mesh, - Istream& msData + Istream& ) : fvMotionSolver(mesh), diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H index 2699e95d32fb2d56a62c82900d819bda5117f4af..c4d51123b1ec0b25d66dcca8e234043cd2996c34 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.H @@ -88,7 +88,11 @@ public: // Constructors //- Construct from polyMesh and data stream - velocityLaplacianFvMotionSolver(const polyMesh& mesh, Istream& msData); + velocityLaplacianFvMotionSolver + ( + const polyMesh&, + Istream& msDataUnused + ); // Destructor diff --git a/src/lagrangian/dieselSpray/Make/files b/src/lagrangian/dieselSpray/Make/files index 86dd21c0bcd473295a4737b9821555c70fd0af84..7fd1ca7f2a48980a44c05565ed59f2dd78d908cb 100644 --- a/src/lagrangian/dieselSpray/Make/files +++ b/src/lagrangian/dieselSpray/Make/files @@ -26,6 +26,7 @@ $(injector)/injector/injector.C $(injector)/injector/injectorIO.C $(injector)/injectorType/injectorType.C $(injector)/unitInjector/unitInjector.C +$(injector)/multiHoleInjector/multiHoleInjector.C $(injector)/commonRailInjector/commonRailInjector.C $(injector)/swirlInjector/swirlInjector.C $(injector)/definedInjector/definedInjector.C diff --git a/src/lagrangian/dieselSpray/injector/commonRailInjector/commonRailInjector.C b/src/lagrangian/dieselSpray/injector/commonRailInjector/commonRailInjector.C index 9249c8ac65cba2198cc7abaee228c32399b377bc..0f00cb79eb9ddb199b687d45177e81d7580a0440 100644 --- a/src/lagrangian/dieselSpray/injector/commonRailInjector/commonRailInjector.C +++ b/src/lagrangian/dieselSpray/injector/commonRailInjector/commonRailInjector.C @@ -187,13 +187,14 @@ Foam::label Foam::commonRailInjector::nParcelsToInject return nParcels; } -const Foam::vector Foam::commonRailInjector::position() const +const Foam::vector Foam::commonRailInjector::position(const label n) const { return position_; } Foam::vector Foam::commonRailInjector::position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -236,12 +237,21 @@ Foam::vector Foam::commonRailInjector::position return position_; } +Foam::label Foam::commonRailInjector::nHoles() const +{ + return 1; +} + Foam::scalar Foam::commonRailInjector::d() const { return d_; } -const Foam::vector& Foam::commonRailInjector::direction() const +const Foam::vector& Foam::commonRailInjector::direction +( + const label i, + const scalar time +) const { return direction_; } @@ -358,7 +368,7 @@ void Foam::commonRailInjector::correctProfiles forAll(velocityProfile_, i) { - scalar Pinj = getTableValue(injectionPressureProfile_, massFlowRateProfile_[i][0]); + scalar Pinj = getTableValue(injectionPressureProfile_, velocityProfile_[i][0]); scalar Vinj = sqrt(2.0*(Pinj - referencePressure)/rho); scalar mfr = massFlowRateProfile_[i][1]/(rho*A); scalar Cd = mfr/Vinj; @@ -367,4 +377,14 @@ void Foam::commonRailInjector::correctProfiles } } +Foam::vector Foam::commonRailInjector::tan1(const label n) const +{ + return tangentialInjectionVector1_; +} + +Foam::vector Foam::commonRailInjector::tan2(const label n) const +{ + return tangentialInjectionVector2_; +} + // ************************************************************************* // diff --git a/src/lagrangian/dieselSpray/injector/commonRailInjector/commonRailInjector.H b/src/lagrangian/dieselSpray/injector/commonRailInjector/commonRailInjector.H index fcb222bc879b644c33992e0c2f6bfdaded3e6cf3..c829799029c84e7761308304d52113de71258ef6 100644 --- a/src/lagrangian/dieselSpray/injector/commonRailInjector/commonRailInjector.H +++ b/src/lagrangian/dieselSpray/injector/commonRailInjector/commonRailInjector.H @@ -132,11 +132,12 @@ public: ) const; //- Return the injection position - const vector position() const; + const vector position(const label n) const; //- Return the injection position vector position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -146,11 +147,18 @@ public: Random& rndGen ) const; + //- Return the number of holes + label nHoles() const; + //- Return the injector diameter scalar d() const; //- Return the injection direction - const vector& direction() const; + const vector& direction + ( + const label i, + const scalar time + ) const; //- Return the mass of the injected particle scalar mass @@ -206,6 +214,9 @@ public: List<pair> CdProfile() const; scalar Cd(const scalar time) const; + vector tan1(const label n) const; + vector tan2(const label n) const; + void correctProfiles ( const liquidMixture& fuel, diff --git a/src/lagrangian/dieselSpray/injector/definedInjector/definedInjector.C b/src/lagrangian/dieselSpray/injector/definedInjector/definedInjector.C index 89960f39782b03a15fd18188d71a1139a3544010..8d422973cfa8c640d692bcb1c22ef6ab63041490 100644 --- a/src/lagrangian/dieselSpray/injector/definedInjector/definedInjector.C +++ b/src/lagrangian/dieselSpray/injector/definedInjector/definedInjector.C @@ -178,13 +178,14 @@ Foam::label Foam::definedInjector::nParcelsToInject return nParcels; } -const Foam::vector Foam::definedInjector::position() const +const Foam::vector Foam::definedInjector::position(const label n) const { return position_; } Foam::vector Foam::definedInjector::position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -227,12 +228,21 @@ Foam::vector Foam::definedInjector::position return position_; } +Foam::label Foam::definedInjector::nHoles() const +{ + return 1; +} + Foam::scalar Foam::definedInjector::d() const { return d_; } -const Foam::vector& Foam::definedInjector::direction() const +const Foam::vector& Foam::definedInjector::direction +( + const label i, + const scalar time +) const { return direction_; } @@ -344,4 +354,14 @@ void Foam::definedInjector::correctProfiles } } +Foam::vector Foam::definedInjector::tan1(const label n) const +{ + return tangentialInjectionVector1_; +} + +Foam::vector Foam::definedInjector::tan2(const label n) const +{ + return tangentialInjectionVector2_; +} + // ************************************************************************* // diff --git a/src/lagrangian/dieselSpray/injector/definedInjector/definedInjector.H b/src/lagrangian/dieselSpray/injector/definedInjector/definedInjector.H index 6389b94339b791e2e188d120b590879aeda8867f..66ca317b3ae549075a5a4c79af350abba1b39f5f 100644 --- a/src/lagrangian/dieselSpray/injector/definedInjector/definedInjector.H +++ b/src/lagrangian/dieselSpray/injector/definedInjector/definedInjector.H @@ -132,11 +132,12 @@ public: ) const; //- Return the injection position - const vector position() const; + const vector position(const label n) const; //- Return the injection position vector position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -146,11 +147,18 @@ public: Random& rndGen ) const; + //- Return the number of holes + label nHoles() const; + //- Return the injector diameter scalar d() const; //- Return the injection direction - const vector& direction() const; + const vector& direction + ( + const label i, + const scalar time + ) const; //- Return the mass of the injected particle scalar mass @@ -210,6 +218,9 @@ public: scalar Cd(const scalar time) const; + vector tan1(const label n) const; + vector tan2(const label n) const; + void correctProfiles ( const liquidMixture& fuel, diff --git a/src/lagrangian/dieselSpray/injector/injectorType/injectorType.H b/src/lagrangian/dieselSpray/injector/injectorType/injectorType.H index 878cc8897d3b16ac233f1b466cfbbc9c411b351a..ab789f5213f69af10a244e1a825ac2281352af06 100644 --- a/src/lagrangian/dieselSpray/injector/injectorType/injectorType.H +++ b/src/lagrangian/dieselSpray/injector/injectorType/injectorType.H @@ -114,11 +114,12 @@ public: ) const = 0; //- Return the injection position - virtual const vector position() const = 0; + virtual const vector position(const label n) const = 0; //- Return the injection position virtual vector position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -127,12 +128,19 @@ public: const vector& axisOfWedgeNormal, Random& rndGen ) const = 0; + + //- Return the number of holes + virtual label nHoles() const = 0; //- Return the injector diameter virtual scalar d() const = 0; - //- Return the injection direction - virtual const vector& direction() const = 0; + //- Return the injection direction for hole i + virtual const vector& direction + ( + const label i, + const scalar time + ) const = 0; //- Return the mass of the injected liquid between times virtual scalar mass @@ -189,6 +197,12 @@ public: virtual bool pressureIndependentVelocity() const = 0; + //- Return a vector perpendicular to the injection direction and tan2 for hole n + virtual vector tan1(const label n) const = 0; + + //- Return a vector perpendicular to the injection direction and tan1 for hole n + virtual vector tan2(const label n) const = 0; + scalar getTableValue ( const List<pair>& table, diff --git a/src/lagrangian/dieselSpray/injector/multiHoleInjector/multiHoleInjector.C b/src/lagrangian/dieselSpray/injector/multiHoleInjector/multiHoleInjector.C new file mode 100644 index 0000000000000000000000000000000000000000..54b4c4f4860bf68a6b6b4a0ea3a83fb05537f360 --- /dev/null +++ b/src/lagrangian/dieselSpray/injector/multiHoleInjector/multiHoleInjector.C @@ -0,0 +1,420 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "multiHoleInjector.H" +#include "addToRunTimeSelectionTable.H" +#include "Random.H" +#include "mathematicalConstants.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +namespace Foam +{ + +defineTypeNameAndDebug(multiHoleInjector, 0); + +addToRunTimeSelectionTable +( + injectorType, + multiHoleInjector, + dictionary +); +} +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::multiHoleInjector::multiHoleInjector +( + const Foam::Time& t, + const Foam::dictionary& dict +) +: + injectorType(t, dict), + propsDict_(dict.subDict(typeName + "Props")), + centerPosition_(propsDict_.lookup("position")), + xyAngle_(readScalar(propsDict_.lookup("xyAngle"))), + zAngle_(readScalar(propsDict_.lookup("zAngle"))), + nHoles_(readLabel(propsDict_.lookup("nHoles"))), + umbrellaAngle_(readScalar(propsDict_.lookup("umbrellaAngle"))), + nozzleTipDiameter_(readScalar(propsDict_.lookup("nozzleTipDiameter"))), + angleSpacing_(propsDict_.lookup("angleSpacing")), + d_(readScalar(propsDict_.lookup("diameter"))), + Cd_(readScalar(propsDict_.lookup("Cd"))), + mass_(readScalar(propsDict_.lookup("mass"))), + nParcels_(readLabel(propsDict_.lookup("nParcels"))), + X_(propsDict_.lookup("X")), + massFlowRateProfile_(propsDict_.lookup("massFlowRateProfile")), + velocityProfile_(massFlowRateProfile_), + injectionPressureProfile_(massFlowRateProfile_), + CdProfile_(massFlowRateProfile_), + TProfile_(propsDict_.lookup("temperatureProfile")), + averageParcelMass_(nHoles_*mass_/nParcels_), + direction_(nHoles_), + position_(nHoles_), + pressureIndependentVelocity_(true), + tangentialInjectionVector1_(nHoles_), + tangentialInjectionVector2_(nHoles_) +{ + + + // check if time entries for soi and eoi match + if (mag(massFlowRateProfile_[0][0]-TProfile_[0][0]) > SMALL) + { + FatalError << "multiHoleInjector::multiHoleInjector(const time& t, const dictionary dict) " << endl + << " start-times do not match for TemperatureProfile and massFlowRateProfile." + << abort(FatalError); + } + + if (mag(massFlowRateProfile_[massFlowRateProfile_.size()-1][0]-TProfile_[TProfile_.size()-1][0]) > SMALL) + { + FatalError << "multiHoleInjector::multiHoleInjector(const time& t, const dictionary dict) " << endl + << " end-times do not match for TemperatureProfile and massFlowRateProfile." + << abort(FatalError); + } + + // convert CA to real time + forAll(massFlowRateProfile_, i) + { + massFlowRateProfile_[i][0] = t.userTimeToTime(massFlowRateProfile_[i][0]); + velocityProfile_[i][0] = massFlowRateProfile_[i][0]; + injectionPressureProfile_[i][0] = massFlowRateProfile_[i][0]; + } + + forAll(TProfile_, i) + { + TProfile_[i][0] = t.userTimeToTime(TProfile_[i][0]); + } + + scalar integratedMFR = integrateTable(massFlowRateProfile_); + + forAll(massFlowRateProfile_, i) + { + // correct the massFlowRateProfile to match the injected mass + massFlowRateProfile_[i][1] *= mass_/integratedMFR; + + CdProfile_[i][0] = massFlowRateProfile_[i][0]; + CdProfile_[i][1] = Cd_; + } + + setTangentialVectors(); + + // check molar fractions + scalar Xsum = 0.0; + forAll(X_, i) + { + Xsum += X_[i]; + } + + if (mag(Xsum - 1.0) > SMALL) + { + Info << "Warning!!!\n multiHoleInjector::multiHoleInjector(const time& t, Istream& is)" + << "X does not add up to 1.0, correcting molar fractions." + << endl; + forAll(X_, i) + { + X_[i] /= Xsum; + } + } + +} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::multiHoleInjector::~multiHoleInjector() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::multiHoleInjector::setTangentialVectors() +{ + scalar pi180 = mathematicalConstant::pi/180.0; + scalar alpha = xyAngle_*pi180; + scalar phi = zAngle_*pi180; + + vector xp(cos(alpha), sin(alpha), 0.0); + vector zp(cos(alpha)*sin(phi), sin(alpha)*sin(phi), cos(phi)); + if (mag(zp-xp) < 1.0e-15) + { + xp = vector(0.0, 0.0, -1.0); + xp -= (xp & zp)*zp; + xp /= mag(xp); + } + vector yp = zp^xp; + +// Info << "xp = " << xp << endl; +// Info << "yp = " << yp << endl; +// Info << "zp = " << zp << endl; + + scalar angle = 0.0; + scalar u = umbrellaAngle_*pi180/2.0; + for(label i=0; i<nHoles_; i++) + { + angle += angleSpacing_[i]; + scalar v = angle*pi180; + direction_[i] = cos(v)*sin(u)*xp + sin(v)*sin(u)*yp + cos(u)*zp; + vector dp = direction_[i] - (direction_[i] & zp)*direction_[i]; + if (mag(dp) > SMALL) + { + dp /= mag(dp); + } + position_[i] = centerPosition_ + 0.5*nozzleTipDiameter_*dp; +// Info << "i = " << i << ", dir = " << direction_[i] << ", pos = " << position_[i] << endl; + } + + Random rndGen(label(0)); + + for(label i=0; i<nHoles_; i++) + { + vector tangent(vector::zero); + scalar magV = 0; + while (magV < SMALL) + { + vector testThis = rndGen.vector01(); + + tangent = testThis - (testThis & direction_[i])*direction_[i]; + magV = mag(tangent); + } + + tangentialInjectionVector1_[i] = tangent/magV; + tangentialInjectionVector2_[i] = direction_[i] ^ tangentialInjectionVector1_[i]; + + } +} + + +Foam::label Foam::multiHoleInjector::nParcelsToInject +( + const scalar time0, + const scalar time1 +) const +{ + + scalar mInj = mass_*(fractionOfInjection(time1)-fractionOfInjection(time0)); + label nParcels = label(mInj/averageParcelMass_ + 0.49); + + return nParcels; +} + +const Foam::vector Foam::multiHoleInjector::position(const label n) const +{ + return position_[n]; +} + +Foam::vector Foam::multiHoleInjector::position +( + const label n, + const scalar time, + const bool twoD, + const scalar angleOfWedge, + const vector& axisOfSymmetry, + const vector& axisOfWedge, + const vector& axisOfWedgeNormal, + Random& rndGen +) const +{ + if (twoD) + { + scalar is = position_[n] & axisOfSymmetry; + scalar magInj = mag(position_[n] - is*axisOfSymmetry); + + vector halfWedge = + axisOfWedge*cos(0.5*angleOfWedge) + + axisOfWedgeNormal*sin(0.5*angleOfWedge); + halfWedge /= mag(halfWedge); + + return (is*axisOfSymmetry + magInj*halfWedge); + } + else + { + // otherwise, disc injection + scalar iRadius = d_*rndGen.scalar01(); + scalar iAngle = 2.0*mathematicalConstant::pi*rndGen.scalar01(); + + return + ( + position_[n] + + iRadius + * ( + tangentialInjectionVector1_[n]*cos(iAngle) + + tangentialInjectionVector2_[n]*sin(iAngle) + ) + ); + + } + return position_[0]; +} + +Foam::label Foam::multiHoleInjector::nHoles() const +{ + return nHoles_; +} + +Foam::scalar Foam::multiHoleInjector::d() const +{ + return d_; +} + +const Foam::vector& Foam::multiHoleInjector::direction +( + const label i, + const scalar time +) const +{ + return direction_[i]; +} + +Foam::scalar Foam::multiHoleInjector::mass +( + const scalar time0, + const scalar time1, + const bool twoD, + const scalar angleOfWedge +) const +{ + scalar mInj = mass_*(fractionOfInjection(time1)-fractionOfInjection(time0)); + + // correct mass if calculation is 2D + if (twoD) + { + mInj *= 0.5*angleOfWedge/mathematicalConstant::pi; + } + + return mInj; +} + +Foam::scalar Foam::multiHoleInjector::mass() const +{ + return mass_; +} + +const Foam::scalarField& Foam::multiHoleInjector::X() const +{ + return X_; +} + +Foam::List<Foam::multiHoleInjector::pair> Foam::multiHoleInjector::T() const +{ + return TProfile_; +} + +Foam::scalar Foam::multiHoleInjector::T(const scalar time) const +{ + return getTableValue(TProfile_, time); +} + +Foam::scalar Foam::multiHoleInjector::tsoi() const +{ + return massFlowRateProfile_[0][0]; +} + +Foam::scalar Foam::multiHoleInjector::teoi() const +{ + return massFlowRateProfile_[massFlowRateProfile_.size()-1][0]; +} + +Foam::scalar Foam::multiHoleInjector::massFlowRate +( + const scalar time +) const +{ + return getTableValue(massFlowRateProfile_, time); +} + +Foam::scalar Foam::multiHoleInjector::injectionPressure +( + const scalar time +) const +{ + return getTableValue(injectionPressureProfile_, time); +} + +Foam::scalar Foam::multiHoleInjector::velocity +( + const scalar time +) const +{ + return getTableValue(velocityProfile_, time); +} + +Foam::List<Foam::multiHoleInjector::pair> Foam::multiHoleInjector::CdProfile() const +{ + return CdProfile_; +} + +Foam::scalar Foam::multiHoleInjector::Cd +( + const scalar time +) const +{ + return Cd_; +} + +Foam::scalar Foam::multiHoleInjector::fractionOfInjection(const scalar time) const +{ + return integrateTable(massFlowRateProfile_, time)/mass_; +} + +Foam::scalar Foam::multiHoleInjector::injectedMass +( + const scalar t +) const +{ + return mass_*fractionOfInjection(t); +} + + +void Foam::multiHoleInjector::correctProfiles +( + const liquidMixture& fuel, + const scalar referencePressure +) +{ + + scalar A = nHoles_*0.25*mathematicalConstant::pi*pow(d_, 2.0); + + forAll(velocityProfile_, i) + { + scalar time = velocityProfile_[i][0]; + scalar rho = fuel.rho(referencePressure, T(time), X_); + scalar v = massFlowRateProfile_[i][1]/(Cd_*rho*A); + velocityProfile_[i][1] = v; + injectionPressureProfile_[i][1] = referencePressure + 0.5*rho*v*v; + } +} + +Foam::vector Foam::multiHoleInjector::tan1(const label n) const +{ + return tangentialInjectionVector1_[n]; +} + +Foam::vector Foam::multiHoleInjector::tan2(const label n) const +{ + return tangentialInjectionVector2_[n]; +} + +// ************************************************************************* // diff --git a/src/lagrangian/dieselSpray/injector/multiHoleInjector/multiHoleInjector.H b/src/lagrangian/dieselSpray/injector/multiHoleInjector/multiHoleInjector.H new file mode 100644 index 0000000000000000000000000000000000000000..30233d72a409d9c37aa31488f6e192419fb0978b --- /dev/null +++ b/src/lagrangian/dieselSpray/injector/multiHoleInjector/multiHoleInjector.H @@ -0,0 +1,248 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::multiHoleInjector + +Description + The unit injector + +SourceFiles + multiHoleInjectorI.H + multiHoleInjector.C + multiHoleInjectorIO.C + +\*---------------------------------------------------------------------------*/ + +#ifndef multiHoleInjector_H +#define multiHoleInjector_H + +#include "injectorType.H" +#include "vector.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class multiHoleInjector Declaration +\*---------------------------------------------------------------------------*/ + +class multiHoleInjector +: + public injectorType +{ + +private: + + typedef VectorSpace<Vector<scalar>, scalar, 2> pair; + + // Private data + + dictionary propsDict_; + + vector centerPosition_; + scalar xyAngle_; + scalar zAngle_; + label nHoles_; + scalar umbrellaAngle_; + scalar nozzleTipDiameter_; + List<scalar> angleSpacing_; + scalar d_; + scalar Cd_; + scalar mass_; + label nParcels_; + scalarField X_; + List<pair> massFlowRateProfile_; + List<pair> velocityProfile_; + List<pair> injectionPressureProfile_; + List<pair> CdProfile_; + List<pair> TProfile_; + scalar averageParcelMass_; + List<vector> direction_; + List<vector> position_; + + bool pressureIndependentVelocity_; + + //- two orthogonal vectors that are also orthogonal + // to the injection direction + List<vector> tangentialInjectionVector1_, tangentialInjectionVector2_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + multiHoleInjector(const multiHoleInjector&); + + //- Disallow default bitwise assignment + void operator=(const multiHoleInjector&); + + //- Create two vectors orthonoal to each other + // and the injection vector + void setTangentialVectors(); + + //- Return the fraction of the total injected liquid + scalar fractionOfInjection(const scalar time) const; + + +public: + + //- Runtime type information + TypeName("multiHoleInjector"); + + + // Constructors + + //- Construct from components + multiHoleInjector + ( + const Time& t, + const dictionary& dict + ); + + + // Destructor + + ~multiHoleInjector(); + + + // Member Functions + + //- Return number of particles to inject + label nParcelsToInject + ( + const scalar t0, + const scalar t1 + ) const; + + //- Return the injection position + const vector position(const label n) const; + + //- Return the injection position + vector position + ( + const label n, + const scalar time, + const bool twoD, + const scalar angleOfWedge, + const vector& axisOfSymmetry, + const vector& axisOfWedge, + const vector& axisOfWedgeNormal, + Random& rndGen + ) const; + + //- Return the number of holes + label nHoles() const; + + //- Return the injector diameter + scalar d() const; + + //- Return the injection direction + const vector& direction + ( + const label i, + const scalar time + ) const; + + //- Return the mass of the injected particle + scalar mass + ( + const scalar t0, + const scalar t1, + const bool twoD, + const scalar angleOfWedge + ) const; + + //- Return the mass injected by the injector + scalar mass() const; + + //- Return the fuel mass fractions of the injected particle + const scalarField& X() const; + + //- Return the temperature profile of the injected particle + List<pair> T() const; + + //- Return the temperature of the injected particle + scalar T(const scalar time) const; + + //- Return the start-of-injection time + scalar tsoi() const; + + //- Return the end-of-injection time + scalar teoi() const; + + //- Return the injected liquid mass + scalar injectedMass(const scalar t) const; + + List<pair> massFlowRateProfile() const + { + return massFlowRateProfile_; + } + + scalar massFlowRate(const scalar time) const; + + List<pair> injectionPressureProfile() const + { + return injectionPressureProfile_; + } + + scalar injectionPressure(const scalar time) const; + + List<pair> velocityProfile() const + { + return velocityProfile_; + } + + scalar velocity(const scalar time) const; + + List<pair> CdProfile() const; + scalar Cd(const scalar time) const; + + vector tan1(const label n) const; + vector tan2(const label n) const; + + void correctProfiles + ( + const liquidMixture& fuel, + const scalar referencePressure + ); + + bool pressureIndependentVelocity() const + { + return pressureIndependentVelocity_; + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/dieselSpray/injector/swirlInjector/swirlInjector.C b/src/lagrangian/dieselSpray/injector/swirlInjector/swirlInjector.C index ef3196695d18242f594af429beeb16eed262e6ba..192319f8ced148c3004fceb550623053e638705b 100644 --- a/src/lagrangian/dieselSpray/injector/swirlInjector/swirlInjector.C +++ b/src/lagrangian/dieselSpray/injector/swirlInjector/swirlInjector.C @@ -187,13 +187,14 @@ Foam::label Foam::swirlInjector::nParcelsToInject return nParcels; } -const Foam::vector Foam::swirlInjector::position() const +const Foam::vector Foam::swirlInjector::position(const label n) const { return position_; } Foam::vector Foam::swirlInjector::position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -236,12 +237,21 @@ Foam::vector Foam::swirlInjector::position return position_; } +Foam::label Foam::swirlInjector::nHoles() const +{ + return 1; +} + Foam::scalar Foam::swirlInjector::d() const { return d_; } -const Foam::vector& Foam::swirlInjector::direction() const +const Foam::vector& Foam::swirlInjector::direction +( + const label i, + const scalar time +) const { return direction_; } @@ -370,4 +380,14 @@ void Foam::swirlInjector::correctProfiles } } +Foam::vector Foam::swirlInjector::tan1(const label n) const +{ + return tangentialInjectionVector1_; +} + +Foam::vector Foam::swirlInjector::tan2(const label n) const +{ + return tangentialInjectionVector2_; +} + // ************************************************************************* // diff --git a/src/lagrangian/dieselSpray/injector/swirlInjector/swirlInjector.H b/src/lagrangian/dieselSpray/injector/swirlInjector/swirlInjector.H index 8c4853b9b7b257dd8c37c2b21a5ad5e46aa5efcd..4cb6cf1da56fd1a1f56ce256b77a1c29b4d0606c 100644 --- a/src/lagrangian/dieselSpray/injector/swirlInjector/swirlInjector.H +++ b/src/lagrangian/dieselSpray/injector/swirlInjector/swirlInjector.H @@ -146,11 +146,12 @@ public: ) const; //- Return the injection position - const vector position() const; + const vector position(const label n) const; //- Return the injection position vector position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -160,11 +161,18 @@ public: Random& rndGen ) const; + //- Return the number of holes + label nHoles() const; + //- Return the injector diameter scalar d() const; //- Return the injection direction - const vector& direction() const; + const vector& direction + ( + const label i, + const scalar time + ) const; //- Return the mass of the injected particle scalar mass @@ -220,6 +228,9 @@ public: //- Return the injected liquid mass scalar injectedMass(const scalar t) const; + vector tan1(const label n) const; + vector tan2(const label n) const; + void correctProfiles ( const liquidMixture& fuel, diff --git a/src/lagrangian/dieselSpray/injector/unitInjector/unitInjector.C b/src/lagrangian/dieselSpray/injector/unitInjector/unitInjector.C index 0429537b2f94e4064638b406163c7d5ca4fca92f..9363379cabaed45dec6768991e50686a6b5dee4f 100644 --- a/src/lagrangian/dieselSpray/injector/unitInjector/unitInjector.C +++ b/src/lagrangian/dieselSpray/injector/unitInjector/unitInjector.C @@ -60,17 +60,32 @@ Foam::unitInjector::unitInjector d_(readScalar(propsDict_.lookup("diameter"))), Cd_(readScalar(propsDict_.lookup("Cd"))), mass_(readScalar(propsDict_.lookup("mass"))), - T_(readScalar(propsDict_.lookup("temperature"))), nParcels_(readLabel(propsDict_.lookup("nParcels"))), X_(propsDict_.lookup("X")), massFlowRateProfile_(propsDict_.lookup("massFlowRateProfile")), velocityProfile_(massFlowRateProfile_), injectionPressureProfile_(massFlowRateProfile_), CdProfile_(massFlowRateProfile_), - TProfile_(massFlowRateProfile_), + TProfile_(propsDict_.lookup("temperatureProfile")), averageParcelMass_(mass_/nParcels_), pressureIndependentVelocity_(true) { + + // check if time entries for soi and eoi match + if (mag(massFlowRateProfile_[0][0]-TProfile_[0][0]) > SMALL) + { + FatalError << "unitInjector::unitInjector(const time& t, const dictionary dict) " << endl + << " start-times do not match for TemperatureProfile and massFlowRateProfile." + << abort(FatalError); + } + + if (mag(massFlowRateProfile_[massFlowRateProfile_.size()-1][0]-TProfile_[TProfile_.size()-1][0]) > SMALL) + { + FatalError << "unitInjector::unitInjector(const time& t, const dictionary dict) " << endl + << " end-times do not match for TemperatureProfile and massFlowRateProfile." + << abort(FatalError); + } + // convert CA to real time forAll(massFlowRateProfile_, i) { @@ -79,6 +94,11 @@ Foam::unitInjector::unitInjector injectionPressureProfile_[i][0] = massFlowRateProfile_[i][0]; } + forAll(TProfile_, i) + { + TProfile_[i][0] = t.userTimeToTime(TProfile_[i][0]); + } + scalar integratedMFR = integrateTable(massFlowRateProfile_); forAll(massFlowRateProfile_, i) @@ -86,9 +106,6 @@ Foam::unitInjector::unitInjector // correct the massFlowRateProfile to match the injected mass massFlowRateProfile_[i][1] *= mass_/integratedMFR; - TProfile_[i][0] = massFlowRateProfile_[i][0]; - TProfile_[i][1] = T_; - CdProfile_[i][0] = massFlowRateProfile_[i][0]; CdProfile_[i][1] = Cd_; } @@ -159,13 +176,14 @@ Foam::label Foam::unitInjector::nParcelsToInject return nParcels; } -const Foam::vector Foam::unitInjector::position() const +const Foam::vector Foam::unitInjector::position(const label n) const { return position_; } Foam::vector Foam::unitInjector::position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -208,12 +226,21 @@ Foam::vector Foam::unitInjector::position return position_; } +Foam::label Foam::unitInjector::nHoles() const +{ + return 1; +} + Foam::scalar Foam::unitInjector::d() const { return d_; } -const Foam::vector& Foam::unitInjector::direction() const +const Foam::vector& Foam::unitInjector::direction +( + const label i, + const scalar time +) const { return direction_; } @@ -254,7 +281,7 @@ Foam::List<Foam::unitInjector::pair> Foam::unitInjector::T() const Foam::scalar Foam::unitInjector::T(const scalar time) const { - return T_; + return getTableValue(TProfile_, time); } Foam::scalar Foam::unitInjector::tsoi() const @@ -328,14 +355,24 @@ void Foam::unitInjector::correctProfiles scalar A = 0.25*mathematicalConstant::pi*pow(d_, 2.0); scalar pDummy = 1.0e+5; - scalar rho = fuel.rho(pDummy, T_, X_); - forAll(velocityProfile_, i) { + scalar time = velocityProfile_[i][0]; + scalar rho = fuel.rho(pDummy, T(time), X_); scalar v = massFlowRateProfile_[i][1]/(Cd_*rho*A); velocityProfile_[i][1] = v; injectionPressureProfile_[i][1] = referencePressure + 0.5*rho*v*v; } } +Foam::vector Foam::unitInjector::tan1(const label n) const +{ + return tangentialInjectionVector1_; +} + +Foam::vector Foam::unitInjector::tan2(const label n) const +{ + return tangentialInjectionVector2_; +} + // ************************************************************************* // diff --git a/src/lagrangian/dieselSpray/injector/unitInjector/unitInjector.H b/src/lagrangian/dieselSpray/injector/unitInjector/unitInjector.H index 057700aad783026e317c9869c9b2d001c4f393c0..c7592417437a0b4c1d16e17b49d2f638081397a7 100644 --- a/src/lagrangian/dieselSpray/injector/unitInjector/unitInjector.H +++ b/src/lagrangian/dieselSpray/injector/unitInjector/unitInjector.H @@ -68,7 +68,6 @@ private: scalar d_; scalar Cd_; scalar mass_; - scalar T_; label nParcels_; scalarField X_; List<pair> massFlowRateProfile_; @@ -132,11 +131,12 @@ public: ) const; //- Return the injection position - const vector position() const; + const vector position(const label n) const; //- Return the injection position vector position ( + const label n, const scalar time, const bool twoD, const scalar angleOfWedge, @@ -146,11 +146,18 @@ public: Random& rndGen ) const; + //- Return the number of holes + label nHoles() const; + //- Return the injector diameter scalar d() const; //- Return the injection direction - const vector& direction() const; + const vector& direction + ( + const label i, + const scalar time + ) const; //- Return the mass of the injected particle scalar mass @@ -206,6 +213,9 @@ public: List<pair> CdProfile() const; scalar Cd(const scalar time) const; + vector tan1(const label n) const; + vector tan2(const label n) const; + void correctProfiles ( const liquidMixture& fuel, diff --git a/src/lagrangian/dieselSpray/parcel/setRelaxationTimes.C b/src/lagrangian/dieselSpray/parcel/setRelaxationTimes.C index 1737b9c20db7878ea64f0a027a50aa1d1c3c9019..07c6362d16f40e2484eb2f5db7c268ed9fc2728c 100644 --- a/src/lagrangian/dieselSpray/parcel/setRelaxationTimes.C +++ b/src/lagrangian/dieselSpray/parcel/setRelaxationTimes.C @@ -86,6 +86,7 @@ void parcel::setRelaxationTimes W = 1.0/W; scalarField Xf(Nf, 0.0); + scalarField Yf(Nf, 0.0); scalarField psat(Nf, 0.0); scalarField msat(Nf, 0.0); @@ -94,6 +95,7 @@ void parcel::setRelaxationTimes label j = sDB.liquidToGasIndex()[i]; scalar Y = sDB.composition().Y()[j][celli]; scalar Wi = sDB.gasProperties()[j].W(); + Yf[i] = Y; Xf[i] = Y*W/Wi; psat[i] = fuels.properties()[i].pv(pressure, temperature); msat[i] = min(1.0, psat[i]/pressure)*Wi/W; @@ -116,6 +118,22 @@ void parcel::setRelaxationTimes scalar rhoFuelVap = pressureAtSurface*fuels.W(X())/(specie::RR*Tf); scalarField Xs(sDB.fuels().Xs(pressure, temperature, T(), Xf, X())); + scalarField Ys(Nf, 0.0); + scalar Wliq = 0.0; + + for(label i=0; i<Nf; i++) + { + label j = sDB.liquidToGasIndex()[i]; + scalar Wi = sDB.gasProperties()[j].W(); + Wliq += Xs[i]*Wi; + } + + for(label i=0; i<Nf; i++) + { + label j = sDB.liquidToGasIndex()[i]; + scalar Wi = sDB.gasProperties()[j].W(); + Ys[i] = Xs[i]*Wi/Wliq; + } scalar Reynolds = Re(Up, nuf); scalar Prandtl = Pr(cpMixture, muf, kMixture); @@ -238,7 +256,6 @@ void parcel::setRelaxationTimes dp0 = dp; } - label j = sDB.liquidToGasIndex()[i]; scalar vapourSurfaceEnthalpy = 0.0; scalar vapourFarEnthalpy = 0.0; @@ -266,8 +283,6 @@ void parcel::setRelaxationTimes vapourSurfaceEnthalpy, vapourFarEnthalpy, cpMixture, - Xs[i], - Xf[j], temperature, kLiquid ); diff --git a/src/lagrangian/dieselSpray/spray/findInjectorCell.H b/src/lagrangian/dieselSpray/spray/findInjectorCell.H index c68f7deaf88ddb116dd264f5195ecba2fbd60d29..f1a8d7fc152c89feac4149d66366a0145ec9802e 100644 --- a/src/lagrangian/dieselSpray/spray/findInjectorCell.H +++ b/src/lagrangian/dieselSpray/spray/findInjectorCell.H @@ -22,7 +22,7 @@ reduce(foundCell, orOp<bool>()); if (!foundCell) { - injectionPosition = it.position(); + injectionPosition = it->position(n); injectorCell = mesh_.findCell(injectionPosition); if (injectorCell >= 0) diff --git a/src/lagrangian/dieselSpray/spray/spray.C b/src/lagrangian/dieselSpray/spray/spray.C index 4aa5c775efe57d18b891eec44d5259747f836a5d..fb9e16bc9b7ddc9f8c1588973946828cbb0fb2c5 100644 --- a/src/lagrangian/dieselSpray/spray/spray.C +++ b/src/lagrangian/dieselSpray/spray/spray.C @@ -52,6 +52,7 @@ defineTemplateTypeNameAndDebug(IOPtrList<injector>, 0); // Construct from components Foam::spray::spray ( + const volPointInterpolation& vpi, const volVectorField& U, const volScalarField& rho, const volScalarField& p, @@ -66,6 +67,7 @@ Foam::spray::spray runTime_(U.time()), time0_(runTime_.value()), mesh_(U.mesh()), + volPointInterpolation_(vpi), rndGen_(label(0)), U_(U), @@ -261,7 +263,7 @@ Foam::spray::spray { FatalErrorIn ( - "spray::spray(const volVectorField& U, " + "spray::spray(const pointMesh& pMesh, const volVectorField& U, " "const volScalarField& rho, const volScalarField& p, " "const volScalarField& T, const combustionMixture& composition," "const PtrList<specieProperties>& gaseousFuelProperties, " diff --git a/src/lagrangian/dieselSpray/spray/spray.H b/src/lagrangian/dieselSpray/spray/spray.H index 603d0c8b68a4abaffe1bb8089bce418698d2bb30..83c93c16f0d65a2a84c075da5fa6110787a905dd 100644 --- a/src/lagrangian/dieselSpray/spray/spray.H +++ b/src/lagrangian/dieselSpray/spray/spray.H @@ -36,6 +36,7 @@ Description #include "parcel.H" #include "injector.H" #include "IOPtrList.H" +#include "volPointInterpolation.H" #include "interpolation.H" #include "liquid.H" #include "sprayThermoTypes.H" @@ -75,6 +76,7 @@ class spray const Time& runTime_; scalar time0_; const fvMesh& mesh_; + const volPointInterpolation& volPointInterpolation_; //- Random number generator Random rndGen_; @@ -187,6 +189,7 @@ public: //- Construct from components spray ( + const volPointInterpolation& vpi, const volVectorField& U, const volScalarField& rho, const volScalarField& p, diff --git a/src/lagrangian/dieselSpray/spray/sprayFunctions.C b/src/lagrangian/dieselSpray/spray/sprayFunctions.C index 2a747d52f8cb26df973edaaae9972ad32cecd9b0..5159a8179c579d21be54bc9da07cbc5352808ed8 100644 --- a/src/lagrangian/dieselSpray/spray/sprayFunctions.C +++ b/src/lagrangian/dieselSpray/spray/sprayFunctions.C @@ -246,7 +246,23 @@ scalar spray::liquidPenetration const scalar prc ) const { - vector ip = injectors_[nozzlei].properties()->position(); + + label nHoles = injectors_[nozzlei].properties()->nHoles(); + vector ip(vector::zero); + if (nHoles > 1) + { + for(label i=0;i<nHoles;i++) + { + ip += injectors_[nozzlei].properties()->position(i); + } + ip /= nHoles; + } + else + { + ip = injectors_[nozzlei].properties()->position(0); + } + +// vector ip = injectors_[nozzlei].properties()->position(); scalar d = 0.0; scalar mTot = 0.0; diff --git a/src/lagrangian/dieselSpray/spray/sprayInject.C b/src/lagrangian/dieselSpray/spray/sprayInject.C index 7b3a5d94c5d58c9b5adb188c15312d368dd58f13..a42acebf58e49297ca457755a180a27d78576e97 100644 --- a/src/lagrangian/dieselSpray/spray/sprayInject.C +++ b/src/lagrangian/dieselSpray/spray/sprayInject.C @@ -45,24 +45,31 @@ void spray::inject() // Inject the parcels for each injector sequentially forAll(injectors_, i) { - const injectorType& it = injectors_[i].properties(); + autoPtr<injectorType>& it = injectors()[i].properties(); + if (!it->pressureIndependentVelocity()) + { + scalar referencePressure = p().average().value(); + it->correctProfiles(fuels(), referencePressure); + } + + const label nHoles = it->nHoles(); // parcels have the same mass during a timestep - scalar mass = it.mass(time0, time, twoD_, angleOfWedge_); + scalar mass = it->mass(time0, time, twoD_, angleOfWedge_); - label Np = it.nParcelsToInject(time0, time); + label Np = it->nParcelsToInject(time0, time); if (mass > 0) { Np = max(1, Np); - scalar mp = mass/Np; + scalar mp = mass/Np/nHoles; // constT is only larger than zero for the first // part of the injection scalar constT = max ( 0.0, - it.tsoi() - time0 + it->tsoi() - time0 ); // deltaT is the duration of injection during this timestep @@ -71,8 +78,8 @@ void spray::inject() runTime_.deltaT().value(), min ( - time - it.tsoi(), - it.teoi() - time0 + time - it->tsoi(), + it->teoi() - time0 ) ); @@ -81,87 +88,92 @@ void spray::inject() // calculate the time of injection for parcel 'j' scalar toi = time0 + constT + deltaT*j/scalar(Np); - // calculate the velocity of the injected parcel - vector injectionPosition = it.position - ( - toi, - twoD_, - angleOfWedge_, - axisOfSymmetry_, - axisOfWedge_, - axisOfWedgeNormal_, - rndGen_ - ); - - scalar diameter = injection().d0(i, toi); - vector direction = injection().direction(i, toi, diameter); - vector U = injection().velocity(i, toi)*direction; - - scalar symComponent = direction & axisOfSymmetry_; - vector normal = direction - symComponent*axisOfSymmetry_; - normal /= mag(normal); - - // should be set from dict or model - scalar deviation = breakup().y0(); - scalar ddev = breakup().yDot0(); - - label injectorCell = mesh_.findCell(injectionPosition); - -# include "findInjectorCell.H" - - if (injectorCell >= 0) + for(label n=0; n<nHoles; n++) { - scalar liquidCore = 1.0; - - // construct the parcel that is to be injected - parcel* pPtr = new parcel + // calculate the velocity of the injected parcel + vector injectionPosition = it->position ( - *this, - injectionPosition, - injectorCell, - normal, - diameter, - it.T(toi), - mp, - deviation, - ddev, - 0.0, - 0.0, - 0.0, - liquidCore, - scalar(i), - U, - vector::zero, - it.X(), - fuels_->components() + n, + toi, + twoD_, + angleOfWedge_, + axisOfSymmetry_, + axisOfWedge_, + axisOfWedgeNormal_, + rndGen_ ); + + scalar diameter = injection().d0(i, toi); + vector direction = injection().direction(i, n, toi, diameter); + vector U = injection().velocity(i, toi)*direction; - injectedLiquidKE_ += 0.5*pPtr->m()*pow(mag(U), 2.0); - - scalar dt = time - toi; - - pPtr->stepFraction() = - (runTime_.deltaT().value() - dt) - /runTime_.deltaT().value(); + scalar symComponent = direction & axisOfSymmetry_; + vector normal = direction - symComponent*axisOfSymmetry_; + normal /= mag(normal); - bool keepParcel = pPtr->move - ( - *this - ); + // should be set from dict or model + scalar deviation = breakup().y0(); + scalar ddev = breakup().yDot0(); - if (keepParcel) - { - addParticle(pPtr); - } - else + label injectorCell = mesh_.findCell(injectionPosition); + +# include "findInjectorCell.H" + + if (injectorCell >= 0) { - delete pPtr; - } - } - } - } - } + scalar liquidCore = 1.0; + + // construct the parcel that is to be injected + + parcel* pPtr = new parcel + ( + *this, + injectionPosition, + injectorCell, + normal, + diameter, + it->T(toi), + mp, + deviation, + ddev, + 0.0, + 0.0, + 0.0, + liquidCore, + scalar(i), + U, + vector::zero, + it->X(), + fuels_->components() + ); + + injectedLiquidKE_ += 0.5*pPtr->m()*pow(mag(U), 2.0); + + scalar dt = time - toi; + + pPtr->stepFraction() = + (runTime_.deltaT().value() - dt) + /runTime_.deltaT().value(); + + bool keepParcel = pPtr->move + ( + *this + ); + + if (keepParcel) + { + addParticle(pPtr); + } + else + { + delete pPtr; + } + } // if (injectorCell.... + } // for(label n=0... + } // for(label j=0.... + } // if (mass>0)... + } // forAll(injectors)... time0_ = time; } diff --git a/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/LISA/LISA.C b/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/LISA/LISA.C index ffdeaf4e9ca6f1219446ed1de1ff9addaf1fe92a..47f15462ac6942be43562f5d12e1674c52a16cbd 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/LISA/LISA.C +++ b/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/LISA/LISA.C @@ -140,12 +140,18 @@ void LISA::atomizeParcel const injectorType& it = spray_.injectors()[label(p.injector())].properties(); - const vector itPosition = it.position(); + if (it.nHoles() > 1) + { + Info << "Warning: This atomization model is not suitable for multihole injector." << endl + << "Only the first hole will be used." << endl; + } + + const vector itPosition = it.position(0); scalar pWalk = mag(p.position() - itPosition); // Updating liquid sheet tickness... that is the droplet diameter - - const vector direction = it.direction(); + + const vector direction = it.direction(0, spray_.runTime().value()); scalar h = (p.position() - itPosition) & direction; diff --git a/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/blobsSheetAtomization/blobsSheetAtomization.C b/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/blobsSheetAtomization/blobsSheetAtomization.C index 1cb8db82ef48c8ab02696eb8a4256f9c0880d4d0..dc7f2b51f731f4f1a61140931a051f73edc68d2c 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/blobsSheetAtomization/blobsSheetAtomization.C +++ b/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/blobsSheetAtomization/blobsSheetAtomization.C @@ -112,7 +112,22 @@ void blobsSheetAtomization::atomizeParcel const injectorType& it = spray_.injectors()[label(p.injector())].properties(); - const vector itPosition = it.position(); + vector itPosition(vector::zero); + label nHoles = it.nHoles(); + if (nHoles > 1) + { + for(label i=0; i<nHoles;i++) + { + itPosition += it.position(i); + } + itPosition /= nHoles; + } + else + { + itPosition = it.position(0); + } +// const vector itPosition = it.position(); + scalar lBU = B_ * sqrt ( diff --git a/src/lagrangian/dieselSpray/spraySubModels/breakupModel/reitzKHRT/reitzKHRT.C b/src/lagrangian/dieselSpray/spraySubModels/breakupModel/reitzKHRT/reitzKHRT.C index 32e0ee4f49dbadf70bd9bfd69724b260d6b18504..8b4375234c03777f8bfd786ff9fe7102984e5620 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/breakupModel/reitzKHRT/reitzKHRT.C +++ b/src/lagrangian/dieselSpray/spraySubModels/breakupModel/reitzKHRT/reitzKHRT.C @@ -169,7 +169,7 @@ void reitzKHRT::breakupParcel // check if we have RT breakup if ((p.ct() > tauRT) && (lambdaRT < p.d())) { - // the RT breakup creates diameter/lmbdaRT new droplets + // the RT breakup creates diameter/lambdaRT new droplets p.ct() = -GREAT; scalar multiplier = p.d()/lambdaRT; scalar nDrops = multiplier*Np; @@ -200,8 +200,6 @@ void reitzKHRT::breakupParcel scalar averageParcelMass = spray_.injectors()[injector].properties()->mass()/nParcels; - // NN. Since the parcel doesn't know from which injector - // it comes we use the first one to obtain a 'reference' mass if ( (p.ms()/averageParcelMass > msLimit_) diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/RutlandFlashBoil/RutlandFlashBoil.C b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/RutlandFlashBoil/RutlandFlashBoil.C index fa84ee812410ab16fc34019595d5d9378da27755..4643c14c8edfac5403f0ae249e7ebefd5b3eb50c 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/RutlandFlashBoil/RutlandFlashBoil.C +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/RutlandFlashBoil/RutlandFlashBoil.C @@ -196,8 +196,6 @@ scalar RutlandFlashBoil::boilingTime const scalar vapourSurfaceEnthalpy, const scalar vapourFarEnthalpy, const scalar cpGas, - const scalar Xs, - const scalar Xf, const scalar temperature, const scalar kLiq ) const diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/RutlandFlashBoil/RutlandFlashBoil.H b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/RutlandFlashBoil/RutlandFlashBoil.H index 010899df2e557e3c466ac2091fb3d84cccdce29d..6b1589ce5a554322694a85bc4b8f43e23d9ab4a5 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/RutlandFlashBoil/RutlandFlashBoil.H +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/RutlandFlashBoil/RutlandFlashBoil.H @@ -135,8 +135,6 @@ public: const scalar vapourSurfaceEnthalpy, const scalar vapourFarEnthalpy, const scalar cpGas, - const scalar Xs, - const scalar Xf, const scalar temperature, const scalar kLiquid ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/evaporationModel/evaporationModel.H b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/evaporationModel/evaporationModel.H index a2493609d4819fc417745fe6facd9abe24b26382..e336bc574b945b3b5b0e569ac4f499654b0ac503 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/evaporationModel/evaporationModel.H +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/evaporationModel/evaporationModel.H @@ -143,8 +143,6 @@ public: const scalar vapourSurfaceEnthalpy, const scalar vapourFarEnthalpy, const scalar cpGas, - const scalar Xs, - const scalar Xf, const scalar temperature, const scalar kLiq ) const = 0; diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/noEvaporation/noEvaporation.C b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/noEvaporation/noEvaporation.C index ce506315ce1277448622aa217a549dd2c7e94e48..558ddda1594167316783008e90ee637f320d5f58 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/noEvaporation/noEvaporation.C +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/noEvaporation/noEvaporation.C @@ -114,8 +114,6 @@ scalar noEvaporation::boilingTime const scalar, const scalar, const scalar, - const scalar, - const scalar, const scalar ) const { diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/noEvaporation/noEvaporation.H b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/noEvaporation/noEvaporation.H index a17dd809632cfd360819392ecb281b3bbf0ce9fd..b4bdc272840072142cd4cba70c675847dfef9d9b 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/noEvaporation/noEvaporation.H +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/noEvaporation/noEvaporation.H @@ -111,8 +111,6 @@ public: const scalar vapourSurfaceEnthalpy, const scalar vapourFarEnthalpy, const scalar cpGas, - const scalar Xs, - const scalar Xf, const scalar temperature, const scalar kLiq ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/saturateEvaporationModel/saturateEvaporationModel.C b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/saturateEvaporationModel/saturateEvaporationModel.C index 944dd4df5ab8468f68b9e6aa52edf296d2fec55d..2c27286ca6d222dc71284106c83193c35980bd46 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/saturateEvaporationModel/saturateEvaporationModel.C +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/saturateEvaporationModel/saturateEvaporationModel.C @@ -117,8 +117,6 @@ scalar saturateEvaporationModel::boilingTime const scalar, const scalar, const scalar, - const scalar, - const scalar, const scalar ) const { diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/saturateEvaporationModel/saturateEvaporationModel.H b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/saturateEvaporationModel/saturateEvaporationModel.H index 1c02d95750a682844e0e6360e411b06ff292f880..51dfdf98acee248b654a5e8456ff0fbe281f6a17 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/saturateEvaporationModel/saturateEvaporationModel.H +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/saturateEvaporationModel/saturateEvaporationModel.H @@ -123,8 +123,6 @@ public: const scalar, const scalar, const scalar, - const scalar, - const scalar, const scalar ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/standardEvaporationModel/standardEvaporationModel.C b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/standardEvaporationModel/standardEvaporationModel.C index e1d39fceb6a3005ee8dcb19064bc6781efd9da7f..832dedc94b254293dff0f65979fd2f1544294206 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/standardEvaporationModel/standardEvaporationModel.C +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/standardEvaporationModel/standardEvaporationModel.C @@ -181,8 +181,6 @@ scalar standardEvaporationModel::boilingTime const scalar, const scalar, const scalar, - const scalar, - const scalar, const scalar ) const { diff --git a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/standardEvaporationModel/standardEvaporationModel.H b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/standardEvaporationModel/standardEvaporationModel.H index 8527c5607d0f1a09b39da78f624662bc4986d505..a7c573b49811dddd29ef9745b0a2ab49b3339899 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/standardEvaporationModel/standardEvaporationModel.H +++ b/src/lagrangian/dieselSpray/spraySubModels/evaporationModel/standardEvaporationModel/standardEvaporationModel.H @@ -127,8 +127,6 @@ public: const scalar, const scalar, const scalar, - const scalar, - const scalar, const scalar ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/Chomiak/Chomiak.C b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/Chomiak/Chomiak.C index 71112ffa76fcd838fc38fb6f5fed2bf78cd9b190..f6740ec4fb7eaccc532625f6d49db9634cff3955 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/Chomiak/Chomiak.C +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/Chomiak/Chomiak.C @@ -64,9 +64,7 @@ ChomiakInjector::ChomiakInjector sm.rndGen() ) ), - maxSprayAngle_(ChomiakDict_.lookup("maxSprayConeAngle")), - tan1_(maxSprayAngle_.size()), - tan2_(maxSprayAngle_.size()) + maxSprayAngle_(ChomiakDict_.lookup("maxSprayConeAngle")) { if (sm.injectors().size() != maxSprayAngle_.size()) @@ -77,24 +75,6 @@ ChomiakInjector::ChomiakInjector << abort(FatalError); } - forAll(sm.injectors(), i) - { - Random rndGen(label(0)); - vector dir = sm.injectors()[i].properties()->direction(); - scalar magV = 0.0; - vector tangent; - - while (magV < SMALL) - { - vector testThis = rndGen.vector01(); - - tangent = testThis - (testThis & dir)*dir; - magV = mag(tangent); - } - - tan1_[i] = tangent/magV; - tan2_[i] = dir ^ tan1_[i]; - } scalar referencePressure = sm.p().average().value(); // correct velocityProfile @@ -127,7 +107,8 @@ scalar ChomiakInjector::d0 vector ChomiakInjector::direction ( const label n, - const scalar, + const label hole, + const scalar time, const scalar d ) const { @@ -162,13 +143,13 @@ vector ChomiakInjector::direction { normal = alpha* ( - tan1_[n]*cos(beta) + - tan2_[n]*sin(beta) + injectors_[n].properties()->tan1(hole)*cos(beta) + + injectors_[n].properties()->tan2(hole)*sin(beta) ); } // set the direction of injection by adding the normal vector - vector dir = dcorr*injectors_[n].properties()->direction() + normal; + vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal; dir /= mag(dir); return dir; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/Chomiak/Chomiak.H b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/Chomiak/Chomiak.H index 58194d6d977759e500ae9d1784ee98bcbd0170b1..fc754e63bf5b9919ac3f3824ce39770b2baaee9e 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/Chomiak/Chomiak.H +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/Chomiak/Chomiak.H @@ -67,10 +67,6 @@ private: autoPtr<pdf> dropletPDF_; scalarList maxSprayAngle_; - // two perpendicular vectors, perpendicular to injection direction - List<vector> tan1_; - List<vector> tan2_; - public: //- Runtime type information @@ -100,7 +96,8 @@ public: //- Return the spray angle of the injector vector direction ( - const label injector, + const label injector, + const label hole, const scalar time, const scalar d ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/blobsSwirl/blobsSwirlInjector.C b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/blobsSwirl/blobsSwirlInjector.C index a15d1336916f6f47d24a3c615651fd9fba9a17f8..e6925c68c13bf48aa1a3cd09d8df3e038c0e1e44 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/blobsSwirl/blobsSwirlInjector.C +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/blobsSwirl/blobsSwirlInjector.C @@ -67,9 +67,7 @@ blobsSwirlInjector::blobsSwirlInjector angle_(0.0), u_(0.0), x_(0.0), - h_(0.0), - tan1_(coneAngle_.size()), - tan2_(coneAngle_.size()) + h_(0.0) { if (sm.injectors().size() != coneAngle_.size()) @@ -80,26 +78,6 @@ blobsSwirlInjector::blobsSwirlInjector << abort(FatalError); } - - forAll(sm.injectors(), i) - { - Random rndGen(label(0)); - vector dir = sm.injectors()[i].properties()->direction(); - scalar magV = 0.0; - vector tangent; - - while (magV < SMALL) - { - vector testThis = rndGen.vector01(); - - tangent = testThis - (testThis & dir)*dir; - magV = mag(tangent); - } - - tan1_[i] = tangent/magV; - tan2_[i] = dir ^ tan1_[i]; - } - scalar referencePressure = sm.p().average().value(); // correct velocityProfile @@ -156,8 +134,9 @@ scalar blobsSwirlInjector::d0 vector blobsSwirlInjector::direction ( const label n, - const scalar, - const scalar + const label hole, + const scalar time, + const scalar d ) const { @@ -186,13 +165,13 @@ vector blobsSwirlInjector::direction { normal = alpha* ( - tan1_[n]*cos(beta) + - tan2_[n]*sin(beta) + injectors_[n].properties()->tan1(hole)*cos(beta) + + injectors_[n].properties()->tan2(hole)*sin(beta) ); } // set the direction of injection by adding the normal vector - vector dir = dcorr*injectors_[n].properties()->direction() + normal; + vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal; dir /= mag(dir); return dir; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/blobsSwirl/blobsSwirlInjector.H b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/blobsSwirl/blobsSwirlInjector.H index de0e2f278f719f44f55a39a31e1e0e8a0c0f615f..200a6cb1d42b1224f5285a5ab3ee3a04b817579b 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/blobsSwirl/blobsSwirlInjector.H +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/blobsSwirl/blobsSwirlInjector.H @@ -90,10 +90,6 @@ private: mutable scalar h_; - // two perpendicular vectors, perpendicular to injection direction - List<vector> tan1_; - List<vector> tan2_; - // private member functions scalar kv @@ -142,6 +138,7 @@ public: vector direction ( const label injector, + const label hole, const scalar time, const scalar d ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/constant/constInjector.C b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/constant/constInjector.C index b5bad617283ecc7c1a9b33af1de7b393550b9aac..52ca12ee6a73b071fa294dbf93eefb96c3c74a21 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/constant/constInjector.C +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/constant/constInjector.C @@ -57,9 +57,7 @@ constInjector::constInjector injectorModel(dict, sm), specDict_(dict.subDict(typeName + "Coeffs")), dropletNozzleDiameterRatio_(specDict_.lookup("dropletNozzleDiameterRatio")), - sprayAngle_(specDict_.lookup("sprayAngle")), - tan1_(sprayAngle_.size()), - tan2_(sprayAngle_.size()) + sprayAngle_(specDict_.lookup("sprayAngle")) { if (sm.injectors().size() != dropletNozzleDiameterRatio_.size()) { @@ -77,26 +75,6 @@ constInjector::constInjector << abort(FatalError); } - - forAll(sm.injectors(), i) - { - Random rndGen(label(0)); - vector dir = sm.injectors()[i].properties()->direction(); - scalar magV = 0.0; - vector tangent; - - while (magV < SMALL) - { - vector testThis = rndGen.vector01(); - - tangent = testThis - (testThis & dir)*dir; - magV = mag(tangent); - } - - tan1_[i] = tangent/magV; - tan2_[i] = dir ^ tan1_[i]; - } - scalar referencePressure = sm.p().average().value(); // correct velocity and pressure profiles @@ -129,12 +107,11 @@ scalar constInjector::d0 vector constInjector::direction ( const label n, - const scalar, - const scalar + const label hole, + const scalar time, + const scalar d ) const { - // return sprayAngle_[n]; - /* randomly distribute parcels in a solid cone @@ -179,13 +156,13 @@ vector constInjector::direction { normal = alpha* ( - tan1_[n]*cos(beta) + - tan2_[n]*sin(beta) + injectors_[n].properties()->tan1(hole)*cos(beta) + + injectors_[n].properties()->tan2(hole)*sin(beta) ); } // set the direction of injection by adding the normal vector - vector dir = dcorr*injectors_[n].properties()->direction() + normal; + vector dir = dcorr*injectors_[n].properties()->direction(n, time) + normal; dir /= mag(dir); return dir; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/constant/constInjector.H b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/constant/constInjector.H index 67fe880c0f3c023e506a8081443634c547ca11d6..4a41808c4b6153fb4f6b63fce7199e3b29edd64d 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/constant/constInjector.H +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/constant/constInjector.H @@ -59,10 +59,6 @@ private: scalarList dropletNozzleDiameterRatio_; scalarList sprayAngle_; - // two perpendicular vectors, perpendicular to injection direction - List<vector> tan1_; - List<vector> tan2_; - public: //- Runtime type information @@ -93,6 +89,7 @@ public: vector direction ( const label injector, + const label hole, const scalar time, const scalar d ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedHollowCone/definedHollowCone.C b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedHollowCone/definedHollowCone.C index 6f06bb17528c7806a5fcfb30eb079244eb0e1711..740108fdf5ccd5db75d9e8b5e9bac463dd23a72a 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedHollowCone/definedHollowCone.C +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedHollowCone/definedHollowCone.C @@ -65,9 +65,7 @@ definedHollowConeInjector::definedHollowConeInjector ) ), innerConeAngle_(definedHollowConeDict_.lookup("innerConeAngle")), - outerConeAngle_(definedHollowConeDict_.lookup("outerConeAngle")), - tan1_(sm.injectors().size()), - tan2_(sm.injectors().size()) + outerConeAngle_(definedHollowConeDict_.lookup("outerConeAngle")) { // convert CA to real time - inner cone angle @@ -109,26 +107,6 @@ definedHollowConeInjector::definedHollowConeInjector << abort(FatalError); } - // initialise injectors - forAll(sm.injectors(), i) - { - Random rndGen(label(0)); - vector dir = sm.injectors()[i].properties()->direction(); - scalar magV = 0.0; - vector tangent; - - while (magV < SMALL) - { - vector testThis = rndGen.vector01(); - - tangent = testThis - (testThis & dir)*dir; - magV = mag(tangent); - } - - tan1_[i] = tangent/magV; - tan2_[i] = dir ^ tan1_[i]; - } - scalar referencePressure = sm.p().average().value(); // correct pressureProfile forAll(sm.injectors(), i) @@ -162,6 +140,7 @@ scalar definedHollowConeInjector::d0 vector definedHollowConeInjector::direction ( const label n, + const label hole, const scalar t, const scalar d ) const @@ -201,13 +180,13 @@ vector definedHollowConeInjector::direction { normal = alpha* ( - tan1_[n]*cos(beta) + - tan2_[n]*sin(beta) + injectors_[n].properties()->tan1(hole)*cos(beta) + + injectors_[n].properties()->tan2(hole)*sin(beta) ); } // set the direction of injection by adding the normal vector - vector dir = dcorr*injectors_[n].properties()->direction() + normal; + vector dir = dcorr*injectors_[n].properties()->direction(hole, t) + normal; // normailse direction vector dir /= mag(dir); diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedHollowCone/definedHollowCone.H b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedHollowCone/definedHollowCone.H index 81023e49a9df4e1b8c961d7f8b326a51d87b80c4..83d9613667ca05ef8c26faf1f79eec711d2b6480 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedHollowCone/definedHollowCone.H +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedHollowCone/definedHollowCone.H @@ -68,11 +68,6 @@ private: List<pair> innerConeAngle_; List<pair> outerConeAngle_; - // two perpendicular vectors, perpendicular to injection direction - List<vector> tan1_; - List<vector> tan2_; - - public: //- Runtime type information @@ -102,7 +97,8 @@ public: //- Return the spray angle of the injector vector direction ( - const label injector, + const label injector, + const label hole, const scalar time, const scalar d ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedPressureSwirl/definedPressureSwirl.C b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedPressureSwirl/definedPressureSwirl.C index 730eee8240c8f0c98780260d4d90e5c954a59f56..c3f56b07f985e5ab3c3ea7b8a54f51c3fff0a0db 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedPressureSwirl/definedPressureSwirl.C +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedPressureSwirl/definedPressureSwirl.C @@ -61,32 +61,9 @@ definedPressureSwirlInjector::definedPressureSwirlInjector coneInterval_(definedPressureSwirlInjectorDict_.lookup("ConeInterval")), maxKv_(definedPressureSwirlInjectorDict_.lookup("maxKv")), - angle_(0.0), - tan1_(coneAngle_.size()), - tan2_(coneAngle_.size()) + angle_(0.0) { - - - forAll(sm.injectors(), i) - { - Random rndGen(label(0)); - vector dir = sm.injectors()[i].properties()->direction(); - scalar magV = 0.0; - vector tangent; - - while (magV < SMALL) - { - vector testThis = rndGen.vector01(); - - tangent = testThis - (testThis & dir)*dir; - magV = mag(tangent); - } - - tan1_[i] = tangent/magV; - tan2_[i] = dir ^ tan1_[i]; - } - scalar referencePressure = sm.p().average().value(); // correct velocityProfile @@ -219,8 +196,9 @@ scalar definedPressureSwirlInjector::d0 vector definedPressureSwirlInjector::direction ( const label n, - const scalar, - const scalar + const label hole, + const scalar time, + const scalar d ) const { @@ -249,13 +227,13 @@ vector definedPressureSwirlInjector::direction { normal = alpha* ( - tan1_[n]*cos(beta) + - tan2_[n]*sin(beta) + injectors_[n].properties()->tan1(hole)*cos(beta) + + injectors_[n].properties()->tan2(hole)*sin(beta) ); } // set the direction of injection by adding the normal vector - vector dir = dcorr*injectors_[n].properties()->direction() + normal; + vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal; dir /= mag(dir); return dir; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedPressureSwirl/definedPressureSwirl.H b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedPressureSwirl/definedPressureSwirl.H index 14415d789b343fbd88fbd71f6bc6611d5a5d4e85..e84dd8f43ef618eb766c0263b60e55e2f5cd13f4 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedPressureSwirl/definedPressureSwirl.H +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/definedPressureSwirl/definedPressureSwirl.H @@ -71,10 +71,6 @@ private: // The initial velocity for the parcels mutable scalar u_; - // two perpendicular vectors, perpendicular to injection direction - List<vector> tan1_; - List<vector> tan2_; - // private member functions scalar kv @@ -118,6 +114,7 @@ public: vector direction ( const label injector, + const label hole, const scalar time, const scalar d ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/hollowCone/hollowCone.C b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/hollowCone/hollowCone.C index 2121a803f11ee6c3ecd9859805069b37e284052f..001102e4f8591470fce95d690f34bb23ddcc2cba 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/hollowCone/hollowCone.C +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/hollowCone/hollowCone.C @@ -65,9 +65,7 @@ hollowConeInjector::hollowConeInjector ) ), innerAngle_(hollowConeDict_.lookup("innerConeAngle")), - outerAngle_(hollowConeDict_.lookup("outerConeAngle")), - tan1_(outerAngle_.size()), - tan2_(outerAngle_.size()) + outerAngle_(hollowConeDict_.lookup("outerConeAngle")) { if (sm.injectors().size() != innerAngle_.size()) @@ -86,26 +84,8 @@ hollowConeInjector::hollowConeInjector << abort(FatalError); } - forAll(sm.injectors(), i) - { - Random rndGen(label(0)); - vector dir = sm.injectors()[i].properties()->direction(); - scalar magV = 0.0; - vector tangent; - - while (magV < SMALL) - { - vector testThis = rndGen.vector01(); - - tangent = testThis - (testThis & dir)*dir; - magV = mag(tangent); - } - - tan1_[i] = tangent/magV; - tan2_[i] = dir ^ tan1_[i]; - } - scalar referencePressure = sm.ambientPressure(); + // correct velocityProfile forAll(sm.injectors(), i) { @@ -136,8 +116,9 @@ scalar hollowConeInjector::d0 vector hollowConeInjector::direction ( const label n, - const scalar, - const scalar + const label hole, + const scalar time, + const scalar d ) const { scalar angle = innerAngle_[n] + rndGen_.scalar01()*(outerAngle_[n]-innerAngle_[n]); @@ -166,13 +147,13 @@ vector hollowConeInjector::direction { normal = alpha* ( - tan1_[n]*cos(beta) + - tan2_[n]*sin(beta) + injectors_[n].properties()->tan1(hole)*cos(beta) + + injectors_[n].properties()->tan2(hole)*sin(beta) ); } // set the direction of injection by adding the normal vector - vector dir = dcorr*injectors_[n].properties()->direction() + normal; + vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal; dir /= mag(dir); return dir; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/hollowCone/hollowCone.H b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/hollowCone/hollowCone.H index e53b6afcbb9b9135cc88addbf79d319ac1a836ad..c0469b997c73ff4eb9d384a76430256cf5d1a0bc 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/hollowCone/hollowCone.H +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/hollowCone/hollowCone.H @@ -63,10 +63,6 @@ private: scalarList innerAngle_; scalarList outerAngle_; - // two perpendicular vectors, perpendicular to injection direction - List<vector> tan1_; - List<vector> tan2_; - public: //- Runtime type information @@ -96,7 +92,8 @@ public: //- Return the spray angle of the injector vector direction ( - const label injector, + const label injector, + const label hole, const scalar time, const scalar d ) const; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/injectorModel/injectorModel.H b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/injectorModel/injectorModel.H index b099208287ce7c304bac71a97752c2c92893241d..22bd419508a32dea6d20ffc66332b48af5d8ff74 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/injectorModel/injectorModel.H +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/injectorModel/injectorModel.H @@ -118,6 +118,7 @@ public: virtual vector direction ( const label injector, + const label hole, const scalar time, const scalar d ) const = 0; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/pressureSwirl/pressureSwirlInjector.C b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/pressureSwirl/pressureSwirlInjector.C index 83dba60703e261c8652b154e9ac5ee52349b233d..86d419c8d8d798b84bf55bd2993c109563640187 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/pressureSwirl/pressureSwirlInjector.C +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/pressureSwirl/pressureSwirlInjector.C @@ -61,9 +61,7 @@ pressureSwirlInjector::pressureSwirlInjector coneInterval_(pressureSwirlInjectorDict_.lookup("ConeInterval")), maxKv_(pressureSwirlInjectorDict_.lookup("maxKv")), - angle_(0.0), - tan1_(coneAngle_.size()), - tan2_(coneAngle_.size()) + angle_(0.0) { if (sm.injectors().size() != coneAngle_.size()) @@ -74,26 +72,6 @@ pressureSwirlInjector::pressureSwirlInjector << abort(FatalError); } - - forAll(sm.injectors(), i) - { - Random rndGen(label(0)); - vector dir = sm.injectors()[i].properties()->direction(); - scalar magV = 0.0; - vector tangent; - - while (magV < SMALL) - { - vector testThis = rndGen.vector01(); - - tangent = testThis - (testThis & dir)*dir; - magV = mag(tangent); - } - - tan1_[i] = tangent/magV; - tan2_[i] = dir ^ tan1_[i]; - } - scalar referencePressure = sm.p().average().value(); // correct velocityProfile @@ -147,8 +125,9 @@ scalar pressureSwirlInjector::d0 vector pressureSwirlInjector::direction ( const label n, - const scalar, - const scalar + const label hole, + const scalar time, + const scalar d ) const { @@ -177,13 +156,13 @@ vector pressureSwirlInjector::direction { normal = alpha* ( - tan1_[n]*cos(beta) + - tan2_[n]*sin(beta) + injectors_[n].properties()->tan1(hole)*cos(beta) + + injectors_[n].properties()->tan2(hole)*sin(beta) ); } // set the direction of injection by adding the normal vector - vector dir = dcorr*injectors_[n].properties()->direction() + normal; + vector dir = dcorr*injectors_[n].properties()->direction(hole, time) + normal; dir /= mag(dir); return dir; diff --git a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/pressureSwirl/pressureSwirlInjector.H b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/pressureSwirl/pressureSwirlInjector.H index d57312871377c9bc0aa57dcc0a60c2034185a1a4..91e5bc9f1a118ec1fc30be5f4a926dd9006ea891 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/injectorModel/pressureSwirl/pressureSwirlInjector.H +++ b/src/lagrangian/dieselSpray/spraySubModels/injectorModel/pressureSwirl/pressureSwirlInjector.H @@ -68,10 +68,6 @@ private: // The initial velocity for the parcels mutable scalar u_; - // two perpendicular vectors, perpendicular to injection direction - List<vector> tan1_; - List<vector> tan2_; - // private member functions scalar kv @@ -113,7 +109,8 @@ public: //- Return the spray angle of the injector vector direction ( - const label injector, + const label injector, + const label hole, const scalar time, const scalar d ) const; diff --git a/src/meshTools/cellFeatures/cellFeatures.C b/src/meshTools/cellFeatures/cellFeatures.C index 3107dc79b0d36c09477ee30eb4259e34e969f8d7..b4838a7addf20e6761835bc03f39b7f2d23f3b2a 100644 --- a/src/meshTools/cellFeatures/cellFeatures.C +++ b/src/meshTools/cellFeatures/cellFeatures.C @@ -369,8 +369,6 @@ void Foam::cellFeatures::calcSuperFaces() const } else { - superFace.shrink(); - faces[superFaceI].transfer(superFace); } } diff --git a/src/meshTools/indexedOctree/indexedOctree.C b/src/meshTools/indexedOctree/indexedOctree.C index b8b18401df14a35a14a0143fb6ea6afdd1639fbc..dab1353dd38f72873474f259fc55802112d277a7 100644 --- a/src/meshTools/indexedOctree/indexedOctree.C +++ b/src/meshTools/indexedOctree/indexedOctree.C @@ -183,9 +183,7 @@ void indexedOctree<Type>::divide result.setSize(8); for (direction octant = 0; octant < subIndices.size(); octant++) { - subIndices[octant].shrink(); result[octant].transfer(subIndices[octant]); - subIndices[octant].clear(); } } diff --git a/src/meshTools/regionSplit/regionSplit.C b/src/meshTools/regionSplit/regionSplit.C index 0b500536a85dc170f26fb443600f26abdb75db0d..e93674ca7dde79f1be007523e30cc4834dfab6cb 100644 --- a/src/meshTools/regionSplit/regionSplit.C +++ b/src/meshTools/regionSplit/regionSplit.C @@ -250,8 +250,7 @@ void Foam::regionSplit::fillSeedMask // << newChangedFaces.size() << endl; //} - changedFaces.transfer(newChangedFaces.shrink()); - newChangedFaces.clear(); + changedFaces.transfer(newChangedFaces); } } diff --git a/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C b/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C index e3c42e77beea8e9e198d48e601dba2746ba2f409..63b85e1d686fc66aa514e80b30612d1371b4a5c2 100644 --- a/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C +++ b/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C @@ -239,12 +239,11 @@ Foam::distributedTriSurfaceMesh::constructSegments sendMap.setSize(Pstream::nProcs()); forAll(sendMap, procI) { - dynSendMap[procI].shrink(); sendMap[procI].transfer(dynSendMap[procI]); } - allSegments.transfer(dynAllSegments.shrink()); - allSegmentMap.transfer(dynAllSegmentMap.shrink()); + allSegments.transfer(dynAllSegments); + allSegmentMap.transfer(dynAllSegmentMap); } @@ -704,13 +703,12 @@ Foam::distributedTriSurfaceMesh::calcLocalQueries sendMap.setSize(Pstream::nProcs()); forAll(sendMap, procI) { - dynSendMap[procI].shrink(); sendMap[procI].transfer(dynSendMap[procI]); } - allCentres.transfer(dynAllCentres.shrink()); - allRadiusSqr.transfer(dynAllRadiusSqr.shrink()); - allSegmentMap.transfer(dynAllSegmentMap.shrink()); + allCentres.transfer(dynAllCentres); + allRadiusSqr.transfer(dynAllRadiusSqr); + allSegmentMap.transfer(dynAllSegmentMap); } diff --git a/src/meshTools/searchableSurface/searchableBox.C b/src/meshTools/searchableSurface/searchableBox.C index 34e3faec99b2c04976ea4701d33d07696f49c2f4..3ed3b90c6e1b5429f0b41d46cf01964ed5fd55dd 100644 --- a/src/meshTools/searchableSurface/searchableBox.C +++ b/src/meshTools/searchableSurface/searchableBox.C @@ -482,7 +482,6 @@ void Foam::searchableBox::findLineAll pt = inter.hitPoint() + smallVec[pointI]; } - hits.shrink(); info[pointI].transfer(hits); } else diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index e8b7c0681ffc3550aa9d3d1ac6336e0a781a29dd..fe9e0c58f9a7306f1a57a94a70ddf0892dbe9927 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -449,7 +449,6 @@ void Foam::triSurfaceMesh::findLineAll pt = inter.hitPoint() + smallVec[pointI]; } - hits.shrink(); info[pointI].transfer(hits); } else diff --git a/src/meshTools/triSurface/booleanOps/intersectedSurface/edgeSurface.C b/src/meshTools/triSurface/booleanOps/intersectedSurface/edgeSurface.C index 577d004982f6469a5743d41454bbee724d35f52e..58a86810b13624cd22fe0abb24ac8ffd9d5b85a8 100644 --- a/src/meshTools/triSurface/booleanOps/intersectedSurface/edgeSurface.C +++ b/src/meshTools/triSurface/booleanOps/intersectedSurface/edgeSurface.C @@ -287,18 +287,12 @@ Foam::edgeSurface::edgeSurface } // Transfer. - allEdges.shrink(); edges_.transfer(allEdges); - - allParentEdges.shrink(); parentEdges_.transfer(allParentEdges); forAll(allFaceEdges, faceI) { - DynamicList<label>& allFEdges = allFaceEdges[faceI]; - - allFEdges.shrink(); - faceEdges_[faceI].transfer(allFEdges); + faceEdges_[faceI].transfer(allFaceEdges[faceI]); } diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C index 3d07e99a93cb27a60c4db5428a2b738421948408..f46508642548d1c4c1ddc53b9454dca79e6f5b42 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C @@ -218,14 +218,8 @@ void Foam::edgeIntersections::intersectEdges // Done current edge. Transfer all data into *this - currentIntersections.shrink(); - currentIntersectionTypes.shrink(); - operator[](edgeI).transfer(currentIntersections); classification_[edgeI].transfer(currentIntersectionTypes); - - currentIntersections.clear(); - currentIntersectionTypes.clear(); } if (debug) @@ -651,7 +645,7 @@ Foam::label Foam::edgeIntersections::removeDegenerates offsetPerturb ( surf1, - surf2, + surf2, edgeI, rndGen, points1, diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersectionTemplates.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersectionTemplates.C index fd06704ab1ccaa853eb39aa3f90547f96696f0de..ce5851cf169af0ac2b042328c6013db2a7f645e1 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersectionTemplates.C +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersectionTemplates.C @@ -38,7 +38,6 @@ void Foam::surfaceIntersection::transfer List<T>& lList ) { - dList.shrink(); lList.transfer(dList); } diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index 1732fb45d62f25fa19dcc6b4b51c75b43e512e7d..de668b54d1b225fa65f792a183d28481ff31f01b 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -197,7 +197,7 @@ void Foam::surfaceFeatures::calcFeatPoints(const List<edgeStatus>& edgeStat) featurePoints.append(pointI); } } - featurePoints.shrink(); + featurePoints_.transfer(featurePoints); } diff --git a/src/sampling/sampledSurface/isoSurface/isoSurface.C b/src/sampling/sampledSurface/isoSurface/isoSurface.C index 937aa68616ac733a850c6407ba2fa04fbf9dda8e..5d77290b0f2be3a8ba809df3503e3894868d581e 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/isoSurface.C @@ -815,8 +815,8 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints } } - triMap.transfer(newToOldTri.shrink()); - tris.transfer(dynTris.shrink()); + triMap.transfer(newToOldTri); + tris.transfer(dynTris); } @@ -875,7 +875,7 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints } } - triMap.transfer(newToOldTri.shrink()); + triMap.transfer(newToOldTri); tris.setSize(newTriI); } } @@ -1373,7 +1373,17 @@ Foam::isoSurface::isoSurface { const polyPatch& pp = patches[patchI]; - if (!pp.coupled()) + if (pp.coupled()) + { + label faceI = pp.start(); + + forAll(pp, i) + { + boundaryRegion[faceI-mesh_.nInternalFaces()] = patchI; + faceI++; + } + } + else { label faceI = pp.start(); @@ -1381,12 +1391,13 @@ Foam::isoSurface::isoSurface { boundaryRegion[faceI-mesh_.nInternalFaces()] = patchI; - const face& f = mesh_.faces()[faceI++]; + const face& f = mesh_.faces()[faceI]; forAll(f, fp) { isBoundaryPoint.set(f[fp], 1); } + faceI++; } } } diff --git a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C index 5cffcdf0ddf4b8f21c8f2f2f01363ad97ec43df9..6557112012114f2cd64ab819e2d01b0184786e59 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C @@ -434,7 +434,7 @@ void Foam::isoSurfaceCell::calcSnappedCc } else { - // Need to analyse + // Need to analyse forAll(cFaces, cFaceI) { const face& f = mesh_.faces()[cFaces[cFaceI]]; @@ -747,7 +747,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint ( false, // do not check for duplicate tris localTriPoints, - triPointReverseMap, + triPointReverseMap, triMap ) ); @@ -871,8 +871,8 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints } } - triMap.transfer(newToOldTri.shrink()); - tris.transfer(dynTris.shrink()); + triMap.transfer(newToOldTri); + tris.transfer(dynTris); } @@ -930,7 +930,7 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints } } - triMap.transfer(newToOldTri.shrink()); + triMap.transfer(newToOldTri); tris.setSize(newTriI); } } @@ -1062,7 +1062,7 @@ void Foam::isoSurfaceCell::calcAddressing faceEdges[triI][1] = oldToMerged[edgeI++]; faceEdges[triI][2] = oldToMerged[edgeI++]; } - + // Determine edgeFaces edgeFace0.setSize(mergedCentres.size()); @@ -1137,7 +1137,7 @@ void Foam::isoSurfaceCell::walkOrientation forAll(fEdges, fp) { label edgeI = fEdges[fp]; - + // my points: label p0 = tri[fp]; label p1 = tri[tri.fcIndex(fp)]; @@ -1174,7 +1174,7 @@ void Foam::isoSurfaceCell::walkOrientation changedFaces.transfer(newChangedFaces); } -} +} void Foam::isoSurfaceCell::orientSurface @@ -1199,7 +1199,7 @@ void Foam::isoSurfaceCell::orientSurface for ( ; - seedTriI < surf.size() && flipState[seedTriI] != -1; + seedTriI < surf.size() && flipState[seedTriI] != -1; seedTriI++ ) {} @@ -1473,14 +1473,13 @@ Foam::isoSurfaceCell::isoSurfaceCell snappedCc = -1; } - snappedPoints.shrink(); - if (debug) { Pout<< "isoSurfaceCell : shifted " << snappedPoints.size() << " cell centres to intersection." << endl; } + snappedPoints.shrink(); label nCellSnaps = snappedPoints.size(); // Per point -1 or a point inside snappedPoints. diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C index a1fcfd401391a13e75ec15e85918f5a56b4b651a..0c7832f176681eff6987201f2d9099cbb755ad2d 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C @@ -45,6 +45,8 @@ void Foam::sampledIsoSurface::getIsoFields() const { const fvMesh& fvm = static_cast<const fvMesh&>(mesh()); + word pointFldName = "volPointInterpolate(" + isoField_ + ')'; + // Get volField // ~~~~~~~~~~~~ @@ -64,28 +66,56 @@ void Foam::sampledIsoSurface::getIsoFields() const if (debug) { - Info<< "sampledIsoSurface::getIsoField() : reading " - << isoField_ << " from time " << fvm.time().timeName() + Info<< "sampledIsoSurface::getIsoField() : checking " + << isoField_ << " for same time " << fvm.time().timeName() << endl; } - storedVolFieldPtr_.reset + if ( - new volScalarField + !storedVolFieldPtr_.valid() + || (fvm.time().timeName() != storedVolFieldPtr_().instance()) + ) + { + if (debug) + { + Info<< "sampledIsoSurface::getIsoField() : reading " + << isoField_ << " from time " << fvm.time().timeName() + << endl; + } + + storedVolFieldPtr_.reset ( - IOobject + new volScalarField ( - isoField_, - fvm.time().timeName(), - fvm, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), - fvm - ) - ); - volFieldPtr_ = storedVolFieldPtr_.operator->(); + IOobject + ( + isoField_, + fvm.time().timeName(), + fvm, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + fvm + ) + ); + volFieldPtr_ = storedVolFieldPtr_.operator->(); + + // Interpolate to get pointField + + if (debug) + { + Info<< "sampledIsoSurface::getIsoField() : interpolating " + << pointFldName << endl; + } + + storedPointFieldPtr_.reset + ( + volPointInterpolation::New(fvm).interpolate(*volFieldPtr_).ptr() + ); + pointFieldPtr_ = storedPointFieldPtr_.operator->(); + } } @@ -93,8 +123,6 @@ void Foam::sampledIsoSurface::getIsoFields() const // Get pointField // ~~~~~~~~~~~~~~ - word pointFldName = "volPointInterpolate(" + isoField_ + ')'; - if (fvm.foundObject<pointScalarField>(pointFldName)) { if (debug) @@ -102,7 +130,6 @@ void Foam::sampledIsoSurface::getIsoFields() const Info<< "sampledIsoSurface::getIsoField() : lookup " << pointFldName << endl; } - storedPointFieldPtr_.clear(); pointFieldPtr_ = &fvm.lookupObject<pointScalarField>(pointFldName); } else @@ -111,15 +138,29 @@ void Foam::sampledIsoSurface::getIsoFields() const if (debug) { - Info<< "sampledIsoSurface::getIsoField() : interpolating " - << pointFldName << endl; + Info<< "sampledIsoSurface::getIsoField() : checking interpolate " + << isoField_ << " for same time " << fvm.time().timeName() + << endl; } - storedPointFieldPtr_.reset + if ( - volPointInterpolation::New(fvm).interpolate(*volFieldPtr_).ptr() - ); - pointFieldPtr_ = storedPointFieldPtr_.operator->(); + !storedPointFieldPtr_.valid() + || (fvm.time().timeName() != storedPointFieldPtr_().instance()) + ) + { + if (debug) + { + Info<< "sampledIsoSurface::getIsoField() : interpolating " + << pointFldName << endl; + } + + storedPointFieldPtr_.reset + ( + volPointInterpolation::New(fvm).interpolate(*volFieldPtr_).ptr() + ); + pointFieldPtr_ = storedPointFieldPtr_.operator->(); + } } if (debug) diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C index 49e48578f510fa922268b77a8d470aafc4451cce..3409b2c42115df69101f36380531c15b0472e977 100644 --- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C +++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.C @@ -135,26 +135,27 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read label regionI = 0; label lineLabel, shapeId, nLabels, cellTableId, typeId; - labelList starLabels(64); + DynamicList<label> vertexLabels(64); while ((is >> lineLabel).good()) { is >> shapeId >> nLabels >> cellTableId >> typeId; - if (nLabels > starLabels.size()) - { - starLabels.setSize(nLabels); - } - starLabels = -1; + vertexLabels.clear(); + vertexLabels.reserve(nLabels); // read indices - max 8 per line for (label i = 0; i < nLabels; ++i) { + label vrtId; if ((i % 8) == 0) { is >> lineLabel; } - is >> starLabels[i]; + is >> vrtId; + + // convert original vertex id to point label + vertexLabels.append(mapPointId[vrtId]); } if (typeId == starcdShellType_) @@ -178,14 +179,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read dynSizes.append(0); } - SubList<label> vertices(starLabels, nLabels); - - // convert orig vertex id to point label - forAll(vertices, i) - { - vertices[i] = mapPointId[vertices[i]]; - } - + SubList<label> vertices(vertexLabels, vertexLabels.size()); if (mustTriangulate && nLabels > 3) { face f(vertices); diff --git a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C index c1114dff6755577b7b74f6f90ba1403c0bf78967..40e624214a2784979d126fa57b68ef3d46e5d202 100644 --- a/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C +++ b/src/surfMesh/surfaceFormats/tri/TRIsurfaceFormatCore.C @@ -175,7 +175,7 @@ bool Foam::fileFormats::TRIsurfaceFormatCore::read } } // truncate addressed size - dynSizes.setSize(nPatch); + dynSizes.setCapacity(nPatch); // transfer to normal lists points_.transfer(dynPoints); diff --git a/applications/test/hmm/dictionaryTest.C b/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.C similarity index 73% rename from applications/test/hmm/dictionaryTest.C rename to src/thermophysicalModels/liquids/CH4N2O/CH4N2O.C index a57a16e552f533f34457e90d9906eff91c3909e6..8a99a9f0ed3a604565909a5aeee30eb9ad305079 100644 --- a/applications/test/hmm/dictionaryTest.C +++ b/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.C @@ -22,30 +22,27 @@ 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 "IOstreams.H" -#include "IFstream.H" -#include "dictionary.H" +------------------------------------------------------------------------------- +*/ -using namespace Foam; +#include "CH4N2O.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Main program: -int main(int argc, char *argv[]) +namespace Foam { - IFstream dictStream("testDict"); - dictionary testDict(dictStream); - Info<< testDict << endl; +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - return 0; -} +defineTypeNameAndDebug(CH4N2O, 0); +addToRunTimeSelectionTable(liquid, CH4N2O,); +addToRunTimeSelectionTable(liquid, CH4N2O, Istream); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace Foam // ************************************************************************* // diff --git a/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.H b/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.H new file mode 100644 index 0000000000000000000000000000000000000000..25c336f32875542a6132e41320fa773bdd05b9d3 --- /dev/null +++ b/src/thermophysicalModels/liquids/CH4N2O/CH4N2O.H @@ -0,0 +1,285 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::CH4N2O + +Description + urea, note that some of the properties are unavailable in the literature and have been copied from water. + +SourceFiles + CH4N2O.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CH4N2O_H +#define CH4N2O_H + +#include "liquid.H" +#include "NSRDSfunc0.H" +#include "NSRDSfunc1.H" +#include "NSRDSfunc2.H" +#include "NSRDSfunc3.H" +#include "NSRDSfunc4.H" +#include "NSRDSfunc5.H" +#include "NSRDSfunc6.H" +#include "NSRDSfunc7.H" +#include "NSRDSfunc14.H" +#include "APIdiffCoefFunc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class CH4N2O Declaration +\*---------------------------------------------------------------------------*/ + +class CH4N2O +: + public liquid +{ + // Private data + + NSRDSfunc0 rho_; + NSRDSfunc1 pv_; + NSRDSfunc6 hl_; + NSRDSfunc0 cp_; + NSRDSfunc0 h_; + NSRDSfunc7 cpg_; + NSRDSfunc4 B_; + NSRDSfunc1 mu_; + NSRDSfunc2 mug_; + NSRDSfunc0 K_; + NSRDSfunc2 Kg_; + NSRDSfunc6 sigma_; + APIdiffCoefFunc D_; + +public: + + //- Runtime type information + TypeName("CH4N2O"); + + + // Constructors + + //- Construct null + CH4N2O() + : + liquid(60.056, 705.0, 9.050e+6, 0.218, 0.337, 405.85, 9.3131e+1, 465.0, 1.52e-29, 0.3449, 4.7813e+4), + rho_(1230.006936, 0, 0, 0, 0, 0), + pv_(12.06, -3992.0, 0, 0, 0), +// hl_(1463034.50113228, 0, 0, 0, 0, 0), +// NN. we cant use constant heat of vapourisation, the below value is linear (sqrt) interpolation to critical temp + hl_(705.0, 2534249.0, 0.5, 0.0, 0.0, 0.0), + cp_(2006.46063673904, 0, 0, 0, 0, 0), + // NN: enthalpy, h_, is not used in the sprayModel. + // For consistency, the enthalpy is derived from hlat and hl. + // It is, however, convenient to have it available. + h_(-6154107.41641135, 2006.46063673904, 0, 0, 0, 0), + + cpg_(811.875582789397, 2099.04089516451, 1627.3, 1603.63660583455, 724.41), + B_(-0.000383641934194752, 0.447249234048222, -469062.208605302, 5.5628080458239e+18, -2.3040162514986e+21), + mu_(-51.964, 3670.6, 5.7331, -5.3495e-29, 10), + mug_(2.6986e-06, 0.498, 1257.7, -19570), + K_(-0.4267, 0.0056903, -8.0065e-06, 1.815e-09, 0, 0), + Kg_(6.977e-05, 1.1243, 844.9, -148850), + sigma_(705.0, 1.0, 0.0, 0.0, 0.0, 0), // set to constant + D_(147.18, 20.1, 60.056, 28) // NN: Same as nHeptane + {} + CH4N2O + ( + const liquid& l, + const NSRDSfunc0& density, + const NSRDSfunc1& vapourPressure, + const NSRDSfunc6& heatOfVapourisation, + const NSRDSfunc0& heatCapacity, + const NSRDSfunc0& enthalpy, + const NSRDSfunc7& idealGasHeatCapacity, + const NSRDSfunc4& secondVirialCoeff, + const NSRDSfunc1& dynamicViscosity, + const NSRDSfunc2& vapourDynamicViscosity, + const NSRDSfunc0& thermalConductivity, + const NSRDSfunc2& vapourThermalConductivity, + const NSRDSfunc6& surfaceTension, + const APIdiffCoefFunc& vapourDiffussivity + ) + : + liquid(l), + rho_(density), + pv_(vapourPressure), + hl_(heatOfVapourisation), + cp_(heatCapacity), + h_(enthalpy), + cpg_(idealGasHeatCapacity), + B_(secondVirialCoeff), + mu_(dynamicViscosity), + mug_(vapourDynamicViscosity), + K_(thermalConductivity), + Kg_(vapourThermalConductivity), + sigma_(surfaceTension), + D_(vapourDiffussivity) + {} + + //- Construct from Istream + CH4N2O(Istream& is) + : + liquid(is), + rho_(is), + pv_(is), + hl_(is), + cp_(is), + h_(is), + cpg_(is), + B_(is), + mu_(is), + mug_(is), + K_(is), + Kg_(is), + sigma_(is), + D_(is) + {} + + + // Member Functions + + //- Liquid density [kg/m^3] + scalar rho(scalar p, scalar T) const + { + return rho_.f(p, T); + } + + //- Vapour pressure [Pa] + scalar pv(scalar p, scalar T) const + { + return pv_.f(p, T); + } + + //- Heat of vapourisation [J/kg] + scalar hl(scalar p, scalar T) const + { + return hl_.f(p, T); + } + + //- Liquid heat capacity [J/(kg K)] + scalar cp(scalar p, scalar T) const + { + return cp_.f(p, T); + } + + //- Liquid Enthalpy [J/(kg)] + scalar h(scalar p, scalar T) const + { + return h_.f(p, T); + } + + //- Ideal gas heat capacity [J/(kg K)] + scalar cpg(scalar p, scalar T) const + { + return cpg_.f(p, T); + } + + //- Second Virial Coefficient [m^3/kg] + scalar B(scalar p, scalar T) const + { + return B_.f(p, T); + } + + //- Liquid viscosity [Pa s] + scalar mu(scalar p, scalar T) const + { + return mu_.f(p, T); + } + + //- Vapour viscosity [Pa s] + scalar mug(scalar p, scalar T) const + { + return mug_.f(p, T); + } + + //- Liquid thermal conductivity [W/(m K)] + scalar K(scalar p, scalar T) const + { + return K_.f(p, T); + } + + //- Vapour thermal conductivity [W/(m K)] + scalar Kg(scalar p, scalar T) const + { + return Kg_.f(p, T); + } + + //- Surface tension [N/m] + scalar sigma(scalar p, scalar T) const + { + return sigma_.f(p, T); + } + + //- Vapour diffussivity [m2/s] + scalar D(scalar p, scalar T) const + { + return D_.f(p, T); + } + + + //- Write the function coefficients + void writeData(Ostream& os) const + { + liquid::writeData(os); os << nl; + rho_.writeData(os); os << nl; + pv_.writeData(os); os << nl; + hl_.writeData(os); os << nl; + cp_.writeData(os); os << nl; + cpg_.writeData(os); os << nl; + B_.writeData(os); os << nl; + mu_.writeData(os); os << nl; + mug_.writeData(os); os << nl; + K_.writeData(os); os << nl; + Kg_.writeData(os); os << nl; + sigma_.writeData(os); os << nl; + D_.writeData(os); os << endl; + } + + + // Ostream Operator + + friend Ostream& operator<<(Ostream& os, const CH4N2O& l) + { + l.writeData(os); + return os; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + diff --git a/src/thermophysicalModels/liquids/Make/files b/src/thermophysicalModels/liquids/Make/files index 7d55ee40b759d37ad4064dc6cb66c51a5b0c5463..e2f27128d520e81ed9e7d4e8b9dee691724f1483 100644 --- a/src/thermophysicalModels/liquids/Make/files +++ b/src/thermophysicalModels/liquids/Make/files @@ -26,5 +26,8 @@ C2H5OH/C2H5OH.C Ar/Ar.C N2/N2.C MB/MB.C +CH4N2O/CH4N2O.C +nC3H8O/nC3H8O.C +iC3H8O/iC3H8O.C LIB = $(FOAM_LIBBIN)/libliquids diff --git a/applications/test/hmm/calcEntry/calcEntry.C b/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.C similarity index 54% rename from applications/test/hmm/calcEntry/calcEntry.C rename to src/thermophysicalModels/liquids/iC3H8O/iC3H8O.C index 8801a5255519333336312a2eea45bef2fcdfcaaa..0020f9f7458440ea23e884ed127457fc7e6eccc1 100644 --- a/applications/test/hmm/calcEntry/calcEntry.C +++ b/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.C @@ -22,67 +22,27 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -\*---------------------------------------------------------------------------*/ +Description -#include "calcEntry.H" -#include "dictionary.H" -#include "IStringStream.H" -#include "OStringStream.H" -#include "addToMemberFunctionSelectionTable.H" +------------------------------------------------------------------------------- +*/ -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +#include "iC3H8O.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -namespace functionEntries -{ - defineTypeNameAndDebug(calcEntry, 0); - - addToMemberFunctionSelectionTable - ( - functionEntry, - calcEntry, - insert, - primitiveEntryIstream - ); - - addToMemberFunctionSelectionTable - ( - functionEntry, - calcEntry, - insert, - dictionaryIstream - ); -} -} +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionEntries::calcEntry::insert -( - const dictionary& parentDict, - primitiveEntry& entry, - Istream& is -) -{ - dictionary args(parentDict, is); - OStringStream resultStream; - resultStream - << (args.lookup("x")[0].number() + args.lookup("y")[0].number()); - entry.read(parentDict, IStringStream(resultStream.str())()); - return true; -} - +defineTypeNameAndDebug(iC3H8O, 0); +addToRunTimeSelectionTable(liquid, iC3H8O,); +addToRunTimeSelectionTable(liquid, iC3H8O, Istream); -bool Foam::functionEntries::calcEntry::insert -( - dictionary& parentDict, - Istream& is -) -{ - return true; -} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace Foam // ************************************************************************* // diff --git a/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.H b/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.H new file mode 100644 index 0000000000000000000000000000000000000000..b665999b46e7208d706f11102f07cc500d4e3ade --- /dev/null +++ b/src/thermophysicalModels/liquids/iC3H8O/iC3H8O.H @@ -0,0 +1,281 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::iC3H8O + +Description + iso-propanol + +SourceFiles + iC3H8O.C + +\*---------------------------------------------------------------------------*/ + +#ifndef iC3H8O_H +#define iC3H8O_H + +#include "liquid.H" +#include "NSRDSfunc0.H" +#include "NSRDSfunc1.H" +#include "NSRDSfunc2.H" +#include "NSRDSfunc3.H" +#include "NSRDSfunc4.H" +#include "NSRDSfunc5.H" +#include "NSRDSfunc6.H" +#include "NSRDSfunc7.H" +#include "NSRDSfunc14.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class iC3H8O Declaration +\*---------------------------------------------------------------------------*/ + +class iC3H8O +: + public liquid +{ + // Private data + + NSRDSfunc5 rho_; + NSRDSfunc1 pv_; + NSRDSfunc6 hl_; + NSRDSfunc0 cp_; + NSRDSfunc0 h_; + NSRDSfunc7 cpg_; + NSRDSfunc4 B_; + NSRDSfunc1 mu_; + NSRDSfunc2 mug_; + NSRDSfunc0 K_; + NSRDSfunc2 Kg_; + NSRDSfunc0 sigma_; + NSRDSfunc1 D_; + +public: + + //- Runtime type information + TypeName("iC3H8O"); + + + // Constructors + + //- Construct null + iC3H8O() + : + liquid(60.096, 508.31, 4.7643e+6, 0.22013, 0.248, 185.28, 3.20e-2, 355.41, 5.5372e-30, 0.6689, 2.3575e+4), + rho_(70.91328, 0.26475, 508.31, 0.243), + pv_(92.935, -8177.1, -10.031, 3.9988e-06, 2), + hl_(508.31, 948149.627263046, 0.087, 0.3007, 0, 0), + cp_(7760.91586794462, -68.3672790202343, 0.241380457933972, -0.000235057241746539, 0, 0), + // NN: enthalpy, h_, is not used in the sprayModel. + // For consistency, the enthalpy is derived from hlat and hl. + // It is, however, convenient to have it available. + h_(-6227786.27583977, 7760.91586794462, -34.1836395101172, 0.0804601526446574, -5.87643104366347e-05, 0), + cpg_(789.73642172524, 3219.8482428115, 1124, 1560.83599574015, 460), + B_(0.000502529286474973, -0.104665867944622, -717185.83599574, 3.3047124600639e+18, -1.43270766773163e+21), + mu_(-8.23, 2282.2, -0.98495, 0, 0), + mug_(1.993e-07, 0.7233, 178, 0), + K_(0.2029, -0.0002278, 0, 0, 0, 0), + Kg_(-80.642, -1.4549, -604.42, 0), + sigma_(0.03818, -3.818e-05, -6.51e-08, 0, 0, 0), + D_(4.75e-10, 1.75, 0.0, 0.0, 0.0) // NN. same as iC3H8O + {} + iC3H8O + ( + const liquid& l, + const NSRDSfunc5& density, + const NSRDSfunc1& vapourPressure, + const NSRDSfunc6& heatOfVapourisation, + const NSRDSfunc0& heatCapacity, + const NSRDSfunc0& enthalpy, + const NSRDSfunc7& idealGasHeatCapacity, + const NSRDSfunc4& secondVirialCoeff, + const NSRDSfunc1& dynamicViscosity, + const NSRDSfunc2& vapourDynamicViscosity, + const NSRDSfunc0& thermalConductivity, + const NSRDSfunc2& vapourThermalConductivity, + const NSRDSfunc0& surfaceTension, + const NSRDSfunc1& vapourDiffussivity + ) + : + liquid(l), + rho_(density), + pv_(vapourPressure), + hl_(heatOfVapourisation), + cp_(heatCapacity), + h_(enthalpy), + cpg_(idealGasHeatCapacity), + B_(secondVirialCoeff), + mu_(dynamicViscosity), + mug_(vapourDynamicViscosity), + K_(thermalConductivity), + Kg_(vapourThermalConductivity), + sigma_(surfaceTension), + D_(vapourDiffussivity) + {} + + //- Construct from Istream + iC3H8O(Istream& is) + : + liquid(is), + rho_(is), + pv_(is), + hl_(is), + cp_(is), + h_(is), + cpg_(is), + B_(is), + mu_(is), + mug_(is), + K_(is), + Kg_(is), + sigma_(is), + D_(is) + {} + + + // Member Functions + + //- Liquid density [kg/m^3] + scalar rho(scalar p, scalar T) const + { + return rho_.f(p, T); + } + + //- Vapour pressure [Pa] + scalar pv(scalar p, scalar T) const + { + return pv_.f(p, T); + } + + //- Heat of vapourisation [J/kg] + scalar hl(scalar p, scalar T) const + { + return hl_.f(p, T); + } + + //- Liquid heat capacity [J/(kg K)] + scalar cp(scalar p, scalar T) const + { + return cp_.f(p, T); + } + + //- Liquid Enthalpy [J/(kg)] + scalar h(scalar p, scalar T) const + { + return h_.f(p, T); + } + + //- Ideal gas heat capacity [J/(kg K)] + scalar cpg(scalar p, scalar T) const + { + return cpg_.f(p, T); + } + + //- Second Virial Coefficient [m^3/kg] + scalar B(scalar p, scalar T) const + { + return B_.f(p, T); + } + + //- Liquid viscosity [Pa s] + scalar mu(scalar p, scalar T) const + { + return mu_.f(p, T); + } + + //- Vapour viscosity [Pa s] + scalar mug(scalar p, scalar T) const + { + return mug_.f(p, T); + } + + //- Liquid thermal conductivity [W/(m K)] + scalar K(scalar p, scalar T) const + { + return K_.f(p, T); + } + + //- Vapour thermal conductivity [W/(m K)] + scalar Kg(scalar p, scalar T) const + { + return Kg_.f(p, T); + } + + //- Surface tension [N/m] + scalar sigma(scalar p, scalar T) const + { + return sigma_.f(p, T); + } + + //- Vapour diffussivity [m2/s] + scalar D(scalar p, scalar T) const + { + return D_.f(p, T); + } + + + //- Write the function coefficients + void writeData(Ostream& os) const + { + liquid::writeData(os); os << nl; + rho_.writeData(os); os << nl; + pv_.writeData(os); os << nl; + hl_.writeData(os); os << nl; + cp_.writeData(os); os << nl; + cpg_.writeData(os); os << nl; + B_.writeData(os); os << nl; + mu_.writeData(os); os << nl; + mug_.writeData(os); os << nl; + K_.writeData(os); os << nl; + Kg_.writeData(os); os << nl; + sigma_.writeData(os); os << nl; + D_.writeData(os); os << endl; + } + + + // Ostream Operator + + friend Ostream& operator<<(Ostream& os, const iC3H8O& l) + { + l.writeData(os); + return os; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + diff --git a/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.C b/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.C new file mode 100644 index 0000000000000000000000000000000000000000..96df4a11cc9c1caaf7703e639c253cfb49bfee6d --- /dev/null +++ b/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.C @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + +------------------------------------------------------------------------------- +*/ + +#include "nC3H8O.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(nC3H8O, 0); +addToRunTimeSelectionTable(liquid, nC3H8O,); +addToRunTimeSelectionTable(liquid, nC3H8O, Istream); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.H b/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.H new file mode 100644 index 0000000000000000000000000000000000000000..2f0079646967b0692fad76730bc7462d25cae16b --- /dev/null +++ b/src/thermophysicalModels/liquids/nC3H8O/nC3H8O.H @@ -0,0 +1,281 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +Class + Foam::nC3H8O + +Description + propanol + +SourceFiles + nC3H8O.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nC3H8O_H +#define nC3H8O_H + +#include "liquid.H" +#include "NSRDSfunc0.H" +#include "NSRDSfunc1.H" +#include "NSRDSfunc2.H" +#include "NSRDSfunc3.H" +#include "NSRDSfunc4.H" +#include "NSRDSfunc5.H" +#include "NSRDSfunc6.H" +#include "NSRDSfunc7.H" +#include "NSRDSfunc14.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class nC3H8O Declaration +\*---------------------------------------------------------------------------*/ + +class nC3H8O +: + public liquid +{ + // Private data + + NSRDSfunc5 rho_; + NSRDSfunc1 pv_; + NSRDSfunc6 hl_; + NSRDSfunc0 cp_; + NSRDSfunc0 h_; + NSRDSfunc7 cpg_; + NSRDSfunc4 B_; + NSRDSfunc1 mu_; + NSRDSfunc2 mug_; + NSRDSfunc0 K_; + NSRDSfunc2 Kg_; + NSRDSfunc0 sigma_; + NSRDSfunc1 D_; + +public: + + //- Runtime type information + TypeName("nC3H8O"); + + + // Constructors + + //- Construct null + nC3H8O() + : + liquid(60.096, 536.71, 5.1696e+6, 0.21853, 0.253, 146.95, 6.5112e-7, 370.35, 5.6039e-30, 0.6279, 2.4557e+4), + rho_(75.300288, 0.272, 536.71, 0.2494), + pv_(77.46, -7960, -7.5235, 3e-07, 2), + hl_(536.71, 1098242.8115016, 0.647, -0.783, 0.613, 0), + cp_(216.320553780618, 18.5203674121406, -0.0751797124600639, 0.000126464323748669, 0, 0), + // NN: enthalpy, h_, is not used in the sprayModel. + // For consistency, the enthalpy is derived from hlat and hl. + // It is, however, convenient to have it available. + h_(-5533091.96851587, 216.320553780618, 9.26018370607029, -0.0250599041533546, 3.16160809371672e-05, 0), + cpg_(961.794462193823, 3467.78487752929, 1542, 2046.72523961661, 649), + B_(0.000933506389776358, -1.09325079872204, -531649.361022364, -2.32627795527157e+17, -3.81888977635783e+20), + mu_(0.571, 1521, -2.0894, 0, 0), + mug_(7.942e-07, 0.5491, 415.8, 0), + K_(0.204, -0.000169, 0, 0, 0, 0), + Kg_(-613.84, 0.7927, -1157400000, 0), + sigma_(0.04533, -6.88e-05, -1.6e-08, 0, 0, 0), + D_(4.75e-10, 1.75, 0.0, 0.0, 0.0) // NN. same as iC3H8O + {} + nC3H8O + ( + const liquid& l, + const NSRDSfunc5& density, + const NSRDSfunc1& vapourPressure, + const NSRDSfunc6& heatOfVapourisation, + const NSRDSfunc0& heatCapacity, + const NSRDSfunc0& enthalpy, + const NSRDSfunc7& idealGasHeatCapacity, + const NSRDSfunc4& secondVirialCoeff, + const NSRDSfunc1& dynamicViscosity, + const NSRDSfunc2& vapourDynamicViscosity, + const NSRDSfunc0& thermalConductivity, + const NSRDSfunc2& vapourThermalConductivity, + const NSRDSfunc0& surfaceTension, + const NSRDSfunc1& vapourDiffussivity + ) + : + liquid(l), + rho_(density), + pv_(vapourPressure), + hl_(heatOfVapourisation), + cp_(heatCapacity), + h_(enthalpy), + cpg_(idealGasHeatCapacity), + B_(secondVirialCoeff), + mu_(dynamicViscosity), + mug_(vapourDynamicViscosity), + K_(thermalConductivity), + Kg_(vapourThermalConductivity), + sigma_(surfaceTension), + D_(vapourDiffussivity) + {} + + //- Construct from Istream + nC3H8O(Istream& is) + : + liquid(is), + rho_(is), + pv_(is), + hl_(is), + cp_(is), + h_(is), + cpg_(is), + B_(is), + mu_(is), + mug_(is), + K_(is), + Kg_(is), + sigma_(is), + D_(is) + {} + + + // Member Functions + + //- Liquid density [kg/m^3] + scalar rho(scalar p, scalar T) const + { + return rho_.f(p, T); + } + + //- Vapour pressure [Pa] + scalar pv(scalar p, scalar T) const + { + return pv_.f(p, T); + } + + //- Heat of vapourisation [J/kg] + scalar hl(scalar p, scalar T) const + { + return hl_.f(p, T); + } + + //- Liquid heat capacity [J/(kg K)] + scalar cp(scalar p, scalar T) const + { + return cp_.f(p, T); + } + + //- Liquid Enthalpy [J/(kg)] + scalar h(scalar p, scalar T) const + { + return h_.f(p, T); + } + + //- Ideal gas heat capacity [J/(kg K)] + scalar cpg(scalar p, scalar T) const + { + return cpg_.f(p, T); + } + + //- Second Virial Coefficient [m^3/kg] + scalar B(scalar p, scalar T) const + { + return B_.f(p, T); + } + + //- Liquid viscosity [Pa s] + scalar mu(scalar p, scalar T) const + { + return mu_.f(p, T); + } + + //- Vapour viscosity [Pa s] + scalar mug(scalar p, scalar T) const + { + return mug_.f(p, T); + } + + //- Liquid thermal conductivity [W/(m K)] + scalar K(scalar p, scalar T) const + { + return K_.f(p, T); + } + + //- Vapour thermal conductivity [W/(m K)] + scalar Kg(scalar p, scalar T) const + { + return Kg_.f(p, T); + } + + //- Surface tension [N/m] + scalar sigma(scalar p, scalar T) const + { + return sigma_.f(p, T); + } + + //- Vapour diffussivity [m2/s] + scalar D(scalar p, scalar T) const + { + return D_.f(p, T); + } + + + //- Write the function coefficients + void writeData(Ostream& os) const + { + liquid::writeData(os); os << nl; + rho_.writeData(os); os << nl; + pv_.writeData(os); os << nl; + hl_.writeData(os); os << nl; + cp_.writeData(os); os << nl; + cpg_.writeData(os); os << nl; + B_.writeData(os); os << nl; + mu_.writeData(os); os << nl; + mug_.writeData(os); os << nl; + K_.writeData(os); os << nl; + Kg_.writeData(os); os << nl; + sigma_.writeData(os); os << nl; + D_.writeData(os); os << endl; + } + + + // Ostream Operator + + friend Ostream& operator<<(Ostream& os, const nC3H8O& l) + { + l.writeData(os); + return os; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + diff --git a/tutorials/dieselFoam/aachenBomb/constant/injectorProperties b/tutorials/dieselFoam/aachenBomb/constant/injectorProperties index 66e47bddebc7818798a167b1153d09d63a31acd0..81b8b07bc6d0135f84a4c63b2b0b78dbc917dd7d 100644 --- a/tutorials/dieselFoam/aachenBomb/constant/injectorProperties +++ b/tutorials/dieselFoam/aachenBomb/constant/injectorProperties @@ -25,7 +25,6 @@ FoamFile diameter 0.00019; Cd 0.9; mass 6e-06; - temperature 320; nParcels 5000; X @@ -67,6 +66,14 @@ FoamFile (0.00120833 5.1737) (0.00125 3.9213) ); + + temperatureProfile + ( + (0.0 320.0) + (0.00125 320.0) + ); + + } commonRailInjectorProps diff --git a/tutorials/dieselFoam/aachenBomb/constant/polyMesh/boundary b/tutorials/dieselFoam/aachenBomb/constant/polyMesh/boundary deleted file mode 100644 index 776ce2125360feefef39ba39f7b92e300f44f131..0000000000000000000000000000000000000000 --- a/tutorials/dieselFoam/aachenBomb/constant/polyMesh/boundary +++ /dev/null @@ -1,27 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | -| \\ / A nd | Web: http://www.OpenFOAM.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format binary; - class polyBoundaryMesh; - object boundary; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -1 -( - walls - { - type wall; - nFaces 19762; - startFace 494419; - } -) - -// ************************************************************************* // diff --git a/wmake/rules/General/version b/wmake/rules/General/version index 805eb585613340ca8d7ffd986ce4078bb73be4c3..0d74179f8cc78c80b4c40ad0155622558d887d9e 100644 --- a/wmake/rules/General/version +++ b/wmake/rules/General/version @@ -1,6 +1,11 @@ .SUFFIXES: .Cver -Cvertoo = sed s/WM_PROJECT_VERSION/\"$(WM_PROJECT_VERSION)\"/ $$SOURCE > $*.C ; $(CC) $(c++FLAGS) -c $*.C -o $@ +# +# update version string +# +Cvertoo = \ + sed s/WM_PROJECT_VERSION/\"$(shell wmakePrintBuild)\"/ $$SOURCE > $*.C; \ + $(CC) $(c++FLAGS) -c $*.C -o $@ .Cver.dep: $(MAKE_DEP) diff --git a/bin/tools/buildParaView3.2.1 b/wmake/wmakePrintBuild similarity index 54% rename from bin/tools/buildParaView3.2.1 rename to wmake/wmakePrintBuild index 904682581df68d664661819d29b88fe4a24bfc7d..61e9b80790f40146ccf2a67fb795134d5a58901b 100755 --- a/bin/tools/buildParaView3.2.1 +++ b/wmake/wmakePrintBuild @@ -5,7 +5,7 @@ # \\ / O peration | # \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. # \\/ M anipulation | -#------------------------------------------------------------------------------ +#------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. # @@ -24,52 +24,72 @@ # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script -# buildParaView3.2.1 +# wmakePrintBuild # # Description -# Build and install ParaView -# - run from folder above ParaView source folder or place the -# ParaView source under $WM_PROJECT_INST_DIR +# Print the version used when building the project. # #------------------------------------------------------------------------------ -. $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions +Script=${0##*/} -PARAVIEW_SRC="ParaView3.2.1" -PARAVIEW_MAJOR_VERSION="3.2" +usage() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE +usage: $Script -# User options: -# ~~~~~~~~~~~~~ +Print the version used when building the project, in this order of precedence: + * git description + * \$WM_PROJECT_DIR/.build + * \$WM_PROJECT_VERSION -WITH_MPI=ON -MPI_MAX_PROCS=32 -WITH_PYTHON=ON -PYTHON_LIBRARY="" -WITH__MESA=OFF +USAGE + exit 1 +} +#------------------------------------------------------------------------------ + +# provide immediate help +if [ "$1" = "-h" -o "$1" = "-help" ] +then + usage +fi -# -# No further editing below this line #------------------------------------------------------------------------------ -# shortcut for repeated builds - use with caution -if [ "$1" = "-fast" ] +# +# persistent build tag +# +build="$WM_PROJECT_DIR/.build" +previous=$(tail -1 $build 2>/dev/null) + +# +# building under git +# note: could also use --abbrev=32 for maximum resolution +# +version=$(git describe --always --tags 2>/dev/null) +if [ $? -eq 0 ] then - CMAKE_SKIP=YES -elif [ "$#" -gt 0 ] + # update persistent build tag (this could be made optional or removed) + if [ "$version" != "$previous" ] + then + if [ -w "$build" -a \( -w "$WM_PROJECT_DIR" -o ! -e "$build" \) ] + then + echo $version >| "$build" 2>/dev/null + fi + fi + + echo $version + +elif [ -n "$previous" ] then - echo "$0: only supports a -fast option" - exit 1 -fi -# Set configure options -#~~~~~~~~~~~~~~~~~~~~~~ -addVerbosity # set cmake verbosity -addMpiSupport # set MPI-specific options -addPythonSupport # set Python-specific options -addMesaSupport # set MESA-specific options + # use previous build tag + echo $previous -buildParaView -installParaView +else -echo "done" + # fallback to WM_PROJECT_VERSION + echo ${WM_PROJECT_VERSION:-unknown} + +fi #------------------------------------------------------------------------------