From 7cf232ceece1807d8dd1694fd81dd1bc9165f3c8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 14 Sep 2018 09:19:32 +0200 Subject: [PATCH] STYLE: split up cuttingPlane source files --- src/sampling/Make/files | 4 +- src/sampling/surface/cutting/cuttingPlane.C | 181 +++++++++ .../{cuttingPlane => cutting}/cuttingPlane.H | 24 +- .../surface/cutting/cuttingPlaneCuts.C | 196 ++++++++++ .../cuttingPlaneWalk.C} | 355 +----------------- 5 files changed, 411 insertions(+), 349 deletions(-) create mode 100644 src/sampling/surface/cutting/cuttingPlane.C rename src/sampling/surface/{cuttingPlane => cutting}/cuttingPlane.H (90%) create mode 100644 src/sampling/surface/cutting/cuttingPlaneCuts.C rename src/sampling/surface/{cuttingPlane/cuttingPlane.C => cutting/cuttingPlaneWalk.C} (57%) diff --git a/src/sampling/Make/files b/src/sampling/Make/files index a97d335f17..7d3665f9a4 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -19,7 +19,9 @@ sampledSet/uniform/uniformSet.C sampledSet/array/arraySet.C sampledSet/shortestPath/shortestPathSet.C -surface/cuttingPlane/cuttingPlane.C +surface/cutting/cuttingPlane.C +surface/cutting/cuttingPlaneCuts.C +surface/cutting/cuttingPlaneWalk.C surface/distanceSurface/distanceSurface.C surface/isoSurface/isoSurface.C surface/isoSurface/isoSurfaceCell.C diff --git a/src/sampling/surface/cutting/cuttingPlane.C b/src/sampling/surface/cutting/cuttingPlane.C new file mode 100644 index 0000000000..46f41212d9 --- /dev/null +++ b/src/sampling/surface/cutting/cuttingPlane.C @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "cuttingPlane.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +int Foam::cuttingPlane::debug(Foam::debug::debugSwitch("cuttingPlane", 0)); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cuttingPlane::cuttingPlane(const plane& pln) +: + plane(pln) +{} + + +Foam::cuttingPlane::cuttingPlane +( + const plane& pln, + const primitiveMesh& mesh, + const bool triangulate, + const bitSet& cellIdLabels +) +: + plane(pln) +{ + performCut(mesh, triangulate, cellIdLabels); +} + + +Foam::cuttingPlane::cuttingPlane +( + const plane& pln, + const primitiveMesh& mesh, + const bool triangulate, + bitSet&& cellIdLabels +) +: + plane(pln) +{ + performCut(mesh, triangulate, cellIdLabels); +} + + +Foam::cuttingPlane::cuttingPlane +( + const plane& pln, + const primitiveMesh& mesh, + const bool triangulate, + const labelUList& cellIdLabels +) +: + plane(pln) +{ + performCut(mesh, triangulate, cellIdLabels); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::cuttingPlane::performCut +( + const primitiveMesh& mesh, + const bool triangulate, + bitSet&& cellIdLabels +) +{ + MeshStorage::clear(); + meshCells_.clear(); + + // Pre-populate with restriction + bitSet cellCuts(std::move(cellIdLabels)); + + if (cellCuts.size()) + { + cellCuts.resize(mesh.nCells()); + } + + // For each mesh point, the encoded side (0,1,2) of the plane + PackedList<2> sides; + + // Determine cells that are (likely) cut + // - some ambiguity when plane is exactly between cells + const label nFaceCuts = calcCellCuts(mesh, sides, cellCuts); + + // Find closed loop from cell cuts + walkCellCuts(mesh, cellCuts, sides, triangulate, nFaceCuts); +} + + +void Foam::cuttingPlane::performCut +( + const primitiveMesh& mesh, + const bool triangulate, + const bitSet& cellIdLabels +) +{ + bitSet subsetCells(cellIdLabels); + + performCut(mesh, triangulate, std::move(subsetCells)); +} + + +void Foam::cuttingPlane::performCut +( + const primitiveMesh& mesh, + const bool triangulate, + const labelUList& cellIdLabels +) +{ + bitSet subsetCells; + + if (notNull(cellIdLabels)) + { + // Pre-populate with restriction + subsetCells.resize(mesh.nCells()); + subsetCells.set(cellIdLabels); + } + + performCut(mesh, triangulate, std::move(subsetCells)); +} + + +void Foam::cuttingPlane::remapFaces(const labelUList& faceMap) +{ + if (notNull(faceMap) && !faceMap.empty()) + { + MeshStorage::remapFaces(faceMap); + + List