ENH: autoHexMesh: parallel consistency

This commit is contained in:
mattijs
2014-09-24 17:37:29 +01:00
committed by Andrew Heather
parent f5adbc85cf
commit a5e73019e9
10 changed files with 266 additions and 190 deletions

View File

@ -2,7 +2,7 @@ autoHexMesh = autoHexMesh
autoHexMeshDriver = $(autoHexMesh)/autoHexMeshDriver autoHexMeshDriver = $(autoHexMesh)/autoHexMeshDriver
$(autoHexMeshDriver)/autoLayerDriver.C $(autoHexMeshDriver)/autoLayerDriver.C
$(autoHexMeshDriver)/autoLayerDriverShrink.C /* $(autoHexMeshDriver)/autoLayerDriverShrink.C */
$(autoHexMeshDriver)/autoSnapDriver.C $(autoHexMeshDriver)/autoSnapDriver.C
$(autoHexMeshDriver)/autoSnapDriverFeature.C $(autoHexMeshDriver)/autoSnapDriverFeature.C
$(autoHexMeshDriver)/autoRefineDriver.C $(autoHexMeshDriver)/autoRefineDriver.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,7 +29,6 @@ Description
SourceFiles SourceFiles
autoLayerDriver.C autoLayerDriver.C
autoLayerDriverShrink.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -1292,7 +1292,15 @@ void Foam::autoSnapDriver::detectNearSurfaces
} }
const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh)); const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh,
meshPoints
)
);
label nOverride = 0; label nOverride = 0;
// 1. All points to non-interface surfaces // 1. All points to non-interface surfaces
@ -1405,7 +1413,7 @@ void Foam::autoSnapDriver::detectNearSurfaces
} }
} }
if (override && isMasterPoint[meshPoints[pointI]]) if (override && isPatchMasterPoint[pointI])
{ {
nOverride++; nOverride++;
} }
@ -1543,7 +1551,7 @@ void Foam::autoSnapDriver::detectNearSurfaces
} }
} }
if (override && isMasterPoint[meshPoints[pointI]]) if (override && isPatchMasterPoint[pointI])
{ {
nOverride++; nOverride++;
} }
@ -1758,16 +1766,19 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
} }
{ {
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh,
pp.meshPoints()
)
);
scalarField magDisp(mag(patchDisp)); scalarField magDisp(mag(patchDisp));
Info<< "Wanted displacement : average:" Info<< "Wanted displacement : average:"
<< meshRefinement::gAverage << meshRefinement::gAverage(isPatchMasterPoint, magDisp)
(
mesh,
syncTools::getMasterPoints(mesh),
pp.meshPoints(),
magDisp
)
<< " min:" << gMin(magDisp) << " min:" << gMin(magDisp)
<< " max:" << gMax(magDisp) << endl; << " max:" << gMax(magDisp) << endl;
} }

View File

@ -126,7 +126,7 @@ bool Foam::autoSnapDriver::isFeaturePoint
void Foam::autoSnapDriver::smoothAndConstrain void Foam::autoSnapDriver::smoothAndConstrain
( (
const PackedBoolList& isMasterEdge, const PackedBoolList& isPatchMasterEdge,
const indirectPrimitivePatch& pp, const indirectPrimitivePatch& pp,
const labelList& meshEdges, const labelList& meshEdges,
const List<pointConstraint>& constraints, const List<pointConstraint>& constraints,
@ -168,7 +168,7 @@ void Foam::autoSnapDriver::smoothAndConstrain
{ {
label edgeI = pEdges[i]; label edgeI = pEdges[i];
if (isMasterEdge[meshEdges[edgeI]]) if (isPatchMasterEdge[edgeI])
{ {
label nbrPointI = edges[edgeI].otherVertex(pointI); label nbrPointI = edges[edgeI].otherVertex(pointI);
if (constraints[nbrPointI].first() >= nConstraints) if (constraints[nbrPointI].first() >= nConstraints)
@ -3231,20 +3231,24 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
patchConstraints patchConstraints
); );
const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh)); //const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh));
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh,
pp.meshPoints()
)
);
{ {
vector avgPatchDisp = meshRefinement::gAverage vector avgPatchDisp = meshRefinement::gAverage
( (
mesh, isPatchMasterPoint,
isMasterPoint,
pp.meshPoints(),
patchDisp patchDisp
); );
vector avgPatchAttr = meshRefinement::gAverage vector avgPatchAttr = meshRefinement::gAverage
( (
mesh, isPatchMasterPoint,
isMasterPoint,
pp.meshPoints(),
patchAttraction patchAttraction
); );
@ -3280,8 +3284,6 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
// Count // Count
{ {
const labelList& meshPoints = pp.meshPoints();
label nMasterPoints = 0; label nMasterPoints = 0;
label nPlanar = 0; label nPlanar = 0;
label nEdge = 0; label nEdge = 0;
@ -3289,7 +3291,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
forAll(patchConstraints, pointI) forAll(patchConstraints, pointI)
{ {
if (isMasterPoint[meshPoints[pointI]]) if (isPatchMasterPoint[pointI])
{ {
nMasterPoints++; nMasterPoints++;
@ -3337,7 +3339,19 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
if (featureAttract < 1-0.001) if (featureAttract < 1-0.001)
{ {
const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh)); //const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh));
const labelList meshEdges
(
pp.meshEdges(mesh.edges(), mesh.pointEdges())
);
const PackedBoolList isPatchMasterEdge
(
meshRefinement::getMasterEdges
(
mesh,
meshEdges
)
);
const vectorField pointNormals const vectorField pointNormals
( (
@ -3347,17 +3361,13 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
pp pp
) )
); );
const labelList meshEdges
(
pp.meshEdges(mesh.edges(), mesh.pointEdges())
);
// 1. Smoothed all displacement // 1. Smoothed all displacement
vectorField smoothedPatchDisp = patchDisp; vectorField smoothedPatchDisp = patchDisp;
smoothAndConstrain smoothAndConstrain
( (
isMasterEdge, isPatchMasterEdge,
pp, pp,
meshEdges, meshEdges,
patchConstraints, patchConstraints,
@ -3370,7 +3380,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
tangPatchDisp -= (pointNormals & patchDisp) * pointNormals; tangPatchDisp -= (pointNormals & patchDisp) * pointNormals;
smoothAndConstrain smoothAndConstrain
( (
isMasterEdge, isPatchMasterEdge,
pp, pp,
meshEdges, meshEdges,
patchConstraints, patchConstraints,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -49,7 +49,6 @@ Foam::externalDisplacementMeshMover::externalDisplacementMeshMover
{} {}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::externalDisplacementMeshMover> Foam::autoPtr<Foam::externalDisplacementMeshMover>

View File

@ -129,9 +129,8 @@ Foam::medialAxisMeshMover::getPatch
void Foam::medialAxisMeshMover::smoothPatchNormals void Foam::medialAxisMeshMover::smoothPatchNormals
( (
const label nSmoothDisp, const label nSmoothDisp,
const PackedBoolList& isMasterPoint, const PackedBoolList& isPatchMasterPoint,
const PackedBoolList& isMasterEdge, const PackedBoolList& isPatchMasterEdge,
const labelList& meshEdges,
pointField& normals pointField& normals
) const ) const
{ {
@ -142,13 +141,12 @@ void Foam::medialAxisMeshMover::smoothPatchNormals
// Get smoothly varying internal normals field. // Get smoothly varying internal normals field.
Info<< typeName << " : Smoothing normals ..." << endl; Info<< typeName << " : Smoothing normals ..." << endl;
scalarField edgeWeights(meshEdges.size()); scalarField edgeWeights(edges.size());
scalarField invSumWeight(meshPoints.size()); scalarField invSumWeight(meshPoints.size());
meshRefinement::calculateEdgeWeights meshRefinement::calculateEdgeWeights
( (
mesh(), mesh(),
isMasterEdge, isPatchMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -162,8 +160,7 @@ void Foam::medialAxisMeshMover::smoothPatchNormals
meshRefinement::weightedSum meshRefinement::weightedSum
( (
mesh(), mesh(),
isMasterEdge, isPatchMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -177,9 +174,7 @@ void Foam::medialAxisMeshMover::smoothPatchNormals
{ {
scalar resid = meshRefinement::gAverage scalar resid = meshRefinement::gAverage
( (
mesh(), isPatchMasterPoint,
isMasterPoint,
meshPoints,
mag(normals-average)() mag(normals-average)()
); );
Info<< " Iteration " << iter << " residual " << resid << endl; Info<< " Iteration " << iter << " residual " << resid << endl;
@ -201,8 +196,8 @@ void Foam::medialAxisMeshMover::smoothPatchNormals
void Foam::medialAxisMeshMover::smoothNormals void Foam::medialAxisMeshMover::smoothNormals
( (
const label nSmoothDisp, const label nSmoothDisp,
const PackedBoolList& isMasterPoint, const PackedBoolList& isMeshMasterPoint,
const PackedBoolList& isMasterEdge, const PackedBoolList& isMeshMasterEdge,
const labelList& fixedPoints, const labelList& fixedPoints,
pointVectorField& normals pointVectorField& normals
) const ) const
@ -229,18 +224,16 @@ void Foam::medialAxisMeshMover::smoothNormals
// Correspondence between local edges/points and mesh edges/points // Correspondence between local edges/points and mesh edges/points
const labelList meshEdges(identity(mesh().nEdges()));
const labelList meshPoints(identity(mesh().nPoints())); const labelList meshPoints(identity(mesh().nPoints()));
// Calculate inverse sum of weights // Calculate inverse sum of weights
scalarField edgeWeights(meshEdges.size()); scalarField edgeWeights(mesh().nEdges());
scalarField invSumWeight(meshPoints.size()); scalarField invSumWeight(meshPoints.size());
meshRefinement::calculateEdgeWeights meshRefinement::calculateEdgeWeights
( (
mesh(), mesh(),
isMasterEdge, isMeshMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -253,8 +246,7 @@ void Foam::medialAxisMeshMover::smoothNormals
meshRefinement::weightedSum meshRefinement::weightedSum
( (
mesh(), mesh(),
isMasterEdge, isMeshMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -268,8 +260,7 @@ void Foam::medialAxisMeshMover::smoothNormals
{ {
scalar resid = meshRefinement::gAverage scalar resid = meshRefinement::gAverage
( (
mesh(), isMeshMasterPoint,
isMasterPoint,
mag(normals-average)() mag(normals-average)()
); );
Info<< " Iteration " << iter << " residual " << resid << endl; Info<< " Iteration " << iter << " residual " << resid << endl;
@ -411,9 +402,9 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
// Predetermine mesh edges // Predetermine mesh edges
// ~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~
// Precalulate master point/edge (only relevant for shared points/edges) // Precalulate (mesh) master point/edge (only relevant for shared pts/edges)
const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh())); const PackedBoolList isMeshMasterPoint(syncTools::getMasterPoints(mesh()));
const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh())); const PackedBoolList isMeshMasterEdge(syncTools::getMasterEdges(mesh()));
// Precalculate meshEdge per pp edge // Precalculate meshEdge per pp edge
const labelList meshEdges const labelList meshEdges
( (
@ -424,6 +415,23 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
) )
); );
// Precalulate (patch) master point/edge
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh(),
meshPoints
)
);
const PackedBoolList isPatchMasterEdge
(
meshRefinement::getMasterEdges
(
mesh(),
meshEdges
)
);
// Determine pointNormal // Determine pointNormal
// ~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~
@ -434,9 +442,8 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
smoothPatchNormals smoothPatchNormals
( (
nSmoothSurfaceNormals, nSmoothSurfaceNormals,
isMasterPoint, isPatchMasterPoint,
isMasterEdge, isPatchMasterEdge,
meshEdges,
pointNormals pointNormals
); );
@ -795,8 +802,8 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
smoothNormals smoothNormals
( (
nSmoothNormals, nSmoothNormals,
isMasterPoint, isMeshMasterPoint,
isMasterEdge, isMeshMasterEdge,
meshPoints, meshPoints,
dispVec_ dispVec_
); );
@ -999,9 +1006,8 @@ void Foam::medialAxisMeshMover::syncPatchDisplacement
void Foam::medialAxisMeshMover::minSmoothField void Foam::medialAxisMeshMover::minSmoothField
( (
const label nSmoothDisp, const label nSmoothDisp,
const PackedBoolList& isMasterPoint, const PackedBoolList& isPatchMasterPoint,
const PackedBoolList& isMasterEdge, const PackedBoolList& isPatchMasterEdge,
const labelList& meshEdges,
const scalarField& fieldMin, const scalarField& fieldMin,
scalarField& field scalarField& field
) const ) const
@ -1010,13 +1016,12 @@ void Foam::medialAxisMeshMover::minSmoothField
const edgeList& edges = pp.edges(); const edgeList& edges = pp.edges();
const labelList& meshPoints = pp.meshPoints(); const labelList& meshPoints = pp.meshPoints();
scalarField edgeWeights(meshEdges.size()); scalarField edgeWeights(edges.size());
scalarField invSumWeight(meshPoints.size()); scalarField invSumWeight(meshPoints.size());
meshRefinement::calculateEdgeWeights meshRefinement::calculateEdgeWeights
( (
mesh(), mesh(),
isMasterEdge, isPatchMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -1032,8 +1037,7 @@ void Foam::medialAxisMeshMover::minSmoothField
meshRefinement::weightedSum meshRefinement::weightedSum
( (
mesh(), mesh(),
isMasterEdge, isPatchMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -1064,9 +1068,7 @@ void Foam::medialAxisMeshMover::minSmoothField
{ {
scalar resid = meshRefinement::gAverage scalar resid = meshRefinement::gAverage
( (
mesh(), isPatchMasterPoint,
isMasterPoint,
meshPoints,
mag(field-average)() mag(field-average)()
); );
Info<< " Iteration " << iter << " residual " << resid << endl; Info<< " Iteration " << iter << " residual " << resid << endl;
@ -1080,7 +1082,7 @@ void Foam::medialAxisMeshMover::
handleFeatureAngleLayerTerminations handleFeatureAngleLayerTerminations
( (
const scalar minCos, const scalar minCos,
const PackedBoolList& isMasterPoint, const PackedBoolList& isPatchMasterPoint,
const labelList& meshEdges, const labelList& meshEdges,
List<autoLayerDriver::extrudeMode>& extrudeStatus, List<autoLayerDriver::extrudeMode>& extrudeStatus,
pointField& patchDisp, pointField& patchDisp,
@ -1122,7 +1124,6 @@ handleFeatureAngleLayerTerminations
const labelListList& edgeFaces = pp.edgeFaces(); const labelListList& edgeFaces = pp.edgeFaces();
const vectorField& faceNormals = pp.faceNormals(); const vectorField& faceNormals = pp.faceNormals();
const labelList& meshPoints = pp.meshPoints();
forAll(edgeFaces, edgeI) forAll(edgeFaces, edgeI)
{ {
@ -1183,14 +1184,14 @@ handleFeatureAngleLayerTerminations
{ {
if (unmarkExtrusion(v0, patchDisp, extrudeStatus)) if (unmarkExtrusion(v0, patchDisp, extrudeStatus))
{ {
if (isMasterPoint[meshPoints[v0]]) if (isPatchMasterPoint[v0])
{ {
nPointCounter++; nPointCounter++;
} }
} }
if (unmarkExtrusion(v1, patchDisp, extrudeStatus)) if (unmarkExtrusion(v1, patchDisp, extrudeStatus))
{ {
if (isMasterPoint[meshPoints[v1]]) if (isPatchMasterPoint[v1])
{ {
nPointCounter++; nPointCounter++;
} }
@ -1213,8 +1214,8 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
( (
const scalar minCosLayerTermination, const scalar minCosLayerTermination,
const bool detectExtrusionIsland, const bool detectExtrusionIsland,
const PackedBoolList& isMasterPoint, const PackedBoolList& isPatchMasterPoint,
const PackedBoolList& isMasterEdge, const PackedBoolList& isPatchMasterEdge,
const labelList& meshEdges, const labelList& meshEdges,
const scalarField& minThickness, const scalarField& minThickness,
List<autoLayerDriver::extrudeMode>& extrudeStatus, List<autoLayerDriver::extrudeMode>& extrudeStatus,
@ -1223,13 +1224,32 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
{ {
const indirectPrimitivePatch& pp = adaptPatchPtr_(); const indirectPrimitivePatch& pp = adaptPatchPtr_();
const labelListList& pointFaces = pp.pointFaces(); const labelListList& pointFaces = pp.pointFaces();
const labelList& meshPoints = pp.meshPoints();
Info<< typeName << " : Removing isolated regions ..." << endl; Info<< typeName << " : Removing isolated regions ..." << endl;
// Keep count of number of points unextruded // Keep count of number of points unextruded
label nPointCounter = 0; label nPointCounter = 0;
autoPtr<OBJstream> str;
if (debug)
{
str.reset
(
new OBJstream
(
mesh().time().path()
/ "islandExcludePoints_"
+ mesh().time().timeName()
+ ".obj"
)
);
Info<< typeName
<< " : Writing points surrounded by non-extruded points to "
<< str().name() << endl;
}
while (true) while (true)
{ {
// Stop layer growth where mesh wraps around edge with a // Stop layer growth where mesh wraps around edge with a
@ -1237,7 +1257,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
handleFeatureAngleLayerTerminations handleFeatureAngleLayerTerminations
( (
minCosLayerTermination, minCosLayerTermination,
isMasterPoint, isPatchMasterPoint,
meshEdges, meshEdges,
extrudeStatus, extrudeStatus,
@ -1353,7 +1373,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
syncTools::syncPointList syncTools::syncPointList
( (
mesh(), mesh(),
pp.meshPoints(), meshPoints,
keptPoints, keptPoints,
orEqOp<bool>(), orEqOp<bool>(),
false // null value false // null value
@ -1369,6 +1389,11 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
{ {
nPointCounter++; nPointCounter++;
nChanged++; nChanged++;
if (str.valid())
{
str().write(pp.points()[meshPoints[patchPointI]]);
}
} }
} }
} }
@ -1390,7 +1415,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
forAll(edges, edgeI) forAll(edges, edgeI)
{ {
if (isMasterEdge.get(meshEdges[edgeI]) == 1) if (isPatchMasterEdge[edgeI])
{ {
const edge& e = edges[edgeI]; const edge& e = edges[edgeI];
@ -1411,7 +1436,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
syncTools::syncPointList syncTools::syncPointList
( (
mesh(), mesh(),
pp.meshPoints(), meshPoints,
isolatedPoint, isolatedPoint,
plusEqOp<label>(), plusEqOp<label>(),
label(0) // null value label(0) // null value
@ -1458,6 +1483,11 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
) )
{ {
nPointCounter++; nPointCounter++;
if (str.valid())
{
str().write(pp.points()[meshPoints[f[fp]]]);
}
} }
} }
} }
@ -1474,25 +1504,23 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement
( (
const label nSmoothDisp, const label nSmoothDisp,
const PackedBoolList& isMasterPoint, const PackedBoolList& isMeshMasterPoint,
const PackedBoolList& isMasterEdge, const PackedBoolList& isMeshMasterEdge,
vectorField& displacement vectorField& displacement
) const ) const
{ {
const edgeList& edges = mesh().edges(); const edgeList& edges = mesh().edges();
// Correspondence between local edges/points and mesh edges/points // Correspondence between local edges/points and mesh edges/points
const labelList meshEdges(identity(mesh().nEdges()));
const labelList meshPoints(identity(mesh().nPoints())); const labelList meshPoints(identity(mesh().nPoints()));
// Calculate inverse sum of weights // Calculate inverse sum of weights
scalarField edgeWeights(meshEdges.size()); scalarField edgeWeights(mesh().nEdges());
scalarField invSumWeight(meshPoints.size()); scalarField invSumWeight(meshPoints.size());
meshRefinement::calculateEdgeWeights meshRefinement::calculateEdgeWeights
( (
mesh(), mesh(),
isMasterEdge, isMeshMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -1512,8 +1540,7 @@ void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement
meshRefinement::weightedSum meshRefinement::weightedSum
( (
mesh(), mesh(),
isMasterEdge, isMeshMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -1533,8 +1560,7 @@ void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement
meshRefinement::weightedSum meshRefinement::weightedSum
( (
mesh(), mesh(),
isMasterEdge, isMeshMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -1558,8 +1584,7 @@ void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement
{ {
scalar resid = meshRefinement::gAverage scalar resid = meshRefinement::gAverage
( (
mesh(), isMeshMasterPoint,
isMasterPoint,
mag(displacement-average)() mag(displacement-average)()
); );
Info<< " Iteration " << iter << " residual " << resid << endl; Info<< " Iteration " << iter << " residual " << resid << endl;
@ -1735,8 +1760,8 @@ void Foam::medialAxisMeshMover::calculateDisplacement
// Precalulate master points/edge (only relevant for shared points/edges) // Precalulate master points/edge (only relevant for shared points/edges)
const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh())); const PackedBoolList isMeshMasterPoint(syncTools::getMasterPoints(mesh()));
const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh())); const PackedBoolList isMeshMasterEdge(syncTools::getMasterEdges(mesh()));
// Precalculate meshEdge per pp edge // Precalculate meshEdge per pp edge
const labelList meshEdges const labelList meshEdges
( (
@ -1747,6 +1772,24 @@ void Foam::medialAxisMeshMover::calculateDisplacement
) )
); );
// Precalulate (patch) master point/edge
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh(),
meshPoints
)
);
const PackedBoolList isPatchMasterEdge
(
meshRefinement::getMasterEdges
(
mesh(),
meshEdges
)
);
scalarField thickness(patchDisp.size()); scalarField thickness(patchDisp.size());
@ -1846,7 +1889,7 @@ void Foam::medialAxisMeshMover::calculateDisplacement
patchDisp[patchPointI] = thickness[patchPointI]*n; patchDisp[patchPointI] = thickness[patchPointI]*n;
if (isMasterPoint[pointI]) if (isPatchMasterPoint[patchPointI])
{ {
numThicknessRatioExclude++; numThicknessRatioExclude++;
} }
@ -1885,8 +1928,8 @@ void Foam::medialAxisMeshMover::calculateDisplacement
minCosLayerTermination, minCosLayerTermination,
detectExtrusionIsland, detectExtrusionIsland,
isMasterPoint, isPatchMasterPoint,
isMasterEdge, isPatchMasterEdge,
meshEdges, meshEdges,
minThickness, minThickness,
@ -1908,9 +1951,8 @@ void Foam::medialAxisMeshMover::calculateDisplacement
minSmoothField minSmoothField
( (
nSmoothPatchThickness, nSmoothPatchThickness,
isMasterPoint, isPatchMasterPoint,
isMasterEdge, isPatchMasterEdge,
meshEdges,
minThickness, minThickness,
thickness thickness
@ -1991,8 +2033,8 @@ void Foam::medialAxisMeshMover::calculateDisplacement
smoothLambdaMuDisplacement smoothLambdaMuDisplacement
( (
nSmoothDisplacement, nSmoothDisplacement,
isMasterPoint, isMeshMasterPoint,
isMasterEdge, isMeshMasterEdge,
displacement displacement
); );
} }

View File

@ -117,7 +117,6 @@ class medialAxisMeshMover
const label nSmoothDisp, const label nSmoothDisp,
const PackedBoolList& isMasterPoint, const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge, const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
pointField& normals pointField& normals
) const; ) const;
@ -175,7 +174,6 @@ class medialAxisMeshMover
const label nSmoothDisp, const label nSmoothDisp,
const PackedBoolList& isMasterPoint, const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge, const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const scalarField& fieldMin, const scalarField& fieldMin,
scalarField& field scalarField& field
) const; ) const;

View File

@ -1954,7 +1954,6 @@ void Foam::meshRefinement::calculateEdgeWeights
( (
const polyMesh& mesh, const polyMesh& mesh,
const PackedBoolList& isMasterEdge, const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints, const labelList& meshPoints,
const edgeList& edges, const edgeList& edges,
scalarField& edgeWeights, scalarField& edgeWeights,
@ -1964,7 +1963,7 @@ void Foam::meshRefinement::calculateEdgeWeights
const pointField& pts = mesh.points(); const pointField& pts = mesh.points();
// Calculate edgeWeights and inverse sum of edge weights // Calculate edgeWeights and inverse sum of edge weights
edgeWeights.setSize(meshEdges.size()); edgeWeights.setSize(isMasterEdge.size());
invSumWeight.setSize(meshPoints.size()); invSumWeight.setSize(meshPoints.size());
forAll(edges, edgeI) forAll(edges, edgeI)
@ -1987,7 +1986,6 @@ void Foam::meshRefinement::calculateEdgeWeights
( (
mesh, mesh,
isMasterEdge, isMasterEdge,
meshEdges,
meshPoints, meshPoints,
edges, edges,
edgeWeights, edgeWeights,
@ -2639,8 +2637,82 @@ bool Foam::meshRefinement::write() const
} }
Foam::PackedBoolList Foam::meshRefinement::getMasterPoints
(
const polyMesh& mesh,
const labelList& meshPoints
)
{
const globalIndex globalPoints(meshPoints.size());
labelList myPoints(meshPoints.size());
forAll(meshPoints, pointI)
{
myPoints[pointI] = globalPoints.toGlobal(pointI);
}
syncTools::syncPointList
(
mesh,
meshPoints,
myPoints,
minEqOp<label>(),
labelMax
);
PackedBoolList isPatchMasterPoint(meshPoints.size());
forAll(meshPoints, pointI)
{
if (myPoints[pointI] == globalPoints.toGlobal(pointI))
{
isPatchMasterPoint[pointI] = true;
}
}
return isPatchMasterPoint;
}
Foam::PackedBoolList Foam::meshRefinement::getMasterEdges
(
const polyMesh& mesh,
const labelList& meshEdges
)
{
const globalIndex globalEdges(meshEdges.size());
labelList myEdges(meshEdges.size());
forAll(meshEdges, edgeI)
{
myEdges[edgeI] = globalEdges.toGlobal(edgeI);
}
syncTools::syncEdgeList
(
mesh,
meshEdges,
myEdges,
minEqOp<label>(),
labelMax
);
PackedBoolList isMasterEdge(meshEdges.size());
forAll(meshEdges, edgeI)
{
if (myEdges[edgeI] == globalEdges.toGlobal(edgeI))
{
isMasterEdge[edgeI] = true;
}
}
return isMasterEdge;
}
void Foam::meshRefinement::printMeshInfo(const bool debug, const string& msg) void Foam::meshRefinement::printMeshInfo(const bool debug, const string& msg)
const const
{ {
const globalMeshData& pData = mesh_.globalData(); const globalMeshData& pData = mesh_.globalData();
@ -2664,11 +2736,11 @@ void Foam::meshRefinement::printMeshInfo(const bool debug, const string& msg)
} }
} }
PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh_)); PackedBoolList isMeshMasterPoint(syncTools::getMasterPoints(mesh_));
label nMasterPoints = 0; label nMasterPoints = 0;
forAll(isMasterPoint, i) forAll(isMeshMasterPoint, i)
{ {
if (isMasterPoint[i]) if (isMeshMasterPoint[i])
{ {
nMasterPoints++; nMasterPoints++;
} }

View File

@ -733,7 +733,6 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const PackedBoolList& isMasterEdge, const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints, const labelList& meshPoints,
const edgeList& edges, const edgeList& edges,
scalarField& edgeWeights, scalarField& edgeWeights,
@ -747,7 +746,6 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const PackedBoolList& isMasterEdge, const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints, const labelList& meshPoints,
const edgeList& edges, const edgeList& edges,
const scalarField& edgeWeights, const scalarField& edgeWeights,
@ -1069,6 +1067,22 @@ public:
const UList<T>& data const UList<T>& data
); );
//- Determine master point for subset of points. If coupled
// chooses only one
static PackedBoolList getMasterPoints
(
const polyMesh& mesh,
const labelList& meshPoints
);
//- Determine master edge for subset of edges. If coupled
// chooses only one
static PackedBoolList getMasterEdges
(
const polyMesh& mesh,
const labelList& meshEdges
);
//- Print some mesh stats. //- Print some mesh stats.
void printMeshInfo(const bool, const string&) const; void printMeshInfo(const bool, const string&) const;
@ -1100,22 +1114,10 @@ public:
template<class T> template<class T>
static T gAverage static T gAverage
( (
const polyMesh& mesh,
const PackedBoolList& isMasterElem, const PackedBoolList& isMasterElem,
const UList<T>& values const UList<T>& values
); );
//- Helper: calculate average over selected elements
template<class T>
static T gAverage
(
const polyMesh& mesh,
const PackedBoolList& isMasterElem,
const labelList& meshPoints,
const UList<T>& values
);
//- Get/set write level //- Get/set write level
static writeType writeLevel(); static writeType writeLevel();
static void writeLevel(const writeType); static void writeLevel(const writeType);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,7 +57,6 @@ template<class T> void Foam::meshRefinement::updateList
template<class T> template<class T>
T Foam::meshRefinement::gAverage T Foam::meshRefinement::gAverage
( (
const polyMesh& mesh,
const PackedBoolList& isMasterElem, const PackedBoolList& isMasterElem,
const UList<T>& values const UList<T>& values
) )
@ -68,7 +67,6 @@ T Foam::meshRefinement::gAverage
( (
"meshRefinement::gAverage\n" "meshRefinement::gAverage\n"
"(\n" "(\n"
" const polyMesh&,\n"
" const PackedBoolList& isMasterElem,\n" " const PackedBoolList& isMasterElem,\n"
" const UList<T>& values\n" " const UList<T>& values\n"
")\n" ")\n"
@ -104,58 +102,6 @@ T Foam::meshRefinement::gAverage
} }
template<class T>
T Foam::meshRefinement::gAverage
(
const polyMesh& mesh,
const PackedBoolList& isMasterElem,
const labelList& meshElems,
const UList<T>& values
)
{
if (values.size() != meshElems.size())
{
FatalErrorIn
(
"meshRefinement::gAverage\n"
"(\n"
" const polyMesh&,\n"
" const labelList&,\n"
" const PackedBoolList& isMasterElem,\n"
" const UList<T>& values\n"
")\n"
) << "Number of elements in list " << values.size()
<< " does not correspond to number of elements in meshElems "
<< meshElems.size()
<< exit(FatalError);
}
T sum = pTraits<T>::zero;
label n = 0;
forAll(values, i)
{
if (isMasterElem[meshElems[i]])
{
sum += values[i];
n++;
}
}
reduce(sum, sumOp<T>());
reduce(n, sumOp<label>());
if (n > 0)
{
return sum/n;
}
else
{
return pTraits<T>::max;
}
}
// Compare two lists over all boundary faces // Compare two lists over all boundary faces
template<class T> template<class T>
void Foam::meshRefinement::testSyncBoundaryFaceList void Foam::meshRefinement::testSyncBoundaryFaceList
@ -343,7 +289,6 @@ void Foam::meshRefinement::weightedSum
( (
const polyMesh& mesh, const polyMesh& mesh,
const PackedBoolList& isMasterEdge, const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints, const labelList& meshPoints,
const edgeList& edges, const edgeList& edges,
const scalarField& edgeWeights, const scalarField& edgeWeights,
@ -353,15 +298,13 @@ void Foam::meshRefinement::weightedSum
{ {
if if
( (
mesh.nEdges() != isMasterEdge.size() edges.size() != isMasterEdge.size()
|| edges.size() != meshEdges.size()
|| edges.size() != edgeWeights.size() || edges.size() != edgeWeights.size()
|| meshPoints.size() != pointData.size() || meshPoints.size() != pointData.size()
) )
{ {
FatalErrorIn("medialAxisMeshMover::weightedSum(..)") FatalErrorIn("medialAxisMeshMover::weightedSum(..)")
<< "Inconsistent sizes for edge or point data:" << "Inconsistent sizes for edge or point data:"
<< " meshEdges:" << meshEdges.size()
<< " isMasterEdge:" << isMasterEdge.size() << " isMasterEdge:" << isMasterEdge.size()
<< " edgeWeights:" << edgeWeights.size() << " edgeWeights:" << edgeWeights.size()
<< " edges:" << edges.size() << " edges:" << edges.size()
@ -375,7 +318,7 @@ void Foam::meshRefinement::weightedSum
forAll(edges, edgeI) forAll(edges, edgeI)
{ {
if (isMasterEdge.get(meshEdges[edgeI]) == 1) if (isMasterEdge[edgeI])
{ {
const edge& e = edges[edgeI]; const edge& e = edges[edgeI];