CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

where to find the labels of the hex ?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 5, 2011, 19:16
Default where to find the labels of the hex ?
  #1
New Member
 
Hsingtzu Wu
Join Date: Feb 2011
Posts: 21
Rep Power: 5
hsingtzu is on a distinguished road
Hi

when I look at the output file of u or p, it is a long list of numbers.
I know each number corresponds to one hex, but I am wondering what hex the number corresponds to. Where can I find the hex labels, just like the point labels, so I will know which number goes to which hex which is hex number __ and is composed by point__, __, __, ...

Thanks
Hsingtzu
hsingtzu is offline   Reply With Quote

Old   October 5, 2011, 21:22
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 379
Rep Power: 10
marupio is on a distinguished road
It's not easy. I'd suggest you use a post-processing program, or the built-in sample utility.

If you don't have mesh motion, your mesh details will be in: /case/constant/polyMesh/

If you do have mesh motion, you also have to refer to your time directories.

1. The geometry starts with points. The points are clear to understand... but they aren't explicitly numbered.

2. Number them, starting at zero from the top.

3. Next comes faces. These are groups of points that form a face. The numbers in the groups correspond to the numbers you gave the points list (in step 2). Again, the faces aren't explicitly numbered... but you don't need to number them.

4. Next come the cells. This is what you are looking for... each cell corresponds with the numbers in your velocity or pressure output files. Finally, after all that work! ... there is no cells file ... but there are two other files: neighbours and owners. The numbers in these files are the cell numbers. These files have a one to one correspondence with the faces file. Using these three files in concert, you can figure out which faces are "owned" by which cells, and which are "neighbours". Outside faces don't have neighbours, so the owners file is longer.

There's probably a way to output the cell centres, in a list, corresponding to the cell numbers.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   October 6, 2011, 02:52
Default
  #3
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 244
Blog Entries: 5
Rep Power: 10
tomislav_maric is on a distinguished road
Quote:
Originally Posted by hsingtzu View Post
Hi

when I look at the output file of u or p, it is a long list of numbers.
I know each number corresponds to one hex, but I am wondering what hex the number corresponds to. Where can I find the hex labels, just like the point labels, so I will know which number goes to which hex which is hex number __ and is composed by point__, __, __, ...

Thanks
Hsingtzu
Hi, here's a very very simple example of direct cellList - vol*Field addressing.

Code:
// Get the mesh cells  = these are the hexes you're talking about, but they
// may not be hex, they can be of any shape (convex logical polyhedron).
const cellList& meshCells = mesh.cells();

// Let's say that your field is called F (again, just a silly example)

forAll (meshCells, I)
{
    // Do something silly.
    F[I] = 5;
    // Access cell points from the cell list... 
    const cell& c = meshCells[I];
    pointField cellPoints = c.points(meshPoints);
}
Something like the example above would be used if you want an operation on the specific cell to change the value of the field.

Notice that the "I" counter maps directly from fvMesh::cells to the vol*Field, because each F value is related to a single cell centre. So, the position of the value in your field F is actually the label of the cell in the field cells. Its indirect, and gets clear if you write some loops over the lists yourself, output that and anaylse. Check out Foam:: PrimitiveMesh class for connectivity information.

Hope this helps,

Tomislav
tomislav_maric is offline   Reply With Quote

Old   October 6, 2011, 11:53
Default
  #4
New Member
 
Hsingtzu Wu
Join Date: Feb 2011
Posts: 21
Rep Power: 5
hsingtzu is on a distinguished road
Thanks to marupio and Tomislav.
I would match the numbers in the "face" file and that in the "owner" file to get the points of the cell. Then I would use the "points" file to find the coordinates. If I would like to find the center of the cell, I find the avg of the points

Also I can write a code according to Tomislav's suggestion.

Hsingtzu

Last edited by hsingtzu; October 6, 2011 at 12:51.
hsingtzu is offline   Reply With Quote

Old   October 6, 2011, 13:56
Default
  #5
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 244
Blog Entries: 5
Rep Power: 10
tomislav_maric is on a distinguished road
Quote:
Originally Posted by hsingtzu View Post
Thanks to marupio and Tomislav.
I would match the numbers in the "face" file and that in the "owner" file to get the points of the cell. Then I would use the "points" file to find the coordinates. If I would like to find the center of the cell, I find the avg of the points

Also I can write a code according to Tomislav's suggestion.

Hsingtzu
No problem. My advice: if you need something from a cell , use the Foam::cell class, meaning a function from this class.

Check out the Doxygen C++ documentation and search there for the stuff you need.

If you need local cell computation (like I do), then use Foam::cell::centre (be aware that the local cell computation of the volume magnitude and centre are approximative and don't check for non-planar faces). If you want the cell magnitude or centre for every cell of the mesh, use fvMesh::C() method.

Search for the methods in the src directory, or go here and search:

http://http://www.openfoam.com/docs/cpp/

Godspeed,
Tomislav
tomislav_maric is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
meshing a cylinder Nico A. OpenFOAM Native Meshers: blockMesh 2 April 8, 2011 04:26
meshing a cylinder Nico A. OpenFOAM Native Meshers: blockMesh 0 April 7, 2011 11:09
Negative labels in faceProcAddressing ngj OpenFOAM Meshing Format & General Technical 6 March 29, 2011 15:54
Internal walls of zero thickness anger OpenFOAM Native Meshers: blockMesh 20 April 6, 2009 01:50
Does inflotion layer necessary for Hex mesh? Pete CFX 2 January 4, 2004 18:21


All times are GMT -4. The time now is 22:35.