openfoam/applications/test/faces/Test-faces.C
Mark Olesen a32eff4e59 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]};
2016-11-12 20:57:48 +01:00

85 lines
2.3 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //