From 7832d77bf26ea120343ad17e71b9e5fcd8fa1875 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Mon, 5 May 2014 20:00:32 +0100 Subject: [PATCH] Stitching sliding interfaces around corners. Zeljko Tukovic --- .../mesh/manipulation/stitchMesh/stitchMesh.C | 43 ++++++++++++++++++- .../enrichedPatch/enrichedPatchCutFaces.C | 23 +++++----- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index a7a7d227d..0b88dccff 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -64,7 +64,6 @@ Description #include "IOobjectList.H" #include "ReadFields.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Checks whether patch present @@ -101,7 +100,7 @@ int main(int argc, char *argv[]) Foam::argList::validOptions.insert("partial", ""); Foam::argList::validOptions.insert("perfect", ""); - + Foam::argList::validOptions.insert("clearUnusedFaces", ""); Foam::argList::validOptions.insert("overwrite", ""); # include "setRootCase.H" @@ -116,6 +115,7 @@ int main(int argc, char *argv[]) bool partialCover = args.optionFound("partial"); bool perfectCover = args.optionFound("perfect"); + bool clearUnusedFaces = args.optionFound("clearUnusedFaces"); bool overwrite = args.optionFound("overwrite"); if (partialCover && perfectCover) @@ -364,6 +364,45 @@ int main(int argc, char *argv[]) mesh.movePoints(morphMap->preMotionPoints()); + if (clearUnusedFaces) + { + // Clear unused points and faces by manually resetting the list" + Info << "Clear unused points and faces" << nl << endl; + + pointField& p = const_cast(mesh.allPoints()); + p.setSize(mesh.nPoints()); + + faceList& f = const_cast(mesh.allFaces()); + f.setSize(mesh.nFaces()); + + Xfer pXfer(p); + Xfer fXfer(f); + Xfer ownXfer(mesh.faceOwner()); + Xfer neiXfer(mesh.faceNeighbour()); + + label nPatches = mesh.boundaryMesh().size(); + labelList patchSizes(nPatches, 0); + labelList patchStarts(nPatches, -1); + forAll(patchSizes, patchI) + { + patchSizes[patchI] = mesh.boundaryMesh()[patchI].size(); + patchStarts[patchI] = mesh.boundaryMesh()[patchI].start(); + } + + mesh.removeZones(); + + mesh.resetPrimitives + ( + pXfer, + fXfer, + ownXfer, + neiXfer, + patchSizes, + patchStarts + ); + } + + // Write mesh if (overwrite) { diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C index f21739744..76c1951ec 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C @@ -238,18 +238,21 @@ void Foam::enrichedPatch::calcCutFaces() const (magNewDir - magCorrNewDir)/magNewDir; // Pout << " corrected: " << corrNewDir << " mag: " << magCorrNewDir << " out of plane: " << outOfPlane << flush; + // Bug fix for cutting around corners + // ZT, 5 May 2014 if (magCorrNewDir < SMALL) { - FatalErrorIn - ( - "void enrichedPatch::" - "calcCutFaces() const" - ) << "Zero length edge detected. Probable " - << "projection error: slave patch probably " - << "does not project onto master. " - << "Please switch on " - << "enriched patch debug for more info" - << abort(FatalError); + continue; +// FatalErrorIn +// ( +// "void enrichedPatch::" +// "calcCutFaces() const" +// ) << "Zero length edge detected. Probable " +// << "projection error: slave patch probably " +// << "does not project onto master. " +// << "Please switch on " +// << "enriched patch debug for more info" +// << abort(FatalError); } corrNewDir /= magCorrNewDir;