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

How to get cell labels for all the points within specific distance from a given point

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By PHS-

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 8, 2014, 23:11
Question How to get cell labels for all the points within specific distance from a given point
  #1
New Member
 
Xiangyu Gao
Join Date: Sep 2013
Location: West Lafayette, IN, USA
Posts: 29
Rep Power: 12
gxy200992243 is on a distinguished road
Hi, everyone!

I need cell labels for all the points within specific distance from a given point. For example, the coordinate for the given point is (x,y,z), and I need velocity values of all the points within 3cm from this point to interpolate the velocity at this point. Could anyone help me with it?

Billions of thanks!

Xiangyu
gxy200992243 is offline   Reply With Quote

Old   October 10, 2014, 13:17
Default
  #2
New Member
 
Join Date: Jul 2011
Posts: 9
Rep Power: 14
PHS- is on a distinguished road
I am not sure if this functionnality is available directly in OpenFOAM .
However, this is how I would do :

- First, get the cell centers coordinates of your mesh by using writeCellCentres. It writes the coordinates in the files ccx, ccy and ccz for the specified times.

- Then, write a code in a scripting language (for example python) that reads the files for the cell centers and the velocity file U, and extract the lines corresponding to cells that are within 3cm of your point.

There is certainly a way to do this directly in OpenFOAM but if you are not familiar with the OpenFOAM source code or C++, this is probably the simplest option
PHS- is offline   Reply With Quote

Old   October 10, 2014, 13:28
Default
  #3
New Member
 
Xiangyu Gao
Join Date: Sep 2013
Location: West Lafayette, IN, USA
Posts: 29
Rep Power: 12
gxy200992243 is on a distinguished road
Quote:
Originally Posted by PHS- View Post
I am not sure if this functionnality is available directly in OpenFOAM .
However, this is how I would do :

- First, get the cell centers coordinates of your mesh by using writeCellCentres. It writes the coordinates in the files ccx, ccy and ccz for the specified times.

- Then, write a code in a scripting language (for example python) that reads the files for the cell centers and the velocity file U, and extract the lines corresponding to cells that are within 3cm of your point.

There is certainly a way to do this directly in OpenFOAM but if you are not familiar with the OpenFOAM source code or C++, this is probably the simplest option
Thank you very much for the reply! This interpolation must be done during the simulation, not after, because I must feed the interpolated value for next time step. Could you please kindly give me some hints about how to do it? My current solution is to feed the coordinate of all the points within 3cm from given point directly to the solver and get the label.
gxy200992243 is offline   Reply With Quote

Old   October 10, 2014, 14:18
Default
  #4
New Member
 
Join Date: Jul 2011
Posts: 9
Rep Power: 14
PHS- is on a distinguished road
My bad, I didn't understand the question properly :P

I guess you could loop over all the cells and access the coordinates with:
mesh.C[celli].component(0) (for the x-coordinate), and if the cell is within 3cm of your point, then just put its label in a list.

Then you just have to iterate over the labels in the list and interpolate the velocities.
Hope this helps..
PHS- is offline   Reply With Quote

Old   October 10, 2014, 20:05
Default
  #5
New Member
 
Xiangyu Gao
Join Date: Sep 2013
Location: West Lafayette, IN, USA
Posts: 29
Rep Power: 12
gxy200992243 is on a distinguished road
Sorry for bothering you again. Now I am facing a new problem. I am running my case in parallel. This is how I get the label and velocity for a given point:

vector probepoint(x[0],x[1],x[2]);
label m=iMesh.findCell(probepoint);
U_in[0]=U[m].x();
U_in[1]=U[m].y();
U_in[2]=U[m].z();

It works well in serial, but in parallel, I have the problem below:

I decompose the domain into 16 parts, and the given point can only be in one part (let's say part 3). The label search works well in part 3, but in other parts, the solver gives me m=-1, which will make U_in[0]=U[m].x() impossible and kill the simulation.

Do you know how to let the label search happen in only part 3?

Thank you,

Xiangyu
gxy200992243 is offline   Reply With Quote

Old   October 10, 2014, 22:18
Default
  #6
New Member
 
Join Date: Jul 2011
Posts: 9
Rep Power: 14
PHS- is on a distinguished road
To find a label in parallel, check out this thread : http://www.cfd-online.com/Forums/ope...-parallel.html
gxy200992243 likes this.

Last edited by wyldckat; October 11, 2014 at 13:29. Reason: rectified link, since the linked thread was moved to the programming sub-forum
PHS- is offline   Reply With Quote

Old   October 11, 2014, 12:43
Default
  #7
New Member
 
Xiangyu Gao
Join Date: Sep 2013
Location: West Lafayette, IN, USA
Posts: 29
Rep Power: 12
gxy200992243 is on a distinguished road
Thank you very much, the information you provided is really helpful! Now the problem has been solved!
gxy200992243 is offline   Reply With Quote

Old   October 11, 2014, 15:17
Default
  #8
New Member
 
Xiangyu Gao
Join Date: Sep 2013
Location: West Lafayette, IN, USA
Posts: 29
Rep Power: 12
gxy200992243 is on a distinguished road
Sorry for my endless questions. I need to use findcell for 60 points per time step, which means I have to loop the domain for 60 times. It will take a lot of time. Is there a way to find the labels for all 60 points in only one loop? I tried to feed a vector list to find cell to findcell in order to get a label list, of course, it did not work. Could you please give me any hints?

Thank you very much,

Xiangyu
gxy200992243 is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[General] 2 datas on one plot Akuji ParaView 46 December 1, 2013 14:06
Error message: 8 face(s) not in face lists of adjacent cells jyoung79 FLUENT 0 November 10, 2012 16:09
Two-Phase Buoyant Flow Issue Miguel Baritto CFX 4 August 31, 2006 12:02
distance from the wall to the first grid point Wenqing Zhang CFX 0 August 9, 2004 10:08
CFX4.3 -build analysis form Chie Min CFX 5 July 12, 2001 23:19


All times are GMT -4. The time now is 06:26.