mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: autoHexMeshDriver: parallel consistent behaviour
This commit is contained in:
@ -1328,7 +1328,7 @@ void Foam::autoLayerDriver::calculateLayerThickness
|
|||||||
// Synchronize displacement among coupled patches.
|
// Synchronize displacement among coupled patches.
|
||||||
void Foam::autoLayerDriver::syncPatchDisplacement
|
void Foam::autoLayerDriver::syncPatchDisplacement
|
||||||
(
|
(
|
||||||
const motionSmoother& meshMover,
|
const indirectPrimitivePatch& pp,
|
||||||
const scalarField& minThickness,
|
const scalarField& minThickness,
|
||||||
pointField& patchDisp,
|
pointField& patchDisp,
|
||||||
labelList& patchNLayers,
|
labelList& patchNLayers,
|
||||||
@ -1336,7 +1336,7 @@ void Foam::autoLayerDriver::syncPatchDisplacement
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const fvMesh& mesh = meshRefiner_.mesh();
|
const fvMesh& mesh = meshRefiner_.mesh();
|
||||||
const labelList& meshPoints = meshMover.patch().meshPoints();
|
const labelList& meshPoints = pp.meshPoints();
|
||||||
|
|
||||||
label nChangedTotal = 0;
|
label nChangedTotal = 0;
|
||||||
|
|
||||||
@ -1578,7 +1578,7 @@ void Foam::autoLayerDriver::getPatchDisplacement
|
|||||||
// Make sure displacement is equal on both sides of coupled patches.
|
// Make sure displacement is equal on both sides of coupled patches.
|
||||||
syncPatchDisplacement
|
syncPatchDisplacement
|
||||||
(
|
(
|
||||||
meshMover,
|
pp,
|
||||||
minThickness,
|
minThickness,
|
||||||
patchDisp,
|
patchDisp,
|
||||||
patchNLayers,
|
patchNLayers,
|
||||||
@ -1776,7 +1776,7 @@ Foam::label Foam::autoLayerDriver::truncateDisplacement
|
|||||||
{
|
{
|
||||||
syncPatchDisplacement
|
syncPatchDisplacement
|
||||||
(
|
(
|
||||||
meshMover,
|
pp,
|
||||||
minThickness,
|
minThickness,
|
||||||
patchDisp,
|
patchDisp,
|
||||||
patchNLayers,
|
patchNLayers,
|
||||||
@ -2865,7 +2865,7 @@ void Foam::autoLayerDriver::addLayers
|
|||||||
// Make sure displacement is equal on both sides of coupled patches.
|
// Make sure displacement is equal on both sides of coupled patches.
|
||||||
syncPatchDisplacement
|
syncPatchDisplacement
|
||||||
(
|
(
|
||||||
meshMover,
|
pp,
|
||||||
minThickness,
|
minThickness,
|
||||||
patchDisp,
|
patchDisp,
|
||||||
patchNLayers,
|
patchNLayers,
|
||||||
|
|||||||
@ -257,7 +257,7 @@ class autoLayerDriver
|
|||||||
//- Synchronize displacement among coupled patches.
|
//- Synchronize displacement among coupled patches.
|
||||||
void syncPatchDisplacement
|
void syncPatchDisplacement
|
||||||
(
|
(
|
||||||
const motionSmoother& meshMover,
|
const indirectPrimitivePatch& pp,
|
||||||
const scalarField& minThickness,
|
const scalarField& minThickness,
|
||||||
pointField& patchDisp,
|
pointField& patchDisp,
|
||||||
labelList& patchNLayers,
|
labelList& patchNLayers,
|
||||||
@ -443,8 +443,11 @@ class autoLayerDriver
|
|||||||
// large feature angle
|
// large feature angle
|
||||||
void handleFeatureAngleLayerTerminations
|
void handleFeatureAngleLayerTerminations
|
||||||
(
|
(
|
||||||
const indirectPrimitivePatch& pp,
|
|
||||||
const scalar minCos,
|
const scalar minCos,
|
||||||
|
const PackedBoolList& isMasterPoint,
|
||||||
|
const indirectPrimitivePatch& pp,
|
||||||
|
const labelList& meshEdges,
|
||||||
|
|
||||||
List<extrudeMode>& extrudeStatus,
|
List<extrudeMode>& extrudeStatus,
|
||||||
pointField& patchDisp,
|
pointField& patchDisp,
|
||||||
labelList& patchNLayers,
|
labelList& patchNLayers,
|
||||||
@ -456,10 +459,13 @@ class autoLayerDriver
|
|||||||
// in the layer mesh and stop any layer growth at these points.
|
// in the layer mesh and stop any layer growth at these points.
|
||||||
void findIsolatedRegions
|
void findIsolatedRegions
|
||||||
(
|
(
|
||||||
const indirectPrimitivePatch& pp,
|
|
||||||
const PackedBoolList& isMasterEdge,
|
|
||||||
const labelList& meshEdges,
|
|
||||||
const scalar minCosLayerTermination,
|
const scalar minCosLayerTermination,
|
||||||
|
const PackedBoolList& isMasterPoint,
|
||||||
|
const PackedBoolList& isMasterEdge,
|
||||||
|
const indirectPrimitivePatch& pp,
|
||||||
|
const labelList& meshEdges,
|
||||||
|
const scalarField& minThickness,
|
||||||
|
|
||||||
List<extrudeMode>& extrudeStatus,
|
List<extrudeMode>& extrudeStatus,
|
||||||
pointField& patchDisp,
|
pointField& patchDisp,
|
||||||
labelList& patchNLayers
|
labelList& patchNLayers
|
||||||
|
|||||||
@ -137,7 +137,7 @@ void Foam::autoLayerDriver::smoothField
|
|||||||
isMasterEdge,
|
isMasterEdge,
|
||||||
meshEdges,
|
meshEdges,
|
||||||
meshPoints,
|
meshPoints,
|
||||||
pp.edges(),
|
edges,
|
||||||
invSumWeight,
|
invSumWeight,
|
||||||
field,
|
field,
|
||||||
average
|
average
|
||||||
@ -305,7 +305,7 @@ void Foam::autoLayerDriver::smoothPatchNormals
|
|||||||
isMasterEdge,
|
isMasterEdge,
|
||||||
meshEdges,
|
meshEdges,
|
||||||
meshPoints,
|
meshPoints,
|
||||||
pp.edges(),
|
edges,
|
||||||
invSumWeight,
|
invSumWeight,
|
||||||
normals,
|
normals,
|
||||||
average
|
average
|
||||||
@ -321,7 +321,6 @@ void Foam::autoLayerDriver::smoothPatchNormals
|
|||||||
meshPoints,
|
meshPoints,
|
||||||
mag(normals-average)()
|
mag(normals-average)()
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Iteration " << iter << " residual " << resid << endl;
|
Info<< " Iteration " << iter << " residual " << resid << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,8 +383,6 @@ void Foam::autoLayerDriver::smoothNormals
|
|||||||
invSumWeight
|
invSumWeight
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "shrinkMeshDistance : Smoothing normals in interior ..." << endl;
|
|
||||||
|
|
||||||
for (label iter = 0; iter < nSmoothDisp; iter++)
|
for (label iter = 0; iter < nSmoothDisp; iter++)
|
||||||
{
|
{
|
||||||
vectorField average(mesh.nPoints());
|
vectorField average(mesh.nPoints());
|
||||||
@ -410,7 +407,6 @@ void Foam::autoLayerDriver::smoothNormals
|
|||||||
isMasterPoint,
|
isMasterPoint,
|
||||||
mag(normals-average)()
|
mag(normals-average)()
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Iteration " << iter << " residual " << resid << endl;
|
Info<< " Iteration " << iter << " residual " << resid << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,14 +491,18 @@ bool Foam::autoLayerDriver::isMaxEdge
|
|||||||
// large feature angle
|
// large feature angle
|
||||||
void Foam::autoLayerDriver::handleFeatureAngleLayerTerminations
|
void Foam::autoLayerDriver::handleFeatureAngleLayerTerminations
|
||||||
(
|
(
|
||||||
const indirectPrimitivePatch& pp,
|
|
||||||
const scalar minCos,
|
const scalar minCos,
|
||||||
|
const PackedBoolList& isMasterPoint,
|
||||||
|
const indirectPrimitivePatch& pp,
|
||||||
|
const labelList& meshEdges,
|
||||||
List<extrudeMode>& extrudeStatus,
|
List<extrudeMode>& extrudeStatus,
|
||||||
pointField& patchDisp,
|
pointField& patchDisp,
|
||||||
labelList& patchNLayers,
|
labelList& patchNLayers,
|
||||||
label& nPointCounter
|
label& nPointCounter
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
const fvMesh& mesh = meshRefiner_.mesh();
|
||||||
|
|
||||||
// Mark faces that have all points extruded
|
// Mark faces that have all points extruded
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@ -523,15 +523,60 @@ void Foam::autoLayerDriver::handleFeatureAngleLayerTerminations
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
label nOldPointCounter = nPointCounter;
|
||||||
|
|
||||||
// Detect situation where two featureedge-neighbouring faces are partly or
|
// Detect situation where two featureedge-neighbouring faces are partly or
|
||||||
// not extruded and the edge itself is extruded. In this case unmark the
|
// not extruded and the edge itself is extruded. In this case unmark the
|
||||||
// edge for extrusion.
|
// edge for extrusion.
|
||||||
|
|
||||||
forAll(pp.edgeFaces(), edgeI)
|
|
||||||
{
|
|
||||||
const labelList& eFaces = pp.edgeFaces()[edgeI];
|
|
||||||
|
|
||||||
if (eFaces.size() == 2)
|
List<List<point> > edgeFaceNormals(pp.nEdges());
|
||||||
|
List<List<bool> > edgeFaceExtrude(pp.nEdges());
|
||||||
|
|
||||||
|
const labelListList& edgeFaces = pp.edgeFaces();
|
||||||
|
const vectorField& faceNormals = pp.faceNormals();
|
||||||
|
const labelList& meshPoints = pp.meshPoints();
|
||||||
|
|
||||||
|
forAll(edgeFaces, edgeI)
|
||||||
|
{
|
||||||
|
const labelList& eFaces = edgeFaces[edgeI];
|
||||||
|
|
||||||
|
edgeFaceNormals[edgeI].setSize(eFaces.size());
|
||||||
|
edgeFaceExtrude[edgeI].setSize(eFaces.size());
|
||||||
|
forAll(eFaces, i)
|
||||||
|
{
|
||||||
|
label faceI = eFaces[i];
|
||||||
|
edgeFaceNormals[edgeI][i] = faceNormals[faceI];
|
||||||
|
edgeFaceExtrude[edgeI][i] = extrudedFaces[faceI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
syncTools::syncEdgeList
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
meshEdges,
|
||||||
|
edgeFaceNormals,
|
||||||
|
globalMeshData::ListPlusEqOp<List<point> >(), // combine operator
|
||||||
|
List<point>() // null value
|
||||||
|
);
|
||||||
|
|
||||||
|
syncTools::syncEdgeList
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
meshEdges,
|
||||||
|
edgeFaceExtrude,
|
||||||
|
globalMeshData::ListPlusEqOp<List<bool> >(), // combine operator
|
||||||
|
List<bool>() // null value
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
forAll(edgeFaceNormals, edgeI)
|
||||||
|
{
|
||||||
|
const List<point>& eFaceNormals = edgeFaceNormals[edgeI];
|
||||||
|
const List<bool>& eFaceExtrude = edgeFaceExtrude[edgeI];
|
||||||
|
|
||||||
|
if (eFaceNormals.size() == 2)
|
||||||
{
|
{
|
||||||
const edge& e = pp.edges()[edgeI];
|
const edge& e = pp.edges()[edgeI];
|
||||||
label v0 = e[0];
|
label v0 = e[0];
|
||||||
@ -543,10 +588,10 @@ void Foam::autoLayerDriver::handleFeatureAngleLayerTerminations
|
|||||||
|| extrudeStatus[v1] != NOEXTRUDE
|
|| extrudeStatus[v1] != NOEXTRUDE
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!extrudedFaces[eFaces[0]] || !extrudedFaces[eFaces[1]])
|
if (!eFaceExtrude[0] || !eFaceExtrude[1])
|
||||||
{
|
{
|
||||||
const vector& n0 = pp.faceNormals()[eFaces[0]];
|
const vector& n0 = eFaceNormals[0];
|
||||||
const vector& n1 = pp.faceNormals()[eFaces[1]];
|
const vector& n1 = eFaceNormals[1];
|
||||||
|
|
||||||
if ((n0 & n1) < minCos)
|
if ((n0 & n1) < minCos)
|
||||||
{
|
{
|
||||||
@ -561,7 +606,10 @@ void Foam::autoLayerDriver::handleFeatureAngleLayerTerminations
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nPointCounter++;
|
if (isMasterPoint[meshPoints[v0]])
|
||||||
|
{
|
||||||
|
nPointCounter++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -574,13 +622,20 @@ void Foam::autoLayerDriver::handleFeatureAngleLayerTerminations
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nPointCounter++;
|
if (isMasterPoint[meshPoints[v1]])
|
||||||
|
{
|
||||||
|
nPointCounter++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< "Added "
|
||||||
|
<< returnReduce(nPointCounter-nOldPointCounter, sumOp<label>())
|
||||||
|
<< " point not to extrude." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -588,10 +643,12 @@ void Foam::autoLayerDriver::handleFeatureAngleLayerTerminations
|
|||||||
// in the layer mesh and stop any layer growth at these points.
|
// in the layer mesh and stop any layer growth at these points.
|
||||||
void Foam::autoLayerDriver::findIsolatedRegions
|
void Foam::autoLayerDriver::findIsolatedRegions
|
||||||
(
|
(
|
||||||
const indirectPrimitivePatch& pp,
|
|
||||||
const PackedBoolList& isMasterEdge,
|
|
||||||
const labelList& meshEdges,
|
|
||||||
const scalar minCosLayerTermination,
|
const scalar minCosLayerTermination,
|
||||||
|
const PackedBoolList& isMasterPoint,
|
||||||
|
const PackedBoolList& isMasterEdge,
|
||||||
|
const indirectPrimitivePatch& pp,
|
||||||
|
const labelList& meshEdges,
|
||||||
|
const scalarField& minThickness,
|
||||||
List<extrudeMode>& extrudeStatus,
|
List<extrudeMode>& extrudeStatus,
|
||||||
pointField& patchDisp,
|
pointField& patchDisp,
|
||||||
labelList& patchNLayers
|
labelList& patchNLayers
|
||||||
@ -610,8 +667,10 @@ void Foam::autoLayerDriver::findIsolatedRegions
|
|||||||
// large feature angle
|
// large feature angle
|
||||||
handleFeatureAngleLayerTerminations
|
handleFeatureAngleLayerTerminations
|
||||||
(
|
(
|
||||||
pp,
|
|
||||||
minCosLayerTermination,
|
minCosLayerTermination,
|
||||||
|
isMasterPoint,
|
||||||
|
pp,
|
||||||
|
meshEdges,
|
||||||
|
|
||||||
extrudeStatus,
|
extrudeStatus,
|
||||||
patchDisp,
|
patchDisp,
|
||||||
@ -619,6 +678,15 @@ void Foam::autoLayerDriver::findIsolatedRegions
|
|||||||
nPointCounter
|
nPointCounter
|
||||||
);
|
);
|
||||||
|
|
||||||
|
syncPatchDisplacement
|
||||||
|
(
|
||||||
|
pp,
|
||||||
|
minThickness,
|
||||||
|
patchDisp,
|
||||||
|
patchNLayers,
|
||||||
|
extrudeStatus
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Do not extrude from point where all neighbouring
|
// Do not extrude from point where all neighbouring
|
||||||
// faces are not grown
|
// faces are not grown
|
||||||
@ -841,7 +909,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
|||||||
if (debug&meshRefinement::MESH || debug&meshRefinement::LAYERINFO)
|
if (debug&meshRefinement::MESH || debug&meshRefinement::LAYERINFO)
|
||||||
{
|
{
|
||||||
pointField meshPointNormals(mesh.nPoints(), point(1, 0, 0));
|
pointField meshPointNormals(mesh.nPoints(), point(1, 0, 0));
|
||||||
UIndirectList<point>(meshPointNormals, pp.meshPoints()) = pointNormals;
|
UIndirectList<point>(meshPointNormals, meshPoints) = pointNormals;
|
||||||
meshRefinement::testSyncPointList
|
meshRefinement::testSyncPointList
|
||||||
(
|
(
|
||||||
"pointNormals",
|
"pointNormals",
|
||||||
@ -865,7 +933,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
|||||||
if (debug&meshRefinement::MESH || debug&meshRefinement::LAYERINFO)
|
if (debug&meshRefinement::MESH || debug&meshRefinement::LAYERINFO)
|
||||||
{
|
{
|
||||||
pointField meshPointNormals(mesh.nPoints(), point(1, 0, 0));
|
pointField meshPointNormals(mesh.nPoints(), point(1, 0, 0));
|
||||||
UIndirectList<point>(meshPointNormals, pp.meshPoints()) = pointNormals;
|
UIndirectList<point>(meshPointNormals, meshPoints) = pointNormals;
|
||||||
meshRefinement::testSyncPointList
|
meshRefinement::testSyncPointList
|
||||||
(
|
(
|
||||||
"smoothed pointNormals",
|
"smoothed pointNormals",
|
||||||
@ -1059,8 +1127,6 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
|
|||||||
&& !adaptPatches.found(patchI)
|
&& !adaptPatches.found(patchI)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelList& meshPoints = pp.meshPoints();
|
|
||||||
|
|
||||||
// Check the type of the patchField. The types are
|
// Check the type of the patchField. The types are
|
||||||
// - fixedValue (0 or more layers) but the >0 layers have
|
// - fixedValue (0 or more layers) but the >0 layers have
|
||||||
// already been handled in the adaptPatches loop
|
// already been handled in the adaptPatches loop
|
||||||
@ -1415,7 +1481,10 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
|
|||||||
|
|
||||||
patchDisp[patchPointI] = thickness[patchPointI]*n;
|
patchDisp[patchPointI] = thickness[patchPointI]*n;
|
||||||
|
|
||||||
numThicknessRatioExclude++;
|
if (isMasterPoint[pointI])
|
||||||
|
{
|
||||||
|
numThicknessRatioExclude++;
|
||||||
|
}
|
||||||
|
|
||||||
if (str.valid())
|
if (str.valid())
|
||||||
{
|
{
|
||||||
@ -1444,24 +1513,16 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
|
|||||||
<< " nodes where thickness to medial axis distance is large " << endl;
|
<< " nodes where thickness to medial axis distance is large " << endl;
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
Info<< "** start thickness **" << endl;
|
|
||||||
meshRefinement::collectAndPrint(pp.localPoints(), thickness);
|
|
||||||
Info<< "** end thickness **" << endl;
|
|
||||||
Info<< "** patchDisp **" << endl;
|
|
||||||
meshRefinement::collectAndPrint(pp.localPoints(), patchDisp);
|
|
||||||
Info<< "** end patchDisp **" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// find points where layer growth isolated to a lone point, edge or face
|
// find points where layer growth isolated to a lone point, edge or face
|
||||||
|
|
||||||
findIsolatedRegions
|
findIsolatedRegions
|
||||||
(
|
(
|
||||||
pp,
|
|
||||||
isMasterEdge,
|
|
||||||
meshEdges,
|
|
||||||
minCosLayerTermination,
|
minCosLayerTermination,
|
||||||
|
isMasterPoint,
|
||||||
|
isMasterEdge,
|
||||||
|
pp,
|
||||||
|
meshEdges,
|
||||||
|
minThickness,
|
||||||
|
|
||||||
extrudeStatus,
|
extrudeStatus,
|
||||||
patchDisp,
|
patchDisp,
|
||||||
@ -1630,19 +1691,14 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance
|
|||||||
// Do residual calculation every so often.
|
// Do residual calculation every so often.
|
||||||
if ((iter % 10) == 0)
|
if ((iter % 10) == 0)
|
||||||
{
|
{
|
||||||
// Info<< " Iteration " << iter << " residual "
|
|
||||||
// << gSum(mag(displacement-average))
|
|
||||||
// /returnReduce(average.size(), sumOp<label>())
|
|
||||||
// << endl;
|
|
||||||
|
|
||||||
scalar resid = meshRefinement::gAverage
|
scalar resid = meshRefinement::gAverage
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
syncTools::getMasterPoints(mesh),
|
syncTools::getMasterPoints(mesh),
|
||||||
mag(displacement-average)()
|
mag(displacement-average)()
|
||||||
);
|
);
|
||||||
Info<< " Iteration " << iter << " residual "
|
Info<< " Iteration " << iter << " residual " << resid
|
||||||
<< resid << endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user