-
Notifications
You must be signed in to change notification settings - Fork 100
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
Find a better way to test Trixi2Vtk #680
Comments
I am trying to collect some ideas here, and weigh the pros and cons. Feel free to amend this post with more arguments or new ideas (and to leave a message afterwards stating what you did): 0 Do not change anythingThat is, compare SHA hashes of the VTK files generated while testing against reference values. Pro
Con
1 Store VTK uncompressedAchievable by passing Pro
Con
2 Compare only headersInstead of comparing the entire file and its contents, we could just compare the headers without the data. For example, for a VTK file, the file would look something like: <?xml version="1.0" encoding="utf-8"?>
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64" compressor="vtkZLibDataCompressor">
<UnstructuredGrid>
<Piece NumberOfPoints="259997" NumberOfCells="197440">
<Points>
<DataArray type="Float64" Name="Points" NumberOfComponents="3" format="appended" offset="0"/>
</Points>
<Cells>
<DataArray type="Int32" Name="connectivity" NumberOfComponents="1" format="appended" offset="543461"/>
<DataArray type="Int32" Name="offsets" NumberOfComponents="1" format="appended" offset="1369328"/>
<DataArray type="UInt8" Name="types" NumberOfComponents="1" format="appended" offset="1598133"/>
</Cells>
<CellData>
<DataArray type="Float64" Name="rho" NumberOfComponents="1" format="appended" offset="1598380"/>
<DataArray type="Float64" Name="v1" NumberOfComponents="1" format="appended" offset="2969685"/>
<DataArray type="Float64" Name="v2" NumberOfComponents="1" format="appended" offset="4283158"/>
<DataArray type="Float64" Name="p" NumberOfComponents="1" format="appended" offset="5822483"/>
</CellData>
</Piece>
</UnstructuredGrid>
<AppendedData encoding="raw">
[raw encoded data]
</AppendedData>
</VTKFile> We could just read in the files line by line until Pros
Cons
3 Read in VTU files and compare directlySince ParaView files are "somewhat" compatible to XML, we could just parse them as XML and then compare. Alternatively, we could try to read them in as actual VTK files. Pros
Cons
|
My current favorite would be to try 1) and if it doesn't help enough, go for 2). |
It looks to me like the headers of two simulations in 2) are identical if the same number of cells and the same polydeg has been used. So, the output could have completely different nodal coordinates and nodal values, and the tests would still pass, right? |
Yes, correct. Although I think it's unlikely (but not impossible) that the number of cells is "accidentally" generated correctly, this check no. 2) will tell us nothing about the contents of the individual arrays. If that's not enough, I think we'd have to go towards something like 3) and either parse the files as XML or directly write a (simplified) parser to be able to compare values one by one against a reference file. |
We're already doing this in practice, aren't we? Speaking at least for me, whenever I see a failing hash check, I expect it to be caused by minor differences and tend to think we should just update the hash. Effectively, we could just remove the checks of the hashes and would only get some smoke tests 🤷 |
Yes, I agree, @ranocha - I have done the same... In the past, I have done such tests for comparing two files by first comparing their headers and then compare the contents variable by variable. I expected equality for integer types and allowed for 1e-12 difference for floating point values. The VTK XML format is not super sophisticated, so I guess it would be possible to write a rudimentary reader in Julia. Given that we will likely always rely on ParaView for 3D visualization, I think the question about a more sophisticated test routine is not "if" but rather "when". |
To support this discussion at the next meeting, I went ahead and implemented a rudimentary VTK XML reader: ReadVTK.jl. It is capable of reading in all unstructured VTK files produced by Trixi2Vtk, i.e., those files ending on Thus, it should be sufficient for comparing VTK files against references during testing, should we decide to go down this road. If necessary, adding support for the remaining file types wouldn't be too hard either. |
The consensus at today's Trixi meeting was to rewrite Trixi2Vtk.jl testing to use ReadVTK.jl for comparing generated VTK files against reference files. Maybe @FelipeSantillan will be able to help us with this. |
@FelipeSantillan @ranocha @jlchan This is what I had in mind for Rewrite
A possible API for said test function could be function compare_vtk_files(reference_file, vtk_file, atol=1e-12)
...
end where Each test category should be in its own The code that compares and checks a single file against its reference (i.e., I would put the reference files in a repo, e.g., Now, these are my thoughts that I had when starting to write ReadVTK.jl, based on experience from other codes I used to work with, where we compared results against reference files. Please note that these are merely taken to be suggestions, and I might very well have missed something, but maybe this can be used to start a conversation and give @FelipeSantillan a starting point. |
Regarding the The former approach might be slightly cleaner, the latter is likely more convenient. What do you think? |
Your overall proposal sounds good to me - thanks 👍 |
OK. I think it is very well in a usable state right now. I'll check again, though, and then register it as a new package if it seems OK. |
Moreover, we should copy the elixirs we use for testing Trixi2Vtk.jl over to Trixi2Vtk.jl - the exact content of elixirs shouldn't be part of the public API of Trixi.jl, I think. This has already caused problems in trixi-framework/Trixi2Vtk.jl#46 |
This allows us to merge simple improvements such as #50 without tedious and useless work. Xref trixi-framework/Trixi.jl#680
This allows us to merge simple improvements such as #50 without tedious and useless work. Xref trixi-framework/Trixi.jl#680
Currently, Trixi2Vtk tests are comparing hashes of the generated VTK files. This doesn't work reliably, especially not when testing on different operating systems.
The text was updated successfully, but these errors were encountered: