|
[Sponsors] |
[Technical] How to get one cell's point label list in correct order (right-hand rule)? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 3, 2020, 12:11 |
How to get one cell's point label list in correct order (right-hand rule)?
|
#1 |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Dear Foamers,
I am writing a small tool to output OpenFOAM mesh to other formats. So far I can get correct points, faces and boundary information. However, when it comes to write one cell's point label list, the order is not correct. For example a hex cell knowing its cell type from Code:
const cellModel& cell_type = cellShapes()[celli].model; Code:
const labelList& cell_point_labels = cellPoints()[celli]; So my question is: knowing a cell's type, all faces and points, how to get the corrected order of point labels? i.e. for visualization purpose in vtk file format. Thanks a lot. ___________________________________________ Update 1: I found that the tool "foamToVTK" can output cell's point labels/IDs correctly. Anyone can give some tips where is the actual code/function to output cell's point labels? Last edited by keepfit; October 8, 2020 at 08:20. |
|
October 3, 2020, 19:52 |
|
#2 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9 |
For class fvMesh, I remember, you can use get cellList, faceList and pointList from function cell(), face() and point(). You can then need reassemble to get the point index oder for a cell. As different cell type has different point order, there might be no function that you can use directly. I might be wrong.
|
|
October 4, 2020, 03:48 |
|
#3 | |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Quote:
Last edited by keepfit; October 4, 2020 at 16:16. |
||
October 4, 2020, 11:12 |
|
#4 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9 |
If you refer to OpenFOAM User Guide, section 5.1.3 cell types, a cell's faces are indexed, so does the edge and point (including Wedge and tetWedge).
The return of functions cells() and faces() give you faces and points in the same order and number of them (please check as I did this 2-3 years ago). You can then code to judge if it is wedge , tetWedge and then get the point in correct order or in the order you want to export. |
|
October 4, 2020, 16:20 |
|
#5 | |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Quote:
Code:
const cellList& cList = cells(); forAll(cList, celli) { const auto& cPts = cList[celli].points(faces(), points()); forAll(cPts, pointi) { std::cout << cPts[pointi].x() << " " << cPts[pointi].y() << " " << cPts[pointi].z() << std::endl; } std::cout << std::endl; } |
||
October 4, 2020, 16:30 |
|
#6 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33 |
You need to ask for a cell shape and than ask that for points. This will give you the correct ordering you expect.
However, not all cells have shapes; if you have anything larger than a hex, the numbering conventions are not well established. The code answer to cell shape will be "I don't know" and you will not get a meaningful order. Why? Well, what order would you expect for a dodecahedron, for example. Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
October 5, 2020, 08:33 |
|
#7 | |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Quote:
|
||
October 5, 2020, 16:54 |
|
#8 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 148
Rep Power: 9 |
Can you post your mesh files and let me know which cell you are looking at?
|
|
October 6, 2020, 04:30 |
|
#9 | |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Quote:
Code:
vertices ( (0 0 0) (1 0 0) (1 1 0) (0 1 0) (0 0 0.1) (1 0 0.1) (1 1 0.1) (0 1 0.1) ); blocks ( hex (0 1 2 3 4 5 6 7) (3 3 1) simpleGrading (1 1 1) ); |
||
October 6, 2020, 11:48 |
|
#10 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40 |
Quote:
Hrv's answer is correct, or there is a bug, or you are doing something wrong. Using cells() is not what you want. This returns the list of faces defining (enclosing) the cell, which is not what you asked. If you have obtained the cellShape(), it contains a list of points defining the cell. It should also be in the correct point order. Example of its use, Note that the VTK conversions have a flipped prism types, but both EnSight and STARCD formats have the same point ordering as OpenFOAM, and there is no problem there. |
||
October 7, 2020, 09:06 |
|
#11 | |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Quote:
so for the vector: Code:
const cellShapeList& cShapes = cellShapes(); Last edited by keepfit; October 7, 2020 at 11:04. |
||
October 8, 2020, 02:33 |
|
#12 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40 |
Quote:
|
||
October 8, 2020, 05:03 |
|
#13 |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
We really need some reference book or user manual to give a big picture on the most important OpenFOAM classes and most useful functions. I have been using openFOAM for 5+ years, it was always a headache to find some useful functions, or to modify some source codes buried deeply. Most of the time I felt like finding a needle in a haystack
Last edited by keepfit; October 8, 2020 at 08:20. |
|
October 8, 2020, 18:25 |
|
#14 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40 |
Quote:
|
||
October 10, 2020, 16:27 |
|
#15 | |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Quote:
Code:
Mesh: primitive mesh: point, face, cell, etc dynamic mesh [optional] fvMesh: fvFace, fvCell, boundary faces, etc Numerics: Boundary conditions Surface interpolation schemes PDEs dicretization: convection/diffusion/pressure terms, etc Turbulence models Sparse Matrix and Ax=B assembly Sparse linear system solvers Post-processing: (less important) drag/lift coefficients yPlus etc Last edited by keepfit; October 11, 2020 at 09:11. |
||
October 13, 2020, 06:40 |
|
#16 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40 |
I guess something like this is what you mean?
https://openfoam.com/documentation/g...urbulence.html If you have some content, would be worth contacting https://wiki.openfoam.com/Technical_..._and_Tutorials |
|
October 13, 2020, 13:15 |
|
#17 | |
Senior Member
David Long
Join Date: May 2012
Location: Germany
Posts: 104
Rep Power: 14 |
Quote:
https://lammps.sandia.gov/doc/Commands_all.html At the moment I am making my own CFD code for the interactions between real particles and fluids . By focusing on the core operation such as surface interpolation and PDEs discrecretization, etc, then some open-source math libraries (PETSc, Eigen3, etc) are used for the solution of sparse linear system. Meshing and visualization are simply based on existing open-source tools. The reason why I'm doing this is that, I personally felt like it will take forever for me to complete it with OF, as it needs a lot of tweak or modification on the basic classes in OpenFOAM, not to mention a lot of new classes are needed as well for the moving particle-fluid interaction. Last edited by keepfit; October 14, 2020 at 04:01. |
||
Tags |
mesh; points; labels |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM.com] swak4foam compiling issues on a cluster | saj216 | OpenFOAM Installation | 5 | January 17, 2023 16:05 |
[snappyHexMesh] How to define to right point for locationInMesh | Mirage12 | OpenFOAM Meshing & Mesh Conversion | 7 | March 13, 2016 14:07 |
snappyhexmesh remove blockmesh geometry | philipp1 | OpenFOAM Running, Solving & CFD | 2 | December 12, 2014 10:58 |
[Netgen] Import netgen mesh to OpenFOAM | hsieh | OpenFOAM Meshing & Mesh Conversion | 32 | September 13, 2011 05:50 |
[Gmsh] Gmsh and samplesurface | touf | OpenFOAM Meshing & Mesh Conversion | 2 | December 10, 2007 02:27 |