From 41aa6d637c8752b38fc43f689559f66cd638bcf5 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 14 Mar 2013 10:01:05 +0000 Subject: [PATCH 1/3] ENH: movingCone: add cuttingPlane to show off moving mesh sampling --- .../movingCone/system/controlDict | 4 ++ .../movingCone/system/cuttingPlane | 38 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tutorials/incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane diff --git a/tutorials/incompressible/pimpleDyMFoam/movingCone/system/controlDict b/tutorials/incompressible/pimpleDyMFoam/movingCone/system/controlDict index d30e569e91..9b931e305a 100644 --- a/tutorials/incompressible/pimpleDyMFoam/movingCone/system/controlDict +++ b/tutorials/incompressible/pimpleDyMFoam/movingCone/system/controlDict @@ -49,5 +49,9 @@ adjustTimeStep no; maxCo 0.2; +functions +{ + #include "cuttingPlane" +} // ************************************************************************* // diff --git a/tutorials/incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane b/tutorials/incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane new file mode 100644 index 0000000000..ba124eb087 --- /dev/null +++ b/tutorials/incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.2.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +cuttingPlane +{ + type surfaces; + functionObjectLibs ("libsampling.so"); + + outputControl outputTime; + + surfaceFormat vtk; + fields ( p U ); + + interpolationScheme cellPoint; + + surfaces + ( + zNormal + { + type cuttingPlane; + planeType pointAndNormal; + pointAndNormalDict + { + basePoint (0 0 0); + normalVector (0 0 1); + } + interpolate true; + } + ); +} + + +// ************************************************************************* // From 0c58d7eaf5f21ae5a88c99ce0cf80c3b8e19339b Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 14 Mar 2013 11:25:16 +0000 Subject: [PATCH 2/3] BUG: syncTools: swap cell centres as positions --- .../polyMesh/polyMeshCheck/polyMeshTools.C | 6 +-- .../meshes/polyMesh/syncTools/syncTools.C | 38 +++++++++++++++++++ .../meshes/polyMesh/syncTools/syncTools.H | 17 ++++++--- .../searchableSurfaceToFaceZone.C | 4 +- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshTools.C b/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshTools.C index fc0739e79f..55f6a90767 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshTools.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshTools.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -60,7 +60,7 @@ Foam::tmp Foam::polyMeshTools::faceOrthogonality // Coupled faces pointField neighbourCc; - syncTools::swapBoundaryCellList(mesh, cc, neighbourCc); + syncTools::swapBoundaryCellPositions(mesh, cc, neighbourCc); forAll(pbm, patchI) { @@ -123,7 +123,7 @@ Foam::tmp Foam::polyMeshTools::faceSkewness // (i.e. treat as if mirror cell on other side) pointField neighbourCc; - syncTools::swapBoundaryCellList(mesh, cellCtrs, neighbourCc); + syncTools::swapBoundaryCellPositions(mesh, cellCtrs, neighbourCc); forAll(pbm, patchI) { diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C index 2d007ad9fa..4326d43f38 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C @@ -27,6 +27,44 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +void Foam::syncTools::swapBoundaryCellPositions +( + const polyMesh& mesh, + const UList& cellData, + List& neighbourCellData +) +{ + if (cellData.size() != mesh.nCells()) + { + FatalErrorIn + ( + "syncTools::swapBoundaryCellPositions" + "(const polyMesh&, const UList&, List&)" + ) << "Number of cell values " << cellData.size() + << " is not equal to the number of cells in the mesh " + << mesh.nCells() << abort(FatalError); + } + + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + label nBnd = mesh.nFaces()-mesh.nInternalFaces(); + + neighbourCellData.setSize(nBnd); + + forAll(patches, patchI) + { + const polyPatch& pp = patches[patchI]; + const labelUList& faceCells = pp.faceCells(); + forAll(faceCells, i) + { + label bFaceI = pp.start()+i-mesh.nInternalFaces(); + neighbourCellData[bFaceI] = cellData[faceCells[i]]; + } + } + syncTools::swapBoundaryFacePositions(mesh, neighbourCellData); +} + + Foam::PackedBoolList Foam::syncTools::getMasterPoints(const polyMesh& mesh) { PackedBoolList isMasterPoint(mesh.nPoints()); diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H index d089d04f9e..cb1484b3b0 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H @@ -442,18 +442,17 @@ public: } //- Swap coupled positions. - template static void swapBoundaryFacePositions ( const polyMesh& mesh, - UList& l + UList& l ) { syncBoundaryFaceList ( mesh, l, - eqOp(), + eqOp(), mapDistribute::transformPosition() ); } @@ -490,6 +489,14 @@ public: List& neighbourCellData ); + //- Swap to obtain neighbour cell positions for all boundary faces + static void swapBoundaryCellPositions + ( + const polyMesh& mesh, + const UList& cellData, + List& neighbourCellData + ); + // Sparse versions //- Synchronize values on selected points. @@ -531,11 +538,11 @@ public: } //- Synchronize locations on selected edges. - template + template static void syncEdgePositions ( const polyMesh& mesh, - EdgeMap& l, + EdgeMap& l, const CombineOp& cop ) { diff --git a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C index b91ec33b82..039e14555f 100644 --- a/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C +++ b/src/meshTools/sets/faceZoneSources/searchableSurfaceToFaceZone/searchableSurfaceToFaceZone.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -120,7 +120,7 @@ void Foam::searchableSurfaceToFaceZone::applyToSet // Boundary faces vectorField nbrCellCentres; - syncTools::swapBoundaryCellList(mesh_, cc, nbrCellCentres); + syncTools::swapBoundaryCellPositions(mesh_, cc, nbrCellCentres); const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); From 48d8fa9e5c047f074553b8c211179beda53076a4 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 14 Mar 2013 11:47:46 +0000 Subject: [PATCH 3/3] STYLE: cuttingPlane: correct version number --- .../incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane b/tutorials/incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane index ba124eb087..29b42ee983 100644 --- a/tutorials/incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane +++ b/tutorials/incompressible/pimpleDyMFoam/movingCone/system/cuttingPlane @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 2.2.0 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/