From 5707b20e5080b5af9f190466cf8cc2b295d7000b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 11 Aug 2016 17:55:40 +0200 Subject: [PATCH 01/15] DEFEATURE: remove unused hashSignedLabel, sortLabelledTri classes (issue #294) --- src/triSurface/Make/files | 5 - .../tools/hashSignedLabel/hashSignedLabel.H | 67 --------- .../tools/labelledTri/sortLabelledTri.C | 92 ------------ .../tools/labelledTri/sortLabelledTri.H | 135 ------------------ .../triSurface/interfaces/STL/writeSTL.C | 2 - 5 files changed, 301 deletions(-) delete mode 100644 src/triSurface/tools/hashSignedLabel/hashSignedLabel.H delete mode 100644 src/triSurface/tools/labelledTri/sortLabelledTri.C delete mode 100644 src/triSurface/tools/labelledTri/sortLabelledTri.H diff --git a/src/triSurface/Make/files b/src/triSurface/Make/files index d2384b3113..bb896bb088 100644 --- a/src/triSurface/Make/files +++ b/src/triSurface/Make/files @@ -1,6 +1,3 @@ -triSurfaceTools = triSurface/triSurfaceTools -geometricSurfacePatch = triSurface/geometricSurfacePatch - faceTriangulation/faceTriangulation.C meshTriangulation/meshTriangulation.C @@ -33,8 +30,6 @@ triSurface/geometricSurfacePatch/geometricSurfacePatch.C triSurface/surfacePatch/surfacePatch.C triSurface/surfacePatch/surfacePatchIOList.C -tools/labelledTri/sortLabelledTri.C - triSurfaceFields/triSurfaceFields.C LIB = $(FOAM_LIBBIN)/libtriSurface diff --git a/src/triSurface/tools/hashSignedLabel/hashSignedLabel.H b/src/triSurface/tools/hashSignedLabel/hashSignedLabel.H deleted file mode 100644 index 992a820290..0000000000 --- a/src/triSurface/tools/hashSignedLabel/hashSignedLabel.H +++ /dev/null @@ -1,67 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 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 . - -Class - Foam::hashSignedLabel - -Description - hash for signed integers (Hash\ only works for unsigned ints) - -\*---------------------------------------------------------------------------*/ - -#ifndef HashSignedLabel_H -#define HashSignedLabel_H - -#include "List.H" -#include "word.H" - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class hashSignedLabel Declaration -\*---------------------------------------------------------------------------*/ - -class hashSignedLabel -{ - -public: - - hashSignedLabel() - {} - - - label operator()(const label key, const label tableSize) const - { - return mag(key)%tableSize; - } -}; - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // - diff --git a/src/triSurface/tools/labelledTri/sortLabelledTri.C b/src/triSurface/tools/labelledTri/sortLabelledTri.C deleted file mode 100644 index 8ee98169f4..0000000000 --- a/src/triSurface/tools/labelledTri/sortLabelledTri.C +++ /dev/null @@ -1,92 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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 "sortLabelledTri.H" -#include "labelledTri.H" -#include "triSurface.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * Private Classes * * * * * * * * * * * * * * // - -inline bool surfAndLabel::less::operator() -( - const surfAndLabel& one, - const surfAndLabel& two -) const -{ - const triSurface& surf = *one.surfPtr_; - return surf[one.index_].region() < surf[two.index_].region(); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components -sortLabelledTri::sortLabelledTri(const triSurface& surf) -: - List(surf.size(), surfAndLabel(surf, -1)) -{ - - // Set the face label - forAll(surf, facei) - { - operator[](facei).index_ = facei; - } - - // Sort according to region number. - sort(*this, surfAndLabel::less()); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void sortLabelledTri::indices(labelList& newIndices) const -{ - newIndices.setSize(size()); - - forAll(newIndices, i) - { - newIndices[i] = operator[](i).index_; - } -} - - -labelList sortLabelledTri::indices() const -{ - labelList newIndices(size()); - indices(newIndices); - return newIndices; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/triSurface/tools/labelledTri/sortLabelledTri.H b/src/triSurface/tools/labelledTri/sortLabelledTri.H deleted file mode 100644 index 593ebe1eaf..0000000000 --- a/src/triSurface/tools/labelledTri/sortLabelledTri.H +++ /dev/null @@ -1,135 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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 . - -Class - Foam::sortLabelledTri - -Description - Helper class which when constructed with a triSurface - sorts the faces according to region number (or rather constructs a - mapping). - -SourceFiles - sortLabelledTri.C - -\*---------------------------------------------------------------------------*/ - -#ifndef sortLabelledTri_H -#define sortLabelledTri_H - -#include "labelList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -class sortLabelledTri; -class triSurface; - -/*---------------------------------------------------------------------------*\ - Class surfAndLabel Declaration -\*---------------------------------------------------------------------------*/ - -//- Hold surface and label -class surfAndLabel -{ - const triSurface* surfPtr_; - - label index_; - - // Private Classes - - //- Scalar comparison function used for sorting - class less - { - public: - - inline bool operator() - ( - const surfAndLabel& one, - const surfAndLabel& two - ) const; - }; - - -public: - - friend class sortLabelledTri; - - // Constructors - - //- Construct null - surfAndLabel() - : - surfPtr_(nullptr), - index_(-1) - {} - - //- Construct from surface and index - surfAndLabel(const triSurface& surf, const label index) - : - surfPtr_(&surf), - index_(index) - {} -}; - - -/*---------------------------------------------------------------------------*\ - Class sortLabelledTri Declaration -\*---------------------------------------------------------------------------*/ - -class sortLabelledTri -: - public List -{ - -public: - - // Constructors - - //- Construct from surface, sorting the faces according to patch - sortLabelledTri(const triSurface&); - - - // Member Functions - - // Access - - //- Set the labelList to those of sorted point indices - void indices(labelList&) const; - - //- Return the list of sorted point indices - labelList indices() const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/triSurface/triSurface/interfaces/STL/writeSTL.C b/src/triSurface/triSurface/interfaces/STL/writeSTL.C index ffa4eb826a..3532b006ab 100644 --- a/src/triSurface/triSurface/interfaces/STL/writeSTL.C +++ b/src/triSurface/triSurface/interfaces/STL/writeSTL.C @@ -26,8 +26,6 @@ License #include "triSurface.H" #include "STLtriangle.H" #include "primitivePatch.H" -#include "HashTable.H" -#include "hashSignedLabel.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // From 4dda4ad1977aad008ded393f08a7e2dee1d46bb0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 11 Aug 2016 19:35:22 +0200 Subject: [PATCH 02/15] DEFEATURE: remove unused meshTriangulation class (issue #294) --- src/triSurface/Make/files | 1 - .../meshTriangulation/meshTriangulation.C | 511 ------------------ .../meshTriangulation/meshTriangulation.H | 152 ------ 3 files changed, 664 deletions(-) delete mode 100644 src/triSurface/meshTriangulation/meshTriangulation.C delete mode 100644 src/triSurface/meshTriangulation/meshTriangulation.H diff --git a/src/triSurface/Make/files b/src/triSurface/Make/files index bb896bb088..933110a4c6 100644 --- a/src/triSurface/Make/files +++ b/src/triSurface/Make/files @@ -1,5 +1,4 @@ faceTriangulation/faceTriangulation.C -meshTriangulation/meshTriangulation.C triSurface/triSurface.C triSurface/triSurfaceAddressing.C diff --git a/src/triSurface/meshTriangulation/meshTriangulation.C b/src/triSurface/meshTriangulation/meshTriangulation.C deleted file mode 100644 index e0d8a753d0..0000000000 --- a/src/triSurface/meshTriangulation/meshTriangulation.C +++ /dev/null @@ -1,511 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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 "meshTriangulation.H" -#include "polyMesh.H" -#include "faceTriangulation.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -bool Foam::meshTriangulation::isInternalFace -( - const primitiveMesh& mesh, - const boolList& includedCell, - const label facei -) -{ - if (mesh.isInternalFace(facei)) - { - label own = mesh.faceOwner()[facei]; - label nei = mesh.faceNeighbour()[facei]; - - if (includedCell[own] && includedCell[nei]) - { - // Neighbouring cell will get included in subset - // as well so face is internal. - return true; - } - else - { - return false; - } - } - else - { - return false; - } -} - - -void Foam::meshTriangulation::getFaces -( - const primitiveMesh& mesh, - const boolList& includedCell, - boolList& faceIsCut, - label& nFaces, - label& nInternalFaces -) -{ - // All faces to be triangulated. - faceIsCut.setSize(mesh.nFaces()); - faceIsCut = false; - - nFaces = 0; - nInternalFaces = 0; - - forAll(includedCell, celli) - { - // Include faces of cut cells only. - if (includedCell[celli]) - { - const labelList& cFaces = mesh.cells()[celli]; - - forAll(cFaces, i) - { - label facei = cFaces[i]; - - if (!faceIsCut[facei]) - { - // First visit of face. - nFaces++; - faceIsCut[facei] = true; - - // See if would become internal or external face - if (isInternalFace(mesh, includedCell, facei)) - { - nInternalFaces++; - } - } - } - } - } - - Pout<< "Subset consists of " << nFaces << " faces out of " << mesh.nFaces() - << " of which " << nInternalFaces << " are internal" << endl; -} - - -void Foam::meshTriangulation::insertTriangles -( - const triFaceList& faceTris, - const label facei, - const label regionI, - const bool reverse, - - List& triangles, - label& triI -) -{ - // Copy triangles. Optionally reverse them - forAll(faceTris, i) - { - const triFace& f = faceTris[i]; - - labelledTri& tri = triangles[triI]; - - if (reverse) - { - tri[0] = f[0]; - tri[2] = f[1]; - tri[1] = f[2]; - } - else - { - tri[0] = f[0]; - tri[1] = f[1]; - tri[2] = f[2]; - } - - tri.region() = regionI; - - faceMap_[triI] = facei; - - triI++; - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Null constructor -Foam::meshTriangulation::meshTriangulation() -: - triSurface(), - nInternalFaces_(0), - faceMap_() -{} - - -// Construct from faces of cells -Foam::meshTriangulation::meshTriangulation -( - const polyMesh& mesh, - const label internalFacesPatch, - const boolList& includedCell, - const bool faceCentreDecomposition -) -: - triSurface(), - nInternalFaces_(0), - faceMap_() -{ - const faceList& faces = mesh.faces(); - const pointField& points = mesh.points(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - // All faces to be triangulated. - boolList faceIsCut; - label nFaces, nInternalFaces; - - getFaces - ( - mesh, - includedCell, - faceIsCut, - nFaces, - nInternalFaces - ); - - - // Find upper limit for number of triangles - // (can be less if triangulation fails) - label nTotTri = 0; - - if (faceCentreDecomposition) - { - forAll(faceIsCut, facei) - { - if (faceIsCut[facei]) - { - nTotTri += faces[facei].size(); - } - } - } - else - { - forAll(faceIsCut, facei) - { - if (faceIsCut[facei]) - { - nTotTri += faces[facei].nTriangles(points); - } - } - } - Pout<< "nTotTri : " << nTotTri << endl; - - - // Storage for new and old points (only for faceCentre decomposition; - // for triangulation uses only existing points) - pointField newPoints; - - if (faceCentreDecomposition) - { - newPoints.setSize(mesh.nPoints() + faces.size()); - forAll(mesh.points(), pointi) - { - newPoints[pointi] = mesh.points()[pointi]; - } - // Face centres - forAll(faces, facei) - { - newPoints[mesh.nPoints() + facei] = mesh.faceCentres()[facei]; - } - } - - // Storage for all triangles - List triangles(nTotTri); - faceMap_.setSize(nTotTri); - label triI = 0; - - - if (faceCentreDecomposition) - { - // Decomposition around face centre - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // Triangulate internal faces - forAll(faceIsCut, facei) - { - if (faceIsCut[facei] && isInternalFace(mesh, includedCell, facei)) - { - // Face was internal to the mesh and will be 'internal' to - // the surface. - - // Triangulate face - const face& f = faces[facei]; - - forAll(f, fp) - { - faceMap_[triI] = facei; - - triangles[triI++] = - labelledTri - ( - f[fp], - f.nextLabel(fp), - mesh.nPoints() + facei, // face centre - internalFacesPatch - ); - } - } - } - nInternalFaces_ = triI; - - - // Triangulate external faces - forAll(faceIsCut, facei) - { - if (faceIsCut[facei] && !isInternalFace(mesh, includedCell, facei)) - { - // Face will become outside of the surface. - - label patchi = -1; - bool reverse = false; - - if (mesh.isInternalFace(facei)) - { - patchi = internalFacesPatch; - - // Check orientation. Check which side of the face gets - // included (note: only one side is). - if (includedCell[mesh.faceOwner()[facei]]) - { - reverse = false; - } - else - { - reverse = true; - } - } - else - { - // Face was already outside so orientation ok. - - patchi = patches.whichPatch(facei); - - reverse = false; - } - - - // Triangulate face - const face& f = faces[facei]; - - if (reverse) - { - forAll(f, fp) - { - faceMap_[triI] = facei; - - triangles[triI++] = - labelledTri - ( - f.nextLabel(fp), - f[fp], - mesh.nPoints() + facei, // face centre - patchi - ); - } - } - else - { - forAll(f, fp) - { - faceMap_[triI] = facei; - - triangles[triI++] = - labelledTri - ( - f[fp], - f.nextLabel(fp), - mesh.nPoints() + facei, // face centre - patchi - ); - } - } - } - } - } - else - { - // Triangulation using existing vertices - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // Triangulate internal faces - forAll(faceIsCut, facei) - { - if (faceIsCut[facei] && isInternalFace(mesh, includedCell, facei)) - { - // Face was internal to the mesh and will be 'internal' to - // the surface. - - // Triangulate face. Fall back to naive triangulation if failed. - faceTriangulation faceTris(points, faces[facei], true); - - if (faceTris.empty()) - { - WarningInFunction - << "Could not find triangulation for face " << facei - << " vertices " << faces[facei] << " coords " - << IndirectList(points, faces[facei])() << endl; - } - else - { - // Copy triangles. Make them internalFacesPatch - insertTriangles - ( - faceTris, - facei, - internalFacesPatch, - false, // no reverse - - triangles, - triI - ); - } - } - } - nInternalFaces_ = triI; - - - // Triangulate external faces - forAll(faceIsCut, facei) - { - if (faceIsCut[facei] && !isInternalFace(mesh, includedCell, facei)) - { - // Face will become outside of the surface. - - label patchi = -1; - bool reverse = false; - - if (mesh.isInternalFace(facei)) - { - patchi = internalFacesPatch; - - // Check orientation. Check which side of the face gets - // included (note: only one side is). - if (includedCell[mesh.faceOwner()[facei]]) - { - reverse = false; - } - else - { - reverse = true; - } - } - else - { - // Face was already outside so orientation ok. - - patchi = patches.whichPatch(facei); - - reverse = false; - } - - // Triangulate face - faceTriangulation faceTris(points, faces[facei], true); - - if (faceTris.empty()) - { - WarningInFunction - << "Could not find triangulation for face " << facei - << " vertices " << faces[facei] << " coords " - << IndirectList(points, faces[facei])() << endl; - } - else - { - // Copy triangles. Optionally reverse them - insertTriangles - ( - faceTris, - facei, - patchi, - reverse, // whether to reverse - - triangles, - triI - ); - } - } - } - } - - // Shrink if necessary (because of invalid triangulations) - triangles.setSize(triI); - faceMap_.setSize(triI); - - Pout<< "nInternalFaces_:" << nInternalFaces_ << endl; - Pout<< "triangles:" << triangles.size() << endl; - - - geometricSurfacePatchList surfPatches(patches.size()); - - forAll(patches, patchi) - { - surfPatches[patchi] = - geometricSurfacePatch - ( - patches[patchi].physicalType(), - patches[patchi].name(), - patchi - ); - } - - // Create globally numbered tri surface - if (faceCentreDecomposition) - { - // Use newPoints (mesh points + face centres) - triSurface globalSurf(triangles, surfPatches, newPoints); - - // Create locally numbered tri surface - triSurface::operator= - ( - triSurface - ( - globalSurf.localFaces(), - surfPatches, - globalSurf.localPoints() - ) - ); - } - else - { - // Use mesh points - triSurface globalSurf(triangles, surfPatches, mesh.points()); - - // Create locally numbered tri surface - triSurface::operator= - ( - triSurface - ( - globalSurf.localFaces(), - surfPatches, - globalSurf.localPoints() - ) - ); - } -} - - -// ************************************************************************* // diff --git a/src/triSurface/meshTriangulation/meshTriangulation.H b/src/triSurface/meshTriangulation/meshTriangulation.H deleted file mode 100644 index c1f87bc0eb..0000000000 --- a/src/triSurface/meshTriangulation/meshTriangulation.H +++ /dev/null @@ -1,152 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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 . - -Class - Foam::meshTriangulation - -Description - Triangulation of mesh faces. Generates (multiply connected) trisurface. - - All patch faces keep their patchID as triangle region. - Internal faces get the supplied region number. - -SourceFiles - meshTriangulation.C - -\*---------------------------------------------------------------------------*/ - - -#ifndef meshTriangulation_H -#define meshTriangulation_H - -#include "triSurface.H" -#include "typeInfo.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declaration of classes -class polyMesh; -class primitiveMesh; - -/*---------------------------------------------------------------------------*\ - Class meshTriangulation Declaration -\*---------------------------------------------------------------------------*/ - -class meshTriangulation -: - public triSurface -{ - // Private data - - //- Number of triangles in this that are internal to the surface. - label nInternalFaces_; - - //- From triangle to mesh face - labelList faceMap_; - - // Private Member Functions - - //- Is face internal to the subset. - static bool isInternalFace - ( - const primitiveMesh&, - const boolList& includedCell, - const label facei - ); - - //- Find boundary faces of subset. - static void getFaces - ( - const primitiveMesh&, - const boolList& includedCell, - boolList& faceIsCut, - label& nFaces, - label& nInternalFaces - ); - - //- Add triangulation of face to triangles. Optionally reverse. - void insertTriangles - ( - const triFaceList&, - const label facei, - const label regionI, - const bool reverse, - - List& triangles, - label& triI - ); - - -public: - - ClassName("meshTriangulation"); - - - // Constructors - - //- Construct null - meshTriangulation(); - - //- Construct from selected mesh cell and region number to be used - // for triangles resulting from internal faces. (all boundary triangles - // get polyMesh patch id). - // faceCentreDecomposition = true : decomposition around face centre - // false : decomposition using - // existing vertices - meshTriangulation - ( - const polyMesh&, - const label internalFacesPatch, - const boolList& includedCell, - const bool faceCentreDecomposition = false - ); - - - // Member Functions - - //- Number of triangles in *this which are internal to the surface - label nInternalFaces() const - { - return nInternalFaces_; - } - - //- From triangle to mesh face - const labelList& faceMap() const - { - return faceMap_; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // From f81c7a036c774ddd14089cdc4ec4d7b55f355323 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 11 Aug 2016 21:22:21 +0200 Subject: [PATCH 03/15] DEFEATURE: remove unused surfacePatchIOList class (issue #294) --- etc/controlDict | 1 - src/triSurface/Make/files | 1 - .../surfacePatch/surfacePatchIOList.C | 160 ------------------ .../surfacePatch/surfacePatchIOList.H | 137 --------------- 4 files changed, 299 deletions(-) delete mode 100644 src/triSurface/triSurface/surfacePatch/surfacePatchIOList.C delete mode 100644 src/triSurface/triSurface/surfacePatch/surfacePatchIOList.H diff --git a/etc/controlDict b/etc/controlDict index 9726a8b1ae..1334cc1bb1 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -794,7 +794,6 @@ DebugSwitches surfaceIntersection 0; surfaceNormalFixedValue 0; surfacePatch 0; - surfacePatchIOList 0; surfaceScalarField 0; surfaceScalarField::Internal 0; surfaceSlipDisplacement 0; diff --git a/src/triSurface/Make/files b/src/triSurface/Make/files index 933110a4c6..b18854f946 100644 --- a/src/triSurface/Make/files +++ b/src/triSurface/Make/files @@ -27,7 +27,6 @@ $(interfaces)/NAS/readNAS.C triSurface/geometricSurfacePatch/geometricSurfacePatch.C triSurface/surfacePatch/surfacePatch.C -triSurface/surfacePatch/surfacePatchIOList.C triSurfaceFields/triSurfaceFields.C diff --git a/src/triSurface/triSurface/surfacePatch/surfacePatchIOList.C b/src/triSurface/triSurface/surfacePatch/surfacePatchIOList.C deleted file mode 100644 index be055638f6..0000000000 --- a/src/triSurface/triSurface/surfacePatch/surfacePatchIOList.C +++ /dev/null @@ -1,160 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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 "surfacePatchIOList.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -defineTypeNameAndDebug(surfacePatchIOList, 0); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from IOObject -Foam::surfacePatchIOList::surfacePatchIOList -( - const IOobject& io -) -: - surfacePatchList(), - regIOobject(io) -{ - Foam::string functionName = - "surfacePatchIOList::surfacePatchIOList" - "(const IOobject& io)"; - - - if - ( - readOpt() == IOobject::MUST_READ - || readOpt() == IOobject::MUST_READ_IF_MODIFIED - ) - { - // Warn for MUST_READ_IF_MODIFIED - warnNoRereading(); - - surfacePatchList& patches = *this; - - // read polyPatchList - Istream& is = readStream(typeName); - - PtrList patchEntries(is); - patches.setSize(patchEntries.size()); - - label facei = 0; - - forAll(patches, patchi) - { - const dictionary& dict = patchEntries[patchi].dict(); - - label patchSize = readLabel(dict.lookup("nFaces")); - label startFacei = readLabel(dict.lookup("startFace")); - - patches[patchi] = - surfacePatch - ( - word(dict.lookup("geometricType")), - patchEntries[patchi].keyword(), - patchSize, - startFacei, - patchi - ); - - - if (startFacei != facei) - { - FatalErrorInFunction - << "Patches are not ordered. Start of patch " << patchi - << " does not correspond to sum of preceding patches." - << endl - << "while reading " << io.objectPath() - << exit(FatalError); - } - - facei += patchSize; - } - - // Check state of IOstream - is.check(functionName.c_str()); - - close(); - } -} - -// Construct from IOObject -Foam::surfacePatchIOList::surfacePatchIOList -( - const IOobject& io, - const surfacePatchList& patches -) -: - surfacePatchList(patches), - regIOobject(io) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::surfacePatchIOList::~surfacePatchIOList() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - -// writeData member function required by regIOobject -bool Foam::surfacePatchIOList::writeData(Ostream& os) const -{ - os << *this; - return os.good(); -} - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - -Foam::Ostream& Foam::operator<<(Ostream& os, const surfacePatchIOList& patches) -{ - os << patches.size() << nl << token::BEGIN_LIST; - - forAll(patches, patchi) - { - patches[patchi].writeDict(os); - } - - os << token::END_LIST; - - return os; -} - - -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - -// ************************************************************************* // diff --git a/src/triSurface/triSurface/surfacePatch/surfacePatchIOList.H b/src/triSurface/triSurface/surfacePatch/surfacePatchIOList.H deleted file mode 100644 index 5dca93d6f0..0000000000 --- a/src/triSurface/triSurface/surfacePatch/surfacePatchIOList.H +++ /dev/null @@ -1,137 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 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 . - -Class - Foam::surfacePatchIOList - -Description - IOobject for a surfacePatchList - -SourceFiles - surfacePatchIOList.C - -\*---------------------------------------------------------------------------*/ - -#ifndef surfacePatchIOList_H -#define surfacePatchIOList_H - -#include "surfacePatchList.H" -#include "regIOobject.H" -#include "faceList.H" -#include "className.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declaration of friend functions and operators - -class surfacePatchIOList; - -Ostream& operator<<(Ostream&, const surfacePatchIOList&); - - -/*---------------------------------------------------------------------------*\ - Class surfacePatchIOList Declaration -\*---------------------------------------------------------------------------*/ - -class surfacePatchIOList -: - public surfacePatchList, - public regIOobject -{ - // Private data - - - // Private Member Functions - - //- Disallow default bitwise copy construct - surfacePatchIOList(const surfacePatchIOList&); - - //- Disallow default bitwise assignment - void operator=(const surfacePatchIOList&); - - -public: - - //- Runtime type information - TypeName("surfacePatchIOList"); - - - // Static data members - - //- Static data someStaticData - - // Constructors - - //- Construct from IOobject - explicit surfacePatchIOList(const IOobject& io); - - //- Construct from IOobject - surfacePatchIOList(const IOobject& io, const surfacePatchList&); - - //- Destructor - ~surfacePatchIOList(); - - - // Member Functions - - //- writeData member function required by regIOobject - bool writeData(Ostream&) const; - - //- Is object global - virtual bool global() const - { - return true; - } - //- Return complete path + object name if the file exists - // either in the case/processor or case otherwise null - virtual fileName filePath() const - { - return globalFilePath(); - } - - // IOstream Operators - - friend Ostream& operator<<(Ostream&, const surfacePatchIOList&); -}; - - -//- Template function for obtaining global status -template<> -inline bool typeGlobal() -{ - return true; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // From c7a291aca85635097f58dde058b16c97d0636c4e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 11 Aug 2016 19:38:29 +0200 Subject: [PATCH 04/15] STYLE: relocate faceTriangulation, labelPairLookup into meshTools (issue #294) - were in triSurface, but only actually used within meshTools --- src/meshTools/Make/files | 1 + .../triSurface/containers}/labelPairLookup.H | 0 .../triSurface/faceTriangulation/faceTriangulation.C | 0 .../triSurface/faceTriangulation/faceTriangulation.H | 0 src/triSurface/Make/files | 2 -- 5 files changed, 1 insertion(+), 2 deletions(-) rename src/{triSurface/tools/labelPair => meshTools/triSurface/containers}/labelPairLookup.H (100%) rename src/{ => meshTools}/triSurface/faceTriangulation/faceTriangulation.C (100%) rename src/{ => meshTools}/triSurface/faceTriangulation/faceTriangulation.H (100%) diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index c187a63d80..d6dd0ec9f2 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -149,6 +149,7 @@ momentOfInertia/momentOfInertia.C surfaceSets/surfaceSets.C +triSurface/faceTriangulation/faceTriangulation.C triSurface/orientedSurface/orientedSurface.C triSurface/surfaceLocation/surfaceLocation.C diff --git a/src/triSurface/tools/labelPair/labelPairLookup.H b/src/meshTools/triSurface/containers/labelPairLookup.H similarity index 100% rename from src/triSurface/tools/labelPair/labelPairLookup.H rename to src/meshTools/triSurface/containers/labelPairLookup.H diff --git a/src/triSurface/faceTriangulation/faceTriangulation.C b/src/meshTools/triSurface/faceTriangulation/faceTriangulation.C similarity index 100% rename from src/triSurface/faceTriangulation/faceTriangulation.C rename to src/meshTools/triSurface/faceTriangulation/faceTriangulation.C diff --git a/src/triSurface/faceTriangulation/faceTriangulation.H b/src/meshTools/triSurface/faceTriangulation/faceTriangulation.H similarity index 100% rename from src/triSurface/faceTriangulation/faceTriangulation.H rename to src/meshTools/triSurface/faceTriangulation/faceTriangulation.H diff --git a/src/triSurface/Make/files b/src/triSurface/Make/files index b18854f946..fab067d63e 100644 --- a/src/triSurface/Make/files +++ b/src/triSurface/Make/files @@ -1,5 +1,3 @@ -faceTriangulation/faceTriangulation.C - triSurface/triSurface.C triSurface/triSurfaceAddressing.C triSurface/stitchTriangles.C From b012e1c7385fd2c9454dad0cbfa370bacfc11235 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 11 Aug 2016 20:00:09 +0200 Subject: [PATCH 05/15] STYLE: relocate labelledTri into OpenFOAM/meshes/meshShapes (issue #294) - was originally in triSurface, but is used in multiple other places --- .../meshes/meshShapes}/labelledTri/labelledTri.H | 0 .../meshes/meshShapes}/labelledTri/labelledTriI.H | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/{triSurface/tools => OpenFOAM/meshes/meshShapes}/labelledTri/labelledTri.H (100%) rename src/{triSurface/tools => OpenFOAM/meshes/meshShapes}/labelledTri/labelledTriI.H (100%) diff --git a/src/triSurface/tools/labelledTri/labelledTri.H b/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTri.H similarity index 100% rename from src/triSurface/tools/labelledTri/labelledTri.H rename to src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTri.H diff --git a/src/triSurface/tools/labelledTri/labelledTriI.H b/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H similarity index 100% rename from src/triSurface/tools/labelledTri/labelledTriI.H rename to src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H From d1d453f06515d1c9be0acd2c9f3fad7cee62a841 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 11 Aug 2016 21:44:14 +0200 Subject: [PATCH 06/15] STYLE: relocate surfZoneIdentifier into OpenFOAM/meshes/Identifiers (issue #294) Note that since these actually act more like 'patches' (ie, contiguous addressing) it might be reasonable to rename as surfPatchIdentifier / surfacePatchIdentifier --- src/OpenFOAM/Make/files | 1 + .../Identifiers/surface}/surfZoneIdentifier.C | 17 +++++++---------- .../Identifiers/surface}/surfZoneIdentifier.H | 3 +-- .../surface}/surfZoneIdentifierList.H | 0 src/surfMesh/Make/files | 1 - 5 files changed, 9 insertions(+), 13 deletions(-) rename src/{surfMesh/surfZone/surfZoneIdentifier => OpenFOAM/meshes/Identifiers/surface}/surfZoneIdentifier.C (90%) rename src/{surfMesh/surfZone/surfZoneIdentifier => OpenFOAM/meshes/Identifiers/surface}/surfZoneIdentifier.H (98%) rename src/{surfMesh/surfZone/surfZoneIdentifier => OpenFOAM/meshes/Identifiers/surface}/surfZoneIdentifierList.H (100%) diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 8b6be8d895..a1650b7ee3 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -418,6 +418,7 @@ $(cellShape)/cellShapeIOList.C meshes/Identifiers/patch/patchIdentifier.C meshes/Identifiers/patch/coupleGroupIdentifier.C +meshes/Identifiers/surface/surfZoneIdentifier.C meshes/MeshObject/meshObject.C diff --git a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C similarity index 90% rename from src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C rename to src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C index 0495598657..88c3f2d788 100644 --- a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C @@ -97,14 +97,11 @@ Foam::surfZoneIdentifier::~surfZoneIdentifier() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - void Foam::surfZoneIdentifier::write(Ostream& os) const { if (geometricType_.size()) { - os.writeKeyword("geometricType") - << geometricType_ - << token::END_STATEMENT << nl; + os.writeEntry("geometricType", geometricType_); } } @@ -112,7 +109,6 @@ void Foam::surfZoneIdentifier::write(Ostream& os) const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // needed for list output - bool Foam::surfZoneIdentifier::operator!= ( const surfZoneIdentifier& rhs @@ -129,8 +125,9 @@ bool Foam::surfZoneIdentifier::operator== { return ( - name() == rhs.name() - && geometricType() == rhs.geometricType() + (index() == rhs.index()) + && (name() == rhs.name()) + && (geometricType() == rhs.geometricType()) ); } @@ -139,8 +136,7 @@ bool Foam::surfZoneIdentifier::operator== Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj) { - is >> obj.name_ - >> obj.geometricType_; + is >> obj.name_ >> obj.geometricType_; return is; } @@ -148,7 +144,8 @@ Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj) Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj) { - os << obj.name_ << ' ' << obj.geometricType_; + // newlines to separate, since that is what triSurface currently expects + os << nl << obj.name_ << nl << obj.geometricType_; os.check("Ostream& operator<<(Ostream&, const surfZoneIdentifier&)"); return os; diff --git a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H similarity index 98% rename from src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H rename to src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H index 3f6a1b9a77..ff75b56afa 100644 --- a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H @@ -40,7 +40,6 @@ SourceFiles #include "word.H" #include "label.H" -#include "typeInfo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,7 +55,7 @@ Istream& operator>>(Istream&, surfZoneIdentifier&); Ostream& operator<<(Ostream&, const surfZoneIdentifier&); /*---------------------------------------------------------------------------*\ - Class surfZoneIdentifier Declaration + Class surfZoneIdentifier Declaration \*---------------------------------------------------------------------------*/ class surfZoneIdentifier diff --git a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifierList.H b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifierList.H similarity index 100% rename from src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifierList.H rename to src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifierList.H diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index 7b23b07ac6..dbf28d1e55 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -1,6 +1,5 @@ surfZone/surfZone/surfZone.C surfZone/surfZone/surfZoneIOList.C -surfZone/surfZoneIdentifier/surfZoneIdentifier.C MeshedSurfaceAllocator/MeshedSurfaceIOAllocator.C From 4fbb59de5d61e15405a7848b66b5f352c17d89f5 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 12 Nov 2016 20:54:50 +0100 Subject: [PATCH 07/15] STYLE: rename MeshedSurfaceProxyCore -> MeshedSurfaceProxys for consistency - it doesn't actually contain 'core' code, but rather various instances of MeshedSurfaceProxy. --- src/surfMesh/Make/files | 2 +- src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.H | 2 +- .../{MeshedSurfaceProxyCore.C => MeshedSurfaceProxys.C} | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) rename src/surfMesh/MeshedSurfaceProxy/{MeshedSurfaceProxyCore.C => MeshedSurfaceProxys.C} (95%) diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index dbf28d1e55..b03fdc7e77 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -7,7 +7,7 @@ MeshedSurface/MeshedSurfaceCore.C MeshedSurface/MeshedSurfaces.C UnsortedMeshedSurface/UnsortedMeshedSurfaces.C -MeshedSurfaceProxy/MeshedSurfaceProxyCore.C +MeshedSurfaceProxy/MeshedSurfaceProxys.C mergedSurf/mergedSurf.C diff --git a/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.H b/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.H index 9dc548aba4..870949e09d 100644 --- a/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.H +++ b/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.H @@ -30,7 +30,7 @@ Description SourceFiles MeshedSurfaceProxy.C - MeshedSurfaceProxyCore.C + MeshedSurfaceProxys.C \*---------------------------------------------------------------------------*/ diff --git a/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxyCore.C b/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxys.C similarity index 95% rename from src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxyCore.C rename to src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxys.C index 76750a14d4..1fd0bfa7e4 100644 --- a/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxyCore.C +++ b/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxys.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,6 +46,7 @@ namespace Foam makeSurface(MeshedSurfaceProxy, face) makeSurface(MeshedSurfaceProxy, triFace) +makeSurface(MeshedSurfaceProxy, labelledTri) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // From a32eff4e59f7dac7bc719284c1300b6e0e2b4fb4 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 12 Nov 2016 20:57:48 +0100 Subject: [PATCH 08/15] ENH: ensure face, triFace and labelledTri all work consistently (issue #294) - triFace() now initialized with '-1', which makes it behave equivalently to face(label). - supply default region=0 for some labelledTri constructors. This allows labelledTri to work more like a triFace and makes it easier to use in templated methods and eases conversion from triFace to a labelledTri. - labelledTri(const labelUList&) can now be used when converting from a face. It can have 3 values (use default region) or 4 values (with region). - face, triFace, labelledTri now all support construction with initializer lists. This can be useful for certain types of code. Eg, triFace f1{a, b, c}; face f2{a, b, c}; labelledTri f3{a, b, c}; Work without ambiguity. Also useful for templated methods: FaceType f{remap[a], remap[b], remap[c]}; --- applications/test/faces/Make/files | 3 + applications/test/faces/Make/options | 0 applications/test/faces/Test-faces.C | 84 +++++++++++++++++++ src/OpenFOAM/meshes/meshShapes/face/face.H | 4 +- src/OpenFOAM/meshes/meshShapes/face/faceI.H | 4 +- .../meshes/meshShapes/face/faceListFwd.H | 2 - .../meshShapes/labelledTri/labelledTri.H | 38 +++++---- .../meshShapes/labelledTri/labelledTriI.H | 44 +++++++++- .../meshes/meshShapes/triFace/triFace.H | 7 +- .../meshes/meshShapes/triFace/triFaceI.H | 8 ++ 10 files changed, 168 insertions(+), 26 deletions(-) create mode 100644 applications/test/faces/Make/files create mode 100644 applications/test/faces/Make/options create mode 100644 applications/test/faces/Test-faces.C diff --git a/applications/test/faces/Make/files b/applications/test/faces/Make/files new file mode 100644 index 0000000000..8418bb2b93 --- /dev/null +++ b/applications/test/faces/Make/files @@ -0,0 +1,3 @@ +Test-faces.C + +EXE = $(FOAM_USER_APPBIN)/Test-faces diff --git a/applications/test/faces/Make/options b/applications/test/faces/Make/options new file mode 100644 index 0000000000..e69de29bb2 diff --git a/applications/test/faces/Test-faces.C b/applications/test/faces/Test-faces.C new file mode 100644 index 0000000000..823f33e3e1 --- /dev/null +++ b/applications/test/faces/Test-faces.C @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 . + +Application + Test-faces + +Description + Simple tests for various faces + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "labelledTri.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + face f1{ 1, 2, 3, 4 }; + Info<< "face:" << f1 << nl; + + triFace t1{ 1, 2, 3 }; + Info<< "triFace:" << t1 << nl; + + f1 = t1; + Info<< "face:" << f1 << nl; + + f1 = t1.triFaceFace(); + Info<< "face:" << f1 << nl; + + // expect these to fail + FatalError.throwExceptions(); + try + { + labelledTri l1{ 1, 2, 3, 10, 24 }; + Info<< "labelled:" << l1 << nl; + } + catch (Foam::error& err) + { + WarningInFunction + << "Caught FatalError " << err << nl << endl; + } + FatalError.dontThrowExceptions(); + + labelledTri l2{ 1, 2, 3 }; + Info<< "labelled:" << l2 << nl; + + labelledTri l3{ 1, 2, 3, 10 }; + Info<< "labelled:" << l3 << nl; + + t1.flip(); + l3.flip(); + + Info<< "flip:" << t1 << nl; + Info<< "flip:" << l3 << nl; + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 0504145ade..62ae47b3d0 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -155,8 +155,8 @@ public: //- Construct from list of labels explicit inline face(const labelUList&); - //- Construct from list of labels - explicit inline face(const labelList&); + //- Construct from an initializer list of labels + explicit inline face(std::initializer_list