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

TypeError in pysu2.CSinglezoneDriver in trying to run in Serial mode

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By bigfootedrockmidget

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 4, 2022, 03:18
Exclamation TypeError in pysu2.CSinglezoneDriver while trying to run in Serial mode
  #1
New Member
 
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 5
Vishnu Sankar is on a distinguished road
Hi there,

I want to run the inv_NACA0012 test case from the QuickStart folder (link here) using pysu2 through a python script in serial mode. I have enabled the python wrapper correctly and it gets imported without any error. I have attached my code below:


Code:
import sys
import shutil
import SU2
import pysu2
#from mpi4py import MPI

def main():
    flow_filename = "inv_NACA0012.cfg"
    #comm = MPI.COMM_WORLD
    comm = 0
    FlowDriver = pysu2.CSinglezoneDriver(flow_filename, 1, comm);
    FlowMarkerID = None
    FlowMarkerIDs = FlowDriver.GetAllBoundaryMarkers()
    
    sys.stdout.flush()
    #comm.Barrier()
    FlowDriver.ResetConvergence()
    FlowDriver.Preprocess(0)
    FlowDriver.run()
    FlowDriver.Postprocess()
    stopCalc = FlowDriver.Monitor(0)
    FlowDriver.Output(0)


if __name__ == '__main__':
    main()
I followed the code structure given in the SU2/SU2_PY/SU2_CFD.py (link here). However, it gives the following error:

SU2/bin/pysu2.py", line 527, in __init__ _pysu2.CSinglezoneDriver_swiginit(self, _pysu2.new_CSinglezoneDriver(confFile, val_nZone, MPICommunicator)) TypeError: in method 'new_CSinglezoneDriver', argument 3 of type 'SU2_Comm'

Even if I enable MPI and use comm = MPI.COMM_WORLD instead of comm = 0,I get another error:

The MPI_Comm_rank() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.


Right now I am only interested in running SU2 in the serial mode, could you help me in resolving the issue (the first error)?

Thanks!

--
I am using SU2 version 7.4.0
swig version: 4.0.2
gcc version 4.9.2

Last edited by Vishnu Sankar; October 4, 2022 at 07:18. Reason: Added the code in the correct format
Vishnu Sankar is offline   Reply With Quote

Old   November 1, 2022, 04:19
Default
  #2
New Member
 
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 5
Vishnu Sankar is on a distinguished road
Hi there,


Can anyone give some guidance on how to sort out this issue? I tried out running the example codes in mpi4py documentation page (link here), and they work fine. But when I am specifically running this piece of code with SU2 involved in it, I get the error mentioned above.

I went through various online discussion forums but could not get it sorted :/
Thanks in advance!
Vishnu Sankar is offline   Reply With Quote

Old   November 3, 2022, 05:48
Default
  #3
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 505
Rep Power: 17
bigfootedrockmidget is on a distinguished road
I'm not too familiar with it, but have a look in the code at

SU2_CFD/src/python_wrapper_structure
and you see what kind of functions are available.


It looks like there is a Get_Drag() and Get_Lift() function and similar functions are present as well.
Vishnu Sankar likes this.
bigfootedrockmidget is offline   Reply With Quote

Old   November 3, 2022, 06:08
Default
  #4
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 505
Rep Power: 17
bigfootedrockmidget is on a distinguished road
There are a couple of examples for the pywrapper in TestCases/py_wrapper, you can first run them to make sure that everything is working properly on your local machine (if you haven't done so already)
bigfootedrockmidget is offline   Reply With Quote

Old   June 17, 2023, 02:03
Smile
  #5
New Member
 
Vishnu_iitb
Join Date: Oct 2020
Location: Mumbai
Posts: 16
Rep Power: 5
Vishnu Sankar is on a distinguished road
Apologies for the very late reply, apparently I got busy with other projects and had to pause the one with SU2 for a while. Thanks a lot your prompt replies @bigfoot, seems the MPI version was creating the issue. I had a lot of trouble with setting up openMPI in the right way. Here are a few suggestions to get do it right for newbies like me who want to use the python wrapper of SU2


- Install openMPI and mpi4py as mention here: https://mdolab-mach-aero.readthedocs...yPackages.html (best source I ever found for mpi installation)

- Install SU2 in parallel mode
- Install the python wrapper appropriately (look at the last reply from the thread: ImportError: pysu2 incase you are facing python path issues)


Python Code for running the Quick Start is re-written with corrections below:
Code:

import sys
import shutil
import SU2
import pysu2
from mpi4py import MPI

def main():
  flow_filename="inv_NACA0012.cfg"
  comm= MPI.COMM_WORLD
  #comm = None
  FlowDriver=pysu2.CSinglezoneDriver(flow_filename, 1, comm);
  FlowMarkerID=None
  FlowMarkerIDs=FlowDriver.GetAllBoundaryMarkers()
  FlowMarkerList=FlowDriver.GetAllBoundaryMarkersTag()
  sys.stdout.flush()
  #comm.Barrier()
  FlowDriver.ResetConvergence()
  FlowDriver.Preprocess(0)
  FlowDriver.Run()
  FlowDriver.Postprocess()
  stopCalc=FlowDriver.Monitor(0)
  FlowDriver.Output(0)
  Cl=FlowDriver.Get_LiftCoeff()
  Cd=FlowDriver.Get_DragCoeff()
  Mz=FlowDriver.Get_Mz()

 if __name__=='__main__':

    main()
(Sorry for spacing issue couldn't help it)
Vishnu Sankar is offline   Reply With Quote

Reply

Tags
pysu2, su2


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
[PyFoam] having problems with pyfoam Installation vitorspadetoventurin OpenFOAM Community Contributions 3 December 2, 2014 07:18
How to run icoFsiFoam in parallel mode? AsDF OpenFOAM Running, Solving & CFD 2 February 21, 2014 07:56
Working directory via command line Luiz CFX 4 March 6, 2011 20:02
How to run numeca in serial/parallel mode? sangamesh Fidelity CFD 0 June 30, 2009 10:26
Parallel run diverges, serial does not SammyB OpenFOAM Running, Solving & CFD 1 May 10, 2009 03:28


All times are GMT -4. The time now is 20:49.