From 0b99b5af1a561eb178d8b258e615c3843c999548 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 13 Nov 2018 12:14:13 +0000 Subject: [PATCH] sampling: Removed deprecated isoSurfaceCell --- .../foamyHexMeshBackgroundMesh/Make/options | 3 - .../foamyHexMeshBackgroundMesh.C | 5 +- src/sampling/Make/files | 2 - .../distanceSurface/distanceSurface.C | 51 +- .../distanceSurface/distanceSurface.H | 18 +- .../distanceSurfaceTemplates.C | 50 +- .../sampledSurface/isoSurface/isoSurface.H | 6 - .../isoSurface/isoSurfaceCell.C | 1589 ----------------- .../isoSurface/isoSurfaceCell.H | 352 ---- .../isoSurface/isoSurfaceCellTemplates.C | 566 ------ .../isoSurface/sampledIsoSurfaceCell.C | 368 ---- .../isoSurface/sampledIsoSurfaceCell.H | 246 --- .../sampledIsoSurfaceCellTemplates.C | 88 - .../sampledCuttingPlane/sampledCuttingPlane.C | 9 - .../sampledCuttingPlane/sampledCuttingPlane.H | 4 - 15 files changed, 25 insertions(+), 3332 deletions(-) delete mode 100644 src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C delete mode 100644 src/sampling/sampledSurface/isoSurface/isoSurfaceCell.H delete mode 100644 src/sampling/sampledSurface/isoSurface/isoSurfaceCellTemplates.C delete mode 100644 src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C delete mode 100644 src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.H delete mode 100644 src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCellTemplates.C diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/Make/options index 701bea14b7..61661dcca2 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/Make/options +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/Make/options @@ -20,9 +20,6 @@ EXE_INC = \ EXE_LIBS = \ $(CGAL_LIBS) \ - -lboost_thread \ - -lmpfr \ - -lgmp \ -lconformalVoronoiMesh \ -ldecompositionMethods /* -L$(FOAM_LIBBIN)/dummy -lscotchDecomp */ \ -ltriSurface \ diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C index 7cec301dc7..a360396873 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C @@ -41,7 +41,7 @@ Description #include "cellShape.H" #include "cellModeller.H" #include "DynamicField.H" -#include "isoSurfaceCell.H" +#include "isoSurface.H" #include "vtkSurfaceWriter.H" #include "syncTools.H" @@ -716,9 +716,8 @@ int main(int argc, char *argv[]) } } - isoSurfaceCell iso + isoSurface iso ( - fvm, cellDistance, pointDistance, 0, // distance, diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 31fe506ae5..5c61d41776 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -25,8 +25,6 @@ sampledSurface/sampledPatchInternalField/sampledPatchInternalField.C sampledSurface/sampledPlane/sampledPlane.C sampledSurface/isoSurface/isoSurface.C sampledSurface/isoSurface/sampledIsoSurface.C -sampledSurface/isoSurface/isoSurfaceCell.C -sampledSurface/isoSurface/sampledIsoSurfaceCell.C sampledSurface/distanceSurface/distanceSurface.C sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C sampledSurface/sampledSurface/sampledSurface.C diff --git a/src/sampling/sampledSurface/distanceSurface/distanceSurface.C b/src/sampling/sampledSurface/distanceSurface/distanceSurface.C index b11bb8d8f1..ec0bd17127 100644 --- a/src/sampling/sampledSurface/distanceSurface/distanceSurface.C +++ b/src/sampling/sampledSurface/distanceSurface/distanceSurface.C @@ -50,7 +50,6 @@ void Foam::distanceSurface::createGeometry() // Clear any stored topologies facesPtr_.clear(); - isoSurfCellPtr_.clear(); isoSurfPtr_.clear(); // Clear derived data @@ -265,33 +264,16 @@ void Foam::distanceSurface::createGeometry() //- Direct from cell field and point field. - if (cell_) - { - isoSurfCellPtr_.reset + isoSurfPtr_.reset + ( + new isoSurface ( - new isoSurfaceCell - ( - fvm, - cellDistance, - pointDistance_, - distance_, - regularise_ - ) - ); - } - else - { - isoSurfPtr_.reset - ( - new isoSurface - ( - cellDistance, - pointDistance_, - distance_, - regularise_ - ) - ); - } + cellDistance, + pointDistance_, + distance_, + regularise_ + ) + ); if (debug) { @@ -330,24 +312,13 @@ Foam::distanceSurface::distanceSurface ), distance_(readScalar(dict.lookup("distance"))), signed_(readBool(dict.lookup("signed"))), - cell_(dict.lookupOrDefault("cell", true)), regularise_(dict.lookupOrDefault("regularise", true)), average_(dict.lookupOrDefault("average", false)), zoneKey_(keyType::null), needsUpdate_(true), - isoSurfCellPtr_(nullptr), isoSurfPtr_(nullptr), facesPtr_(nullptr) -{ -// dict.readIfPresent("zone", zoneKey_); -// -// if (debug && zoneKey_.size() && mesh.cellZones().findZoneID(zoneKey_) < 0) -// { -// Info<< "cellZone " << zoneKey_ -// << " not found - using entire mesh" << endl; -// } -} - +{} Foam::distanceSurface::distanceSurface @@ -384,12 +355,10 @@ Foam::distanceSurface::distanceSurface ), distance_(distance), signed_(signedDistance), - cell_(cell), regularise_(regularise), average_(average), zoneKey_(keyType::null), needsUpdate_(true), - isoSurfCellPtr_(nullptr), isoSurfPtr_(nullptr), facesPtr_(nullptr) {} diff --git a/src/sampling/sampledSurface/distanceSurface/distanceSurface.H b/src/sampling/sampledSurface/distanceSurface/distanceSurface.H index 1f2ce0832d..206cb72931 100644 --- a/src/sampling/sampledSurface/distanceSurface/distanceSurface.H +++ b/src/sampling/sampledSurface/distanceSurface/distanceSurface.H @@ -27,8 +27,6 @@ Class Description A sampledSurface defined by a distance to a surface. - Uses either isoSurfaceCell or isoSurface. - SourceFiles distanceSurface.C @@ -39,7 +37,6 @@ SourceFiles #include "sampledSurface.H" #include "searchableSurface.H" -#include "isoSurfaceCell.H" #include "isoSurface.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -66,9 +63,6 @@ class distanceSurface //- Signed distance const bool signed_; - //- Whether to use isoSurfaceCell or isoSurface - const bool cell_; - //- Whether to coarsen const Switch regularise_; @@ -88,9 +82,6 @@ class distanceSurface //- Distance to points scalarField pointDistance_; - //- Constructed iso surface - autoPtr isoSurfCellPtr_; - //- Constructed iso surface autoPtr isoSurfPtr_; @@ -191,14 +182,7 @@ public: const triSurface& surface() const { - if (cell_) - { - return isoSurfCellPtr_(); - } - else - { - return isoSurfPtr_(); - } + return isoSurfPtr_(); } //- Sample field on surface diff --git a/src/sampling/sampledSurface/distanceSurface/distanceSurfaceTemplates.C b/src/sampling/sampledSurface/distanceSurface/distanceSurfaceTemplates.C index 6dcf8fa95d..6d2bdff1d0 100644 --- a/src/sampling/sampledSurface/distanceSurface/distanceSurfaceTemplates.C +++ b/src/sampling/sampledSurface/distanceSurface/distanceSurfaceTemplates.C @@ -37,20 +37,10 @@ Foam::distanceSurface::sampleField const GeometricField& vField ) const { - if (cell_) - { - return tmp> - ( - new Field(vField, isoSurfCellPtr_().meshCells()) - ); - } - else - { - return tmp> - ( - new Field(vField, isoSurfPtr_().meshCells()) - ); - } + return tmp> + ( + new Field(vField, isoSurfPtr_().meshCells()) + ); } @@ -72,31 +62,15 @@ Foam::distanceSurface::interpolateField volPointInterpolation::New(fvm).interpolate(volFld) ); - // Sample. - if (cell_) - { - return isoSurfCellPtr_().interpolate + return isoSurfPtr_().interpolate + ( ( - ( - average_ - ? pointAverage(pointFld())() - : volFld - ), - pointFld() - ); - } - else - { - return isoSurfPtr_().interpolate - ( - ( - average_ - ? pointAverage(pointFld())() - : volFld - ), - pointFld() - ); - } + average_ + ? pointAverage(pointFld())() + : volFld + ), + pointFld() + ); } diff --git a/src/sampling/sampledSurface/isoSurface/isoSurface.H b/src/sampling/sampledSurface/isoSurface/isoSurface.H index 0225493678..4fce24834b 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurface.H +++ b/src/sampling/sampledSurface/isoSurface/isoSurface.H @@ -248,8 +248,6 @@ class isoSurface ) const; - //- Note: cannot use simpler isoSurfaceCell::generateTriPoints since - // the need here to sometimes pass in remote 'snappedPoints' template void generateTriPoints ( @@ -345,10 +343,6 @@ class isoSurface public: - //- Declare friendship with isoSurfaceCell to share some functionality - friend class isoSurfaceCell; - - //- Runtime type information TypeName("isoSurface"); diff --git a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C deleted file mode 100644 index 748e19b6fb..0000000000 --- a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C +++ /dev/null @@ -1,1589 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation - \\/ 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 "isoSurfaceCell.H" -#include "dictionary.H" -#include "polyMesh.H" -#include "mergePoints.H" -#include "tetMatcher.H" -#include "syncTools.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(isoSurfaceCell, 0); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -Foam::scalar Foam::isoSurfaceCell::isoFraction -( - const scalar s0, - const scalar s1 -) const -{ - scalar d = s1-s0; - - if (mag(d) > vSmall) - { - return (iso_-s0)/d; - } - else - { - return -1.0; - } -} - - -bool Foam::isoSurfaceCell::isTriCut -( - const triFace& tri, - const scalarField& pointValues -) const -{ - bool aLower = (pointValues[tri[0]] < iso_); - bool bLower = (pointValues[tri[1]] < iso_); - bool cLower = (pointValues[tri[2]] < iso_); - - return !(aLower == bLower && aLower == cLower); -} - - -Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType -( - const PackedBoolList& isTet, - const scalarField& cellValues, - const scalarField& pointValues, - const label celli -) const -{ - const cell& cFaces = mesh_.cells()[celli]; - - if (isTet.get(celli) == 1) - { - forAll(cFaces, cFacei) - { - const face& f = mesh_.faces()[cFaces[cFacei]]; - - for (label fp = 1; fp < f.size() - 1; fp++) - { - triFace tri(f[0], f[fp], f[f.fcIndex(fp)]); - - if (isTriCut(tri, pointValues)) - { - return CUT; - } - } - } - return NOTCUT; - } - else - { - bool cellLower = (cellValues[celli] < iso_); - - // First check if there is any cut in cell - bool edgeCut = false; - - forAll(cFaces, cFacei) - { - label facei = cFaces[cFacei]; - const face& f = mesh_.faces()[facei]; - - // Check pyramids cut - forAll(f, fp) - { - if ((pointValues[f[fp]] < iso_) != cellLower) - { - edgeCut = true; - break; - } - } - - if (edgeCut) - { - break; - } - - const label fp0 = mesh_.tetBasePtIs()[facei]; - label fp = f.fcIndex(fp0); - for (label i = 2; i < f.size(); i++) - { - label nextFp = f.fcIndex(fp); - - if (isTriCut(triFace(f[fp0], f[fp], f[nextFp]), pointValues)) - { - edgeCut = true; - break; - } - - fp = nextFp; - } - - if (edgeCut) - { - break; - } - } - - if (edgeCut) - { - // Count actual cuts (expensive since addressing needed) - // Note: not needed if you don't want to preserve maxima/minima - // centred around cellcentre. In that case just always return CUT - - const labelList& cPoints = mesh_.cellPoints(celli); - - label nPyrCuts = 0; - - forAll(cPoints, i) - { - if ((pointValues[cPoints[i]] < iso_) != cellLower) - { - nPyrCuts++; - } - } - - if (nPyrCuts == cPoints.size()) - { - return SPHERE; - } - else - { - return CUT; - } - } - else - { - return NOTCUT; - } - } -} - - -void Foam::isoSurfaceCell::calcCutTypes -( - const PackedBoolList& isTet, - const scalarField& cVals, - const scalarField& pVals -) -{ - cellCutType_.setSize(mesh_.nCells()); - nCutCells_ = 0; - forAll(mesh_.cells(), celli) - { - cellCutType_[celli] = calcCutType(isTet, cVals, pVals, celli); - - if (cellCutType_[celli] == CUT) - { - nCutCells_++; - } - } - - if (debug) - { - Pout<< "isoSurfaceCell : detected " << nCutCells_ - << " candidate cut cells." << endl; - } -} - - -Foam::labelPair Foam::isoSurfaceCell::findCommonPoints -( - const labelledTri& tri0, - const labelledTri& tri1 -) -{ - labelPair common(-1, -1); - - label fp0 = 0; - label fp1 = findIndex(tri1, tri0[fp0]); - - if (fp1 == -1) - { - fp0 = 1; - fp1 = findIndex(tri1, tri0[fp0]); - } - - if (fp1 != -1) - { - // So tri0[fp0] is tri1[fp1] - - // Find next common point - label fp0p1 = tri0.fcIndex(fp0); - label fp1p1 = tri1.fcIndex(fp1); - label fp1m1 = tri1.rcIndex(fp1); - - if (tri0[fp0p1] == tri1[fp1p1] || tri0[fp0p1] == tri1[fp1m1]) - { - common[0] = tri0[fp0]; - common[1] = tri0[fp0p1]; - } - } - return common; -} - - -Foam::point Foam::isoSurfaceCell::calcCentre(const triSurface& s) -{ - vector sum = Zero; - - forAll(s, i) - { - sum += s[i].centre(s.points()); - } - return sum/s.size(); -} - - -Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface -( - const label celli, - pointField& localPoints, - DynamicList& localTris -) const -{ - pointIndexHit info(false, Zero, localTris.size()); - - if (localTris.size() == 1) - { - const labelledTri& tri = localTris[0]; - info.setPoint(tri.centre(localPoints)); - info.setHit(); - } - else if (localTris.size() == 2) - { - // Check if the two triangles share an edge. - const labelledTri& tri0 = localTris[0]; - const labelledTri& tri1 = localTris[1]; - - labelPair shared = findCommonPoints(tri0, tri1); - - if (shared[0] != -1) - { - const vector n0 = tri0.normal(localPoints); - const vector n1 = tri1.normal(localPoints); - - if ((n0 & n1) < 0) - { - // Too big an angle. Do not simplify. - } - else - { - info.setPoint - ( - 0.5 - * ( - tri0.centre(localPoints) - + tri1.centre(localPoints) - ) - ); - info.setHit(); - } - } - } - else if (localTris.size()) - { - // Check if single region. Rare situation. - triSurface surf - ( - localTris, - geometricSurfacePatchList(0), - localPoints, - true - ); - localTris.clearStorage(); - - labelList faceZone; - label nZones = surf.markZones - ( - boolList(surf.nEdges(), false), - faceZone - ); - - if (nZones == 1) - { - // Check that all normals make a decent angle - scalar minCos = great; - const vector& n0 = surf.faceNormals()[0]; - for (label i = 1; i < surf.size(); i++) - { - scalar cosAngle = (n0 & surf.faceNormals()[i]); - if (cosAngle < minCos) - { - minCos = cosAngle; - } - } - - if (minCos > 0) - { - info.setPoint(calcCentre(surf)); - info.setHit(); - } - } - } - - return info; -} - - -void Foam::isoSurfaceCell::calcSnappedCc -( - const PackedBoolList& isTet, - const scalarField& cVals, - const scalarField& pVals, - - DynamicList& snappedPoints, - labelList& snappedCc -) const -{ - const pointField& cc = mesh_.cellCentres(); - const pointField& pts = mesh_.points(); - - snappedCc.setSize(mesh_.nCells()); - snappedCc = -1; - - // Work arrays - DynamicList localPoints(64); - DynamicList localTris(64); - Map