diff --git a/applications/solvers/compressible/rhoCentralFoam/Allwmake b/applications/solvers/compressible/rhoCentralFoam/Allwmake index 69a108d537..698558da0b 100755 --- a/applications/solvers/compressible/rhoCentralFoam/Allwmake +++ b/applications/solvers/compressible/rhoCentralFoam/Allwmake @@ -1,5 +1,8 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x wmake libso BCs wmake +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C index a1347365f5..101c41a353 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C @@ -77,13 +77,13 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField : mixedFvPatchScalarField(p, iF), accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))), - Twall_("Twall", dict, p.size()) + Twall_("Twall", dict, p.size()), + gamma_(dict.lookupOrDefault("gamma", 1.4)) { if ( mag(accommodationCoeff_) < SMALL - || - mag(accommodationCoeff_) > 2.0 + || mag(accommodationCoeff_) > 2.0 ) { FatalIOErrorIn @@ -96,8 +96,8 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField " const dictionary&" ")", dict - ) << "unphysical accommodationCoeff_ specified" - << "(0 < accommodationCoeff_ <= 1)" << endl + ) << "unphysical accommodationCoeff specified" + << "(0 < accommodationCoeff <= 1)" << endl << exit(FatalError); } @@ -113,15 +113,6 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField fvPatchField::operator=(patchInternalField()); } - if (dict.found("gamma")) - { - gamma_ = readScalar(dict.lookup("gamma")); - } - else - { - gamma_ = 1.4; - } - refValue() = *this; refGrad() = 0.0; valueFraction() = 0.0; diff --git a/applications/solvers/compressible/rhopSonicFoam/Allwmake b/applications/solvers/compressible/rhopSonicFoam/Allwmake index cccfd63757..698558da0b 100755 --- a/applications/solvers/compressible/rhopSonicFoam/Allwmake +++ b/applications/solvers/compressible/rhopSonicFoam/Allwmake @@ -1,5 +1,8 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso BCs wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/multiphase/lesInterFoam/lesInterFoam.C b/applications/solvers/multiphase/lesInterFoam/lesInterFoam.C index 264eb28dea..8d109f03b3 100644 --- a/applications/solvers/multiphase/lesInterFoam/lesInterFoam.C +++ b/applications/solvers/multiphase/lesInterFoam/lesInterFoam.C @@ -85,6 +85,8 @@ int main(int argc, char *argv[]) #include "continuityErrs.H" + p = pd + rho*gh; + runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" diff --git a/applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake b/applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake index 8314bfa069..29294d166a 100755 --- a/applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake +++ b/applications/solvers/multiphase/twoPhaseEulerFoam/Allwmake @@ -1,7 +1,10 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso phaseModel wmake libso interfacialModels wmake libso kineticTheoryModels wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C index 61a2f4d854..f4336bce92 100644 --- a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C +++ b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C @@ -184,10 +184,6 @@ int main(int argc, char *argv[]) << endl; // Transfer DynamicLists to straight ones. - labelList cutEdges; - cutEdges.transfer(allCutEdges); - allCutEdges.clear(); - scalarField cutEdgeWeights; cutEdgeWeights.transfer(allCutEdgeWeights); allCutEdgeWeights.clear(); @@ -199,7 +195,7 @@ int main(int argc, char *argv[]) mesh, cutCells.toc(), // cells candidate for cutting labelList(0), // cut vertices - cutEdges, // cut edges + allCutEdges, // cut edges cutEdgeWeights // weight on cut edges ); diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake index 2db40f48ad..2734e41562 100755 --- a/applications/utilities/mesh/conversion/Optional/Allwmake +++ b/applications/utilities/mesh/conversion/Optional/Allwmake @@ -2,7 +2,6 @@ # # Build optional components (eg, may depend on third-party libraries) # ----------------------------------------------------------------------------- - cd ${0%/*} || exit 1 # run from this directory set -x @@ -18,4 +17,4 @@ then wmake ccm26ToFoam fi -# end +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/extrudeMesh/Allwmake b/applications/utilities/mesh/generation/extrudeMesh/Allwmake index 876125ce82..871cad2b68 100755 --- a/applications/utilities/mesh/generation/extrudeMesh/Allwmake +++ b/applications/utilities/mesh/generation/extrudeMesh/Allwmake @@ -1,6 +1,8 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x wmake libso extrudeModel wmake +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 4737f38e53..edcfbf2aee 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -433,7 +433,7 @@ int main(int argc, char *argv[]) Info<< "Finished meshing in = " << runTime.elapsedCpuTime() << " s." << endl; - Pout<< "End\n" << endl; + Info<< "End\n" << endl; return(0); } diff --git a/applications/utilities/mesh/manipulation/setSet/Allwmake b/applications/utilities/mesh/manipulation/setSet/Allwmake index 35e3af7c1b..e10d037cbc 100755 --- a/applications/utilities/mesh/manipulation/setSet/Allwmake +++ b/applications/utilities/mesh/manipulation/setSet/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory READLINE=0 if [ -f /usr/include/readline/readline.h ]; then @@ -9,3 +10,5 @@ if [ -f /usr/include/readline/readline.h ]; then fi export READLINE wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposeMesh.C b/applications/utilities/parallelProcessing/decomposePar/decomposeMesh.C index 0d81b1aedd..55f5c96579 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposeMesh.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposeMesh.C @@ -35,11 +35,8 @@ Description #include "IOstreams.H" #include "SLPtrList.H" #include "boolList.H" -#include "cellList.H" #include "primitiveMesh.H" -#include "cyclicFvPatch.H" -#include "fvPatchList.H" -#include "DynamicList.H" +#include "cyclicPolyPatch.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C index bee2d17b25..dd107c2f2f 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C @@ -33,7 +33,7 @@ License #include "OSspecific.H" #include "Map.H" #include "globalMeshData.H" - +#include "DynamicList.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/foamToFieldview9.C b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/foamToFieldview9.C index 3030a30316..7cf137cd0e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/foamToFieldview9.C +++ b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/foamToFieldview9.C @@ -45,7 +45,6 @@ Description #include "IOobjectList.H" #include "boolList.H" #include "stringList.H" -#include "DynamicList.H" #include "cellModeller.H" #include "floatScalar.H" diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C index bf1fb3b775..1ac0d8b729 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/internalWriter.C @@ -27,9 +27,6 @@ License #include "internalWriter.H" #include "writeFuns.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from components diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C index bbf24b1b17..ea7da50a40 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.C @@ -29,9 +29,6 @@ License #include "Cloud.H" #include "passiveParticle.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from components diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C index 62b8661810..6ad993e0aa 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePatchGeom.C @@ -78,6 +78,7 @@ void writePatchGeom writeFuns::write(pStream, binary, vertLabels); } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C index ea7dbf4301..9e495e073d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C @@ -103,6 +103,7 @@ void writePointSet writeFuns::write(pStream, binary, pointIDs); } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake index a7e703b8c0..c7a80fc7fb 100755 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake @@ -17,3 +17,5 @@ then ;; esac fi + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake index ea67e28d5b..b1106aa608 100755 --- a/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] @@ -16,3 +17,5 @@ then ;; esac fi + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/ensightFoamReader/Allwmake index aca3e014c9..f29cdda208 100755 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/Allwmake +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/Allwmake @@ -1,2 +1,6 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + wmake libso + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C index 4b7a09acbf..3c0e18a9cf 100644 --- a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C +++ b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) } // Give patch area - Info<< " Patch area = " << sum(mesh.Sf()) << endl; + Info<< " Patch area = " << sum(mesh.Sf().boundaryField()[patchi]) << endl; if (fieldHeader.headerClassName() == "volScalarField") { diff --git a/bin/mpirunDebug b/bin/mpirunDebug index eec1513439..013a63997f 100755 --- a/bin/mpirunDebug +++ b/bin/mpirunDebug @@ -76,9 +76,9 @@ echo "run $args" > $HOME/gdbCommands echo "where" >> $HOME/gdbCommands echo "Constructed gdb initialization file $HOME/gdbCommands" -$ECHO "Choose running method: 1)gdb+xterm 2)gdb 3)log 4)xterm+valgrind: \c" +$ECHO "Choose running method: 1)gdb+xterm 2)gdb 3)log 4)log+xterm 5)xterm+valgrind: \c" read method -if [ "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 ]; then +if [ "$method" -ne 1 -a "$method" -ne 2 -a "$method" -ne 3 -a "$method" -ne 4 -a "$method" -ne 5 ]; then printUsage exit 1 fi @@ -152,6 +152,9 @@ do echo "$sourceFoam; cd $PWD; $exec $args >& $procLog" >> $procCmdFile echo "${node}$procCmdFile" >> $HOME/mpirun.schema elif [ "$method" -eq 4 ]; then + echo "$sourceFoam; cd $PWD; $exec $args 2>&1 | tee $procLog; read dummy" >> $procCmdFile + echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $HOME/mpirun.schema + elif [ "$method" -eq 5 ]; then echo "$sourceFoam; cd $PWD; valgrind $exec $args; read dummy" >> $procCmdFile echo "${node}xterm -font fixed -title 'processor'$proc $geom -e $procCmdFile" >> $HOME/mpirun.schema fi diff --git a/doc/Doxygen/Allwmake b/doc/Doxygen/Allwmake index 7f9ccb0522..dab44579b8 100755 --- a/doc/Doxygen/Allwmake +++ b/doc/Doxygen/Allwmake @@ -1,4 +1,5 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory set -x umask 22 diff --git a/etc/controlDict b/etc/controlDict index 2cf2ce334a..9651981ac9 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -808,7 +808,7 @@ OptimisationSwitches { fileModificationSkew 10; commsType nonBlocking; //scheduled; //blocking; - floatTransfer 1; + floatTransfer 0; nProcsSimpleSum 0; } diff --git a/etc/settings.csh b/etc/settings.csh index d21268aafb..cfa1927ef2 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -82,7 +82,10 @@ switch ("$WM_COMPILER_INST") case OpenFOAM: switch ("$WM_COMPILER") case Gcc: - setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH + #setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH + setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH + _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.3/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib breaksw case Gcc42: setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH @@ -105,13 +108,8 @@ case OpenFOAM: endsw if ($?WM_COMPILER_BIN) then - set path=($WM_COMPILER_BIN $path) - - if ($?LD_LIBRARY_PATH) then - setenv LD_LIBRARY_PATH ${WM_COMPILER_LIB}:${LD_LIBRARY_PATH} - else - setenv LD_LIBRARY_PATH ${WM_COMPILER_LIB} - endif + _foamAddPath $WM_COMPILER_BIN + _foamAddLib $WM_COMPILER_LIB endif unset WM_COMPILER_BIN diff --git a/etc/settings.sh b/etc/settings.sh index 612719e292..743d8e1fc0 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -99,7 +99,10 @@ case "$WM_COMPILER_INST" in OpenFOAM) case "$WM_COMPILER" in Gcc) - export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH + #export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH + export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH + _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.3/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib ;; Gcc42) export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH @@ -123,8 +126,8 @@ OpenFOAM) esac if [ -d "$WM_COMPILER_BIN" ]; then - export PATH=$WM_COMPILER_BIN:$PATH - export LD_LIBRARY_PATH=$WM_COMPILER_LIB:$LD_LIBRARY_PATH + _foamAddPath $WM_COMPILER_BIN + _foamAddLib $WM_COMPILER_LIB fi unset WM_COMPILER_BIN WM_COMPILER_LIB diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C index 8297002b82..24d1edea53 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.C @@ -33,7 +33,7 @@ template Foam::DynamicList::DynamicList(Istream& is) : List(is), - nextFree_(List::size()) + allocSize_(List::size()) {} @@ -44,9 +44,6 @@ Foam::Ostream& Foam::operator<< const Foam::DynamicList& DL ) { - const_cast&>(DL) - .setSize(DL.nextFree_); - os << static_cast&>(DL); return os; } @@ -60,7 +57,7 @@ Foam::Istream& Foam::operator>> ) { is >> static_cast&>(DL); - DL.nextFree_ = DL.List::size(); + DL.allocSize_ = DL.List::size(); return is; } diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index a98be44fef..c913892c26 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -26,7 +26,7 @@ Class Foam::DynamicList Description - A 1D vector of objects of type \ which resizes itself as necessary to + A 1D vector of objects of type \ that resizes itself as necessary to accept the new objects. Internal storage is a compact array and the list can be shrunk to compact @@ -81,24 +81,29 @@ class DynamicList { // Private data - //- Number of next free element - label nextFree_; + //- Allocated size for underlying List. + label allocSize_; public: + // Related types + + //- Declare friendship with the List class + friend class List; + // Constructors //- Construct null inline DynamicList(); - //- Construct given size + //- Construct given size. explicit inline DynamicList(const label); - //- Construct from UList. nextFree_ set to size(). + //- Construct from UList. Size set to UList size. explicit inline DynamicList(const UList&); - //- Construct from Istream. nextFree_ set to size(). + //- Construct from Istream. Size set to size of read list. explicit DynamicList(Istream&); @@ -106,22 +111,24 @@ public: // Access - //- Size of the active part of the list. - // Direct over-ride of list size member function - inline label size() const; + //- Size of the underlying storage. + inline label allocSize() const; // Edit //- Reset size of List. - void setSize(const label); + inline void setSize(const label); //- Reset size of List and value for new elements. - void setSize(const label, const T&); + inline void setSize(const label, const T&); - //- Clear the list, i.e. set next free to zero. + //- Clear the list, i.e. set the size to zero. // Allocated size does not change - void clear(); + inline void clear(); + + //- Clear the list and delete storage. + inline void clearStorage(); //- Shrink the List to the number of elements used inline DynamicList& shrink(); @@ -129,12 +136,12 @@ public: //- Transfer the contents of the argument List into this List // and annull the argument list. Is same as List::transfer except // checks that you're not changing the underlying list to something - // smaller than nextFree_. - void transfer(List&); + // smaller than allocSize_. + inline void transfer(List&); //- Transfer the contents of the argument DynamicList into this // DynamicList and annull the argument list. - void transfer(DynamicList&); + inline void transfer(DynamicList&); // Member Operators @@ -142,7 +149,7 @@ public: //- Append an element at the end of the list inline void append(const T& e); - //- Return and remove the top element + //- Remove and return the top element inline T remove(); //- Return non-const access to an element, @@ -152,9 +159,15 @@ public: //- Assignment of all entries to the given value inline void operator=(const T&); - //- Assignment to List + //- Assignment from List inline void operator=(const List&); + //- Assignment from DynamicList + inline void operator= + ( + const DynamicList& + ); + // IOstream operators diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index 8d451ccd7a..d383480035 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -31,8 +31,10 @@ template inline Foam::DynamicList::DynamicList() : List(SizeInc), - nextFree_(0) -{} + allocSize_(SizeInc) +{ + List::size() = 0; +} //- Construct given size @@ -43,8 +45,10 @@ inline Foam::DynamicList::DynamicList ) : List(s), - nextFree_(0) -{} + allocSize_(s) +{ + List::size() = 0; +} //- Construct given size @@ -55,17 +59,17 @@ inline Foam::DynamicList::DynamicList ) : List(s), - nextFree_(s.size()) + allocSize_(s.size()) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline Foam::label Foam::DynamicList::size() +inline Foam::label Foam::DynamicList::allocSize() const { - return nextFree_; + return allocSize_; } @@ -75,13 +79,14 @@ inline void Foam::DynamicList::setSize const label s ) { - if (s < nextFree_) + if (s < List::size()) { - nextFree_ = s; + List::size() = s; } else { - List::setSize(s); + allocSize_ = s; + List::setSize(allocSize_); } } @@ -93,14 +98,14 @@ inline void Foam::DynamicList::setSize const T& t ) { - if (s < nextFree_) + if (s < List::size()) { - nextFree_ = s; + List::size() = s; } else { - List::setSize(s, t); - nextFree_ = s; + allocSize_ = s; + List::setSize(allocSize_, t); } } @@ -108,7 +113,15 @@ inline void Foam::DynamicList::setSize template inline void Foam::DynamicList::clear() { - nextFree_ = 0; + List::size() = 0; +} + + +template +inline void Foam::DynamicList::clearStorage() +{ + List::clear(); + allocSize_ = 0; } @@ -116,7 +129,8 @@ template inline Foam::DynamicList& Foam::DynamicList::shrink() { - List::setSize(nextFree_); + allocSize_ = List::size(); + List::setSize(allocSize_); return *this; } @@ -125,20 +139,20 @@ template inline void Foam::DynamicList::transfer(List& l) { - if (l.size() < nextFree_) + if (l.size() < List::size()) { FatalErrorIn ( "void DynamicList::transfer(List&)" ) << "Cannot replace the underlying storage of this DynamicList" - << " of which " << nextFree_ << " elements are used" << nl + << " of which " << List::size() << " elements are used" << nl << "with a List of size " << l.size() << abort(FatalError); } else { + allocSize_ = l.size(); List::transfer(l); // take over storage - l.clear(); // set nextFree of l to 0 } } @@ -150,48 +164,47 @@ Foam::DynamicList::transfer DynamicList& l ) { + allocSize_ = l.allocSize(); List::transfer(l); // take over storage - nextFree_ = l.size(); // take over used size - l.clear(); // set nextFree of l to 0 } template -inline void Foam::DynamicList::append -( - const T& e -) +inline void Foam::DynamicList::append(const T& e) { - nextFree_++; + // Work on copy free index since gets overwritten by setSize + label nextFree = List::size(); - if (nextFree_ > List::size()) + nextFree++; + + if (nextFree > allocSize_) { - List::setSize + allocSize_ = max ( - max - ( - nextFree_, - label(SizeMult*List::size()/SizeDiv + SizeInc) - ) + nextFree, + label(SizeMult*allocSize_/SizeDiv + SizeInc) ); + List::setSize(allocSize_); } - this->operator[](nextFree_ - 1) = e; + this->operator[](nextFree - 1) = e; + + List::size() = nextFree; } template inline T Foam::DynamicList::remove() { - if (nextFree_ == 0) + if (List::size() == 0) { FatalErrorIn ( - "void Foam::DynamicList::remove()" + "Foam::DynamicList::remove()" ) << "List is empty" << abort(FatalError); } - return List::operator[](--nextFree_); + return List::operator[](--List::size()); } @@ -203,20 +216,22 @@ inline T& Foam::DynamicList::operator() const label i ) { - nextFree_ = max(nextFree_, i + 1); + label nextFree = List::size(); - if (nextFree_ > List::size()) + nextFree = max(nextFree, i + 1); + + if (nextFree > allocSize_) { - List::setSize + allocSize_ = max ( - max - ( - nextFree_, - label(SizeMult*List::size()/SizeDiv + SizeInc) - ) + nextFree, + label(SizeMult*allocSize_/SizeDiv + SizeInc) ); + List::setSize(allocSize_); } + List::size() = nextFree; + return this->operator[](i); } @@ -228,7 +243,7 @@ inline void Foam::DynamicList::operator= ) { List::operator=(t); - nextFree_ = List::size(); + allocSize_ = List::size(); } @@ -239,7 +254,21 @@ inline void Foam::DynamicList::operator= ) { List::operator=(l); - nextFree_ = l.size(); + allocSize_ = List::size(); +} + + +template +inline void Foam::DynamicList::operator= +( + const DynamicList& l +) +{ + List::operator=(l); + // allocSize_ = l.allocSize(); // wrong + allocSize_ = List::size(); + // ^^^^ with this change, we could just use + // DynamicList::operator=(const List&) instead } diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 249d1fcf2b..a599490781 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -38,14 +38,11 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // // Construct with length specified template -List::List(const label s) +Foam::List::List(const label s) : UList(NULL, s) { @@ -69,7 +66,7 @@ List::List(const label s) // Construct with length and single value specified template -List::List(const label s, const T& a) +Foam::List::List(const label s, const T& a) : UList(NULL, s) { @@ -98,7 +95,7 @@ List::List(const label s, const T& a) // Construct as copy template -List::List(const List& a) +Foam::List::List(const List& a) : UList(NULL, a.size_) { @@ -130,7 +127,7 @@ List::List(const List& a) // Construct as copy or re-use as specified. template -List::List(List& a, bool reUse) +Foam::List::List(List& a, bool reUse) : UList(NULL, a.size_) { @@ -166,10 +163,10 @@ List::List(List& a, bool reUse) } -// Construct given size and start and end iterators. +// Construct given start and end iterators. template template -List::List(InputIterator first, InputIterator last) +Foam::List::List(InputIterator first, InputIterator last) { label s = 0; for @@ -200,8 +197,8 @@ List::List(InputIterator first, InputIterator last) // Construct as copy of FixedList template -template