Commit 0f3c91ce authored by Andrew Heather's avatar Andrew Heather
Browse files
parents 5e20eeb0 908e8fd3
......@@ -119,7 +119,7 @@ scalar StCoNum = 0.0;
fvc::makeAbsolute(phi, rho, U);
// Test : disable refinement for some cells
PackedList<1>& protectedCell =
PackedBoolList& protectedCell =
refCast<dynamicRefineFvMesh>(mesh).protectedCell();
if (protectedCell.empty())
......
......@@ -395,7 +395,7 @@ Foam::laminarFlameSpeedModels::SCOPE::Ma() const
(
"Ma",
mesh.time().timeName(),
mesh.db(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
......
......@@ -160,6 +160,19 @@ int main(int argc, char *argv[])
<< " " << lstB.size() << endl;
Info<< "<dlD>" << dlD << "</dlD>" << nl << "sizes: "
<< " " << dlD.size() << "/" << dlD.capacity() << endl;
DynamicList<label,10> dlE1(10);
DynamicList<label> dlE2(dlE1);
Info<< "<dlE1>" << dlE1 << "</dlE1>" << nl << "sizes: "
<< " " << dlE1.size() << "/" << dlE1.capacity() << endl;
Info<< "<dlE2>" << dlE2 << "</dlE2>" << nl << "sizes: "
<< " " << dlE2.size() << "/" << dlE2.capacity() << endl;
dlE2.append(100);
Info<< "<dlE2>" << dlE2 << "</dlE2>" << endl;
Info<< "\nEnd\n";
return 0;
}
......
PackedListTest.C
EXE = $(FOAM_USER_APPBIN)/PackedListTest
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "PackedBoolList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
bool changed;
Info<< "PackedList max_bits() = " << PackedList<0>::max_bits() << nl;
Info<< "\ntest allocation with value\n";
PackedList<3> list1(5,1);
list1.print(Info);
Info<< "\ntest assign uniform value\n";
list1 = 2;
list1.print(Info);
Info<< "\ntest resize with value (without reallocation)\n";
list1.resize(6, 3);
list1.print(Info);
Info<< "\ntest set() function\n";
list1.set(1, 5);
list1.print(Info);
Info<< "\ntest assign bool\n";
list1 = false;
list1.print(Info);
Info<< "\ntest assign bool\n";
list1 = true;
list1.print(Info);
Info<< "\ntest resize without value (with reallocation)\n";
list1.resize(12);
list1.print(Info);
Info<< "\ntest resize with value (with reallocation)\n";
list1.resize(25, list1.max_value());
list1.print(Info);
Info<< "\ntest resize smaller (should not touch allocation)\n";
list1.resize(8);
list1.print(Info);
Info<< "\ntest append() operation\n";
list1.append(2);
list1.append(3);
list1.append(4);
list1.print(Info);
Info<< "\ntest reserve() operation\n";
list1.reserve(32);
list1.print(Info);
Info<< "\ntest shrink() operation\n";
list1.shrink();
list1.print(Info);
Info<< "\ntest setCapacity() operation\n";
list1.setCapacity(15);
list1.print(Info);
Info<< "\ntest setCapacity() operation\n";
list1.setCapacity(30);
list1.print(Info);
Info<< "\ntest operator[] assignment\n";
list1[16] = 5;
list1.print(Info);
Info<< "\ntest operator[] assignment with auto-vivify\n";
list1[36] = list1.max_value();
list1.print(Info);
Info<< "\ntest setCapacity smaller\n";
list1.setCapacity(32);
list1.print(Info);
// add in some misc values
list1[31] = 1;
list1[32] = 2;
list1[33] = 3;
Info<< "\ntest iterator\n";
PackedList<3>::iterator iter = list1.begin();
Info<< "iterator:" << iter() << "\n";
iter.print(Info) << "\n";
Info<< "\ntest iterator operator=\n";
changed = (iter = 5);
Info<< "iterator:" << iter() << "\n";
Info<< "changed:" << changed << "\n";
changed = (iter = 5);
Info<< "changed:" << changed << "\n";
list1.print(Info);
Info<< "\ntest get() method\n";
Info<< "get(10):" << list1.get(10)
<< " and list[10]:" << unsigned(list1[10]) << "\n";
list1.print(Info);
Info<< "\ntest iterator indexing\n";
Info<< "end() ";
list1.end().print(Info) << "\n";
for (iter = list1[31]; iter != list1.end(); ++iter)
{
iter.print(Info);
}
Info<< "\ntest operator[] auto-vivify\n";
const unsigned int val = list1[45];
Info<< "list[45]:" << val << "\n";
list1.print(Info);
Info<< "\ntest copy constructor + append\n";
PackedList<3> list2(list1);
list2.append(4);
Info<< "source list:\n";
list1.print(Info);
Info<< "destination list:\n";
list2.print(Info);
Info<< "\ntest pattern that fills all bits\n";
PackedList<4> list3(8, 8);
list3[list3.size()-2] = 0;
list3[list3.size()-1] = list3.max_value();
list3.print(Info);
Info<< "\n\nDone.\n";
return 0;
}
// ************************************************************************* //
......@@ -48,7 +48,7 @@ Description
#include "polyMesh.H"
#include "mapPolyMesh.H"
#include "mathematicalConstants.H"
#include "PackedList.H"
#include "PackedBoolList.H"
#include "SortableList.H"
using namespace Foam;
......@@ -177,7 +177,7 @@ label mergeEdges
// Return master point edge needs to be collapsed to (or -1)
label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e)
label edgeMaster(const PackedBoolList& boundaryPoint, const edge& e)
{
label masterPoint = -1;
......@@ -215,7 +215,7 @@ label edgeMaster(const PackedList<1>& boundaryPoint, const edge& e)
label collapseSmallEdges
(
const polyMesh& mesh,
const PackedList<1>& boundaryPoint,
const PackedBoolList& boundaryPoint,
const scalar minLen,
edgeCollapser& collapser
)
......@@ -254,7 +254,7 @@ label collapseSmallEdges
label collapseHighAspectFaces
(
const polyMesh& mesh,
const PackedList<1>& boundaryPoint,
const PackedBoolList& boundaryPoint,
const scalar areaFac,
const scalar edgeRatio,
edgeCollapser& collapser
......@@ -346,7 +346,7 @@ void set(const labelList& elems, const bool val, boolList& status)
label simplifyFaces
(
const polyMesh& mesh,
const PackedList<1>& boundaryPoint,
const PackedBoolList& boundaryPoint,
const label minSize,
const scalar lenGap,
edgeCollapser& collapser
......@@ -485,7 +485,7 @@ int main(int argc, char *argv[])
const faceList& faces = mesh.faces();
// Get all points on the boundary
PackedList<1> boundaryPoint(mesh.nPoints(), false);
PackedBoolList boundaryPoint(mesh.nPoints());
label nIntFaces = mesh.nInternalFaces();
for (label faceI = nIntFaces; faceI < mesh.nFaces(); faceI++)
......
......@@ -51,7 +51,7 @@ cellShape create3DCellShape
static List<const cellModel*> fluentCellModelLookup
(
7,
reinterpret_cast<const cellModel*>(NULL)
reinterpret_cast<const cellModel*>(0)
);
fluentCellModelLookup[2] = cellModeller::lookup("tet");
......
......@@ -49,7 +49,7 @@ Description
#include "mathematicalConstants.H"
#include "polyTopoChange.H"
#include "mapPolyMesh.H"
#include "PackedList.H"
#include "PackedBoolList.H"
#include "meshTools.H"
#include "OFstream.H"
#include "meshDualiser.H"
......@@ -67,7 +67,7 @@ using namespace Foam;
void simpleMarkFeatures
(
const polyMesh& mesh,
const PackedList<1>& isBoundaryEdge,
const PackedBoolList& isBoundaryEdge,
const scalar featureAngle,
const bool doNotPreserveFaceZones,
......@@ -358,7 +358,7 @@ int main(int argc, char *argv[])
// Mark boundary edges and points.
// (Note: in 1.4.2 we can use the built-in mesh point ordering
// facility instead)
PackedList<1> isBoundaryEdge(mesh.nEdges());
PackedBoolList isBoundaryEdge(mesh.nEdges());
for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
{
const labelList& fEdges = mesh.faceEdges()[faceI];
......
......@@ -155,7 +155,7 @@ Foam::label Foam::meshDualiser::findDualCell
// from (boundary & feature) point
void Foam::meshDualiser::generateDualBoundaryEdges
(
const PackedList<1>& isBoundaryEdge,
const PackedBoolList& isBoundaryEdge,
const label pointI,
polyTopoChange& meshMod
)
......@@ -388,7 +388,7 @@ Foam::label Foam::meshDualiser::addBoundaryFace
void Foam::meshDualiser::createFacesAroundEdge
(
const bool splitFace,
const PackedList<1>& isBoundaryEdge,
const PackedBoolList& isBoundaryEdge,
const label edgeI,
const label startFaceI,
polyTopoChange& meshMod,
......@@ -907,7 +907,7 @@ void Foam::meshDualiser::setRefinement
// Mark boundary edges and points.
// (Note: in 1.4.2 we can use the built-in mesh point ordering
// facility instead)
PackedList<1> isBoundaryEdge(mesh_.nEdges());
PackedBoolList isBoundaryEdge(mesh_.nEdges());
for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
{
const labelList& fEdges = mesh_.faceEdges()[faceI];
......
......@@ -49,7 +49,7 @@ SourceFiles
#define meshDualiser_H
#include "DynamicList.H"
#include "PackedList.H"
#include "PackedBoolList.H"
#include "boolList.H"
#include "typeInfo.H"
......@@ -101,7 +101,7 @@ class meshDualiser
// emanating from (boundary & feature) point
void generateDualBoundaryEdges
(
const PackedList<1>&,
const PackedBoolList&,
const label pointI,
polyTopoChange&
);
......@@ -144,7 +144,7 @@ class meshDualiser
void createFacesAroundEdge
(
const bool splitFace,
const PackedList<1>&,
const PackedBoolList&,
const label edgeI,
const label startFaceI,
polyTopoChange&,
......
......@@ -90,13 +90,13 @@ const label sammMesh::shapeFaceLookup[19][9] =
List<const cellModel*> sammMesh::sammShapeLookup
(
256,
reinterpret_cast<cellModel*>(NULL)
reinterpret_cast<cellModel*>(0)
);
List<const label*> sammMesh::sammAddressingTable
(
256,
reinterpret_cast<label*>(NULL)
reinterpret_cast<label*>(0)
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -48,7 +48,7 @@ void starMesh::addRegularCell
label regularTypeFlag = -1;
// grab the shape from the table
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
if // Tetrahedron
(
......@@ -130,7 +130,7 @@ void starMesh::addSAMMcell
// grab the shape from the table
label sammTypeFlag = -1;
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
switch (typeFlag)
{
......
......@@ -82,7 +82,7 @@ topoSetSources
// Cells in cell zone
zoneToCell
{
name ".*Zone"; // name of cellZone, wildcards allowed.
name ".*Zone"; // Name of cellZone, regular expressions allowed
}
// values of field within certain range
......@@ -102,16 +102,16 @@ topoSetSources
// Select based on surface
surfaceToCell
{
file "www.avl.com-geometry.stl";
outsidePoints ((-99 -99 -59)); // definition of outside
includeCut false; // cells cut by surface
includeInside false; // cells not on outside of surf
includeOutside false; // cells on outside of surf
nearDistance -1; // cells with centre near surf
// (set to -1 if not used)
curvature 0.9; // cells within nearDistance
// and near surf curvature
// (set to -100 if not used)
file "www.avl.com-geometry.stl";
outsidePoints ((-99 -99 -59)); // definition of outside
includeCut false; // cells cut by surface
includeInside false; // cells not on outside of surf
includeOutside false; // cells on outside of surf
nearDistance -1; // cells with centre near surf
// (set to -1 if not used)
curvature 0.9; // cells within nearDistance
// and near surf curvature
// (set to -100 if not used)
}
);
......
......@@ -60,18 +60,18 @@ topoSetSources
// All points in pointzone
zoneToPoint
{
name ".*Zone"; // name of pointZone, wildcards allowed.
name ".*Zone"; // name of pointZone, regular expressions allowed
}
// Select based on surface
surfaceToPoint
{
file "www.avl.com-geometry.stl";
nearDistance 0.1; // points near to surface
includeInside false; // points on inside of surface
// (requires closed surface with consistent
// normals)
includeOutside false; // ,, outside ,,
file "www.avl.com-geometry.stl";
nearDistance 0.1; // points near to surface
includeInside false; // points on inside of surface
// (requires closed surface with consistent
// normals)
includeOutside false; // ,, outside ,,
}
);
......
......@@ -30,12 +30,17 @@ Description
- any face inbetween differing cellZones (-cellZones)
Output is:
- mesh with multiple regions
- mesh with multiple regions or
- mesh with cells put into cellZones (-makeCellZones)
Should work in parallel but cellZone interfaces cannot align with
Note:
- Should work in parallel but cellZone interfaces cannot align with
processor boundaries so use the correct option in decomposition to
preserve those interfaces.
- If a cell zone gets split into more than one region it can detect
the largest matching region (-sloppyCellZones). This will accept any
region that covers more than 50% of the zone. It has to be a subset
so cannot have any cells in any other zone.
\*---------------------------------------------------------------------------*/
......@@ -613,7 +618,7 @@ autoPtr<mapPolyMesh> createRegionMesh
"fvSchemes",
mesh.time().system(),
regionName,
mesh.db(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
......@@ -642,7 +647,7 @@ autoPtr<mapPolyMesh> createRegionMesh
"fvSolution",
mesh.time().system(),
regionName,
mesh.db(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
......@@ -1036,78 +1041,181 @@ EdgeMap<label> addRegionPatches
}
// Checks if regionI in cellRegion corresponds to existing zone.
label findCorrespondingZone
//// Checks if regionI in cellRegion is subset of existing cellZone. Returns -1
//// if no zone found, zone otherwise
//label findCorrespondingSubZone
//(
// const cellZoneMesh& cellZones,
// const labelList& existingZoneID,
// const labelList& cellRegion,
// const label regionI
//)
//{
// // Zone corresponding to region. No corresponding zone.
// label zoneI = labelMax;
//
// labelList regionCells = findIndices(cellRegion, regionI);
//
// if (regionCells.empty())
// {
// // My local portion is empty. Maps to any empty cellZone. Mark with
// // special value which can get overwritten by other processors.
// zoneI = -1;
// }
// else
// {
// // Get zone for first element.
// zoneI = existingZoneID[regionCells[0]];
//
// if (zoneI == -1)
// {
// zoneI = labelMax;
// }
// else
// {
// // 1. All regionCells in zoneI?
// forAll(regionCells, i)
// {
// if (existingZoneID[regionCells[i]] != zoneI)
// {
// zoneI = labelMax;
// break;
// }
// }
// }
// }
//
// // Determine same zone over all processors.
// reduce(zoneI, maxOp<label>());
//
// if (zoneI == labelMax)
// {
// // Cells in region that are not in zoneI
// zoneI = -1;
// }
//
// return zoneI;
//}
//XXXXXXXXX
// Find region that covers most of cell zone
label findCorrespondingRegion
(
const cellZoneMesh& cellZones,
const labelList& existingZoneID,
const labelList& cellRegion,
const label regionI
const labelList& existingZoneID, // per cell the (unique) zoneID
const regionSplit& cellRegion,
const label zoneI,
const label minOverlapSize
)
{
// Zone corresponding to region. No corresponding zone.
label zoneI = labelMax;
labelList regionCells = findIndices(cellRegion, regionI);
// Per region the number of cells in zoneI
labelList cellsInZone(cellRegion.nRegions(), 0);
if (regionCells.empty())
{
// My local portion is empty. Maps to any empty cellZone. Mark with
// special value which can get overwritten by other processors.
zoneI = -1;
}
else
forAll(cellRegion, cellI)
{
// Get zone for first element.
zoneI = existingZoneID[regionCells[0]];