Allow selecting the zone used by the python wrapper (for multizone drivers) by afshawnlotfi · Pull Request #2019 · su2code/SU2 · GitHub
Skip to content

Allow selecting the zone used by the python wrapper (for multizone drivers)#2019

Merged
pcarruscag merged 8 commits into
su2code:developfrom
afshawnlotfi:develop
Aug 13, 2023
Merged

Allow selecting the zone used by the python wrapper (for multizone drivers)#2019
pcarruscag merged 8 commits into
su2code:developfrom
afshawnlotfi:develop

Conversation

@afshawnlotfi

Copy link
Copy Markdown
Contributor

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.

@pcarruscag pcarruscag changed the title added compatibility for multizone driver selection Allow selecting the zone used by the python wrapper interface Apr 29, 2023

@pcarruscag pcarruscag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the lead on this, you changed too many places, only the functions of the python wrapper (the ones in the pySU2 group) need to be changed.
The others are internal functions of the drivers that need to work on the zone the driver decides.

Comment thread SU2_CFD/src/drivers/CMultizoneDriver.cpp
Comment thread SU2_CFD/src/drivers/CDriver.cpp Outdated
@pcarruscag

Copy link
Copy Markdown
Member

Comment thread SU2_CFD/include/drivers/CDriverBase.hpp Outdated
Comment thread SU2_CFD/include/drivers/CDriverBase.hpp Outdated
Comment thread SU2_CFD/include/drivers/CDriverBase.hpp Outdated
Comment thread SU2_CFD/include/drivers/CDriverBase.hpp
@afshawnlotfi

Copy link
Copy Markdown
Contributor Author

@pcarruscag pcarruscag changed the title Allow selecting the zone used by the python wrapper interface Allow selecting the zone used by the python wrapper (for multizone drivers) Aug 7, 2023
@pcarruscag pcarruscag merged commit 931f367 into su2code:develop Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants