diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index f3feb5b835..f479698744 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -112,6 +112,7 @@ Foam::UList Foam::UList::operator[](const labelRange& range) return UList(&(this->v_[slice.start()]), slice.size()); // SubList } + template const Foam::UList Foam::UList::operator[](const labelRange& range) const { @@ -132,6 +133,7 @@ Foam::UList Foam::UList::operator[] return UList(&(this->v_[slice.start()]), slice.size()); // SubList } + template const Foam::UList Foam::UList::operator[] ( diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H index 52bf97cb7c..aecb9a9c2e 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H @@ -149,7 +149,11 @@ public: //- Return true if point label is found in edge. // Always false for a negative label. - inline bool found(const label index) const; + inline bool found(const label pointLabel) const; + + //- Return local index (0,1) of point label in edge -1 on failure + // Always return -1 for a negative label. + inline label which(const label pointLabel) const; //- Do the edges share a common vertex index? // Negative point labels never connect. diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H index 75a5ba2365..e4ca81e938 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H @@ -206,10 +206,28 @@ inline Foam::label Foam::edge::maxVertex() const } -inline bool Foam::edge::found(const label index) const +inline bool Foam::edge::found(const label pointLabel) const { // -1: always false - return (index >= 0 && (index == start() || index == end())); + return (pointLabel >= 0 && (pointLabel == start() || pointLabel == end())); +} + + +inline Foam::label Foam::edge::which(const label pointLabel) const +{ + // -1: always false + if (pointLabel >= 0) + { + if (pointLabel == start()) + { + return 0; + } + if (pointLabel == end()) + { + return 1; + } + } + return -1; } diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 2d83def920..822e3c4f9a 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -202,7 +202,10 @@ public: //- Navigation through face vertices - //- Which vertex on face (face index given a global index) + //- Return true if the global point label is found in face. + inline bool found(const label globalIndex) const; + + //- Which local vertex on face given a global index. // returns -1 if not found label which(const label globalIndex) const; diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H index b45193f0e7..ce807528c6 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -116,20 +116,24 @@ inline Foam::edge Foam::face::faceEdge(const label n) const } -// Next vertex on face +inline bool Foam::face::found(const label globalIndex) const +{ + return which(globalIndex) != -1; +} + + inline Foam::label Foam::face::nextLabel(const label i) const { return operator[](fcIndex(i)); } -// Previous vertex on face inline Foam::label Foam::face::prevLabel(const label i) const { return operator[](rcIndex(i)); } -// Number of triangles directly known from number of vertices + inline Foam::label Foam::face::nTriangles() const { return size() - 2; diff --git a/src/surfMesh/MeshedSurface/MeshedSurfaceI.H b/src/OpenFOAM/meshes/meshShapes/traits/faceTraits.H similarity index 51% rename from src/surfMesh/MeshedSurface/MeshedSurfaceI.H rename to src/OpenFOAM/meshes/meshShapes/traits/faceTraits.H index a7415f7b4b..523233a569 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurfaceI.H +++ b/src/OpenFOAM/meshes/meshShapes/traits/faceTraits.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,83 +21,53 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . +Class + Foam::faceTraits + +Description + Traits class for faces + \*---------------------------------------------------------------------------*/ +#ifndef faceTraits_H +#define faceTraits_H + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// A triFace surface only handles triangulated faces -template<> -inline bool MeshedSurface::isTri() +// Forward declarations +class triFace; +class labelledTri; + +/*---------------------------------------------------------------------------*\ + Class faceTraits Declaration +\*---------------------------------------------------------------------------*/ + +template +class faceTraits { - return true; -} +public: + + //- Face-type only handles triangles. Not true in general. + inline static bool isTri() { return false; } +}; -// A labelledTri surface only handles triangulated faces template<> -inline bool MeshedSurface::isTri() -{ - return true; -} +inline bool faceTraits::isTri() { return true; } - -// Number of triangles for a triFace surface template<> -inline label MeshedSurface::nTriangles() const -{ - return ParentType::size(); -} - -// Number of triangles for a labelledTri surface -template<> -inline label MeshedSurface::nTriangles() const -{ - return ParentType::size(); -} - - -// Inplace triangulation of triFace surface = no-op -template<> -inline label MeshedSurface::triangulate() -{ - return 0; -} - -// Inplace triangulation of labelledTri surface = no-op -template<> -inline label MeshedSurface::triangulate() -{ - return 0; -} - -// Inplace triangulation of triFace surface (with face map) = no-op -template<> -inline label MeshedSurface::triangulate(List