diff --git a/applications/test/faces/Make/files b/applications/test/faces/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..8418bb2b93aa267c53b55aae8ba4fc2eb7d2729d --- /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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/applications/test/faces/Test-faces.C b/applications/test/faces/Test-faces.C new file mode 100644 index 0000000000000000000000000000000000000000..823f33e3e10046f8836158180c2d22f033b855f1 --- /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 <http://www.gnu.org/licenses/>. + +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 0504145adeb815a6887408d9421d23b218dba99b..62ae47b3d078d5907346571684059c775891cdc5 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<label>); //- Construct by transferring the parameter contents explicit inline face(const Xfer<labelList>&); diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H index 7dfc9ef7ea7a43ffc28ab0ed6d741e41ce54f213..0dc5e035a60819fc80236ba51d8935041dc27fec 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H @@ -57,7 +57,7 @@ inline Foam::face::face(const labelUList& lst) {} -inline Foam::face::face(const labelList& lst) +inline Foam::face::face(std::initializer_list<label> lst) : labelList(lst) {} @@ -79,7 +79,7 @@ inline Foam::face::face(Istream& is) inline Foam::pointField Foam::face::points(const pointField& meshPoints) const { - // There are as many points as there labels for them + // There are as many points as there are labels for them pointField p(size()); // For each point in list, set it to the point in 'pnts' addressed diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H b/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H index d268b0ccbc291119dd0b63b7270cbed46b83c6c4..0caf8a454a2d93c03ad9e66ada975b8d86d20ab9 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceListFwd.H @@ -43,8 +43,6 @@ namespace Foam typedef List<face> faceList; typedef SubList<face> faceSubList; typedef List<faceList> faceListList; - // same as faceUList: - typedef UList<face> unallocFaceList; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTri.H b/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTri.H index a0fd5a90dd0a371aaedb6364ac7a1fca4318e851..f9feafa610a78004d5a68142cafd9734b2d4fc8e 100644 --- a/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTri.H +++ b/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTri.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) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,29 +64,44 @@ class labelledTri label region_; + // Private Member Functions + + //- Assign from a list of 3 or 4 labels. + // Default region is 0. + inline void assign(const labelUList&); + public: // Constructors - //- Construct null + //- Construct null with invalid point labels and region (-1). inline labelledTri(); - //- Construct from triFace and a region label + //- Construct from triFace and region label. + // Default region is 0 if not specified. inline labelledTri ( const triFace&, - const label region + const label region = 0 ); - //- Construct from three point labels and a region label + //- Construct from three point labels and a region label. + // Default region is 0 if not specified. inline labelledTri ( const label a, const label b, const label c, - const label region + const label region = 0 ); + //- Construct from a list of 3 or 4 labels. + // Default region is 0. + explicit inline labelledTri(const labelUList&); + + //- Construct from an initializer list of 3 or 4 labels. + explicit inline labelledTri(std::initializer_list<label>); + //- Construct from Istream inline labelledTri(Istream&); @@ -102,17 +117,6 @@ public: inline label& region(); - // Check - - // Edit - - // Write - - - // Friend Functions - - // Friend Operators - // IOstream Operators inline friend Istream& operator>>(Istream&, labelledTri&); diff --git a/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H b/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H index 0d86d6cee9086ed6bb67a6245ab6c587a8d46f36..0e0c72af77c9836d9c175c22a297dc3063be0b4e 100644 --- a/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H +++ b/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.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) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,10 +25,34 @@ License #include "IOstreams.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +inline void Foam::labelledTri::assign(const labelUList& lst) +{ + const label sz = lst.size(); + + // checkSize + if (sz < 3 || sz > 4) + { + FatalErrorInFunction + << "size " << sz << " != (3 or 4)" + << abort(FatalError); + } + + for (label i=0; i<3; ++i) + { + operator[](i) = lst[i]; + } + + region_ = (sz > 3 ? lst[3] : 0); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // inline Foam::labelledTri::labelledTri() : + triFace(), region_(-1) {} @@ -57,6 +81,24 @@ inline Foam::labelledTri::labelledTri {} +inline Foam::labelledTri::labelledTri(const labelUList& lst) +: + triFace(), + region_(0) +{ + assign(lst); +} + + +inline Foam::labelledTri::labelledTri(std::initializer_list<label> initLst) +: + triFace(), + region_(0) +{ + assign(labelList(initLst)); +} + + inline Foam::labelledTri::labelledTri(Istream& is) { operator>>(is, *this); diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index 2e7a730228adbf9999521160ee364611d0ba9a5d..0b2d5170ad04bc0808addb15776e47ab0a83d095 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -75,7 +75,7 @@ public: // Constructors - //- Construct null + //- Construct null with invalid point labels (-1) inline triFace(); //- Construct from three point labels @@ -86,9 +86,12 @@ public: const label c ); - //- Construct from a list of labels + //- Construct from a list of 3 labels. explicit inline triFace(const labelUList&); + //- Construct from an initializer list of 3 labels + explicit inline triFace(std::initializer_list<label>); + //- Construct from Istream inline triFace(Istream&); diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H index b956780df4138ec0f0c4c8b7c52154bc292cdfd1..8d8bcaba99af925979b26f12ab2ea33c6ef7e7d0 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H @@ -62,6 +62,8 @@ inline int Foam::triFace::compare(const triFace& a, const triFace& b) // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // inline Foam::triFace::triFace() +: + FixedList<label, 3>(-1) {} @@ -84,6 +86,12 @@ inline Foam::triFace::triFace(const labelUList& lst) {} +inline Foam::triFace::triFace(std::initializer_list<label> lst) +: + FixedList<label, 3>(lst) +{} + + inline Foam::triFace::triFace(Istream& is) : FixedList<label, 3>(is)