|
[Sponsors] |
June 16, 2016, 10:39 |
How to call external function in parallel
|
#1 |
Senior Member
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12 |
Dear foamers,
I added to a solver a call to an external function after the transport problem is solved, as the code below summarizes. Now, I would like to make the loop between stars (***) parallel. Could you please advise me on that? After reading many docs and posts, I still couldn't do it. Code:
int main(int argc, char *argv[]) { [...] while (simple.loop()) { [...] Solution of a scalar convection-diffusion problem on a given velocity field. [...] // *** parallelize this loop forAll (mesh.cells(), cellI) <= Lines I added (along with the { <= appropriate declarations and definitions). myFunc(states[cellI]); <= states is an object of a class from } <= an external library. // *** end of parallel loop runTime.write(); } Info<< "End\n" << endl; return 0; } Thomas |
|
June 16, 2016, 14:42 |
|
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
I'm not sure I understand. How is this not parallel? When running a parallel simulation, there are nProcs processes executing simultaneously. Each processor will do their own forAll(mesh.cells()) loop, and each one will execute myFunc for each cell on their own memory space.
What is not working?
__________________
~~~ Follow me on twitter @DavidGaden |
|
July 16, 2019, 16:10 |
|
#3 |
Senior Member
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12 |
Dear David,
Thank you for your reply. At that time, I was still new to OpenFOAM. I was running OpenFOAM in serial mode, and wanted to parallelize only the call to the function. After I understood how OpenFOAM runs in parallel, this question lost most of its significance. |
|
Tags |
parallel |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] refineWallLayer Error | Yuby | OpenFOAM Meshing & Mesh Conversion | 2 | November 11, 2021 12:04 |
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 | keepfit | ParaView | 60 | September 18, 2013 04:23 |
[swak4Foam] installation problem with version 0.2.3 | Claudio87 | OpenFOAM Community Contributions | 9 | May 8, 2013 11:20 |
[blockMesh] non-orthogonal faces and incorrect orientation? | nennbs | OpenFOAM Meshing & Mesh Conversion | 7 | April 17, 2013 06:42 |
Version 15 on Mac OS X | gschaider | OpenFOAM Installation | 113 | December 2, 2009 11:23 |