Skip to content
Snippets Groups Projects
Commit c4ccd9e8 authored by Stephan Hilb's avatar Stephan Hilb
Browse files

add vtk export support for DP1

parent d59124e7
No related branches found
No related tags found
No related merge requests found
......@@ -186,11 +186,16 @@ end
append_data!(vtkfile, f::FeFunction) = append_data!(vtkfile, f, f.space.element)
function append_data!(vtkfile, f::FeFunction, ::P1)
vtk_point_data(vtkfile, f.data, f.name)
# separate out data per cell
fd = vec(f.data[f.space.dofmap])
vtk_point_data(vtkfile, fd, f.name)
end
function append_data!(vtkfile, f::FeFunction, ::DP0)
vtk_cell_data(vtkfile, f.data, f.name)
end
append_data!(vtkfile, f::FeFunction, ::DP1) =
append_data!(vtkfile, f, P1())
......@@ -47,9 +47,9 @@ save(filename, f::FeFunction, fs::FeFunction...) =
save(filename, f.space.mesh, f, fs...)
function save(filename, mesh::Mesh, fs...)
cells = [MeshCell(VTKCellTypes.VTK_TRIANGLE, mesh.cells[:, i]) for i in axes(mesh.cells, 2)]
#vertices = [mesh.vertices[i, j] for i in axes(mesh.vertices, 1), j in axes(mesh.vertices, 2)]
vtkfile = vtk_grid(filename, mesh.vertices, cells)
cells = [MeshCell(VTKCellTypes.VTK_TRIANGLE, 3*(i-1)+1:3*(i-1)+3) for i in axes(mesh.cells, 2)]
vertices = reshape(mesh.vertices[:, mesh.cells], 2, :)
vtkfile = vtk_grid(filename, vertices, cells)
for f in fs
f.space.mesh == mesh ||
throw(ArgumentError("meshes do not match"))
......
......@@ -123,5 +123,5 @@ function myrun()
end
end
save("test.vtu", g, u, p1)
save("test.vtu", g, u, p1, p2)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment