From 709b92d907cd26bd1df8844493bca09d036e8b79 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 3 Jun 2014 14:42:39 +0100 Subject: [PATCH] ENH: mesh motion updates --- .../manipulation/checkMesh/checkGeometry.C | 32 ++-- .../constraint/wedge/wedgePointPatch.C | 20 +- .../constraint/wedge/wedgePointPatch.H | 18 +- .../mapPolyMesh/faceMapper/faceMapper.C | 16 +- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 13 +- .../constraint/wedge/wedgePolyPatch.C | 122 ++++++++---- .../constraint/wedge/wedgePolyPatch.H | 26 ++- .../layerAdditionRemoval/addCellLayer.C | 118 +++++++----- .../layerAdditionRemoval/removeCellLayer.C | 90 +++++---- .../layerAdditionRemoval/setLayerPairing.C | 48 +++-- .../displacementLayeredMotionMotionSolver.C | 178 ++++++++++++------ .../twoDPointCorrector/twoDPointCorrector.C | 134 +++++++------ .../twoDPointCorrector/twoDPointCorrector.H | 16 +- .../sixDoFRigidBodyMotionIO.C | 14 +- 14 files changed, 534 insertions(+), 311 deletions(-) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 32e260f5fa..8677f08c65 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -19,7 +19,7 @@ Foam::label Foam::findOppositeWedge { const polyBoundaryMesh& patches = mesh.boundaryMesh(); - scalar wppCosAngle = wpp.centreNormal()&wpp.patchNormal(); + scalar wppCosAngle = wpp.cosAngle(); forAll(patches, patchI) { @@ -30,13 +30,11 @@ Foam::label Foam::findOppositeWedge && isA(patches[patchI]) ) { - const wedgePolyPatch& pp = refCast - ( - patches[patchI] - ); + const wedgePolyPatch& pp = + refCast(patches[patchI]); // Calculate (cos of) angle to wpp (not pp!) centre normal - scalar ppCosAngle = wpp.centreNormal()&pp.patchNormal(); + scalar ppCosAngle = wpp.centreNormal() & pp.n(); if ( @@ -73,12 +71,10 @@ bool Foam::checkWedges { if (patches[patchI].size() && isA(patches[patchI])) { - const wedgePolyPatch& pp = refCast - ( - patches[patchI] - ); + const wedgePolyPatch& pp = + refCast(patches[patchI]); - scalar wedgeAngle = acos(pp.centreNormal()&pp.patchNormal()); + scalar wedgeAngle = acos(pp.cosAngle()); if (report) { @@ -100,10 +96,8 @@ bool Foam::checkWedges return true; } - const wedgePolyPatch& opp = refCast - ( - patches[oppositePatchI] - ); + const wedgePolyPatch& opp = + refCast(patches[oppositePatchI]); if (mag(opp.axis() & pp.axis()) < (1-1e-3)) @@ -140,7 +134,7 @@ bool Foam::checkWedges forAll(pp.meshPoints(), i) { const point& pt = p[pp.meshPoints()[i]]; - scalar d = mag((pt-p0) & pp.patchNormal()); + scalar d = mag((pt - p0) & pp.n()); if (d > sqrt(SMALL)) { @@ -385,10 +379,8 @@ bool Foam::checkCoupledPoints { if (patches[patchI].coupled()) { - const coupledPolyPatch& cpp = refCast - ( - patches[patchI] - ); + const coupledPolyPatch& cpp = + refCast(patches[patchI]); if (cpp.owner()) { diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.C index c335911c55..56dba9971a 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.C +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.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-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,9 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Description - Wedge front and back plane patch - \*---------------------------------------------------------------------------*/ #include "wedgePointPatch.H" @@ -46,6 +43,19 @@ namespace Foam } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::wedgePointPatch::wedgePointPatch +( + const polyPatch& patch, + const pointBoundaryMesh& bm +) +: + facePointPatch(patch, bm), + wedgePolyPatch_(refCast(patch)) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::wedgePointPatch::applyConstraint @@ -54,7 +64,7 @@ void Foam::wedgePointPatch::applyConstraint pointConstraint& pc ) const { - pc.applyConstraint(pointNormals()[pointi]); + pc.applyConstraint(wedgePolyPatch_.n()); } diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H index a62acfaa90..0a437c3218 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/wedge/wedgePointPatch.H @@ -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-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -51,6 +51,11 @@ class wedgePointPatch : public facePointPatch { + // Private data + + //- Local reference cast into the symmetryPlane patch + const wedgePolyPatch& wedgePolyPatch_; + public: @@ -65,10 +70,7 @@ public: ( const polyPatch& patch, const pointBoundaryMesh& bm - ) - : - facePointPatch(patch, bm) - {} + ); // Member Functions @@ -85,6 +87,12 @@ public: const label pointi, pointConstraint& ) const; + + //- Return symmetry plane normal + const vector& n() const + { + return wedgePolyPatch_.n(); + } }; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.C index e95fbe95f9..803e523d41 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.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-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,9 +28,6 @@ License #include "polyMesh.H" #include "mapPolyMesh.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::faceMapper::calcAddressing() const @@ -168,7 +165,7 @@ void Foam::faceMapper::calcAddressing() const } - // Grab inserted points (for them the size of addressing is still zero) + // Grab inserted faces (for them the size of addressing is still zero) insertedFaceLabelsPtr_ = new labelList(mesh_.nFaces()); labelList& insertedFaces = *insertedFaceLabelsPtr_; @@ -413,13 +410,4 @@ const Foam::labelList& Foam::faceMapper::oldPatchSizes() const } -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index cd70eb3999..668a595321 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -921,7 +921,6 @@ Foam::polyMesh::cellTree() const } -// Add boundary patches. Constructor helper void Foam::polyMesh::addPatches ( const List& p, @@ -968,7 +967,6 @@ void Foam::polyMesh::addPatches } -// Add mesh zones. Constructor helper void Foam::polyMesh::addZones ( const List& pz, @@ -1084,7 +1082,6 @@ const Foam::labelList& Foam::polyMesh::faceNeighbour() const } -// Return old mesh motion points const Foam::pointField& Foam::polyMesh::oldPoints() const { if (oldPointsPtr_.empty()) @@ -1129,11 +1126,14 @@ Foam::tmp Foam::polyMesh::movePoints points_ = newPoints; + bool moveError = false; if (debug) { // Check mesh motion if (checkMeshMotion(points_, true)) { + moveError = true; + Info<< "tmp polyMesh::movePoints" << "(const pointField&) : " << "Moving the mesh with given points will " @@ -1176,6 +1176,12 @@ Foam::tmp Foam::polyMesh::movePoints const_cast(time()).functionObjects().movePoints(*this); + + if (debug && moveError) + { + write(); + } + return sweptVols; } @@ -1219,7 +1225,6 @@ Foam::label& Foam::polyMesh::comm() } -// Remove all files and some subdirs (eg, sets) void Foam::polyMesh::removeFiles(const fileName& instanceDir) const { fileName meshFilesPath = thisDb().time().path()/instanceDir/meshDir(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C index b7c9783cb9..e12d22e5a5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/wedge/wedgePolyPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,56 +40,90 @@ namespace Foam // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -void Foam::wedgePolyPatch::initTransforms() +void Foam::wedgePolyPatch::calcGeometry(PstreamBuffers&) { - if (size() > 0) + if (axis_ != vector::rootMax) { - const pointField& points = this->points(); + return; + } - patchNormal_ = operator[](0).normal(points); - patchNormal_ /= mag(patchNormal_); + if (returnReduce(size(), sumOp