
[Sponsors] 
December 19, 2012, 14:43 
I know the cell ID, how do I find the cell coordinates?

#1  
Member
Simon Arne
Join Date: May 2012
Posts: 42
Rep Power: 5 
Hey,
I have a complex case that seems to be crashing because of a single cell. Unluckily I cant identify it with the sets generated by checkMesh (allGeo allTopo). But I checked values immediately before the crash, so I think I know its ID (its nr 94495 in the list). How do I find out where it is located? E.g. I need to find it's cell centre point or the vertices defining the cell (their coordinates). So I know where inside my mesh the crash magic takes place. Isn't there a cell list similiar to the face list in 0/polyMesh ? My intention is to change meshing parameters in a way that this cell becomes normal. Any help is highly appreciated! These crashes drive me absolutely crazy (as they happen after 520 hours of computation time and then its meshproblemhunt ) Greetings and thanks in advance, Simon Not sure if it is helpful but here is my checkMesh output (it's about tank filling). Quote:


December 19, 2012, 15:49 

#2 
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 727
Rep Power: 18 
For cell center, you should be able to do mesh[cellI].x() to get the xcoordinate of the cell center. You can do a similar operation for y and z.


December 28, 2012, 16:29 

#3 
New Member
Mulualem
Join Date: May 2010
Posts: 11
Rep Power: 7 
Hi Marco,
Good day and happy new year! I have been trying to find the maximum value of the coordinates, say (max(y)) in order to calculate a hydrostatic pressure as: hydrostatic pressure = rho * (g & (max(y)  mesh.C())), where rho is the density of water and g is the gravitational acceleration. I am having a problem, either in getting the maximum value of "y" from my computational domain ( which is the depth of the water level in principle, b/c I have air and water body in the domain) or the equation I am using is wrong. I have been trying to modify the postprocessing uttility (ptot), which calculates the total pressure (static + dynamic) in order to include the hydrostatic pressure but is giving me errors during compiliation. I have used a constant number say max(y) = 1, and still the solver is not compiling. I have been thinking of finding max (y) when the density of the fluid is 1000 in the cell, which is the water density, in this way, I will be able to track the free surface dynamics and its corresponding height (max (y)). But this seems to be very difficult for the time being, for me at least. So I was thinking just to do in the simplest way by using constant value of the water depth though I couldn't do this one either. I would appreciate if you can lend me a hand on how to access the maximum value of the coordinates and if the minus sign used in the above equation is correct in the programming point of view. Thank you for your time and help. With regards, Mulualem 

December 28, 2012, 18:08 

#4 
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 727
Rep Power: 18 
I think your problem is that you are mixing up types and operators. You are trying to subtract a single constant scalar value (max(y)) from a vector field (mesh.C()). I think you can agree this doesn't make sense. You may have to do the calculation cell by cell to extract the y value. Either change max(y) to a vector (create a temporary one that is just (0,1,0)*max(y)), and the subtraction and then dot product should work. As long as g is oriented in the y direction this should give you the answer you want.


December 30, 2012, 05:53 

#5 
New Member
Mulualem
Join Date: May 2010
Posts: 11
Rep Power: 7 
Thank you Marco for your prompt reply.
You rightly pointed out my problem, it appears that it was mixing of types and operators. Now, the solver is working great with a temporary vector of the form "Foam::vector(0,1,0)". I will try the cell by cell method b/c that could help me to figure out the free surface dynamics by searching the cells with the maximum density. Regards, Mulualem 

February 25, 2014, 13:11 

#6 
Senior Member
Join Date: Jan 2013
Posts: 202
Rep Power: 5 
Is it possible to extract the coordinates of the vertices belonging to one face in openbfoam? Assume the face is triangular, then the coordinates of the three vertices? Thank you.


June 30, 2014, 10:29 
Accessing coordinates in BC face by face

#7 
New Member
Dominik Pöltl
Join Date: Jul 2013
Location: Hamburg
Posts: 14
Rep Power: 4 
Dear all,
your advice is pretty pretty close to what I needed recently. I'm trying to assign a scalar value to my boundaryField depending on each face's x and zvalue. So since I'm doing it face by face in my 0/Tfile figuratively I'm being handed a cell, I don't care about it's index, I just want to access THIS face's coordinates. Is there something similar to Xcoord=mesh.x() I can use? Here's my code with some placeholders Code:
// 0/Tfile focus_inlet { type groovyBC; variables "circ=<value>;d_2=<value>;n=5;Xcoord=mesh.x();Zcoord=mesh.z();"; valueExpression "(<f(Xcoord,Zcoord)> ? 1 : 0.1"; value uniform 0.1; Code:
variables "circ=<value>;d_2=<value>;n=5;Xcoord=pos().x;Zcoord=pos().z;"; Last edited by Yeru; July 3, 2014 at 09:45. Reason: Solution found and added 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
OpenFOAM 1.6ext git installation on Ubuntu 11.10 x64  Attesz  OpenFOAM Installation  45  January 13, 2012 13:38 
Mass flow rate through each cell  Babakjingo  Main CFD Forum  0  August 21, 2011 03:18 
Find fraction of area of cell occupied by body  CF  Main CFD Forum  0  December 19, 2007 00:08 
Ultra high temperature?  bk  CDadapco  2  July 19, 2005 00:01 
Warning 097  AB  CDadapco  6  November 15, 2004 05:41 