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

How to call external function in parallel

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 16, 2016, 10:39
Default How to call external function in parallel
  #1
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
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;
}
Best wishes,
Thomas
t.oliveira is offline   Reply With Quote

Old   June 16, 2016, 14:42
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
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
marupio is offline   Reply With Quote

Old   July 16, 2019, 16:10
Default
  #3
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
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.
t.oliveira is offline   Reply With Quote

Reply

Tags
parallel


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
[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


All times are GMT -4. The time now is 04:39.