Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Aug 13, 2023

Conversation

afshawnlotfi
Copy link
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
Copy link
Member

@pcarruscag pcarruscag left a comment

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.

SU2_CFD/src/drivers/CMultizoneDriver.cpp Outdated Show resolved Hide resolved
SU2_CFD/src/drivers/CDriver.cpp Outdated Show resolved Hide resolved
@pcarruscag
Copy link
Member

@afshawnlotfi is this working as expected?

SU2_CFD/include/drivers/CDriverBase.hpp Outdated Show resolved Hide resolved
SU2_CFD/include/drivers/CDriverBase.hpp Outdated Show resolved Hide resolved
SU2_CFD/include/drivers/CDriverBase.hpp Outdated Show resolved Hide resolved
SU2_CFD/include/drivers/CDriverBase.hpp Show resolved Hide resolved
@afshawnlotfi
Copy link
Contributor Author

@afshawnlotfi is this working as expected?

Sorry this last week has been busy, will verify by the end of this week.

@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
30 checks passed
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