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

Multicore sequential sum and index extraction

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 19, 2025, 04:41
Default Multicore sequential sum and index extraction
  #1
New Member
 
Raoul
Join Date: Apr 2021
Posts: 17
Rep Power: 6
rol97 is on a distinguished road
Hi everyone,

I am writing a routine in OpenFOAM that requires me to perform the following operations:

- calculate a scalarField (volScalarField works fine as well, I do not need boundaries thought), let us call it myField.

- perform the following operation on the field
Code:
for (label i = 1; i < myField.size(); i++)
{
    myField[i] += myField[i-1]; 
}
- then from myField I have to find the closest element to a scalar myScalar, i was thinking of the following loop
Code:
forAllReverse (myField, i)
{
    if (myScalar >= myField[i])
    {
    myElement = i;
    break; 
    }
}
I have already implemented and works perfectly in single core, however, when moving to multicore this process obviously does not work, as the same process is repeated separately by each core, thus I am not finding an "absolute" value of myElement, but several indeces.

Any suggestion on how to make it multicore-proof?

Thanks!

Edit: I forgot to say that I am using OpenFOAM v9, I am not sure it that makes any difference!
rol97 is offline   Reply With Quote

Reply

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



All times are GMT -4. The time now is 22:54.