Gridap.jl
Gridap.jl copied to clipboard
Support `ascii=true` option in `writevtk`
It would be convenient if Griap's version of writevtk supported the ascii=true function of the WriteVTK writevtk function. This would help debugging. It would also allow testing Gridap's output in the VtkTests.jl test case.
Good point @eschnett !
In general, we want a way of passing all options supported by WriteVTK.vtk_grid.
The signature of Gridap.writevtk has to be modified with care in order to not mess up with the arguments redirected to visualization_data.
In file,
https://github.com/gridap/Gridap.jl/blob/master/src/Visualization/Vtk.jl
I would do something in this direction:
struct VtkOptions{T}
kwargs::T
end
VtkOptions(;kwargs...) = VtkOptions(kwargs)
function writevtk(options::VtkOptions,args...;kwargs...)
map(visualization_data(args...;kwargs...)) do visdata
write_vtk_file(
options,visdata.grid,visdata.filebase,celldata=visdata.celldata,nodaldata=visdata.nodaldata)
end
end
# Needed for backwards compatibility
function writevtk(args...;kwargs...)
writevtk(VtkOptions(compress=false),args...;kwargs...)
end
then propagate options until we reach the call to vtk_grid which now should be called as
vtkfile = vtk_grid(filebase, points, cells; options...)
From the user perspective when visualizing a FEFunction:
# Default options (like now)
writevtk(trian,"trian",cellfields=["uh"=>uh])
# Custom options
options = VtkOptions(compress=false,ascii=true)
writevtk(options,trian,"trian",cellfields=["uh"=>uh])
Idem for createvtk