|
[Sponsors] |
I am doing something wrong with scatterList and boundaryFieldRef() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 17, 2020, 08:52 |
I am doing something wrong with scatterList and boundaryFieldRef()
|
#1 |
Member
David Andersson
Join Date: Oct 2019
Posts: 46
Rep Power: 7 |
Hi Foamers,
I am writing a functionObject that is reading the pressureField, performing some calculations on those values and lastly writing the new values to a custom made field. I am currently working on adapting the code for parallel computing and I am almost there, however there is one last problem that I need help with to solve. The code is compiling and running properly but when I validate the parallel run against the EXACT same run in serial they are not the same (and I am confident that the serial run is correct), or to be precise the values that are written by the master proc (proc0) are correct but the values written by the other procs are not. I print the values in ESWLVec just before I scatter the list and update the field and then everything looks good. However, when I compare the field from the parallel run and serial run in paraview it is not the same anymore. This is the last section of my code. Code:
. . Pstream::gatherList(facePressuresPerProc); . calculate meanVec and stdVec . calculate nomenator and denomenator . . ESWLVec.resize(totNoFaces); for(int i = 0; i < totNoFaces; i++){ if(meanVec[i] >= 0){ ESWLVec[i] = meanVec[i] + std::abs(3.2*stdVec[i]*nomenator[i]/sqrt(denomenator)); }else{ ESWLVec[i] = meanVec[i] - std::abs(3.2*stdVec[i]*nomenator[i]/sqrt(denomenator)); } } //- Calculating ESWL field if(Pstream::parRun()){ Foam::List<Foam::List<scalar>> ESWLforField(Pstream::nProcs(),Foam::List<scalar>(0.0)); for(int iProc=0; iProc<Pstream::nProcs(); iProc++){ ESWLforField[iProc] = Foam::List<scalar>(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]; Info << "P=" << gatheredPatchMapping[i] << " F=" << gatheredFaceMapping[i] << " ESWL=" << ESWLVec[i] << endl; i++; } } Pstream::scatterList(ESWLforField); for(int i=0; i<ESWLforField[Pstream::myProcNo()].size(); i++){ label iPatch = patchMapping[Pstream::myProcNo()][i]; label iFace = faceMapping[Pstream::myProcNo()][i]; ESWL.boundaryFieldRef()[iPatch][iFace] = ESWLforField[Pstream::myProcNo()][i]; } } Cheers, David |
|
Tags |
parallel computing, scatter |
|
|