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

scatterList

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 19, 2020, 09:24
Default scatterList
  #1
Member
 
David Andersson
Join Date: Oct 2019
Posts: 46
Rep Power: 6
sippanspojk is on a distinguished road
Hi foamers,
I need help with scatterList because it is not doing what I want it to do. Below you see my code where I construct a list of size nProcs() on my master processor and then I scatter that list in hope to "deconstruct" the list and provide one chunk of the list to each processor, however that is not how it is working.

I run the case on two processors for the sake of easy while troubleshooting my code. I print the size of the list chunks before and after scattering to see how it changes and this is what it gives me:

Code:
Before scatter
[1] ESWLforField[0].size() = 0
[1] ESWLforField[1].size() = 0
[0] ESWLforField[0].size() = 248
[0] ESWLforField[1].size() = 104
After scatter
[0] ESWLforField[0].size() = 248
[0] ESWLforField[1].size() = 104
[1] ESWLforField[0].size() = 248
[1] ESWLforField[1].size() = 0
However, what I expected after scattering was:
Code:
[0] ESWLforField[0].size() = 248
[0] ESWLforField[1].size() = 104
[1] ESWLforField[0].size() = 0
[1] ESWLforField[1].size() = 104
what am I doing wrong here?

I would be very grateful if someone could help me out here.
Thanks,
David

SOLVED: I am now using listCombineScatter() instead of scatterList() and then it works fine.


Code:
if(Pstream::parRun()){
    Foam::List<Foam::List<scalar>> ESWLforField(Pstream::nProcs());
    if (Pstream::master()){
        for(int iProc=0; iProc<Pstream::nProcs(); iProc++){
            ESWLforField[iProc].setSize(nFacesPerProc[iProc],0.0);
        }

        int i = 0;
        for(int iProc=0; iProc<Pstream::nProcs(); iProc++){
            for(int iFace=0; iFace<nFacesPerProc[iProc]; iFace++){
                ESWLforField[iProc][iFace] = ESWLVec[i];
                i++;
            }
        }
    }

    Info << "Before scatter" << endl;
    Pout << "ESWLforField[0].size() = " << ESWLforField[0].size() << endl;
    Pout << "ESWLforField[1].size() = " << ESWLforField[1].size() << endl;

    Pstream::listCombineScatter(ESWLforField);

    Info << "After scatter" << endl;
    Pout << "ESWLforField[0].size() = " << ESWLforField[0].size() << endl;
    Pout << "ESWLforField[1].size() = " << ESWLforField[1].size() << endl;

Last edited by sippanspojk; June 24, 2020 at 09:35.
sippanspojk is offline   Reply With Quote

Reply

Tags
parallel computation, scatter


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
How to use gatherlist and scatterlist? gxy200992243 OpenFOAM Running, Solving & CFD 2 January 27, 2021 11:22
I am doing something wrong with scatterList and boundaryFieldRef() sippanspojk OpenFOAM Programming & Development 0 June 17, 2020 07:52
discussions about the gatherList, scatterList, and combine openfoammaofnepo OpenFOAM Programming & Development 0 February 5, 2014 11:15


All times are GMT -4. The time now is 07:55.