-
Notifications
You must be signed in to change notification settings - Fork 35
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
TL: generic FieldsIO class for n-dimensional rectilinear grids + VTK support #533
Conversation
You can make your code compatible with older Python versions with a slightly less clean syntax:
|
Oh thanks, I didn't find this yesterday ... but do we need that ? 3.10 will be in end of life next year 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't read too carefully, but looks good to me.
I personally would use the older syntax compatible with 3.10. But I also wouldn't insist on it.
About adding vtk as a dependency: Could that become a problem on some laptops?
|
||
# ------------------------------------------------------------------------- | ||
# Class specifics | ||
# ------------------------------------------------------------------------- | ||
@property | ||
def nX(self): | ||
"""Number of points in x direction""" | ||
return self.header["coordX"].size | ||
"""Number of points in y direction""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really the number of points in y direction or is it in all directions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's in all directions indeed ... gridSizes
instead ?
pySDC/helpers/fieldsIO.py
Outdated
def readField(self, idx): | ||
""" | ||
Read one field stored in the binary file, corresponding to the given | ||
time index, possibly in MPI mode. | ||
time index, eventually in MPI mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental reverting of a commit that corrected it ... I'll change it if I do another commit
|
If no one has any issue anymore, then it's ready to be merged. |
You said "I was the only one using the old classes", but then you need to add |
Those are two different aspects. First : there were two classes before, Second : the |
I am generally in favor of having streamlined output in pySDC. To me, this is part of the feature set it should have for prototyping. If you want to test out a new method on the existing problems and then have to work out how to plot the results, even though other people have done that before, that is just a waste of time. |
So, the idea is to establish this as the default way to dump files for visualization out of pySDC, yes? |
If you are fine with the current minimalist structure, yes 😉 |
We should write a hook for doing this as well. But in a follow up PR.. |
That would be your area of expertise then, not mine 😅 |
Good idea. I like this approach and I'm happy to have this as the default way of doing things. Can we add a hook and a demo to this PR, then? |
I can add a more extended documentation + demo of the data IO structure, but concerning the hook class I would prefer letting @brownbaerchen do that (he'll probably do that better than me) |
I can do a hook, but I would prefer doing that in a second PR. This diff is already quite large and this makes sense by itself already. |
So, demo + extended doc + hooks in a next PR, I'm also fine with that. What about you @pancetta ? |
pySDC.helpers.fieldsIO
reformatingCart1D
andCart2D
have been replace by oneRectilinear
class that does the same for all dimensions. It's not backward compatible, but since I was the only one using the old classes, it should be fine ...While this is pretty neat to handle n-dimensional data without making the code too complicated, it's still seen as a syntax error in python 3.10 and lower. Hence the module requires now python 3.11 and higher, but it does not prevent to use pySDC with lower version (just do not import
pySDC.helpers.fieldsIO
...)VTK support
Two utility functions added in
pySDC.helpers.vtkIO
, namelywriteToVTR
andreadFromVTR
that allow to go from numpy array to VTR files and vice-versa. Also, atoVTR
method has been added to thepySDC.helpers.fieldsIO.Rectilinear
class such that conversion of binary file storing fields can be easily done like this :It allows to separate IO during simulation, that can be easilly done in parallel with the FieldsIO features, from the generation of VTR files, that would have been way trickier in space parallel ... Also, this VTR IO feature is now only enabled for 3D fields only, although it could be adapted for 1D or 2D fields (but use rather matplotlib for that, not VTK 😮💨)
So thanks to this PR, @brownbaerchen will be able to generate nice 3D movies that could make @danielru happy 🥳