Commit 37b33d08 authored by andy's avatar andy
Browse files

ENH: snappy - do not merge patch faces on either side of nelwy created baffles

parent 36fa660f
......@@ -2470,12 +2470,15 @@ void Foam::autoLayerDriver::mergePatchFacesUndo
<< " (0=straight, 180=fully concave)" << nl
<< endl;
const fvMesh& mesh = meshRefiner_.mesh();
label nChanged = meshRefiner_.mergePatchFacesUndo
(
minCos,
concaveCos,
meshRefiner_.meshedPatches(),
motionDict
motionDict,
labelList(mesh.nFaces() -1)
);
nChanged += meshRefiner_.mergeEdgesUndo(minCos, motionDict);
......
......@@ -1079,12 +1079,15 @@ void Foam::autoRefineDriver::mergePatchFaces
<< "----------------------------" << nl
<< endl;
const fvMesh& mesh = meshRefiner_.mesh();
meshRefiner_.mergePatchFacesUndo
(
Foam::cos(degToRad(45.0)),
Foam::cos(degToRad(45.0)),
meshRefiner_.meshedPatches(),
motionDict
motionDict,
labelList(mesh.nFaces(), -1)
);
if (debug)
......
......@@ -1348,7 +1348,8 @@ bool Foam::autoSnapDriver::scaleMesh
Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::repatchToSurface
(
const snapParameters& snapParams,
const labelList& adaptPatchIDs
const labelList& adaptPatchIDs,
const labelList& preserveFaces
)
{
const fvMesh& mesh = meshRefiner_.mesh();
......@@ -1375,7 +1376,16 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::repatchToSurface
// Faces that do not move
PackedBoolList isZonedFace(mesh.nFaces());
{
// 1. All faces on zoned surfaces
// 1. Preserve faces in preserveFaces list
forAll(preserveFaces, faceI)
{
if (preserveFaces[faceI] != -1)
{
isZonedFace.set(faceI, 1);
}
}
// 2. All faces on zoned surfaces
const wordList& faceZoneNames = surfaces.faceZoneNames();
const faceZoneMesh& fZones = mesh.faceZones();
......@@ -1531,6 +1541,15 @@ void Foam::autoSnapDriver::doSnap
baffles
);
// Keep copy of baffles
labelList origBaffles(mesh.nFaces(), -1);
forAll(baffles, i)
{
const labelPair& baffle = baffles[i];
origBaffles[baffle.first()] = baffle.second();
origBaffles[baffle.second()] = baffle.first();
}
// Selectively 'forget' about the baffles, i.e. not check across them
// or merge across them.
......@@ -1618,6 +1637,19 @@ void Foam::autoSnapDriver::doSnap
);
meshRefinement::updateList(mapPtr().faceMap(), -1, filterFace);
const labelList& reverseFaceMap = mapPtr().reverseFaceMap();
origBaffles.setSize(mesh.nFaces());
origBaffles = -1;
forAll(baffles, i)
{
labelPair& baffle = baffles[i];
baffle.first() = reverseFaceMap[baffle.first()];
baffle.second() = reverseFaceMap[baffle.second()];
origBaffles[baffle.first()] = baffle.second();
origBaffles[baffle.second()] = baffle.first();
}
if (debug&meshRefinement::MESH)
{
const_cast<Time&>(mesh.time())++;
......@@ -1834,10 +1866,23 @@ void Foam::autoSnapDriver::doSnap
}
// Merge any introduced baffles.
mergeZoneBaffles(baffles);
{
autoPtr<mapPolyMesh> mapPtr = mergeZoneBaffles(baffles);
if (mapPtr.valid())
{
forAll(origBaffles, faceI)
{
if (origBaffles[faceI] != -1)
{
origBaffles[faceI] = mapPtr->reverseFaceMap()[faceI];
}
}
}
}
// Repatch faces according to nearest.
repatchToSurface(snapParams, adaptPatchIDs);
repatchToSurface(snapParams, adaptPatchIDs, origBaffles);
// Repatching might have caused faces to be on same patch and hence
// mergeable so try again to merge coplanar faces
......@@ -1846,7 +1891,8 @@ void Foam::autoSnapDriver::doSnap
featureCos, // minCos
featureCos, // concaveCos
meshRefiner_.meshedPatches(),
motionDict
motionDict,
origBaffles
);
nChanged += meshRefiner_.mergeEdgesUndo
......@@ -1855,7 +1901,7 @@ void Foam::autoSnapDriver::doSnap
motionDict
);
if (nChanged > 0 && debug&meshRefinement::MESH)
if (nChanged > 0 && debug & meshRefinement::MESH)
{
const_cast<Time&>(mesh.time())++;
Info<< "Writing patchFace merged mesh to time "
......
......@@ -474,7 +474,8 @@ public:
autoPtr<mapPolyMesh> repatchToSurface
(
const snapParameters& snapParams,
const labelList& adaptPatchIDs
const labelList& adaptPatchIDs,
const labelList& preserveFaces
);
void doSnap
......
......@@ -920,7 +920,8 @@ public:
const scalar minCos,
const scalar concaveCos,
const labelList& patchIDs,
const dictionary& motionDict
const dictionary& motionDict,
const labelList& preserveFaces
);
autoPtr<mapPolyMesh> doRemovePoints
......
......@@ -249,7 +249,8 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
const scalar minCos,
const scalar concaveCos,
const labelList& patchIDs,
const dictionary& motionDict
const dictionary& motionDict,
const labelList& preserveFaces
)
{
// Patch face merging engine
......@@ -280,7 +281,7 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
// Get all sets of faces that can be merged. Since only faces on the same
// patch get merged there is no risk of e.g. patchID faces getting merged
// with original patches (or even processor patches). There is a risk
// though of original patchfaces getting merged if they make a small
// though of original patch faces getting merged if they make a small
// angle. Would be pretty weird starting mesh though.
labelListList allFaceSets
(
......@@ -292,6 +293,27 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
)
);
label compactI = 0;
forAll(allFaceSets, i)
{
bool keep = true;
const labelList& set = allFaceSets[i];
forAll(set, j)
{
if (preserveFaces[set[j]] != -1)
{
keep = false;
break;
}
}
if (keep && (compactI != i))
{
allFaceSets[compactI++] = set;
}
}
allFaceSets.setSize(compactI);
label nFaceSets = returnReduce(allFaceSets.size(), sumOp<label>());
Info<< "Merging " << nFaceSets << " sets of faces." << nl << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment