|
[Sponsors] |
June 19, 2020, 10:24 |
scatterList
|
#1 |
Member
David Andersson
Join Date: Oct 2019
Posts: 46
Rep Power: 7 |
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 Code:
[0] ESWLforField[0].size() = 248 [0] ESWLforField[1].size() = 104 [1] ESWLforField[0].size() = 0 [1] ESWLforField[1].size() = 104 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 10:35. |
|
Tags |
parallel computation, scatter |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to use gatherlist and scatterlist? | gxy200992243 | OpenFOAM Running, Solving & CFD | 2 | January 27, 2021 12:22 |
I am doing something wrong with scatterList and boundaryFieldRef() | sippanspojk | OpenFOAM Programming & Development | 0 | June 17, 2020 08:52 |
discussions about the gatherList, scatterList, and combine | openfoammaofnepo | OpenFOAM Programming & Development | 0 | February 5, 2014 12:15 |