mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: various enhancements for edge.
- support edge-ordering on construction, and additional methods:
- sort(), sorted(), unitVec(), collapse()
- null constructor initializes with -1, for consistency with face,
triFace and since it is generally much more useful that way.
- add some methods that allow edges to used somewhat more like hashes.
- count(), found(), insert(), erase()
Here is possible way to use that:
edge someEdge; // initializes with '-1' for both entries
if (someEdge.insert(pt1))
{
// added a new point label
}
... later
// unmark point on edge
someEdge.erase(pt2);
--
STYLE:
- use UList<point> instead of pointField for edge methods for flexibility.
The pointField include is retained, however, since many other routines
may be relying on it being included via edge.H
This commit is contained in:
3
applications/test/edges/Make/files
Normal file
3
applications/test/edges/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-edges.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-edges
|
||||
0
applications/test/edges/Make/options
Normal file
0
applications/test/edges/Make/options
Normal file
114
applications/test/edges/Test-edges.C
Normal file
114
applications/test/edges/Test-edges.C
Normal file
@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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-edges
|
||||
|
||||
Description
|
||||
Simple tests for edges
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "edgeList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
void printInfo(const edge& e)
|
||||
{
|
||||
Info<< "edge: " << e << " count:" << e.count() << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
edge e1;
|
||||
printInfo(e1);
|
||||
Info<<"has '2'? " << e1.found(2) << endl;
|
||||
|
||||
edge e2(1, 2);
|
||||
printInfo(e2);
|
||||
Info<<"has '2'? " << e2.found(2) << endl;
|
||||
|
||||
edge e3{2, 3};
|
||||
printInfo(e3);
|
||||
Info<<"has '2'? " << e3.found(2) << endl;
|
||||
|
||||
edge e4(4, 4);
|
||||
printInfo(e4);
|
||||
Info<<"has '2'? " << e4.found(2) << endl;
|
||||
|
||||
Info<<"collapse? -> " << e4.collapse() << endl;
|
||||
printInfo(e4);
|
||||
|
||||
Info<< e3 << " connects " << e2 << " => " << e2.connects(e3) << endl;
|
||||
|
||||
Info<< nl << "hash-like functionality" << nl;
|
||||
|
||||
// doesn't work e4 = -1;
|
||||
e4.start() = e4.end() = -1;
|
||||
|
||||
printInfo(e4);
|
||||
for (label i : {2, -1, 2, 1, 4, 1, 2, 3})
|
||||
{
|
||||
bool ok = e4.insert(i);
|
||||
Info<< "insert(" << i << ") = " << ok << " resulting ";
|
||||
printInfo(e4);
|
||||
}
|
||||
|
||||
for (label i : {-1, 0, 1, 3})
|
||||
{
|
||||
bool ok = e4.erase(i);
|
||||
Info<< "erase(" << i << ") = " << ok << " resulting ";
|
||||
printInfo(e4);
|
||||
}
|
||||
|
||||
for (label i : {-1, 0, 1, 3})
|
||||
{
|
||||
bool ok = e4.insert(i);
|
||||
Info<< "insert(" << i << ") = " << ok << " resulting ";
|
||||
printInfo(e4);
|
||||
}
|
||||
e4.flip();
|
||||
Info<< "flipped ";
|
||||
printInfo(e4);
|
||||
|
||||
for (label i : {-1, 0, 1, 3})
|
||||
{
|
||||
bool ok = e4.erase(i);
|
||||
Info<< "erase(" << i << ") = " << ok << " resulting ";
|
||||
printInfo(e4);
|
||||
}
|
||||
|
||||
e4.sort();
|
||||
Info<< "sorted ";
|
||||
printInfo(e4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user