diff --git a/src/mesh/autoMesh/Make/files b/src/mesh/autoMesh/Make/files index be8a5fff15..2bc9cd80a1 100644 --- a/src/mesh/autoMesh/Make/files +++ b/src/mesh/autoMesh/Make/files @@ -2,7 +2,7 @@ autoHexMesh = autoHexMesh autoHexMeshDriver = $(autoHexMesh)/autoHexMeshDriver $(autoHexMeshDriver)/autoLayerDriver.C -$(autoHexMeshDriver)/autoLayerDriverShrink.C +/* $(autoHexMeshDriver)/autoLayerDriverShrink.C */ $(autoHexMeshDriver)/autoSnapDriver.C $(autoHexMeshDriver)/autoSnapDriverFeature.C $(autoHexMeshDriver)/autoRefineDriver.C diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index ee94b0b015..07bf19ce0d 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,6 @@ Description SourceFiles autoLayerDriver.C - autoLayerDriverShrink.C \*---------------------------------------------------------------------------*/ diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index ed05edf492..006ead54fb 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -1292,7 +1292,15 @@ void Foam::autoSnapDriver::detectNearSurfaces } - const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh)); + const PackedBoolList isPatchMasterPoint + ( + meshRefinement::getMasterPoints + ( + mesh, + meshPoints + ) + ); + label nOverride = 0; // 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++; } @@ -1543,7 +1551,7 @@ void Foam::autoSnapDriver::detectNearSurfaces } } - if (override && isMasterPoint[meshPoints[pointI]]) + if (override && isPatchMasterPoint[pointI]) { nOverride++; } @@ -1758,16 +1766,19 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface } { + const PackedBoolList isPatchMasterPoint + ( + meshRefinement::getMasterPoints + ( + mesh, + pp.meshPoints() + ) + ); + scalarField magDisp(mag(patchDisp)); Info<< "Wanted displacement : average:" - << meshRefinement::gAverage - ( - mesh, - syncTools::getMasterPoints(mesh), - pp.meshPoints(), - magDisp - ) + << meshRefinement::gAverage(isPatchMasterPoint, magDisp) << " min:" << gMin(magDisp) << " max:" << gMax(magDisp) << endl; } diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C index c7a00df00e..b1cc58a051 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C @@ -126,7 +126,7 @@ bool Foam::autoSnapDriver::isFeaturePoint void Foam::autoSnapDriver::smoothAndConstrain ( - const PackedBoolList& isMasterEdge, + const PackedBoolList& isPatchMasterEdge, const indirectPrimitivePatch& pp, const labelList& meshEdges, const List& constraints, @@ -168,7 +168,7 @@ void Foam::autoSnapDriver::smoothAndConstrain { label edgeI = pEdges[i]; - if (isMasterEdge[meshEdges[edgeI]]) + if (isPatchMasterEdge[edgeI]) { label nbrPointI = edges[edgeI].otherVertex(pointI); if (constraints[nbrPointI].first() >= nConstraints) @@ -3231,20 +3231,24 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature 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 ( - mesh, - isMasterPoint, - pp.meshPoints(), + isPatchMasterPoint, patchDisp ); vector avgPatchAttr = meshRefinement::gAverage ( - mesh, - isMasterPoint, - pp.meshPoints(), + isPatchMasterPoint, patchAttraction ); @@ -3280,8 +3284,6 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature // Count { - const labelList& meshPoints = pp.meshPoints(); - label nMasterPoints = 0; label nPlanar = 0; label nEdge = 0; @@ -3289,7 +3291,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature forAll(patchConstraints, pointI) { - if (isMasterPoint[meshPoints[pointI]]) + if (isPatchMasterPoint[pointI]) { nMasterPoints++; @@ -3337,7 +3339,19 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature 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 ( @@ -3347,17 +3361,13 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature pp ) ); - const labelList meshEdges - ( - pp.meshEdges(mesh.edges(), mesh.pointEdges()) - ); // 1. Smoothed all displacement vectorField smoothedPatchDisp = patchDisp; smoothAndConstrain ( - isMasterEdge, + isPatchMasterEdge, pp, meshEdges, patchConstraints, @@ -3370,7 +3380,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature tangPatchDisp -= (pointNormals & patchDisp) * pointNormals; smoothAndConstrain ( - isMasterEdge, + isPatchMasterEdge, pp, meshEdges, patchConstraints, diff --git a/src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C b/src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C index 55e60904ff..2067b24cac 100644 --- a/src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C +++ b/src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/externalDisplacementMeshMover.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,7 +49,6 @@ Foam::externalDisplacementMeshMover::externalDisplacementMeshMover {} - // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // Foam::autoPtr diff --git a/src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C b/src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C index b605ae672b..df17b0ece4 100644 --- a/src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C +++ b/src/mesh/autoMesh/autoHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C @@ -129,9 +129,8 @@ Foam::medialAxisMeshMover::getPatch void Foam::medialAxisMeshMover::smoothPatchNormals ( const label nSmoothDisp, - const PackedBoolList& isMasterPoint, - const PackedBoolList& isMasterEdge, - const labelList& meshEdges, + const PackedBoolList& isPatchMasterPoint, + const PackedBoolList& isPatchMasterEdge, pointField& normals ) const { @@ -142,13 +141,12 @@ void Foam::medialAxisMeshMover::smoothPatchNormals // Get smoothly varying internal normals field. Info<< typeName << " : Smoothing normals ..." << endl; - scalarField edgeWeights(meshEdges.size()); + scalarField edgeWeights(edges.size()); scalarField invSumWeight(meshPoints.size()); meshRefinement::calculateEdgeWeights ( mesh(), - isMasterEdge, - meshEdges, + isPatchMasterEdge, meshPoints, edges, edgeWeights, @@ -162,8 +160,7 @@ void Foam::medialAxisMeshMover::smoothPatchNormals meshRefinement::weightedSum ( mesh(), - isMasterEdge, - meshEdges, + isPatchMasterEdge, meshPoints, edges, edgeWeights, @@ -177,9 +174,7 @@ void Foam::medialAxisMeshMover::smoothPatchNormals { scalar resid = meshRefinement::gAverage ( - mesh(), - isMasterPoint, - meshPoints, + isPatchMasterPoint, mag(normals-average)() ); Info<< " Iteration " << iter << " residual " << resid << endl; @@ -201,8 +196,8 @@ void Foam::medialAxisMeshMover::smoothPatchNormals void Foam::medialAxisMeshMover::smoothNormals ( const label nSmoothDisp, - const PackedBoolList& isMasterPoint, - const PackedBoolList& isMasterEdge, + const PackedBoolList& isMeshMasterPoint, + const PackedBoolList& isMeshMasterEdge, const labelList& fixedPoints, pointVectorField& normals ) const @@ -229,18 +224,16 @@ void Foam::medialAxisMeshMover::smoothNormals // Correspondence between local edges/points and mesh edges/points - const labelList meshEdges(identity(mesh().nEdges())); const labelList meshPoints(identity(mesh().nPoints())); // Calculate inverse sum of weights - scalarField edgeWeights(meshEdges.size()); + scalarField edgeWeights(mesh().nEdges()); scalarField invSumWeight(meshPoints.size()); meshRefinement::calculateEdgeWeights ( mesh(), - isMasterEdge, - meshEdges, + isMeshMasterEdge, meshPoints, edges, edgeWeights, @@ -253,8 +246,7 @@ void Foam::medialAxisMeshMover::smoothNormals meshRefinement::weightedSum ( mesh(), - isMasterEdge, - meshEdges, + isMeshMasterEdge, meshPoints, edges, edgeWeights, @@ -268,8 +260,7 @@ void Foam::medialAxisMeshMover::smoothNormals { scalar resid = meshRefinement::gAverage ( - mesh(), - isMasterPoint, + isMeshMasterPoint, mag(normals-average)() ); Info<< " Iteration " << iter << " residual " << resid << endl; @@ -411,9 +402,9 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict) // Predetermine mesh edges // ~~~~~~~~~~~~~~~~~~~~~~~ - // Precalulate master point/edge (only relevant for shared points/edges) - const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh())); - const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh())); + // Precalulate (mesh) master point/edge (only relevant for shared pts/edges) + const PackedBoolList isMeshMasterPoint(syncTools::getMasterPoints(mesh())); + const PackedBoolList isMeshMasterEdge(syncTools::getMasterEdges(mesh())); // Precalculate meshEdge per pp edge 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 // ~~~~~~~~~~~~~~~~~~~~~ @@ -434,9 +442,8 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict) smoothPatchNormals ( nSmoothSurfaceNormals, - isMasterPoint, - isMasterEdge, - meshEdges, + isPatchMasterPoint, + isPatchMasterEdge, pointNormals ); @@ -795,8 +802,8 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict) smoothNormals ( nSmoothNormals, - isMasterPoint, - isMasterEdge, + isMeshMasterPoint, + isMeshMasterEdge, meshPoints, dispVec_ ); @@ -999,9 +1006,8 @@ void Foam::medialAxisMeshMover::syncPatchDisplacement void Foam::medialAxisMeshMover::minSmoothField ( const label nSmoothDisp, - const PackedBoolList& isMasterPoint, - const PackedBoolList& isMasterEdge, - const labelList& meshEdges, + const PackedBoolList& isPatchMasterPoint, + const PackedBoolList& isPatchMasterEdge, const scalarField& fieldMin, scalarField& field ) const @@ -1010,13 +1016,12 @@ void Foam::medialAxisMeshMover::minSmoothField const edgeList& edges = pp.edges(); const labelList& meshPoints = pp.meshPoints(); - scalarField edgeWeights(meshEdges.size()); + scalarField edgeWeights(edges.size()); scalarField invSumWeight(meshPoints.size()); meshRefinement::calculateEdgeWeights ( mesh(), - isMasterEdge, - meshEdges, + isPatchMasterEdge, meshPoints, edges, edgeWeights, @@ -1032,8 +1037,7 @@ void Foam::medialAxisMeshMover::minSmoothField meshRefinement::weightedSum ( mesh(), - isMasterEdge, - meshEdges, + isPatchMasterEdge, meshPoints, edges, edgeWeights, @@ -1064,9 +1068,7 @@ void Foam::medialAxisMeshMover::minSmoothField { scalar resid = meshRefinement::gAverage ( - mesh(), - isMasterPoint, - meshPoints, + isPatchMasterPoint, mag(field-average)() ); Info<< " Iteration " << iter << " residual " << resid << endl; @@ -1080,7 +1082,7 @@ void Foam::medialAxisMeshMover:: handleFeatureAngleLayerTerminations ( const scalar minCos, - const PackedBoolList& isMasterPoint, + const PackedBoolList& isPatchMasterPoint, const labelList& meshEdges, List& extrudeStatus, pointField& patchDisp, @@ -1122,7 +1124,6 @@ handleFeatureAngleLayerTerminations const labelListList& edgeFaces = pp.edgeFaces(); const vectorField& faceNormals = pp.faceNormals(); - const labelList& meshPoints = pp.meshPoints(); forAll(edgeFaces, edgeI) { @@ -1183,14 +1184,14 @@ handleFeatureAngleLayerTerminations { if (unmarkExtrusion(v0, patchDisp, extrudeStatus)) { - if (isMasterPoint[meshPoints[v0]]) + if (isPatchMasterPoint[v0]) { nPointCounter++; } } if (unmarkExtrusion(v1, patchDisp, extrudeStatus)) { - if (isMasterPoint[meshPoints[v1]]) + if (isPatchMasterPoint[v1]) { nPointCounter++; } @@ -1213,8 +1214,8 @@ void Foam::medialAxisMeshMover::findIsolatedRegions ( const scalar minCosLayerTermination, const bool detectExtrusionIsland, - const PackedBoolList& isMasterPoint, - const PackedBoolList& isMasterEdge, + const PackedBoolList& isPatchMasterPoint, + const PackedBoolList& isPatchMasterEdge, const labelList& meshEdges, const scalarField& minThickness, List& extrudeStatus, @@ -1223,13 +1224,32 @@ void Foam::medialAxisMeshMover::findIsolatedRegions { const indirectPrimitivePatch& pp = adaptPatchPtr_(); const labelListList& pointFaces = pp.pointFaces(); - + const labelList& meshPoints = pp.meshPoints(); Info<< typeName << " : Removing isolated regions ..." << endl; // Keep count of number of points unextruded label nPointCounter = 0; + + autoPtr 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) { // Stop layer growth where mesh wraps around edge with a @@ -1237,7 +1257,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions handleFeatureAngleLayerTerminations ( minCosLayerTermination, - isMasterPoint, + isPatchMasterPoint, meshEdges, extrudeStatus, @@ -1353,7 +1373,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions syncTools::syncPointList ( mesh(), - pp.meshPoints(), + meshPoints, keptPoints, orEqOp(), false // null value @@ -1369,6 +1389,11 @@ void Foam::medialAxisMeshMover::findIsolatedRegions { nPointCounter++; nChanged++; + + if (str.valid()) + { + str().write(pp.points()[meshPoints[patchPointI]]); + } } } } @@ -1390,7 +1415,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions forAll(edges, edgeI) { - if (isMasterEdge.get(meshEdges[edgeI]) == 1) + if (isPatchMasterEdge[edgeI]) { const edge& e = edges[edgeI]; @@ -1411,7 +1436,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions syncTools::syncPointList ( mesh(), - pp.meshPoints(), + meshPoints, isolatedPoint, plusEqOp