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

[CoSimulationApplication] Adding FluxWrapper and FluxIO #11523

Closed
wants to merge 9 commits into from

Conversation

loumalouomega
Copy link
Member

@loumalouomega loumalouomega commented Aug 29, 2023

📝 Description

Includes #11524

This PR introduces a new CoSimulation wrapper called FluxWrapper that serves as a dedicated Kratos wrapper for the Flux solver.

NOTE: This wrapper class was not developed by me, the details I can provide are limited.

The contents of the commit include the following changes:

  1. Definition of the FluxWrapper class that extends CoSimulationSolverWrapper.
  2. Definition of the FluxIO class that extends CoSimulationIO

🆕 Changelog

@loumalouomega loumalouomega added Cleanup Applications FastPR This Pr is simple and / or has been already tested and the revision should be fast labels Aug 29, 2023
@loumalouomega loumalouomega requested a review from a team as a code owner August 29, 2023 12:34
@loumalouomega loumalouomega added Enhancement and removed Cleanup FastPR This Pr is simple and / or has been already tested and the revision should be fast labels Aug 29, 2023
@loumalouomega loumalouomega changed the title [CoSimulationApplication] Minor refactor and typo correction in documentation and solver wrapper [CoSimulationApplication] Adding FluxWrapper and FluxIO Aug 29, 2023
@philbucher
Copy link
Member

Hm there is lots of unused code, will review over the weekend

Btw I think there is even wrong syntax such that the file cannot even be imported

@loumalouomega
Copy link
Member Author

Hm there is lots of unused code, will review over the weekend

Okay

Btw I think there is even wrong syntax such that the file cannot even be imported

What do you mean?, I refactored the code that was given to me (cleaning up) and a priori a fixed some import issues

Comment on lines +57 to +65
# Check for a subprocess call
world_rank = 0
if KM.IsDistributedRun() :
world_data_comm = KM.ParallelEnvironment.GetDataCommunicator("World")
world_rank = world_data_comm.Rank()

# Prevent any launch of a FluxServer from a subprocess
if world_rank != 0:
return
Copy link
Member

Choose a reason for hiding this comment

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

this should not be necessary due to the usage of the _GetDataCommunicator function. Not sure why it was added

Copy link
Member Author

Choose a reason for hiding this comment

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

Me neither, as I said, I have not wrote this

Copy link
Member

Choose a reason for hiding this comment

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

To my understanding, it can be changed to world_rank=_GetDataCommunicator().Rank() but let me confirm it with the author

Copy link
Member

Choose a reason for hiding this comment

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

I think the entire block is not needed any more, I implemented this (solvers not running on some MPI-procs) on a global level

I suggest to remove it and try

Comment on lines +241 to +246
if hasattr(self, 'flux') :
# Close the MultiPhysic session
self.flux.CloseMultiPhysics()
# Save and close the Flux project
self.flux.SaveProject()
self.flux.CloseProject()
Copy link
Member

Choose a reason for hiding this comment

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

should this also be called in Finalize?

If so, then perhaps refactor to a separate fct

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, but I don't know the details

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should call it twice in finalize and also in del but let me ask the author.

Copy link
Member

Choose a reason for hiding this comment

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

meant to call it in Finalize instead of del, as in my experience del is not reliable

but perhaps a flag would be useful, e.g. flux_was_closed which is set in Finalize. If for some reason the run crashes, and only del is called, then you could execute the closing of flux depending on this flag

Copy link
Member

Choose a reason for hiding this comment

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

maybe you could also use atexit instead of del

@loumalouomega
Copy link
Member Author

@pooyan-dadvand there are two comments from @philbucher that I don't know how to handle, can you take a look?

@pooyan-dadvand
Copy link
Member

I am closing this PR as Flux team feels that the wrapper is not ready yet to be added here.

@loumalouomega loumalouomega deleted the CoSim/adding-flux-wrapper branch October 24, 2023 15:50
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