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?

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

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.

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..

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.

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?