diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/polyhedralRefinement/polyhedralRefinement.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/polyhedralRefinement/polyhedralRefinement.C index 1a51d34c9..e76861d64 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/polyhedralRefinement/polyhedralRefinement.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/polyhedralRefinement/polyhedralRefinement.C @@ -388,11 +388,9 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement return; } - // New point and cell levels. Insert original lists into dynamic list for - // easy insertion. Note: dynamic lists shall be resized with multiplier 2 on - // the first insertion using operator() for non existing element - dynamicLabelList newCellLevel(cellLevel_); - dynamicLabelList newPointLevel(pointLevel_); + // Reset refinementLevelIndicator field + refinementLevelIndicator_.clear(); + refinementLevelIndicator_.setSize(mesh_.nCells(), UNCHANGED); if (debug) { @@ -430,11 +428,6 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement true // Supports a cell ) ); - - // Add a level for the new point into the dynamic list. - // Note: operator() resizes the list if necessary and returns the - // reference to newly created element - newPointLevel(cellMidPoint[cellI]) = cellLevel_[cellI] + 1; } // Write out split cells as a cell set for debug @@ -560,10 +553,6 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement { if (edgeMidPoint[edgeI] > -1) { - // Edge marked to be split: replace edgeMidPoint with actual - // point label - const edge& e = meshEdges[edgeI]; - edgeMidPoint[edgeI] = ref.setAction ( polyAddPoint @@ -574,17 +563,6 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement true // Supports a cell ) ); - - // Update new point level: take maximum of the two points in the - // original edge and increment. Note: operator() resizes the - // list if necessary - newPointLevel(edgeMidPoint[edgeI]) = - max - ( - pointLevel_[e[0]], - pointLevel_[e[1]] - ) - + 1; } } } // End memory management for syncing/adding edge points @@ -793,11 +771,6 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement true // Supports a cell ) ); - - // The point level of the added point will be one higher than - // the faceAnchorLevel (corner point). Note: operator() resizes - // the list if necessary - newPointLevel(faceMidPoint[faceI]) = faceAnchorLevel[faceI] + 1; } } } // End memory management for syncing boundary data and adding face mids @@ -938,6 +911,12 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement // number of anchor points in a cell labelListList cellAddedCells(mesh_.nCells()); + // Count number of new cells needed to update refinement history + label nNewCells = 0; + + // Get cell zone mesh + const cellZoneMesh& cellZones = mesh_.cellZones(); + forAll(cellAnchorPoints, cellI) { // Check whether this is a split cell @@ -950,11 +929,12 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement labelList& cAdded = cellAddedCells[cellI]; cAdded.setSize(cAnchors.size()); - // Original cell has index 0. Nothing to do except add the index + // Original cell has index 0 cAdded[0] = cellI; - // Update cell level - newCellLevel[cellI] = cellLevel_[cellI] + 1; + // Update refinement level indicator field to 1 since this original + // cell will be refined + refinementLevelIndicator_[cellI] = REFINED; // Add other cells for (label i = 1; i < cAdded.size(); ++i) @@ -963,17 +943,15 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement ( polyAddCell ( - -1, // Master point - -1, // Master edge - -1, // Master face - cellI, // Master cell - mesh_.cellZones().whichZone(cellI) // Zone for cell + -1, // Master point + -1, // Master edge + -1, // Master face + cellI, // Master cell + cellZones.whichZone(cellI) // Zone for cell ) ); - // Update level for this cell. Note: operator() resizes the list - // if necessary - newCellLevel(cAdded[i]) = cellLevel_[cellI] + 1; + ++nNewCells; } } } @@ -1120,12 +1098,6 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement newFace.transfer(faceVerts); faceVerts.clear(); - if (debug) - { - Pout<< "Split face: " << faceI << ", verts: " << f - << ", into quad: " << newFace << endl; - } - // Set new owner/neighbour indices based on split cells label own, nei; setNewFaceNeighbours @@ -1151,6 +1123,12 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement const label oldOwn = meshFaceOwner[faceI]; const label oldNei = meshFaceNeighbour[faceI]; + Pout<< "Split internal face: " << faceI + << ", verts: " << f + << ", into quad: " << newFace << nl + << "owner: " << oldOwn + << ", neighbour: " << oldNei << endl; + checkInternalOrientation ( ref, @@ -1165,6 +1143,11 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement { const label oldOwn = meshFaceOwner[faceI]; + Pout<< "Split boundary face: " << faceI + << ", verts: " << f + << ", into quad: " << newFace << nl + << "owner: " << oldOwn << endl; + checkBoundaryOrientation ( ref, @@ -1443,16 +1426,6 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement } } - // Update cell/point levels - pointLevel_.transfer(newPointLevel.shrink()); - newPointLevel.clear(); - cellLevel_.transfer(newCellLevel.shrink()); - newCellLevel.clear(); - - // Mark files as changed - setInstance(mesh_.facesInstance()); - - // Update polyehdral refinement history (live split cells tree) if (history_.active()) { @@ -1464,7 +1437,7 @@ void Foam::polyhedralRefinement::setPolyhedralRefinement } // Extend refinement history for new cells - history_.resize(cellLevel_.size()); + history_.resize(mesh_.nCells() + nNewCells); forAll(cellAddedCells, cellI) { @@ -1497,6 +1470,9 @@ void Foam::polyhedralRefinement::setPolyhedralUnrefinement << abort(FatalError); } + // Note: no need to reset refinementLevelIndicator_ list since the + // unrefinement set-up always needs to happen after refinement set-up + // Get point cells necessary for debug and face removal const labelListList& meshPointCells = mesh_.pointCells(); @@ -1633,18 +1609,15 @@ void Foam::polyhedralRefinement::setPolyhedralUnrefinement // Get master cell index by searching for minimum of cell labels const label masterCellI = min(pCells); - // Loop through cells and decrement their cell level + // Loop through cells and mark that they will be unrefined (-1) forAll(pCells, j) { - --cellLevel_[pCells[j]]; + refinementLevelIndicator_[pCells[j]] = UNREFINED; } // Combine cells in the history history_.combineCells(masterCellI, pCells); } - - // Mark files as changed - setInstance(mesh_.facesInstance()); } @@ -3334,6 +3307,7 @@ Foam::polyhedralRefinement::polyhedralRefinement ), labelList(mesh_.nPoints(), 0) ), + refinementLevelIndicator_(mesh_.nCells(), UNCHANGED), level0EdgeLength_(), // Initialised in constructor body history_ ( @@ -3556,8 +3530,10 @@ void Foam::polyhedralRefinement::setCellsToRefine // point consistent (4:1 consistency) if necessary // Counter for additional cells to refine due to consistency in each - // iteration + // iteration and number of iterations label nAddCells = 0; + label nIters = 0; + label nTotalAddCells = 0; do { @@ -3578,15 +3554,17 @@ void Foam::polyhedralRefinement::setCellsToRefine // Global reduction reduce(nAddCells, sumOp