64 character(len=1024) :: fname
65 character(len=10) :: id_str
68 fname = this%get_base_fname()
70 write(id_str,
'(i10.10)')
pe_rank
72 fname = trim(fname(1:suffix_pos-1)) // id_str //
'.vtk'
80 class(*),
target,
intent(in) :: data
81 real(kind=
dp),
intent(in),
optional :: t
82 type(
mesh_t),
pointer :: msh => null()
83 type(
field_t),
pointer :: fld => null()
85 type(
dofmap_t),
pointer :: dm => null()
89 character(len=1024) :: fname
110 fname = this%get_next_output_fname()
111 open(newunit = file_unit,
file = trim(fname))
114 write(file_unit, fmt =
'(A)')
'# vtk DataFile Version 2.0'
115 write(file_unit, fmt =
'(A)')
'Neko'
116 write(file_unit, fmt =
'(A)')
'ASCII'
118 if (
associated(msh))
then
119 write(file_unit, fmt =
'(A)')
'DATASET UNSTRUCTURED_GRID'
123 if (
associated(mfld))
then
125 else if (
associated(fld))
then
128 else if (
associated(dm))
then
129 write(file_unit, fmt =
'(A)')
'DATASET POLYDATA'
134 else if (
associated(tet_msh))
then
135 write(file_unit, fmt =
'(A)')
'DATASET UNSTRUCTURED_GRID'
137 else if (
associated(tri_msh))
then
138 write(file_unit, fmt =
'(A)')
'DATASET UNSTRUCTURED_GRID'
149 class(*),
target,
intent(inout) :: data
151 call neko_error(
'VTK file read not implemented')
157 type(
mesh_t),
intent(inout) :: msh
158 integer :: i, j, vtk_type
159 integer,
dimension(8),
parameter :: vcyc_to_sym = [1, 2, 4, 3, &
162 if (.not.
allocated(msh%pt_lid))
then
163 call neko_error(
'VTK output requires a mesh with generated connectivity')
167 write(unit, fmt =
'(A,I8,A)')
'POINTS', msh%mpts,
' double'
169 write(unit, fmt =
'(F15.8,F15.8,F15.8)')
real(msh%points(i)%x,
dp)
173 write(unit, fmt =
'(A,I8,I8)')
'CELLS', msh%nelv, msh%nelv*(msh%npts+1)
176 write(unit, fmt =
'(I8,8I8)') msh%npts, &
177 (msh%pt_lid(vcyc_to_sym(j), i) - 1, j = 1, msh%npts)
181 write(unit, fmt =
'(A,I8)')
'CELL_TYPES', msh%nelv
183 if (msh%gdim .eq. 3) vtk_type = 12
185 write(unit, fmt =
'(I2)') vtk_type
196 write(unit, fmt =
'(A,I8)')
'CELL_DATA', mfld%msh%nelv
197 write(unit, fmt =
'(A,A,A,I8)')
'SCALARS ', trim(mfld%name),
' int', 1
198 write(unit, fmt =
'(A)')
'LOOKUP_TABLE default'
200 do i = 1, mfld%msh%nelv
201 write(unit, fmt =
'(I8)') mfld%data(i)
211 type(
field_t),
intent(inout) :: fld
212 real(kind=
dp),
allocatable :: point_data(:)
213 integer :: i, j, lx, ly, lz, id(8)
215 if ( (fld%Xh%lx - 1 .gt. 1) .or. &
216 (fld%Xh%ly - 1 .gt. 1) .or. &
217 (fld%Xh%lz - 1 .gt. 1))
then
218 call neko_log%warning(
"Interpolate high-order data onto a " // &
222 write(unit, fmt =
'(A,I8)')
'POINT_DATA', fld%msh%mpts
223 write(unit, fmt =
'(A,A,A,I8)')
'SCALARS ', trim(fld%name),
' double', 1
224 write(unit, fmt =
'(A)')
'LOOKUP_TABLE default'
229 if (.not.
allocated(fld%msh%pt_lid))
then
230 call neko_error(
'VTK output requires a mesh with generated connectivity')
233 allocate(point_data(fld%msh%mpts))
235 do i = 1, fld%msh%nelv
236 do j = 1, fld%msh%npts
237 id(j) = fld%msh%pt_lid(j, i)
240 point_data(id(1)) =
real(fld%x(1, 1, 1, i),
dp)
241 point_data(id(2)) =
real(fld%x(lx, 1, 1, i),
dp)
242 point_data(id(3)) =
real(fld%x(1, ly, 1, i),
dp)
243 point_data(id(4)) =
real(fld%x(lx, ly, 1, i),
dp)
245 if (fld%msh%gdim .eq. 3)
then
246 point_data(id(5)) =
real(fld%x(1, 1, lz, i),
dp)
247 point_data(id(6)) =
real(fld%x(lx, 1, lz, i),
dp)
248 point_data(id(7)) =
real(fld%x(1, ly, lz, i),
dp)
249 point_data(id(8)) =
real(fld%x(lx, ly, lz, i),
dp)
254 write(unit, *) point_data
256 deallocate(point_data)
264 integer :: i, j, k, l
266 write(unit, fmt =
'(A,I8,A)')
'POINTS',
size(dm%x),
' double'
268 do i = 1, dm%msh%nelv
272 write(unit, fmt =
'(F15.8,F15.8,F15.8)') &
273 real(dm%x(j,k,l,i), dp), &
274 real(dm%y(j,k,l,i), dp), &
275 real(dm%z(j,k,l,i), dp)
281 write(unit, fmt =
'(A,I8,I8)')
'VERTICES',
size(dm%x), 2*
size(dm%x)
283 write(unit, fmt =
'(I8,I8)') 1, i-1
293 integer :: i, j, k, l
295 write(unit, fmt =
'(A,I8)')
'POINT_DATA',
size(dm%dof)
296 write(unit, fmt =
'(A,A,A,I8)')
'SCALARS ',
'dof_id',
' integer', 1
297 write(unit, fmt =
'(A)')
'LOOKUP_TABLE default'
299 do i = 1, dm%msh%nelv
303 write(unit, fmt =
'(I8)')
real(dm%dof(j,k,l,i),
dp)
309 write(unit, fmt =
'(A,A,A,I8)')
'SCALARS ',
'shared_dof',
' integer', 1
310 write(unit, fmt =
'(A)')
'LOOKUP_TABLE default'
312 do i = 1, dm%msh%nelv
316 if (dm%shared_dof(j,k,l,i))
then
317 write(unit, fmt =
'(I8)') 1
319 write(unit, fmt =
'(I8)') 0
332 integer,
parameter :: npts = 4
333 integer :: i, j, vtk_type
334 integer :: pt_id, pt_lid
335 integer :: tet_pts(npts)
339 write(unit, fmt =
'(A,I8,A)')
'POINTS', tet_msh%msh%mpts,
' double'
340 do i = 1, tet_msh%msh%mpts
341 write(unit, fmt =
'(F15.8,F15.8,F15.8)') &
342 real(tet_msh%msh%points(i)%x, dp)
350 call lid%init(tet_msh%msh%mpts, i)
351 do i = 1, tet_msh%msh%mpts
352 pt_id = tet_msh%msh%points(i)%id()
353 if (lid%get(pt_id, pt_lid) .gt. 0)
then
355 call lid%set(pt_id, pt_lid)
360 write(unit, fmt =
'(A,I8,I8)')
'CELLS', tet_msh%nelv, tet_msh%nelv*(npts+1)
361 do i = 1, tet_msh%nelv
363 pt_id = tet_msh%el(i)%pts(j)%p%id()
364 if (lid%get(pt_id, pt_lid) .gt. 0)
then
365 call neko_error(
'Tetrahedron vertex is not a mesh point')
367 tet_pts(j) = pt_lid - 1
369 write(unit, fmt =
'(I8,8I8)') npts, (tet_pts(j), j = 1, npts)
375 write(unit, fmt =
'(A,I8)')
'CELL_TYPES', tet_msh%nelv
377 do i = 1, tet_msh%nelv
378 write(unit, fmt =
'(I2)') vtk_type
387 integer,
parameter :: npts = 3
388 integer :: i, j, vtk_type
391 write(unit, fmt =
'(A,I8,A)')
'POINTS', tri_msh%mpts,
' double'
392 do i = 1, tri_msh%mpts
393 write(unit, fmt =
'(F15.8,F15.8,F15.8)')
real(tri_msh%points(i)%x,
dp)
397 write(unit, fmt =
'(A,I8,I8)')
'CELLS', tri_msh%nelv, tri_msh%nelv*(npts+1)
399 do i = 1, tri_msh%nelv
400 write(unit, fmt =
'(I8,8I8)') npts, &
401 (tri_msh%el(i)%pts(j)%p%id() - 1, j = 1, npts)
405 write(unit, fmt =
'(A,I8)')
'CELL_TYPES', tri_msh%nelv
407 do i = 1, tri_msh%nelv
408 write(unit, fmt =
'(I2)') vtk_type
integer, public pe_size
MPI size of communicator.
integer, public pe_rank
MPI rank.
Defines a mapping of the degrees of freedom.
Module for file I/O operations.
Implements a hash table ADT.
type(log_t), public neko_log
Global log stream.
integer, parameter, public dp
Defines a tetrahedral mesh.
Defines a triangular surface mesh.
pure integer function, public filename_suffix_pos(fname)
Find position (in the string) of a filename's suffix.
subroutine vtk_file_write(this, data, t)
Write data in legacy VTK.
subroutine vtk_file_write_tet_mesh(unit, tet_msh)
Write a tetrahedral mesh in legacy VTK format.
subroutine vtk_file_read(this, data)
subroutine vtk_file_write_dofmap_data(unit, dm)
Write a dofmap dm data as point data.
subroutine vtk_file_write_tri_mesh(unit, tri_msh)
Write a triangular mesh in legacy VTK format.
subroutine vtk_file_write_dofmap_coordinates(unit, dm)
Write xyz-coordinates of a dofmap dm as points.
subroutine vtk_file_write_cell_data(unit, mfld)
Write a mesh field mfld as cell data.
subroutine vtk_file_write_point_data(unit, fld)
Write a field fld as point data.
character(len=1024) function vtk_file_get_next_output_fname(this)
Get the physical file name generated by the next write.
subroutine vtk_file_write_mesh(unit, msh)
Write a mesh in legacy VTK format.
Integer based hash table.
Interface for legacy VTK files.