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);
|
fvc::makeAbsolute(phi, rho, U);
|
||||||
|
|
||||||
// Test : disable refinement for some cells
|
// Test : disable refinement for some cells
|
||||||
PackedList<1>& protectedCell =
|
PackedBoolList& protectedCell =
|
||||||
refCast<dynamicRefineFvMesh>(mesh).protectedCell();
|
refCast<dynamicRefineFvMesh>(mesh).protectedCell();
|
||||||
|
|
||||||
if (protectedCell.empty())
|
if (protectedCell.empty())
|
||||||
|
|||||||
@ -395,7 +395,7 @@ Foam::laminarFlameSpeedModels::SCOPE::Ma() const
|
|||||||
(
|
(
|
||||||
"Ma",
|
"Ma",
|
||||||
mesh.time().timeName(),
|
mesh.time().timeName(),
|
||||||
mesh.db(),
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
),
|
),
|
||||||
|
|||||||
@ -161,6 +161,19 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
|
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
|
||||||
<< " " << dlD.size() << "/" << dlD.capacity() << endl;
|
<< " " << 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;
|
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 "polyMesh.H"
|
||||||
#include "mapPolyMesh.H"
|
#include "mapPolyMesh.H"
|
||||||
#include "mathematicalConstants.H"
|
#include "mathematicalConstants.H"
|
||||||
#include "PackedList.H"
|
#include "PackedBoolList.H"
|
||||||
#include "SortableList.H"
|
#include "SortableList.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
@ -177,7 +177,7 @@ label mergeEdges
|
|||||||
|
|
||||||
|
|
||||||
// Return master point edge needs to be collapsed to (or -1)
|
// 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;
|
label masterPoint = -1;
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e)
|
|||||||
label collapseSmallEdges
|
label collapseSmallEdges
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const PackedList<1>& boundaryPoint,
|
const PackedBoolList& boundaryPoint,
|
||||||
const scalar minLen,
|
const scalar minLen,
|
||||||
edgeCollapser& collapser
|
edgeCollapser& collapser
|
||||||
)
|
)
|
||||||
@ -254,7 +254,7 @@ label collapseSmallEdges
|
|||||||
label collapseHighAspectFaces
|
label collapseHighAspectFaces
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const PackedList<1>& boundaryPoint,
|
const PackedBoolList& boundaryPoint,
|
||||||
const scalar areaFac,
|
const scalar areaFac,
|
||||||
const scalar edgeRatio,
|
const scalar edgeRatio,
|
||||||
edgeCollapser& collapser
|
edgeCollapser& collapser
|
||||||
@ -346,7 +346,7 @@ void set(const labelList& elems, const bool val, boolList& status)
|
|||||||
label simplifyFaces
|
label simplifyFaces
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const PackedList<1>& boundaryPoint,
|
const PackedBoolList& boundaryPoint,
|
||||||
const label minSize,
|
const label minSize,
|
||||||
const scalar lenGap,
|
const scalar lenGap,
|
||||||
edgeCollapser& collapser
|
edgeCollapser& collapser
|
||||||
@ -485,7 +485,7 @@ int main(int argc, char *argv[])
|
|||||||
const faceList& faces = mesh.faces();
|
const faceList& faces = mesh.faces();
|
||||||
|
|
||||||
// Get all points on the boundary
|
// Get all points on the boundary
|
||||||
PackedList<1> boundaryPoint(mesh.nPoints(), false);
|
PackedBoolList boundaryPoint(mesh.nPoints());
|
||||||
|
|
||||||
label nIntFaces = mesh.nInternalFaces();
|
label nIntFaces = mesh.nInternalFaces();
|
||||||
for (label faceI = nIntFaces; faceI < mesh.nFaces(); faceI++)
|
for (label faceI = nIntFaces; faceI < mesh.nFaces(); faceI++)
|
||||||
|
|||||||
@ -51,7 +51,7 @@ cellShape create3DCellShape
|
|||||||
static List<const cellModel*> fluentCellModelLookup
|
static List<const cellModel*> fluentCellModelLookup
|
||||||
(
|
(
|
||||||
7,
|
7,
|
||||||
reinterpret_cast<const cellModel*>(NULL)
|
reinterpret_cast<const cellModel*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
fluentCellModelLookup[2] = cellModeller::lookup("tet");
|
fluentCellModelLookup[2] = cellModeller::lookup("tet");
|
||||||
|
|||||||
@ -49,7 +49,7 @@ Description
|
|||||||
#include "mathematicalConstants.H"
|
#include "mathematicalConstants.H"
|
||||||
#include "polyTopoChange.H"
|
#include "polyTopoChange.H"
|
||||||
#include "mapPolyMesh.H"
|
#include "mapPolyMesh.H"
|
||||||
#include "PackedList.H"
|
#include "PackedBoolList.H"
|
||||||
#include "meshTools.H"
|
#include "meshTools.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
#include "meshDualiser.H"
|
#include "meshDualiser.H"
|
||||||
@ -67,7 +67,7 @@ using namespace Foam;
|
|||||||
void simpleMarkFeatures
|
void simpleMarkFeatures
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const PackedList<1>& isBoundaryEdge,
|
const PackedBoolList& isBoundaryEdge,
|
||||||
const scalar featureAngle,
|
const scalar featureAngle,
|
||||||
const bool doNotPreserveFaceZones,
|
const bool doNotPreserveFaceZones,
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ int main(int argc, char *argv[])
|
|||||||
// Mark boundary edges and points.
|
// Mark boundary edges and points.
|
||||||
// (Note: in 1.4.2 we can use the built-in mesh point ordering
|
// (Note: in 1.4.2 we can use the built-in mesh point ordering
|
||||||
// facility instead)
|
// facility instead)
|
||||||
PackedList<1> isBoundaryEdge(mesh.nEdges());
|
PackedBoolList isBoundaryEdge(mesh.nEdges());
|
||||||
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
|
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
|
||||||
{
|
{
|
||||||
const labelList& fEdges = mesh.faceEdges()[faceI];
|
const labelList& fEdges = mesh.faceEdges()[faceI];
|
||||||
|
|||||||
@ -155,7 +155,7 @@ Foam::label Foam::meshDualiser::findDualCell
|
|||||||
// from (boundary & feature) point
|
// from (boundary & feature) point
|
||||||
void Foam::meshDualiser::generateDualBoundaryEdges
|
void Foam::meshDualiser::generateDualBoundaryEdges
|
||||||
(
|
(
|
||||||
const PackedList<1>& isBoundaryEdge,
|
const PackedBoolList& isBoundaryEdge,
|
||||||
const label pointI,
|
const label pointI,
|
||||||
polyTopoChange& meshMod
|
polyTopoChange& meshMod
|
||||||
)
|
)
|
||||||
@ -388,7 +388,7 @@ Foam::label Foam::meshDualiser::addBoundaryFace
|
|||||||
void Foam::meshDualiser::createFacesAroundEdge
|
void Foam::meshDualiser::createFacesAroundEdge
|
||||||
(
|
(
|
||||||
const bool splitFace,
|
const bool splitFace,
|
||||||
const PackedList<1>& isBoundaryEdge,
|
const PackedBoolList& isBoundaryEdge,
|
||||||
const label edgeI,
|
const label edgeI,
|
||||||
const label startFaceI,
|
const label startFaceI,
|
||||||
polyTopoChange& meshMod,
|
polyTopoChange& meshMod,
|
||||||
@ -907,7 +907,7 @@ void Foam::meshDualiser::setRefinement
|
|||||||
// Mark boundary edges and points.
|
// Mark boundary edges and points.
|
||||||
// (Note: in 1.4.2 we can use the built-in mesh point ordering
|
// (Note: in 1.4.2 we can use the built-in mesh point ordering
|
||||||
// facility instead)
|
// facility instead)
|
||||||
PackedList<1> isBoundaryEdge(mesh_.nEdges());
|
PackedBoolList isBoundaryEdge(mesh_.nEdges());
|
||||||
for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
|
for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
|
||||||
{
|
{
|
||||||
const labelList& fEdges = mesh_.faceEdges()[faceI];
|
const labelList& fEdges = mesh_.faceEdges()[faceI];
|
||||||
|
|||||||
@ -49,7 +49,7 @@ SourceFiles
|
|||||||
#define meshDualiser_H
|
#define meshDualiser_H
|
||||||
|
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
#include "PackedList.H"
|
#include "PackedBoolList.H"
|
||||||
#include "boolList.H"
|
#include "boolList.H"
|
||||||
#include "typeInfo.H"
|
#include "typeInfo.H"
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ class meshDualiser
|
|||||||
// emanating from (boundary & feature) point
|
// emanating from (boundary & feature) point
|
||||||
void generateDualBoundaryEdges
|
void generateDualBoundaryEdges
|
||||||
(
|
(
|
||||||
const PackedList<1>&,
|
const PackedBoolList&,
|
||||||
const label pointI,
|
const label pointI,
|
||||||
polyTopoChange&
|
polyTopoChange&
|
||||||
);
|
);
|
||||||
@ -144,7 +144,7 @@ class meshDualiser
|
|||||||
void createFacesAroundEdge
|
void createFacesAroundEdge
|
||||||
(
|
(
|
||||||
const bool splitFace,
|
const bool splitFace,
|
||||||
const PackedList<1>&,
|
const PackedBoolList&,
|
||||||
const label edgeI,
|
const label edgeI,
|
||||||
const label startFaceI,
|
const label startFaceI,
|
||||||
polyTopoChange&,
|
polyTopoChange&,
|
||||||
|
|||||||
@ -90,13 +90,13 @@ const label sammMesh::shapeFaceLookup[19][9] =
|
|||||||
List<const cellModel*> sammMesh::sammShapeLookup
|
List<const cellModel*> sammMesh::sammShapeLookup
|
||||||
(
|
(
|
||||||
256,
|
256,
|
||||||
reinterpret_cast<cellModel*>(NULL)
|
reinterpret_cast<cellModel*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
List<const label*> sammMesh::sammAddressingTable
|
List<const label*> sammMesh::sammAddressingTable
|
||||||
(
|
(
|
||||||
256,
|
256,
|
||||||
reinterpret_cast<label*>(NULL)
|
reinterpret_cast<label*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|||||||
@ -48,7 +48,7 @@ void starMesh::addRegularCell
|
|||||||
label regularTypeFlag = -1;
|
label regularTypeFlag = -1;
|
||||||
|
|
||||||
// grab the shape from the table
|
// grab the shape from the table
|
||||||
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
|
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
|
||||||
|
|
||||||
if // Tetrahedron
|
if // Tetrahedron
|
||||||
(
|
(
|
||||||
@ -130,7 +130,7 @@ void starMesh::addSAMMcell
|
|||||||
|
|
||||||
// grab the shape from the table
|
// grab the shape from the table
|
||||||
label sammTypeFlag = -1;
|
label sammTypeFlag = -1;
|
||||||
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
|
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
|
||||||
|
|
||||||
switch (typeFlag)
|
switch (typeFlag)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -82,7 +82,7 @@ topoSetSources
|
|||||||
// Cells in cell zone
|
// Cells in cell zone
|
||||||
zoneToCell
|
zoneToCell
|
||||||
{
|
{
|
||||||
name ".*Zone"; // name of cellZone, wildcards allowed.
|
name ".*Zone"; // Name of cellZone, regular expressions allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
// values of field within certain range
|
// values of field within certain range
|
||||||
|
|||||||
@ -60,7 +60,7 @@ topoSetSources
|
|||||||
// All points in pointzone
|
// All points in pointzone
|
||||||
zoneToPoint
|
zoneToPoint
|
||||||
{
|
{
|
||||||
name ".*Zone"; // name of pointZone, wildcards allowed.
|
name ".*Zone"; // name of pointZone, regular expressions allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select based on surface
|
// Select based on surface
|
||||||
|
|||||||
@ -30,12 +30,17 @@ Description
|
|||||||
- any face inbetween differing cellZones (-cellZones)
|
- any face inbetween differing cellZones (-cellZones)
|
||||||
|
|
||||||
Output is:
|
Output is:
|
||||||
- mesh with multiple regions
|
- mesh with multiple regions or
|
||||||
- mesh with cells put into cellZones (-makeCellZones)
|
- 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
|
processor boundaries so use the correct option in decomposition to
|
||||||
preserve those interfaces.
|
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",
|
"fvSchemes",
|
||||||
mesh.time().system(),
|
mesh.time().system(),
|
||||||
regionName,
|
regionName,
|
||||||
mesh.db(),
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
@ -642,7 +647,7 @@ autoPtr<mapPolyMesh> createRegionMesh
|
|||||||
"fvSolution",
|
"fvSolution",
|
||||||
mesh.time().system(),
|
mesh.time().system(),
|
||||||
regionName,
|
regionName,
|
||||||
mesh.db(),
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE,
|
IOobject::NO_WRITE,
|
||||||
false
|
false
|
||||||
@ -1036,78 +1041,181 @@ EdgeMap<label> addRegionPatches
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Checks if regionI in cellRegion corresponds to existing zone.
|
//// Checks if regionI in cellRegion is subset of existing cellZone. Returns -1
|
||||||
label findCorrespondingZone
|
//// 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, // per cell the (unique) zoneID
|
||||||
const labelList& existingZoneID,
|
const regionSplit& cellRegion,
|
||||||
const labelList& cellRegion,
|
const label zoneI,
|
||||||
const label regionI
|
const label minOverlapSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Zone corresponding to region. No corresponding zone.
|
// Per region the number of cells in zoneI
|
||||||
label zoneI = labelMax;
|
labelList cellsInZone(cellRegion.nRegions(), 0);
|
||||||
|
|
||||||
labelList regionCells = findIndices(cellRegion, regionI);
|
forAll(cellRegion, cellI)
|
||||||
|
|
||||||
if (regionCells.empty())
|
|
||||||
{
|
{
|
||||||
// My local portion is empty. Maps to any empty cellZone. Mark with
|
if (existingZoneID[cellI] == zoneI)
|
||||||
// special value which can get overwritten by other processors.
|
{
|
||||||
zoneI = -1;
|
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
|
else
|
||||||
{
|
{
|
||||||
// Get zone for first element.
|
// Check that region contains no cells that aren't in cellZone.
|
||||||
zoneI = existingZoneID[regionCells[0]];
|
forAll(cellRegion, cellI)
|
||||||
|
|
||||||
if (zoneI == -1)
|
|
||||||
{
|
{
|
||||||
zoneI = labelMax;
|
if (cellRegion[cellI] == regionI && existingZoneID[cellI] != zoneI)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// 1. All regionCells in zoneI?
|
// cellI in regionI but not in zoneI
|
||||||
forAll(regionCells, i)
|
regionI = -1;
|
||||||
{
|
|
||||||
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;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If one in error, all should be in error. Note that branch gets taken
|
// If one in error, all should be in error. Note that branch gets taken
|
||||||
// on all procs.
|
// 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:
|
// Main program:
|
||||||
@ -1120,6 +1228,8 @@ int main(int argc, char *argv[])
|
|||||||
argList::validOptions.insert("largestOnly", "");
|
argList::validOptions.insert("largestOnly", "");
|
||||||
argList::validOptions.insert("insidePoint", "point");
|
argList::validOptions.insert("insidePoint", "point");
|
||||||
argList::validOptions.insert("overwrite", "");
|
argList::validOptions.insert("overwrite", "");
|
||||||
|
argList::validOptions.insert("detectOnly", "");
|
||||||
|
argList::validOptions.insert("sloppyCellZones", "");
|
||||||
|
|
||||||
# include "setRootCase.H"
|
# include "setRootCase.H"
|
||||||
# include "createTime.H"
|
# include "createTime.H"
|
||||||
@ -1134,10 +1244,13 @@ int main(int argc, char *argv[])
|
|||||||
<< blockedFacesName << nl << endl;
|
<< blockedFacesName << nl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool makeCellZones = args.options().found("makeCellZones");
|
||||||
bool largestOnly = args.options().found("largestOnly");
|
bool largestOnly = args.options().found("largestOnly");
|
||||||
bool insidePoint = args.options().found("insidePoint");
|
bool insidePoint = args.options().found("insidePoint");
|
||||||
bool useCellZones = args.options().found("cellZones");
|
bool useCellZones = args.options().found("cellZones");
|
||||||
bool overwrite = args.options().found("overwrite");
|
bool overwrite = args.options().found("overwrite");
|
||||||
|
bool detectOnly = args.options().found("detectOnly");
|
||||||
|
bool sloppyCellZones = args.options().found("sloppyCellZones");
|
||||||
|
|
||||||
if (insidePoint && largestOnly)
|
if (insidePoint && largestOnly)
|
||||||
{
|
{
|
||||||
@ -1281,6 +1394,31 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Writing region per cell file (for manual decomposition) to "
|
Info<< "Writing region per cell file (for manual decomposition) to "
|
||||||
<< cellToRegion.objectPath() << nl << endl;
|
<< 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
|
// Sizes per region
|
||||||
@ -1307,40 +1445,131 @@ int main(int argc, char *argv[])
|
|||||||
Info<< endl;
|
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
|
// Whether region corresponds to a cellzone
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Info<< "Region\tZone\tName" << nl
|
|
||||||
<< "------\t----\t----" << endl;
|
|
||||||
|
|
||||||
// Region per zone
|
// Region per zone
|
||||||
labelList regionToZone(cellRegion.nRegions());
|
labelList regionToZone(cellRegion.nRegions(), -1);
|
||||||
// Name of region
|
// Name of region
|
||||||
wordList regionNames(cellRegion.nRegions());
|
wordList regionNames(cellRegion.nRegions());
|
||||||
forAll(regionToZone, regionI)
|
// Zone to region
|
||||||
|
labelList zoneToRegion(cellZones.size(), -1);
|
||||||
|
|
||||||
|
if (sloppyCellZones)
|
||||||
{
|
{
|
||||||
regionToZone[regionI] = findCorrespondingZone
|
Info<< "Trying to match regions to existing cell zones;"
|
||||||
|
<< " region can be subset of cell zone." << nl << endl;
|
||||||
|
|
||||||
|
forAll(cellZones, zoneI)
|
||||||
|
{
|
||||||
|
label regionI = findCorrespondingRegion
|
||||||
(
|
(
|
||||||
cellZones,
|
|
||||||
zoneID,
|
zoneID,
|
||||||
cellRegion,
|
cellRegion,
|
||||||
regionI
|
zoneI,
|
||||||
|
label(0.5*zoneSizes[zoneI]) // minimum overlap
|
||||||
);
|
);
|
||||||
|
|
||||||
if (regionToZone[regionI] != -1)
|
if (regionI != -1)
|
||||||
{
|
{
|
||||||
regionNames[regionI] = cellZones[regionToZone[regionI]].name();
|
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
|
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)
|
||||||
|
{
|
||||||
|
if (regionToZone[regionI] == -1)
|
||||||
{
|
{
|
||||||
regionNames[regionI] = "domain" + Foam::name(regionI);
|
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'
|
Info<< regionI << '\t' << regionToZone[regionI] << '\t'
|
||||||
<< regionNames[regionI] << nl;
|
<< regionNames[regionI] << nl;
|
||||||
}
|
}
|
||||||
Info<< endl;
|
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
|
// Since we're going to mess with patches make sure all non-processor ones
|
||||||
// are on all processors.
|
// are on all processors.
|
||||||
@ -1361,7 +1590,8 @@ int main(int argc, char *argv[])
|
|||||||
interfaceSizes
|
interfaceSizes
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "Region\tRegion\tFaces" << nl
|
Info<< "Sizes inbetween regions:" << nl << nl
|
||||||
|
<< "Region\tRegion\tFaces" << nl
|
||||||
<< "------\t------\t-----" << endl;
|
<< "------\t------\t-----" << endl;
|
||||||
|
|
||||||
forAll(interfaces, interI)
|
forAll(interfaces, interI)
|
||||||
@ -1373,7 +1603,10 @@ int main(int argc, char *argv[])
|
|||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
|
||||||
|
if (detectOnly)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read objects in time directory
|
// Read objects in time directory
|
||||||
@ -1423,7 +1656,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< "Only one region. Doing nothing." << endl;
|
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."
|
Info<< "Putting cells into cellZones instead of splitting mesh."
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|||||||
@ -299,7 +299,7 @@ bool domainDecomposition::writeDecomposition()
|
|||||||
(
|
(
|
||||||
curPatchSizes.size()
|
curPatchSizes.size()
|
||||||
+ curProcessorPatchSizes.size(),
|
+ curProcessorPatchSizes.size(),
|
||||||
reinterpret_cast<polyPatch*>(NULL)
|
reinterpret_cast<polyPatch*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
label nPatches = 0;
|
label nPatches = 0;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ int nFields = volScalarNames.size() + 3*volVectorNames.size();
|
|||||||
List<volScalarField*> volFieldPtrs
|
List<volScalarField*> volFieldPtrs
|
||||||
(
|
(
|
||||||
nFields,
|
nFields,
|
||||||
reinterpret_cast<volScalarField*>(NULL)
|
reinterpret_cast<volScalarField*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
stringList volFieldNames(nFields);
|
stringList volFieldNames(nFields);
|
||||||
@ -27,8 +27,7 @@ nFields = 0;
|
|||||||
|
|
||||||
if (ioHeader.headerOk())
|
if (ioHeader.headerOk())
|
||||||
{
|
{
|
||||||
volFieldPtrs[nFields] =
|
volFieldPtrs[nFields] = new volScalarField
|
||||||
new volScalarField
|
|
||||||
(
|
(
|
||||||
ioHeader,
|
ioHeader,
|
||||||
mesh
|
mesh
|
||||||
@ -106,7 +105,7 @@ int nSurfFields = surfScalarNames.size() + 3*surfVectorNames.size();
|
|||||||
List<surfaceScalarField*> surfFieldPtrs
|
List<surfaceScalarField*> surfFieldPtrs
|
||||||
(
|
(
|
||||||
nSurfFields,
|
nSurfFields,
|
||||||
reinterpret_cast<surfaceScalarField*>(NULL)
|
reinterpret_cast<surfaceScalarField*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
stringList surfFieldNames(nSurfFields);
|
stringList surfFieldNames(nSurfFields);
|
||||||
|
|||||||
@ -2,13 +2,13 @@
|
|||||||
List<IOField<scalar>* > sprayScalarFieldPtrs
|
List<IOField<scalar>* > sprayScalarFieldPtrs
|
||||||
(
|
(
|
||||||
sprayScalarNames.size(),
|
sprayScalarNames.size(),
|
||||||
reinterpret_cast<IOField<scalar>*>(NULL)
|
reinterpret_cast<IOField<scalar>*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
List<IOField<vector>* > sprayVectorFieldPtrs
|
List<IOField<vector>* > sprayVectorFieldPtrs
|
||||||
(
|
(
|
||||||
sprayVectorNames.size(),
|
sprayVectorNames.size(),
|
||||||
reinterpret_cast<IOField<vector>*>(NULL)
|
reinterpret_cast<IOField<vector>*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@ -108,13 +108,13 @@ int main(int argc, char *argv[])
|
|||||||
List<volScalarField*> sFields
|
List<volScalarField*> sFields
|
||||||
(
|
(
|
||||||
nCols,
|
nCols,
|
||||||
reinterpret_cast<volScalarField*>(NULL)
|
reinterpret_cast<volScalarField*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
List<volVectorField*> vFields
|
List<volVectorField*> vFields
|
||||||
(
|
(
|
||||||
nCols,
|
nCols,
|
||||||
reinterpret_cast<volVectorField*>(NULL)
|
reinterpret_cast<volVectorField*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
label i=0;
|
label i=0;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|||||||
@ -34,6 +34,9 @@ Usage
|
|||||||
@param -clean \n
|
@param -clean \n
|
||||||
Perform some surface checking/cleanup on the input surface
|
Perform some surface checking/cleanup on the input surface
|
||||||
|
|
||||||
|
@param -orient \n
|
||||||
|
Check face orientation on the input surface
|
||||||
|
|
||||||
@param -scale \<scale\> \n
|
@param -scale \<scale\> \n
|
||||||
Specify a scaling factor for writing the files
|
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("inputFile");
|
||||||
argList::validArgs.append("outputFile");
|
argList::validArgs.append("outputFile");
|
||||||
argList::validOptions.insert("clean", "");
|
argList::validOptions.insert("clean", "");
|
||||||
|
argList::validOptions.insert("orient", "");
|
||||||
argList::validOptions.insert("scale", "scale");
|
argList::validOptions.insert("scale", "scale");
|
||||||
argList::validOptions.insert("triSurface", "");
|
argList::validOptions.insert("triSurface", "");
|
||||||
argList::validOptions.insert("unsorted", "");
|
argList::validOptions.insert("unsorted", "");
|
||||||
@ -108,6 +112,13 @@ int main(int argc, char *argv[])
|
|||||||
surf.writeStats(Info);
|
surf.writeStats(Info);
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
if (args.options().found("orient"))
|
||||||
|
{
|
||||||
|
Info<< "Checking surface orientation" << endl;
|
||||||
|
surf.checkOrientation(true);
|
||||||
|
Info<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
Info<< "Cleaning up surface" << endl;
|
Info<< "Cleaning up surface" << endl;
|
||||||
@ -140,6 +151,13 @@ int main(int argc, char *argv[])
|
|||||||
surf.writeStats(Info);
|
surf.writeStats(Info);
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
if (args.options().found("orient"))
|
||||||
|
{
|
||||||
|
Info<< "Checking surface orientation" << endl;
|
||||||
|
surf.checkOrientation(true);
|
||||||
|
Info<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
Info<< "Cleaning up surface" << endl;
|
Info<< "Cleaning up surface" << endl;
|
||||||
@ -171,6 +189,13 @@ int main(int argc, char *argv[])
|
|||||||
surf.writeStats(Info);
|
surf.writeStats(Info);
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
if (args.options().found("orient"))
|
||||||
|
{
|
||||||
|
Info<< "Checking surface orientation" << endl;
|
||||||
|
surf.checkOrientation(true);
|
||||||
|
Info<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
Info<< "Cleaning up surface" << endl;
|
Info<< "Cleaning up surface" << endl;
|
||||||
@ -202,6 +227,13 @@ int main(int argc, char *argv[])
|
|||||||
surf.writeStats(Info);
|
surf.writeStats(Info);
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
|
if (args.options().found("orient"))
|
||||||
|
{
|
||||||
|
Info<< "Checking surface orientation" << endl;
|
||||||
|
surf.checkOrientation(true);
|
||||||
|
Info<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.options().found("clean"))
|
if (args.options().found("clean"))
|
||||||
{
|
{
|
||||||
Info<< "Cleaning up surface" << endl;
|
Info<< "Cleaning up surface" << endl;
|
||||||
|
|||||||
@ -687,6 +687,7 @@ DebugSwitches
|
|||||||
staticFvMesh 0;
|
staticFvMesh 0;
|
||||||
steadyState 0;
|
steadyState 0;
|
||||||
stl 0;
|
stl 0;
|
||||||
|
string 0;
|
||||||
stochasticDispersionRAS 0;
|
stochasticDispersionRAS 0;
|
||||||
supersonicFreestream 0;
|
supersonicFreestream 0;
|
||||||
surfaceFeatures 0;
|
surfaceFeatures 0;
|
||||||
|
|||||||
@ -112,6 +112,12 @@ public:
|
|||||||
|
|
||||||
//- Access
|
//- Access
|
||||||
|
|
||||||
|
//- Return true if a precompiled expression does not exist
|
||||||
|
inline bool empty() const
|
||||||
|
{
|
||||||
|
return !preg_;
|
||||||
|
}
|
||||||
|
|
||||||
//- Does a precompiled expression exist?
|
//- Does a precompiled expression exist?
|
||||||
inline bool exists() const
|
inline bool exists() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,19 +25,13 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
|
|
||||||
#include "HashPtrTable.H"
|
#include "HashPtrTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Construct given initial table size
|
// Construct given initial table size
|
||||||
template<class T, class Key, class Hash>
|
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)
|
HashTable<T*, Key, Hash>(size)
|
||||||
{}
|
{}
|
||||||
@ -45,7 +39,10 @@ HashPtrTable<T, Key, Hash>::HashPtrTable(label size)
|
|||||||
|
|
||||||
// Construct as copy
|
// Construct as copy
|
||||||
template<class T, class Key, class Hash>
|
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>()
|
HashTable<T*, Key, Hash>()
|
||||||
{
|
{
|
||||||
@ -59,7 +56,7 @@ HashPtrTable<T, Key, Hash>::HashPtrTable(const HashPtrTable<T, Key, Hash>& ht)
|
|||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
HashPtrTable<T, Key, Hash>::~HashPtrTable()
|
Foam::HashPtrTable<T, Key, Hash>::~HashPtrTable()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
@ -68,7 +65,7 @@ HashPtrTable<T, Key, Hash>::~HashPtrTable()
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
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;
|
T* elemPtr = *it;
|
||||||
HashTable<T*, Key, Hash>::erase(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>
|
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;
|
T* elemPtr = *it;
|
||||||
|
|
||||||
@ -98,7 +95,7 @@ bool HashPtrTable<T, Key, Hash>::erase(iterator& it)
|
|||||||
|
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
void HashPtrTable<T, Key, Hash>::clear()
|
void Foam::HashPtrTable<T, Key, Hash>::clear()
|
||||||
{
|
{
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
@ -117,10 +114,13 @@ void HashPtrTable<T, Key, Hash>::clear()
|
|||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
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
|
// Check for assignment to self
|
||||||
if (this == &ht)
|
if (this == &rhs)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
@ -132,17 +132,12 @@ void HashPtrTable<T, Key, Hash>::operator=(const HashPtrTable<T, Key, Hash>& ht)
|
|||||||
|
|
||||||
clear();
|
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));
|
insert(iter.key(), new T(**iter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#include "HashPtrTableIO.C"
|
#include "HashPtrTableIO.C"
|
||||||
|
|||||||
@ -83,7 +83,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct given initial table size
|
//- Construct given initial table size
|
||||||
HashPtrTable(label size = 100);
|
HashPtrTable(const label size = 100);
|
||||||
|
|
||||||
//- Construct from Istream using given Istream constructor class
|
//- Construct from Istream using given Istream constructor class
|
||||||
template<class INew>
|
template<class INew>
|
||||||
|
|||||||
@ -29,16 +29,11 @@ License
|
|||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
#include "INew.H"
|
#include "INew.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
template<class INew>
|
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&)");
|
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 T, class Key, class Hash>
|
||||||
template<class INew>
|
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);
|
read(is, inewt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
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>());
|
read(is, INew<T>());
|
||||||
}
|
}
|
||||||
@ -163,7 +158,7 @@ HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is)
|
|||||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, class Key, class Hash>
|
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.clear();
|
||||||
L.read(is, INew<T>());
|
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>
|
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
|
// Write size and start delimiter
|
||||||
os << nl << L.size() << nl << token::BEGIN_LIST << nl;
|
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
|
// Constructors
|
||||||
|
|
||||||
//- Construct given initial size
|
//- Construct given initial size
|
||||||
HashSet(label size = 100)
|
HashSet(const label size = 100)
|
||||||
:
|
:
|
||||||
HashTable<nil, Key, Hash>(size)
|
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
|
//- const_iterator set to the beginning of the HashTable
|
||||||
inline const_iterator begin() const;
|
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>
|
template<class T, class Key, class Hash>
|
||||||
inline typename Foam::HashTable<T, Key, Hash>::const_iterator
|
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;
|
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>
|
template<class T, class Key, class Hash>
|
||||||
inline const typename Foam::HashTable<T, Key, Hash>::const_iterator&
|
inline const typename Foam::HashTable<T, Key, Hash>::const_iterator&
|
||||||
Foam::HashTable<T, Key, Hash>::end() const
|
Foam::HashTable<T, Key, Hash>::end() const
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct given initial size
|
//- Construct given initial size
|
||||||
Map(label size = 100)
|
Map(const label size = 100)
|
||||||
:
|
:
|
||||||
HashTable<T, label, Hash<label> >(size)
|
HashTable<T, label, Hash<label> >(size)
|
||||||
{}
|
{}
|
||||||
@ -92,14 +92,6 @@ public:
|
|||||||
HashTable<T, label, Hash<label> >(map)
|
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
|
// Constructors
|
||||||
|
|
||||||
//- Construct given initial map size
|
//- Construct given initial map size
|
||||||
PtrMap(label size = 100)
|
PtrMap(const label size = 100)
|
||||||
:
|
:
|
||||||
HashPtrTable<T, label, Hash<label> >(size)
|
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();
|
inline iterator begin();
|
||||||
|
|
||||||
//- iterator set to beyond the end of the StaticHashTable
|
//- iterator set to beyond the end of the StaticHashTable
|
||||||
inline const iterator& end();
|
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;
|
inline const_iterator begin() const;
|
||||||
|
|
||||||
//- const_iterator set to beyond the end of the StaticHashTable
|
//- const_iterator set to beyond the end of the StaticHashTable
|
||||||
inline const const_iterator& end() const;
|
inline const const_iterator& end() const;
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operator
|
// IOstream Operator
|
||||||
|
|
||||||
friend Istream& operator>> <T, Key, Hash>
|
friend Istream& operator>> <T, Key, Hash>
|
||||||
|
|||||||
@ -355,7 +355,7 @@ Foam::StaticHashTable<T, Key, Hash>::end()
|
|||||||
|
|
||||||
template<class T, class Key, class Hash>
|
template<class T, class Key, class Hash>
|
||||||
inline typename Foam::StaticHashTable<T, Key, Hash>::const_iterator
|
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
|
// Find first non-empty entry
|
||||||
forAll(keys_, hashIdx)
|
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>
|
template<class T, class Key, class Hash>
|
||||||
inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator&
|
inline const typename Foam::StaticHashTable<T, Key, Hash>::const_iterator&
|
||||||
Foam::StaticHashTable<T, Key, Hash>::end() const
|
Foam::StaticHashTable<T, Key, Hash>::end() const
|
||||||
|
|||||||
@ -30,17 +30,17 @@ License
|
|||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "long.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()))
|
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()),
|
static_cast<const DLListBase&>(DLListBase()),
|
||||||
reinterpret_cast<const link*>(NULL)
|
reinterpret_cast<const link*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -176,7 +176,7 @@ public:
|
|||||||
|
|
||||||
// STL iterator
|
// STL iterator
|
||||||
|
|
||||||
//- An STL iterator
|
//- An STL-conforming iterator
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
friend class DLListBase;
|
friend class DLListBase;
|
||||||
@ -193,16 +193,17 @@ public:
|
|||||||
//- Copy of the link
|
//- Copy of the link
|
||||||
link curLink_;
|
link curLink_;
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Construct for a given SLListBase with NULL element and link.
|
||||||
|
// Only used to create endIter
|
||||||
|
inline iterator(DLListBase&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Construct for a given DLListBase and link
|
//- Construct for a given DLListBase and link
|
||||||
inline iterator(DLListBase&, 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
|
// Member operators
|
||||||
|
|
||||||
inline void operator=(const iterator&);
|
inline void operator=(const iterator&);
|
||||||
@ -217,16 +218,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline iterator begin();
|
inline iterator begin();
|
||||||
|
|
||||||
//- iterator returned by end()
|
|
||||||
static iterator endIter;
|
|
||||||
|
|
||||||
inline const iterator& end();
|
inline const iterator& end();
|
||||||
|
|
||||||
|
|
||||||
// STL const_iterator
|
// STL const_iterator
|
||||||
|
|
||||||
//- An STL const_iterator
|
//- An STL-conforming const_iterator
|
||||||
class const_iterator
|
class const_iterator
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
@ -258,12 +255,20 @@ public:
|
|||||||
inline const_iterator operator++(int);
|
inline const_iterator operator++(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline const_iterator cbegin() const;
|
||||||
|
inline const const_iterator& cend() const;
|
||||||
|
|
||||||
inline const_iterator begin() 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()
|
//- 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
|
else
|
||||||
{
|
{
|
||||||
return endIter;
|
return endIter_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::DLListBase::iterator& Foam::DLListBase::end()
|
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
|
inline Foam::DLListBase::const_iterator
|
||||||
Foam::DLListBase::begin() const
|
Foam::DLListBase::cbegin() const
|
||||||
{
|
{
|
||||||
if (size())
|
if (size())
|
||||||
{
|
{
|
||||||
@ -358,15 +358,29 @@ Foam::DLListBase::begin() const
|
|||||||
}
|
}
|
||||||
else
|
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&
|
inline const Foam::DLListBase::const_iterator&
|
||||||
Foam::DLListBase::end() const
|
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()))
|
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()),
|
static_cast<const SLListBase&>(SLListBase()),
|
||||||
reinterpret_cast<const link*>(NULL)
|
reinterpret_cast<const link*>(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -178,17 +178,17 @@ public:
|
|||||||
//- Copy of the link
|
//- Copy of the link
|
||||||
link curLink_;
|
link curLink_;
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Construct for a given SLListBase with NULL element and link.
|
||||||
|
// Only used to create endIter
|
||||||
|
inline iterator(SLListBase&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Construct for a given SLListBase and link
|
//- Construct for a given SLListBase and link
|
||||||
inline iterator(SLListBase&, 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
|
// Member operators
|
||||||
|
|
||||||
inline void operator=(const iterator&);
|
inline void operator=(const iterator&);
|
||||||
@ -203,10 +203,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline iterator begin();
|
inline iterator begin();
|
||||||
|
|
||||||
//- iterator returned by end()
|
|
||||||
static iterator endIter;
|
|
||||||
|
|
||||||
inline const iterator& end();
|
inline const iterator& end();
|
||||||
|
|
||||||
|
|
||||||
@ -245,12 +241,20 @@ public:
|
|||||||
inline const_iterator operator++(int);
|
inline const_iterator operator++(int);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline const_iterator cbegin() const;
|
||||||
|
inline const const_iterator& cend() const;
|
||||||
|
|
||||||
inline const_iterator begin() 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()
|
//- const_iterator returned by end()
|
||||||
static const_iterator endConstIter;
|
static const_iterator endConstIter_;
|
||||||
|
|
||||||
inline const const_iterator& end() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -231,7 +231,7 @@ Foam::SLListBase::begin()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return endIter;
|
return endIter_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ Foam::SLListBase::begin()
|
|||||||
inline const Foam::SLListBase::iterator&
|
inline const Foam::SLListBase::iterator&
|
||||||
Foam::SLListBase::end()
|
Foam::SLListBase::end()
|
||||||
{
|
{
|
||||||
return endIter;
|
return endIter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ Foam::SLListBase::const_iterator::operator++(int)
|
|||||||
|
|
||||||
|
|
||||||
inline Foam::SLListBase::const_iterator
|
inline Foam::SLListBase::const_iterator
|
||||||
Foam::SLListBase::begin() const
|
Foam::SLListBase::cbegin() const
|
||||||
{
|
{
|
||||||
if (size())
|
if (size())
|
||||||
{
|
{
|
||||||
@ -331,15 +331,29 @@ Foam::SLListBase::begin() const
|
|||||||
}
|
}
|
||||||
else
|
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&
|
inline const Foam::SLListBase::const_iterator&
|
||||||
Foam::SLListBase::end() const
|
Foam::SLListBase::end() const
|
||||||
{
|
{
|
||||||
return endConstIter;
|
return endConstIter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -118,14 +118,6 @@ Foam::CompactListList<T>::CompactListList
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class T>
|
||||||
void Foam::CompactListList<T>::setSize(const label nRows)
|
void Foam::CompactListList<T>::setSize(const label nRows)
|
||||||
{
|
{
|
||||||
@ -150,12 +142,17 @@ void Foam::CompactListList<T>::setSize(const label nRows)
|
|||||||
|
|
||||||
|
|
||||||
template<class T>
|
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);
|
offsets_.setSize(nRows);
|
||||||
m_.setSize(nData);
|
m_.setSize(nData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void Foam::CompactListList<T>::setSize
|
void Foam::CompactListList<T>::setSize
|
||||||
(
|
(
|
||||||
@ -168,19 +165,6 @@ void Foam::CompactListList<T>::setSize
|
|||||||
m_.setSize(nData, t);
|
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>
|
template<class T>
|
||||||
void Foam::CompactListList<T>::setSize(const UList<label>& rowSizes)
|
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);
|
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>
|
template<class T>
|
||||||
void Foam::CompactListList<T>::clear()
|
void Foam::CompactListList<T>::clear()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -81,6 +81,11 @@ class CompactListList
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Return a null CompactListList
|
||||||
|
inline static const CompactListList<T>& null();
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Null constructor.
|
//- Null constructor.
|
||||||
@ -116,10 +121,7 @@ public:
|
|||||||
inline autoPtr<CompactListList<T> > clone() const;
|
inline autoPtr<CompactListList<T> > clone() const;
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return a null CompactListList
|
|
||||||
static const CompactListList<T>& null();
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
@ -154,15 +156,28 @@ public:
|
|||||||
//- Reset sizes of CompactListList and value for new elements.
|
//- Reset sizes of CompactListList and value for new elements.
|
||||||
void setSize(const label nRows, const label nData, const T&);
|
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.
|
//- Reset size of CompactListList.
|
||||||
void setSize(const UList<label>& rowSizes);
|
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.
|
//- Clear the CompactListList, i.e. set sizes to zero.
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
//- Return sizes (to be used e.g. for construction)
|
||||||
|
labelList sizes() const;
|
||||||
|
|
||||||
//- Transfer the contents of the argument CompactListList
|
//- Transfer the contents of the argument CompactListList
|
||||||
// into this CompactListList and annull the argument list.
|
// into this CompactListList and annull the argument list.
|
||||||
void transfer(CompactListList<T>&);
|
void transfer(CompactListList<T>&);
|
||||||
|
|||||||
@ -67,6 +67,13 @@ Foam::CompactListList<T>::clone() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast< CompactListList<T>* >(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::label Foam::CompactListList<T>::size() const
|
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 * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
@ -108,6 +108,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from UList. Size set to UList size.
|
//- Construct from UList. Size set to UList size.
|
||||||
|
// Also constructs from DynamicList with different sizing parameters.
|
||||||
explicit inline DynamicList(const UList<T>&);
|
explicit inline DynamicList(const UList<T>&);
|
||||||
|
|
||||||
//- Construct by transferring the parameter contents
|
//- Construct by transferring the parameter contents
|
||||||
@ -141,6 +142,15 @@ public:
|
|||||||
//- Alter the addressed list size and fill new space with a constant.
|
//- Alter the addressed list size and fill new space with a constant.
|
||||||
inline void setSize(const label, const T&);
|
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.
|
//- Reserve allocation space for at least this size.
|
||||||
// Never shrinks the allocated size, use setCapacity() for that.
|
// Never shrinks the allocated size, use setCapacity() for that.
|
||||||
inline void reserve(const label);
|
inline void reserve(const label);
|
||||||
@ -182,9 +192,14 @@ public:
|
|||||||
//- Assignment of all addressed entries to the given value
|
//- Assignment of all addressed entries to the given value
|
||||||
inline void operator=(const T&);
|
inline void operator=(const T&);
|
||||||
|
|
||||||
//- Assignment from List<T>. Also handles assignment from DynamicList.
|
//- Assignment from DynamicList
|
||||||
inline void operator=(const UList<T>&);
|
inline void operator=
|
||||||
|
(
|
||||||
|
const DynamicList<T, SizeInc, SizeMult, SizeDiv>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Assignment from List<T>.
|
||||||
|
inline void operator=(const UList<T>&);
|
||||||
|
|
||||||
// IOstream operators
|
// IOstream operators
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,7 @@ inline Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::DynamicList
|
|||||||
List<T>(nElem),
|
List<T>(nElem),
|
||||||
capacity_(nElem)
|
capacity_(nElem)
|
||||||
{
|
{
|
||||||
|
// we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
|
||||||
List<T>::size(0);
|
List<T>::size(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +108,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setCapacity
|
|||||||
// truncate addressed sizes too
|
// truncate addressed sizes too
|
||||||
nextFree = capacity_;
|
nextFree = capacity_;
|
||||||
}
|
}
|
||||||
|
// we could also enforce SizeInc granularity when (!SizeMult || !SizeDiv)
|
||||||
|
|
||||||
List<T>::setSize(capacity_);
|
List<T>::setSize(capacity_);
|
||||||
List<T>::size(nextFree);
|
List<T>::size(nextFree);
|
||||||
@ -121,12 +123,26 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::reserve
|
|||||||
{
|
{
|
||||||
// allocate more capacity?
|
// allocate more capacity?
|
||||||
if (nElem > capacity_)
|
if (nElem > capacity_)
|
||||||
|
{
|
||||||
|
// 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
|
capacity_ = max
|
||||||
(
|
(
|
||||||
nElem,
|
nElem,
|
||||||
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// adjust allocated size, leave addressed size untouched
|
// adjust allocated size, leave addressed size untouched
|
||||||
label nextFree = List<T>::size();
|
label nextFree = List<T>::size();
|
||||||
@ -144,12 +160,26 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
|
|||||||
{
|
{
|
||||||
// allocate more capacity?
|
// allocate more capacity?
|
||||||
if (nElem > capacity_)
|
if (nElem > capacity_)
|
||||||
|
{
|
||||||
|
// 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
|
capacity_ = max
|
||||||
(
|
(
|
||||||
nElem,
|
nElem,
|
||||||
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
List<T>::setSize(capacity_);
|
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>
|
template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
|
||||||
inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::clear()
|
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
|
// use the full list when resizing
|
||||||
List<T>::size(capacity_);
|
List<T>::size(capacity_);
|
||||||
|
|
||||||
// the new size
|
// the new size
|
||||||
capacity_ = nextFree;
|
capacity_ = nextFree;
|
||||||
List<T>::setSize(capacity_);
|
List<T>::setSize(capacity_);
|
||||||
@ -334,13 +386,36 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
|
|||||||
(
|
(
|
||||||
const UList<T>& lst
|
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)
|
if (this == &lst)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator="
|
"DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator="
|
||||||
"(const UList<T>&)"
|
"(const DynamicList<T, SizeInc, SizeMult, SizeDiv>&)"
|
||||||
) << "attempted assignment to self" << abort(FatalError);
|
) << "attempted assignment to self" << abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,14 +29,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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 * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T, Foam::label Size>
|
template<class T, Foam::label Size>
|
||||||
|
|||||||
@ -93,6 +93,11 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Return a null FixedList
|
||||||
|
inline static const FixedList<T, Size>& null();
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
@ -121,11 +126,7 @@ public:
|
|||||||
inline autoPtr<FixedList<T, Size> > clone() const;
|
inline autoPtr<FixedList<T, Size> > clone() const;
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return a null FixedList
|
|
||||||
static const FixedList<T, Size>& null();
|
|
||||||
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
@ -152,6 +153,10 @@ public:
|
|||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
|
//- Dummy resize function
|
||||||
|
// needed to make FixedList consistent with List
|
||||||
|
inline void resize(const label);
|
||||||
|
|
||||||
//- Dummy setSize function
|
//- Dummy setSize function
|
||||||
// needed to make FixedList consistent with List
|
// needed to make FixedList consistent with List
|
||||||
inline void setSize(const label);
|
inline void setSize(const label);
|
||||||
@ -226,12 +231,16 @@ public:
|
|||||||
//- Random access iterator for traversing FixedList.
|
//- Random access iterator for traversing FixedList.
|
||||||
typedef const T* const_iterator;
|
typedef const T* const_iterator;
|
||||||
|
|
||||||
//- Return a const_iterator to begin traversing the
|
//- Return const_iterator to begin traversing the constant FixedList.
|
||||||
// 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;
|
inline const_iterator begin() const;
|
||||||
|
|
||||||
//- Return a const_iterator to end traversing the
|
//- Return const_iterator to end traversing the constant FixedList.
|
||||||
// constant FixedList.
|
|
||||||
inline const_iterator end() const;
|
inline const_iterator end() const;
|
||||||
|
|
||||||
|
|
||||||
@ -240,12 +249,10 @@ public:
|
|||||||
//- Reverse iterator for reverse traversal of FixedList.
|
//- Reverse iterator for reverse traversal of FixedList.
|
||||||
typedef T* reverse_iterator;
|
typedef T* reverse_iterator;
|
||||||
|
|
||||||
//- Return a reverse_iterator to begin reverse traversing the
|
//- Return reverse_iterator to begin reverse traversing the FixedList.
|
||||||
// FixedList.
|
|
||||||
inline reverse_iterator rbegin();
|
inline reverse_iterator rbegin();
|
||||||
|
|
||||||
//- Return a reverse_iterator to end reverse traversing the
|
//- Return reverse_iterator to end reverse traversing the FixedList.
|
||||||
// FixedList.
|
|
||||||
inline reverse_iterator rend();
|
inline reverse_iterator rend();
|
||||||
|
|
||||||
|
|
||||||
@ -254,12 +261,16 @@ public:
|
|||||||
//- Reverse iterator for reverse traversal of constant FixedList.
|
//- Reverse iterator for reverse traversal of constant FixedList.
|
||||||
typedef const T* const_reverse_iterator;
|
typedef const T* const_reverse_iterator;
|
||||||
|
|
||||||
//- Return a const_reverse_iterator to begin reverse traversing the
|
//- Return const_reverse_iterator to begin reverse traversing FixedList.
|
||||||
// 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;
|
inline const_reverse_iterator rbegin() const;
|
||||||
|
|
||||||
//- Return a const_reverse_iterator to end reverse traversing the
|
//- Return const_reverse_iterator to end reverse traversing FixedList.
|
||||||
// FixedList.
|
|
||||||
inline const_reverse_iterator rend() const;
|
inline const_reverse_iterator rend() const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -104,6 +104,13 @@ Foam::FixedList<T, Size>::clone() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class T, Foam::label Size>
|
||||||
inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
|
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>
|
template<class T, Foam::label Size>
|
||||||
inline void Foam::FixedList<T, Size>::setSize(const label s)
|
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>
|
template<class T, Foam::label Size>
|
||||||
inline typename Foam::FixedList<T, Size>::iterator
|
inline typename Foam::FixedList<T, Size>::iterator
|
||||||
Foam::FixedList<T, Size>::end()
|
Foam::FixedList<T, Size>::end()
|
||||||
@ -284,6 +307,15 @@ Foam::FixedList<T, Size>::end() const
|
|||||||
return &v_[Size];
|
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>
|
template<class T, Foam::label Size>
|
||||||
inline typename Foam::FixedList<T, Size>::iterator
|
inline typename Foam::FixedList<T, Size>::iterator
|
||||||
Foam::FixedList<T, Size>::rbegin()
|
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>
|
template<class T, Foam::label Size>
|
||||||
inline typename Foam::FixedList<T, Size>::iterator
|
inline typename Foam::FixedList<T, Size>::iterator
|
||||||
Foam::FixedList<T, Size>::rend()
|
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>
|
template<class T, Foam::label Size>
|
||||||
inline Foam::label Foam::FixedList<T, Size>::size() const
|
inline Foam::label Foam::FixedList<T, Size>::size() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -332,14 +332,6 @@ Foam::List<T>::~List()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class T>
|
||||||
void Foam::List<T>::setSize(const label newSize)
|
void Foam::List<T>::setSize(const label newSize)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -87,6 +87,11 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Return a null List
|
||||||
|
inline static const List<T>& null();
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Null constructor.
|
//- Null constructor.
|
||||||
@ -145,10 +150,7 @@ public:
|
|||||||
typedef SubList<T> subList;
|
typedef SubList<T> subList;
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return a null List
|
|
||||||
static const List<T>& null();
|
|
||||||
|
|
||||||
//- Return the number of elements in the UList.
|
//- Return the number of elements in the UList.
|
||||||
inline label size() const;
|
inline label size() const;
|
||||||
@ -156,6 +158,12 @@ public:
|
|||||||
|
|
||||||
// Edit
|
// 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.
|
//- Reset size of List.
|
||||||
void setSize(const label);
|
void setSize(const label);
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,27 @@ inline Foam::autoPtr<Foam::List<T> > Foam::List<T>::clone() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class T>
|
||||||
inline T& Foam::List<T>::newElmt(const label i)
|
inline T& Foam::List<T>::newElmt(const label i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -173,7 +173,14 @@ void Foam::sortedOrder
|
|||||||
labelList& order
|
labelList& order
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// list lengths must be identical
|
||||||
|
if (order.size() != lst.size())
|
||||||
|
{
|
||||||
|
// avoid copying any elements, they are overwritten anyhow
|
||||||
|
order.clear();
|
||||||
order.setSize(lst.size());
|
order.setSize(lst.size());
|
||||||
|
}
|
||||||
|
|
||||||
forAll(order, elemI)
|
forAll(order, elemI)
|
||||||
{
|
{
|
||||||
order[elemI] = elemI;
|
order[elemI] = elemI;
|
||||||
|
|||||||
@ -31,32 +31,17 @@ License
|
|||||||
template<int nBits>
|
template<int nBits>
|
||||||
Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val)
|
Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val)
|
||||||
:
|
:
|
||||||
List<unsigned int>(intSize(size)),
|
List<PackedStorage>(packedLength(size), 0u),
|
||||||
size_(size)
|
size_(size)
|
||||||
{
|
{
|
||||||
operator=(val);
|
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>
|
template<int nBits>
|
||||||
Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||||
:
|
:
|
||||||
List<unsigned int>(intSize(lst.size()), 0),
|
List<PackedStorage>(packedLength(lst.size()), 0u),
|
||||||
size_(lst.size())
|
size_(lst.size())
|
||||||
{
|
{
|
||||||
forAll(lst, i)
|
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 * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
void Foam::PackedList<nBits>::setSize(const label size)
|
Foam::labelList Foam::PackedList<nBits>::values() const
|
||||||
{
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
labelList elems(size());
|
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 * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//template<int nBits>
|
//template<int nBits>
|
||||||
|
|||||||
@ -26,9 +26,22 @@ Class
|
|||||||
Foam::PackedList
|
Foam::PackedList
|
||||||
|
|
||||||
Description
|
Description
|
||||||
List of packed unsigned ints.
|
A Dynamically allocatable list of packed unsigned ints.
|
||||||
|
|
||||||
Gets given the number of bits per item.
|
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
|
SourceFiles
|
||||||
PackedListI.H
|
PackedListI.H
|
||||||
PackedList.C
|
PackedList.C
|
||||||
@ -39,103 +52,85 @@ SourceFiles
|
|||||||
#define PackedList_H
|
#define PackedList_H
|
||||||
|
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
#include "List.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
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
|
Class PackedListName Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
TemplateName(PackedList);
|
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>
|
template <int nBits>
|
||||||
class PackedList
|
class PackedList
|
||||||
:
|
:
|
||||||
private List<unsigned int>
|
private List<unsigned int>
|
||||||
{
|
{
|
||||||
|
typedef unsigned int PackedStorage;
|
||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Number of nBits entries
|
//- Number of nBits entries
|
||||||
label size_;
|
label size_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Calculate underlying list size
|
//- Calculate the list length when packed
|
||||||
inline static label intSize(const label sz);
|
inline static label packedLength(const label);
|
||||||
|
|
||||||
//- Calculate index into underlying List.
|
//- Check index I is within valid range [ 0 .. max_value() ]
|
||||||
inline static label intIndex(const label i);
|
inline void checkIndex(const label) const;
|
||||||
|
|
||||||
//- 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;
|
|
||||||
|
|
||||||
public:
|
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
|
// Constructors
|
||||||
|
|
||||||
//- Null constructor
|
//- Null constructor
|
||||||
inline PackedList();
|
inline PackedList();
|
||||||
|
|
||||||
//- Construct with given size. Note: initializes intList to 0.
|
//- Construct with given size, initializes list to 0.
|
||||||
inline PackedList(const label size);
|
inline PackedList(const label size);
|
||||||
|
|
||||||
//- Construct with given size and value for all elements.
|
//- 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.
|
//- Copy constructor.
|
||||||
PackedList(const PackedList<nBits>& PList);
|
inline PackedList(const PackedList<nBits>&);
|
||||||
|
|
||||||
//- Construct by transferring the parameter contents
|
//- Construct by transferring the parameter contents
|
||||||
PackedList(const Xfer<PackedList<nBits> >&);
|
inline PackedList(const Xfer<PackedList<nBits> >&);
|
||||||
|
|
||||||
//- Construct from a list of labels
|
//- Construct from a list of labels
|
||||||
PackedList(const UList<label>&);
|
PackedList(const UList<label>&);
|
||||||
@ -145,66 +140,166 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// 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
|
// Access
|
||||||
|
|
||||||
//- Number of packed elements
|
//- The number of elements that can be stored before resizing
|
||||||
|
inline label capacity() const;
|
||||||
|
|
||||||
|
//- Number of entries.
|
||||||
inline label size() const;
|
inline label size() const;
|
||||||
|
|
||||||
//- Return true if the list is empty (i.e., if size() == 0).
|
//- Return true if the list is empty (i.e., if size() == 0).
|
||||||
inline bool empty() const;
|
inline bool empty() const;
|
||||||
|
|
||||||
//- Get value at index I
|
//- Get value at index I.
|
||||||
inline unsigned int get(const label i) const;
|
// Does not auto-vivifies entries.
|
||||||
|
inline unsigned int get(const label) const;
|
||||||
|
|
||||||
//- Set value at index I. Return true if value changed.
|
//- Set value at index I. Return true if value changed.
|
||||||
inline bool set(const label i, const unsigned int val);
|
// Does not auto-vivifies entries.
|
||||||
|
inline bool set(const label, const unsigned int val);
|
||||||
|
|
||||||
//- Underlying storage
|
//- Return the underlying packed storage
|
||||||
inline List<unsigned int>& 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
|
// Member operators
|
||||||
|
|
||||||
//- Get value at index i
|
//- Append a value at the end of the list
|
||||||
inline unsigned int operator[](const label i) const;
|
inline void append(const unsigned int val);
|
||||||
|
|
||||||
//- Set value at index i. Returns proxy which does actual operation
|
//- Get value at index I
|
||||||
inline ::Foam::reference operator[](const label i);
|
// Auto-vivifies any new values to zero.
|
||||||
|
inline unsigned int operator[](const label) const;
|
||||||
|
|
||||||
|
//- 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 operator. Takes linear time.
|
//- Assignment operator. Takes linear time.
|
||||||
void operator=(const PackedList<nBits>&);
|
void operator=(const PackedList<nBits>&);
|
||||||
|
|
||||||
//- Assignment of all entries to the given value. Does set on all
|
//- Assignment operator. Takes linear time.
|
||||||
// elements.
|
void operator=(const UList<label>&);
|
||||||
inline void operator=(const unsigned int val);
|
|
||||||
|
|
||||||
//- Return as labelList
|
|
||||||
labelList operator()() const;
|
|
||||||
|
|
||||||
|
|
||||||
// Ostream operator
|
// Ostream operator
|
||||||
|
|
||||||
// // Write PackedList to Ostream.
|
// // Write PackedList to Ostream.
|
||||||
// friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&);
|
// 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
|
} // End namespace Foam
|
||||||
|
|||||||
@ -25,44 +25,45 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef PackedList_I
|
#include "error.H"
|
||||||
#define PackedList_I
|
|
||||||
|
|
||||||
#include "IOstreams.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Calculate underlying list size
|
|
||||||
template<int nBits>
|
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 sizeof(PackedStorage)*8 - 1;
|
||||||
|
|
||||||
return (sz+nElemsPerLabel-1)/nElemsPerLabel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Convert index into index in integer array
|
|
||||||
template<int nBits>
|
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;
|
return ((1u << nBits) - 1);
|
||||||
|
}
|
||||||
// Index in underlying int array
|
|
||||||
label elemI = i/nElemsPerLabel;
|
|
||||||
|
template<int nBits>
|
||||||
return elemI;
|
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>
|
template<int nBits>
|
||||||
inline void Foam::PackedList<nBits>::checkIndex(const label i) const
|
inline void Foam::PackedList<nBits>::checkIndex(const label i) const
|
||||||
{
|
{
|
||||||
if (!size_)
|
if (!size_)
|
||||||
{
|
{
|
||||||
FatalErrorIn("PackedList<nBits>::checkIndex(const label)")
|
FatalErrorIn("PackedList<nBits>::checkIndex(const label)")
|
||||||
<< "attempt to access element from zero sized list"
|
<< "attempt to access element from zero-sized list"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
else if (i < 0 || i >= size_)
|
else if (i < 0 || i >= size_)
|
||||||
@ -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 * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Null constructor
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline Foam::PackedList<nBits>::PackedList()
|
inline Foam::PackedList<nBits>::PackedList()
|
||||||
:
|
:
|
||||||
List<unsigned int>(0),
|
List<PackedStorage>(),
|
||||||
size_(0)
|
size_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// Construct with given size.
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline Foam::PackedList<nBits>::PackedList(const label size)
|
inline Foam::PackedList<nBits>::PackedList(const label size)
|
||||||
:
|
:
|
||||||
List<unsigned int>(intSize(size), 0u),
|
List<PackedStorage>(packedLength(size), 0u),
|
||||||
size_(size)
|
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 * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
@ -120,76 +275,134 @@ inline Foam::label Foam::PackedList<nBits>::size() const
|
|||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline bool Foam::PackedList<nBits>::empty() const
|
inline bool Foam::PackedList<nBits>::empty() const
|
||||||
{
|
{
|
||||||
return (size_ == 0);
|
return !size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get value at i
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline unsigned int Foam::PackedList<nBits>::get(const label i) const
|
inline void Foam::PackedList<nBits>::resize
|
||||||
|
(
|
||||||
|
const label nElem,
|
||||||
|
const unsigned int& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
reserve(nElem, val);
|
||||||
|
size_ = nElem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<int nBits>
|
||||||
|
inline void Foam::PackedList<nBits>::setSize
|
||||||
|
(
|
||||||
|
const label newSize,
|
||||||
|
const unsigned int& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
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
|
# ifdef DEBUGList
|
||||||
checkIndex(i);
|
// clear old values (purely cosmetics for string output)
|
||||||
|
for (label i = nElem; i < size_; i++)
|
||||||
|
{
|
||||||
|
set(i, 0);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
size_ = nElem;
|
||||||
// Constant: number of elements that fit in an unsigned int
|
}
|
||||||
const label nElemsPerLabel = sizeof(unsigned int)*8/nBits;
|
else
|
||||||
|
{
|
||||||
unsigned int mask = ((1u << nBits) - 1);
|
// fill new elements
|
||||||
|
for (label i = size_; i < nElem; i++)
|
||||||
label indexInLabel = i % nElemsPerLabel;
|
{
|
||||||
|
set(i, 0);
|
||||||
// Starting bit in int.
|
}
|
||||||
label startBit = nBits*indexInLabel;
|
}
|
||||||
|
|
||||||
return (List<unsigned int>::operator[](intIndex(i)) >> startBit) & mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const
|
inline void Foam::PackedList<nBits>::reserve
|
||||||
|
(
|
||||||
|
const label nElem,
|
||||||
|
const unsigned int& val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return get(i);
|
label len = packedLength(nElem);
|
||||||
|
|
||||||
|
// need more capacity?
|
||||||
|
if (len > List<PackedStorage>::size())
|
||||||
|
{
|
||||||
|
List<PackedStorage>::setSize(len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fill new elements
|
||||||
// Set value at i
|
for (label i = size_; i < nElem; i++)
|
||||||
template<int nBits>
|
|
||||||
inline bool Foam::PackedList<nBits>::set(const label i, const unsigned int val)
|
|
||||||
{
|
{
|
||||||
# ifdef DEBUGList
|
set(i, val);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<int nBits>
|
template<int nBits>
|
||||||
inline Foam::List<unsigned int>& Foam::PackedList<nBits>::storage()
|
inline void Foam::PackedList<nBits>::clear()
|
||||||
{
|
{
|
||||||
return static_cast<List<unsigned int>&>(*this);
|
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>
|
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
|
# ifdef DEBUGList
|
||||||
checkIndex(i);
|
checkIndex(i);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// Constant: number of elements that fit in an unsigned int
|
return iterator(*this, i)();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set all to val
|
|
||||||
template<int nBits>
|
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
|
if (i >= size_)
|
||||||
checkValue(val);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (val == 0)
|
|
||||||
{
|
{
|
||||||
List<unsigned int>::operator=(val);
|
setSize(i + 1);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (label i = 0; i < size_; i++)
|
return iterator(*this, i)();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<int nBits>
|
||||||
|
inline bool Foam::PackedList<nBits>::set
|
||||||
|
(
|
||||||
|
const label i,
|
||||||
|
const unsigned int val
|
||||||
|
)
|
||||||
{
|
{
|
||||||
set(i, 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
|
# 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -42,7 +42,7 @@ Foam::PtrList<T>::PtrList()
|
|||||||
template<class T>
|
template<class T>
|
||||||
Foam::PtrList<T>::PtrList(const label s)
|
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);
|
<< ")." << abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(NULL));
|
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(0));
|
||||||
|
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -170,6 +170,12 @@ public:
|
|||||||
// deleted.
|
// deleted.
|
||||||
void setSize(const label);
|
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
|
//- Clear the PtrList, i.e. set size to zero deleting all the
|
||||||
// allocated entries.
|
// allocated entries.
|
||||||
void clear();
|
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>
|
template<class T>
|
||||||
inline bool Foam::PtrList<T>::set(const label i) const
|
inline bool Foam::PtrList<T>::set(const label i) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -27,17 +27,21 @@ License
|
|||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
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
|
// list lengths must be identical
|
||||||
ind.setSize(this->size());
|
if (order.size() != this->size())
|
||||||
|
|
||||||
forAll(ind, i)
|
|
||||||
{
|
{
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class SortableList
|
|||||||
//- Original indices
|
//- Original indices
|
||||||
labelList 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;
|
void sortIndices(List<label>&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -59,6 +59,12 @@ class SubList
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Return a null SubList
|
||||||
|
inline static const SubList<T>& null();
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from UList and sub-list size
|
//- 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
|
// Member operators
|
||||||
|
|
||||||
//- Allow cast to a const List<T>&
|
//- Allow cast to a const List<T>&
|
||||||
|
|||||||
@ -75,8 +75,7 @@ inline Foam::SubList<T>::SubList
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline const Foam::SubList<T>& Foam::SubList<T>::null()
|
inline const Foam::SubList<T>& Foam::SubList<T>::null()
|
||||||
{
|
{
|
||||||
SubList<T>* nullPtr = reinterpret_cast<SubList<T>*>(NULL);
|
return *reinterpret_cast< SubList<T>* >(0);
|
||||||
return *nullPtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -32,14 +32,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class T>
|
||||||
void Foam::UList<T>::assign(const UList<T>& a)
|
void Foam::UList<T>::assign(const UList<T>& a)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -86,6 +86,11 @@ public:
|
|||||||
//- Declare friendship with the SubList class
|
//- Declare friendship with the SubList class
|
||||||
friend class SubList<T>;
|
friend class SubList<T>;
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Return a null UList
|
||||||
|
inline static const UList<T>& null();
|
||||||
|
|
||||||
// Public classes
|
// Public classes
|
||||||
|
|
||||||
//- Less function class that can be used for sorting
|
//- Less function class that can be used for sorting
|
||||||
@ -116,10 +121,7 @@ public:
|
|||||||
inline UList(T* __restrict__ v, label size);
|
inline UList(T* __restrict__ v, label size);
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return a null UList
|
|
||||||
static const UList<T>& null();
|
|
||||||
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
@ -213,12 +215,16 @@ public:
|
|||||||
//- Random access iterator for traversing UList.
|
//- Random access iterator for traversing UList.
|
||||||
typedef const T* const_iterator;
|
typedef const T* const_iterator;
|
||||||
|
|
||||||
//- Return a const_iterator to begin traversing the
|
//- Return const_iterator to begin traversing the constant UList.
|
||||||
// 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;
|
inline const_iterator begin() const;
|
||||||
|
|
||||||
//- Return a const_iterator to end traversing the
|
//- Return const_iterator to end traversing the constant UList.
|
||||||
// constant UList.
|
|
||||||
inline const_iterator end() const;
|
inline const_iterator end() const;
|
||||||
|
|
||||||
|
|
||||||
@ -227,12 +233,10 @@ public:
|
|||||||
//- Reverse iterator for reverse traversal of UList.
|
//- Reverse iterator for reverse traversal of UList.
|
||||||
typedef T* reverse_iterator;
|
typedef T* reverse_iterator;
|
||||||
|
|
||||||
//- Return a reverse_iterator to begin reverse traversing the
|
//- Return reverse_iterator to begin reverse traversing the UList.
|
||||||
// UList.
|
|
||||||
inline reverse_iterator rbegin();
|
inline reverse_iterator rbegin();
|
||||||
|
|
||||||
//- Return a reverse_iterator to end reverse traversing the
|
//- Return reverse_iterator to end reverse traversing the UList.
|
||||||
// UList.
|
|
||||||
inline reverse_iterator rend();
|
inline reverse_iterator rend();
|
||||||
|
|
||||||
|
|
||||||
@ -241,12 +245,16 @@ public:
|
|||||||
//- Reverse iterator for reverse traversal of constant UList.
|
//- Reverse iterator for reverse traversal of constant UList.
|
||||||
typedef const T* const_reverse_iterator;
|
typedef const T* const_reverse_iterator;
|
||||||
|
|
||||||
//- Return a const_reverse_iterator to begin reverse traversing the
|
//- Return const_reverse_iterator to begin reverse traversing the UList.
|
||||||
// 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;
|
inline const_reverse_iterator rbegin() const;
|
||||||
|
|
||||||
//- Return a const_reverse_iterator to end reverse traversing the
|
//- Return const_reverse_iterator to end reverse traversing the UList.
|
||||||
// UList.
|
|
||||||
inline const_reverse_iterator rend() const;
|
inline const_reverse_iterator rend() const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -47,6 +47,13 @@ inline Foam::UList<T>::UList(T* __restrict__ v, label size)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline const Foam::UList<T>& Foam::UList<T>::null()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast< UList<T>* >(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::label Foam::UList<T>::fcIndex(const label i) const
|
inline Foam::label Foam::UList<T>::fcIndex(const label i) const
|
||||||
{
|
{
|
||||||
@ -154,6 +161,13 @@ Foam::UList<T>::begin() const
|
|||||||
return v_;
|
return v_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline typename Foam::UList<T>::const_iterator
|
||||||
|
Foam::UList<T>::cbegin() const
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename Foam::UList<T>::iterator
|
inline typename Foam::UList<T>::iterator
|
||||||
Foam::UList<T>::end()
|
Foam::UList<T>::end()
|
||||||
@ -168,6 +182,13 @@ Foam::UList<T>::end() const
|
|||||||
return &v_[size_];
|
return &v_[size_];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline typename Foam::UList<T>::const_iterator
|
||||||
|
Foam::UList<T>::cend() const
|
||||||
|
{
|
||||||
|
return &v_[size_];
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline typename Foam::UList<T>::iterator
|
inline typename Foam::UList<T>::iterator
|
||||||
Foam::UList<T>::rbegin()
|
Foam::UList<T>::rbegin()
|
||||||
@ -182,6 +203,13 @@ Foam::UList<T>::rbegin() const
|
|||||||
return &v_[size_-1];
|
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>
|
template<class T>
|
||||||
inline typename Foam::UList<T>::iterator
|
inline typename Foam::UList<T>::iterator
|
||||||
Foam::UList<T>::rend()
|
Foam::UList<T>::rend()
|
||||||
@ -196,6 +224,13 @@ Foam::UList<T>::rend() const
|
|||||||
return &v_[-1];
|
return &v_[-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline typename Foam::UList<T>::const_iterator
|
||||||
|
Foam::UList<T>::crend() const
|
||||||
|
{
|
||||||
|
return &v_[-1];
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline Foam::label Foam::UList<T>::size() const
|
inline Foam::label Foam::UList<T>::size() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -41,7 +41,7 @@ Foam::UPtrList<T>::UPtrList()
|
|||||||
template<class T>
|
template<class T>
|
||||||
Foam::UPtrList<T>::UPtrList(const label s)
|
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);
|
<< ")." << abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(NULL));
|
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(0));
|
||||||
|
|
||||||
forAll(*this, i)
|
forAll(*this, i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -124,6 +124,9 @@ public:
|
|||||||
//- Return the number of elements in the UPtrList
|
//- Return the number of elements in the UPtrList
|
||||||
inline label size() const;
|
inline label size() const;
|
||||||
|
|
||||||
|
//- Return true if the UPtrList is empty (i.e., if size() == 0).
|
||||||
|
inline bool empty() const;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
@ -132,6 +135,11 @@ public:
|
|||||||
// the end of a UPtrList.
|
// the end of a UPtrList.
|
||||||
void setSize(const label);
|
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
|
//- Clear the UPtrList, i.e. set size to zero
|
||||||
void clear();
|
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>
|
template<class T>
|
||||||
inline bool Foam::UPtrList<T>::set(const label i) const
|
inline bool Foam::UPtrList<T>::set(const label i) const
|
||||||
{
|
{
|
||||||
return ptrs_[i] != NULL;
|
return ptrs_[i] != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline T* Foam::UPtrList<T>::set(const label i, T* ptr)
|
inline T* Foam::UPtrList<T>::set(const label i, T* ptr)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,17 +48,11 @@ void Foam::Ostream::decrIndent()
|
|||||||
|
|
||||||
|
|
||||||
// Write keyType
|
// Write keyType
|
||||||
|
// write regular expression as quoted string
|
||||||
|
// write plain word as word (unquoted)
|
||||||
Foam::Ostream& Foam::Ostream::write(const keyType& kw)
|
Foam::Ostream& Foam::Ostream::write(const keyType& kw)
|
||||||
{
|
{
|
||||||
// Write as word or string
|
return writeQuoted(kw, kw.isPattern());
|
||||||
if (kw.isPattern())
|
|
||||||
{
|
|
||||||
return write(static_cast<const string&>(kw));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return write(static_cast<const word&>(kw));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,6 +70,7 @@ Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
|
|||||||
nSpaces -= 2;
|
nSpaces -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// could also increment by indentSize_ ...
|
||||||
if (nSpaces < 1)
|
if (nSpaces < 1)
|
||||||
{
|
{
|
||||||
nSpaces = 1;
|
nSpaces = 1;
|
||||||
|
|||||||
@ -115,6 +115,14 @@ public:
|
|||||||
//- Write string
|
//- Write string
|
||||||
virtual Ostream& write(const string&) = 0;
|
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
|
//- Write label
|
||||||
virtual Ostream& write(const label) = 0;
|
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)
|
Foam::Ostream& Foam::OPstream::write(const label val)
|
||||||
{
|
{
|
||||||
write(char(token::LABEL));
|
write(char(token::LABEL));
|
||||||
|
|||||||
@ -136,6 +136,14 @@ public:
|
|||||||
//- Write string
|
//- Write string
|
||||||
Ostream& write(const 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
|
//- Write label
|
||||||
Ostream& write(const label);
|
Ostream& write(const label);
|
||||||
|
|
||||||
|
|||||||
@ -366,6 +366,9 @@ Foam::Istream& Foam::ISstream::read(string& str)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char endTok = token::END_STRING;
|
||||||
|
|
||||||
|
// Note, we could also handle single-quoted strings here (if desired)
|
||||||
if (c != token::BEGIN_STRING)
|
if (c != token::BEGIN_STRING)
|
||||||
{
|
{
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
@ -382,9 +385,8 @@ Foam::Istream& Foam::ISstream::read(string& str)
|
|||||||
|
|
||||||
while (get(c))
|
while (get(c))
|
||||||
{
|
{
|
||||||
switch (c)
|
if (c == endTok)
|
||||||
{
|
{
|
||||||
case token::END_STRING :
|
|
||||||
if (escaped)
|
if (escaped)
|
||||||
{
|
{
|
||||||
escaped = false;
|
escaped = false;
|
||||||
@ -397,9 +399,9 @@ Foam::Istream& Foam::ISstream::read(string& str)
|
|||||||
str = buf;
|
str = buf;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
else if (c == token::NL)
|
||||||
case token::NL :
|
{
|
||||||
if (escaped)
|
if (escaped)
|
||||||
{
|
{
|
||||||
escaped = false;
|
escaped = false;
|
||||||
@ -417,17 +419,15 @@ Foam::Istream& Foam::ISstream::read(string& str)
|
|||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case '\\':
|
|
||||||
escaped = !escaped; // toggle state (retains backslashes)
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
escaped = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if (c == '\\')
|
||||||
|
{
|
||||||
|
escaped = !escaped; // toggle state (retains backslashes)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
escaped = false;
|
||||||
|
}
|
||||||
|
|
||||||
buf[i] = c;
|
buf[i] = c;
|
||||||
if (i++ == maxLen)
|
if (i++ == maxLen)
|
||||||
|
|||||||
@ -74,28 +74,26 @@ Foam::Ostream& Foam::OSstream::write(const string& str)
|
|||||||
{
|
{
|
||||||
register char c = *iter;
|
register char c = *iter;
|
||||||
|
|
||||||
switch (c)
|
if (c == '\\')
|
||||||
{
|
{
|
||||||
case '\\' :
|
|
||||||
backslash++;
|
backslash++;
|
||||||
// suppress output until we know if other characters follow
|
// suppress output until we know if other characters follow
|
||||||
continue;
|
continue;
|
||||||
break;
|
}
|
||||||
|
else if (c == token::NL)
|
||||||
case token::NL :
|
{
|
||||||
lineNumber_++;
|
lineNumber_++;
|
||||||
backslash++; // backslash escape for newline
|
backslash++; // backslash escape for newline
|
||||||
break;
|
}
|
||||||
|
else if (c == token::END_STRING)
|
||||||
case token::END_STRING :
|
{
|
||||||
backslash++; // backslash escape for double-quote
|
backslash++; // backslash escape for quote
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// output pending backslashes
|
// output pending backslashes
|
||||||
while (backslash)
|
while (backslash)
|
||||||
{
|
{
|
||||||
os_ << '\\'; // escape for new-line
|
os_ << '\\';
|
||||||
backslash--;
|
backslash--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +101,7 @@ Foam::Ostream& Foam::OSstream::write(const string& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// silently drop any trailing backslashes
|
// 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;
|
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)
|
Foam::Ostream& Foam::OSstream::write(const label val)
|
||||||
{
|
{
|
||||||
os_ << val;
|
os_ << val;
|
||||||
|
|||||||
@ -141,6 +141,14 @@ public:
|
|||||||
// double-quote.
|
// double-quote.
|
||||||
virtual Ostream& write(const 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
|
//- Write label
|
||||||
virtual Ostream& write(const 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)
|
Foam::Ostream& Foam::prefixOSstream::write(const label val)
|
||||||
{
|
{
|
||||||
checkWritePrefix();
|
checkWritePrefix();
|
||||||
|
|||||||
@ -114,6 +114,14 @@ public:
|
|||||||
//- Write string
|
//- Write string
|
||||||
virtual Ostream& write(const 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
|
//- Write label
|
||||||
virtual Ostream& write(const label);
|
virtual Ostream& write(const label);
|
||||||
|
|
||||||
|
|||||||
@ -105,6 +105,7 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
//- Return the string
|
||||||
string str() const
|
string str() const
|
||||||
{
|
{
|
||||||
return dynamic_cast<const std::istringstream&>(stream()).str();
|
return dynamic_cast<const std::istringstream&>(stream()).str();
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Set stream status
|
//- Construct and set stream status
|
||||||
OStringStream
|
OStringStream
|
||||||
(
|
(
|
||||||
streamFormat format=ASCII,
|
streamFormat format=ASCII,
|
||||||
@ -106,6 +106,7 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
//- Return the string
|
||||||
string str() const
|
string str() const
|
||||||
{
|
{
|
||||||
return dynamic_cast<const std::ostringstream&>(stream()).str();
|
return dynamic_cast<const std::ostringstream&>(stream()).str();
|
||||||
|
|||||||
@ -106,8 +106,9 @@ public:
|
|||||||
END_BLOCK = '}',
|
END_BLOCK = '}',
|
||||||
COLON = ':',
|
COLON = ':',
|
||||||
COMMA = ',',
|
COMMA = ',',
|
||||||
|
|
||||||
BEGIN_STRING = '"',
|
BEGIN_STRING = '"',
|
||||||
END_STRING = '"',
|
END_STRING = BEGIN_STRING,
|
||||||
|
|
||||||
ASSIGN = '=',
|
ASSIGN = '=',
|
||||||
ADD = '+',
|
ADD = '+',
|
||||||
|
|||||||
@ -35,6 +35,20 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * 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>
|
template <class Type>
|
||||||
dimensioned<Type> dimensioned<Type>::lookupOrAddToDict
|
dimensioned<Type> dimensioned<Type>::lookupOrAddToDict
|
||||||
(
|
(
|
||||||
|
|||||||
@ -108,8 +108,17 @@ public:
|
|||||||
//- Construct from an Istream with a given name and dimensions
|
//- Construct from an Istream with a given name and dimensions
|
||||||
dimensioned(const word&, const dimensionSet&, Istream&);
|
dimensioned(const word&, const dimensionSet&, Istream&);
|
||||||
|
|
||||||
//- Construct from dictionary, supplying default value so that if the
|
//- Construct from dictionary, with default value.
|
||||||
// value is not found, it is added into the dictionary.
|
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
|
static dimensioned<Type> lookupOrAddToDict
|
||||||
(
|
(
|
||||||
const word&,
|
const word&,
|
||||||
@ -148,8 +157,7 @@ public:
|
|||||||
//- Return transpose.
|
//- Return transpose.
|
||||||
dimensioned<Type> T() const;
|
dimensioned<Type> T() const;
|
||||||
|
|
||||||
//- Update the value of the dimensioned<Type> if it is found in the
|
//- Update the value of dimensioned<Type> if found in the dictionary.
|
||||||
// dictionary
|
|
||||||
bool readIfPresent(const dictionary&);
|
bool readIfPresent(const dictionary&);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -271,16 +271,6 @@ DimensionedField<Type, GeoMesh>::~DimensionedField()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class Type, class GeoMesh>
|
||||||
tmp
|
tmp
|
||||||
<
|
<
|
||||||
|
|||||||
@ -100,6 +100,11 @@ public:
|
|||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
TypeName("DimensionedField");
|
TypeName("DimensionedField");
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Return a null DimensionedField
|
||||||
|
inline static const DimensionedField<Type, GeoMesh>& null();
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
@ -232,9 +237,6 @@ public:
|
|||||||
|
|
||||||
inline Field<Type>& field();
|
inline Field<Type>& field();
|
||||||
|
|
||||||
//- Return a null DimensionedField
|
|
||||||
static const DimensionedField<Type, GeoMesh>& null();
|
|
||||||
|
|
||||||
//- Return a component field of the field
|
//- Return a component field of the field
|
||||||
tmp<DimensionedField<cmptType, GeoMesh> > component
|
tmp<DimensionedField<cmptType, GeoMesh> > component
|
||||||
(
|
(
|
||||||
|
|||||||
@ -31,6 +31,14 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class Type, class GeoMesh>
|
||||||
inline const typename GeoMesh::Mesh&
|
inline const typename GeoMesh::Mesh&
|
||||||
DimensionedField<Type, GeoMesh>::mesh() const
|
DimensionedField<Type, GeoMesh>::mesh() const
|
||||||
|
|||||||
@ -81,9 +81,7 @@ template<class Type, class GeoMesh>
|
|||||||
inline const SubDimensionedField<Type, GeoMesh>&
|
inline const SubDimensionedField<Type, GeoMesh>&
|
||||||
SubDimensionedField<Type, GeoMesh>::null()
|
SubDimensionedField<Type, GeoMesh>::null()
|
||||||
{
|
{
|
||||||
SubDimensionedField<Type, GeoMesh>* nullPtr
|
return *reinterpret_cast< SubDimensionedField<Type, GeoMesh>* >(0);
|
||||||
= reinterpret_cast<SubDimensionedField<Type, GeoMesh>*>(NULL);
|
|
||||||
return *nullPtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -430,10 +430,7 @@ Type max(const FieldField<Field, Type>& f)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningIn("max(const FieldField<Field, Type>&) const")
|
return pTraits<Type>::min;
|
||||||
<< "empty fieldField, returning zero" << endl;
|
|
||||||
|
|
||||||
return pTraits<Type>::zero;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,10 +461,7 @@ Type min(const FieldField<Field, Type>& f)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningIn("min(const FieldField<Field, Type>&) const")
|
return pTraits<Type>::max;
|
||||||
<< "empty fieldField, returning zero" << endl;
|
|
||||||
|
|
||||||
return pTraits<Type>::zero;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -298,14 +298,6 @@ tmp<Field<Type> > Field<Type>::clone() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
const Field<Type>& Field<Type>::null()
|
|
||||||
{
|
|
||||||
Field<Type>* nullPtr = reinterpret_cast<Field<Type>*>(NULL);
|
|
||||||
return *nullPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Field<Type>::map
|
void Field<Type>::map
|
||||||
(
|
(
|
||||||
|
|||||||
@ -98,6 +98,15 @@ public:
|
|||||||
static const char* const typeName;
|
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
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
@ -198,11 +207,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return a null Field
|
|
||||||
static const Field<Type>& null();
|
|
||||||
|
|
||||||
|
|
||||||
//- 1 to 1 map from the given field
|
//- 1 to 1 map from the given field
|
||||||
void map
|
void map
|
||||||
|
|||||||
@ -319,10 +319,7 @@ Type max(const UList<Type>& f)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningIn("max(const UList<Type>&)")
|
return pTraits<Type>::min;
|
||||||
<< "empty field, returning zero" << endl;
|
|
||||||
|
|
||||||
return pTraits<Type>::zero;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,10 +336,7 @@ Type min(const UList<Type>& f)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningIn("min(const UList<Type>&)")
|
return pTraits<Type>::max;
|
||||||
<< "empty field, returning zero" << endl;
|
|
||||||
|
|
||||||
return pTraits<Type>::zero;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,8 +74,7 @@ inline Foam::SubField<Type>::SubField
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
inline const Foam::SubField<Type>& Foam::SubField<Type>::null()
|
inline const Foam::SubField<Type>& Foam::SubField<Type>::null()
|
||||||
{
|
{
|
||||||
SubField<Type>* nullPtr = reinterpret_cast<SubField<Type>*>(NULL);
|
return *reinterpret_cast< SubField<Type>* >(0);
|
||||||
return *nullPtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ void Foam::transform
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rtf = vector::zero;
|
rtf = tf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -887,16 +887,6 @@ writeData(Ostream& os) const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::T() const
|
Foam::GeometricField<Type, PatchField, GeoMesh>::T() const
|
||||||
|
|||||||
@ -254,6 +254,11 @@ public:
|
|||||||
|
|
||||||
typedef typename Field<Type>::cmptType cmptType;
|
typedef typename Field<Type>::cmptType cmptType;
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Return a null geometric field
|
||||||
|
inline static const GeometricField<Type, PatchField, GeoMesh>& null();
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
@ -381,7 +386,7 @@ public:
|
|||||||
virtual ~GeometricField();
|
virtual ~GeometricField();
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return dimensioned internal field
|
//- Return dimensioned internal field
|
||||||
DimensionedInternalField& dimensionedInternalField();
|
DimensionedInternalField& dimensionedInternalField();
|
||||||
@ -435,9 +440,6 @@ public:
|
|||||||
//- Does the field need a reference level for solution
|
//- Does the field need a reference level for solution
|
||||||
bool needReference() const;
|
bool needReference() const;
|
||||||
|
|
||||||
//- Return a null geometric field
|
|
||||||
static const GeometricField<Type, PatchField, GeoMesh>& null();
|
|
||||||
|
|
||||||
//- Return a component of the field
|
//- Return a component of the field
|
||||||
tmp<GeometricField<cmptType, PatchField, GeoMesh> > component
|
tmp<GeometricField<cmptType, PatchField, GeoMesh> > component
|
||||||
(
|
(
|
||||||
|
|||||||
@ -26,6 +26,14 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
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>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
inline
|
inline
|
||||||
const typename
|
const typename
|
||||||
@ -36,6 +44,7 @@ dimensionedInternalField() const
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
inline
|
inline
|
||||||
const typename
|
const typename
|
||||||
|
|||||||
@ -75,7 +75,7 @@ void MapGeometricFields
|
|||||||
{
|
{
|
||||||
HashTable<const GeometricField<Type, PatchField, GeoMesh>*> fields
|
HashTable<const GeometricField<Type, PatchField, GeoMesh>*> fields
|
||||||
(
|
(
|
||||||
mapper.db().objectRegistry::lookupClass
|
mapper.thisDb().objectRegistry::lookupClass
|
||||||
<GeometricField<Type, PatchField, GeoMesh> >()
|
<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)
|
else if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -59,14 +59,6 @@ Foam::Matrix<Form, Type>::~Matrix()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Form, Type>::Matrix(const label n, const label m)
|
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* av = a.v_[0];
|
||||||
const Type* bv = b.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++)
|
for (register label i=0; i<nm; i++)
|
||||||
{
|
{
|
||||||
abv[i] = av[i] + bv[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* av = a.v_[0];
|
||||||
const Type* bv = b.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++)
|
for (register label i=0; i<nm; i++)
|
||||||
{
|
{
|
||||||
abv[i] = av[i] - bv[i];
|
abv[i] = av[i] - bv[i];
|
||||||
|
|||||||
@ -88,6 +88,12 @@ class Matrix
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Static Member Functions
|
||||||
|
|
||||||
|
//- Return a null Matrix
|
||||||
|
inline static const Matrix<Form, Type>& null();
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Null constructor.
|
//- Null constructor.
|
||||||
@ -115,11 +121,7 @@ public:
|
|||||||
~Matrix();
|
~Matrix();
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return a null Matrix
|
|
||||||
static const Matrix<Form, Type>& null();
|
|
||||||
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,13 @@ inline Foam::autoPtr<Foam::Matrix<Form, Type> > Foam::Matrix<Form, Type>::clone(
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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
|
//- Return the number of rows
|
||||||
template<class Form, class Type>
|
template<class Form, class Type>
|
||||||
inline Foam::label Foam::Matrix<Form, Type>::n() const
|
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