|
[Sponsors] |
Double sampling of cell label using cuttingPlane??? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 21, 2011, 20:15 |
Double sampling of cell label using cuttingPlane???
|
#1 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
Dear Foamers,
I'm using the cuttingPlane class to sample information on a plane during a simulation run. I then use the .cutCells() function to retrieve the cells cut by my plane. But in the labelList returned, every cell cut is sampled twice instead of once.. Any idea why?? My code is: Code:
point pnt_1(1.5, 1, 2); vector direction(1, 0, 0); plane plane_1(pnt_1, direction); cuttingPlane cutPlane_1(plane_1, mesh); const labelList& cutCellsPlane_1 = cutPlane_1.cutCells(); Code:
cutCellsPlane_1 face-> 1 cutCellsPlane_1 face-> 1 cutCellsPlane_1 face-> 7 cutCellsPlane_1 face-> 7 cutCellsPlane_1 face-> 13 cutCellsPlane_1 face-> 13 etc. Kind regards, Francois. |
|
April 26, 2011, 04:41 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
http://foam.sourceforge.net/doc/Doxy....html#_details |
||
April 26, 2011, 14:58 |
|
#3 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
Dear Mark,
Thank you for you reply! I did indeed read in the doxygen documentation that there could be triangulation involved, but I don't understand why that should return a .cutCells() list returning every cell twice. Especially on a Cartesian orthogonal grid.. Could you explain to me why triangulation would give me such a result? Kind regards, Francois. |
|
April 27, 2011, 03:43 |
|
#4 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
The following code snippet from cuttingPlane.C explains what is happening inside: Code:
// the cut faces are usually quite ugly, so always triangulate label nTri = f.triangles(cutPoints, dynCutFaces); while (nTri--) { dynCutCells.append(cellI); } Code:
const bool triangulate = true; // temporary hack for Francois // the cut faces are usually quite ugly, so optionally triangulate if (triangulate) { label nTri = f.triangles(cutPoints, dynCutFaces); while (nTri--) { dynCutCells.append(cellI); } } else { dynCutFaces.append(f); dynCutCells.append(cellI); } The good news is that triangulation/non-triangulation of cuttingPlane is an option in the next OpenFOAM release, so you won't need this hack in later releases. |
||
April 27, 2011, 12:24 |
|
#5 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
Dear Mark,
Once again, thank you for your swift reply! As I was using an orthogonal grid for the time being and needed an fix fast to get my simulation running, I wrote a simple routine filtering out the cells listed twice in my cell list. Not very elegant, I know, but it did the job until I found a better way of doing it. Now that the urgency to get my simulation running is gone, I can search for a better solution. So thank your piece of code! It definitely looks like a more elegant solution! I will implement it, see how it works, and if I need triangulation, I will know which boolean I have to change to get it back. Kind regards, Francois. |
|
April 27, 2011, 12:35 |
|
#6 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
|
||
April 27, 2011, 19:24 |
|
#7 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
Dear Mark,
Well, it appears I keep getting more reasons to thank you! I had only vaguely heard of HashSet until today, although it appears to be used in quite fundamental handling of objects in OpenFOAM... But after greping and doxygen-ing around and what not, I came up indeed with a very short piece of code to do my filtering! Code:
labelHashSet myHashList(myCutCellsLabelList); labelList myFilteredList = myHashList.toc(); Thank you for the comments! Kind regards, François. |
|
April 28, 2011, 03:05 |
|
#8 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
You indeed have the type of code I was thinking about. For some cases the PackedBoolList might be faster (you can try the applications/test/PackedList2/ if you'd like). The only way to shorten your code (which is already quite short) would be to skip intermediates: Code:
const labelList myFilteredList(labelHashSet(cutPln.cutCells()).toc()); |
||
May 4, 2011, 07:03 |
|
#9 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
Dear Mark,
Well, thank you, once more! It works! It was a bit odd because the compiler started by being cranky, not wanting to compile the code, so I changed it back to the original code, compiled, and retried with exactly the same inline code once more, and it worked.. Dont ask.. On a totally different topic, you wouldn't happen to be familiar with the reduce() function to reconstruct data across processors by any chance? Kind regards, Francois. |
|
May 4, 2011, 08:38 |
|
#10 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
For your sample plane application, it could get used something like this: Code:
// count all faces label nFaces = pln.faces().size(); reduce(nFaces, sumOp<label>()); // find max value (and known a priori to be > 0) scalar maxU(0); if (pln.faces().size()) { some operation to get a max value from the plane } reduce(maxU, maxOp<scalar>()); |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Continuing User Defined Real Gas Model issues | aeroman | FLUENT | 6 | April 8, 2016 04:34 |
Missing math.h header | Travis | FLUENT | 4 | January 15, 2009 12:48 |
REAL GAS UDF | brian | FLUENT | 6 | September 11, 2006 09:23 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 05:41 |