mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -119,7 +119,7 @@ scalar StCoNum = 0.0;
|
||||
fvc::makeAbsolute(phi, rho, U);
|
||||
|
||||
// Test : disable refinement for some cells
|
||||
PackedList<1>& protectedCell =
|
||||
PackedBoolList& protectedCell =
|
||||
refCast<dynamicRefineFvMesh>(mesh).protectedCell();
|
||||
|
||||
if (protectedCell.empty())
|
||||
|
||||
@ -395,7 +395,7 @@ Foam::laminarFlameSpeedModels::SCOPE::Ma() const
|
||||
(
|
||||
"Ma",
|
||||
mesh.time().timeName(),
|
||||
mesh.db(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
|
||||
@ -160,6 +160,19 @@ int main(int argc, char *argv[])
|
||||
<< " " << lstB.size() << endl;
|
||||
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
|
||||
<< " " << dlD.size() << "/" << dlD.capacity() << endl;
|
||||
|
||||
DynamicList<label,10> dlE1(10);
|
||||
DynamicList<label> dlE2(dlE1);
|
||||
|
||||
Info<< "<dlE1>" << dlE1 << "</dlE1>" << nl << "sizes: "
|
||||
<< " " << dlE1.size() << "/" << dlE1.capacity() << endl;
|
||||
Info<< "<dlE2>" << dlE2 << "</dlE2>" << nl << "sizes: "
|
||||
<< " " << dlE2.size() << "/" << dlE2.capacity() << endl;
|
||||
|
||||
dlE2.append(100);
|
||||
Info<< "<dlE2>" << dlE2 << "</dlE2>" << endl;
|
||||
|
||||
Info<< "\nEnd\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
3
applications/test/PackedList/Make/files
Normal file
3
applications/test/PackedList/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
PackedListTest.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/PackedListTest
|
||||
0
applications/test/PackedList/Make/options
Normal file
0
applications/test/PackedList/Make/options
Normal file
174
applications/test/PackedList/PackedListTest.C
Normal file
174
applications/test/PackedList/PackedListTest.C
Normal file
@ -0,0 +1,174 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "IOstreams.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool changed;
|
||||
Info<< "PackedList max_bits() = " << PackedList<0>::max_bits() << nl;
|
||||
|
||||
Info<< "\ntest allocation with value\n";
|
||||
PackedList<3> list1(5,1);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest assign uniform value\n";
|
||||
list1 = 2;
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest resize with value (without reallocation)\n";
|
||||
list1.resize(6, 3);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest set() function\n";
|
||||
list1.set(1, 5);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest assign bool\n";
|
||||
list1 = false;
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest assign bool\n";
|
||||
list1 = true;
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest resize without value (with reallocation)\n";
|
||||
list1.resize(12);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest resize with value (with reallocation)\n";
|
||||
list1.resize(25, list1.max_value());
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest resize smaller (should not touch allocation)\n";
|
||||
list1.resize(8);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest append() operation\n";
|
||||
list1.append(2);
|
||||
list1.append(3);
|
||||
list1.append(4);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest reserve() operation\n";
|
||||
list1.reserve(32);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest shrink() operation\n";
|
||||
list1.shrink();
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest setCapacity() operation\n";
|
||||
list1.setCapacity(15);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest setCapacity() operation\n";
|
||||
list1.setCapacity(30);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest operator[] assignment\n";
|
||||
list1[16] = 5;
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest operator[] assignment with auto-vivify\n";
|
||||
list1[36] = list1.max_value();
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest setCapacity smaller\n";
|
||||
list1.setCapacity(32);
|
||||
list1.print(Info);
|
||||
|
||||
// add in some misc values
|
||||
list1[31] = 1;
|
||||
list1[32] = 2;
|
||||
list1[33] = 3;
|
||||
|
||||
Info<< "\ntest iterator\n";
|
||||
PackedList<3>::iterator iter = list1.begin();
|
||||
Info<< "iterator:" << iter() << "\n";
|
||||
iter.print(Info) << "\n";
|
||||
|
||||
Info<< "\ntest iterator operator=\n";
|
||||
changed = (iter = 5);
|
||||
|
||||
Info<< "iterator:" << iter() << "\n";
|
||||
Info<< "changed:" << changed << "\n";
|
||||
changed = (iter = 5);
|
||||
Info<< "changed:" << changed << "\n";
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest get() method\n";
|
||||
Info<< "get(10):" << list1.get(10)
|
||||
<< " and list[10]:" << unsigned(list1[10]) << "\n";
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest iterator indexing\n";
|
||||
Info<< "end() ";
|
||||
list1.end().print(Info) << "\n";
|
||||
|
||||
for (iter = list1[31]; iter != list1.end(); ++iter)
|
||||
{
|
||||
iter.print(Info);
|
||||
}
|
||||
|
||||
Info<< "\ntest operator[] auto-vivify\n";
|
||||
const unsigned int val = list1[45];
|
||||
|
||||
Info<< "list[45]:" << val << "\n";
|
||||
list1.print(Info);
|
||||
|
||||
|
||||
Info<< "\ntest copy constructor + append\n";
|
||||
PackedList<3> list2(list1);
|
||||
list2.append(4);
|
||||
Info<< "source list:\n";
|
||||
list1.print(Info);
|
||||
Info<< "destination list:\n";
|
||||
list2.print(Info);
|
||||
|
||||
Info<< "\ntest pattern that fills all bits\n";
|
||||
PackedList<4> list3(8, 8);
|
||||
list3[list3.size()-2] = 0;
|
||||
list3[list3.size()-1] = list3.max_value();
|
||||
list3.print(Info);
|
||||
|
||||
Info<< "\n\nDone.\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -48,7 +48,7 @@ Description
|
||||
#include "polyMesh.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "mathematicalConstants.H"
|
||||
#include "PackedList.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "SortableList.H"
|
||||
|
||||
using namespace Foam;
|
||||
@ -177,7 +177,7 @@ label mergeEdges
|
||||
|
||||
|
||||
// Return master point edge needs to be collapsed to (or -1)
|
||||
label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e)
|
||||
label edgeMaster(const PackedBoolList& boundaryPoint, const edge& e)
|
||||
{
|
||||
label masterPoint = -1;
|
||||
|
||||
@ -215,7 +215,7 @@ label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e)
|
||||
label collapseSmallEdges
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const PackedList<1>& boundaryPoint,
|
||||
const PackedBoolList& boundaryPoint,
|
||||
const scalar minLen,
|
||||
edgeCollapser& collapser
|
||||
)
|
||||
@ -254,7 +254,7 @@ label collapseSmallEdges
|
||||
label collapseHighAspectFaces
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const PackedList<1>& boundaryPoint,
|
||||
const PackedBoolList& boundaryPoint,
|
||||
const scalar areaFac,
|
||||
const scalar edgeRatio,
|
||||
edgeCollapser& collapser
|
||||
@ -346,7 +346,7 @@ void set(const labelList& elems, const bool val, boolList& status)
|
||||
label simplifyFaces
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const PackedList<1>& boundaryPoint,
|
||||
const PackedBoolList& boundaryPoint,
|
||||
const label minSize,
|
||||
const scalar lenGap,
|
||||
edgeCollapser& collapser
|
||||
@ -485,7 +485,7 @@ int main(int argc, char *argv[])
|
||||
const faceList& faces = mesh.faces();
|
||||
|
||||
// Get all points on the boundary
|
||||
PackedList<1> boundaryPoint(mesh.nPoints(), false);
|
||||
PackedBoolList boundaryPoint(mesh.nPoints());
|
||||
|
||||
label nIntFaces = mesh.nInternalFaces();
|
||||
for (label faceI = nIntFaces; faceI < mesh.nFaces(); faceI++)
|
||||
|
||||
@ -51,7 +51,7 @@ cellShape create3DCellShape
|
||||
static List<const cellModel*> fluentCellModelLookup
|
||||
(
|
||||
7,
|
||||
reinterpret_cast<const cellModel*>(NULL)
|
||||
reinterpret_cast<const cellModel*>(0)
|
||||
);
|
||||
|
||||
fluentCellModelLookup[2] = cellModeller::lookup("tet");
|
||||
|
||||
@ -49,7 +49,7 @@ Description
|
||||
#include "mathematicalConstants.H"
|
||||
#include "polyTopoChange.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "PackedList.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "meshTools.H"
|
||||
#include "OFstream.H"
|
||||
#include "meshDualiser.H"
|
||||
@ -67,7 +67,7 @@ using namespace Foam;
|
||||
void simpleMarkFeatures
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const PackedList<1>& isBoundaryEdge,
|
||||
const PackedBoolList& isBoundaryEdge,
|
||||
const scalar featureAngle,
|
||||
const bool doNotPreserveFaceZones,
|
||||
|
||||
@ -358,7 +358,7 @@ int main(int argc, char *argv[])
|
||||
// Mark boundary edges and points.
|
||||
// (Note: in 1.4.2 we can use the built-in mesh point ordering
|
||||
// facility instead)
|
||||
PackedList<1> isBoundaryEdge(mesh.nEdges());
|
||||
PackedBoolList isBoundaryEdge(mesh.nEdges());
|
||||
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
|
||||
{
|
||||
const labelList& fEdges = mesh.faceEdges()[faceI];
|
||||
|
||||
@ -155,7 +155,7 @@ Foam::label Foam::meshDualiser::findDualCell
|
||||
// from (boundary & feature) point
|
||||
void Foam::meshDualiser::generateDualBoundaryEdges
|
||||
(
|
||||
const PackedList<1>& isBoundaryEdge,
|
||||
const PackedBoolList& isBoundaryEdge,
|
||||
const label pointI,
|
||||
polyTopoChange& meshMod
|
||||
)
|
||||
@ -388,7 +388,7 @@ Foam::label Foam::meshDualiser::addBoundaryFace
|
||||
void Foam::meshDualiser::createFacesAroundEdge
|
||||
(
|
||||
const bool splitFace,
|
||||
const PackedList<1>& isBoundaryEdge,
|
||||
const PackedBoolList& isBoundaryEdge,
|
||||
const label edgeI,
|
||||
const label startFaceI,
|
||||
polyTopoChange& meshMod,
|
||||
@ -907,7 +907,7 @@ void Foam::meshDualiser::setRefinement
|
||||
// Mark boundary edges and points.
|
||||
// (Note: in 1.4.2 we can use the built-in mesh point ordering
|
||||
// facility instead)
|
||||
PackedList<1> isBoundaryEdge(mesh_.nEdges());
|
||||
PackedBoolList isBoundaryEdge(mesh_.nEdges());
|
||||
for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
|
||||
{
|
||||
const labelList& fEdges = mesh_.faceEdges()[faceI];
|
||||
|
||||
@ -49,7 +49,7 @@ SourceFiles
|
||||
#define meshDualiser_H
|
||||
|
||||
#include "DynamicList.H"
|
||||
#include "PackedList.H"
|
||||
#include "PackedBoolList.H"
|
||||
#include "boolList.H"
|
||||
#include "typeInfo.H"
|
||||
|
||||
@ -101,7 +101,7 @@ class meshDualiser
|
||||
// emanating from (boundary & feature) point
|
||||
void generateDualBoundaryEdges
|
||||
(
|
||||
const PackedList<1>&,
|
||||
const PackedBoolList&,
|
||||
const label pointI,
|
||||
polyTopoChange&
|
||||
);
|
||||
@ -144,7 +144,7 @@ class meshDualiser
|
||||
void createFacesAroundEdge
|
||||
(
|
||||
const bool splitFace,
|
||||
const PackedList<1>&,
|
||||
const PackedBoolList&,
|
||||
const label edgeI,
|
||||
const label startFaceI,
|
||||
polyTopoChange&,
|
||||
|
||||
@ -90,13 +90,13 @@ const label sammMesh::shapeFaceLookup[19][9] =
|
||||
List<const cellModel*> sammMesh::sammShapeLookup
|
||||
(
|
||||
256,
|
||||
reinterpret_cast<cellModel*>(NULL)
|
||||
reinterpret_cast<cellModel*>(0)
|
||||
);
|
||||
|
||||
List<const label*> sammMesh::sammAddressingTable
|
||||
(
|
||||
256,
|
||||
reinterpret_cast<label*>(NULL)
|
||||
reinterpret_cast<label*>(0)
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -48,7 +48,7 @@ void starMesh::addRegularCell
|
||||
label regularTypeFlag = -1;
|
||||
|
||||
// grab the shape from the table
|
||||
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
|
||||
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
|
||||
|
||||
if // Tetrahedron
|
||||
(
|
||||
@ -130,7 +130,7 @@ void starMesh::addSAMMcell
|
||||
|
||||
// grab the shape from the table
|
||||
label sammTypeFlag = -1;
|
||||
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
|
||||
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
|
||||
|
||||
switch (typeFlag)
|
||||
{
|
||||
|
||||
@ -82,7 +82,7 @@ topoSetSources
|
||||
// Cells in cell zone
|
||||
zoneToCell
|
||||
{
|
||||
name ".*Zone"; // name of cellZone, wildcards allowed.
|
||||
name ".*Zone"; // Name of cellZone, regular expressions allowed
|
||||
}
|
||||
|
||||
// values of field within certain range
|
||||
@ -102,16 +102,16 @@ topoSetSources
|
||||
// Select based on surface
|
||||
surfaceToCell
|
||||
{
|
||||
file "www.avl.com-geometry.stl";
|
||||
outsidePoints ((-99 -99 -59)); // definition of outside
|
||||
includeCut false; // cells cut by surface
|
||||
includeInside false; // cells not on outside of surf
|
||||
includeOutside false; // cells on outside of surf
|
||||
nearDistance -1; // cells with centre near surf
|
||||
// (set to -1 if not used)
|
||||
curvature 0.9; // cells within nearDistance
|
||||
// and near surf curvature
|
||||
// (set to -100 if not used)
|
||||
file "www.avl.com-geometry.stl";
|
||||
outsidePoints ((-99 -99 -59)); // definition of outside
|
||||
includeCut false; // cells cut by surface
|
||||
includeInside false; // cells not on outside of surf
|
||||
includeOutside false; // cells on outside of surf
|
||||
nearDistance -1; // cells with centre near surf
|
||||
// (set to -1 if not used)
|
||||
curvature 0.9; // cells within nearDistance
|
||||
// and near surf curvature
|
||||
// (set to -100 if not used)
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -60,18 +60,18 @@ topoSetSources
|
||||
// All points in pointzone
|
||||
zoneToPoint
|
||||
{
|
||||
name ".*Zone"; // name of pointZone, wildcards allowed.
|
||||
name ".*Zone"; // name of pointZone, regular expressions allowed
|
||||
}
|
||||
|
||||
// Select based on surface
|
||||
surfaceToPoint
|
||||
{
|
||||
file "www.avl.com-geometry.stl";
|
||||
nearDistance 0.1; // points near to surface
|
||||
includeInside false; // points on inside of surface
|
||||
// (requires closed surface with consistent
|
||||
// normals)
|
||||
includeOutside false; // ,, outside ,,
|
||||
file "www.avl.com-geometry.stl";
|
||||
nearDistance 0.1; // points near to surface
|
||||
includeInside false; // points on inside of surface
|
||||
// (requires closed surface with consistent
|
||||
// normals)
|
||||
includeOutside false; // ,, outside ,,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -30,12 +30,17 @@ Description
|
||||
- any face inbetween differing cellZones (-cellZones)
|
||||
|
||||
Output is:
|
||||
- mesh with multiple regions
|
||||
- mesh with multiple regions or
|
||||
- mesh with cells put into cellZones (-makeCellZones)
|
||||
|
||||
Should work in parallel but cellZone interfaces cannot align with
|
||||
Note:
|
||||
- Should work in parallel but cellZone interfaces cannot align with
|
||||
processor boundaries so use the correct option in decomposition to
|
||||
preserve those interfaces.
|
||||
- If a cell zone gets split into more than one region it can detect
|
||||
the largest matching region (-sloppyCellZones). This will accept any
|
||||
region that covers more than 50% of the zone. It has to be a subset
|
||||
so cannot have any cells in any other zone.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -613,7 +618,7 @@ autoPtr<mapPolyMesh> createRegionMesh
|
||||
"fvSchemes",
|
||||
mesh.time().system(),
|
||||
regionName,
|
||||
mesh.db(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
@ -642,7 +647,7 @@ autoPtr<mapPolyMesh> createRegionMesh
|
||||
"fvSolution",
|
||||
mesh.time().system(),
|
||||
regionName,
|
||||
mesh.db(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
@ -1036,78 +1041,181 @@ EdgeMap<label> addRegionPatches
|
||||
}
|
||||
|
||||
|
||||
// Checks if regionI in cellRegion corresponds to existing zone.
|
||||
label findCorrespondingZone
|
||||
//// Checks if regionI in cellRegion is subset of existing cellZone. Returns -1
|
||||
//// if no zone found, zone otherwise
|
||||
//label findCorrespondingSubZone
|
||||
//(
|
||||
// const cellZoneMesh& cellZones,
|
||||
// const labelList& existingZoneID,
|
||||
// const labelList& cellRegion,
|
||||
// const label regionI
|
||||
//)
|
||||
//{
|
||||
// // Zone corresponding to region. No corresponding zone.
|
||||
// label zoneI = labelMax;
|
||||
//
|
||||
// labelList regionCells = findIndices(cellRegion, regionI);
|
||||
//
|
||||
// if (regionCells.empty())
|
||||
// {
|
||||
// // My local portion is empty. Maps to any empty cellZone. Mark with
|
||||
// // special value which can get overwritten by other processors.
|
||||
// zoneI = -1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Get zone for first element.
|
||||
// zoneI = existingZoneID[regionCells[0]];
|
||||
//
|
||||
// if (zoneI == -1)
|
||||
// {
|
||||
// zoneI = labelMax;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 1. All regionCells in zoneI?
|
||||
// forAll(regionCells, i)
|
||||
// {
|
||||
// if (existingZoneID[regionCells[i]] != zoneI)
|
||||
// {
|
||||
// zoneI = labelMax;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Determine same zone over all processors.
|
||||
// reduce(zoneI, maxOp<label>());
|
||||
//
|
||||
// if (zoneI == labelMax)
|
||||
// {
|
||||
// // Cells in region that are not in zoneI
|
||||
// zoneI = -1;
|
||||
// }
|
||||
//
|
||||
// return zoneI;
|
||||
//}
|
||||
|
||||
|
||||
//XXXXXXXXX
|
||||
// Find region that covers most of cell zone
|
||||
label findCorrespondingRegion
|
||||
(
|
||||
const cellZoneMesh& cellZones,
|
||||
const labelList& existingZoneID,
|
||||
const labelList& cellRegion,
|
||||
const label regionI
|
||||
const labelList& existingZoneID, // per cell the (unique) zoneID
|
||||
const regionSplit& cellRegion,
|
||||
const label zoneI,
|
||||
const label minOverlapSize
|
||||
)
|
||||
{
|
||||
// Zone corresponding to region. No corresponding zone.
|
||||
label zoneI = labelMax;
|
||||
// Per region the number of cells in zoneI
|
||||
labelList cellsInZone(cellRegion.nRegions(), 0);
|
||||
|
||||
labelList regionCells = findIndices(cellRegion, regionI);
|
||||
|
||||
if (regionCells.empty())
|
||||
forAll(cellRegion, cellI)
|
||||
{
|
||||
// My local portion is empty. Maps to any empty cellZone. Mark with
|
||||
// special value which can get overwritten by other processors.
|
||||
zoneI = -1;
|
||||
if (existingZoneID[cellI] == zoneI)
|
||||
{
|
||||
cellsInZone[cellRegion[cellI]]++;
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(cellsInZone, plusEqOp<label>());
|
||||
Pstream::listCombineScatter(cellsInZone);
|
||||
|
||||
// Pick region with largest overlap of zoneI
|
||||
label regionI = findMax(cellsInZone);
|
||||
|
||||
|
||||
if (cellsInZone[regionI] < minOverlapSize)
|
||||
{
|
||||
// Region covers too little of zone. Not good enough.
|
||||
regionI = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get zone for first element.
|
||||
zoneI = existingZoneID[regionCells[0]];
|
||||
|
||||
if (zoneI == -1)
|
||||
// Check that region contains no cells that aren't in cellZone.
|
||||
forAll(cellRegion, cellI)
|
||||
{
|
||||
zoneI = labelMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1. All regionCells in zoneI?
|
||||
forAll(regionCells, i)
|
||||
if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI)
|
||||
{
|
||||
if (existingZoneID[regionCells[i]] != zoneI)
|
||||
{
|
||||
zoneI = labelMax;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Determine same zone over all processors.
|
||||
reduce(zoneI, maxOp<label>());
|
||||
|
||||
|
||||
// 2. All of cellZone present?
|
||||
|
||||
if (zoneI == labelMax)
|
||||
{
|
||||
zoneI = -1;
|
||||
}
|
||||
else if (zoneI != -1)
|
||||
{
|
||||
const cellZone& cz = cellZones[zoneI];
|
||||
|
||||
forAll(cz, i)
|
||||
{
|
||||
if (cellRegion[cz[i]] != regionI)
|
||||
{
|
||||
zoneI = -1;
|
||||
// cellI in regionI but not in zoneI
|
||||
regionI = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If one in error, all should be in error. Note that branch gets taken
|
||||
// on all procs.
|
||||
reduce(zoneI, minOp<label>());
|
||||
reduce(regionI, minOp<label>());
|
||||
}
|
||||
|
||||
return zoneI;
|
||||
return regionI;
|
||||
}
|
||||
//XXXXXXXXX
|
||||
|
||||
|
||||
//// Checks if cellZone has corresponding cellRegion.
|
||||
//label findCorrespondingRegion
|
||||
//(
|
||||
// const cellZoneMesh& cellZones,
|
||||
// const labelList& existingZoneID, // per cell the (unique) zoneID
|
||||
// const regionSplit& cellRegion,
|
||||
// const label zoneI
|
||||
//)
|
||||
//{
|
||||
// // Region corresponding to zone. Start off with special value: no
|
||||
// // corresponding region.
|
||||
// label regionI = labelMax;
|
||||
//
|
||||
// const cellZone& cz = cellZones[zoneI];
|
||||
//
|
||||
// if (cz.empty())
|
||||
// {
|
||||
// // My local portion is empty. Maps to any empty cellZone. Mark with
|
||||
// // special value which can get overwritten by other processors.
|
||||
// regionI = -1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// regionI = cellRegion[cz[0]];
|
||||
//
|
||||
// forAll(cz, i)
|
||||
// {
|
||||
// if (cellRegion[cz[i]] != regionI)
|
||||
// {
|
||||
// regionI = labelMax;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Determine same zone over all processors.
|
||||
// reduce(regionI, maxOp<label>());
|
||||
//
|
||||
//
|
||||
// // 2. All of region present?
|
||||
//
|
||||
// if (regionI == labelMax)
|
||||
// {
|
||||
// regionI = -1;
|
||||
// }
|
||||
// else if (regionI != -1)
|
||||
// {
|
||||
// forAll(cellRegion, cellI)
|
||||
// {
|
||||
// if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI)
|
||||
// {
|
||||
// // cellI in regionI but not in zoneI
|
||||
// regionI = -1;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// // If one in error, all should be in error. Note that branch gets taken
|
||||
// // on all procs.
|
||||
// reduce(regionI, minOp<label>());
|
||||
// }
|
||||
//
|
||||
// return regionI;
|
||||
//}
|
||||
|
||||
|
||||
// Main program:
|
||||
@ -1120,6 +1228,8 @@ int main(int argc, char *argv[])
|
||||
argList::validOptions.insert("largestOnly", "");
|
||||
argList::validOptions.insert("insidePoint", "point");
|
||||
argList::validOptions.insert("overwrite", "");
|
||||
argList::validOptions.insert("detectOnly", "");
|
||||
argList::validOptions.insert("sloppyCellZones", "");
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
@ -1134,10 +1244,13 @@ int main(int argc, char *argv[])
|
||||
<< blockedFacesName << nl << endl;
|
||||
}
|
||||
|
||||
bool makeCellZones = args.options().found("makeCellZones");
|
||||
bool largestOnly = args.options().found("largestOnly");
|
||||
bool insidePoint = args.options().found("insidePoint");
|
||||
bool useCellZones = args.options().found("cellZones");
|
||||
bool overwrite = args.options().found("overwrite");
|
||||
bool detectOnly = args.options().found("detectOnly");
|
||||
bool sloppyCellZones = args.options().found("sloppyCellZones");
|
||||
|
||||
if (insidePoint && largestOnly)
|
||||
{
|
||||
@ -1281,6 +1394,31 @@ int main(int argc, char *argv[])
|
||||
Info<< "Writing region per cell file (for manual decomposition) to "
|
||||
<< cellToRegion.objectPath() << nl << endl;
|
||||
}
|
||||
// Write for postprocessing
|
||||
{
|
||||
volScalarField cellToRegion
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"cellToRegion",
|
||||
mesh.facesInstance(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("zero", dimless, 0)
|
||||
);
|
||||
forAll(cellRegion, cellI)
|
||||
{
|
||||
cellToRegion[cellI] = cellRegion[cellI];
|
||||
}
|
||||
cellToRegion.write();
|
||||
|
||||
Info<< "Writing region per cell as volScalarField to "
|
||||
<< cellToRegion.objectPath() << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
// Sizes per region
|
||||
@ -1307,40 +1445,131 @@ int main(int argc, char *argv[])
|
||||
Info<< endl;
|
||||
|
||||
|
||||
// Sizes per cellzone
|
||||
// ~~~~~~~~~~~~~~~~~~
|
||||
|
||||
labelList zoneSizes(cellZones.size(), 0);
|
||||
if (useCellZones || makeCellZones || sloppyCellZones)
|
||||
{
|
||||
List<wordList> zoneNames(Pstream::nProcs());
|
||||
zoneNames[Pstream::myProcNo()] = cellZones.names();
|
||||
Pstream::gatherList(zoneNames);
|
||||
Pstream::scatterList(zoneNames);
|
||||
|
||||
forAll(zoneNames, procI)
|
||||
{
|
||||
if (zoneNames[procI] != zoneNames[0])
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "cellZones not synchronised across processors." << endl
|
||||
<< "Master has cellZones " << zoneNames[0] << endl
|
||||
<< "Processor " << procI
|
||||
<< " has cellZones " << zoneNames[procI]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
forAll(cellZones, zoneI)
|
||||
{
|
||||
zoneSizes[zoneI] = returnReduce
|
||||
(
|
||||
cellZones[zoneI].size(),
|
||||
sumOp<label>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Whether region corresponds to a cellzone
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Info<< "Region\tZone\tName" << nl
|
||||
<< "------\t----\t----" << endl;
|
||||
|
||||
// Region per zone
|
||||
labelList regionToZone(cellRegion.nRegions());
|
||||
labelList regionToZone(cellRegion.nRegions(), -1);
|
||||
// Name of region
|
||||
wordList regionNames(cellRegion.nRegions());
|
||||
// Zone to region
|
||||
labelList zoneToRegion(cellZones.size(), -1);
|
||||
|
||||
if (sloppyCellZones)
|
||||
{
|
||||
Info<< "Trying to match regions to existing cell zones;"
|
||||
<< " region can be subset of cell zone." << nl << endl;
|
||||
|
||||
forAll(cellZones, zoneI)
|
||||
{
|
||||
label regionI = findCorrespondingRegion
|
||||
(
|
||||
zoneID,
|
||||
cellRegion,
|
||||
zoneI,
|
||||
label(0.5*zoneSizes[zoneI]) // minimum overlap
|
||||
);
|
||||
|
||||
if (regionI != -1)
|
||||
{
|
||||
Info<< "Sloppily matched region " << regionI
|
||||
<< " size " << regionSizes[regionI]
|
||||
<< " to zone " << zoneI << " size " << zoneSizes[zoneI]
|
||||
<< endl;
|
||||
zoneToRegion[zoneI] = regionI;
|
||||
regionToZone[regionI] = zoneI;
|
||||
regionNames[regionI] = cellZones[zoneI].name();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Trying to match regions to existing cell zones." << nl << endl;
|
||||
|
||||
forAll(cellZones, zoneI)
|
||||
{
|
||||
label regionI = findCorrespondingRegion
|
||||
(
|
||||
zoneID,
|
||||
cellRegion,
|
||||
zoneI,
|
||||
1 // minimum overlap
|
||||
);
|
||||
|
||||
if (regionI != -1)
|
||||
{
|
||||
zoneToRegion[zoneI] = regionI;
|
||||
regionToZone[regionI] = zoneI;
|
||||
regionNames[regionI] = cellZones[zoneI].name();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Allocate region names for unmatched regions.
|
||||
forAll(regionToZone, regionI)
|
||||
{
|
||||
regionToZone[regionI] = findCorrespondingZone
|
||||
(
|
||||
cellZones,
|
||||
zoneID,
|
||||
cellRegion,
|
||||
regionI
|
||||
);
|
||||
|
||||
if (regionToZone[regionI] != -1)
|
||||
{
|
||||
regionNames[regionI] = cellZones[regionToZone[regionI]].name();
|
||||
}
|
||||
else
|
||||
if (regionToZone[regionI] == -1)
|
||||
{
|
||||
regionNames[regionI] = "domain" + Foam::name(regionI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Print region to zone
|
||||
Info<< "Region\tZone\tName" << nl
|
||||
<< "------\t----\t----" << endl;
|
||||
forAll(regionToZone, regionI)
|
||||
{
|
||||
Info<< regionI << '\t' << regionToZone[regionI] << '\t'
|
||||
<< regionNames[regionI] << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
//// Print zone to region
|
||||
//Info<< "Zone\tName\tRegion" << nl
|
||||
// << "----\t----\t------" << endl;
|
||||
//forAll(zoneToRegion, zoneI)
|
||||
//{
|
||||
// Info<< zoneI << '\t' << cellZones[zoneI].name() << '\t'
|
||||
// << zoneToRegion[zoneI] << nl;
|
||||
//}
|
||||
//Info<< endl;
|
||||
|
||||
|
||||
|
||||
// Since we're going to mess with patches make sure all non-processor ones
|
||||
// are on all processors.
|
||||
@ -1361,7 +1590,8 @@ int main(int argc, char *argv[])
|
||||
interfaceSizes
|
||||
);
|
||||
|
||||
Info<< "Region\tRegion\tFaces" << nl
|
||||
Info<< "Sizes inbetween regions:" << nl << nl
|
||||
<< "Region\tRegion\tFaces" << nl
|
||||
<< "------\t------\t-----" << endl;
|
||||
|
||||
forAll(interfaces, interI)
|
||||
@ -1373,7 +1603,10 @@ int main(int argc, char *argv[])
|
||||
Info<< endl;
|
||||
|
||||
|
||||
|
||||
if (detectOnly)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Read objects in time directory
|
||||
@ -1423,7 +1656,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Only one region. Doing nothing." << endl;
|
||||
}
|
||||
else if (args.options().found("makeCellZones"))
|
||||
else if (makeCellZones)
|
||||
{
|
||||
Info<< "Putting cells into cellZones instead of splitting mesh."
|
||||
<< endl;
|
||||
|
||||
@ -299,7 +299,7 @@ bool domainDecomposition::writeDecomposition()
|
||||
(
|
||||
curPatchSizes.size()
|
||||
+ curProcessorPatchSizes.size(),
|
||||
reinterpret_cast<polyPatch*>(NULL)
|
||||
reinterpret_cast<polyPatch*>(0)
|
||||
);
|
||||
|
||||
label nPatches = 0;
|
||||
|
||||
@ -3,7 +3,7 @@ int nFields = volScalarNames.size() + 3*volVectorNames.size();
|
||||
List<volScalarField*> volFieldPtrs
|
||||
(
|
||||
nFields,
|
||||
reinterpret_cast<volScalarField*>(NULL)
|
||||
reinterpret_cast<volScalarField*>(0)
|
||||
);
|
||||
|
||||
stringList volFieldNames(nFields);
|
||||
@ -27,12 +27,11 @@ nFields = 0;
|
||||
|
||||
if (ioHeader.headerOk())
|
||||
{
|
||||
volFieldPtrs[nFields] =
|
||||
new volScalarField
|
||||
(
|
||||
ioHeader,
|
||||
mesh
|
||||
);
|
||||
volFieldPtrs[nFields] = new volScalarField
|
||||
(
|
||||
ioHeader,
|
||||
mesh
|
||||
);
|
||||
}
|
||||
|
||||
fieldName = getFieldViewName(fieldName);
|
||||
@ -106,7 +105,7 @@ int nSurfFields = surfScalarNames.size() + 3*surfVectorNames.size();
|
||||
List<surfaceScalarField*> surfFieldPtrs
|
||||
(
|
||||
nSurfFields,
|
||||
reinterpret_cast<surfaceScalarField*>(NULL)
|
||||
reinterpret_cast<surfaceScalarField*>(0)
|
||||
);
|
||||
|
||||
stringList surfFieldNames(nSurfFields);
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
List<IOField<scalar>* > sprayScalarFieldPtrs
|
||||
(
|
||||
sprayScalarNames.size(),
|
||||
reinterpret_cast<IOField<scalar>*>(NULL)
|
||||
reinterpret_cast<IOField<scalar>*>(0)
|
||||
);
|
||||
|
||||
List<IOField<vector>* > sprayVectorFieldPtrs
|
||||
(
|
||||
sprayVectorNames.size(),
|
||||
reinterpret_cast<IOField<vector>*>(NULL)
|
||||
reinterpret_cast<IOField<vector>*>(0)
|
||||
);
|
||||
|
||||
{
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
|
||||
Description
|
||||
Translates a STAR-CD SMAP data file into FOAM field format.
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
@ -108,15 +108,15 @@ int main(int argc, char *argv[])
|
||||
List<volScalarField*> sFields
|
||||
(
|
||||
nCols,
|
||||
reinterpret_cast<volScalarField*>(NULL)
|
||||
reinterpret_cast<volScalarField*>(0)
|
||||
);
|
||||
|
||||
List<volVectorField*> vFields
|
||||
(
|
||||
nCols,
|
||||
reinterpret_cast<volVectorField*>(NULL)
|
||||
reinterpret_cast<volVectorField*>(0)
|
||||
);
|
||||
|
||||
|
||||
label i=0;
|
||||
while (i < nCols)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -34,6 +34,9 @@ Usage
|
||||
@param -clean \n
|
||||
Perform some surface checking/cleanup on the input surface
|
||||
|
||||
@param -orient \n
|
||||
Check face orientation on the input surface
|
||||
|
||||
@param -scale \<scale\> \n
|
||||
Specify a scaling factor for writing the files
|
||||
|
||||
@ -68,6 +71,7 @@ int main(int argc, char *argv[])
|
||||
argList::validArgs.append("inputFile");
|
||||
argList::validArgs.append("outputFile");
|
||||
argList::validOptions.insert("clean", "");
|
||||
argList::validOptions.insert("orient", "");
|
||||
argList::validOptions.insert("scale", "scale");
|
||||
argList::validOptions.insert("triSurface", "");
|
||||
argList::validOptions.insert("unsorted", "");
|
||||
@ -108,6 +112,13 @@ int main(int argc, char *argv[])
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.options().found("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
@ -140,6 +151,13 @@ int main(int argc, char *argv[])
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.options().found("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
@ -171,6 +189,13 @@ int main(int argc, char *argv[])
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.options().found("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
@ -202,6 +227,13 @@ int main(int argc, char *argv[])
|
||||
surf.writeStats(Info);
|
||||
Info<< endl;
|
||||
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (args.options().found("clean"))
|
||||
{
|
||||
Info<< "Cleaning up surface" << endl;
|
||||
|
||||
@ -687,6 +687,7 @@ DebugSwitches
|
||||
staticFvMesh 0;
|
||||
steadyState 0;
|
||||
stl 0;
|
||||
string 0;
|
||||
stochasticDispersionRAS 0;
|
||||
supersonicFreestream 0;
|
||||
surfaceFeatures 0;
|
||||
|
||||
@ -112,6 +112,12 @@ public:
|
||||
|
||||
//- Access
|
||||
|
||||
//- Return true if a precompiled expression does not exist
|
||||
inline bool empty() const
|
||||
{
|
||||
return !preg_;
|
||||
}
|
||||
|
||||
//- Does a precompiled expression exist?
|
||||
inline bool exists() const
|
||||
{
|
||||
|
||||
@ -25,19 +25,13 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
|
||||
#include "HashPtrTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct given initial table size
|
||||
template<class T, class Key, class Hash>
|
||||
HashPtrTable<T, Key, Hash>::HashPtrTable(label size)
|
||||
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(const label size)
|
||||
:
|
||||
HashTable<T*, Key, Hash>(size)
|
||||
{}
|
||||
@ -45,7 +39,10 @@ HashPtrTable<T, Key, Hash>::HashPtrTable(label size)
|
||||
|
||||
// Construct as copy
|
||||
template<class T, class Key, class Hash>
|
||||
HashPtrTable<T, Key, Hash>::HashPtrTable(const HashPtrTable<T, Key, Hash>& ht)
|
||||
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable
|
||||
(
|
||||
const HashPtrTable<T, Key, Hash>& ht
|
||||
)
|
||||
:
|
||||
HashTable<T*, Key, Hash>()
|
||||
{
|
||||
@ -59,7 +56,7 @@ HashPtrTable<T, Key, Hash>::HashPtrTable(const HashPtrTable<T, Key, Hash>& ht)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
HashPtrTable<T, Key, Hash>::~HashPtrTable()
|
||||
Foam::HashPtrTable<T, Key, Hash>::~HashPtrTable()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
@ -68,7 +65,7 @@ HashPtrTable<T, Key, Hash>::~HashPtrTable()
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
T* HashPtrTable<T, Key, Hash>::remove(iterator& it)
|
||||
T* Foam::HashPtrTable<T, Key, Hash>::remove(iterator& it)
|
||||
{
|
||||
T* elemPtr = *it;
|
||||
HashTable<T*, Key, Hash>::erase(it);
|
||||
@ -77,7 +74,7 @@ T* HashPtrTable<T, Key, Hash>::remove(iterator& it)
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
bool HashPtrTable<T, Key, Hash>::erase(iterator& it)
|
||||
bool Foam::HashPtrTable<T, Key, Hash>::erase(iterator& it)
|
||||
{
|
||||
T* elemPtr = *it;
|
||||
|
||||
@ -98,7 +95,7 @@ bool HashPtrTable<T, Key, Hash>::erase(iterator& it)
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
void HashPtrTable<T, Key, Hash>::clear()
|
||||
void Foam::HashPtrTable<T, Key, Hash>::clear()
|
||||
{
|
||||
for
|
||||
(
|
||||
@ -117,10 +114,13 @@ void HashPtrTable<T, Key, Hash>::clear()
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
void HashPtrTable<T, Key, Hash>::operator=(const HashPtrTable<T, Key, Hash>& ht)
|
||||
void Foam::HashPtrTable<T, Key, Hash>::operator=
|
||||
(
|
||||
const HashPtrTable<T, Key, Hash>& rhs
|
||||
)
|
||||
{
|
||||
// Check for assignment to self
|
||||
if (this == &ht)
|
||||
if (this == &rhs)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
@ -132,17 +132,12 @@ void HashPtrTable<T, Key, Hash>::operator=(const HashPtrTable<T, Key, Hash>& ht)
|
||||
|
||||
clear();
|
||||
|
||||
for(const_iterator iter = ht.begin(); iter != ht.end(); ++iter)
|
||||
for (const_iterator iter = rhs.begin(); iter != rhs.end(); ++iter)
|
||||
{
|
||||
insert(iter.key(), new T(**iter));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "HashPtrTableIO.C"
|
||||
|
||||
@ -83,7 +83,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial table size
|
||||
HashPtrTable(label size = 100);
|
||||
HashPtrTable(const label size = 100);
|
||||
|
||||
//- Construct from Istream using given Istream constructor class
|
||||
template<class INew>
|
||||
|
||||
@ -29,16 +29,11 @@ License
|
||||
#include "Ostream.H"
|
||||
#include "INew.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class INew>
|
||||
void HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
|
||||
void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
|
||||
{
|
||||
is.fatalCheck("HashPtrTable<T, Key, Hash>::read(Istream&, const INew&)");
|
||||
|
||||
@ -147,14 +142,14 @@ void HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
template<class INew>
|
||||
HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is, const INew& inewt)
|
||||
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is, const INew& inewt)
|
||||
{
|
||||
read(is, inewt);
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is)
|
||||
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is)
|
||||
{
|
||||
read(is, INew<T>());
|
||||
}
|
||||
@ -163,7 +158,7 @@ HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is)
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Istream& operator>>(Istream& is, HashPtrTable<T, Key, Hash>& L)
|
||||
Foam::Istream& Foam::operator>>(Istream& is, HashPtrTable<T, Key, Hash>& L)
|
||||
{
|
||||
L.clear();
|
||||
L.read(is, INew<T>());
|
||||
@ -173,7 +168,11 @@ Istream& operator>>(Istream& is, HashPtrTable<T, Key, Hash>& L)
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
Ostream& operator<<(Ostream& os, const HashPtrTable<T, Key, Hash>& L)
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const HashPtrTable<T, Key, Hash>& L
|
||||
)
|
||||
{
|
||||
// Write size and start delimiter
|
||||
os << nl << L.size() << nl << token::BEGIN_LIST << nl;
|
||||
@ -199,8 +198,4 @@ Ostream& operator<<(Ostream& os, const HashPtrTable<T, Key, Hash>& L)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial size
|
||||
HashSet(label size = 100)
|
||||
HashSet(const label size = 100)
|
||||
:
|
||||
HashTable<nil, Key, Hash>(size)
|
||||
{}
|
||||
|
||||
@ -384,6 +384,12 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- const_iterator set to the beginning of the HashTable
|
||||
inline const_iterator cbegin() const;
|
||||
|
||||
//- const_iterator set to beyond the end of the HashTable
|
||||
inline const const_iterator& cend() const;
|
||||
|
||||
//- const_iterator set to the beginning of the HashTable
|
||||
inline const_iterator begin() const;
|
||||
|
||||
|
||||
@ -452,7 +452,7 @@ const Key& Foam::HashTable<T, Key, Hash>::const_iterator::key()
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline typename Foam::HashTable<T, Key, Hash>::const_iterator
|
||||
Foam::HashTable<T, Key, Hash>::begin() const
|
||||
Foam::HashTable<T, Key, Hash>::cbegin() const
|
||||
{
|
||||
label i = 0;
|
||||
|
||||
@ -477,6 +477,22 @@ Foam::HashTable<T, Key, Hash>::begin() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline const typename Foam::HashTable<T, Key, Hash>::const_iterator&
|
||||
Foam::HashTable<T, Key, Hash>::cend() const
|
||||
{
|
||||
return HashTable<T, Key, Hash>::endConstIter_;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline typename Foam::HashTable<T, Key, Hash>::const_iterator
|
||||
Foam::HashTable<T, Key, Hash>::begin() const
|
||||
{
|
||||
return this->cbegin();
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline const typename Foam::HashTable<T, Key, Hash>::const_iterator&
|
||||
Foam::HashTable<T, Key, Hash>::end() const
|
||||
|
||||
@ -63,7 +63,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial size
|
||||
Map(label size = 100)
|
||||
Map(const label size = 100)
|
||||
:
|
||||
HashTable<T, label, Hash<label> >(size)
|
||||
{}
|
||||
@ -92,14 +92,6 @@ public:
|
||||
HashTable<T, label, Hash<label> >(map)
|
||||
{}
|
||||
|
||||
|
||||
//- Return a null Map
|
||||
static const Map<T>& null()
|
||||
{
|
||||
Map<T>* nullPtr = reinterpret_cast<Map<T>*>(0);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct given initial map size
|
||||
PtrMap(label size = 100)
|
||||
PtrMap(const label size = 100)
|
||||
:
|
||||
HashPtrTable<T, label, Hash<label> >(size)
|
||||
{}
|
||||
|
||||
@ -317,19 +317,24 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- iterator set to the begining of the StaticHashTable
|
||||
//- iterator set to the beginning of the StaticHashTable
|
||||
inline iterator begin();
|
||||
|
||||
//- iterator set to beyond the end of the StaticHashTable
|
||||
inline const iterator& end();
|
||||
|
||||
//- const_iterator set to the begining of the StaticHashTable
|
||||
//- const_iterator set to the beginning of the StaticHashTable
|
||||
inline const_iterator cbegin() const;
|
||||
|
||||
//- const_iterator set to beyond the end of the StaticHashTable
|
||||
inline const const_iterator& cend() const;
|
||||
|
||||
//- const_iterator set to the beginning of the StaticHashTable
|
||||
inline const_iterator begin() const;
|
||||
|
||||
//- const_iterator set to beyond the end of the StaticHashTable
|
||||
inline const const_iterator& end() const;
|
||||
|
||||
|
||||
// IOstream Operator
|
||||
|
||||
friend Istream& operator>> <T, Key, Hash>
|
||||
|
||||
@ -355,7 +355,7 @@ Foam::StaticHashTable<T, Key, Hash>::end()
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator
|
||||
Foam::StaticHashTable<T, Key, Hash>::begin() const
|
||||
Foam::StaticHashTable<T, Key, Hash>::cbegin() const
|
||||
{
|
||||
// Find first non-empty entry
|
||||
forAll(keys_, hashIdx)
|
||||
@ -377,6 +377,22 @@ Foam::StaticHashTable<T, Key, Hash>::begin() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator&
|
||||
Foam::StaticHashTable<T, Key, Hash>::cend() const
|
||||
{
|
||||
return StaticHashTable<T, Key, Hash>::endConstIter_;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator
|
||||
Foam::StaticHashTable<T, Key, Hash>::begin() const
|
||||
{
|
||||
return this->cbegin();
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Key, class Hash>
|
||||
inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator&
|
||||
Foam::StaticHashTable<T, Key, Hash>::end() const
|
||||
|
||||
@ -30,17 +30,17 @@ License
|
||||
#include "IOstreams.H"
|
||||
#include "long.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
Foam::DLListBase::iterator Foam::DLListBase::endIter
|
||||
Foam::DLListBase::iterator Foam::DLListBase::endIter_
|
||||
(
|
||||
const_cast<DLListBase&>(static_cast<const DLListBase&>(DLListBase()))
|
||||
);
|
||||
|
||||
Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter
|
||||
Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter_
|
||||
(
|
||||
static_cast<const DLListBase&>(DLListBase()),
|
||||
reinterpret_cast<const link*>(NULL)
|
||||
reinterpret_cast<const link*>(0)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ public:
|
||||
|
||||
// STL iterator
|
||||
|
||||
//- An STL iterator
|
||||
//- An STL-conforming iterator
|
||||
class iterator
|
||||
{
|
||||
friend class DLListBase;
|
||||
@ -193,16 +193,17 @@ public:
|
||||
//- Copy of the link
|
||||
link curLink_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Construct for a given SLListBase with NULL element and link.
|
||||
// Only used to create endIter
|
||||
inline iterator(DLListBase&);
|
||||
|
||||
public:
|
||||
|
||||
//- Construct for a given DLListBase and link
|
||||
inline iterator(DLListBase&, link*);
|
||||
|
||||
//- Construct for a given DLListBase
|
||||
// setting element and link to NULL.
|
||||
// Only used to create endIter
|
||||
inline iterator(DLListBase&);
|
||||
|
||||
// Member operators
|
||||
|
||||
inline void operator=(const iterator&);
|
||||
@ -217,16 +218,12 @@ public:
|
||||
};
|
||||
|
||||
inline iterator begin();
|
||||
|
||||
//- iterator returned by end()
|
||||
static iterator endIter;
|
||||
|
||||
inline const iterator& end();
|
||||
|
||||
|
||||
// STL const_iterator
|
||||
|
||||
//- An STL const_iterator
|
||||
//- An STL-conforming const_iterator
|
||||
class const_iterator
|
||||
{
|
||||
// Private data
|
||||
@ -258,12 +255,20 @@ public:
|
||||
inline const_iterator operator++(int);
|
||||
};
|
||||
|
||||
inline const_iterator cbegin() const;
|
||||
inline const const_iterator& cend() const;
|
||||
|
||||
inline const_iterator begin() const;
|
||||
inline const const_iterator& end() const;
|
||||
|
||||
private:
|
||||
|
||||
//- iterator returned by end()
|
||||
static iterator endIter_;
|
||||
|
||||
//- const_iterator returned by end()
|
||||
static const_iterator endConstIter;
|
||||
static const_iterator endConstIter_;
|
||||
|
||||
inline const const_iterator& end() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -259,14 +259,14 @@ Foam::DLListBase::begin()
|
||||
}
|
||||
else
|
||||
{
|
||||
return endIter;
|
||||
return endIter_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::DLListBase::iterator& Foam::DLListBase::end()
|
||||
{
|
||||
return endIter;
|
||||
return endIter_;
|
||||
}
|
||||
|
||||
|
||||
@ -350,7 +350,7 @@ Foam::DLListBase::const_iterator::operator++(int)
|
||||
|
||||
|
||||
inline Foam::DLListBase::const_iterator
|
||||
Foam::DLListBase::begin() const
|
||||
Foam::DLListBase::cbegin() const
|
||||
{
|
||||
if (size())
|
||||
{
|
||||
@ -358,15 +358,29 @@ Foam::DLListBase::begin() const
|
||||
}
|
||||
else
|
||||
{
|
||||
return endConstIter;
|
||||
return endConstIter_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::DLListBase::const_iterator&
|
||||
Foam::DLListBase::cend() const
|
||||
{
|
||||
return endConstIter_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::DLListBase::const_iterator
|
||||
Foam::DLListBase::begin() const
|
||||
{
|
||||
return this->cbegin();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::DLListBase::const_iterator&
|
||||
Foam::DLListBase::end() const
|
||||
{
|
||||
return endConstIter;
|
||||
return endConstIter_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -29,15 +29,15 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::SLListBase::iterator Foam::SLListBase::endIter
|
||||
Foam::SLListBase::iterator Foam::SLListBase::endIter_
|
||||
(
|
||||
const_cast<SLListBase&>(static_cast<const SLListBase&>(SLListBase()))
|
||||
);
|
||||
|
||||
Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter
|
||||
Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter_
|
||||
(
|
||||
static_cast<const SLListBase&>(SLListBase()),
|
||||
reinterpret_cast<const link*>(NULL)
|
||||
reinterpret_cast<const link*>(0)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -178,17 +178,17 @@ public:
|
||||
//- Copy of the link
|
||||
link curLink_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Construct for a given SLListBase with NULL element and link.
|
||||
// Only used to create endIter
|
||||
inline iterator(SLListBase&);
|
||||
|
||||
public:
|
||||
|
||||
//- Construct for a given SLListBase and link
|
||||
inline iterator(SLListBase&, link*);
|
||||
|
||||
//- Construct for a given SLListBase
|
||||
// setting element and link to NULL.
|
||||
// Only used to create endIter
|
||||
inline iterator(SLListBase&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
inline void operator=(const iterator&);
|
||||
@ -203,10 +203,6 @@ public:
|
||||
};
|
||||
|
||||
inline iterator begin();
|
||||
|
||||
//- iterator returned by end()
|
||||
static iterator endIter;
|
||||
|
||||
inline const iterator& end();
|
||||
|
||||
|
||||
@ -245,12 +241,20 @@ public:
|
||||
inline const_iterator operator++(int);
|
||||
};
|
||||
|
||||
inline const_iterator cbegin() const;
|
||||
inline const const_iterator& cend() const;
|
||||
|
||||
inline const_iterator begin() const;
|
||||
inline const const_iterator& end() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- iterator returned by end()
|
||||
static iterator endIter_;
|
||||
|
||||
//- const_iterator returned by end()
|
||||
static const_iterator endConstIter;
|
||||
|
||||
inline const const_iterator& end() const;
|
||||
static const_iterator endConstIter_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -231,7 +231,7 @@ Foam::SLListBase::begin()
|
||||
}
|
||||
else
|
||||
{
|
||||
return endIter;
|
||||
return endIter_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ Foam::SLListBase::begin()
|
||||
inline const Foam::SLListBase::iterator&
|
||||
Foam::SLListBase::end()
|
||||
{
|
||||
return endIter;
|
||||
return endIter_;
|
||||
}
|
||||
|
||||
|
||||
@ -323,7 +323,7 @@ Foam::SLListBase::const_iterator::operator++(int)
|
||||
|
||||
|
||||
inline Foam::SLListBase::const_iterator
|
||||
Foam::SLListBase::begin() const
|
||||
Foam::SLListBase::cbegin() const
|
||||
{
|
||||
if (size())
|
||||
{
|
||||
@ -331,15 +331,29 @@ Foam::SLListBase::begin() const
|
||||
}
|
||||
else
|
||||
{
|
||||
return endConstIter;
|
||||
return endConstIter_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::SLListBase::const_iterator&
|
||||
Foam::SLListBase::cend() const
|
||||
{
|
||||
return endConstIter_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::SLListBase::const_iterator
|
||||
Foam::SLListBase::begin() const
|
||||
{
|
||||
return this->cbegin();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::SLListBase::const_iterator&
|
||||
Foam::SLListBase::end() const
|
||||
{
|
||||
return endConstIter;
|
||||
return endConstIter_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -118,14 +118,6 @@ Foam::CompactListList<T>::CompactListList
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
|
||||
{
|
||||
CompactListList<T>* nullPtr = reinterpret_cast<CompactListList<T>*>(NULL);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::CompactListList<T>::setSize(const label nRows)
|
||||
{
|
||||
@ -150,12 +142,17 @@ void Foam::CompactListList<T>::setSize(const label nRows)
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::CompactListList<T>::setSize(const label nRows, const label nData)
|
||||
void Foam::CompactListList<T>::setSize
|
||||
(
|
||||
const label nRows,
|
||||
const label nData
|
||||
)
|
||||
{
|
||||
offsets_.setSize(nRows);
|
||||
m_.setSize(nData);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::CompactListList<T>::setSize
|
||||
(
|
||||
@ -168,19 +165,6 @@ void Foam::CompactListList<T>::setSize
|
||||
m_.setSize(nData, t);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
Foam::labelList Foam::CompactListList<T>::sizes() const
|
||||
{
|
||||
labelList rowSizes(offsets_.size());
|
||||
|
||||
label prevOffset = 0;
|
||||
forAll(offsets_, i)
|
||||
{
|
||||
rowSizes[i] = offsets_[i]-prevOffset;
|
||||
prevOffset = offsets_[i];
|
||||
}
|
||||
return rowSizes;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void Foam::CompactListList<T>::setSize(const UList<label>& rowSizes)
|
||||
@ -197,6 +181,22 @@ void Foam::CompactListList<T>::setSize(const UList<label>& rowSizes)
|
||||
m_.setSize(sumSize);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::labelList Foam::CompactListList<T>::sizes() const
|
||||
{
|
||||
labelList rowSizes(offsets_.size());
|
||||
|
||||
label prevOffset = 0;
|
||||
forAll(offsets_, i)
|
||||
{
|
||||
rowSizes[i] = offsets_[i]-prevOffset;
|
||||
prevOffset = offsets_[i];
|
||||
}
|
||||
return rowSizes;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::CompactListList<T>::clear()
|
||||
{
|
||||
|
||||
@ -81,6 +81,11 @@ class CompactListList
|
||||
|
||||
public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null CompactListList
|
||||
inline static const CompactListList<T>& null();
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor.
|
||||
@ -116,10 +121,7 @@ public:
|
||||
inline autoPtr<CompactListList<T> > clone() const;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return a null CompactListList
|
||||
static const CompactListList<T>& null();
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
@ -154,15 +156,28 @@ public:
|
||||
//- Reset sizes of CompactListList and value for new elements.
|
||||
void setSize(const label nRows, const label nData, const T&);
|
||||
|
||||
//- Return sizes (to be used e.g. for construction)
|
||||
labelList sizes() const;
|
||||
|
||||
//- Reset size of CompactListList.
|
||||
void setSize(const UList<label>& rowSizes);
|
||||
|
||||
//- Reset size of CompactListList.
|
||||
// This form only allows contraction of the CompactListList.
|
||||
inline void resize(const label nRows);
|
||||
|
||||
//- Reset size of CompactListList.
|
||||
inline void resize(const label nRows, const label nData);
|
||||
|
||||
//- Reset sizes of CompactListList and value for new elements.
|
||||
inline void resize(const label nRows, const label nData, const T&);
|
||||
|
||||
//- Reset size of CompactListList.
|
||||
inline void resize(const UList<label>& rowSizes);
|
||||
|
||||
//- Clear the CompactListList, i.e. set sizes to zero.
|
||||
void clear();
|
||||
|
||||
//- Return sizes (to be used e.g. for construction)
|
||||
labelList sizes() const;
|
||||
|
||||
//- Transfer the contents of the argument CompactListList
|
||||
// into this CompactListList and annull the argument list.
|
||||
void transfer(CompactListList<T>&);
|
||||
|
||||
@ -67,6 +67,13 @@ Foam::CompactListList<T>::clone() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
|
||||
{
|
||||
return *reinterpret_cast< CompactListList<T>* >(0);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::CompactListList<T>::size() const
|
||||
{
|
||||
@ -169,6 +176,43 @@ inline Foam::Xfer<Foam::CompactListList<T> > Foam::CompactListList<T>::xfer()
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::CompactListList<T>::resize(const label nRows)
|
||||
{
|
||||
this->setSize(nRows);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::CompactListList<T>::resize
|
||||
(
|
||||
const label nRows,
|
||||
const label nData
|
||||
)
|
||||
{
|
||||
this->setSize(nRows, nData);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::CompactListList<T>::resize
|
||||
(
|
||||
const label nRows,
|
||||
const label nData,
|
||||
const T& t
|
||||
)
|
||||
{
|
||||
this->setSize(nRows, nData, t);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::CompactListList<T>::resize(const UList<label>& rowSizes)
|
||||
{
|
||||
this->setSize(rowSizes);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
|
||||
@ -108,6 +108,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from UList. Size set to UList size.
|
||||
// Also constructs from DynamicList with different sizing parameters.
|
||||
explicit inline DynamicList(const UList<T>&);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
@ -141,6 +142,15 @@ public:
|
||||
//- Alter the addressed list size and fill new space with a constant.
|
||||
inline void setSize(const label, const T&);
|
||||
|
||||
//- Alter the addressed list size.
|
||||
// New space will be allocated if required.
|
||||
// Use this to resize the list prior to using the operator[] for
|
||||
// setting values (as per List usage).
|
||||
inline void resize(const label);
|
||||
|
||||
//- Alter the addressed list size and fill new space with a constant.
|
||||
inline void resize(const label, const T&);
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size, use setCapacity() for that.
|
||||
inline void reserve(const label);
|
||||
@ -182,9 +192,14 @@ public:
|
||||
//- Assignment of all addressed entries to the given value
|
||||
inline void operator=(const T&);
|
||||
|
||||
//- Assignment from List<T>. Also handles assignment from DynamicList.
|
||||
inline void operator=(const UList<T>&);
|
||||
//- Assignment from DynamicList
|
||||
inline void operator=
|
||||
(
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||
);
|
||||
|
||||
//- Assignment from List<T>.
|
||||
inline void operator=(const UList<T>&);
|
||||
|
||||
// IOstream operators
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
||||
List<T>(nElem),
|
||||
capacity_(nElem)
|
||||
{
|
||||
// we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
|
||||
List<T>::size(0);
|
||||
}
|
||||
|
||||
@ -107,6 +108,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setCapacity
|
||||
// truncate addressed sizes too
|
||||
nextFree = capacity_;
|
||||
}
|
||||
// we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
|
||||
|
||||
List<T>::setSize(capacity_);
|
||||
List<T>::size(nextFree);
|
||||
@ -122,11 +124,25 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::reserve
|
||||
// allocate more capacity?
|
||||
if (nElem > capacity_)
|
||||
{
|
||||
capacity_ = max
|
||||
(
|
||||
nElem,
|
||||
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||
);
|
||||
// TODO: convince the compiler that division by zero does not occur
|
||||
// if (SizeInc && (!SizeMult || !SizeDiv))
|
||||
// {
|
||||
// // resize with SizeInc as the granularity
|
||||
// capacity_ = nElem;
|
||||
// unsigned pad = SizeInc - (capacity_ % SizeInc);
|
||||
// if (pad != SizeInc)
|
||||
// {
|
||||
// capacity_ += pad;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
{
|
||||
capacity_ = max
|
||||
(
|
||||
nElem,
|
||||
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||
);
|
||||
}
|
||||
|
||||
// adjust allocated size, leave addressed size untouched
|
||||
label nextFree = List<T>::size();
|
||||
@ -145,11 +161,25 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
|
||||
// allocate more capacity?
|
||||
if (nElem > capacity_)
|
||||
{
|
||||
capacity_ = max
|
||||
(
|
||||
nElem,
|
||||
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||
);
|
||||
// TODO: convince the compiler that division by zero does not occur
|
||||
// if (SizeInc && (!SizeMult || !SizeDiv))
|
||||
// {
|
||||
// // resize with SizeInc as the granularity
|
||||
// capacity_ = nElem;
|
||||
// unsigned pad = SizeInc - (capacity_ % SizeInc);
|
||||
// if (pad != SizeInc)
|
||||
// {
|
||||
// capacity_ += pad;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
{
|
||||
capacity_ = max
|
||||
(
|
||||
nElem,
|
||||
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||
);
|
||||
}
|
||||
|
||||
List<T>::setSize(capacity_);
|
||||
}
|
||||
@ -177,6 +207,27 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize
|
||||
(
|
||||
const label nElem
|
||||
)
|
||||
{
|
||||
this->setSize(nElem);
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::resize
|
||||
(
|
||||
const label nElem,
|
||||
const T& t
|
||||
)
|
||||
{
|
||||
this->setSize(nElem, t);
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clear()
|
||||
{
|
||||
@ -201,6 +252,7 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::shrink()
|
||||
{
|
||||
// use the full list when resizing
|
||||
List<T>::size(capacity_);
|
||||
|
||||
// the new size
|
||||
capacity_ = nextFree;
|
||||
List<T>::setSize(capacity_);
|
||||
@ -334,13 +386,36 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
|
||||
(
|
||||
const UList<T>& lst
|
||||
)
|
||||
{
|
||||
if (capacity_ >= lst.size())
|
||||
{
|
||||
// can copy w/o reallocating, match initial size to avoid reallocation
|
||||
List<T>::size(lst.size());
|
||||
List<T>::operator=(lst);
|
||||
}
|
||||
else
|
||||
{
|
||||
// make everything available for the copy operation
|
||||
List<T>::size(capacity_);
|
||||
|
||||
List<T>::operator=(lst);
|
||||
capacity_ = List<T>::size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
|
||||
(
|
||||
const DynamicList<T, SizeInc, SizeMult, SizeDiv>& lst
|
||||
)
|
||||
{
|
||||
if (this == &lst)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator="
|
||||
"(const UList<T>&)"
|
||||
"(const DynamicList<T, SizeInc, SizeMult, SizeDiv>&)"
|
||||
) << "attempted assignment to self" << abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
@ -29,14 +29,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
const Foam::FixedList<T, Size>& Foam::FixedList<T, Size>::null()
|
||||
{
|
||||
FixedList<T, Size>* nullPtr = reinterpret_cast<FixedList<T, Size>*>(NULL);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
|
||||
@ -93,6 +93,11 @@ public:
|
||||
) const;
|
||||
};
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null FixedList
|
||||
inline static const FixedList<T, Size>& null();
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -121,11 +126,7 @@ public:
|
||||
inline autoPtr<FixedList<T, Size> > clone() const;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return a null FixedList
|
||||
static const FixedList<T, Size>& null();
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
@ -152,6 +153,10 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Dummy resize function
|
||||
// needed to make FixedList consistent with List
|
||||
inline void resize(const label);
|
||||
|
||||
//- Dummy setSize function
|
||||
// needed to make FixedList consistent with List
|
||||
inline void setSize(const label);
|
||||
@ -226,12 +231,16 @@ public:
|
||||
//- Random access iterator for traversing FixedList.
|
||||
typedef const T* const_iterator;
|
||||
|
||||
//- Return a const_iterator to begin traversing the
|
||||
// constant FixedList.
|
||||
//- Return const_iterator to begin traversing the constant FixedList.
|
||||
inline const_iterator cbegin() const;
|
||||
|
||||
//- Return const_iterator to end traversing the constant FixedList.
|
||||
inline const_iterator cend() const;
|
||||
|
||||
//- Return const_iterator to begin traversing the constant FixedList.
|
||||
inline const_iterator begin() const;
|
||||
|
||||
//- Return a const_iterator to end traversing the
|
||||
// constant FixedList.
|
||||
//- Return const_iterator to end traversing the constant FixedList.
|
||||
inline const_iterator end() const;
|
||||
|
||||
|
||||
@ -240,12 +249,10 @@ public:
|
||||
//- Reverse iterator for reverse traversal of FixedList.
|
||||
typedef T* reverse_iterator;
|
||||
|
||||
//- Return a reverse_iterator to begin reverse traversing the
|
||||
// FixedList.
|
||||
//- Return reverse_iterator to begin reverse traversing the FixedList.
|
||||
inline reverse_iterator rbegin();
|
||||
|
||||
//- Return a reverse_iterator to end reverse traversing the
|
||||
// FixedList.
|
||||
//- Return reverse_iterator to end reverse traversing the FixedList.
|
||||
inline reverse_iterator rend();
|
||||
|
||||
|
||||
@ -254,12 +261,16 @@ public:
|
||||
//- Reverse iterator for reverse traversal of constant FixedList.
|
||||
typedef const T* const_reverse_iterator;
|
||||
|
||||
//- Return a const_reverse_iterator to begin reverse traversing the
|
||||
// FixedList.
|
||||
//- Return const_reverse_iterator to begin reverse traversing FixedList.
|
||||
inline const_reverse_iterator crbegin() const;
|
||||
|
||||
//- Return const_reverse_iterator to end reverse traversing FixedList.
|
||||
inline const_reverse_iterator crend() const;
|
||||
|
||||
//- Return const_reverse_iterator to begin reverse traversing FixedList.
|
||||
inline const_reverse_iterator rbegin() const;
|
||||
|
||||
//- Return a const_reverse_iterator to end reverse traversing the
|
||||
// FixedList.
|
||||
//- Return const_reverse_iterator to end reverse traversing FixedList.
|
||||
inline const_reverse_iterator rend() const;
|
||||
|
||||
|
||||
|
||||
@ -104,6 +104,13 @@ Foam::FixedList<T, Size>::clone() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline const Foam::FixedList<T, Size>& Foam::FixedList<T, Size>::null()
|
||||
{
|
||||
return *reinterpret_cast< FixedList<T, Size>* >(0);
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
|
||||
{
|
||||
@ -163,6 +170,14 @@ inline void Foam::FixedList<T, Size>::checkIndex(const label i) const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline void Foam::FixedList<T, Size>::resize(const label s)
|
||||
{
|
||||
# ifdef FULLDEBUG
|
||||
checkSize(s);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline void Foam::FixedList<T, Size>::setSize(const label s)
|
||||
{
|
||||
@ -269,6 +284,14 @@ Foam::FixedList<T, Size>::begin() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::cbegin() const
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline typename Foam::FixedList<T, Size>::iterator
|
||||
Foam::FixedList<T, Size>::end()
|
||||
@ -284,6 +307,15 @@ Foam::FixedList<T, Size>::end() const
|
||||
return &v_[Size];
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::cend() const
|
||||
{
|
||||
return &v_[Size];
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline typename Foam::FixedList<T, Size>::iterator
|
||||
Foam::FixedList<T, Size>::rbegin()
|
||||
@ -300,6 +332,14 @@ Foam::FixedList<T, Size>::rbegin() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::crbegin() const
|
||||
{
|
||||
return &v_[Size-1];
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline typename Foam::FixedList<T, Size>::iterator
|
||||
Foam::FixedList<T, Size>::rend()
|
||||
@ -316,6 +356,14 @@ Foam::FixedList<T, Size>::rend() const
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline typename Foam::FixedList<T, Size>::const_iterator
|
||||
Foam::FixedList<T, Size>::crend() const
|
||||
{
|
||||
return &v_[-1];
|
||||
}
|
||||
|
||||
|
||||
template<class T, Foam::label Size>
|
||||
inline Foam::label Foam::FixedList<T, Size>::size() const
|
||||
{
|
||||
|
||||
@ -332,14 +332,6 @@ Foam::List<T>::~List()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
const Foam::List<T>& Foam::List<T>::null()
|
||||
{
|
||||
List<T>* nullPtr = reinterpret_cast<List<T>*>(NULL);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::List<T>::setSize(const label newSize)
|
||||
{
|
||||
|
||||
@ -87,6 +87,11 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null List
|
||||
inline static const List<T>& null();
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor.
|
||||
@ -145,10 +150,7 @@ public:
|
||||
typedef SubList<T> subList;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return a null List
|
||||
static const List<T>& null();
|
||||
// Member Functions
|
||||
|
||||
//- Return the number of elements in the UList.
|
||||
inline label size() const;
|
||||
@ -156,6 +158,12 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Reset size of List.
|
||||
inline void resize(const label);
|
||||
|
||||
//- Reset size of List and value for new elements.
|
||||
inline void resize(const label, const T&);
|
||||
|
||||
//- Reset size of List.
|
||||
void setSize(const label);
|
||||
|
||||
|
||||
@ -40,6 +40,27 @@ inline Foam::autoPtr<Foam::List<T> > Foam::List<T>::clone() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline const Foam::List<T>& Foam::List<T>::null()
|
||||
{
|
||||
return *reinterpret_cast< List<T>* >(0);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::resize(const label newSize)
|
||||
{
|
||||
this->setSize(newSize);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::resize(const label newSize, const T& a)
|
||||
{
|
||||
this->setSize(newSize, a);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::List<T>::newElmt(const label i)
|
||||
{
|
||||
|
||||
@ -173,7 +173,14 @@ void Foam::sortedOrder
|
||||
labelList& order
|
||||
)
|
||||
{
|
||||
order.setSize(lst.size());
|
||||
// list lengths must be identical
|
||||
if (order.size() != lst.size())
|
||||
{
|
||||
// avoid copying any elements, they are overwritten anyhow
|
||||
order.clear();
|
||||
order.setSize(lst.size());
|
||||
}
|
||||
|
||||
forAll(order, elemI)
|
||||
{
|
||||
order[elemI] = elemI;
|
||||
|
||||
@ -31,32 +31,17 @@ License
|
||||
template<int nBits>
|
||||
Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val)
|
||||
:
|
||||
List<unsigned int>(intSize(size)),
|
||||
List<PackedStorage>(packedLength(size), 0u),
|
||||
size_(size)
|
||||
{
|
||||
operator=(val);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
Foam::PackedList<nBits>::PackedList(const PackedList<nBits>& lst)
|
||||
:
|
||||
List<unsigned int>(lst),
|
||||
size_(lst.size())
|
||||
{}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
Foam::PackedList<nBits>::PackedList(const Xfer<PackedList<nBits> >& lst)
|
||||
{
|
||||
transfer(lst());
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||
:
|
||||
List<unsigned int>(intSize(lst.size()), 0),
|
||||
List<PackedStorage>(packedLength(lst.size()), 0u),
|
||||
size_(lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
@ -66,51 +51,10 @@ Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
Foam::autoPtr<Foam::PackedList<nBits> > Foam::PackedList<nBits>::clone() const
|
||||
{
|
||||
return autoPtr<PackedList<nBits> >(new PackedList<nBits>(*this));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<int nBits>
|
||||
void Foam::PackedList<nBits>::setSize(const label size)
|
||||
{
|
||||
List<unsigned int>::setSize(intSize(size));
|
||||
size_ = size;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
void Foam::PackedList<nBits>::clear()
|
||||
{
|
||||
List<unsigned int>::clear();
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
void Foam::PackedList<nBits>::transfer(PackedList<nBits>& lst)
|
||||
{
|
||||
size_ = lst.size();
|
||||
List<unsigned int>::transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<int nBits>
|
||||
void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
||||
{
|
||||
setSize(lst.size());
|
||||
List<unsigned int>::operator=(lst);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
Foam::labelList Foam::PackedList<nBits>::operator()() const
|
||||
Foam::labelList Foam::PackedList<nBits>::values() const
|
||||
{
|
||||
labelList elems(size());
|
||||
|
||||
@ -122,6 +66,97 @@ Foam::labelList Foam::PackedList<nBits>::operator()() const
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
Foam::Ostream& Foam::PackedList<nBits>::iterator::print(Ostream& os) const
|
||||
{
|
||||
os << "iterator<" << nBits << "> [" << position() << "]"
|
||||
<< " elem:" << elem_ << " offset:" << offset_
|
||||
<< " value:" << unsigned(*this)
|
||||
<< nl;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
|
||||
{
|
||||
os << "PackedList<" << nBits << ">"
|
||||
<< " max_value:" << max_value()
|
||||
<< " packing:" << packing() << nl
|
||||
<< "values: " << size() << "/" << capacity() << "( ";
|
||||
forAll(*this, i)
|
||||
{
|
||||
os << get(i) << ' ';
|
||||
}
|
||||
|
||||
os << ")\n"
|
||||
<< "storage: " << storage().size() << "( ";
|
||||
|
||||
label count = size();
|
||||
|
||||
forAll(storage(), i)
|
||||
{
|
||||
const PackedStorage& rawBits = storage()[i];
|
||||
|
||||
// create mask for unaddressed bits
|
||||
unsigned int addressed = 0;
|
||||
|
||||
for (unsigned packI = 0; count && packI < packing(); packI++, count--)
|
||||
{
|
||||
addressed <<= nBits;
|
||||
addressed |= max_value();
|
||||
}
|
||||
|
||||
for (unsigned int testBit = 0x1 << max_bits(); testBit; testBit >>= 1)
|
||||
{
|
||||
if (testBit & addressed)
|
||||
{
|
||||
if (rawBits & testBit)
|
||||
{
|
||||
os << '1';
|
||||
}
|
||||
else
|
||||
{
|
||||
os << '0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
os << '_';
|
||||
}
|
||||
}
|
||||
cout << ' ';
|
||||
}
|
||||
os << ")\n";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<int nBits>
|
||||
void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
||||
{
|
||||
setCapacity(lst.size());
|
||||
List<PackedStorage>::operator=(lst);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
||||
{
|
||||
setCapacity(lst.size());
|
||||
|
||||
forAll(lst, i)
|
||||
{
|
||||
set(i, lst[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
|
||||
//template<int nBits>
|
||||
|
||||
@ -26,9 +26,22 @@ Class
|
||||
Foam::PackedList
|
||||
|
||||
Description
|
||||
List of packed unsigned ints.
|
||||
A Dynamically allocatable list of packed unsigned ints.
|
||||
|
||||
Gets given the number of bits per item.
|
||||
|
||||
Note
|
||||
The list resizing is similar to DynamicList, thus the methods clear()
|
||||
and setSize() behave like their DynamicList counterparts and the methods
|
||||
reserve() and setCapacity() can be used to influence the allocation.
|
||||
|
||||
SeeAlso
|
||||
Foam::DynamicList
|
||||
|
||||
ToDo
|
||||
Add checks for bad template parameters (ie, nBits=0, nBits too large).
|
||||
The missing const_iterator might eventually still be needed.
|
||||
|
||||
SourceFiles
|
||||
PackedListI.H
|
||||
PackedList.C
|
||||
@ -39,172 +52,254 @@ SourceFiles
|
||||
#define PackedList_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "List.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
template<int nBits> class PackedList;
|
||||
|
||||
// template<int nBits>
|
||||
// Ostream& operator<<(Ostream&, const PackedList<nBits>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PackedListName Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
TemplateName(PackedList);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class PackedList Declaration
|
||||
Class PackedList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- For PackedList
|
||||
class reference
|
||||
{
|
||||
// private data
|
||||
unsigned int& elem_;
|
||||
|
||||
unsigned int mask_;
|
||||
|
||||
label startBit_;
|
||||
|
||||
public:
|
||||
|
||||
inline reference(unsigned int& elem, unsigned int mask, label startBit)
|
||||
:
|
||||
elem_(elem),
|
||||
mask_(mask),
|
||||
startBit_(startBit)
|
||||
{}
|
||||
|
||||
inline void operator=(const unsigned int val)
|
||||
{
|
||||
unsigned int shiftedMask = mask_ << startBit_;
|
||||
|
||||
unsigned int shiftedVal = val << startBit_;
|
||||
|
||||
elem_ = (elem_ & ~shiftedMask) | shiftedVal;
|
||||
}
|
||||
|
||||
inline operator unsigned int () const
|
||||
{
|
||||
return (elem_ >> startBit_) & mask_;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <int nBits>
|
||||
class PackedList
|
||||
:
|
||||
private List<unsigned int>
|
||||
{
|
||||
typedef unsigned int PackedStorage;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Number of nBits entries
|
||||
label size_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate underlying list size
|
||||
inline static label intSize(const label sz);
|
||||
//- Calculate the list length when packed
|
||||
inline static label packedLength(const label);
|
||||
|
||||
//- Calculate index into underlying List.
|
||||
inline static label intIndex(const label i);
|
||||
|
||||
//- Check index i is within valid range (0 ... size-1).
|
||||
inline void checkIndex(const label i) const;
|
||||
|
||||
//- Check value is representable in nBits
|
||||
inline void checkValue(const unsigned int val) const;
|
||||
//- Check index I is within valid range [ 0 .. max_value() ]
|
||||
inline void checkIndex(const label) const;
|
||||
|
||||
public:
|
||||
|
||||
// Public data
|
||||
|
||||
//- The max. number of bits that can be templated.
|
||||
// Might someday be useful for a template assert.
|
||||
inline static unsigned int max_bits();
|
||||
|
||||
//- The max. value for an entry, which simultaneously the bit-mask
|
||||
// eg, ((1 << 2) - 1) yields 0b0011
|
||||
inline static unsigned int max_value();
|
||||
|
||||
//- The number of entries per packed storage element
|
||||
inline static unsigned int packing();
|
||||
|
||||
// Forward declaration of iterator
|
||||
class iterator;
|
||||
friend class iterator;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor
|
||||
inline PackedList();
|
||||
|
||||
//- Construct with given size. Note: initializes intList to 0.
|
||||
//- Construct with given size, initializes list to 0.
|
||||
inline PackedList(const label size);
|
||||
|
||||
//- Construct with given size and value for all elements.
|
||||
PackedList(const label size, const unsigned int val);
|
||||
PackedList(const label size, const unsigned val);
|
||||
|
||||
//- Copy constructor.
|
||||
PackedList(const PackedList<nBits>& PList);
|
||||
inline PackedList(const PackedList<nBits>&);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
PackedList(const Xfer<PackedList<nBits> >&);
|
||||
inline PackedList(const Xfer<PackedList<nBits> >&);
|
||||
|
||||
//- Construct from a list of labels
|
||||
PackedList(const UList<label>&);
|
||||
|
||||
//- Clone
|
||||
inline autoPtr<PackedList<nBits> > clone() const;
|
||||
inline autoPtr< PackedList<nBits> > clone() const;
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Edit
|
||||
|
||||
//- Reset size of List.
|
||||
void setSize(const label);
|
||||
|
||||
//- Clear the list, i.e. set size to zero.
|
||||
void clear();
|
||||
|
||||
//- Transfer the contents of the argument List into this List
|
||||
// and annull the argument list.
|
||||
void transfer(PackedList<nBits>&);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PackedList<nBits> > xfer();
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- Number of packed elements
|
||||
inline label size() const;
|
||||
//- The number of elements that can be stored before resizing
|
||||
inline label capacity() const;
|
||||
|
||||
//- Return true if the list is empty (i.e., if size() == 0).
|
||||
inline bool empty() const;
|
||||
//- Number of entries.
|
||||
inline label size() const;
|
||||
|
||||
//- Get value at index I
|
||||
inline unsigned int get(const label i) const;
|
||||
//- Return true if the list is empty (i.e., if size() == 0).
|
||||
inline bool empty() const;
|
||||
|
||||
//- Set value at index I. Return true if value changed.
|
||||
inline bool set(const label i, const unsigned int val);
|
||||
//- Get value at index I.
|
||||
// Does not auto-vivifies entries.
|
||||
inline unsigned int get(const label) const;
|
||||
|
||||
//- Underlying storage
|
||||
inline List<unsigned int>& storage();
|
||||
//- Set value at index I. Return true if value changed.
|
||||
// Does not auto-vivifies entries.
|
||||
inline bool set(const label, const unsigned int val);
|
||||
|
||||
//- Return the underlying packed storage
|
||||
inline const List<unsigned int>& storage() const;
|
||||
|
||||
//- Return the values as a labelList
|
||||
labelList values() const;
|
||||
|
||||
//- Print values and information
|
||||
Ostream& print(Ostream&) const;
|
||||
|
||||
// Edit
|
||||
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
inline void setCapacity(const label);
|
||||
|
||||
//- Reset addressable list size, does not shrink the allocated size.
|
||||
// Optionally specify a value for new elements.
|
||||
inline void resize(const label, const unsigned int& val = 0);
|
||||
|
||||
//- Alias for resize()
|
||||
inline void setSize(const label, const unsigned int& val = 0);
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size.
|
||||
// Optionally provide an initialization value for new elements.
|
||||
inline void reserve(const label, const unsigned int& val = 0);
|
||||
|
||||
//- Clear the list, i.e. set addressable size to zero.
|
||||
// Does not adjust the underlying storage
|
||||
inline void clear();
|
||||
|
||||
//- Clear the list and delete storage.
|
||||
inline void clearStorage();
|
||||
|
||||
//- Shrink the allocated space to what is used.
|
||||
inline void shrink();
|
||||
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annull the argument list.
|
||||
inline void transfer(PackedList<nBits>&);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PackedList<nBits> > xfer();
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Get value at index i
|
||||
inline unsigned int operator[](const label i) const;
|
||||
//- Append a value at the end of the list
|
||||
inline void append(const unsigned int val);
|
||||
|
||||
//- Set value at index i. Returns proxy which does actual operation
|
||||
inline ::Foam::reference operator[](const label i);
|
||||
//- Get value at index I
|
||||
// Auto-vivifies any new values to zero.
|
||||
inline unsigned int operator[](const label) const;
|
||||
|
||||
//- Assignment operator. Takes linear time.
|
||||
void operator=(const PackedList<nBits>&);
|
||||
//- Set value at index I.
|
||||
// Returns proxy to perform the actual operation.
|
||||
// Auto-vivifies any new values to zero.
|
||||
inline iterator operator[](const label);
|
||||
|
||||
//- Assignment of all entries to the given value. Does set on all
|
||||
// elements.
|
||||
inline void operator=(const unsigned int val);
|
||||
//- Assignment of all entries to the given value.
|
||||
// Does set on all elements.
|
||||
inline void operator=(const unsigned int val);
|
||||
|
||||
//- Return as labelList
|
||||
labelList operator()() const;
|
||||
//- Assignment operator. Takes linear time.
|
||||
void operator=(const PackedList<nBits>&);
|
||||
|
||||
//- Assignment operator. Takes linear time.
|
||||
void operator=(const UList<label>&);
|
||||
|
||||
// Ostream operator
|
||||
|
||||
// // Write PackedList to Ostream.
|
||||
// friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&);
|
||||
};
|
||||
// // Write PackedList to Ostream.
|
||||
// friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&);
|
||||
|
||||
|
||||
//- The iterator-like class used for PackedList
|
||||
class iterator
|
||||
{
|
||||
friend class PackedList;
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Reference to original list
|
||||
PackedList& list_;
|
||||
|
||||
//- Element index within storage
|
||||
unsigned elem_;
|
||||
|
||||
//- Offset within storage element
|
||||
unsigned offset_;
|
||||
|
||||
//- Return the raw storage element
|
||||
inline PackedStorage& chunk() const;
|
||||
|
||||
//- Return the position in the PackedList
|
||||
inline label position() const;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from base list and position index
|
||||
inline iterator(const PackedList&, const label i);
|
||||
|
||||
// Members
|
||||
|
||||
//- Assign value, returns true if the value changed
|
||||
inline bool operator=(const unsigned int val);
|
||||
|
||||
//- Conversion operator
|
||||
inline operator unsigned int () const;
|
||||
|
||||
//- Conversion operator
|
||||
inline operator bool() const;
|
||||
|
||||
// Member operators
|
||||
|
||||
inline void operator=(const iterator&);
|
||||
inline bool operator==(const iterator&) const;
|
||||
inline bool operator!=(const iterator&) const;
|
||||
|
||||
//- Return referenced value
|
||||
inline unsigned int operator()() const;
|
||||
|
||||
inline iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
|
||||
//- Print value and information
|
||||
Ostream& print(Ostream&) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//- iterator set to the begining of the PackedList
|
||||
inline iterator begin();
|
||||
|
||||
//- iterator set to beyond the end of the HashTable
|
||||
inline iterator end();
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -25,47 +25,48 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PackedList_I
|
||||
#define PackedList_I
|
||||
|
||||
#include "IOstreams.H"
|
||||
#include "error.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Calculate underlying list size
|
||||
template<int nBits>
|
||||
inline Foam::label Foam::PackedList<nBits>::intSize(const label sz)
|
||||
inline unsigned int Foam::PackedList<nBits>::max_bits()
|
||||
{
|
||||
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
||||
|
||||
return (sz+nElemsPerLabel-1)/nElemsPerLabel;
|
||||
return sizeof(PackedStorage)*8 - 1;
|
||||
}
|
||||
|
||||
|
||||
// Convert index into index in integer array
|
||||
template<int nBits>
|
||||
inline Foam::label Foam::PackedList<nBits>::intIndex(const label i)
|
||||
inline unsigned int Foam::PackedList<nBits>::max_value()
|
||||
{
|
||||
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
||||
|
||||
// Index in underlying int array
|
||||
label elemI = i/nElemsPerLabel;
|
||||
|
||||
return elemI;
|
||||
return ((1u << nBits) - 1);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline unsigned int Foam::PackedList<nBits>::packing()
|
||||
{
|
||||
return sizeof(PackedStorage)*8 / nBits;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::label Foam::PackedList<nBits>::packedLength(const label nElem)
|
||||
{
|
||||
return (nElem + packing() - 1) / packing();
|
||||
}
|
||||
|
||||
|
||||
// Check index i is within valid range (0 ... size-1).
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::checkIndex(const label i) const
|
||||
{
|
||||
if (!size_)
|
||||
{
|
||||
FatalErrorIn("PackedList<nBits>::checkIndex(const label)")
|
||||
<< "attempt to access element from zero sized list"
|
||||
<< "attempt to access element from zero-sized list"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
else if (i<0 || i>=size_)
|
||||
else if (i < 0 || i >= size_)
|
||||
{
|
||||
FatalErrorIn("PackedList<nBits>::checkIndex(const label)")
|
||||
<< "index " << i << " out of range 0 ... " << size_-1
|
||||
@ -74,40 +75,194 @@ inline void Foam::PackedList<nBits>::checkIndex(const label i) const
|
||||
}
|
||||
|
||||
|
||||
// Check value is representable in nBits
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::checkValue(const unsigned int val) const
|
||||
{
|
||||
if (val>=(1u << nBits))
|
||||
{
|
||||
FatalErrorIn("PackedList<T>::checkValue(const unsigned int)")
|
||||
<< "value " << label(val) << " out of range 0 ... "
|
||||
<< label((1u << nBits)-1)
|
||||
<< " representable by " << nBits << " bits"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Null constructor
|
||||
template<int nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList()
|
||||
:
|
||||
List<unsigned int>(0),
|
||||
List<PackedStorage>(),
|
||||
size_(0)
|
||||
{}
|
||||
|
||||
|
||||
// Construct with given size.
|
||||
template<int nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(const label size)
|
||||
:
|
||||
List<unsigned int>(intSize(size), 0u),
|
||||
List<PackedStorage>(packedLength(size), 0u),
|
||||
size_(size)
|
||||
{}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(const PackedList<nBits>& lst)
|
||||
:
|
||||
List<PackedStorage>(lst),
|
||||
size_(lst.size())
|
||||
{}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::PackedList<nBits>::PackedList(const Xfer<PackedList<nBits> >& lst)
|
||||
{
|
||||
transfer(lst());
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::autoPtr<Foam::PackedList<nBits> >
|
||||
Foam::PackedList<nBits>::clone() const
|
||||
{
|
||||
return autoPtr<PackedList<nBits> >(new PackedList<nBits>(*this));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::PackedList<nBits>::iterator::iterator
|
||||
(
|
||||
const PackedList<nBits>& lst,
|
||||
const label i
|
||||
)
|
||||
:
|
||||
list_(const_cast<PackedList<nBits>&>(lst)),
|
||||
elem_(i / packing()),
|
||||
offset_(i % packing())
|
||||
{}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::iterator::operator=
|
||||
(
|
||||
const iterator& iter
|
||||
)
|
||||
{
|
||||
elem_ = iter.elem_;
|
||||
offset_ = iter.offset_;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline bool Foam::PackedList<nBits>::iterator::operator==
|
||||
(
|
||||
const iterator& iter
|
||||
) const
|
||||
{
|
||||
return elem_ == iter.elem_ && offset_ == iter.offset_;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline bool Foam::PackedList<nBits>::iterator::operator!=
|
||||
(
|
||||
const iterator& iter
|
||||
) const
|
||||
{
|
||||
return !(operator==(iter));
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline bool Foam::PackedList<nBits>::iterator::operator=
|
||||
(
|
||||
const unsigned int val
|
||||
)
|
||||
{
|
||||
const unsigned int startBit = nBits * offset_;
|
||||
const unsigned int mask = max_value() << startBit;
|
||||
|
||||
unsigned int& stored = chunk();
|
||||
const unsigned int old = stored;
|
||||
|
||||
stored &= ~mask;
|
||||
stored |= (val << startBit) & mask;
|
||||
|
||||
return (old != stored);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::label Foam::PackedList<nBits>::iterator::position() const
|
||||
{
|
||||
return (elem_ * packing() + offset_);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline unsigned int& Foam::PackedList<nBits>::iterator::chunk() const
|
||||
{
|
||||
return list_.List<PackedStorage>::operator[](elem_);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline typename Foam::PackedList<nBits>::iterator&
|
||||
Foam::PackedList<nBits>::iterator::operator++()
|
||||
{
|
||||
if (position() < list_.size())
|
||||
{
|
||||
offset_++;
|
||||
if (offset_ >= packing())
|
||||
{
|
||||
elem_++;
|
||||
offset_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline typename Foam::PackedList<nBits>::iterator
|
||||
Foam::PackedList<nBits>::iterator::operator++(int)
|
||||
{
|
||||
iterator old = *this;
|
||||
++*this;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline unsigned int
|
||||
Foam::PackedList<nBits>::iterator::operator()() const
|
||||
{
|
||||
return (chunk() >> (nBits * offset_)) & max_value();
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::PackedList<nBits>::iterator::operator
|
||||
unsigned int () const
|
||||
{
|
||||
return (chunk() >> (nBits * offset_)) & max_value();
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::PackedList<nBits>::iterator::operator
|
||||
bool() const
|
||||
{
|
||||
return !!(chunk() >> (nBits * offset_)) & max_value();
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline typename Foam::PackedList<nBits>::iterator
|
||||
Foam::PackedList<nBits>::begin()
|
||||
{
|
||||
return iterator(*this, 0);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline typename Foam::PackedList<nBits>::iterator
|
||||
Foam::PackedList<nBits>::end()
|
||||
{
|
||||
return iterator(*this, size());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<int nBits>
|
||||
@ -120,76 +275,134 @@ inline Foam::label Foam::PackedList<nBits>::size() const
|
||||
template<int nBits>
|
||||
inline bool Foam::PackedList<nBits>::empty() const
|
||||
{
|
||||
return (size_ == 0);
|
||||
}
|
||||
|
||||
|
||||
// Get value at i
|
||||
template<int nBits>
|
||||
inline unsigned int Foam::PackedList<nBits>::get(const label i) const
|
||||
{
|
||||
# ifdef DEBUGList
|
||||
checkIndex(i);
|
||||
# endif
|
||||
|
||||
// Constant: number of elements that fit in an unsigned int
|
||||
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
||||
|
||||
unsigned int mask = ((1u << nBits) - 1);
|
||||
|
||||
label indexInLabel = i % nElemsPerLabel;
|
||||
|
||||
// Starting bit in int.
|
||||
label startBit = nBits*indexInLabel;
|
||||
|
||||
return (List<unsigned int>::operator[](intIndex(i)) >> startBit) & mask;
|
||||
return !size_;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
|
||||
inline void Foam::PackedList<nBits>::resize
|
||||
(
|
||||
const label nElem,
|
||||
const unsigned int& val
|
||||
)
|
||||
{
|
||||
return get(i);
|
||||
}
|
||||
|
||||
|
||||
// Set value at i
|
||||
template<int nBits>
|
||||
inline bool Foam::PackedList<nBits>::set(const label i, const unsigned int val)
|
||||
{
|
||||
# ifdef DEBUGList
|
||||
checkIndex(i);
|
||||
checkValue(val);
|
||||
# endif
|
||||
|
||||
// Constant: number of elements that fit in an unsigned int
|
||||
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
||||
|
||||
unsigned int mask = ((1u << nBits) - 1);
|
||||
|
||||
label indexInLabel = i % nElemsPerLabel;
|
||||
|
||||
// Starting bit in int.
|
||||
label startBit = nBits*indexInLabel;
|
||||
|
||||
|
||||
unsigned int shiftedMask = mask << startBit;
|
||||
unsigned int shiftedVal = val << startBit;
|
||||
|
||||
unsigned int& elem = List<unsigned int>::operator[](intIndex(i));
|
||||
|
||||
unsigned int oldElem = elem;
|
||||
|
||||
elem = (elem & ~shiftedMask) | shiftedVal;
|
||||
|
||||
return elem != oldElem;
|
||||
reserve(nElem, val);
|
||||
size_ = nElem;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::List<unsigned int>& Foam::PackedList<nBits>::storage()
|
||||
inline void Foam::PackedList<nBits>::setSize
|
||||
(
|
||||
const label newSize,
|
||||
const unsigned int& val
|
||||
)
|
||||
{
|
||||
return static_cast<List<unsigned int>&>(*this);
|
||||
resize(newSize, val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::label Foam::PackedList<nBits>::capacity() const
|
||||
{
|
||||
return packing() * List<PackedStorage>::size();
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::setCapacity(const label nElem)
|
||||
{
|
||||
List<PackedStorage>::setSize(packedLength(nElem), 0u);
|
||||
|
||||
// truncates addressable section too
|
||||
if (size_ > nElem)
|
||||
{
|
||||
# ifdef DEBUGList
|
||||
// clear old values (purely cosmetics for string output)
|
||||
for (label i = nElem; i < size_; i++)
|
||||
{
|
||||
set(i, 0);
|
||||
}
|
||||
# endif
|
||||
size_ = nElem;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fill new elements
|
||||
for (label i = size_; i < nElem; i++)
|
||||
{
|
||||
set(i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::reserve
|
||||
(
|
||||
const label nElem,
|
||||
const unsigned int& val
|
||||
)
|
||||
{
|
||||
label len = packedLength(nElem);
|
||||
|
||||
// need more capacity?
|
||||
if (len > List<PackedStorage>::size())
|
||||
{
|
||||
List<PackedStorage>::setSize(len, 0);
|
||||
}
|
||||
|
||||
// fill new elements
|
||||
for (label i = size_; i < nElem; i++)
|
||||
{
|
||||
set(i, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::clear()
|
||||
{
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::clearStorage()
|
||||
{
|
||||
List<PackedStorage>::clear();
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::shrink()
|
||||
{
|
||||
label len = packedLength(size_);
|
||||
|
||||
// we have unused space?
|
||||
if (len < List<PackedStorage>::size())
|
||||
{
|
||||
List<PackedStorage>::setSize(len);
|
||||
}
|
||||
}
|
||||
|
||||
template<int nBits>
|
||||
inline const Foam::List<unsigned int>&
|
||||
Foam::PackedList<nBits>::storage() const
|
||||
{
|
||||
return static_cast<const List<PackedStorage>&>(*this);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::transfer(PackedList<nBits>& lst)
|
||||
{
|
||||
size_ = lst.size_;
|
||||
lst.size_ = 0;
|
||||
|
||||
List<PackedStorage>::transfer(lst);
|
||||
}
|
||||
|
||||
|
||||
@ -201,54 +414,95 @@ Foam::PackedList<nBits>::xfer()
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline Foam::reference Foam::PackedList<nBits>::operator[](const label i)
|
||||
inline unsigned int Foam::PackedList<nBits>::get(const label i) const
|
||||
{
|
||||
# ifdef DEBUGList
|
||||
checkIndex(i);
|
||||
# endif
|
||||
|
||||
// Constant: number of elements that fit in an unsigned int
|
||||
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
||||
|
||||
unsigned int mask = ((1u << nBits) - 1);
|
||||
|
||||
label indexInLabel = i % nElemsPerLabel;
|
||||
|
||||
// Starting bit in int.
|
||||
label startBit = nBits*indexInLabel;
|
||||
|
||||
unsigned int& elem = List<unsigned int>::operator[](intIndex(i));
|
||||
|
||||
return ::Foam::reference(elem, mask, startBit);
|
||||
return iterator(*this, i)();
|
||||
}
|
||||
|
||||
|
||||
// Set all to val
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
||||
inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
|
||||
{
|
||||
# ifdef DEBUGList
|
||||
checkValue(val);
|
||||
# endif
|
||||
|
||||
if (val == 0)
|
||||
if (i >= size_)
|
||||
{
|
||||
List<unsigned int>::operator=(val);
|
||||
setSize(i + 1);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (label i = 0; i < size_; i++)
|
||||
{
|
||||
set(i, val);
|
||||
}
|
||||
return iterator(*this, i)();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
template<int nBits>
|
||||
inline bool Foam::PackedList<nBits>::set
|
||||
(
|
||||
const label i,
|
||||
const unsigned int val
|
||||
)
|
||||
{
|
||||
# ifdef DEBUGList
|
||||
checkIndex(i);
|
||||
|
||||
if (val & ~max_value())
|
||||
{
|
||||
FatalErrorIn("PackedList<T>::set(const label, const unsigned int)")
|
||||
<< "value " << label(val)
|
||||
<< " out-of-range 0 ... " << label(max_value())
|
||||
<< " representable by " << nBits << " bits"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
# endif
|
||||
|
||||
return (iterator(*this, i) = val);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::append(const unsigned int val)
|
||||
{
|
||||
label elemI = size_;
|
||||
reserve(elemI + 1);
|
||||
size_++;
|
||||
|
||||
iterator(*this, elemI) = val;
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline typename Foam::PackedList<nBits>::iterator
|
||||
Foam::PackedList<nBits>::operator[](const label i)
|
||||
{
|
||||
if (i >= size_)
|
||||
{
|
||||
setSize(i + 1);
|
||||
}
|
||||
|
||||
return iterator(*this, i);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
forAll(*this, elemI)
|
||||
{
|
||||
set(elemI, val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List<PackedStorage>::operator=(val);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::PtrList<T>::PtrList()
|
||||
template<class T>
|
||||
Foam::PtrList<T>::PtrList(const label s)
|
||||
:
|
||||
ptrs_(s, reinterpret_cast<T*>(NULL))
|
||||
ptrs_(s, reinterpret_cast<T*>(0))
|
||||
{}
|
||||
|
||||
|
||||
@ -216,7 +216,7 @@ void Foam::PtrList<T>::reorder(const UList<label>& oldToNew)
|
||||
<< ")." << abort(FatalError);
|
||||
}
|
||||
|
||||
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(NULL));
|
||||
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(0));
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
|
||||
@ -170,6 +170,12 @@ public:
|
||||
// deleted.
|
||||
void setSize(const label);
|
||||
|
||||
//- Reset size of PtrList. This can only be used to set the size
|
||||
// of an empty PtrList, extend a PtrList, remove entries from
|
||||
// the end of a PtrList. If the entries are non-empty they are
|
||||
// deleted.
|
||||
inline void resize(const label);
|
||||
|
||||
//- Clear the PtrList, i.e. set size to zero deleting all the
|
||||
// allocated entries.
|
||||
void clear();
|
||||
|
||||
@ -45,6 +45,13 @@ inline bool Foam::PtrList<T>::empty() const
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::resize(const label newSize)
|
||||
{
|
||||
this->setSize(newSize);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::PtrList<T>::set(const label i) const
|
||||
{
|
||||
|
||||
@ -27,17 +27,21 @@ License
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::SortableList<T>::sortIndices(List<label>& ind) const
|
||||
void Foam::SortableList<T>::sortIndices(List<label>& order) const
|
||||
{
|
||||
// list lengths must be identical
|
||||
ind.setSize(this->size());
|
||||
|
||||
forAll(ind, i)
|
||||
if (order.size() != this->size())
|
||||
{
|
||||
ind[i] = i;
|
||||
// avoid copying any elements, they are overwritten anyhow
|
||||
order.clear();
|
||||
order.setSize(this->size());
|
||||
}
|
||||
|
||||
Foam::stableSort(ind, typename UList<T>::less(*this));
|
||||
forAll(order, elemI)
|
||||
{
|
||||
order[elemI] = elemI;
|
||||
}
|
||||
Foam::stableSort(order, typename UList<T>::less(*this));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class SortableList Declaration
|
||||
Class SortableList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
@ -60,7 +60,7 @@ class SortableList
|
||||
//- Original indices
|
||||
labelList indices_;
|
||||
|
||||
//- Resize and sort the parameter according to the list values
|
||||
//- Resize, fill and sort the parameter according to the list values
|
||||
void sortIndices(List<label>&) const;
|
||||
|
||||
public:
|
||||
|
||||
@ -59,6 +59,12 @@ class SubList
|
||||
|
||||
public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null SubList
|
||||
inline static const SubList<T>& null();
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from UList and sub-list size
|
||||
@ -77,12 +83,6 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return a null SubList
|
||||
static inline const SubList<T>& null();
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Allow cast to a const List<T>&
|
||||
|
||||
@ -75,8 +75,7 @@ inline Foam::SubList<T>::SubList
|
||||
template<class T>
|
||||
inline const Foam::SubList<T>& Foam::SubList<T>::null()
|
||||
{
|
||||
SubList<T>* nullPtr = reinterpret_cast<SubList<T>*>(NULL);
|
||||
return *nullPtr;
|
||||
return *reinterpret_cast< SubList<T>* >(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -32,14 +32,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
const Foam::UList<T>& Foam::UList<T>::null()
|
||||
{
|
||||
UList<T>* nullPtr = reinterpret_cast<UList<T>*>(NULL);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::UList<T>::assign(const UList<T>& a)
|
||||
{
|
||||
|
||||
@ -86,6 +86,11 @@ public:
|
||||
//- Declare friendship with the SubList class
|
||||
friend class SubList<T>;
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null UList
|
||||
inline static const UList<T>& null();
|
||||
|
||||
// Public classes
|
||||
|
||||
//- Less function class that can be used for sorting
|
||||
@ -116,10 +121,7 @@ public:
|
||||
inline UList(T* __restrict__ v, label size);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return a null UList
|
||||
static const UList<T>& null();
|
||||
// Member Functions
|
||||
|
||||
|
||||
// Access
|
||||
@ -213,12 +215,16 @@ public:
|
||||
//- Random access iterator for traversing UList.
|
||||
typedef const T* const_iterator;
|
||||
|
||||
//- Return a const_iterator to begin traversing the
|
||||
// constant UList.
|
||||
//- Return const_iterator to begin traversing the constant UList.
|
||||
inline const_iterator cbegin() const;
|
||||
|
||||
//- Return const_iterator to end traversing the constant UList.
|
||||
inline const_iterator cend() const;
|
||||
|
||||
//- Return const_iterator to begin traversing the constant UList.
|
||||
inline const_iterator begin() const;
|
||||
|
||||
//- Return a const_iterator to end traversing the
|
||||
// constant UList.
|
||||
//- Return const_iterator to end traversing the constant UList.
|
||||
inline const_iterator end() const;
|
||||
|
||||
|
||||
@ -227,12 +233,10 @@ public:
|
||||
//- Reverse iterator for reverse traversal of UList.
|
||||
typedef T* reverse_iterator;
|
||||
|
||||
//- Return a reverse_iterator to begin reverse traversing the
|
||||
// UList.
|
||||
//- Return reverse_iterator to begin reverse traversing the UList.
|
||||
inline reverse_iterator rbegin();
|
||||
|
||||
//- Return a reverse_iterator to end reverse traversing the
|
||||
// UList.
|
||||
//- Return reverse_iterator to end reverse traversing the UList.
|
||||
inline reverse_iterator rend();
|
||||
|
||||
|
||||
@ -241,12 +245,16 @@ public:
|
||||
//- Reverse iterator for reverse traversal of constant UList.
|
||||
typedef const T* const_reverse_iterator;
|
||||
|
||||
//- Return a const_reverse_iterator to begin reverse traversing the
|
||||
// UList.
|
||||
//- Return const_reverse_iterator to begin reverse traversing the UList.
|
||||
inline const_reverse_iterator crbegin() const;
|
||||
|
||||
//- Return const_reverse_iterator to end reverse traversing the UList.
|
||||
inline const_reverse_iterator crend() const;
|
||||
|
||||
//- Return const_reverse_iterator to begin reverse traversing the UList.
|
||||
inline const_reverse_iterator rbegin() const;
|
||||
|
||||
//- Return a const_reverse_iterator to end reverse traversing the
|
||||
// UList.
|
||||
//- Return const_reverse_iterator to end reverse traversing the UList.
|
||||
inline const_reverse_iterator rend() const;
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,13 @@ inline Foam::UList<T>::UList(T* __restrict__ v, label size)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline const Foam::UList<T>& Foam::UList<T>::null()
|
||||
{
|
||||
return *reinterpret_cast< UList<T>* >(0);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::UList<T>::fcIndex(const label i) const
|
||||
{
|
||||
@ -154,6 +161,13 @@ Foam::UList<T>::begin() const
|
||||
return v_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::const_iterator
|
||||
Foam::UList<T>::cbegin() const
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::iterator
|
||||
Foam::UList<T>::end()
|
||||
@ -168,6 +182,13 @@ Foam::UList<T>::end() const
|
||||
return &v_[size_];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::const_iterator
|
||||
Foam::UList<T>::cend() const
|
||||
{
|
||||
return &v_[size_];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::iterator
|
||||
Foam::UList<T>::rbegin()
|
||||
@ -182,6 +203,13 @@ Foam::UList<T>::rbegin() const
|
||||
return &v_[size_-1];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::const_iterator
|
||||
Foam::UList<T>::crbegin() const
|
||||
{
|
||||
return &v_[size_-1];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::iterator
|
||||
Foam::UList<T>::rend()
|
||||
@ -196,6 +224,13 @@ Foam::UList<T>::rend() const
|
||||
return &v_[-1];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::const_iterator
|
||||
Foam::UList<T>::crend() const
|
||||
{
|
||||
return &v_[-1];
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::UList<T>::size() const
|
||||
{
|
||||
|
||||
@ -41,7 +41,7 @@ Foam::UPtrList<T>::UPtrList()
|
||||
template<class T>
|
||||
Foam::UPtrList<T>::UPtrList(const label s)
|
||||
:
|
||||
ptrs_(s, reinterpret_cast<T*>(NULL))
|
||||
ptrs_(s, reinterpret_cast<T*>(0))
|
||||
{}
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ void Foam::UPtrList<T>::reorder(const UList<label>& oldToNew)
|
||||
<< ")." << abort(FatalError);
|
||||
}
|
||||
|
||||
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(NULL));
|
||||
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(0));
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
|
||||
@ -124,6 +124,9 @@ public:
|
||||
//- Return the number of elements in the UPtrList
|
||||
inline label size() const;
|
||||
|
||||
//- Return true if the UPtrList is empty (i.e., if size() == 0).
|
||||
inline bool empty() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
@ -132,6 +135,11 @@ public:
|
||||
// the end of a UPtrList.
|
||||
void setSize(const label);
|
||||
|
||||
//- Reset size of UPtrList. This can only be used to set the size
|
||||
// of an empty UPtrList, extend a UPtrList, remove entries from
|
||||
// the end of a UPtrList.
|
||||
inline void resize(const label);
|
||||
|
||||
//- Clear the UPtrList, i.e. set size to zero
|
||||
void clear();
|
||||
|
||||
|
||||
@ -35,13 +35,26 @@ inline Foam::label Foam::UPtrList<T>::size() const
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::empty() const
|
||||
{
|
||||
return ptrs_.empty();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::resize(const label newSize)
|
||||
{
|
||||
this->setSize(newSize);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::set(const label i) const
|
||||
{
|
||||
return ptrs_[i] != NULL;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T* Foam::UPtrList<T>::set(const label i, T* ptr)
|
||||
{
|
||||
|
||||
@ -48,17 +48,11 @@ void Foam::Ostream::decrIndent()
|
||||
|
||||
|
||||
// Write keyType
|
||||
// write regular expression as quoted string
|
||||
// write plain word as word (unquoted)
|
||||
Foam::Ostream& Foam::Ostream::write(const keyType& kw)
|
||||
{
|
||||
// Write as word or string
|
||||
if (kw.isPattern())
|
||||
{
|
||||
return write(static_cast<const string&>(kw));
|
||||
}
|
||||
else
|
||||
{
|
||||
return write(static_cast<const word&>(kw));
|
||||
}
|
||||
return writeQuoted(kw, kw.isPattern());
|
||||
}
|
||||
|
||||
|
||||
@ -76,6 +70,7 @@ Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
||||
nSpaces -= 2;
|
||||
}
|
||||
|
||||
// could also increment by indentSize_ ...
|
||||
if (nSpaces < 1)
|
||||
{
|
||||
nSpaces = 1;
|
||||
|
||||
@ -115,6 +115,14 @@ public:
|
||||
//- Write string
|
||||
virtual Ostream& write(const string&) = 0;
|
||||
|
||||
//- Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
virtual Ostream& writeQuoted
|
||||
(
|
||||
const std::string&,
|
||||
const bool quoted=true
|
||||
) = 0;
|
||||
|
||||
//- Write label
|
||||
virtual Ostream& write(const label) = 0;
|
||||
|
||||
|
||||
@ -175,6 +175,18 @@ Foam::Ostream& Foam::OPstream::write(const string& str)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OPstream::writeQuoted(const std::string& str, const bool)
|
||||
{
|
||||
write(char(token::STRING));
|
||||
|
||||
size_t len = str.size();
|
||||
writeToBuffer(len);
|
||||
writeToBuffer(str.c_str(), len + 1, 1);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OPstream::write(const label val)
|
||||
{
|
||||
write(char(token::LABEL));
|
||||
|
||||
@ -136,6 +136,14 @@ public:
|
||||
//- Write string
|
||||
Ostream& write(const string&);
|
||||
|
||||
//- Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
Ostream& writeQuoted
|
||||
(
|
||||
const std::string&,
|
||||
const bool quoted=true
|
||||
);
|
||||
|
||||
//- Write label
|
||||
Ostream& write(const label);
|
||||
|
||||
|
||||
@ -366,6 +366,9 @@ Foam::Istream& Foam::ISstream::read(string& str)
|
||||
return *this;
|
||||
}
|
||||
|
||||
char endTok = token::END_STRING;
|
||||
|
||||
// Note, we could also handle single-quoted strings here (if desired)
|
||||
if (c != token::BEGIN_STRING)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
@ -382,52 +385,49 @@ Foam::Istream& Foam::ISstream::read(string& str)
|
||||
|
||||
while (get(c))
|
||||
{
|
||||
switch (c)
|
||||
if (c == endTok)
|
||||
{
|
||||
case token::END_STRING :
|
||||
if (escaped)
|
||||
{
|
||||
escaped = false;
|
||||
i--; // overwrite backslash
|
||||
}
|
||||
else
|
||||
{
|
||||
// done reading string
|
||||
buf[i] = '\0';
|
||||
str = buf;
|
||||
return *this;
|
||||
}
|
||||
break;
|
||||
|
||||
case token::NL :
|
||||
if (escaped)
|
||||
{
|
||||
escaped = false;
|
||||
i--; // overwrite backslash
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[i] = '\0';
|
||||
buf[errLen] = '\0';
|
||||
|
||||
FatalIOErrorIn("ISstream::read(string&)", *this)
|
||||
<< "found '\\n' while reading string \""
|
||||
<< buf << "...\""
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return *this;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
escaped = !escaped; // toggle state (retains backslashes)
|
||||
break;
|
||||
|
||||
default:
|
||||
if (escaped)
|
||||
{
|
||||
escaped = false;
|
||||
break;
|
||||
i--; // overwrite backslash
|
||||
}
|
||||
else
|
||||
{
|
||||
// done reading string
|
||||
buf[i] = '\0';
|
||||
str = buf;
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
else if (c == token::NL)
|
||||
{
|
||||
if (escaped)
|
||||
{
|
||||
escaped = false;
|
||||
i--; // overwrite backslash
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[i] = '\0';
|
||||
buf[errLen] = '\0';
|
||||
|
||||
FatalIOErrorIn("ISstream::read(string&)", *this)
|
||||
<< "found '\\n' while reading string \""
|
||||
<< buf << "...\""
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
escaped = !escaped; // toggle state (retains backslashes)
|
||||
}
|
||||
else
|
||||
{
|
||||
escaped = false;
|
||||
}
|
||||
|
||||
buf[i] = c;
|
||||
if (i++ == maxLen)
|
||||
|
||||
@ -74,28 +74,26 @@ Foam::Ostream& Foam::OSstream::write(const string& str)
|
||||
{
|
||||
register char c = *iter;
|
||||
|
||||
switch (c)
|
||||
if (c == '\\')
|
||||
{
|
||||
case '\\' :
|
||||
backslash++;
|
||||
// suppress output until we know if other characters follow
|
||||
continue;
|
||||
break;
|
||||
|
||||
case token::NL :
|
||||
lineNumber_++;
|
||||
backslash++; // backslash escape for newline
|
||||
break;
|
||||
|
||||
case token::END_STRING :
|
||||
backslash++; // backslash escape for double-quote
|
||||
break;
|
||||
backslash++;
|
||||
// suppress output until we know if other characters follow
|
||||
continue;
|
||||
}
|
||||
else if (c == token::NL)
|
||||
{
|
||||
lineNumber_++;
|
||||
backslash++; // backslash escape for newline
|
||||
}
|
||||
else if (c == token::END_STRING)
|
||||
{
|
||||
backslash++; // backslash escape for quote
|
||||
}
|
||||
|
||||
// output pending backslashes
|
||||
while (backslash)
|
||||
{
|
||||
os_ << '\\'; // escape for new-line
|
||||
os_ << '\\';
|
||||
backslash--;
|
||||
}
|
||||
|
||||
@ -103,7 +101,7 @@ Foam::Ostream& Foam::OSstream::write(const string& str)
|
||||
}
|
||||
|
||||
// silently drop any trailing backslashes
|
||||
// they would otherwise appear like an escaped double-quote
|
||||
// they would otherwise appear like an escaped end-quote
|
||||
|
||||
os_ << token::END_STRING;
|
||||
|
||||
@ -112,6 +110,68 @@ Foam::Ostream& Foam::OSstream::write(const string& str)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OSstream::writeQuoted
|
||||
(
|
||||
const std::string& str,
|
||||
const bool quoted
|
||||
)
|
||||
{
|
||||
if (quoted)
|
||||
{
|
||||
os_ << token::BEGIN_STRING;
|
||||
|
||||
register int backslash = 0;
|
||||
for
|
||||
(
|
||||
string::const_iterator iter = str.begin();
|
||||
iter != str.end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
register char c = *iter;
|
||||
|
||||
if (c == '\\')
|
||||
{
|
||||
backslash++;
|
||||
// suppress output until we know if other characters follow
|
||||
continue;
|
||||
}
|
||||
else if (c == token::NL)
|
||||
{
|
||||
lineNumber_++;
|
||||
backslash++; // backslash escape for newline
|
||||
}
|
||||
else if (c == token::END_STRING)
|
||||
{
|
||||
backslash++; // backslash escape for quote
|
||||
}
|
||||
|
||||
// output pending backslashes
|
||||
while (backslash)
|
||||
{
|
||||
os_ << '\\';
|
||||
backslash--;
|
||||
}
|
||||
|
||||
os_ << c;
|
||||
}
|
||||
|
||||
// silently drop any trailing backslashes
|
||||
// they would otherwise appear like an escaped end-quote
|
||||
os_ << token::END_STRING;
|
||||
}
|
||||
else
|
||||
{
|
||||
// output unquoted string, only advance line number on newline
|
||||
lineNumber_ += string(str).count(token::NL);
|
||||
os_ << str;
|
||||
}
|
||||
|
||||
setState(os_.rdstate());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::OSstream::write(const label val)
|
||||
{
|
||||
os_ << val;
|
||||
|
||||
@ -141,6 +141,14 @@ public:
|
||||
// double-quote.
|
||||
virtual Ostream& write(const string&);
|
||||
|
||||
//- Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
virtual Ostream& writeQuoted
|
||||
(
|
||||
const std::string&,
|
||||
const bool quoted=true
|
||||
);
|
||||
|
||||
//- Write label
|
||||
virtual Ostream& write(const label);
|
||||
|
||||
|
||||
@ -115,6 +115,17 @@ Foam::Ostream& Foam::prefixOSstream::write(const string& val)
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::prefixOSstream::writeQuoted
|
||||
(
|
||||
const std::string& val,
|
||||
const bool quoted
|
||||
)
|
||||
{
|
||||
checkWritePrefix();
|
||||
return OSstream::writeQuoted(val, quoted);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::prefixOSstream::write(const label val)
|
||||
{
|
||||
checkWritePrefix();
|
||||
|
||||
@ -114,6 +114,14 @@ public:
|
||||
//- Write string
|
||||
virtual Ostream& write(const string&);
|
||||
|
||||
//- Write std::string surrounded by quotes.
|
||||
// Optional write without quotes.
|
||||
virtual Ostream& writeQuoted
|
||||
(
|
||||
const std::string&,
|
||||
const bool quoted=true
|
||||
);
|
||||
|
||||
//- Write label
|
||||
virtual Ostream& write(const label);
|
||||
|
||||
|
||||
@ -105,6 +105,7 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the string
|
||||
string str() const
|
||||
{
|
||||
return dynamic_cast<const std::istringstream&>(stream()).str();
|
||||
|
||||
@ -57,7 +57,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Set stream status
|
||||
//- Construct and set stream status
|
||||
OStringStream
|
||||
(
|
||||
streamFormat format=ASCII,
|
||||
@ -106,6 +106,7 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the string
|
||||
string str() const
|
||||
{
|
||||
return dynamic_cast<const std::ostringstream&>(stream()).str();
|
||||
|
||||
@ -92,28 +92,29 @@ public:
|
||||
//- Standard punctuation tokens
|
||||
enum punctuationToken
|
||||
{
|
||||
NULL_TOKEN = '\0',
|
||||
SPACE = ' ',
|
||||
TAB = '\t',
|
||||
NL = '\n',
|
||||
NULL_TOKEN = '\0',
|
||||
SPACE = ' ',
|
||||
TAB = '\t',
|
||||
NL = '\n',
|
||||
|
||||
END_STATEMENT = ';',
|
||||
BEGIN_LIST = '(',
|
||||
END_LIST = ')',
|
||||
BEGIN_SQR = '[',
|
||||
END_SQR = ']',
|
||||
BEGIN_BLOCK = '{',
|
||||
END_BLOCK = '}',
|
||||
COLON = ':',
|
||||
COMMA = ',',
|
||||
BEGIN_STRING = '"',
|
||||
END_STRING = '"',
|
||||
END_STATEMENT = ';',
|
||||
BEGIN_LIST = '(',
|
||||
END_LIST = ')',
|
||||
BEGIN_SQR = '[',
|
||||
END_SQR = ']',
|
||||
BEGIN_BLOCK = '{',
|
||||
END_BLOCK = '}',
|
||||
COLON = ':',
|
||||
COMMA = ',',
|
||||
|
||||
ASSIGN = '=',
|
||||
ADD = '+',
|
||||
SUBTRACT = '-',
|
||||
MULTIPLY = '*',
|
||||
DIVIDE = '/'
|
||||
BEGIN_STRING = '"',
|
||||
END_STRING = BEGIN_STRING,
|
||||
|
||||
ASSIGN = '=',
|
||||
ADD = '+',
|
||||
SUBTRACT = '-',
|
||||
MULTIPLY = '*',
|
||||
DIVIDE = '/'
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -35,6 +35,20 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
dimensioned<Type> dimensioned<Type>::lookupOrDefault
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const Type& defaultValue,
|
||||
const dimensionSet& dims
|
||||
)
|
||||
{
|
||||
Type value = dict.lookupOrDefault<Type>(name, defaultValue);
|
||||
return dimensioned<Type>(name, dims, value);
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
dimensioned<Type> dimensioned<Type>::lookupOrAddToDict
|
||||
(
|
||||
|
||||
@ -108,8 +108,17 @@ public:
|
||||
//- Construct from an Istream with a given name and dimensions
|
||||
dimensioned(const word&, const dimensionSet&, Istream&);
|
||||
|
||||
//- Construct from dictionary, supplying default value so that if the
|
||||
// value is not found, it is added into the dictionary.
|
||||
//- Construct from dictionary, with default value.
|
||||
static dimensioned<Type> lookupOrDefault
|
||||
(
|
||||
const word&,
|
||||
const dictionary&,
|
||||
const Type& defaultValue = pTraits<Type>::zero,
|
||||
const dimensionSet& dims = dimless
|
||||
);
|
||||
|
||||
//- Construct from dictionary, with default value.
|
||||
// If the value is not found, it is added into the dictionary.
|
||||
static dimensioned<Type> lookupOrAddToDict
|
||||
(
|
||||
const word&,
|
||||
@ -148,8 +157,7 @@ public:
|
||||
//- Return transpose.
|
||||
dimensioned<Type> T() const;
|
||||
|
||||
//- Update the value of the dimensioned<Type> if it is found in the
|
||||
// dictionary
|
||||
//- Update the value of dimensioned<Type> if found in the dictionary.
|
||||
bool readIfPresent(const dictionary&);
|
||||
|
||||
|
||||
|
||||
@ -271,16 +271,6 @@ DimensionedField<Type, GeoMesh>::~DimensionedField()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Return a null Field
|
||||
template<class Type, class GeoMesh>
|
||||
const DimensionedField<Type, GeoMesh>& DimensionedField<Type, GeoMesh>::null()
|
||||
{
|
||||
DimensionedField<Type, GeoMesh>* nullPtr =
|
||||
reinterpret_cast<DimensionedField<Type, GeoMesh>*>(NULL);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
tmp
|
||||
<
|
||||
|
||||
@ -100,6 +100,11 @@ public:
|
||||
//- Runtime type information
|
||||
TypeName("DimensionedField");
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null DimensionedField
|
||||
inline static const DimensionedField<Type, GeoMesh>& null();
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -232,9 +237,6 @@ public:
|
||||
|
||||
inline Field<Type>& field();
|
||||
|
||||
//- Return a null DimensionedField
|
||||
static const DimensionedField<Type, GeoMesh>& null();
|
||||
|
||||
//- Return a component field of the field
|
||||
tmp<DimensionedField<cmptType, GeoMesh> > component
|
||||
(
|
||||
|
||||
@ -31,6 +31,14 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
inline const DimensionedField<Type, GeoMesh>&
|
||||
DimensionedField<Type, GeoMesh>::null()
|
||||
{
|
||||
return *reinterpret_cast< DimensionedField<Type, GeoMesh>* >(0);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
inline const typename GeoMesh::Mesh&
|
||||
DimensionedField<Type, GeoMesh>::mesh() const
|
||||
|
||||
@ -81,9 +81,7 @@ template<class Type, class GeoMesh>
|
||||
inline const SubDimensionedField<Type, GeoMesh>&
|
||||
SubDimensionedField<Type, GeoMesh>::null()
|
||||
{
|
||||
SubDimensionedField<Type, GeoMesh>* nullPtr
|
||||
= reinterpret_cast<SubDimensionedField<Type, GeoMesh>*>(NULL);
|
||||
return *nullPtr;
|
||||
return *reinterpret_cast< SubDimensionedField<Type, GeoMesh>* >(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -430,10 +430,7 @@ Type max(const FieldField<Field, Type>& f)
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("max(const FieldField<Field, Type>&) const")
|
||||
<< "empty fieldField, returning zero" << endl;
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
return pTraits<Type>::min;
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,10 +461,7 @@ Type min(const FieldField<Field, Type>& f)
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("min(const FieldField<Field, Type>&) const")
|
||||
<< "empty fieldField, returning zero" << endl;
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
return pTraits<Type>::max;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -298,14 +298,6 @@ tmp<Field<Type> > Field<Type>::clone() const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Field<Type>& Field<Type>::null()
|
||||
{
|
||||
Field<Type>* nullPtr = reinterpret_cast<Field<Type>*>(NULL);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Field<Type>::map
|
||||
(
|
||||
|
||||
@ -98,6 +98,15 @@ public:
|
||||
static const char* const typeName;
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null field
|
||||
inline static const Field<Type>& null()
|
||||
{
|
||||
return *reinterpret_cast< Field<Type>* >(0);
|
||||
}
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
@ -198,11 +207,7 @@ public:
|
||||
#endif
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return a null Field
|
||||
static const Field<Type>& null();
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- 1 to 1 map from the given field
|
||||
void map
|
||||
|
||||
@ -319,10 +319,7 @@ Type max(const UList<Type>& f)
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("max(const UList<Type>&)")
|
||||
<< "empty field, returning zero" << endl;
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
return pTraits<Type>::min;
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,10 +336,7 @@ Type min(const UList<Type>& f)
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("min(const UList<Type>&)")
|
||||
<< "empty field, returning zero" << endl;
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
return pTraits<Type>::max;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -74,8 +74,7 @@ inline Foam::SubField<Type>::SubField
|
||||
template<class Type>
|
||||
inline const Foam::SubField<Type>& Foam::SubField<Type>::null()
|
||||
{
|
||||
SubField<Type>* nullPtr = reinterpret_cast<SubField<Type>*>(NULL);
|
||||
return *nullPtr;
|
||||
return *reinterpret_cast< SubField<Type>* >(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ void Foam::transform
|
||||
}
|
||||
else
|
||||
{
|
||||
rtf = vector::zero;
|
||||
rtf = tf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -887,16 +887,6 @@ writeData(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
const Foam::GeometricField<Type, PatchField, GeoMesh>&
|
||||
Foam::GeometricField<Type, PatchField, GeoMesh>::null()
|
||||
{
|
||||
GeometricField<Type, PatchField, GeoMesh>* nullPtr =
|
||||
reinterpret_cast<GeometricField<Type, PatchField, GeoMesh>*>(NULL);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >
|
||||
Foam::GeometricField<Type, PatchField, GeoMesh>::T() const
|
||||
|
||||
@ -254,6 +254,11 @@ public:
|
||||
|
||||
typedef typename Field<Type>::cmptType cmptType;
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null geometric field
|
||||
inline static const GeometricField<Type, PatchField, GeoMesh>& null();
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -381,7 +386,7 @@ public:
|
||||
virtual ~GeometricField();
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Return dimensioned internal field
|
||||
DimensionedInternalField& dimensionedInternalField();
|
||||
@ -435,9 +440,6 @@ public:
|
||||
//- Does the field need a reference level for solution
|
||||
bool needReference() const;
|
||||
|
||||
//- Return a null geometric field
|
||||
static const GeometricField<Type, PatchField, GeoMesh>& null();
|
||||
|
||||
//- Return a component of the field
|
||||
tmp<GeometricField<cmptType, PatchField, GeoMesh> > component
|
||||
(
|
||||
|
||||
@ -27,8 +27,16 @@ License
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
inline
|
||||
const typename
|
||||
inline const Foam::GeometricField<Type, PatchField, GeoMesh>&
|
||||
Foam::GeometricField<Type, PatchField, GeoMesh>::null()
|
||||
{
|
||||
return *reinterpret_cast< GeometricField<Type, PatchField, GeoMesh>* >(0);
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
inline
|
||||
const typename
|
||||
Foam::GeometricField<Type, PatchField, GeoMesh>::DimensionedInternalField&
|
||||
Foam::GeometricField<Type, PatchField, GeoMesh>::
|
||||
dimensionedInternalField() const
|
||||
@ -36,6 +44,7 @@ dimensionedInternalField() const
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
inline
|
||||
const typename
|
||||
|
||||
@ -75,7 +75,7 @@ void MapGeometricFields
|
||||
{
|
||||
HashTable<const GeometricField<Type, PatchField, GeoMesh>*> fields
|
||||
(
|
||||
mapper.db().objectRegistry::lookupClass
|
||||
mapper.thisDb().objectRegistry::lookupClass
|
||||
<GeometricField<Type, PatchField, GeoMesh> >()
|
||||
);
|
||||
|
||||
@ -145,7 +145,7 @@ void MapGeometricFields
|
||||
);
|
||||
}
|
||||
|
||||
field.instance() = field.mesh().db().time().timeName();
|
||||
field.instance() = field.time().timeName();
|
||||
}
|
||||
else if (polyMesh::debug)
|
||||
{
|
||||
|
||||
@ -59,14 +59,6 @@ Foam::Matrix<Form, Type>::~Matrix()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Form, class Type>
|
||||
const Foam::Matrix<Form, Type>& Foam::Matrix<Form, Type>::null()
|
||||
{
|
||||
Matrix<Form, Type>* nullPtr = reinterpret_cast<Matrix<Form, Type>*>(NULL);
|
||||
return *nullPtr;
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Type>
|
||||
Foam::Matrix<Form, Type>::Matrix(const label n, const label m)
|
||||
:
|
||||
@ -356,7 +348,7 @@ Form Foam::operator+(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
|
||||
const Type* av = a.v_[0];
|
||||
const Type* bv = b.v_[0];
|
||||
|
||||
label nm = a.n_*a.m_;;
|
||||
label nm = a.n_*a.m_;
|
||||
for (register label i=0; i<nm; i++)
|
||||
{
|
||||
abv[i] = av[i] + bv[i];
|
||||
@ -395,7 +387,7 @@ Form Foam::operator-(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
|
||||
const Type* av = a.v_[0];
|
||||
const Type* bv = b.v_[0];
|
||||
|
||||
label nm = a.n_*a.m_;;
|
||||
label nm = a.n_*a.m_;
|
||||
for (register label i=0; i<nm; i++)
|
||||
{
|
||||
abv[i] = av[i] - bv[i];
|
||||
|
||||
@ -88,6 +88,12 @@ class Matrix
|
||||
|
||||
public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Return a null Matrix
|
||||
inline static const Matrix<Form, Type>& null();
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor.
|
||||
@ -115,11 +121,7 @@ public:
|
||||
~Matrix();
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return a null Matrix
|
||||
static const Matrix<Form, Type>& null();
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
|
||||
@ -44,6 +44,13 @@ inline Foam::autoPtr<Foam::Matrix<Form, Type> > Foam::Matrix<Form, Type>::clone(
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Form, class Type>
|
||||
inline const Foam::Matrix<Form, Type>& Foam::Matrix<Form, Type>::null()
|
||||
{
|
||||
return *reinterpret_cast< Matrix<Form, Type>* >(0);
|
||||
}
|
||||
|
||||
|
||||
//- Return the number of rows
|
||||
template<class Form, class Type>
|
||||
inline Foam::label Foam::Matrix<Form, Type>::n() const
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user