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/incompressible/boundaryFoam/boundaryFoam.C b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C index b9b46a3cc9..19933091a0 100644 --- a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C +++ b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C @@ -26,8 +26,8 @@ Application boundaryFoam Description - Steady-state solver for 1D turbulent flow, typically to generate boundary - layer conditions at an inlet, for use in a simulation. + Steady-state solver for 1D turbulent flow, typically to generate boundary + layer conditions at an inlet, for use in a simulation. Boundary layer code to calculate the U, k and epsilon distributions. Used to create inlet boundary conditions for experimental comparisons @@ -82,11 +82,14 @@ int main(int argc, char *argv[]) U += (Ubar - UbarStar); gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V()); + label id = y.size() - 1; + scalar wallShearStress = - flowDirection & turbulence->R()()[0] & wallNormal; + flowDirection & turbulence->R()()[id] & wallNormal; scalar yplusWall - = ::sqrt(mag(wallShearStress))*y[0]/laminarTransport.nu()()[0]; +// = ::sqrt(mag(wallShearStress))*y[id]/laminarTransport.nu()()[id]; + = ::sqrt(mag(wallShearStress))*y[id]/turbulence->nuEff()()[id]; Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())<< tab << "pressure gradient = " << (flowDirection & gradP.value()) << tab diff --git a/applications/solvers/incompressible/simpleFoam/Make/options b/applications/solvers/incompressible/simpleFoam/Make/options index e1ffa28773..8a31f7e5ab 100644 --- a/applications/solvers/incompressible/simpleFoam/Make/options +++ b/applications/solvers/incompressible/simpleFoam/Make/options @@ -7,5 +7,4 @@ EXE_LIBS = \ -lincompressibleRASModels \ -lincompressibleTransportModels \ -lfiniteVolume \ - -lmeshTools \ - /* $(LIB_WM_OPTIONS_DIR)/libfbsdmalloc.o */ + -lmeshTools 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/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/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/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/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files new file mode 100644 index 0000000000..58f5dd3974 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files @@ -0,0 +1,3 @@ +applyWallFunctionBounaryConditions.C + +EXE = $(FOAM_APPBIN)/applyWallFunctionBounaryConditions diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options new file mode 100644 index 0000000000..89e52b6d52 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options @@ -0,0 +1,6 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume + diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C new file mode 100644 index 0000000000..e571cc4373 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C @@ -0,0 +1,279 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 + applyWallFunctionBounaryConditions + +Description + Updates OpenFOAM RAS cases to use the new wall function framework + Attempts to determine whether case is compressible or incompressible, or + can be supplied with -compressible command line argument + +\*---------------------------------------------------------------------------*/ + + +#include "argList.H" +#include "fvMesh.H" +#include "Time.H" +#include "volFields.H" +#include "surfaceFields.H" + +#include "wallPolyPatch.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +bool caseIsCompressible(const fvMesh& mesh) +{ + // Attempt flux field + IOobject phiHeader + ( + "phi", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (phiHeader.headerOk()) + { + surfaceScalarField phi(phiHeader, mesh); + if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + return true; + } + } + + // Attempt density field + IOobject rhoHeader + ( + "rho", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (rhoHeader.headerOk()) + { + volScalarField rho(rhoHeader, mesh); + if (rho.dimensions() == dimDensity) + { + return true; + } + } + + // Attempt pressure field + IOobject pHeader + ( + "p", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (pHeader.headerOk()) + { + volScalarField p(pHeader, mesh); + if (p.dimensions() == dimMass/sqr(dimTime)/dimLength) + { + return true; + } + } + + // Attempt hydrostatic pressure field + IOobject pdHeader + ( + "pd", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (pdHeader.headerOk()) + { + volScalarField pd(pdHeader, mesh); + if (pd.dimensions() == dimMass/sqr(dimTime)/dimLength) + { + return true; + } + } + + // If none of the above are true, assume that the case is incompressible + return false; +} + + +void createVolScalarField +( + const fvMesh& mesh, + const word& fieldName, + const dimensionSet& dims +) +{ + IOobject fieldHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!fieldHeader.headerOk()) + { + Info<< "Creating field " << fieldName << nl << endl; + + volScalarField field + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dims, 0.0) + ); + + field.write(); + } +} + + +void replaceBoundaryType +( + const fvMesh& mesh, + const word& fieldName, + const word& boundaryType, + const string& boundaryValue +) +{ + IOobject header + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!header.headerOk()) + { + return; + } + + Info<< "Updating boundary types for field " << header.name() << endl; + + const word oldTypeName = IOdictionary::typeName; + const_cast(IOdictionary::typeName) = word::null; + + IOdictionary dict(header); + + const_cast(IOdictionary::typeName) = oldTypeName; + const_cast(dict.type()) = dict.headerClassName(); + + // Make a backup of the old field + word backupName(dict.name() + ".old"); + Info<< " copying " << dict.name() << " to " + << backupName << endl; + IOdictionary dictOld = dict; + dictOld.rename(backupName); + dictOld.regIOobject::write(); + + // Loop through boundary patches and update + const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); + dictionary& boundaryDict = dict.subDict("boundaryField"); + forAll(bMesh, patchI) + { + if (isType(bMesh[patchI])) + { + word patchName = bMesh[patchI].name(); + dictionary& oldPatch = boundaryDict.subDict(patchName); + + dictionary newPatch(dictionary::null); + newPatch.add("type", boundaryType); + newPatch.add("value", ("uniform " + boundaryValue).c_str()); + + oldPatch = newPatch; + } + } + + Info<< " writing updated " << dict.name() << nl << endl; + dict.regIOobject::write(); +} + + +int main(int argc, char *argv[]) +{ + +# include "addTimeOptions.H" + argList::validOptions.insert("compressible", ""); + +# include "setRootCase.H" +# include "createTime.H" +# include "createMesh.H" + + bool compressible = args.options().found("compressible"); + + Info<< "Updating turbulence fields to operate using new run time " + << "selectable" << nl << "wall functions" + << nl << endl; + + if (compressible || caseIsCompressible(mesh)) + { + Info<< "Case treated as compressible" << nl << endl; + createVolScalarField + ( + mesh, + "mut", + dimArea/dimTime*dimDensity + ); + replaceBoundaryType(mesh, "mut", "mutWallFunction", "0"); + } + else + { + Info<< "Case treated as incompressible" << nl << endl; + createVolScalarField(mesh, "nut", dimArea/dimTime); + replaceBoundaryType(mesh, "nut", "nutWallFunction", "0"); + } + + replaceBoundaryType(mesh, "epsilon", "epsilonWallFunction", "0"); + replaceBoundaryType(mesh, "omega", "omegaWallFunction", "0"); + replaceBoundaryType(mesh, "k", "kQRWallFunction", "0"); + replaceBoundaryType(mesh, "q", "kQRWallFunction", "0"); + replaceBoundaryType(mesh, "R", "kQRWallFunction", "(0 0 0 0 0 0)"); + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // 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/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.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index 684d393745..95cb34932d 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 @@ -136,7 +136,7 @@ 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_. + // smaller than allocSize_. inline void transfer(List&); //- Transfer the contents of the argument DynamicList into this @@ -149,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, @@ -159,15 +159,9 @@ public: //- Assignment of all entries to the given value inline void operator=(const T&); - //- Assignment from List + //- Assignment from List. Also handles assignment from DynamicList. 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 d9a14a1111..da6bd13067 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -85,8 +85,10 @@ inline void Foam::DynamicList::setSize } else { + label nextFree = List::size(); allocSize_ = s; List::setSize(allocSize_); + List::size() = nextFree; } } @@ -104,8 +106,10 @@ inline void Foam::DynamicList::setSize } else { + label nextFree = List::size(); allocSize_ = s; List::setSize(allocSize_, t); + List::size() = nextFree; } } @@ -120,7 +124,6 @@ inline void Foam::DynamicList::clear() template inline void Foam::DynamicList::clearStorage() { - List::size() = allocSize_; // make List consistent List::clear(); allocSize_ = 0; } @@ -166,8 +169,7 @@ Foam::DynamicList::transfer ) { allocSize_ = l.allocSize(); - List::transfer(l); // take over storage - l.allocSize_ = 0; + List::transfer(l); // take over storage. Null l. } @@ -189,9 +191,9 @@ inline void Foam::DynamicList::append(const T& e) List::setSize(allocSize_); } - this->operator[](nextFree - 1) = e; - List::size() = nextFree; + + this->operator[](nextFree - 1) = e; } @@ -202,11 +204,17 @@ inline T Foam::DynamicList::remove() { FatalErrorIn ( - "void Foam::DynamicList::remove()" + "Foam::DynamicList::remove()" ) << "List is empty" << abort(FatalError); } - return List::operator[](--List::size()); + label nextFree = List::size()-1; + + const T& val = List::operator[](nextFree); + + List::size() = nextFree; + + return val; } @@ -224,7 +232,7 @@ inline T& Foam::DynamicList::operator() if (nextFree > allocSize_) { - allocSize_ = max + allocSize_ = max ( nextFree, label(SizeMult*allocSize_/SizeDiv + SizeInc) @@ -260,15 +268,4 @@ inline void Foam::DynamicList::operator= } -template -inline void Foam::DynamicList::operator= -( - const DynamicList& l -) -{ - List::operator=(l); - allocSize_ = l.allocSize(); -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 21cc042050..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