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

Finding Cell neighbours using mesh.cellCells() in parallel

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

Like Tree1Likes
  • 1 Post By amirhosseintaran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 14, 2024, 07:05
Default Finding Cell neighbours using mesh.cellCells() in parallel
  #1
Member
 
Divyaprakash
Join Date: Jun 2014
Posts: 76
Rep Power: 12
Divyaprakash is on a distinguished road
Hello everyone,


For my application I need to find cells around a point so that I can perform some operation on them. I need to do this for many such points at every time-step. Currently I am using the following set of lines.


Code:
label cellIndex = mesh.findCell(rr);



labelList appended;
appended.append(cellIndex);

// Info << "Cell Index: " << cellIndex << endl;

// Get the neighbouring cells 4 times
for (int l = 0; l < 4; ++l) {
    int nn = appended.size();
    for (int m = 0; m < nn; ++m) {
        labelList neighbors = mesh.cellCells()[appended[m]];
        appended.append(neighbors);
    }
    // Get rid of repeating values and also sort the array
    Foam::inplaceUniqueSort(appended);
}


However, it won't work when I discretize the domain since the neighbours may be located in some other processor. I have gone through the forum and although I found some threads which mention this issue, they haven't been resolved.


So I am asking again if this is possible in newer versions or some alternatives exist to accomplish the above goal.
Divyaprakash is offline   Reply With Quote

Old   December 13, 2024, 06:07
Default
  #2
New Member
 
Join Date: Nov 2022
Location: Slovenia
Posts: 12
Rep Power: 4
jenc24 is on a distinguished road
Hi, I am dealing with the same problem. If you found the solution/workaround, do you mind sharing it?
jenc24 is offline   Reply With Quote

Old   January 11, 2025, 05:57
Default
  #3
Member
 
Amirhossein Taran
Join Date: Sep 2016
Location: Dublin, Ireland
Posts: 60
Rep Power: 10
amirhosseintaran is on a distinguished road
Quote:
Originally Posted by Divyaprakash View Post
Hello everyone,


For my application I need to find cells around a point so that I can perform some operation on them. I need to do this for many such points at every time-step. Currently I am using the following set of lines.


Code:
label cellIndex = mesh.findCell(rr);



labelList appended;
appended.append(cellIndex);

// Info << "Cell Index: " << cellIndex << endl;

// Get the neighbouring cells 4 times
for (int l = 0; l < 4; ++l) {
    int nn = appended.size();
    for (int m = 0; m < nn; ++m) {
        labelList neighbors = mesh.cellCells()[appended[m]];
        appended.append(neighbors);
    }
    // Get rid of repeating values and also sort the array
    Foam::inplaceUniqueSort(appended);
}


However, it won't work when I discretize the domain since the neighbours may be located in some other processor. I have gone through the forum and although I found some threads which mention this issue, they haven't been resolved.


So I am asking again if this is possible in newer versions or some alternatives exist to accomplish the above goal.
Hi Divyaprakash,

How about the following algorithm:

1- For each cell you find using findCell(), perform a loop to get the cell faces

2- For each face, find the owner ID in which will iterate over the neighbours of that cell.


I think it will automatically resolve your issues with domain decomposition.

Regards,
Amirhossein.
Divyaprakash likes this.
amirhosseintaran is offline   Reply With Quote

Old   January 13, 2025, 12:47
Default
  #4
Member
 
Divyaprakash
Join Date: Jun 2014
Posts: 76
Rep Power: 12
Divyaprakash is on a distinguished road
I am doing it a bit differently now and I have explained the method in my blog.
https://dpcfd.com/posts/2024/12/blog-post-4/
Divyaprakash is offline   Reply With Quote

Reply

Tags
cellcells(), neighbours, parallel

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
sloshingTank3D6DoF failed to run in parallel phsieh2005 OpenFOAM Running, Solving & CFD 1 May 19, 2023 00:51
Finding a cell closest to a point Mohammad74 Fluent UDF and Scheme Programming 2 May 24, 2022 09:17
UDF in case with DPM modle POSTHU Fluent UDF and Scheme Programming 0 March 3, 2021 08:21
Journal file error magicalmarshmallow FLUENT 3 April 4, 2014 13:25
finding the size of smallest cell cfdiscool FLUENT 6 June 18, 2013 06:20


All times are GMT -4. The time now is 01:27.