diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C index 3e87fbd7d51f5ac94f16c203fe97cfd3c25b6ff7..1375099a4b8d469d6df5a4df392fb95e70bd0607 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.C +++ b/src/dynamicMesh/motionSmoother/motionSmoother.C @@ -872,10 +872,8 @@ void Foam::motionSmoother::correctBoundaryConditions } -Foam::tmp<Foam::scalarField> Foam::motionSmoother::movePoints -( - pointField& newPoints -) + +void Foam::motionSmoother::modifyMotionPoints(pointField& newPoints) const { // Correct for 2-D motion if (twoDCorrector_.required()) @@ -892,8 +890,8 @@ Foam::tmp<Foam::scalarField> Foam::motionSmoother::movePoints const pointField& oldPoints = mesh_.points(); const edgeList& edges = mesh_.edges(); - const labelList& neIndices = twoDCorrector().normalEdgeIndices(); - const vector& pn = twoDCorrector().planeNormal(); + const labelList& neIndices = twoDCorrector_.normalEdgeIndices(); + const vector& pn = twoDCorrector_.planeNormal(); forAll(neIndices, i) { @@ -915,19 +913,19 @@ Foam::tmp<Foam::scalarField> Foam::motionSmoother::movePoints if (debug) { - Pout<< "motionSmoother::movePoints : testing sync of newPoints." + Pout<< "motionSmoother::modifyMotionPoints : testing sync of newPoints." << endl; testSyncPositions(newPoints, 1e-6*mesh_.bounds().mag()); } +} - // Move actual mesh points. Make sure to delete tetBasePtIs so it - // gets rebuilt. - mesh_.clearAdditionalGeom(); - tmp<scalarField> tsweptVol = mesh_.movePoints(newPoints); +void Foam::motionSmoother::movePoints() +{ + // Make sure to clear out tetPtIs since used in checks (sometimes, should + // really check) + mesh_.clearAdditionalGeom(); pp_.movePoints(mesh_.points()); - - return tsweptVol; } @@ -983,6 +981,79 @@ bool Foam::motionSmoother::scaleMesh } +Foam::tmp<Foam::pointField> Foam::motionSmoother::curPoints() const +{ + // Set newPoints as old + scale*displacement + + // Create overall displacement with same b.c.s as displacement_ + wordList actualPatchTypes; + { + const pointBoundaryMesh& pbm = displacement_.mesh().boundary(); + actualPatchTypes.setSize(pbm.size()); + forAll(pbm, patchI) + { + actualPatchTypes[patchI] = pbm[patchI].type(); + } + } + + wordList actualPatchFieldTypes; + { + const pointVectorField::GeometricBoundaryField& pfld = + displacement_.boundaryField(); + actualPatchFieldTypes.setSize(pfld.size()); + forAll(pfld, patchI) + { + if (isA<fixedValuePointPatchField<vector> >(pfld[patchI])) + { + // Get rid of funny + actualPatchFieldTypes[patchI] = + fixedValuePointPatchField<vector>::typeName; + } + else + { + actualPatchFieldTypes[patchI] = pfld[patchI].type(); + } + } + } + + pointVectorField totalDisplacement + ( + IOobject + ( + "totalDisplacement", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + scale_*displacement_, + actualPatchFieldTypes, + actualPatchTypes + ); + correctBoundaryConditions(totalDisplacement); + + if (debug) + { + Pout<< "scaleMesh : testing sync of totalDisplacement" << endl; + testSyncField + ( + totalDisplacement, + maxMagEqOp(), + vector::zero, // null value + 1e-6*mesh_.bounds().mag() + ); + } + + tmp<pointField> tnewPoints(oldPoints_ + totalDisplacement.internalField()); + + // Correct for 2-D motion + modifyMotionPoints(tnewPoints()); + + return tnewPoints; +} + + bool Foam::motionSmoother::scaleMesh ( labelList& checkFaces, @@ -1052,60 +1123,18 @@ bool Foam::motionSmoother::scaleMesh vector::zero // null value ); - // Set newPoints as old + scale*displacement - pointField newPoints; - { - // Create overall displacement with same b.c.s as displacement_ - wordList actualPatchTypes; - { - const pointBoundaryMesh& pbm = displacement_.mesh().boundary(); - actualPatchTypes.setSize(pbm.size()); - forAll(pbm, patchI) - { - actualPatchTypes[patchI] = pbm[patchI].type(); - } - } - - pointVectorField totalDisplacement - ( - IOobject - ( - "totalDisplacement", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - scale_*displacement_, - displacement_.boundaryField().types(), - actualPatchTypes - ); - correctBoundaryConditions(totalDisplacement); - - if (debug) - { - Pout<< "scaleMesh : testing sync of totalDisplacement" << endl; - testSyncField - ( - totalDisplacement, - maxMagEqOp(), - vector::zero, // null value - 1e-6*mesh_.bounds().mag() - ); - } - - newPoints = oldPoints_ + totalDisplacement.internalField(); - } - Info<< "Moving mesh using displacement scaling :" << " min:" << gMin(scale_.internalField()) << " max:" << gMax(scale_.internalField()) << endl; + // Get points using current displacement and scale. Optionally 2D corrected. + pointField newPoints(curPoints()); + + // Move. No need to do 2D correction since curPoints already done that. + mesh_.movePoints(newPoints); + movePoints(); - // Move - movePoints(newPoints); // Check. Returns parallel number of incorrect faces. faceSet wrongFaces(mesh_, "wrongFaces", mesh_.nFaces()/100+100); diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.H b/src/dynamicMesh/motionSmoother/motionSmoother.H index fff07c4b94a8a73c1490ef084024a93bb73f8a3b..33bb2835e2186f8c504dcbabfc5719c0e6cd799f 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.H +++ b/src/dynamicMesh/motionSmoother/motionSmoother.H @@ -403,9 +403,11 @@ public: // bc's. void correctBoundaryConditions(pointVectorField&) const; - //- Move mesh. Does 2D correction (modifies passed pointField) and - // polyMesh::movePoints. Returns swept volumes. - tmp<scalarField> movePoints(pointField&); + //- Apply optional point constraint (2d correction) + void modifyMotionPoints(pointField& newPoints) const; + + //- Get the current points (oldPoints+scale*displacement) + tmp<pointField> curPoints() const; //- Set the errorReduction (by how much to scale the displacement // at error locations) parameter. Returns the old value. @@ -446,9 +448,14 @@ public: const label nAllow = 0 ); - //- Update topology + + //- Update for new mesh geometry + void movePoints(); + + //- Update for new mesh topology void updateMesh(); + //- Check mesh with mesh settings in dict. Collects incorrect faces // in set. Returns true if one or more faces in error. // Parallel ok. diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 316d376defd8aa15a79fcc8b931c9e16393df682..1dcafdec3ee132d501cc521de1334dccb5c94a43 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -3522,7 +3522,9 @@ void Foam::autoLayerDriver::addLayers } // Reset mesh points and start again - meshMover().movePoints(oldPoints); + mesh.movePoints(oldPoints); + // Update meshmover for change of mesh geometry + meshMover().movePoints(); meshMover().correct(); diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index 58464ad495419029a2f756b4f7b7b55f0f0adcfb..72c62020a0a0f2f9a654cf2d38de2f98a1482b27 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -58,7 +58,9 @@ class layerParameters; class autoLayerDriver { - // Static data members +public: + + // Public data types //- Extrusion controls enum extrudeMode @@ -69,6 +71,7 @@ class autoLayerDriver /*!< faces locally */ }; +private: // Private classes diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index 328b4fd86a13dd472583808a434c525f4d98e9fe..3349a5f8b6b5386f91b1025fa6e6b825c8df8fbc 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -1756,19 +1756,10 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance Info<< "Writing wanted-displacement mesh (possibly illegal) to " << meshRefiner_.timeName() << endl; pointField oldPoints(mesh.points()); - vectorField totalDisp - ( - meshMover.scale().internalField() - * displacement.internalField() - ); - syncTools::syncPointList - ( - mesh, - totalDisp, - minMagSqrEqOp<point>(), - vector(GREAT, GREAT, GREAT) - ); - meshMover.movePoints((mesh.points()+totalDisp)()); + + meshRefiner_.mesh().movePoints(meshMover.curPoints()); + // Warn meshMover for changed geometry + meshMover.movePoints(); // Above move will have changed the instance only on the points (which // is correct). @@ -1791,7 +1782,11 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance dispVec.write(); medialDist.write(); medialRatio.write(); - meshMover.movePoints(oldPoints); + + // Move mesh back + meshRefiner_.mesh().movePoints(oldPoints); + // Warn meshMover for changed geometry + meshMover.movePoints(); }