Commit 991810d5 authored by franjo_j@hotmail.com's avatar franjo_j@hotmail.com
Browse files

An incomplete version of bnd layer refinement + other changes


git-svn-id: https://pl5.projectlocker.com/igui/meshGeneration/svn@33 fdcce57e-7e00-11e2-b579-49867b4cea03
parent 0bdd1dc4
......@@ -265,6 +265,10 @@ $(boundaryLayers)/boundaryLayerCells.C
$(boundaryLayers)/boundaryLayersCheckTopologyOfBndFaces.C
$(boundaryLayers)/boundaryLayersWrapperLayer.C
$(boundaryLayers)/extrudeLayer.C
$(boundaryLayers)/refineBoundaryLayers.C
$(boundaryLayers)/refineBoundaryLayersFunctions.C
$(boundaryLayers)/refineBoundaryLayersFaces.C
$(boundaryLayers)/refineBoundaryLayersCells.C
$(boundaryOutwardOrientation)/boundaryOutwardOrientation.C
......
......@@ -54,14 +54,14 @@ namespace Foam
void boundaryLayers::createLayerCells(const labelList& patchLabels)
{
Info << "Starting creating layer cells" << endl;
const meshSurfaceEngine& mse = surfaceEngine();
const faceList::subList& bFaces = mse.boundaryFaces();
const VRWGraph& faceEdges = mse.faceEdges();
const VRWGraph& edgeFaces = mse.edgeFaces();
const labelList& boundaryFacePatches = mse.boundaryFacePatches();
const labelList& faceOwners = mse.faceOwners();
boolList treatPatches(mesh_.boundaries().size(), false);
forAll(patchLabels, patchI)
{
......@@ -69,56 +69,57 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
forAll(treatPatchesWithPatch_[pLabel], i)
treatPatches[treatPatchesWithPatch_[pLabel][i]] = true;
}
//- create new faces at parallel boundaries
const Map<label>* otherProcPatchPtr(NULL);
const Map<label>* otherFaceProcPtr(NULL);
if( Pstream::parRun() )
{
createNewFacesParallel(treatPatches);
otherProcPatchPtr = &mse.otherEdgeFacePatch();
otherFaceProcPtr = &mse.otherEdgeFaceAtProc();
}
//- create lists for new boundary faces
VRWGraph newBoundaryFaces;
labelListPMG newBoundaryOwners;
labelListPMG newBoundaryPatches;
//- create storage for new cells
VRWGraphList cellsToAdd;
//- create layer cells and store boundary faces
const label nOldCells = mesh_.cells().size();
forAll(bFaces, bfI)
{
if( treatPatches[boundaryFacePatches[bfI]] )
{
const face& f = bFaces[bfI];
const label pKey = patchKey_[boundaryFacePatches[bfI]];
DynList<DynList<label> > cellFaces;
DynList<label> newF;
//- store boundary face
//- store the current boundary face
newF.clear();
newF.append(f[0]);
for(label pI=f.size()-1;pI>0;--pI)
newF.append(f[pI]);
cellFaces.append(newF);
//- create parallel face
newF.clear();
forAll(f, pI)
newF.append(findNewNodeLabel(f[pI], pKey));
newF[pI] = findNewNodeLabel(f[pI], pKey);
cellFaces.append(newF);
newBoundaryFaces.appendList(newF);
newBoundaryOwners.append(cellsToAdd.size() + nOldCells);
newBoundaryPatches.append(boundaryFacePatches[bfI]);
//- create quad faces
newF.setSize(4);
forAll(f, pI)
......@@ -129,7 +130,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
newF[3] = findNewNodeLabel(f[pI], pKey);
cellFaces.append(newF);
//- check if the face is at the boundary
//- of the treated partitions
const label edgeI = faceEdges(bfI, pI);
......@@ -138,7 +139,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
label neiFace = edgeFaces(edgeI, 0);
if( neiFace == bfI )
neiFace = edgeFaces(edgeI, 1);
if( !treatPatches[boundaryFacePatches[neiFace]] )
{
newBoundaryFaces.appendList(newF);
......@@ -158,11 +159,11 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
}
}
}
# ifdef DEBUGLayer
Info << "Adding cell " << cellFaces << endl;
# endif
cellsToAdd.appendGraph(cellFaces);
}
else
......@@ -176,6 +177,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
newBoundaryOwners.append(faceOwners[bfI]);
newBoundaryPatches.append(boundaryFacePatches[bfI]);
}
}
//- data for parallel execution
boolList procPoint;
......@@ -185,10 +187,10 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
{
procPoint.setSize(nPoints_);
procPoint = false;
const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing();
const labelList& bPoints = mse.boundaryPoints();
for
(
Map<label>::const_iterator iter=globalToLocal.begin();
......@@ -200,7 +202,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
procPoint[bPoints[bpI]] = true;
}
}
//- create cells at edges
const edgeList& edges = mse.edges();
forAll(edgeFaces, edgeI)
......@@ -208,17 +210,17 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
//- do not consider edges with no faces attached to it
if( edgeFaces.sizeOfRow(edgeI) == 0 )
continue;
//- cells are generated at the processor with the lowest label
if(
(edgeFaces.sizeOfRow(edgeI) == 1) &&
(otherFaceProcPtr->operator[](edgeI) < Pstream::myProcNo())
)
continue;
//- check if the edge is a feature edge
const label patchI = boundaryFacePatches[edgeFaces(edgeI, 0)];
label patchJ;
if( otherProcPatchPtr && otherProcPatchPtr->found(edgeI) )
{
......@@ -228,23 +230,23 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
{
patchJ = boundaryFacePatches[edgeFaces(edgeI, 1)];
}
if( patchI == patchJ )
continue;
//- check if the faces attached to the edge have different keys
const label pKeyI = patchKey_[patchI];
const label pKeyJ = patchKey_[patchJ];
if( pKeyI == pKeyJ )
continue;
const edge& e = edges[edgeI];
if( otherVrts_.find(e.start()) == otherVrts_.end() )
continue;
if( otherVrts_.find(e.end()) == otherVrts_.end() )
continue;
DynList<DynList<label, 4>, 6> cellFaces;
createNewCellFromEdge(e, pKeyI, pKeyJ, cellFaces);
......@@ -252,11 +254,11 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
newBoundaryFaces.appendList(cellFaces[1]);
newBoundaryOwners.append(nOldCells+cellsToAdd.size());
newBoundaryPatches.append(patchJ);
newBoundaryFaces.appendList(cellFaces[3]);
newBoundaryOwners.append(nOldCells+cellsToAdd.size());
newBoundaryPatches.append(patchI);
if( Pstream::parRun() )
{
if( procPoint[e.start()] )
......@@ -270,15 +272,15 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
faceAtPatches.append(labelPair(patchI, patchJ));
}
}
//- append cell to the queue
cellsToAdd.appendGraph(cellFaces);
}
//- create cells for corner nodes
const VRWGraph& pointFaces = mse.pointFaces();
const labelList& bp = mse.bp();
std::map<label, DynList<label, 3> > nodePatches;
labelHashSet parPoint;
if( Pstream::parRun() )
......@@ -287,7 +289,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
const VRWGraph& pProcs = mse.bpAtProcs();
const labelList& globalPointLabel = mse.globalBoundaryPointLabel();
const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing();
std::map<label, labelListPMG> facesToSend;
std::map<label, DynList<face, 8> > parPointFaces;
std::map<label, DynList<label, 3> > parPointPatches;
......@@ -302,26 +304,26 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
{
if( iter->second.size() == 2 )
continue;
const label bpI = bp[iter->first];
if( pProcs.sizeOfRow(bpI) != 0 )
{
parPoint.insert(iter->first);
//- point is at a parallel boundary
label pMin = pProcs(bpI, 0);
forAllRow(pProcs, bpI, i)
{
const label prI = pProcs(bpI, i);
if( facesToSend.find(prI) == facesToSend.end() )
facesToSend.insert(std::make_pair(prI, labelListPMG()));
if( prI < pMin )
pMin = prI;
}
if( Pstream::myProcNo() == pMin )
{
DynList<face, 8> pFaces(3);
......@@ -341,9 +343,9 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
parPointPatches.insert(std::make_pair(bpI, pPatches));
continue;
}
labelListPMG& stp = facesToSend[pMin];
//- send the data to the processor with the lowest label
//- data is flatenned as follows
//- 1. the number of faces and global point label
......@@ -363,11 +365,11 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
}
}
}
//- exchange data with other processors
labelListPMG receivedData;
help::exchangeMap(facesToSend, receivedData);
label counter(0);
while( counter < receivedData.size() )
{
......@@ -382,7 +384,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
parPointFaces[bpI].append(f);
}
}
//- sort faces sharing corners at the parallel boundaries
for
(
......@@ -394,12 +396,12 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
DynList<face, 8>& pFaces = iter->second;
DynList<label, 3>& fPatches = parPointPatches[iter->first];
const label gpI = globalPointLabel[iter->first];
for(label i=0;i<pFaces.size();++i)
{
const face& bf = pFaces[i];
const edge e = bf.faceEdge(bf.which(gpI));
for(label j=i+1;j<pFaces.size();++j)
{
const face& obf = pFaces[j];
......@@ -419,15 +421,15 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
}
}
}
DynList<label, 3> patchIDs(fPatches.size());
forAll(fPatches, fpI)
patchIDs.appendIfNotIn(fPatches[fpI]);
nodePatches.insert(std::make_pair(bPoints[iter->first], patchIDs));
}
}
//- sort out vertices at one processor
for
(
......@@ -440,17 +442,17 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
{
if( iter->second.size() == 2 )
continue;
if( parPoint.found(iter->first) )
continue;
const label bpI = bp[iter->first];
//- ensure correct orientation
labelList pFaces(pointFaces.sizeOfRow(bpI));
forAll(pFaces, fI)
pFaces[fI] = pointFaces(bpI, fI);
for(label i=0;i<pFaces.size();++i)
{
const face& bf = bFaces[pFaces[i]];
......@@ -471,13 +473,13 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
}
}
}
DynList<label, 3> patchIDs;
forAll(pFaces, patchI)
{
patchIDs.appendIfNotIn(boundaryFacePatches[pFaces[patchI]]);
}
nodePatches.insert(std::make_pair(iter->first, patchIDs));
}
......@@ -495,33 +497,33 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
{
pKeys.appendIfNotIn(patchKey_[patchIDs[patchI]]);
}
if( pKeys.size() != 3 )
continue;
DynList<DynList<label, 4>, 6> cellFaces;
createNewCellFromNode(iter->first, pKeys, cellFaces);
//- store boundary faces
newBoundaryFaces.appendList(cellFaces[1]);
newBoundaryOwners.append(nOldCells+cellsToAdd.size());
newBoundaryPatches.append(patchIDs[0]);
newBoundaryFaces.appendList(cellFaces[3]);
newBoundaryOwners.append(nOldCells+cellsToAdd.size());
newBoundaryPatches.append(patchIDs[1]);
newBoundaryFaces.appendList(cellFaces[5]);
newBoundaryOwners.append(nOldCells+cellsToAdd.size());
newBoundaryPatches.append(patchIDs[2]);
if( Pstream::parRun() )
{
if( procPoint[iter->first] )
{
pointProcFaces.append(cellFaces[0]);
faceAtPatches.append(labelPair(patchIDs[1], patchIDs[2]));
pointProcFaces.append(cellFaces[2]);
faceAtPatches.append(labelPair(patchIDs[0], patchIDs[2]));
......@@ -529,11 +531,11 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
faceAtPatches.append(labelPair(patchIDs[0], patchIDs[1]));
}
}
# ifdef DEBUGLayer
Info << "Adding corner cell " << cellFaces << endl;
# endif
//- append cell to the queue
cellsToAdd.appendGraph(cellFaces);
}
......@@ -548,10 +550,10 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
faceAtPatches
);
}
//- create mesh modifier
polyMeshGenModifier meshModifier(mesh_);
meshModifier.addCells(cellsToAdd);
cellsToAdd.clear();
meshModifier.reorderBoundaryFaces();
......@@ -585,7 +587,7 @@ void boundaryLayers::createNewFacesFromPointsParallel
const VRWGraph& bpAtProcs = mse.bpAtProcs();
const labelList& globalPointLabel = mse.globalBoundaryPointLabel();
const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing();
labelList otherFaceProc(faceCandidates.size(), -1);
//- some faces may appear more than once
//- such faces are ordinary internal faces
......@@ -595,16 +597,16 @@ void boundaryLayers::createNewFacesFromPointsParallel
forAll(faceCandidates[fI], pI)
pointFaceCandidates.append(faceCandidates[fI][pI], fI);
}
boolList duplicateFace(faceCandidates.size(), false);
List<labelledPair> pointOfOrigin(faceCandidates.size());
std::map<labelledPair, label> pointOfOriginToFaceLabel;
forAll(faceCandidates, fI)
{
const DynList<label, 4>& f = faceCandidates[fI];
const label pointI = f[0];
const labelledPair lp
(
globalPointLabel[bp[pointI]],
......@@ -614,7 +616,7 @@ void boundaryLayers::createNewFacesFromPointsParallel
patchKey_[candidatePatches[fI][1]]
)
);
if(
pointOfOriginToFaceLabel.find(lp) != pointOfOriginToFaceLabel.end()
)
......@@ -624,12 +626,12 @@ void boundaryLayers::createNewFacesFromPointsParallel
duplicateFace[pointOfOriginToFaceLabel[lp]] = true;
continue;
}
pointOfOrigin[fI] = lp;
pointOfOriginToFaceLabel.insert(std::make_pair(lp, fI));
}
//- find the processor patch for each processor boundary face
//- the key of the algorithm is the point from which the face was created
//- by sending the point label and the associated patches, it will be
......@@ -639,10 +641,10 @@ void boundaryLayers::createNewFacesFromPointsParallel
forAll(neiProcs, procI)
{
const label neiProcI = neiProcs[procI];
if( neiProcI == Pstream::myProcNo() )
continue;
if( exchangeData.find(neiProcI) == exchangeData.end() )
exchangeData.insert
(
......@@ -654,7 +656,7 @@ void boundaryLayers::createNewFacesFromPointsParallel
{
if( duplicateFace[fI] )
continue;
const label bpI = bp[faceCandidates[fI][0]];
forAllRow(bpAtProcs, bpI, procI)
......@@ -662,17 +664,17 @@ void boundaryLayers::createNewFacesFromPointsParallel
const label neiProcNo = bpAtProcs(bpI, procI);
if( neiProcNo == Pstream::myProcNo() )
continue;
LongList<labelledPair>& dataToSend = exchangeData[neiProcNo];
dataToSend.append(pointOfOrigin[fI]);
}
}
//- exchange the data with other processors
std::map<label, List<labelledPair> > receivedMap;
help::exchangeMap(exchangeData, receivedMap);
exchangeData.clear();
for
(
std::map<label, List<labelledPair> >::const_iterator
......@@ -682,25 +684,25 @@ void boundaryLayers::createNewFacesFromPointsParallel
)
{
const List<labelledPair>& receivedData = iter->second;
forAll(receivedData, i)
{
const labelledPair& lpp = receivedData[i];
const label gpI = lpp.pairLabel();
const label pointI = bPoints[globalToLocal[gpI]];
const labelPair& lp = lpp.pair();
forAllRow(pointFaceCandidates, pointI, i)
{
const label fI = pointFaceCandidates(pointI, i);
const DynList<label, 4>& f = faceCandidates[fI];
Pair<label> pk
(
patchKey_[candidatePatches[fI][0]],
patchKey_[candidatePatches[fI][1]]
);
if(
(f[0] == pointI) && ((pk == lp) || (pk.reversePair() == lp))
)
......@@ -712,29 +714,29 @@ void boundaryLayers::createNewFacesFromPointsParallel
}
}
receivedMap.clear();
//- sort the points in ascending order
//- this ensures the correct order of faces at the processor boundaries
sort(pointOfOrigin);
Map<label> otherProcToProcPatch;
forAll(mesh_.procBoundaries(), patchI)
{
const writeProcessorPatch& wp = mesh_.procBoundaries()[patchI];
otherProcToProcPatch.insert(wp.neiProcNo(), patchI);
}
//- store processor faces
VRWGraph newProcFaces;
labelListPMG newProc;
forAll(pointOfOrigin, i)
{
const label fI = pointOfOriginToFaceLabel[pointOfOrigin[i]];
if( duplicateFace[fI] || (otherFaceProc[fI] == -1) )
continue;
if( !otherProcToProcPatch.found(otherFaceProc