CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > SU2

Multiple MPI communicators for python wrapper

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 19, 2021, 10:57
Default Multiple MPI communicators for python wrapper
  #1
New Member
 
Jane Bae
Join Date: Apr 2021
Posts: 2
Rep Power: 0
jbae is on a distinguished road
Hi,

I am trying to run multiple runs of SU2 using the python wrapper. However, whenever I try to pass a pre-set communicator that is not MPI_COMM_WORLD as the communicator, the program seems to hang. Does anyone have an idea why this might be?

Here is a simplified version of the code I'm trying to run:

Code:
import sys
import shutil
import pysu2 as pysu2          # imports the SU2 adjoint-wrapped module
from mpi4py import MPI

def main(comm):

  # Define the input file names
  flow_filename = "config.cfg"

  # Initialize the flow driver of SU2, this includes solver preprocessing
  FlowDriver = pysu2.CSinglezoneDriver(flow_filename, 1, comm);
  
  print("\n------------------------------ Begin Solver -----------------------------\n")
  sys.stdout.flush()
  comm.Barrier()

  Flow_Time  = FlowDriver.GetTime_Iter()
  Flow_nTime = FlowDriver.GetnTimeIter()

  for i in range(Flow_nTime):

    # Time iteration preprocessing
    FlowDriver.Preprocess(Flow_Time+i)
    FlowDriver.Run()
    FlowDriver.Postprocess()
    FlowDriver.Update()
    FlowDriver.Output(Flow_Time+i)
    stopCalc = FlowDriver.Monitor(Flow_Time+i)
    if stopCalc:
        break

# -------------------------------------------------------------------
#  Run Main Program
# -------------------------------------------------------------------

# this is only accessed if running from command prompt
if __name__ == '__main__':

    world_rank = MPI.COMM_WORLD.Get_rank()
    world_size = MPI.COMM_WORLD.Get_size()

    if world_rank < world_size//2:
        color = 1
    else:
        color = 2

    comm = MPI.COMM_WORLD.Split(color,world_rank)

    print('[Pre Barrier] My Rank is: ' + str(world_rank))
    sys.stdout.flush()

    comm1.Barrier() # Checking the communicator was correctly created

    print('[Post Barrier] My Rank is: ' + str(world_rank))
    sys.stdout.flush()

    if world_rank < world_size//2:
        main(comm)
jbae is offline   Reply With Quote

Old   April 19, 2021, 11:38
Default
  #2
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 466
Rep Power: 13
pcg is on a distinguished road
That was added in version 7.1.1
Third feature from the top https://github.com/su2code/SU2/releases/tag/v7.1.1
pcg is offline   Reply With Quote

Old   April 19, 2021, 13:31
Default
  #3
New Member
 
Jane Bae
Join Date: Apr 2021
Posts: 2
Rep Power: 0
jbae is on a distinguished road
Thank you. I was in one of the developer branches. The origin branch seems to work fine.
jbae is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 06:09
Sgimpi pere OpenFOAM 27 September 24, 2011 07:57
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21
Error using LaunderGibsonRSTM on SGI ALTIX 4700 jaswi OpenFOAM 2 April 29, 2008 10:54
Is Testsuite on the way or not lakeat OpenFOAM Installation 6 April 28, 2008 11:12


All times are GMT -4. The time now is 06:51.