Commit 6052b538 authored by Franjo's avatar Franjo

Improved transferrig of patch types

parent 47108813
......@@ -638,6 +638,10 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
newBoundaryPatches
);
PtrList<boundaryPatch>& boundaries = meshModifier.boundariesAccess();
forAll(boundaries, patchI)
boundaries[patchI].patchType() = patchTypes_[patchI];
//- delete meshSurfaceEngine
this->clearOut();
......
......@@ -543,6 +543,7 @@ boundaryLayers::boundaryLayers
terminateLayersAtConcaveEdges_(false),
is2DMesh_(false),
patchNames_(),
patchTypes_(),
treatedPatch_(),
treatPatchesWithPatch_(),
newLabelForVertex_(),
......@@ -553,8 +554,12 @@ boundaryLayers::boundaryLayers
{
const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
patchNames_.setSize(boundaries.size());
patchTypes_.setSize(boundaries.size());
forAll(boundaries, patchI)
{
patchNames_[patchI] = boundaries[patchI].patchName();
patchTypes_[patchI] = boundaries[patchI].patchType();
}
treatedPatch_.setSize(boundaries.size());
treatedPatch_ = false;
......
......@@ -84,6 +84,9 @@ class boundaryLayers
//- patch names
wordList patchNames_;
//- patch types
wordList patchTypes_;
//- helper which contains information if a boundary layer
//- has already been extruded for a given patch
boolList treatedPatch_;
......
......@@ -46,25 +46,25 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
{
if( !patchWiseLayers_ )
return;
Info << "Checking topology of boundary faces" << endl;
labelHashSet usedPatches;
forAll(patchLabels, i)
usedPatches.insert(patchLabels[i]);
//- create a set of patch pairs. These are pairs at which the layers
//- shall be terminated
std::set<std::pair<label, label> > terminatedPairs;
forAll(treatPatchesWithPatch_, patchI)
{
const DynList<label>& otherPatches = treatPatchesWithPatch_[patchI];
forAll(otherPatches, patchJ)
{
if( patchI == otherPatches[patchJ] )
continue;
terminatedPairs.insert
(
std::make_pair
......@@ -75,48 +75,48 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
);
}
}
bool changed;
label nDecomposed(0);
boolList decomposeCell(mesh_.cells().size(), false);
do
{
changed = false;
const meshSurfaceEngine& mse = this->surfaceEngine();
const faceList::subList& bFaces = mse.boundaryFaces();
const labelList& faceOwner = mse.faceOwners();
const labelList& facePatches = mse.boundaryFacePatches();
const VRWGraph& faceEdges = mse.faceEdges();
const VRWGraph& edgeFaces = mse.edgeFaces();
const Map<label>& otherProcPatch = mse.otherEdgeFacePatch();
VRWGraph newBoundaryFaces;
labelLongList newBoundaryOwners;
labelLongList newBoundaryPatches;
forAll(bFaces, bfI)
{
const face& bf = bFaces[bfI];
const label fPatch = facePatches[bfI];
if( !usedPatches.found(fPatch) )
continue;
//- find patches of neighbour faces
labelList neiPatches(bf.size());
forAll(bf, eI)
{
const label beI = faceEdges(bfI, eI);
if( edgeFaces.sizeOfRow(beI) == 2 )
{
label neiFace = edgeFaces(beI, 0);
if( neiFace == bfI )
neiFace = edgeFaces(beI, 1);
neiPatches[eI] = facePatches[neiFace];
}
else if( edgeFaces.sizeOfRow(beI) == 1 )
......@@ -125,7 +125,7 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
neiPatches[eI] = otherProcPatch[beI];
}
}
//- find feature edges and check if the patches meeting there
//- shall be treated together.
bool storedFace(false);
......@@ -133,16 +133,16 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
{
if( neiPatches[eI] == fPatch )
continue;
std::pair<label, label> pp
(
Foam::min(fPatch, neiPatches[eI]),
Foam::max(fPatch, neiPatches[eI])
);
if( terminatedPairs.find(pp) == terminatedPairs.end() )
continue;
//- create a new face from this edge and the neighbouring edges
bool usePrev(false), useNext(false);
if( neiPatches[neiPatches.rcIndex(eI)] == fPatch )
......@@ -156,11 +156,11 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
Foam::min(fPatch, neiPatches[neiPatches.rcIndex(eI)]),
Foam::max(fPatch, neiPatches[neiPatches.rcIndex(eI)])
);
if( terminatedPairs.find(ppPrev) == terminatedPairs.end() )
usePrev = true;
}
if( neiPatches[neiPatches.fcIndex(eI)] == fPatch )
{
useNext = true;
......@@ -172,11 +172,11 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
Foam::min(fPatch, neiPatches[neiPatches.fcIndex(eI)]),
Foam::max(fPatch, neiPatches[neiPatches.fcIndex(eI)])
);
if( terminatedPairs.find(ppNext) == terminatedPairs.end() )
useNext = true;
}
DynList<edge> removeEdges;
if( useNext && usePrev )
{
......@@ -197,7 +197,7 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
removeEdges[0] = bf.faceEdge(neiPatches.rcIndex(eI));
removeEdges[1] = bf.faceEdge(eI);
}
const face cutFace = help::removeEdgesFromFace(bf, removeEdges);
if( cutFace.size() > 2 )
{
......@@ -212,19 +212,19 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
newBoundaryOwners.append(faceOwner[bfI]);
newBoundaryPatches.append(fPatch);
}
if( (cutFace.size() > 2) && (rFace.size() > 2) )
{
decomposeCell[faceOwner[bfI]] = true;
changed = true;
++nDecomposed;
}
storedFace = true;
break;
}
if( !storedFace )
{
newBoundaryFaces.appendList(bf);
......@@ -232,37 +232,43 @@ void boundaryLayers::checkTopologyOfBoundaryFaces(const labelList& patchLabels)
newBoundaryPatches.append(fPatch);
}
}
//- Finally, replace the boundary faces
reduce(changed, maxOp<bool>());
if( changed )
{
polyMeshGenModifier(mesh_).replaceBoundary
polyMeshGenModifier meshModifier(mesh_);
meshModifier.replaceBoundary
(
patchNames_,
newBoundaryFaces,
newBoundaryOwners,
newBoundaryPatches
);
PtrList<boundaryPatch>& boundaries =
meshModifier.boundariesAccess();
forAll(boundaries, patchI)
boundaries[patchI].patchType() = patchTypes_[patchI];
clearOut();
}
} while( changed );
//- decompose owner cells adjacent to the decomposed faces
reduce(nDecomposed, sumOp<label>());
if( nDecomposed != 0 )
{
FatalError << "Critical. Not tested" << exit(FatalError);
decomposeCells dc(mesh_);
dc.decomposeMesh(decomposeCell);
clearOut();
}
mesh_.write();
Info << "Finished checking topology" << endl;
}
......
......@@ -162,6 +162,10 @@ void boundaryLayers::createNewFacesAndCells(const boolList& treatPatches)
newBoundaryPatches
);
PtrList<boundaryPatch>& boundaries = meshModifier.boundariesAccess();
forAll(boundaries, patchI)
boundaries[patchI].patchType() = patchTypes_[patchI];
//- delete meshSurfaceEngine
this->clearOut();
......
......@@ -1221,8 +1221,12 @@ void extrudeLayer::createLayerCells()
void extrudeLayer::updateBoundary()
{
wordList patchNames(mesh_.boundaries().size());
wordList patchTypes(mesh_.boundaries().size());
forAll(patchNames, patchI)
{
patchNames[patchI] = mesh_.boundaries()[patchI].patchName();
patchTypes[patchI] = mesh_.boundaries()[patchI].patchType();
}
VRWGraph newBoundaryFaces;
labelLongList newBoundaryOwners;
......@@ -1327,14 +1331,19 @@ void extrudeLayer::updateBoundary()
}
}
polyMeshGenModifier(mesh_).reorderBoundaryFaces();
polyMeshGenModifier(mesh_).replaceBoundary
polyMeshGenModifier meshModifier(mesh_);
meshModifier.reorderBoundaryFaces();
meshModifier.replaceBoundary
(
patchNames,
newBoundaryFaces,
newBoundaryOwners,
newBoundaryPatches
);
PtrList<boundaryPatch>& boundaries = meshModifier.boundariesAccess();
forAll(boundaries, patchI)
boundaries[patchI].patchType() = patchTypes[patchI];
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......
......@@ -36,13 +36,17 @@ decomposeCells::decomposeCells(polyMeshGen& mesh)
:
mesh_(mesh),
patchNames_(mesh.boundaries().size()),
patchTypes_(mesh.boundaries().size()),
newBoundaryFaces_(),
newBoundaryPatches_(),
facesOfNewCells_()
{
const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
forAll(boundaries, patchI)
{
patchNames_[patchI] = boundaries[patchI].patchName();
patchTypes_[patchI] = boundaries[patchI].patchType();
}
}
//- Destructor
......
......@@ -28,7 +28,7 @@ Description
Decomposes selected cells into pyramids
SourceFiles
\*---------------------------------------------------------------------------*/
......@@ -54,18 +54,19 @@ class decomposeCells
//- new boundary faces
wordList patchNames_;
wordList patchTypes_;
VRWGraph newBoundaryFaces_;
labelLongList newBoundaryPatches_;
VRWGraphList facesOfNewCells_;
// Private member functions
//- check if the valid pyramids are generated from the split cells
//- this check splits faces which could
//- result in multiple inbetween faces
void checkFaceConnections(const boolList& decomposeCell);
//- create addressing needed to decompose the cell
void findAddressingForCell
(
......@@ -75,7 +76,7 @@ class decomposeCells
DynList<DynList<label, 8> >& faceEdges,
DynList<DynList<label, 2>, 64>& edgeFaces
) const;
//- find the apex of the pyramids
label findTopVertex
(
......@@ -84,15 +85,15 @@ class decomposeCells
const DynList<edge, 64>& edges,
const DynList<DynList<label, 2>, 64>& edgeFaces
);
void decomposeCellIntoPyramids(const label cellI);
void createPointsAndCellFaces(const boolList& decomposeCell);
void storeBoundaryFaces(const boolList& decomposeCell);
void removeDecomposedCells(const boolList& decomposeCell);
void addNewCells();
//- disallows bitwise construct
......
......@@ -249,6 +249,11 @@ void decomposeCells::addNewCells()
polyMeshGenModifier(mesh_).removeUnusedVertices();
polyMeshGenModifier(mesh_).clearAll();
PtrList<boundaryPatch>& boundaries =
polyMeshGenModifier(mesh_).boundariesAccess();
forAll(boundaries, patchI)
boundaries[patchI].patchType() = patchTypes_[patchI];
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
......
......@@ -85,6 +85,7 @@ correctEdgesBetweenPatches::correctEdgesBetweenPatches(polyMeshGen& mesh)
mesh_(mesh),
msePtr_(NULL),
patchNames_(mesh.boundaries().size()),
patchTypes_(mesh.boundaries().size()),
newBoundaryFaces_(),
newBoundaryOwners_(),
newBoundaryPatches_(),
......@@ -93,7 +94,10 @@ correctEdgesBetweenPatches::correctEdgesBetweenPatches(polyMeshGen& mesh)
{
const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
forAll(boundaries, patchI)
{
patchNames_[patchI] = boundaries[patchI].patchName();
patchTypes_[patchI] = boundaries[patchI].patchType();
}
decomposeProblematicFaces();
......
......@@ -64,6 +64,7 @@ class correctEdgesBetweenPatches
//- boundary data
wordList patchNames_;
wordList patchTypes_;
VRWGraph newBoundaryFaces_;
labelLongList newBoundaryOwners_;
labelLongList newBoundaryPatches_;
......
......@@ -2535,7 +2535,8 @@ const triSurf* edgeExtractor::surfaceWithPatches(const label bpI) const
void edgeExtractor::updateMeshPatches()
{
const triSurf& surface = meshOctree_.surface();
const label nPatches = surface.patches().size();
const geometricSurfacePatchList& surfPatches = surface.patches();
const label nPatches = surfPatches.size();
const meshSurfaceEngine& mse = this->surfaceEngine();
const faceList::subList& bFaces = mse.boundaryFaces();
......@@ -2559,13 +2560,20 @@ void edgeExtractor::updateMeshPatches()
}
//- replace the boundary with the new patches
polyMeshGenModifier(mesh_).replaceBoundary
polyMeshGenModifier meshModifier(mesh_);
meshModifier.replaceBoundary
(
patchNames,
newBoundaryFaces,
newBoundaryOwners,
newBoundaryPatches
);
//- set the new patch types
PtrList<boundaryPatch>& boundaries = meshModifier.boundariesAccess();
forAll(surfPatches, patchI)
boundaries[patchI].patchType() = surfPatches[patchI].geometricType();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
......
......@@ -132,13 +132,20 @@ void meshSurfaceEdgeExtractor2D::distributeBoundaryFaces()
}
//- replace the boundary
polyMeshGenModifier(mesh_).replaceBoundary
polyMeshGenModifier meshModifier(mesh_);
meshModifier.replaceBoundary
(
patchNames,
bndFaces,
bndFaceOwner,
bndFacePatch
);
//- set coorect patch types
PtrList<boundaryPatch>& modBnd = meshModifier.boundariesAccess();
forAll(surfPatches, patchI)
modBnd[patchI].patchType() = surfPatches[patchI].geometricType();
}
void meshSurfaceEdgeExtractor2D::remapBoundaryPoints()
......
......@@ -38,177 +38,177 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
{
# include "setRootCase.H"
# include "createTime.H"
fileName inFileName;
Info << "Reading mesh from file " << endl;
cin >> inFileName;
IFstream file(inFileName);
polyMeshGen pmg(runTime);
polyMeshGenModifier meshModifier(pmg);
label counter;
//- read the number of vertices
pointFieldPMG& points = meshModifier.pointsAccess();
file >> counter;
//- read points from file
points.setSize(counter);
forAll(points, pointI)
{
point p;
file >> p.x();
file >> p.y();
file >> p.z();
points[pointI] = p;
point p;
file >> p.x();
file >> p.y();
file >> p.z();
points[pointI] = p;
}
//- read the number of faces
file >> counter;
faceListPMG& faces = meshModifier.facesAccess();
//- read faces from file
faces.setSize(counter);
forAll(faces, faceI)
{
file >> counter;
face f;
f.setSize(counter);
forAll(f, pI)
file >> f[pI];
faces[faceI] = f.reverseFace();
face f;
f.setSize(counter);
forAll(f, pI)
file >> f[pI];
faces[faceI] = f.reverseFace();
}
//- read the number of cells
file >> counter;
//- read cells from file
cellListPMG& cells = meshModifier.cellsAccess();
cells.setSize(counter);
forAll(cells, cellI)
{
file >> counter;
cell& c = cells[cellI];
c.setSize(counter);
forAll(c, fI)
file >> c[fI];
file >> counter;