Allow selecting the zone used by the python wrapper (for multizone drivers) by afshawnlotfi · Pull Request #2019 · su2code/SU2
Proposed Changes
Added SelectZone function to CDriverBase that dynamically sets the zone index
Example Usage
import pysu2 from mpi4py import MPI def execute_su2(): # Import mpi4py for parallel run comm = MPI.COMM_WORLD rank = comm.Get_rank() num_zones = 2 # Initialize the corresponding driver of SU2, this includes solver preprocessing SU2Driver = pysu2.CMultizoneDriver(config_path, num_zones, comm) # type: ignore # Get all the markers defined on this rank and their associated indices. allMarkerIDs = SU2Driver.GetMarkerIndices() # Time loop is defined in Python so that we have acces to SU2 functionalities at each time step comm.Barrier() # Time iteration preprocessing SU2Driver.Preprocess(0) # Run one time-step (static: one simulation) SU2Driver.Run() # Update the solver for the next time iteration SU2Driver.Update() # Monitor the solver and output solution to file if required SU2Driver.Monitor(0) for izone in range(num_zones): SU2Driver.SelectZone(izone) # Get all the markers defined on this rank and their associated indices. allMarkerIDs = SU2Driver.GetMarkerIndices() print(allMarkerIDs) # Output the solution to file SU2Driver.Output(0) # Finalize the solver and exit cleanly SU2Driver.Finalize()
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
- I am submitting my contribution to the develop branch.
- My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
- My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
- I have added a test case that demonstrates my contribution, if necessary.
- I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.