How to get cell labels for all the points within specific distance from a given point
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 |
I am not sure if this functionnality is available directly in OpenFOAM :confused:.
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 :) |
Quote:
|
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.. |
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 |
To find a label in parallel, check out this thread : http://www.cfd-online.com/Forums/ope...-parallel.html
|
Thank you very much, the information you provided is really helpful! Now the problem has been solved!
|
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 |
All times are GMT -4. The time now is 06:29. |