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

Reset derived quantity objects data and t at the beginning of a simulation #733

Open
wants to merge 2 commits into
base: fenicsx
Choose a base branch
from

Conversation

Allentro
Copy link
Contributor

@Allentro Allentro commented Apr 2, 2024

Proposed changes

I have implemented a fix to reset export.t and export.data at the beginning of a simulation, accompanied by a respective test. This PR resolves #728

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring
  • Documentation Update (if none of the other choices apply)
  • New tests

Checklist

  • Black formatted
  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@Allentro Allentro marked this pull request as ready for review April 2, 2024 22:51
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.40%. Comparing base (3d6b9da) to head (f08f0b5).

Additional details and impacted files
@@           Coverage Diff            @@
##           fenicsx     #733   +/-   ##
========================================
  Coverage    98.39%   98.40%           
========================================
  Files           27       27           
  Lines         1437     1439    +2     
========================================
+ Hits          1414     1416    +2     
  Misses          23       23           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RemDelaporteMathurin RemDelaporteMathurin added bug Something isn't working fenicsx Issue that is related to the fenicsx support labels Apr 3, 2024
Copy link
Collaborator

@RemDelaporteMathurin RemDelaporteMathurin left a comment

Choose a reason for hiding this comment

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

Initial round of comments, the fix obviously works fine, but it's not the right place for it.

Comment on lines +329 to +330
export.t = []
export.data = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doing it here is not the right place.
This iterates through all the exports, which can be derived quantities, but also VTXExport or XDMFExport etc.

Instead, we could do it in write(), making use of the self._is_first_time_export attribute. For example here:

if self._first_time_export:
header = ["t(s)", f"{title}"]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively we could do it here, but with an additional type check to only do this for derived quantities.

Comment on lines +346 to +349
my_export = F.SurfaceFlux(
field=H,
surface=surf,
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you parametrise this test to also check for other derived quantities (eg. TotalVolume)

@RemDelaporteMathurin
Copy link
Collaborator

Hey @Allentro what is the status of this?

@Allentro
Copy link
Contributor Author

Hey @Allentro what is the status of this?

Hi Remi, sorry this has slipped my list. I'll get this complete tomorrow!

@RemDelaporteMathurin
Copy link
Collaborator

Hi @Allentro! Do you want someone else to pick up this PR?

@Allentro
Copy link
Contributor Author

Hi @Allentro! Do you want someone else to pick up this PR?

Hi Remi,

This slipped my inbox.. I was just scrolling through my mentions and saw this. I'm happy to work on this tomorrow evening. Sorry for the delay on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fenicsx Issue that is related to the fenicsx support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Derived quantity objects data and t attributes are not emptied at beginning of simulation
2 participants