VtkWriter behaves differently in write() and pwrite() for commSize=1
The VtkWriter
provides two methods for writing .vtu files: write()
to create a file in the working directory and pwrite()
(i.e. path-write) with additional parameters for directories where to store the files.
The documentation of the function pwrite()
states:
"pwrite" means "path write" (i.e. write somewhere else than the current directory).
The "p" does not mean this method has a monopoly on parallel writing, [...]
While write()
creates just a .vtu file if commSize == 1 and redirects to pwrite()
in the other case, pwrite()
always creates a pair .pvtu and .vtu (or .pvtp and .vtp) files. In particular, there is no specialization for the commSize == 1 case.
This behavior is a bit irritating, particularly because the write()
method does not allow a directory in the name
parameter. So, there is no way to write serial files in an output directory.
Is this behavior intended and what is the reason for it?
One argument could be, that the path
parameter indicates the directory where to put the collection file (.pvtu and .pvtk) and the piece files are stored relative to this path (maybe using the extendpath
parameter). If the last parameter is omitted, then the piece files are also put into the path
directory, otherwise in path/extendPath
. But, this would also be fine in the case of serial files.
Suggestion: have the same behavior in both methods. Then, the write()
method can be implemented completely in terms of the pwrite()
method and there is no code duplication any more.
Looking in the VtkSequenceWriter
implementation, the behavior is as suggested. Both variants (with and without path/extendPath parameter) create serial files for commSize==1 and collection files otherwise. But, there the requirement for the write()
method is ignored. It is stated in VtkWrite::write
:
\param name Base name of the output files. This should not contain any directory part and no filename extensions.
Interestingly, the VtkSequenceWrite
calls write with path/name
.
Alternative suggestion: change the requirement on the parameters of write()
to allow full paths (without filename extension)