TimeValue field data is wrong for vtkNonOverlappingAMR files written in Catalyst
The Pagosa adaptor uses Catalyst to write vtkNonOverlappingAMR files as .vth files. TimeValue is a standard field data added by Catalyst and XML writers to store time information.
We are trying to store simulation time in TimeValue in vth files. The problem is that TimeValue is correct for the first timestep, but stays the same value for each timestep afterwards. I have attached an example dataset. In the example dataset, if you open the .vth files in a text editor and see the TimeValue entry, you can check the min and max range and see that TimeValue is always the same.
Example dataset: GridCellData.tar.gz
GridCellData_1.vth, TimeValue=1.002
GridCellData_2.vth, TimeValue=1.002
GridCellData_3.vth, TimeValue=1.002
etc...
There are two places where TimeValue is being added: 1) in the Catalyst code (vtkCPProcessor.cxx, line 250) and 2) XML writers.
I checked the code in Catalyst, and TimeValue seems to be set to the correct time there.
It is in the XML writers where the problem seems to occur. Specifically, in vtkXMLCompositeDataWriter.cxx, function WriteData(), where the TimeValue field data is getting added. If you query the time being used there, it is the wrong time.
The strange thing is that if I query the time of the grid at any point in the adaptor or catalyst python script, it shows the correct time. Somehow by the time the code gets to the XML writer, querying the time gives the wrong answer.
Also, sometimes I see this warning when running. Seems likely to be related.
( 13.808s) [pvbatch.9 ]vtkPVTrivialProducer.cx:95 WARN| vtkPVTrivialProducer (0xf950250): Requesting time 5.50247 but only 1.00257 is available
The Pagosa adaptor also writes out vtm files. The vtm files do no have this issue. TimeValue has the correct time. Also, the vth files have vti files associated with them. Those vti files also have the right time. It's something specific to the .vth file.
Note: When I say "query the time", I mean something like the below code. It's exactly how the code which adds TimeValue get the time.
double time = grid->GetInformation()->Get(vtkDataObject::DATA_TIME_STEP());
How to Reproduce
Example dataset: GridCellData.tar.gz
Catalyst python script: CoProcess_vth.py
Miniapp script: filedriver_miniapp.py
I have modified filedriver_miniapp.py
from the original so that it sets the time to be 0, 1, 2, etc., independent of what the time was in the original files that were read in. So you would expect in the resulting files to have TimeValue
of 0, 1, 2, etc.
To run, use the command
pvpython filedriver_miniapp.py -g "GridCellData/*.vth" -s CoProcess_vth.py
The resulting files will be in a directory called pv_files
. Load the .vth files in a text editor, and inspect the TimeValue
xml entry. TimeValue
will be 0 for all .vth files.