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