From 900c7ae70d743b935a5468a561e5761b7d948e85 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 1 Jun 2010 15:20:44 +0100 Subject: [PATCH] BUG: Preserve face zone orientation (fvMeshSubset, removeCels, addPatchCellLayer) --- .../polyTopoChange/addPatchCellLayer.C | 34 +++++++++---- .../polyTopoChange/polyTopoChange/removeCells.C | 6 ++- .../fvMesh/fvMeshSubset/fvMeshSubset.C | 58 +++++++++++++++------- 3 files changed, 68 insertions(+), 30 deletions(-) diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index e59c85e5..e6cfc8be 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -348,7 +348,10 @@ Foam::label Foam::addPatchCellLayer::addSideFace // Get my mesh face and its zone. label meshFaceI = pp.addressing()[ownFaceI]; - label zoneI = mesh_.faceZones().whichZone(meshFaceI); + // Zone info comes from any side patch face. Otherwise -1 since we + // don't know what to put it in - inherit from the extruded faces? + label zoneI = -1; //mesh_.faceZones().whichZone(meshFaceI); + bool flip = false; label addedFaceI = -1; @@ -375,6 +378,12 @@ Foam::label Foam::addPatchCellLayer::addSideFace ) { otherPatchID = patches.whichPatch(faceI); + zoneI = mesh_.faceZones().whichZone(faceI); + if (zoneI != -1) + { + label index = mesh_.faceZones()[zoneI].whichFace(faceI); + flip = mesh_.faceZones()[zoneI].flipMap()[index]; + } break; } } @@ -421,7 +430,7 @@ Foam::label Foam::addPatchCellLayer::addSideFace false, // flux flip otherPatchID, // patch for face zoneI, // zone for face - false // face zone flip + flip // face zone flip ) ); } @@ -487,7 +496,7 @@ Foam::label Foam::addPatchCellLayer::addSideFace false, // flux flip -1, // patch for face zoneI, // zone for face - false // face zone flip + flip // face zone flip ) ); @@ -967,8 +976,6 @@ void Foam::addPatchCellLayer::setRefinement layerFaces_[patchFaceI].setSize(addedCells[patchFaceI].size() + 1); layerFaces_[patchFaceI][0] = meshFaceI; - label zoneI = mesh_.faceZones().whichZone(meshFaceI); - // Get duplicated vertices on the patch face. const face& f = pp.localFaces()[patchFaceI]; @@ -997,12 +1004,21 @@ void Foam::addPatchCellLayer::setRefinement // Get new neighbour label nei; label patchI; + label zoneI = -1; + bool flip = false; + if (i == addedCells[patchFaceI].size()-1) { // Top layer so is patch face. nei = -1; patchI = patchID[patchFaceI]; + zoneI = mesh_.faceZones().whichZone(meshFaceI); + if (zoneI != -1) + { + const faceZone& fz = mesh_.faceZones()[zoneI]; + flip = fz.flipMap()[fz.whichFace(meshFaceI)]; + } } else { @@ -1025,7 +1041,7 @@ void Foam::addPatchCellLayer::setRefinement false, // flux flip patchI, // patch for face zoneI, // zone for face - false // face zone flip + flip // face zone flip ) ); //Pout<< "Added inbetween face " << newFace @@ -1046,8 +1062,6 @@ void Foam::addPatchCellLayer::setRefinement { label meshFaceI = pp.addressing()[patchFaceI]; - label zoneI = mesh_.faceZones().whichZone(meshFaceI); - meshMod.setAction ( polyModifyFace @@ -1058,8 +1072,8 @@ void Foam::addPatchCellLayer::setRefinement addedCells[patchFaceI][0], // neighbour false, // face flip -1, // patch for face - false, // remove from zone - zoneI, // zone for face + true, //false, // remove from zone + -1, //zoneI, // zone for face false // face flip in zone ) ); diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C index d1ecbed0..cc4e4031 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C @@ -324,7 +324,9 @@ void Foam::removeCells::setRefinement if (zoneID >= 0) { const faceZone& fZone = faceZones[zoneID]; - zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)]; + // Note: we reverse the owner/neighbour of the face + // so should also select the other side of the zone + zoneFlip = !fZone.flipMap()[fZone.whichFace(faceI)]; } //Pout<< "Putting exposed internal face " << faceI @@ -339,7 +341,7 @@ void Foam::removeCells::setRefinement faceI, // label of face being modified nei, // owner -1, // neighbour - false, // face flip + true, // face flip newPatchID[faceI], // patch for face false, // remove from zone zoneID, // zone for face diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C index 74581231..261285c6 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C @@ -285,28 +285,50 @@ void Foam::fvMeshSubset::subsetZones() { const faceZone& fz = faceZones[i]; - // Create list of mesh faces part of the new zone - labelList subAddressing - ( - subset - ( - baseMesh().nFaces(), - fz, - faceMap() - ) - ); - - // Flipmap for all mesh faces - boolList fullFlipStatus(baseMesh().nFaces(), false); + // Expand faceZone to full mesh + // +1 : part of faceZone, flipped + // -1 : ,, , unflipped + // 0 : not part of faceZone + labelList zone(baseMesh().nFaces(), 0); forAll(fz, j) { - fullFlipStatus[fz[j]] = fz.flipMap()[j]; + if (fz.flipMap()[j]) + { + zone[fz[j]] = 1; + } + else + { + zone[fz[j]] = -1; + } + } + + // Select faces + label nSub = 0; + forAll(faceMap(), j) + { + if (zone[faceMap()[j]] != 0) + { + nSub++; + } } - // Extract sub part - boolList subFlipStatus(subAddressing.size(), false); - forAll(subAddressing, j) + labelList subAddressing(nSub); + boolList subFlipStatus(nSub); + nSub = 0; + forAll(faceMap(), subFaceI) { - subFlipStatus[j] = fullFlipStatus[faceMap()[subAddressing[j]]]; + label meshFaceI = faceMap()[subFaceI]; + if (zone[meshFaceI] != 0) + { + subAddressing[nSub] = subFaceI; + label subOwner = subMesh().faceOwner()[subFaceI]; + label baseOwner = baseMesh().faceOwner()[meshFaceI]; + // If subowner is the same cell as the base keep the flip status + bool sameOwner = (cellMap()[subOwner] == baseOwner); + bool flip = (zone[meshFaceI] == 1); + subFlipStatus[nSub] = (sameOwner == flip); + + nSub++; + } } fZonePtrs[i] = new faceZone -- 2.11.4.GIT