ENH: snappyHexMesh: block walk through other surfaces.

This commit is contained in:
mattijs
2021-02-22 19:06:40 +00:00
committed by Mattijs Janssens
parent 3f1f191034
commit a9f8bc079f
6 changed files with 99 additions and 69 deletions

View File

@ -2408,14 +2408,18 @@ void Foam::meshRefinement::growCellZone
List<wallPoints> allFaceInfo(mesh_.nFaces()); List<wallPoints> allFaceInfo(mesh_.nFaces());
FaceCellWave<wallPoints> wallDistCalc
const bitSet isBlockedFace(mesh_.nFaces());
wallPoints::trackData td(isBlockedFace);
FaceCellWave<wallPoints, wallPoints::trackData> wallDistCalc
( (
mesh_, mesh_,
changedFaces, changedFaces,
faceDist, faceDist,
allFaceInfo, allFaceInfo,
allCellInfo, allCellInfo,
0 // max iterations 0, // max iterations
td
); );
wallDistCalc.iterate(nGrowCellZones); wallDistCalc.iterate(nGrowCellZones);

View File

@ -514,8 +514,8 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave
} }
} }
// Clever limiting of the number of iterations (= max cells in the channel) // Clever limiting of the number of iterations (= max cells in the channel)
// since it has too many problematic issues, e.g. with volume refinement. // since it has too many problematic issues, e.g. with volume refinement
// Since the real check uses the proper distance anyway just disable. // and the real check uses the proper distance anyway just disable.
const label nIters = mesh_.globalData().nTotalCells(); const label nIters = mesh_.globalData().nTotalCells();
@ -613,11 +613,21 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave
DynamicList<FixedList<label, 3>> originSurface(2); DynamicList<FixedList<label, 3>> originSurface(2);
//DynamicList<point> originNormal(2); //DynamicList<point> originNormal(2);
//- To avoid walking through surfaces we mark all faces that have been
// intersected. We can either mark only those faces intersecting
// blockedSurfaces (i.e. with a 'blockLevel') or mark faces intersecting
// any (refinement) surface (this includes e.g. faceZones). This is
// much easier since that information is already cached
// (meshRefinement::intersectedFaces())
//bitSet isBlockedFace(mesh_.nFaces());
forAll(testFaces, i) forAll(testFaces, i)
{ {
if (hit1[i].hit()) if (hit1[i].hit())
{ {
const label facei = testFaces[i]; const label facei = testFaces[i];
//isBlockedFace.set(facei);
const point& fc = mesh_.faceCentres()[facei]; const point& fc = mesh_.faceCentres()[facei];
const labelList& fz1 = faceZones[surface1[i]]; const labelList& fz1 = faceZones[surface1[i]];
@ -656,6 +666,8 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave
); );
} }
// Collect all seed data. Currently walking does not look at
// surface direction - if so pass in surface normal as well
faceDist[n] = wallPoints faceDist[n] = wallPoints
( (
originLocation, // origin originLocation, // origin
@ -683,14 +695,21 @@ Foam::label Foam::meshRefinement::markProximityRefinementWave
List<wallPoints> allFaceInfo(mesh_.nFaces()); List<wallPoints> allFaceInfo(mesh_.nFaces());
List<wallPoints> allCellInfo(mesh_.nCells()); List<wallPoints> allCellInfo(mesh_.nCells());
FaceCellWave<wallPoints> wallDistCalc // Any refinement surface (even a faceZone) should stop the gap walking.
// This is exactly the information which is cached in the surfaceIndex_
// field.
const bitSet isBlockedFace(intersectedFaces());
wallPoints::trackData td(isBlockedFace);
FaceCellWave<wallPoints, wallPoints::trackData> wallDistCalc
( (
mesh_, mesh_,
changedFaces, changedFaces,
faceDist, faceDist,
allFaceInfo, allFaceInfo,
allCellInfo, allCellInfo,
0 // max iterations 0, // max iterations
td
); );
wallDistCalc.iterate(nIters); wallDistCalc.iterate(nIters);

View File

@ -42,6 +42,7 @@ SourceFiles
#include "tensor.H" #include "tensor.H"
#include "DynamicList.H" #include "DynamicList.H"
#include "labelList.H" #include "labelList.H"
#include "bitSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -61,6 +62,23 @@ Ostream& operator<<(Ostream&, const wallPoints&);
class wallPoints class wallPoints
{ {
public:
//- Class used to pass additional data in
class trackData
{
public:
//- Per face whether the face should not be walked through
const bitSet& isBlockedFace_;
trackData(const bitSet& isBlockedFace)
:
isBlockedFace_(isBlockedFace)
{}
};
protected: protected:
// Protected Data // Protected Data

View File

@ -241,10 +241,13 @@ inline bool Foam::wallPoints::updateFace
TrackingData& td TrackingData& td
) )
{ {
const point& fc = mesh.faceCentres()[thisFacei];
// From cell to its faces. // From cell to its faces.
bool hasChanged = false; bool hasChanged = false;
if (!td.isBlockedFace_[thisFacei])
{
const point& fc = mesh.faceCentres()[thisFacei];
forAll(neighbourInfo.surface_, i) forAll(neighbourInfo.surface_, i)
{ {
const FixedList<label, 3>& nbrSurface = neighbourInfo.surface_[i]; const FixedList<label, 3>& nbrSurface = neighbourInfo.surface_[i];
@ -267,6 +270,7 @@ inline bool Foam::wallPoints::updateFace
|| hasChanged; || hasChanged;
} }
} }
}
return hasChanged; return hasChanged;
} }
@ -283,16 +287,19 @@ inline bool Foam::wallPoints::updateFace
TrackingData& td TrackingData& td
) )
{ {
const point& fc = mesh.faceCentres()[thisFacei];
// From face to face (e.g. coupled faces) // From face to face (e.g. coupled faces)
bool hasChanged = false; bool hasChanged = false;
if (!td.isBlockedFace_[thisFacei])
{
const point& fc = mesh.faceCentres()[thisFacei];
forAll(neighbourInfo.surface_, i) forAll(neighbourInfo.surface_, i)
{ {
const FixedList<label, 3>& nbrSurface = neighbourInfo.surface_[i]; const FixedList<label, 3>& nbrSurface = neighbourInfo.surface_[i];
// Find in my surfaces // Find in my surfaces
label index = surface_.find(nbrSurface); const label index = surface_.find(nbrSurface);
if (index == -1) if (index == -1)
{ {
// Append // Append
@ -309,6 +316,7 @@ inline bool Foam::wallPoints::updateFace
|| hasChanged; || hasChanged;
} }
} }
}
return hasChanged; return hasChanged;
} }

View File

@ -1,21 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format binary;
class cellSet;
arch "LSB;label=32;scalar=64";
location "0/polyMesh/sets";
object cellsToRemove;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0()
// ************************************************************************* //

View File

@ -113,8 +113,10 @@ castellatedMeshControls
// surfaces // surfaces
//gapLevel (1 2 10); //gapLevel (1 2 10);
//MEJ: from cell level 2 onwards start checking for opposite // Block any gap (opposite surfaces or opposite disconnected region
// surfaces // of surface):
// - thinner than 2*blockcellsize where blockcellsize
// is the size of a cell at blockLevel
blockLevel 2; blockLevel 2;
} }
} }