Created
March 2, 2017 16:22
-
-
Save hertzsprung/dd14ad39e5ad03b8e16dcd8f92ab2ab1 to your computer and use it in GitHub Desktop.
OpenFOAM application to find faces that share points (vertices) with other faces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "fvCFD.H" | |
using namespace fv; | |
int main(int argc, char *argv[]) | |
{ | |
# include "setRootCase.H" | |
# include "createTime.H" | |
# include "createMesh.H" | |
for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) | |
{ | |
const face& f = mesh.faces()[faceI]; | |
labelList connectedFaceList; | |
forAll(f, pointForFaceI) | |
{ | |
const label pointI = f[pointForFaceI]; | |
const labelList& connectedFaces = mesh.pointFaces()[pointI]; | |
forAll(connectedFaces, i) | |
{ | |
connectedFaceList.append(connectedFaces[i]); | |
} | |
} | |
HashSet<label, Hash<label>> connectedFaceSet(connectedFaceList); | |
Info << "faces connected to faceI " << faceI << " are " << connectedFaceSet << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could use a PackedBoolList instead of a HashSet (you'll need to recheck the code - ie, untested).
But the important thing is to have your hashing or bool-list to accumulate the values and build the list from that. You should not build the list and then use a hash or whatever to filter afterward.
If it works (and you like it), it would be good to update the gist and tweet so that people can find it.
/mark
Using a HashSet (perhaps not here, but somewhere else), now looks almost the same.
For this particular case I think that using a hash will be better than the PackedBoolList, since the number of faces connected to any particular face would be rather small. The PackedBoolList storage would require (nInternalFaces() / sizeof(int)) storage and the HashSet would use less. However, the hasher will need a few more operations (see Hasher.C) to calculate an index compared to a PackedBoolList. I'd be interested to see which speed difference you can observe (on which size mesh).