Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2009-01-13 12:14:43 +00:00
325 changed files with 1765 additions and 1391 deletions

View File

@ -26,7 +26,7 @@ Application
PDRFoam
Description
Compressible premixed/partially-premixed combustion solver with turbulence
Compressible premixed/partially-premixed combustion solver with turbulence
modelling.
Combusting RANS code using the b-Xi two-equation model.
@ -121,7 +121,8 @@ scalar StCoNum = 0.0;
// Test : disable refinement for some cells
PackedList<1>& protectedCell =
refCast<dynamicRefineFvMesh>(mesh).protectedCell();
if (protectedCell.size() == 0)
if (protectedCell.empty())
{
protectedCell.setSize(mesh.nCells());
protectedCell = 0;
@ -135,7 +136,7 @@ scalar StCoNum = 0.0;
}
}
//volScalarField pIndicator("pIndicator",
//volScalarField pIndicator("pIndicator",
// p*(fvc::laplacian(p))
// / (
// magSqr(fvc::grad(p))

View File

@ -26,7 +26,8 @@ Class
Foam::PDRDragModel
Description
Base-class for sub-grid obstacle drag models.
Base-class for sub-grid obstacle drag models. The available drag model is at
\link basic.H \endlink.
SourceFiles
PDRDragModel.C

View File

@ -70,7 +70,7 @@ Description
\f$ T \f$ is a tensor in the file CT.
The term \f$ G_{R} \f$ is treated explicitly in the \f$ \kappa-\epsilon
\f$ Eqs in the PDRkEpsilon.C file.
\f$ Eqs in the \link PDRkEpsilon.C \endlink file.
SourceFiles

View File

@ -50,7 +50,7 @@ PDRkEpsilon::PDRkEpsilon
const volScalarField& rho,
const volVectorField& U,
const surfaceScalarField& phi,
const basicThermo& thermophysicalModel
basicThermo& thermophysicalModel
)
:
RASModel(typeName, rho, U, phi, thermophysicalModel),

View File

@ -27,7 +27,7 @@ Class
Description
Standard k-epsilon turbulence model with additional source terms
corresponding to PDR basic drag model (basic.H)
corresponding to PDR basic drag model (\link basic.H \endlink)
The turbulence source term \f$ G_{R} \f$ appears in the
\f$ \kappa-\epsilon \f$ equation for the generation of turbulence due to
@ -93,7 +93,7 @@ public:
const volScalarField& rho,
const volVectorField& U,
const surfaceScalarField& phi,
const basicThermo& thermophysicalModel
basicThermo& thermophysicalModel
);

View File

@ -26,6 +26,10 @@ Class
Foam::XiEqModels::SCOPEBlend
Description
Simple SCOPEBlendXiEq model for XiEq based on SCOPEXiEqs correlation
with a linear correction function to give a plausible profile for XiEq.
See @link SCOPELaminarFlameSpeed.H @endlink for details on the SCOPE
laminar flame speed model.
SourceFiles
SCOPEBlend.C

View File

@ -28,6 +28,8 @@ Class
Description
Simple SCOPEXiEq model for XiEq based on SCOPEXiEqs correlation
with a linear correction function to give a plausible profile for XiEq.
See \link SCOPELaminarFlameSpeed.H \endlink for details on the SCOPE laminar
flame speed model.
SourceFiles
SCOPEXiEq.C

View File

@ -27,6 +27,12 @@ Class
Description
Base-class for all XiEq models used by the b-XiEq combustion model.
The available models are :
\link basicXiSubXiEq.H \endlink
\link Gulder.H \endlink
\link instabilityXiEq.H \endlink
\link SCOPEBlendXiEq.H \endlink
\link SCOPEXiEq.H \endlink
SourceFiles
XiEqModel.C

View File

@ -26,6 +26,9 @@ Class
Foam::XiEqModels::instability
Description
This is the equilibrium level of the flame wrinkling generated by
instability. It is a constant (default 2.5). It is used in
@link XiModel.H @endlink.
SourceFiles
instability.C

View File

@ -26,7 +26,8 @@ Class
Foam::XiGModels::KTS
Description
Simple Kolmogorov time-scale model for the flame-wrinling generation rate.
Simple Kolmogorov time-scale (KTS) model for the flame-wrinling generation
rate.
SourceFiles
KTS.C

View File

@ -27,6 +27,9 @@ Class
Description
Base-class for all Xi generation models used by the b-Xi combustion model.
See Technical Report SH/RE/01R for details on the PDR modelling. For details
on the use of XiGModel see \link XiModel.H \endlink. The model available is
\link instabilityG.H \endlink
SourceFiles
XiGModel.C

View File

@ -26,7 +26,10 @@ Class
Foam::XiGModels::instabilityG
Description
Flame-surface instabilityG flame-wrinking generation rate coefficient model.
Flame-surface instabilityG flame-wrinking generation rate coefficient model
used in \link XiModel.H \endlink.
See Technical Report SH/RE/01R for details on the PDR modelling.
SourceFiles
instabilityG.C

View File

@ -29,8 +29,10 @@ Description
Base-class for all Xi models used by the b-Xi combustion model.
See Technical Report SH/RE/01R for details on the PDR modelling.
Xi is given through an algebraic expression (algebraic.H),
by solving a transport equation (transport.H) or a fixed value (fixed.H).
Xi is given through an algebraic expression (\link algebraic.H \endlink),
by solving a transport equation (\link transport.H \endlink) or a
fixed value (\link fixed.H \endlink).
See report TR/HGW/10 for details on the Weller two equations model.
In the algebraic and transport methods \f$\Xi_{eq}\f$ is calculated in
@ -45,6 +47,8 @@ Description
\f$ \dwea{b} \f$ is the regress variable.
\f$ \Xi_{coeff} \f$ is a model constant.
\f$ \Xi^* \f$ is the total equilibrium wrinkling combining the effects
of the flame inestability and turbulence interaction and is given by

View File

@ -28,6 +28,8 @@ Class
Description
Simple algebraic model for Xi based on Gulders correlation
with a linear correction function to give a plausible profile for Xi.
See report TR/HGW/10 for details on the Weller two equations model.
See \link XiModel.H \endlink for more details on flame wrinkling modelling.
SourceFiles
algebraic.C

View File

@ -26,7 +26,8 @@ Class
Foam::XiModels::fixed
Description
Fixed value model for Xi.
Fixed value model for Xi. See \link XiModel.H \endlink for more details
on flame wrinkling modelling.
SourceFiles
fixed.C

View File

@ -28,6 +28,8 @@ Class
Description
Simple transport model for Xi based on Gulders correlation
with a linear correction function to give a plausible profile for Xi.
See report TR/HGW/10 for details on the Weller two equations model.
See \link XiModel.H \endlink for more details on flame wrinkling modelling.
SourceFiles
transport.C

View File

@ -100,7 +100,19 @@ int main(int argc, char *argv[])
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
if
(
corr == nCorr-1
&& nonOrth == nNonOrthCorr
)
{
pEqn.solve(mesh.solver("pFinal"));
}
else
{
pEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{

View File

@ -39,7 +39,7 @@ int main(int argc, char *argv[])
wordHashSet setA(0);
HashTable<label, word> tableA;
HashTable<empty> tableB;
HashTable<nil> tableB;
Map<label> mapA;
setA.insert("kjhk");
@ -49,9 +49,9 @@ int main(int argc, char *argv[])
tableA.insert("value2", 2);
tableA.insert("value3", 3);
tableB.insert("value4", empty());
tableB.insert("value5", empty());
tableB.insert("value6", empty());
tableB.insert("value4", nil());
tableB.insert("value5", nil());
tableB.insert("value6", nil());
mapA.set(1, 1);
mapA.set(2, 2);
@ -66,7 +66,7 @@ int main(int argc, char *argv[])
Info<< wordHashSet(setA) << endl;
Info<< "create from HashTable<T>: ";
Info<< wordHashSet(tableA) << endl;
Info<< "create from HashTable<empty>: ";
Info<< "create from HashTable<nil>: ";
Info<< wordHashSet(tableB) << endl;
Info<< "create from Map<label>: ";

View File

@ -100,12 +100,12 @@ int main()
<< "\ntable2" << table1 << nl
<< "\ntable3" << table3 << nl;
Info<< "\ndelete table2" << nl;
Info<< "\nerase table2 by iterator" << nl;
forAllIter(HASHTABLE_CLASS<double>, table2, iter)
{
Info<< "deleting " << iter.key() << " => " << iter() << " ... ";
Info<< "erasing " << iter.key() << " => " << iter() << " ... ";
table2.erase(iter);
Info<< "deleted" << endl;
Info<< "erased" << endl;
}
Info<< "\ntable1" << table1 << nl
@ -134,6 +134,24 @@ int main()
table1.erase(table1.begin());
Info<< "removed an element - test table1 != table3 : "
<< (table1 != table3) << nl;
// insert a few things into table2
table2.set("ada", 14.0);
table2.set("aeq", 15.0);
table2.set("aaw", 16.0);
table2.set("abs", 17.0);
table2.set("adx", 20.0);
Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl;
label nErased = table1.erase(table2);
Info<< "\nerase table2 keys from table1 (removed "
<< nErased << " elements)" << nl
<< "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl;
Info<< "\nclearStorage table3 ... ";
table3.clearStorage();

View File

@ -100,13 +100,13 @@ int main()
<< "\ntable2" << table1 << nl
<< "\ntable3" << table3 << nl;
Info<< "\ndelete table2" << nl;
forAllIter(HASHTABLE_CLASS<double>, table2, iter)
{
Info<< "deleting " << iter.key() << " => " << iter() << " ... ";
table2.erase(iter);
Info<< "deleted" << endl;
}
Info<< "\nerase table2 by iterator" << nl;
forAllIter(HASHTABLE_CLASS<double>, table2, iter)
{
Info<< "erasing " << iter.key() << " => " << iter() << " ... ";
table2.erase(iter);
Info<< "erased" << endl;
}
Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl
@ -134,6 +134,24 @@ int main()
table1.erase(table1.begin());
Info<< "removed an element - test table1 != table3 : "
<< (table1 != table3) << nl;
// insert a few things into table2
table2.set("ada", 14.0);
table2.set("aeq", 15.0);
table2.set("aaw", 16.0);
table2.set("abs", 17.0);
table2.set("adx", 20.0);
Info<< "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl;
label nErased = table1.erase(table2);
Info<< "\nerase table2 keys from table1 (removed "
<< nErased << " elements)" << nl
<< "\ntable1" << table1 << nl
<< "\ntable2" << table2 << nl;
Info<< "\nclearStorage table3 ... ";
table3.clearStorage();
@ -144,5 +162,4 @@ int main()
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
foamVersionString.C
EXE = $(FOAM_USER_APPBIN)/foamVersionString

View File

@ -0,0 +1,2 @@
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */

View File

@ -0,0 +1,47 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
foamVersionString.C
Description
Print the OpenFOAM version strings.
Simultaneously the smallest possible program to use a minimal bit of
the OpenFOAM library
\*---------------------------------------------------------------------------*/
#include <iostream>
#include "foamVersion.H"
int main()
{
std::cerr
<< "build " << Foam::FOAMbuild << "\n"
<< "version " << Foam::FOAMversion << "\n";
return 0;
}
// ************************************************************************* //

View File

@ -413,7 +413,7 @@ bool limitRefinementLevel
}
}
if (addCutCells.size() > 0)
if (addCutCells.size())
{
// Add cells to cutCells.
@ -479,7 +479,7 @@ void doRefinement
{
const labelList& added = addedCells[oldCellI];
if (added.size() > 0)
if (added.size())
{
// Give all cells resulting from split the refinement level
// of the master.
@ -895,7 +895,7 @@ int main(int argc, char *argv[])
<< " Selected for refinement :" << cutCells.size() << nl
<< endl;
if (cutCells.size() == 0)
if (cutCells.empty())
{
Info<< "Stopping refining since 0 cells selected to be refined ..."
<< nl << endl;

View File

@ -358,18 +358,21 @@ int main(int argc, char *argv[])
(
dict.lookup("facesToTriangulate")
);
bool cutBoundary =
pointsToMove.size() > 0
|| edgesToSplit.size() > 0
|| facesToTriangulate.size() > 0;
(
pointsToMove.size()
|| edgesToSplit.size()
|| facesToTriangulate.size()
);
List<Pair<point> > edgesToCollapse(dict.lookup("edgesToCollapse"));
bool collapseEdge = edgesToCollapse.size() > 0;
bool collapseEdge = edgesToCollapse.size();
List<Pair<point> > cellsToPyramidise(dict.lookup("cellsToSplit"));
bool cellsToSplit = cellsToPyramidise.size() > 0;
bool cellsToSplit = cellsToPyramidise.size();
//List<Tuple<pointField,point> >
// cellsToCreate(dict.lookup("cellsToCreate"));
@ -523,7 +526,7 @@ int main(int argc, char *argv[])
Info<< nl << "There was a problem in one of the inputs in the"
<< " dictionary. Not modifying mesh." << endl;
}
else if (cellToPyrCentre.size() > 0)
else if (cellToPyrCentre.size())
{
Info<< nl << "All input cells located. Modifying mesh." << endl;
@ -555,7 +558,7 @@ int main(int argc, char *argv[])
Info << "Writing modified mesh to time " << runTime.value() << endl;
mesh.write();
}
else if (edgeToPos.size() > 0)
else if (edgeToPos.size())
{
Info<< nl << "All input edges located. Modifying mesh." << endl;

View File

@ -336,7 +336,7 @@ int main(int argc, char *argv[])
)
{}
if (refCells.size() > 0)
if (refCells.size())
{
Info<< "Collected " << refCells.size() << " cells that need to be"
<< " refined to get closer to overall 2:1 refinement level limit"

View File

@ -652,7 +652,7 @@ int main(int argc, char *argv[])
// Remove cut cells from cellsToCut (Note:only relevant if -readSet)
forAll(cuts.cellLoops(), cellI)
{
if (cuts.cellLoops()[cellI].size() > 0)
if (cuts.cellLoops()[cellI].size())
{
//Info<< "Removing cut cell " << cellI << " from wishlist"
// << endl;

View File

@ -584,7 +584,7 @@ int main(int argc, char *argv[])
forAll (rawPatches, patchI)
{
if (rawPatches[patchI].size() > 0 && cfxPatchTypes[patchI] != "BLKBDY")
if (rawPatches[patchI].size() && cfxPatchTypes[patchI] != "BLKBDY")
{
// Check if this name has been already created
label existingPatch = -1;

View File

@ -1,4 +1,4 @@
/*---------------------------------------------------------------------------*\
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
@ -1486,7 +1486,7 @@ int main(int argc, char *argv[])
}
defaultBoundaryFaces.shrink();
if(defaultBoundaryFaces.size() != 0)
if (defaultBoundaryFaces.size())
{
Warning << " fluent mesh has " << defaultBoundaryFaces.size()
<< " undefined boundary faces." << endl
@ -1695,7 +1695,7 @@ int main(int argc, char *argv[])
// soon negating the need for double output
if (writeSets)
{
if (cellGroupZoneID.size() > 1 )
if (cellGroupZoneID.size() > 1)
{
Info<< "Writing cell sets" << endl;

View File

@ -667,7 +667,7 @@ void readCells
const labelList& zCells = zoneCells[zoneI];
if (zCells.size() > 0)
if (zCells.size())
{
Info<< " " << zoneI << '\t' << zCells.size() << endl;
}
@ -778,7 +778,7 @@ int main(int argc, char *argv[])
forAll(zoneCells, zoneI)
{
if (zoneCells[zoneI].size() > 0)
if (zoneCells[zoneI].size())
{
nValidCellZones++;
}
@ -910,7 +910,7 @@ int main(int argc, char *argv[])
const labelList& zFaces = zoneFaces[zoneI];
if (zFaces.size() > 0)
if (zFaces.size())
{
nValidFaceZones++;
@ -940,7 +940,7 @@ int main(int argc, char *argv[])
forAll(zoneCells, zoneI)
{
if (zoneCells[zoneI].size() > 0)
if (zoneCells[zoneI].size())
{
label physReg = zoneToPhys[zoneI];
@ -979,7 +979,7 @@ int main(int argc, char *argv[])
forAll(zoneFaces, zoneI)
{
if (zoneFaces[zoneI].size() > 0)
if (zoneFaces[zoneI].size())
{
label physReg = zoneToPhys[zoneI];
@ -1011,7 +1011,7 @@ int main(int argc, char *argv[])
}
}
if (cz.size() > 0 || fz.size() > 0)
if (cz.size() || fz.size())
{
mesh.addZones(List<pointZone*>(0), fz, cz);
}

View File

@ -752,7 +752,7 @@ int main(int argc, char *argv[])
List<faceList> patchFaceVerts;
if (dofVertIndices.size() > 0)
if (dofVertIndices.size())
{
// Use the vertex constraints to patch. Is of course bit dodgy since
// face goes on patch if all its vertices are on a constraint.

View File

@ -242,7 +242,7 @@ int main(int argc, char *argv[])
}
if (vertsToBoundary.size() > 0)
if (vertsToBoundary.size())
{
// Didn't find cells connected to boundary faces.
WarningIn(args.executable())

View File

@ -229,7 +229,7 @@ void simpleMarkFeatures
if (doNotPreserveFaceZones)
{
if (faceZones.size() > 0)
if (faceZones.size())
{
WarningIn("simpleMarkFeatures(..)")
<< "Detected " << faceZones.size()
@ -239,7 +239,7 @@ void simpleMarkFeatures
}
else
{
if (faceZones.size() > 0)
if (faceZones.size())
{
Info<< "Detected " << faceZones.size()
<< " faceZones. Preserving these by marking their"

View File

@ -38,10 +38,7 @@ Class
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(meshDualiser, 0);
}
defineTypeNameAndDebug(Foam::meshDualiser, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -735,7 +732,7 @@ void Foam::meshDualiser::createFacesAroundBoundaryPoint
) << "Walked from face on patch:" << patchI
<< " to face:" << faceI
<< " fc:" << mesh_.faceCentres()[faceI]
<< " on patch:" << patches.whichPatch(faceI)
<< " on patch:" << patches.whichPatch(faceI)
<< abort(FatalError);
}
@ -886,7 +883,7 @@ Foam::meshDualiser::meshDualiser(const polyMesh& mesh)
faceToDualPoint_(mesh_.nFaces(), -1),
edgeToDualPoint_(mesh_.nEdges(), -1)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -1083,7 +1080,7 @@ void Foam::meshDualiser::setRefinement
{
label pointI = multiCellFeaturePoints[i];
if (pointToDualCells_[pointI].size() > 0)
if (pointToDualCells_[pointI].size())
{
FatalErrorIn
(
@ -1133,7 +1130,7 @@ void Foam::meshDualiser::setRefinement
// Normal points
forAll(mesh_.points(), pointI)
{
if (pointToDualCells_[pointI].size() == 0)
if (pointToDualCells_[pointI].empty())
{
pointToDualCells_[pointI].setSize(1);
pointToDualCells_[pointI][0] = meshMod.addCell
@ -1241,7 +1238,7 @@ void Foam::meshDualiser::setRefinement
const edge& e = mesh_.edges()[edgeI];
// We need a point on the edge if not all cells on both sides
// are the same.
// are the same.
const labelList& eCells = mesh_.edgeCells()[edgeI];

View File

@ -136,7 +136,7 @@ void sammMesh::readCouples()
forAll (curFaces, faceI)
{
if (curFaces[faceI].size() == 0)
if (curFaces[faceI].empty())
{
zeroSizeFound++;
}
@ -153,7 +153,7 @@ void sammMesh::readCouples()
forAll (oldFaces, faceI)
{
if (oldFaces[faceI].size() > 0)
if (oldFaces[faceI].size())
{
curFaces[nFaces] = oldFaces[faceI];

View File

@ -45,12 +45,11 @@ void starMesh::createCoupleMatches()
// existing points list
// Estimate the number of cells affected by couple matches
const label cellMapSize =
min
(
cellShapes_.size()/10,
couples_.size()*2
);
const label cellMapSize = min
(
cellShapes_.size()/10,
couples_.size()*2
);
// Store newly created faces for each cell
Map<SLList<face> > cellAddedFaces(cellMapSize);
@ -322,7 +321,7 @@ void starMesh::createCoupleMatches()
// A new point is created. Warning:
// using original edge for accuracy.
//
//
coupleFacePoints.append
(P + alpha*curMasterEdge.vec(points_));
}
@ -338,7 +337,7 @@ void starMesh::createCoupleMatches()
// master edge and vice versa. The problem is that
// no symmetry exists, i.e. both operations needs
// to be done separately for both master and slave
// side.
// side.
// Master side
// check if the first or second point of slave edge is
@ -625,11 +624,11 @@ void starMesh::createCoupleMatches()
// Eliminate all zero-length edges
face newMasterFace(labelList(tmpMasterFace.size(), labelMax));
// insert first point by hand. Careful: the first one is
// used for comparison to allow the edge collapse across
// point zero.
//
//
newMasterFace[0] = tmpMasterFace[0];
label nMaster = 0;
@ -823,7 +822,7 @@ void starMesh::createCoupleMatches()
// insert first point by hand. Careful: the first one is
// used for comparison to allow the edge collapse across
// point zero.
//
//
newSlaveFace[0] = tmpSlaveFace[0];
label nSlave = 0;
@ -1097,7 +1096,7 @@ void starMesh::createCoupleMatches()
<< "edges to consider: " << edgesToConsider << endl;
# endif
if (edgesToConsider.size() == 0)
if (edgesToConsider.empty())
{
FatalErrorIn("void starMesh::createCoupleMatches()")
<< setprecision(12)
@ -1420,7 +1419,7 @@ void starMesh::createCoupleMatches()
} // end of arbitrary match
}
if (couples_.size() > 0)
if (couples_.size())
{
// Loop through all cells and reset faces for removal to zero size
const labelList crfToc = cellRemovedFaces.toc();
@ -1442,7 +1441,7 @@ void starMesh::createCoupleMatches()
cellFaces_[curCell][curRemovedFacesIter()].setSize(0);
}
if (curRemovedFaces.size() > 0)
if (curRemovedFaces.size())
{
// reset the shape pointer to unknown
cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0));
@ -1468,7 +1467,7 @@ void starMesh::createCoupleMatches()
// copy original faces that have not been removed
forAll (oldFaces, faceI)
{
if (oldFaces[faceI].size() > 0)
if (oldFaces[faceI].size())
{
newFaces[nNewFaces] = oldFaces[faceI];
nNewFaces++;
@ -1491,7 +1490,7 @@ void starMesh::createCoupleMatches()
// reset the size of the face list
newFaces.setSize(nNewFaces);
if (curAddedFaces.size() > 0)
if (curAddedFaces.size())
{
// reset the shape pointer to unknown
cellShapes_[curCell] = cellShape(*unknownPtr_, labelList(0));

View File

@ -264,7 +264,7 @@ starMesh::starMesh
readCouples();
if (couples_.size() > 0)
if (couples_.size())
{
createCoupleMatches();
}

View File

@ -160,7 +160,7 @@ int main(int argc, char *argv[])
{
nodeStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream nodeLine(line);
@ -193,7 +193,7 @@ int main(int argc, char *argv[])
{
nodeStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream nodeLine(line);
@ -237,7 +237,7 @@ int main(int argc, char *argv[])
{
eleStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream eleLine(line);
@ -281,7 +281,7 @@ int main(int argc, char *argv[])
{
eleStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream eleLine(line);
@ -356,7 +356,7 @@ int main(int argc, char *argv[])
{
faceStream.getLine(line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
IStringStream faceLine(line);
@ -398,7 +398,7 @@ int main(int argc, char *argv[])
{
faceStream.getLine(line);
if ((line.size() > 0) && (line[0] != '#'))
if (line.size() && line[0] != '#')
{
IStringStream faceLine(line);

View File

@ -118,7 +118,7 @@ Foam::label Foam::blockMesh::numZonedBlocks() const
forAll(*this, blockI)
{
if (operator[](blockI).blockDef().zoneName().size() > 0)
if (operator[](blockI).blockDef().zoneName().size())
{
num++;
}

View File

@ -278,7 +278,7 @@ int main(int argc, char *argv[])
const labelListList& blockCells = b.cells();
const word& zoneName = b.blockDef().zoneName();
if (zoneName.size() > 0)
if (zoneName.size())
{
HashTable<label>::const_iterator iter = zoneMap.find(zoneName);

View File

@ -1,6 +1,6 @@
Info<< "Creating merge patch pairs" << nl << endl;
if (mergePatchPairs.size() > 0)
if (mergePatchPairs.size())
{
// Create and add point and face zones and mesh modifiers
List<pointZone*> pz(mergePatchPairs.size());

View File

@ -177,7 +177,7 @@ Foam::label Foam::checkTopology
primitivePatch::surfaceTopo pTyp = pp.surfaceType();
if (pp.size() == 0)
if (pp.empty())
{
Pout<< setw(34) << "ok (empty)";
}
@ -232,7 +232,7 @@ Foam::label Foam::checkTopology
Pout<< endl;
}
if (points.size() > 0)
if (points.size())
{
Pout<< " <<Writing " << points.size()
<< " conflicting points to set "

View File

@ -172,7 +172,7 @@ void filterPatches(polyMesh& mesh)
if (isA<processorPolyPatch>(pp))
{
if (pp.size() > 0)
if (pp.size())
{
allPatches.append
(
@ -586,7 +586,7 @@ int main(int argc, char *argv[])
// 1. Add all new patches
// ~~~~~~~~~~~~~~~~~~~~~~
if (patchSources.size() > 0)
if (patchSources.size())
{
// Old and new patches.
DynamicList<polyPatch*> allPatches(patches.size()+patchSources.size());

View File

@ -34,10 +34,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(mergePolyMesh, 1);
}
defineTypeNameAndDebug(Foam::mergePolyMesh, 1);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -142,7 +139,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Point zones
wordList curPointZoneNames = pointZones().names();
if (curPointZoneNames.size() > 0)
if (curPointZoneNames.size())
{
pointZoneNames_.setCapacity(2*curPointZoneNames.size());
}
@ -155,7 +152,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Face zones
wordList curFaceZoneNames = faceZones().names();
if (curFaceZoneNames.size() > 0)
if (curFaceZoneNames.size())
{
faceZoneNames_.setCapacity(2*curFaceZoneNames.size());
}
@ -167,7 +164,7 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io)
// Cell zones
wordList curCellZoneNames = cellZones().names();
if (curCellZoneNames.size() > 0)
if (curCellZoneNames.size())
{
cellZoneNames_.setCapacity(2*curCellZoneNames.size());
}
@ -333,11 +330,11 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
newOwn = own[faceI];
if (newOwn > -1) newOwn = renumberCells[newOwn];
if (newPatch > -1)
if (newPatch > -1)
{
newNei = -1;
}
else
}
else
{
newNei = nei[faceI];
newNei = renumberCells[newNei];
@ -373,7 +370,7 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m)
)
);
}
}

View File

@ -48,7 +48,7 @@ string getLine(std::ifstream& is)
{
std::getline(is, line);
}
while((line.size() > 0) && (line[0] == '#'));
while (line.size() && line[0] == '#');
return line;
}
@ -60,13 +60,13 @@ labelList parseVertices(const string& line)
DynamicList<label> verts;
// Assume 'l' is followed by space.
label endNum = 1;
string::size_type endNum = 1;
do
{
label startNum = line.find_first_not_of(' ', endNum);
string::size_type startNum = line.find_first_not_of(' ', endNum);
if (startNum == label(string::npos))
if (startNum == string::npos)
{
break;
}
@ -74,7 +74,7 @@ labelList parseVertices(const string& line)
endNum = line.find(' ', startNum);
string vertexSpec;
if (endNum != label(string::npos))
if (endNum != string::npos)
{
vertexSpec = line.substr(startNum, endNum-startNum);
}
@ -83,10 +83,10 @@ labelList parseVertices(const string& line)
vertexSpec = line.substr(startNum, line.size() - startNum);
}
label slashPos = vertexSpec.find('/');
string::size_type slashPos = vertexSpec.find('/');
label vertI = 0;
if (slashPos != label(string::npos))
if (slashPos != string::npos)
{
IStringStream intStream(vertexSpec.substr(0, slashPos));

View File

@ -485,7 +485,7 @@ int main(int argc, char *argv[])
{
const labelList& added = oldToNew[oldCellI];
if (added.size() > 0)
if (added.size())
{
forAll(added, i)
{

View File

@ -89,7 +89,7 @@ void backup
const word& toName
)
{
if (fromSet.size() > 0)
if (fromSet.size())
{
Pout<< " Backing up " << fromName << " into " << toName << endl;
@ -284,7 +284,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
polyMesh::meshSubDir/"sets"
);
IOobjectList cellSets(objects.lookupClass(cellSet::typeName));
if (cellSets.size() > 0)
if (cellSets.size())
{
os << "cellSets:" << endl;
forAllConstIter(IOobjectList, cellSets, iter)
@ -294,7 +294,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
}
}
IOobjectList faceSets(objects.lookupClass(faceSet::typeName));
if (faceSets.size() > 0)
if (faceSets.size())
{
os << "faceSets:" << endl;
forAllConstIter(IOobjectList, faceSets, iter)
@ -304,7 +304,7 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
}
}
IOobjectList pointSets(objects.lookupClass(pointSet::typeName));
if (pointSets.size() > 0)
if (pointSets.size())
{
os << "pointSets:" << endl;
forAllConstIter(IOobjectList, pointSets, iter)
@ -347,7 +347,7 @@ bool doCommand
bool ok = true;
// Set to work on
autoPtr<topoSet> currentSetPtr(NULL);
autoPtr<topoSet> currentSetPtr;
word sourceType;
@ -383,7 +383,7 @@ bool doCommand
currentSet.resize(max(currentSet.size(), typSize));
}
if (!currentSetPtr.valid())
if (currentSetPtr.empty())
{
Pout<< " Cannot construct/load set "
<< topoSet::localPath(mesh, setName) << endl;
@ -522,7 +522,7 @@ bool doCommand
Pout<< fIOErr.message().c_str() << endl;
if (sourceType.size() != 0)
if (sourceType.size())
{
Pout<< topoSetSource::usage(sourceType).c_str();
}
@ -533,7 +533,7 @@ bool doCommand
Pout<< fErr.message().c_str() << endl;
if (sourceType.size() != 0)
if (sourceType.size())
{
Pout<< topoSetSource::usage(sourceType).c_str();
}
@ -571,7 +571,7 @@ commandStatus parseType
IStringStream& is
)
{
if (setType.size() == 0)
if (setType.empty())
{
Pout<< "Type 'help' for usage information" << endl;
@ -689,7 +689,7 @@ commandStatus parseAction(const word& actionName)
{
commandStatus stat = INVALID;
if (actionName.size() != 0)
if (actionName.size())
{
try
{
@ -792,7 +792,7 @@ int main(int argc, char *argv[])
std::getline(*fileStreamPtr, rawLine);
if (rawLine.size() > 0)
if (rawLine.size())
{
Pout<< "Doing:" << rawLine << endl;
}
@ -821,7 +821,7 @@ int main(int argc, char *argv[])
# endif
}
if (rawLine.size() == 0 || rawLine[0] == '#')
if (rawLine.empty() || rawLine[0] == '#')
{
continue;
}

View File

@ -100,10 +100,10 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError);
}
if (bMesh[patchI].size() != 0)
if (bMesh[patchI].size())
{
FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)")
<< "Patch " << name << " is present but not of zero size"
<< "Patch " << name << " is present but non-zero size"
<< exit(FatalError);
}
}

View File

@ -878,7 +878,7 @@ void createAndWriteRegion
{
const polyPatch& pp = newPatches[patchI];
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
if (isA<processorPolyPatch>(pp) && pp.size())
{
oldToNew[patchI] = newI++;
}
@ -1049,7 +1049,7 @@ label findCorrespondingZone
labelList regionCells = findIndices(cellRegion, regionI);
if (regionCells.size() == 0)
if (regionCells.empty())
{
// My local portion is empty. Maps to any empty cellZone. Mark with
// special value which can get overwritten by other processors.
@ -1200,7 +1200,7 @@ int main(int argc, char *argv[])
boolList blockedFace;
// Read from faceSet
if (blockedFacesName.size() > 0)
if (blockedFacesName.size())
{
faceSet blockedFaceSet(mesh, blockedFacesName);
Info<< "Read " << returnReduce(blockedFaceSet.size(), sumOp<label>())

View File

@ -82,7 +82,7 @@ void checkPatch(const polyBoundaryMesh& bMesh, const word& name)
<< exit(FatalError);
}
if (bMesh[patchI].size() == 0)
if (bMesh[patchI].empty())
{
FatalErrorIn("checkPatch(const polyBoundaryMesh&, const word&)")
<< "Patch " << name << " is present but zero size"

View File

@ -152,7 +152,7 @@ int main(int argc, char *argv[])
);
if (args.options().size() == 0)
if (args.options().empty())
{
FatalErrorIn(args.executable())
<< "No options supplied, please use one or more of "

View File

@ -104,7 +104,7 @@ void domainDecomposition::distributeCells()
}
}
if (sameProcFaces.size() > 0)
if (sameProcFaces.size())
{
Info<< "Selected " << sameProcFaces.size()
<< " faces whose owner and neighbour cell should be kept on the"
@ -123,7 +123,7 @@ void domainDecomposition::distributeCells()
*this
);
if (sameProcFaces.size() == 0)
if (sameProcFaces.empty())
{
cellToProc_ = decomposePtr().decompose(cellCentres());
}

View File

@ -100,7 +100,7 @@ int main(int argc, char *argv[])
args
);
if (!timeDirs.size())
if (timeDirs.empty())
{
FatalErrorIn(args.executable())
<< "No times selected"
@ -309,7 +309,7 @@ int main(int argc, char *argv[])
}
if (cloudObjects.size() > 0)
if (cloudObjects.size())
{
// Pass2: reconstruct the cloud
forAllConstIter(HashTable<IOobjectList>, cloudObjects, iter)

View File

@ -558,7 +558,7 @@ void ensightFieldAscii
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
if (!patchNames.size())
if (patchNames.empty())
{
if (Pstream::master())
{
@ -633,7 +633,7 @@ void ensightFieldAscii
const word& patchName = iter.key();
const labelList& patchProcessors = iter();
if (!patchNames.size() || patchNames.found(patchName))
if (patchNames.empty() || patchNames.found(patchName))
{
if (patchIndices.found(patchName))
{
@ -734,7 +734,7 @@ void ensightFieldBinary
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, mesh);
if (!patchNames.size())
if (patchNames.empty())
{
if (Pstream::master())
{
@ -805,7 +805,7 @@ void ensightFieldBinary
const word& patchName = iter.key();
const labelList& patchProcessors = iter();
if (!patchNames.size() || patchNames.found(patchName))
if (patchNames.empty() || patchNames.found(patchName))
{
if (patchIndices.found(patchName))
{

View File

@ -129,7 +129,7 @@ Foam::ensightMesh::ensightMesh
{
wordList patchNameList(IStringStream(args.options()["patches"])());
if (!patchNameList.size())
if (patchNameList.empty())
{
patchNameList = allPatchNames_.toc();
}
@ -163,7 +163,7 @@ Foam::ensightMesh::ensightMesh
label nHexes = 0;
label nPolys = 0;
if (!patchNames_.size())
if (patchNames_.empty())
{
forAll(cellShapes, celli)
{
@ -267,7 +267,7 @@ Foam::ensightMesh::ensightMesh
const word& patchName = iter.key();
nFacePrimitives nfp;
if (!patchNames_.size() || patchNames_.found(patchName))
if (patchNames_.empty() || patchNames_.found(patchName))
{
if (patchIndices_.found(patchName))
{
@ -403,7 +403,7 @@ void Foam::ensightMesh::writePrimsBinary
numElem = cellShapes.size();
if (cellShapes.size() > 0)
if (cellShapes.size())
{
// All the cellShapes have the same number of elements!
int numIntElem = cellShapes.size()*cellShapes[0].size();
@ -917,7 +917,7 @@ void Foam::ensightMesh::writeAscii
labelList pointOffsets(Pstream::nProcs(), 0);
if (!patchNames_.size())
if (patchNames_.empty())
{
label nPoints = points.size();
Pstream::gather(nPoints, sumOp<label>());
@ -1044,7 +1044,7 @@ void Foam::ensightMesh::writeAscii
{
const labelList& patchProcessors = iter();
if (!patchNames_.size() || patchNames_.found(iter.key()))
if (patchNames_.empty() || patchNames_.found(iter.key()))
{
const word& patchName = iter.key();
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
@ -1244,7 +1244,7 @@ void Foam::ensightMesh::writeBinary
labelList pointOffsets(Pstream::nProcs(), 0);
if (!patchNames_.size())
if (patchNames_.empty())
{
label nPoints = points.size();
Pstream::gather(nPoints, sumOp<label>());
@ -1373,7 +1373,7 @@ void Foam::ensightMesh::writeBinary
iCount ++;
const labelList& patchProcessors = iter();
if (!patchNames_.size() || patchNames_.found(iter.key()))
if (patchNames_.empty() || patchNames_.found(iter.key()))
{
const word& patchName = iter.key();
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();

View File

@ -57,7 +57,7 @@ void writeEnsDataBinary
std::ofstream& ensightFile
)
{
if (sf.size() > 0)
if (sf.size())
{
List<float> temp(sf.size());

View File

@ -77,9 +77,9 @@ forAllIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
}
}
if (!cloudIter().size())
if (cloudIter().empty())
{
Info<< "removing cloud " << cloudName<< endl;
Info<< "removing cloud " << cloudName << endl;
cloudFields.erase(cloudIter);
}
}

View File

@ -227,7 +227,7 @@ int main(int argc, char *argv[])
# include "getFieldNames.H"
bool hasLagrangian = false;
if ((sprayScalarNames.size() > 0) || (sprayVectorNames.size() > 0))
if (sprayScalarNames.size() || sprayVectorNames.size())
{
hasLagrangian = true;
}

View File

@ -80,7 +80,7 @@ for(label i=0; i < nTypes; i++)
wordList lagrangianScalarNames = objects.names("scalarField");
wordList lagrangianVectorNames = objects.names("vectorField");
if (particles.size() > 0)
if (particles.size())
{
# include "gmvOutputLagrangian.H"
}

View File

@ -49,16 +49,11 @@ forAll(lagrangianScalarNames, i)
)
);
if (s.size() != 0)
if (s.size())
{
gmvFile << name << nl;
for
(
label n = 0;
n < s.size();
n++
)
for (label n = 0; n < s.size(); n++)
{
gmvFile << s[n] << token::SPACE;
}
@ -85,16 +80,11 @@ forAll(lagrangianVectorNames, i)
)
);
if (v.size() != 0)
if (v.size())
{
gmvFile << name + "x" << nl;
for
(
label n = 0;
n < v.size();
n++
)
for (label n = 0; n < v.size(); n++)
{
gmvFile << v[n].x() << token::SPACE;
}
@ -102,12 +92,7 @@ forAll(lagrangianVectorNames, i)
gmvFile << name + "y" << nl;
for
(
label n = 0;
n < v.size();
n++
)
for (label n = 0; n < v.size(); n++)
{
gmvFile << v[n].y() << token::SPACE;
}
@ -115,19 +100,13 @@ forAll(lagrangianVectorNames, i)
gmvFile << name + "z" << nl;
for
(
label n = 0;
n < v.size();
n++
)
for (label n = 0; n < v.size(); n++)
{
gmvFile << v[n].z() << token::SPACE;
}
gmvFile << nl;
}
}

View File

@ -47,16 +47,11 @@ forAll(lagrangianScalarNames, i)
)
);
if (s.size() != 0)
if (s.size())
{
gmvFile << name << nl;
for
(
label n = 0;
n < s.size();
n++
)
for (label n = 0; n < s.size(); n++)
{
gmvFile << s[n] << token::SPACE;
}

View File

@ -339,7 +339,7 @@ int main(int argc, char *argv[])
(
args.options().found("time")
|| args.options().found("latestTime")
|| cellSetName.size() > 0
|| cellSetName.size()
|| regionName != polyMesh::defaultRegion
)
{

View File

@ -58,7 +58,7 @@ void readFields
++iter
)
{
if (!selectedFields.size() || selectedFields.found(iter()->name()))
if (selectedFields.empty() || selectedFields.found(iter()->name()))
{
fields.set
(

View File

@ -47,7 +47,7 @@ Foam::vtkMesh::vtkMesh
subsetter_(baseMesh),
setName_(setName)
{
if (setName.size() > 0)
if (setName.size())
{
// Read cellSet using whole mesh
cellSet currentSet(baseMesh_, setName_);
@ -71,7 +71,7 @@ Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
topoPtr_.clear();
if (setName_.size() > 0)
if (setName_.size())
{
Info<< "Subsetting mesh based on cellSet " << setName_ << endl;

View File

@ -105,13 +105,13 @@ public:
//- Check if running subMesh
bool useSubMesh() const
{
return setName_.size() > 0;
return setName_.size();
}
//- topology
const vtkTopo& topo() const
{
if (!topoPtr_.valid())
if (topoPtr_.empty())
{
topoPtr_.reset(new vtkTopo(mesh()));
}

View File

@ -154,6 +154,11 @@ class vtkPV3Foam
return size_;
}
bool empty() const
{
return (size_ == 0);
}
void reset()
{
start_ = -1;

View File

@ -147,14 +147,14 @@ int USERD_set_filenames
bool lagrangianNamesFound = false;
label n = 0;
while ((!lagrangianNamesFound) && (n<Num_time_steps))
while (!lagrangianNamesFound && n < Num_time_steps)
{
runTime.setTime(TimeList[n+1], n+1);
Cloud<passiveParticle> lagrangian(*meshPtr);
n++;
if (lagrangian.size()>0)
if (lagrangian.size())
{
lagrangianNamesFound = true;
}

View File

@ -4,7 +4,6 @@ nVar -= Num_variables - nSprayVariables;
if (nVar >= 0)
{
word name = lagrangianScalarNames[nVar];
IOField<scalar> s
@ -20,15 +19,9 @@ if (nVar >= 0)
)
);
if (s.size() != 0)
if (s.size())
{
for
(
label n = 0;
n < s.size();
n++
)
for (label n = 0; n < s.size(); n++)
{
var_array[n+1] = s[n];
}
@ -36,7 +29,7 @@ if (nVar >= 0)
}
else
{
//Info << "getLagrangianScalar: nVar = " << nVar << endl;
// Info << "getLagrangianScalar: nVar = " << nVar << endl;
return Z_UNDEF;
}

View File

@ -21,16 +21,10 @@ if (nVar >= 0)
)
);
if (v.size() != 0)
if (v.size())
{
for
(
label n = 0;
n < v.size();
n++
)
for (label n = 0; n < v.size(); n++)
{
if (component == 0)
{
var_array[n+1] = v[n].x();

View File

@ -235,7 +235,7 @@ static void createFieldNames
HashSet<word> surfScalarHash;
HashSet<word> surfVectorHash;
if (setName.size() == 0)
if (setName.empty())
{
forAll(Times, timeI)
{
@ -536,13 +536,12 @@ void user_query_file_function
fileName caseName(rootAndCase.name());
// handle trailing '/'
if (caseName.size() == 0)
if (caseName.empty())
{
caseName = rootDir.name();
rootDir = rootDir.path();
rootDir = rootDir.path();
}
Info<< "rootDir : " << rootDir << endl
<< "caseName : " << caseName << endl
<< "setName : " << setName << endl;

View File

@ -150,7 +150,7 @@ const Foam::fvMesh& Foam::readerDatabase::mesh() const
<< "No mesh set" << abort(FatalError);
}
if (setName_.size() == 0)
if (setName_.empty())
{
return *meshPtr_;
}
@ -265,7 +265,7 @@ void Foam::readerDatabase::loadMesh()
IOobject::AUTO_WRITE
);
if (setName_.size() != 0)
if (setName_.size())
{
Info<< "Subsetting mesh based on cellSet " << setName_ << endl;
@ -294,9 +294,9 @@ Foam::polyMesh::readUpdateState Foam::readerDatabase::setTime
// Update loaded mesh
meshChange = meshPtr_->readUpdate();
if ((setName_.size() != 0) && (meshChange != polyMesh::UNCHANGED))
if (setName_.size() && meshChange != polyMesh::UNCHANGED)
{
Info<< "Subsetting mesh based on " << setName_ << endl;
Info<< "Subsetting mesh based on " << setName_ << endl;
fvMeshSubset& mesh = *meshPtr_;

View File

@ -206,7 +206,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
// Do closer inspection for unmapped particles
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (unmappedSource.size() > 0)
if (unmappedSource.size())
{
meshSearch targetSearcher(meshTarget, false);
@ -237,7 +237,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
Info<< " after additional mesh searching found "
<< targetParcels.size() << " parcels in target mesh." << endl;
if (addParticles.size() > 0)
if (addParticles.size())
{
IOPosition<passiveParticle>(targetParcels).write();

View File

@ -242,9 +242,7 @@ int main(int argc, char *argv[])
}
}
illegalFaces.shrink();
if (illegalFaces.size() > 0)
if (illegalFaces.size())
{
Pout<< "Surface has " << illegalFaces.size()
<< " illegal triangles." << endl;
@ -628,7 +626,7 @@ int main(int argc, char *argv[])
triSurfaceSearch querySurf(surf);
surfaceIntersection inter(querySurf);
if ((inter.cutEdges().size() == 0) && (inter.cutPoints().size() == 0))
if (inter.cutEdges().empty() && inter.cutPoints().empty())
{
Pout<< "Surface is not self-intersecting" << endl;
}

View File

@ -860,7 +860,7 @@ label collapseBase(triSurface& surf, const scalar minLen)
splitWeights
);
if (splitVerts.size() > 0)
if (splitVerts.size())
{
// Split edge using splitVerts. All non-collapsed triangles
// using edge will get split.

View File

@ -49,9 +49,9 @@ void readNASEdges
edgeList& allEdges
)
{
IFstream OBJfile(inFileName);
IFstream is(inFileName);
if (!OBJfile.good())
if (!is.good())
{
FatalErrorIn("readNASEdges")
<< "Cannot read file " << inFileName
@ -68,14 +68,14 @@ void readNASEdges
DynamicList<label> edgeIndices;
while (OBJfile.good())
while (is.good())
{
string line;
OBJfile.getLine(line);
is.getLine(line);
if (line.size() > 0 && line[0] == '$')
if (line.empty() || line[0] == '$')
{
// Skip comment
// Skip empty and comment
continue;
}
@ -87,9 +87,9 @@ void readNASEdges
while (true)
{
string buf;
OBJfile.getLine(buf);
is.getLine(buf);
if (buf.size() > 72 && buf[72]=='+')
if (buf.size() > 72 && buf[72] == '+')
{
line += buf.substr(8, 64);
}

View File

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
word patchName = pp.name();
if (patchName.size() == 0)
if (patchName.empty())
{
patchName = "patch" + Foam::name(patchI);
}

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
meshSubsetDict.lookup("zone")
);
if ((markedZone.size() != 0) && (markedZone.size() != 2))
if (markedZone.size() && markedZone.size() != 2)
{
FatalErrorIn(args.executable())
<< "zone specification should be two points, min and max of "
@ -115,7 +115,7 @@ int main(int argc, char *argv[])
// pick up faces connected to "localPoints"
//
if (markedPoints.size() > 0)
if (markedPoints.size())
{
Info << "Found " << markedPoints.size() << " marked point(s)." << endl;
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
// pick up faces connected to "edges"
//
if (markedEdges.size() > 0)
if (markedEdges.size())
{
Info << "Found " << markedEdges.size() << " marked edge(s)." << endl;
@ -293,7 +293,7 @@ int main(int argc, char *argv[])
// Number of additional faces picked up because of addFaceNeighbours
label nFaceNeighbours = 0;
if (markedFaces.size() > 0)
if (markedFaces.size())
{
Info << "Found " << markedFaces.size() << " marked face(s)." << endl;

View File

@ -63,7 +63,7 @@ int main(int argc, char *argv[])
Info<< "Writing surf to " << outFileName << " ..." << endl;
if (args.options().size() == 0)
if (args.options().empty())
{
FatalErrorIn(args.executable())
<< "No options supplied, please use one or more of "

View File

@ -35,7 +35,7 @@
#------------------------------------------------------------------------------
if [ "$1" = "-h" -o "$1" = "-help" -o "$#" -ne 2 ]
then
cat <<USAGE 1>&2
cat <<USAGE 1>&2
Usage: ${0##*/} srcDir dstDir
Copy OpenFOAM settings from one case to another, without copying
@ -46,30 +46,23 @@ USAGE
exit 1
fi
srcDir=$1
dstDir=$2
srcDir=${1%/}
dstDir=${2%/}
if [ ! -d $srcDir ]
then
echo "Error: directory '$srcDir' does not exist"
exit 1
fi
if [ ! -d $dstDir ]
then
echo "Error: directory '$dstDir' does not exist"
exit 1
fi
for i in $srcDir $dstDir
do
[ -d "$i" ] || { echo "Error: directory '$i' does not exist"; exit 1; }
done
# check that the srcDir looks okay
for i in $srcDir/constant $srcDir/system
do
if [ ! -d $i ]
then
echo "Error: no '${i##*/}' directory in '$srcDir'"
echo " does not appear to be an OpenFOAM case"
exit 1
fi
if [ ! -d "$i" ]
then
echo "Error: no '${i##*/}' directory in '$srcDir'"
echo " does not appear to be an OpenFOAM case"
exit 1
fi
done
# files and directories to copy
@ -82,19 +75,19 @@ fileList=$(find -H $srcDir -mindepth 1 -maxdepth 1 -not -name "processor*")
for i in $fileList
do
name="${i##*/}"
# skip numerical (results) directories (except 0)
# and things that look like queuing system output or log files
case "$name" in
[1-9] | [0-9]?* | foam.[eo][1-9]* | log | *.log )
echo "$i [skipped]"
continue
;;
*)
echo "$i -> $dstDir/$name"
rsync --exclude polyMesh --exclude "processor*" -a $i $dstDir
;;
esac
name="${i##*/}"
# skip numerical (results) directories (except 0)
# and things that look like log files or queuing system output
case "$name" in
[1-9] | [0-9]?* | log | *.log | foam.[eo][1-9]* )
echo "$i [skipped]"
continue
;;
*)
echo "$i -> $dstDir/$name"
rsync --exclude polyMesh --exclude "processor*" -a $i $dstDir
;;
esac
done
# --------------------------------------------------------------- end-of-file

View File

@ -36,9 +36,10 @@ export WM_PROJECT=OpenFOAM
# export WM_PROJECT_VERSION=1.5.x
: ${WM_PROJECT_VERSION:=dev}; export WM_PROJECT_VERSION
#!!User:
# either set $FOAM_INST_DIR before sourcing this file or set
################################################################################
# USER EDITABLE PART
#
# either set $FOAM_INST_DIR before sourcing this file or set
# $foamInstall below to where OpenFOAM is installed
#
# Location of FOAM installation
@ -47,9 +48,22 @@ foamInstall=$HOME/$WM_PROJECT
# foamInstall=~$WM_PROJECT
# foamInstall=/usr/local/$WM_PROJECT
# foamInstall=/opt/$WM_PROJECT
#
# END OF (NORMAL) USER EDITABLE PART
################################################################################
# note the location for later use (eg, in job scripts)
: ${FOAM_INST_DIR:=$foamInstall}; export FOAM_INST_DIR
# The old dirs to be cleaned from the various environment variables
# - remove anything under top-level directory.
# NB: the WM_PROJECT_INST_DIR might not be identical between versions
foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$USER"
if [ "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ]
then
foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs"
fi
# Location of site/user files
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -169,21 +183,18 @@ USAGE
esac
# Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
# Remove anything under top-level foam directory
wildCards="$WM_PROJECT_INST_DIR $HOME/$WM_PROJECT/$USER"
#- Clean path/PATH
cleanPath=`$cleanProg "$PATH" "$wildCards"` && PATH="$cleanPath"
#- Clean PATH
cleanEnv=`$cleanProg "$PATH" "$foamOldDirs"` && PATH="$cleanEnv"
#- Clean LD_LIBRARY_PATH
cleanPath=`$cleanProg "$LD_LIBRARY_PATH" "$wildCards"` && LD_LIBRARY_PATH="$cleanPath"
cleanEnv=`$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleanEnv"
#- Clean MANPATH
cleanPath=`$cleanProg "$MANPATH" "$wildCards"` && MANPATH="$cleanPath"
cleanEnv=`$cleanProg "$MANPATH" "$foamCleanDirs"` && MANPATH="$cleanEnv"
export PATH LD_LIBRARY_PATH MANPATH
@ -212,29 +223,30 @@ _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
_foamSource $WM_PROJECT_DIR/etc/apps/cint/bashrc
# Again clean environment (path, PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#- Clean path/PATH. Only remove duplicates
cleanPath=`$cleanProg "$PATH"` && PATH="$cleanPath"
# Clean environment paths again. Only remove duplicates
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#- Clean PATH
cleanEnv=`$cleanProg "$PATH"` && PATH="$cleanEnv"
#- Clean LD_LIBRARY_PATH
cleanPath=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanPath"
cleanEnv=`$cleanProg "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleanEnv"
#- Clean MANPATH
cleanPath=`$cleanProg "$MANPATH"` && MANPATH="$cleanPath"
cleanEnv=`$cleanProg "$MANPATH"` && MANPATH="$cleanEnv"
export PATH LD_LIBRARY_PATH MANPATH
#- Clean LD_PRELOAD
if [ "$LD_PRELOAD" != "" ]; then
cleanPath=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanPath"
if [ "$LD_PRELOAD" != "" ]
then
cleanEnv=`$cleanProg "$LD_PRELOAD"` && LD_PRELOAD="$cleanEnv"
export LD_PRELOAD
fi
# cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~
unset cleanPath cleanProg foamInstall
unset cleanEnv cleanProg foamInstall foamOldDirs
unset _foamSource
# -----------------------------------------------------------------------------

View File

@ -688,7 +688,6 @@ DebugSwitches
steadyState 0;
stl 0;
stochasticDispersionRAS 0;
string 0;
supersonicFreestream 0;
surfaceFeatures 0;
surfaceInterpolation 0;

View File

@ -35,7 +35,9 @@ setenv WM_PROJECT OpenFOAM
# setenv WM_PROJECT_VERSION 1.5.x
if ( ! $?WM_PROJECT_VERSION ) setenv WM_PROJECT_VERSION dev
#!!User:
################################################################################
# USER EDITABLE PART
#
# either setenv FOAM_INST_DIR before sourcing this file or set
# foamInstall below to where OpenFOAM is installed
#
@ -45,9 +47,17 @@ set foamInstall = $HOME/$WM_PROJECT
# set foamInstall = ~$WM_PROJECT
# set foamInstall = /usr/local/$WM_PROJECT
# set foamInstall = /opt/$WM_PROJECT
#
# END OF (NORMAL) USER EDITABLE PART
################################################################################
# note the location for later use (eg, in job scripts)
if ( ! $?FOAM_INST_DIR ) setenv FOAM_INST_DIR $foamInstall
# The old dirs to be cleaned from the various environment variables
# - remove anything under top-level directory.
# NB: the WM_PROJECT_INST_DIR might not be identical between versions
set foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$LOGNAME"
# Location of site/user files
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -165,8 +175,8 @@ default:
endsw
# Clean standard environment variables (path, PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Clean standard environment variables (path/PATH, LD_LIBRARY_PATH, MANPATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set cleanProg=$WM_PROJECT_DIR/bin/foamCleanPath
if (! $?LD_LIBRARY_PATH ) then
@ -176,21 +186,18 @@ if (! $?MANPATH) then
setenv MANPATH ''
endif
# Remove anything under top-level foam directory
set wildCards="$WM_PROJECT_INST_DIR $HOME/$WM_PROJECT/$LOGNAME"
#- Clean path/PATH
set colonPath=`echo "$path" | sed -e 's/ /:/g'`
set PATH=`$cleanProg "$colonPath" "$wildCards"`
set cleanEnv=`$cleanProg "$colonPath" "$foamOldDirs"`
if ( $status == 0 ) then
set path=`echo "$PATH" | sed -e 's/:/ /g'`
set path=`echo "$cleanEnv" | sed -e 's/:/ /g'`
endif
#- Clean LD_LIBRARY_PATH
setenv LD_LIBRARY_PATH `$cleanProg "$LD_LIBRARY_PATH" "$wildCards"`
setenv LD_LIBRARY_PATH `$cleanProg "$LD_LIBRARY_PATH" "$foamOldDirs"`
#- Clean MANPATH
setenv MANPATH `$cleanProg "$MANPATH" "$wildCards"`
setenv MANPATH `$cleanProg "$MANPATH" "$foamOldDirs"`
# Source project setup files
@ -205,15 +212,16 @@ _foamSource $WM_PROJECT_DIR/etc/aliases.csh
# _foamSource $WM_PROJECT_DIR/etc/apps/paraview/cshrc
_foamSource $WM_PROJECT_DIR/etc/apps/paraview3/cshrc
# _foamSource $WM_PROJECT_DIR/etc/apps/ensight/cshrc
# _foamSource $WM_PROJECT_DIR/etc/apps/cint/cshrc
# Again clean environment (path, PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#- Clean path/PATH. Only remove duplicates
# Clean environment paths again. Only remove duplicates
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#- Clean path/PATH
set colonPath=`echo "$path" | sed -e 's/ /:/g'`
set PATH=`$cleanProg "$colonPath"`
set cleanEnv=`$cleanProg "$colonPath"`
if ( $status == 0 ) then
set path=`echo "$PATH" | sed -e 's/:/ /g'`
set path=`echo "$cleanEnv" | sed -e 's/:/ /g'`
endif
#- Clean LD_LIBRARY_PATH
@ -229,8 +237,7 @@ endif
# cleanup environment:
# ~~~~~~~~~~~~~~~~~~~~
unset cleanProg
unset wildCards
unset colonPath
unset cleanEnv cleanProg colonPath foamInstall foamOldDirs
unalias _foamSource
# -----------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
cd ${0%/*} || exit 1 # run from this directory
set -x
# update Foam::FOAMversion string if required
# update OpenFOAM version strings if required
wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null
wmakeLnInclude -f OpenFOAM

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
UNIX versions of the functions declated in OSspecific.H.
UNIX versions of the functions declared in OSspecific.H.
\*---------------------------------------------------------------------------*/
@ -284,7 +284,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
bool Foam::mkDir(const fileName& pathName, mode_t mode)
{
// empty names are meaningless
if (!pathName.size())
if (pathName.empty())
{
return false;
}
@ -491,7 +491,7 @@ bool Foam::dir(const fileName& name)
// Return size of file
off_t Foam::size(const fileName& name)
off_t Foam::fileSize(const fileName& name)
{
fileStat fileStatus(name);
if (fileStatus.isValid())
@ -541,7 +541,7 @@ Foam::fileNameList Foam::readDir
// Setup empty string list MAXTVALUES long
fileNameList dirEntries(maxNnames);
// Pointers to the Unix director system
// Pointers to the directory entries
DIR *source;
struct dirent *list;
@ -567,10 +567,10 @@ Foam::fileNameList Foam::readDir
{
fileName fName(list->d_name);
// ignore files begining with ., i.e. ., .. and .??*
if (fName.size() > 0 && fName[size_t(0)] != '.')
// ignore files begining with ., i.e. '.', '..' and '.*'
if (fName.size() && fName[0] != '.')
{
word fileNameExt = fName.ext();
word fExt = fName.ext();
if
(
@ -578,11 +578,11 @@ Foam::fileNameList Foam::readDir
||
(
type == fileName::FILE
&& fName[fName.size()-1] != '~'
&& fileNameExt != "bak"
&& fileNameExt != "BAK"
&& fileNameExt != "old"
&& fileNameExt != "save"
&& fName[fName.size()-1] != '~'
&& fExt != "bak"
&& fExt != "BAK"
&& fExt != "old"
&& fExt != "save"
)
)
{
@ -593,7 +593,7 @@ Foam::fileNameList Foam::readDir
dirEntries.setSize(dirEntries.size() + maxNnames);
}
if (filtergz && fileNameExt == "gz")
if (filtergz && fExt == "gz")
{
dirEntries[nEntries++] = fName.lessExt();
}
@ -616,17 +616,17 @@ Foam::fileNameList Foam::readDir
}
// Copy, recursively if necessary, the source top the destination
// Copy, recursively if necessary, the source to the destination
bool Foam::cp(const fileName& src, const fileName& dest)
{
fileName destFile(dest);
// Make sure source exists.
if (!exists(src))
{
return false;
}
fileName destFile(dest);
// Check type of source file.
if (src.type() == fileName::FILE)
{
@ -676,7 +676,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
destFile = destFile/src.component(src.components().size() -1);
}
// Make sure the destination directory extists.
// Make sure the destination directory exists.
if (!dir(destFile) && !mkDir(destFile))
{
return false;
@ -806,7 +806,7 @@ bool Foam::rmDir(const fileName& directory)
<< "removing directory " << directory << endl;
}
// Pointers to the Unix director system
// Pointers to the directory entries
DIR *source;
struct dirent *list;

View File

@ -149,7 +149,7 @@ void getSymbolForRaw
const word& address
)
{
if (filename.size() > 0 && filename[0] == '/')
if (filename.size() && filename[0] == '/')
{
string fcnt = pOpen
(
@ -189,7 +189,7 @@ void error::printStack(Ostream& os)
string::size_type space = line.rfind(' ') + 1;
fileName libPath = line.substr(space, line.size()-space);
if (libPath.size() > 0 && libPath[0] == '/')
if (libPath.size() && libPath[0] == '/')
{
string offsetString(line.substr(0, line.find('-')));
IStringStream offsetStr(offsetString);
@ -217,7 +217,7 @@ void error::printStack(Ostream& os)
string::size_type lPos = msg.find('[');
string::size_type rPos = msg.find(']');
if (lPos != string::npos && rPos != string::npos && lPos<rPos)
if (lPos != string::npos && rPos != string::npos && lPos < rPos)
{
address = msg.substr(lPos+1, rPos-lPos-1);
msg = msg.substr(0, lPos);
@ -232,7 +232,7 @@ void error::printStack(Ostream& os)
// not an absolute path
if (programFile[0] != '/')
{
string tmp = pOpen("which "+programFile);
string tmp = pOpen("which " + programFile);
if (tmp[0] == '/' || tmp[0] == '~')
{
programFile = tmp;
@ -243,13 +243,13 @@ void error::printStack(Ostream& os)
string::size_type bracketPos = msg.find('(');
if (bracketPos != string::size_type(string::npos))
if (bracketPos != string::npos)
{
string::size_type start = bracketPos+1;
string::size_type plusPos = msg.find('+', start);
if (plusPos != string::size_type(string::npos))
if (plusPos != string::npos)
{
string cName(msg.substr(start, plusPos-start));
@ -276,7 +276,7 @@ void error::printStack(Ostream& os)
{
string::size_type endBracketPos = msg.find(')', start);
if (endBracketPos != string::size_type(string::npos))
if (endBracketPos != string::npos)
{
string fullName(msg.substr(start, endBracketPos-start));

View File

@ -51,21 +51,15 @@ class Ostream;
template<class T, class Key, class Hash> class HashPtrTable;
template<class T, class Key, class Hash> Istream& operator>>
(
Istream&,
HashPtrTable<T, Key, Hash>&
);
template<class T, class Key, class Hash>
Istream& operator>>(Istream&, HashPtrTable<T, Key, Hash>&);
template<class T, class Key, class Hash> Ostream& operator<<
(
Ostream&,
const HashPtrTable<T, Key, Hash>&
);
template<class T, class Key, class Hash>
Ostream& operator<<(Ostream&, const HashPtrTable<T, Key, Hash>&);
/*---------------------------------------------------------------------------*\
Class HashPtrTable Declaration
Class HashPtrTable Declaration
\*---------------------------------------------------------------------------*/
template<class T, class Key=word, class Hash=string::hash>

View File

@ -32,19 +32,19 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Key, class Hash>
template<class T>
Foam::HashSet<Key, Hash>::HashSet(const HashTable<T, Key, Hash>& ht)
template<class AnyType>
Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& ht)
:
HashTable<empty, Key, Hash>(ht.size())
HashTable<nil, Key, Hash>(ht.size())
{
for
(
typename HashTable<T, Key, Hash>::const_iterator iter = ht.begin();
iter != ht.end();
++iter
typename HashTable<AnyType, Key, Hash>::const_iterator cit = ht.begin();
cit != ht.end();
++cit
)
{
insert(iter.key());
insert(cit.key());
}
}
@ -126,6 +126,7 @@ void Foam::HashSet<Key, Hash>::operator^=(const HashSet<Key, Hash>& rhs)
}
// same as HashTable::erase()
template<class Key, class Hash>
void Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs)
{

View File

@ -46,7 +46,7 @@ Description
#define HashSet_H
#include "HashTable.H"
#include "empty.H"
#include "nil.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -60,13 +60,13 @@ namespace Foam
template<class Key=word, class Hash=string::hash>
class HashSet
:
public HashTable<empty, Key, Hash>
public HashTable<nil, Key, Hash>
{
public:
typedef typename HashTable<empty, Key, Hash>::iterator iterator;
typedef typename HashTable<empty, Key, Hash>::const_iterator const_iterator;
typedef typename HashTable<nil, Key, Hash>::iterator iterator;
typedef typename HashTable<nil, Key, Hash>::const_iterator const_iterator;
// Constructors
@ -74,19 +74,19 @@ public:
//- Construct given initial size
HashSet(label size = 100)
:
HashTable<empty, Key, Hash>(size)
HashTable<nil, Key, Hash>(size)
{}
//- Construct from Istream
HashSet(Istream& is)
:
HashTable<empty, Key, Hash>(is)
HashTable<nil, Key, Hash>(is)
{}
//- Construct from UList of Key
HashSet(const UList<Key>& lst)
:
HashTable<empty, Key, Hash>(2*lst.size())
HashTable<nil, Key, Hash>(2*lst.size())
{
forAll(lst, i)
{
@ -97,24 +97,25 @@ public:
//- Construct as copy
HashSet(const HashSet<Key, Hash>& hs)
:
HashTable<empty, Key, Hash>(hs)
HashTable<nil, Key, Hash>(hs)
{}
//- Construct by transferring the parameter contents
HashSet(const Xfer<HashSet<Key, Hash> >& hs)
:
HashTable<empty, Key, Hash>(hs)
HashTable<nil, Key, Hash>(hs)
{}
//- Construct by transferring the parameter contents
HashSet(const Xfer<HashTable<empty, Key, Hash> >& hs)
HashSet(const Xfer<HashTable<nil, Key, Hash> >& hs)
:
HashTable<empty, Key, Hash>(hs)
HashTable<nil, Key, Hash>(hs)
{}
//- Construct from table of contents of the HashTable
template<class T>
HashSet(const HashTable<T, Key, Hash>& ht);
//- Construct from the keys of another HashTable,
// the type of values held is arbitrary.
template<class AnyType>
HashSet(const HashTable<AnyType, Key, Hash>&);
// Member Functions
@ -123,13 +124,13 @@ public:
//- Insert a new entry
bool insert(const Key& key)
{
return HashTable<empty, Key, Hash>::insert(key, empty());
return HashTable<nil, Key, Hash>::insert(key, nil());
}
//- Same as insert (cannot overwrite empty content)
//- Same as insert (cannot overwrite nil content)
bool set(const Key& key)
{
return HashTable<empty, Key, Hash>::insert(key, empty());
return HashTable<nil, Key, Hash>::insert(key, nil());
}

View File

@ -388,11 +388,11 @@ bool Foam::HashTable<T, Key, Hash>::erase(const iterator& cit)
template<class T, class Key, class Hash>
bool Foam::HashTable<T, Key, Hash>::erase(const Key& key)
{
iterator it = find(key);
iterator fnd = find(key);
if (it != end())
if (fnd != end())
{
return erase(it);
return erase(fnd);
}
else
{
@ -401,6 +401,53 @@ bool Foam::HashTable<T, Key, Hash>::erase(const Key& key)
}
template<class T, class Key, class Hash>
Foam::label Foam::HashTable<T, Key, Hash>::erase(const UList<Key>& keys)
{
label count = 0;
// Remove listed keys from this table
if (this->size())
{
forAll(keys, keyI)
{
if (erase(keys[keyI]))
{
count++;
}
}
}
return count;
}
template<class T, class Key, class Hash>
template<class AnyType>
Foam::label Foam::HashTable<T, Key, Hash>::erase
(
const HashTable<AnyType, Key, Hash>& rhs
)
{
label count = 0;
// Remove rhs elements from this table
if (this->size())
{
// NOTE: could further optimize depending on which hash is smaller
for (iterator iter = begin(); iter != end(); ++iter)
{
if (rhs.found(iter.key()) && erase(iter))
{
count++;
}
}
}
return count;
}
template<class T, class Key, class Hash>
void Foam::HashTable<T, Key, Hash>::resize(const label newSize)
{

View File

@ -51,20 +51,15 @@ namespace Foam
// Forward declaration of friend functions and operators
template<class T> class List;
template<class T> class UList;
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>>
(
Istream&,
HashTable<T, Key, Hash>&
);
template<class T, class Key, class Hash>
Istream& operator>>(Istream&, HashTable<T, Key, Hash>&);
template<class T, class Key, class Hash> Ostream& operator<<
(
Ostream&,
const HashTable<T, Key, Hash>&
);
template<class T, class Key, class Hash>
Ostream& operator<<(Ostream&, const HashTable<T, Key, Hash>&);
/*---------------------------------------------------------------------------*\
@ -171,6 +166,9 @@ public:
//- Return number of elements in table.
inline label size() const;
//- Return true if the hash table is empty
inline bool empty() const;
//- Return true if hashedEntry is found in table
bool found(const Key&) const;
@ -200,6 +198,17 @@ public:
//- Erase an hashedEntry specified by given key if in table
bool erase(const Key&);
//- Remove entries given by the listed keys from this HashTable
// Return the number of elements removed
label erase(const UList<Key>&);
//- Remove entries given by the given keys from this HashTable
// Return the number of elements removed.
// The parameter HashTable needs the same type of keys, but
// but the type of values held is arbitrary.
template<class AnyType>
label erase(const HashTable<AnyType, Key, Hash>&);
//- Resize the hash table for efficiency
void resize(const label newSize);

View File

@ -51,6 +51,13 @@ inline Foam::label Foam::HashTable<T, Key, Hash>::size() const
}
template<class T, class Key, class Hash>
inline bool Foam::HashTable<T, Key, Hash>::empty() const
{
return (nElmts_ == 0);
}
template<class T, class Key, class Hash>
inline bool Foam::HashTable<T, Key, Hash>::insert
(

View File

@ -346,6 +346,28 @@ bool Foam::StaticHashTable<T, Key, Hash>::erase(const Key& key)
}
template<class T, class Key, class Hash>
Foam::label Foam::StaticHashTable<T, Key, Hash>::erase
(
const StaticHashTable<T, Key, Hash>& rhs
)
{
label count = 0;
// Remove rhs elements from this table
// NOTE: could optimize depending on which hash is smaller
for (iterator iter = this->begin(); iter != this->end(); ++iter)
{
if (rhs.found(iter.key()) && erase(iter))
{
count++;
}
}
return count;
}
template<class T, class Key, class Hash>
void Foam::StaticHashTable<T, Key, Hash>::resize(const label newSize)
{
@ -454,8 +476,8 @@ void Foam::StaticHashTable<T, Key, Hash>::operator=
}
// could be zero-sized from a previous transfer()
if (keys_.size() == 0)
// keys could be empty from a previous transfer()
if (keys_.empty())
{
keys_.setSize(rhs.keys_.size());
objects_.setSize(keys_.size());

View File

@ -164,6 +164,9 @@ public:
//- Return number of elements in table.
inline label size() const;
//- Return true if the hash table is empty
inline bool empty() const;
//- Return true if hashed entry is found in table
bool found(const Key& key) const;
@ -196,6 +199,10 @@ public:
//- Resize the hash table for efficiency
void resize(const label newSize);
//- Remove entries in the given hash table from this hash table
// Return the number of elements removed
label erase(const StaticHashTable<T, Key, Hash>&);
//- Clear all entries from table
void clear();

View File

@ -38,6 +38,13 @@ inline Foam::label Foam::StaticHashTable<T, Key, Hash>::size() const
}
template<class T, class Key, class Hash>
inline bool Foam::StaticHashTable<T, Key, Hash>::empty() const
{
return (nElmts_ == 0);
}
template<class T, class Key, class Hash>
inline bool Foam::StaticHashTable<T, Key, Hash>::insert
(
@ -321,7 +328,7 @@ Foam::StaticHashTable<T, Key, Hash>::begin()
// Find first non-empty entry
forAll(keys_, hashIdx)
{
if (keys_[hashIdx].size() > 0)
if (keys_[hashIdx].size())
{
return iterator(*this, hashIdx, 0);
}
@ -353,7 +360,7 @@ Foam::StaticHashTable<T, Key, Hash>::begin() const
// Find first non-empty entry
forAll(keys_, hashIdx)
{
if (keys_[hashIdx].size() > 0)
if (keys_[hashIdx].size())
{
return const_iterator(*this, hashIdx, 0);
}

View File

@ -122,6 +122,9 @@ public:
//- Return number of elements in list
inline label size() const;
//- Return true if the list is empty
inline bool empty() const;
//- Return first entry
inline link* first();

View File

@ -81,6 +81,12 @@ inline Foam::label Foam::DLListBase::size() const
}
inline bool Foam::DLListBase::empty() const
{
return (nElmts_ == 0);
}
inline Foam::DLListBase::link*
Foam::DLListBase::first()
{

View File

@ -119,6 +119,9 @@ public:
//- Return number of elements in list
inline label size() const;
//- Return true if the list is empty
inline bool empty() const;
//- Return first entry
inline link* first();

View File

@ -71,6 +71,12 @@ inline Foam::label Foam::SLListBase::size() const
}
inline bool Foam::SLListBase::empty() const
{
return (nElmts_ == 0);
}
inline Foam::SLListBase::link*
Foam::SLListBase::first()
{

View File

@ -92,15 +92,6 @@ public:
}
// Check
//- Is the stack empty
bool empty() const
{
return this->size() == 0;
}
// Edit
//- Push an element onto the stack

View File

@ -92,15 +92,6 @@ public:
}
// Check
//- Is the stack empty
bool empty() const
{
return this->size() == 0;
}
// Edit
//- Push an element onto the stack

Some files were not shown because too many files have changed in this diff Show More