Commit efbe9490 authored by franjo.juretic@c-fields.com's avatar franjo.juretic@c-fields.com
Browse files

DynList(const label) now construct a list with the requested size.


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@55 fdcce57e-7e00-11e2-b579-49867b4cea03
parent 7745d994
......@@ -381,8 +381,8 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
if( Pstream::myProcNo() == pMin )
{
DynList<face, 8> pFaces(3);
DynList<label, 3> pPatches(3);
DynList<face, 8> pFaces;
DynList<label, 3> pPatches;
forAllRow(pointFaces, bpI, fI)
{
const label bfI = pointFaces(bpI, fI);
......
......@@ -132,7 +132,7 @@ point boundaryLayers::createNewVertex
Info << "Vertex is on the border" << endl;
# endif
DynList<label> otherPatches(2);
DynList<label> otherPatches;
forAllRow(pPatches, bpI, patchI)
if( !treatPatches[pPatches(bpI, patchI)] )
otherPatches.appendIfNotIn
......@@ -542,9 +542,9 @@ void boundaryLayers::createNewVertices(const labelList& patchLabels)
const point& p = points[pointI];
std::map<std::pair<label, label>, label>& m = otherVrts_[pointI];
DynList<label> usedPatches(3);
DynList<label> newNodeLabel(3);
DynList<vector> newPatchPenetrationVector(3);
DynList<label> usedPatches;
DynList<label> newNodeLabel;
DynList<vector> newPatchPenetrationVector;
forAllRow(pPatches, bpI, patchI)
{
const label pKey = patchKey_[pPatches(bpI, patchI)];
......@@ -759,7 +759,7 @@ void boundaryLayers::createNewEdgeVerticesParallel
const labelList& globalPointLabel = mse.globalBoundaryPointLabel();
const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing();
DynList<label> neiProcs(10);
DynList<label> neiProcs;
labelLongList edgePoints;
Map<label> bpToEdgePoint;
forAll(procPoints, pointI)
......@@ -810,7 +810,7 @@ void boundaryLayers::createNewEdgeVerticesParallel
const point& p = points[bPoints[bpI]];
//- find patches for the given point
DynList<label> otherPatches(2);
DynList<label> otherPatches;
forAllRow(pPatches, bpI, patchI)
if( !treatPatches[pPatches(bpI, patchI)] )
otherPatches.appendIfNotIn(pPatches(bpI, patchI));
......@@ -928,7 +928,7 @@ void boundaryLayers::createNewEdgeVerticesParallel
const label bpI = edgePoints[epI];
//- find patches for the given point
DynList<label> otherPatches(2);
DynList<label> otherPatches;
forAllRow(pPatches, bpI, patchI)
if( !treatPatches[pPatches(bpI, patchI)] )
otherPatches.appendIfNotIn(pPatches(bpI, patchI));
......@@ -953,7 +953,7 @@ void boundaryLayers::createNewEdgeVerticesParallel
const point& p = points[bPoints[bpI]];
//- find patches for the given point
DynList<label> otherPatches(2);
DynList<label> otherPatches;
forAllRow(pPatches, bpI, patchI)
if( !treatPatches[pPatches(bpI, patchI)] )
otherPatches.appendIfNotIn(pPatches(bpI, patchI));
......
......@@ -101,7 +101,7 @@ inline Foam::DynList<T, staticSize>::DynList(const label s)
UList<T>(staticData_, staticSize),
nextFree_(0)
{
allocateSize(s);
setSize(s);
}
//- Construct given size
......
......@@ -70,7 +70,6 @@ void decomposeCells::checkFaceConnections(const boolList& decomposeCell)
DynList<label, 32> vrt;
DynList<edge, 64> edges;
DynList<DynList<label, 8> > faceEdges;
faceEdges.setSize(cells[cellI].size());
DynList<DynList<label, 2>, 64> edgeFaces;
findAddressingForCell(cellI, vrt, edges, faceEdges, edgeFaces);
......
......@@ -36,7 +36,7 @@ Description
namespace Foam
{
void decomposeCells::findAddressingForCell
(
const label cellI,
......@@ -47,6 +47,12 @@ void decomposeCells::findAddressingForCell
) const
{
const cell& c = mesh_.cells()[cellI];
vrt.clear();
edges.clear();
edgeFaces.clear();
faceEdges.setSize(c.size());
const faceListPMG& faces = mesh_.faces();
forAll(faceEdges, feI)
{
......@@ -57,10 +63,11 @@ void decomposeCells::findAddressingForCell
forAll(c, fI)
{
const face& f = faces[c[fI]];
const edgeList edg = faces[c[fI]].edges();
forAll(edg, eI)
forAll(f, eI)
{
const edge e = f.faceEdge(eI);
bool store(true);
forAll(vrt, vI)
if( vrt[vI] == f[eI] )
......@@ -72,13 +79,12 @@ void decomposeCells::findAddressingForCell
{
vrt.append(f[eI]);
}
else
{
store = true;
}
//- check if the edge alreready exists
store = true;
forAll(edges, eJ)
if( edg[eI] == edges[eJ] )
if( e == edges[eJ] )
{
store = false;
faceEdges[fI][eI] = eJ;
......@@ -92,7 +98,7 @@ void decomposeCells::findAddressingForCell
DynList<label, 2> ef;
ef.append(fI);
edgeFaces.append(ef);
edges.append(edg[eI]);
edges.append(e);
}
}
}
......@@ -101,16 +107,22 @@ void decomposeCells::findAddressingForCell
forAll(edgeFaces, efI)
if( edgeFaces[efI].size() != 2 )
{
forAll(c, fI)
Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl;
Info << "Edges " << edges << endl;
Info << "faceEdges " << faceEdges << endl;
Info << "edgeFaces " << edgeFaces << endl;
mesh_.write();
FatalErrorIn
(
"faceListList pMesh::decomposeCellIntoPyramids()"
"void decomposeCells::findAddressingForCell"
"(const label, DynList<label, 32>&, DynList<edge, 64>&"
", DynList<DynList<label, 8> >&"
", DynList<DynList<label, 2>, 64>&) const"
) << "Cell " << cellI << " is not topologically closed!"
<< abort(FatalError);
}
}
}
label decomposeCells::findTopVertex
......@@ -123,19 +135,19 @@ label decomposeCells::findTopVertex
{
const cell& c = mesh_.cells()[cellI];
const faceListPMG& faces = mesh_.faces();
pointFieldPMG& pointsAccess = mesh_.points();
//- there is no vertex in 3 or more patches
//- find boundary faces
label topVertex(-1);
const labelList cp = c.labels(faces);
point p(vector::zero);
forAll(cp, cpI)
p += pointsAccess[cp[cpI]];
p /= cp.size();
topVertex = pointsAccess.size();
pointsAccess.append(p);
......@@ -153,7 +165,7 @@ void decomposeCells::decomposeCellIntoPyramids(const label cellI)
const labelList& owner = mesh_.owner();
const cell& c = cells[cellI];
# ifdef DEBUGDecompose
Info << "Starting decomposing cell " << cellI << endl;
Info << "Cell consists of faces " << c << endl;
......@@ -173,7 +185,7 @@ void decomposeCells::decomposeCellIntoPyramids(const label cellI)
//- if there exist a corner vertex which is in 3 or more patches then
//- it is selected as the top vertex
label topVertex = findTopVertex(cellI, vrt, edges, edgeFaces);
//- start generating pyramids
forAll(c, fI)
{
......@@ -183,7 +195,7 @@ void decomposeCells::decomposeCellIntoPyramids(const label cellI)
const face& f = faces[c[fI]];
DynList<DynList<label, 8> > cellFaces;
cellFaces.setSize(f.size() + 1);
DynList<triFace> triFaces;
triFaces.setSize(f.size());
forAll(triFaces, pI)
......@@ -192,12 +204,12 @@ void decomposeCells::decomposeCellIntoPyramids(const label cellI)
triFaces[pI][1] = f[pI];
triFaces[pI][2] = topVertex;
}
label cfI(0);
if( owner[c[fI]] == cellI )
{
cellFaces[cfI++] = faces[c[fI]];
forAll(triFaces, tfI)
{
cellFaces[cfI++] = triFaces[tfI];
......@@ -214,12 +226,12 @@ void decomposeCells::decomposeCellIntoPyramids(const label cellI)
rf[1] = triFaces[tfI][2];
rf[2] = triFaces[tfI][1];
cellFaces[cfI++] = rf;
}
}
}
# ifdef DEBUGDecompose
Info << "Cell for face is " << cellFaces << endl;
DynList<edge, 64> cEdges;
DynList<DynList<label, 2>, 64> eFaces;
forAll(cellFaces, fI)
......@@ -228,9 +240,9 @@ void decomposeCells::decomposeCellIntoPyramids(const label cellI)
forAll(f, eI)
{
const edge e(f[eI], f[(eI+1)%f.size()]);
const label pos = cEdges.contains(e);
if( pos < 0 )
{
cEdges.append(e);
......@@ -244,12 +256,12 @@ void decomposeCells::decomposeCellIntoPyramids(const label cellI)
}
}
}
forAll(eFaces, eI)
if( eFaces[eI].size() != 2 )
Pout << "This pyrmid is not topologically closed" << endl;
# endif
facesOfNewCells_.appendGraph(cellFaces);
}
}
......
......@@ -51,7 +51,7 @@ void createFacesFromChain::findPointsBelongingToTheFace
endPoints.setSize(chainPoints_.size());
endPoints = false;
includePoints = false;
const label currRegion = regionsForPointAtPosition_[currPos][0];
if( regionsForPointAtPosition_[currPos].size() != 1 )
{
......@@ -62,19 +62,19 @@ void createFacesFromChain::findPointsBelongingToTheFace
) << "Trying to create a face from an invalid point!"
<< abort(FatalError);
}
# ifdef DEBUGCutter
Info << "Finding vertices belonging to the face from chain "
<< chainPoints_ << endl;
# endif
forAll(chainPoints_, pI)
{
const label pos = (pI+currPos) % chainPoints_.size();
if( regionsForPointAtPosition_[pos].contains(currRegion) )
includePoints[pos] = true;
if( regionsForPointAtPosition_[pos].size() > 1 )
{
endPoints[pos] = true;
......@@ -89,15 +89,15 @@ void createFacesFromChain::findPointsBelongingToTheFace
<< abort(FatalError);
}
}
forAllReverse(chainPoints_, pI)
{
const label pos = (pI+currPos) % chainPoints_.size();
if( includePoints[pos] ) break;
if( regionsForPointAtPosition_[pos].contains(currRegion) )
includePoints[pos] = true;
if( regionsForPointAtPosition_[pos].size() > 1 )
{
endPoints[pos] = true;
......@@ -113,7 +113,7 @@ void createFacesFromChain::findPointsBelongingToTheFace
<< abort(FatalError);
}
}
# ifdef DEBUGCutter
Info << "Include points " << includePoints << endl;
Info << "End points " << endPoints << endl;
......@@ -137,16 +137,16 @@ void createFacesFromChain::shrinkTheChain
) << "Trying to create a face from an invalid point!"
<< abort(FatalError);
}
# ifdef DEBUGCutter
Info << "Shrinking chain " << chainPoints_ << endl;
# endif
labelList shrinkedChain(chainPoints_.size());
List<DynList<label> > shrinkedRegions(chainPoints_.size());
direction pI(0);
forAll(chainPoints_, vI)
if( !includePoints[vI] )
{
......@@ -165,15 +165,15 @@ void createFacesFromChain::shrinkTheChain
);
++pI;
}
//- set sizes
shrinkedChain.setSize(pI);
shrinkedRegions.setSize(pI);
//- store the shrinked lists
chainPoints_ = shrinkedChain;
regionsForPointAtPosition_ = shrinkedRegions;
# ifdef DEBUGCutter
Info << "Shrinked chain " << chainPoints_ << endl;
Info << "Shrinked regions " << regionsForPointAtPosition_ << endl;
......@@ -200,7 +200,7 @@ createFacesFromChain::createFacesFromChain
forAll(row, rI)
regionsForPointAtPosition_[vI].append(row[rI]);
}
# ifdef DEBUGCutter
Info << "Making boundary faces for chain " << chainPoints_ << endl;
Info << "Regions for chain points " << regionsForPointAtPosition_ << endl;
......@@ -222,13 +222,13 @@ createFacesFromChain::createFacesFromChain
{
regionsForPointAtPosition_[vI] = pointRegions[chVertices[vI]];
}
# ifdef DEBUGCutter
Info << "Making boundary faces for chain " << chainPoints_ << endl;
Info << "Regions for chain points " << regionsForPointAtPosition_ << endl;
# endif
}
createFacesFromChain::~createFacesFromChain()
{
}
......@@ -242,15 +242,15 @@ void createFacesFromChain::createFacesWithoutACorner()
do
{
found = false;
boolList includePoints, endPoints;
//- this function removes nodes from the chainPoints_ and creates
//- new faces. In order to create a valid face, it is important that
//- that a chain of vertices belonging to a given patch is singly
//- connected. Non-singly connected chains are not treated until they
//- become singly connected after elimination of other chains
/*
boolList usedPoint(chainPoints_.size(), false);
Map<label> numOfChains;
......@@ -258,11 +258,11 @@ void createFacesFromChain::createFacesWithoutACorner()
if( !usedPoint[pI] && (regionsForPointAtPosition_[pI].size() == 1) )
{
findPointsBelongingToTheFace(pI, includePoints, endPoints);
forAll(includePoints, ipI)
if( includePoints[ipI] )
usedPoint[ipI] = true;
if( !numOfChains.found(regionsForPointAtPosition_[pI][0]) )
{
numOfChains.insert
......@@ -277,7 +277,7 @@ void createFacesFromChain::createFacesWithoutACorner()
}
}
*/
//- start creating faces and eliminating nodes from the chain for
//- singly connected topologies
forAll(chainPoints_, pI)
......@@ -285,42 +285,42 @@ void createFacesFromChain::createFacesWithoutACorner()
(regionsForPointAtPosition_[pI].size() == 1)
//&& (numOfChains[regionsForPointAtPosition_[pI][0]] == 1)
)
{
{
findPointsBelongingToTheFace(pI, includePoints, endPoints);
//- create a new face
face f(chainPoints_.size());
direction vrtI(0);
forAll(includePoints, incI)
if( includePoints[incI] )
f[vrtI++] = chainPoints_[incI];
DynList<label> facePatches(3);
DynList<label> facePatches;
forAll(endPoints, epI)
if( endPoints[epI] )
{
const DynList<label>& pr =
regionsForPointAtPosition_[epI];
forAll(pr, i)
facePatches.appendIfNotIn(pr[i]);
}
//- face must contain an additional corner point if the number
//- of associated patches is greater than 2. Skip creating the
//- face is this is the case
if( facePatches.size() > 2 )
continue;
found = true;
if( vrtI > 2 )
{
f.setSize(vrtI);
createdFaces_.append(f);
faceRegions_.append(regionsForPointAtPosition_[pI][0]);
# ifdef DEBUGCutter
Info << "Created face " << f << endl;
# endif
......@@ -328,31 +328,28 @@ void createFacesFromChain::createFacesWithoutACorner()
//- shrink the chainPoints_
shrinkTheChain(pI, includePoints, endPoints);
break;
}
} while( found );
}
void createFacesFromChain::createFacesWithACorner
(
const label cornerLabel
)
void createFacesFromChain::createFacesWithACorner(const label cornerLabel)
{
label start(-1), facePatch(-1);
forAll(chainPoints_, cpI)
if( regionsForPointAtPosition_[cpI].size() == 2 )
{
start = cpI;
DynList<label> commonPatches(2);
DynList<label> commonPatches;
const DynList<label>& np =
regionsForPointAtPosition_[chainPoints_.fcIndex(cpI)];
forAll(np, npI)
if( regionsForPointAtPosition_[cpI].contains(np[npI]) )
commonPatches.append(np[npI]);
if( commonPatches.size() == 1 )
{
facePatch = commonPatches[0];
......@@ -365,19 +362,19 @@ void createFacesFromChain::createFacesWithACorner
"createFacesWithACorner(const label cornerLabel)"
) << "Cannot determine face patch" << abort(FatalError);
}
break;
}
//- start creating faces with a corner
face f(5);
direction vI(0);
f[vI++] = chainPoints_[start];
for(label cpI=1;cpI<chainPoints_.size();++cpI)
{
const label pos = (cpI + start) % chainPoints_.size();
if( regionsForPointAtPosition_[pos].size() == 1 )
{
f.newElmt(vI++) = chainPoints_[pos];
......@@ -391,7 +388,7 @@ void createFacesFromChain::createFacesWithACorner
vI = 0;
createdFaces_.append(f);
faceRegions_.append(facePatch);
//- start creting new face
f[vI++] = chainPoints_[pos];
const label ppos =
......@@ -415,7 +412,7 @@ void createFacesFromChain::createFacesWithACorner
<< abort(FatalError);
}
}
//- add the start position into the last face
f.newElmt(vI++) = chainPoints_[start];
f.newElmt(vI++) = cornerLabel;
......
......@@ -50,23 +50,23 @@ void sortEdgesIntoChains::createNodeLabels()
if( !newNodeLabel_.found(e.end()) )
newNodeLabel_.insert(e.end(), nPoints++);
}
edgesAtPoint_.setSize(nPoints, DynList<label>(2));
edgesAtPoint_.setSize(nPoints, DynList<label>());
forAll(bEdges_, eI)
{
const edge& e = bEdges_[eI];
label l = newNodeLabel_[e.start()];
edgesAtPoint_[l].append(eI);
l = newNodeLabel_[e.end()];
edgesAtPoint_[l].append(eI);
}