From e07309eea3ee8ee86a3a8986aaf5957c25cd461a Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 14 Sep 2012 13:30:59 +0100 Subject: [PATCH] BUG: layering: disable mesh movement if extrusion disabled --- .../autoHexMeshDriver/autoLayerDriver.C | 89 ++++++++++- .../autoHexMeshDriver/autoLayerDriver.H | 14 +- .../autoHexMeshDriver/autoLayerDriverShrink.C | 139 +++++++++++++++--- .../autoHexMeshDriver/autoSnapDriver.C | 23 ++- .../autoHexMeshDriver/autoSnapDriverFeature.C | 70 +++++++++ .../layerParameters/layerParameters.C | 2 +- .../layerParameters/layerParameters.H | 4 + .../meshRefinementProblemCells.C | 13 +- 8 files changed, 316 insertions(+), 38 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index abe3bc487c..26b4fb0187 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -48,6 +48,10 @@ Description #include "globalIndex.H" #include "DynamicField.H" #include "PatchTools.H" +#include "slipPointPatchFields.H" +#include "fixedValuePointPatchFields.H" +#include "calculatedPointPatchFields.H" +#include "cyclicSlipPointPatchFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -71,7 +75,7 @@ void Foam::autoLayerDriver::dumpDisplacement ) { OFstream dispStr(prefix + "_disp.obj"); - Info<< "Writing all displacements to " << dispStr.name() << nl << endl; + Info<< "Writing all displacements to " << dispStr.name() << endl; label vertI = 0; @@ -87,7 +91,7 @@ void Foam::autoLayerDriver::dumpDisplacement OFstream illStr(prefix + "_illegal.obj"); - Info<< "Writing invalid displacements to " << illStr.name() << nl << endl; + Info<< "Writing invalid displacements to " << illStr.name() << endl; vertI = 0; @@ -801,6 +805,81 @@ void Foam::autoLayerDriver::setNumLayers } +// Construct pointVectorField with correct boundary conditions for adding +// layers +Foam::tmp +Foam::autoLayerDriver::makeLayerDisplacementField +( + const pointMesh& pMesh, + const labelList& numLayers +) +{ + // Construct displacement field. + const pointBoundaryMesh& pointPatches = pMesh.boundary(); + + wordList patchFieldTypes + ( + pointPatches.size(), + slipPointPatchVectorField::typeName + ); + + forAll(numLayers, patchI) + { + // 0 layers: do not allow lslip so fixedValue 0 + // >0 layers: fixedValue which gets adapted + if (numLayers[patchI] >= 0) + { + patchFieldTypes[patchI] = fixedValuePointPatchVectorField::typeName; + } + } + + forAll(pointPatches, patchI) + { + if (isA(pointPatches[patchI])) + { + patchFieldTypes[patchI] = calculatedPointPatchVectorField::typeName; + } + else if (isA(pointPatches[patchI])) + { + patchFieldTypes[patchI] = cyclicSlipPointPatchVectorField::typeName; + } + } + + +//Pout<< "*** makeLayerDisplacementField : boundary conditions:" << endl; +//forAll(patchFieldTypes, patchI) +//{ +// Pout<< "\t" << patchI << " name:" << pointPatches[patchI].name() +// << " type:" << patchFieldTypes[patchI] +// << " nLayers:" << numLayers[patchI] +// << endl; +//} + + const polyMesh& mesh = pMesh(); + + // Note: time().timeName() instead of meshRefinement::timeName() since + // postprocessable field. + tmp tfld + ( + new pointVectorField + ( + IOobject + ( + "pointDisplacement", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + pMesh, + dimensionedVector("displacement", dimLength, vector::zero), + patchFieldTypes + ) + ); + return tfld; +} + + void Foam::autoLayerDriver::growNoExtrusion ( const indirectPrimitivePatch& pp, @@ -2392,10 +2471,10 @@ void Foam::autoLayerDriver::addLayers mesh, pp(), patchIDs, - meshRefinement::makeDisplacementField + makeLayerDisplacementField ( pointMesh::New(mesh), - patchIDs + layerParams.numLayers() ), motionDict ) @@ -3186,7 +3265,7 @@ void Foam::autoLayerDriver::doLayers // Merge coplanar boundary faces mergePatchFacesUndo(layerParams, motionDict); - // Per patch the number of layers (0 if no layer) + // Per patch the number of layers (-1 or 0 if no layer) const labelList& numLayers = layerParams.numLayers(); // Patches that need to get a layer diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index cb720dc64f..d36d15a4cb 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -195,6 +195,19 @@ class autoLayerDriver List& extrudeStatus ) const; + //- Helper function to make a pointVectorField with correct + // bcs for layer addition: + // - numLayers > 0 : fixedValue + // - numLayers == 0 : fixedValue (always zero) + // - processor : calculated (so free to move) + // - cyclic/wedge/symmetry : slip + // - other : slip + static tmp makeLayerDisplacementField + ( + const pointMesh& pMesh, + const labelList& numLayers + ); + //- Grow no-extrusion layer. void growNoExtrusion ( @@ -444,7 +457,6 @@ class autoLayerDriver const PackedBoolList& isMasterEdge, const labelList& meshEdges, const scalar minCosLayerTermination, - scalarField& field, List& extrudeStatus, pointField& patchDisp, labelList& patchNLayers diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index 35133f062d..58725470e1 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -99,6 +99,76 @@ void Foam::autoLayerDriver::sumWeights // Smooth field on moving patch +//void Foam::autoLayerDriver::smoothField +//( +// const motionSmoother& meshMover, +// const PackedBoolList& isMasterEdge, +// const labelList& meshEdges, +// const scalarField& fieldMin, +// const label nSmoothDisp, +// scalarField& field +//) const +//{ +// const indirectPrimitivePatch& pp = meshMover.patch(); +// const edgeList& edges = pp.edges(); +// const labelList& meshPoints = pp.meshPoints(); +// +// scalarField invSumWeight(pp.nPoints()); +// sumWeights +// ( +// isMasterEdge, +// meshEdges, +// meshPoints, +// edges, +// invSumWeight +// ); +// +// // Get smoothly varying patch field. +// Info<< "shrinkMeshDistance : Smoothing field ..." << endl; +// +// for (label iter = 0; iter < nSmoothDisp; iter++) +// { +// scalarField average(pp.nPoints()); +// averageNeighbours +// ( +// meshMover.mesh(), +// isMasterEdge, +// meshEdges, +// meshPoints, +// pp.edges(), +// invSumWeight, +// field, +// average +// ); +// +// // Transfer to field +// forAll(field, pointI) +// { +// //full smoothing neighbours + point value +// average[pointI] = 0.5*(field[pointI]+average[pointI]); +// +// // perform monotonic smoothing +// if +// ( +// average[pointI] < field[pointI] +// && average[pointI] >= fieldMin[pointI] +// ) +// { +// field[pointI] = average[pointI]; +// } +// } +// +// // Do residual calculation every so often. +// if ((iter % 10) == 0) +// { +// Info<< " Iteration " << iter << " residual " +// << gSum(mag(field-average)) +// /returnReduce(average.size(), sumOp