From 8407dd2454add751124c83d12bf46d0bffa3ef74 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 1 Mar 2012 12:43:10 +0000 Subject: [PATCH] ENH: autoLayerDriver: use weighted smoothing --- .../autoHexMeshDriver/autoLayerDriver.C | 22 ++++++++++++------- .../autoHexMeshDriver/autoLayerDriverShrink.C | 22 +++++++++++++++---- .../autoLayerDriverTemplates.C | 17 ++++++++++++-- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index f70381471bd..c300cc53a71 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -2067,8 +2067,10 @@ Foam::label Foam::autoLayerDriver::checkAndUnmark // The important thing, however, is that when only a few faces // are disabled, their coordinates are printed, and this should be // the case - label nReportLocal = - min + label nReportLocal = nChanged; + if (nChangedTotal > nReportMax) + { + nReportLocal = min ( max(nChangedTotal / Pstream::nProcs(), 1), min @@ -2077,11 +2079,15 @@ Foam::label Foam::autoLayerDriver::checkAndUnmark max(nReportMax / Pstream::nProcs(), 1) ) ); + } - Pout<< "Checked mesh with layers. Disabled extrusion at " << endl; - for (label i=0; i < nReportLocal; i++) + if (nReportLocal) { - Pout<< " " << disabledFaceCentres[i] << endl; + Pout<< "Checked mesh with layers. Disabled extrusion at " << endl; + for (label i=0; i < nReportLocal; i++) + { + Pout<< " " << disabledFaceCentres[i] << endl; + } } label nReportTotal = returnReduce(nReportLocal, sumOp<label>()); @@ -2546,7 +2552,7 @@ void Foam::autoLayerDriver::addLayers false ), meshMover().pMesh(), - dimensionedScalar("pointMedialDist", dimless, 0.0) + dimensionedScalar("pointMedialDist", dimLength, 0.0) ); pointVectorField dispVec @@ -2561,7 +2567,7 @@ void Foam::autoLayerDriver::addLayers false ), meshMover().pMesh(), - dimensionedVector("dispVec", dimless, vector::zero) + dimensionedVector("dispVec", dimLength, vector::zero) ); pointScalarField medialRatio diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index 5731562575b..a35e2f2171b 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,6 +49,8 @@ void Foam::autoLayerDriver::sumWeights scalarField& invSumWeight ) const { + const pointField& pts = meshRefiner_.mesh().points(); + invSumWeight = 0; forAll(edges, edgeI) @@ -57,7 +59,18 @@ void Foam::autoLayerDriver::sumWeights { const edge& e = edges[edgeI]; //scalar eWeight = edgeWeights[edgeI]; - scalar eWeight = 1.0; + //scalar eWeight = 1.0; + + scalar eMag = max + ( + VSMALL, + mag + ( + pts[meshPoints[e[1]]] + - pts[meshPoints[e[0]]] + ) + ); + scalar eWeight = 1.0/eMag; invSumWeight[e[0]] += eWeight; invSumWeight[e[1]] += eWeight; @@ -799,6 +812,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo // Both end points of edge have very different nearest wall // point. Mark both points as medial axis points. const edge& e = edges[edgeI]; + const point eMid = e.centre(points); forAll(e, ep) { @@ -811,8 +825,8 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo ( pointData ( - points[pointI], - 0.0, + eMid, //points[pointI], + magSqr(points[pointI]-eMid), //0.0, pointI, // passive data vector::zero // passive data ) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverTemplates.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverTemplates.C index ddfe4ed4aff..afb66396c88 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverTemplates.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,6 +41,8 @@ void Foam::autoLayerDriver::averageNeighbours Field<Type>& average ) { + const pointField& pts = mesh.points(); + average = pTraits<Type>::zero; forAll(edges, edgeI) @@ -49,7 +51,18 @@ void Foam::autoLayerDriver::averageNeighbours { const edge& e = edges[edgeI]; //scalar eWeight = edgeWeights[edgeI]; - scalar eWeight = 1.0; + //scalar eWeight = 1.0; + scalar eMag = max + ( + VSMALL, + mag + ( + pts[meshPoints[e[1]]] + - pts[meshPoints[e[0]]] + ) + ); + scalar eWeight = 1.0/eMag; + label v0 = e[0]; label v1 = e[1]; -- GitLab