-
Notifications
You must be signed in to change notification settings - Fork 441
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
Add skip_zero_time property in OpenFOAMReader #2847
Add skip_zero_time property in OpenFOAMReader #2847
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2847 +/- ##
=======================================
Coverage 94.03% 94.03%
=======================================
Files 76 76
Lines 16399 16409 +10
=======================================
+ Hits 15420 15430 +10
Misses 979 979 |
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.
Looking good so far
EditBut now I see that pipeline does not fail... I may have done something wrong in my tests... Hum. Here is my test: from pyvista import OpenFOAMReader
# First test, with `SetRefresh`
file_1 = OpenFOAMReader(
"/home/hnum/OLART/Docs/Data/OpenFOAM/Chanson_2004_2D_am_calcul_large_iso_density/foam.foam"
)
file_1.skip_zero_time = True
print(file_1.skip_zero_time)
print(file_1.time_values)
file_1.reader.SetRefresh()
file_1.skip_zero_time = False
print(file_1.skip_zero_time)
print(file_1.time_values)
# Second test, without `SetRefresh`
file_2 = OpenFOAMReader(
"/home/hnum/OLART/Docs/Data/OpenFOAM/Chanson_2004_2D_am_calcul_large_iso_density/foam.foam"
)
file_2.skip_zero_time = True
print(file_2.skip_zero_time)
print(file_2.time_values)
file_2.skip_zero_time = False
print(file_2.skip_zero_time)
print(file_2.time_values) This script gives the following output: True
[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]
False
[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]
True
[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]
False
[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0] |
I do not fully understand what the differences are between some of these update and refresh methods do. import pyvista
from pyvista import examples
filename = pyvista.download_cavity(load=False)
reader = pyvista.get_reader(filename)
reader.time_values # Has 0.0 in it
reader.skip_zero_time = True
reader.time_values # Has 0.0 in it
reader.reader.SetRefresh()
reader.time_values # Has 0.0 in it
reader._update_information()
reader.time_values # No longer contains 0.0 |
Here is another test. I am using the same configuration for the OpenFOAMReader as in 8d0e3c7. import pyvista
filename = "/home/hnum/OLART/Docs/Data/OpenFOAM/cavity/foam.foam"
reader = pyvista.get_reader(filename)
reader.skip_zero_time = False
reader._update_information()
print(reader.skip_zero_time is False) # True
print(0.0 in reader.time_values) # True
reader.skip_zero_time = True
reader._update_information()
print(reader.skip_zero_time is True) # True
print(0.0 not in reader.time_values) # True
reader.skip_zero_time = False
reader._update_information()
print(reader.skip_zero_time is False) # True
print(0.0 in reader.time_values) # False <--- Should be True here
reader.skip_zero_time = True
reader._update_information()
print(reader.skip_zero_time is True) # True
print(0.0 not in reader.time_values) # True
reader.skip_zero_time = False
reader._update_information()
print(reader.skip_zero_time is False) # True
print(0.0 in reader.time_values) # False <--- Should be True here
reader.skip_zero_time = True
reader._update_information()
print(reader.skip_zero_time is True) # True
print(0.0 not in reader.time_values) # True
reader.reader.SetRefresh()
reader.skip_zero_time = False
reader._update_information()
print(reader.skip_zero_time is False) # True
print(0.0 in reader.time_values) # True <--- Added setRefresh(), it seems to be working
reader.skip_zero_time = True
reader._update_information()
print(reader.skip_zero_time is True) # True
print(0.0 not in reader.time_values) # True
reader.skip_zero_time = False
reader._update_information()
print(reader.skip_zero_time is False) # True
print(0.0 in reader.time_values) # False <--- Should be True here |
Good investigating! This is puzzling that one method is required in one direction yet a different method is required in the opposite direction. Would you recommend adding |
Hard to tell haha. Since we do not fully understand what these methods do, I think we should only add I am going to do some more testing soon. |
Ok so I've tested with this version ( |
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.
LGTM
Overview
Expose the
SkipZeroTime
property for OpenFOAMReader.Resolves #2843