63 character(len=1024) :: fname
64 character(len=10) :: id_str
67 fname = this%get_base_fname()
69 write(id_str,
'(i10.10)')
pe_rank
71 fname = trim(fname(1:suffix_pos-1)) // id_str //
'.vtk'
79 class(*),
target,
intent(in) :: data
80 real(kind=
rp),
intent(in),
optional :: t
81 type(
mesh_t),
pointer :: msh => null()
82 type(
field_t),
pointer :: fld => null()
84 type(
dofmap_t),
pointer :: dm => null()
88 character(len=1024) :: fname
109 fname = this%get_next_output_fname()
110 open(newunit = file_unit,
file = trim(fname))
113 write(file_unit, fmt =
'(A)')
'# vtk DataFile Version 2.0'
114 write(file_unit, fmt =
'(A)')
'Neko'
115 write(file_unit, fmt =
'(A)')
'ASCII'
117 if (
associated(msh))
then
118 write(file_unit, fmt =
'(A)')
'DATASET UNSTRUCTURED_GRID'
122 if (
associated(mfld))
then
124 else if (
associated(fld))
then
127 else if (
associated(dm))
then
128 write(file_unit, fmt =
'(A)')
'DATASET POLYDATA'
133 else if (
associated(tet_msh))
then
134 write(file_unit, fmt =
'(A)')
'DATASET UNSTRUCTURED_GRID'
136 else if (
associated(tri_msh))
then
137 write(file_unit, fmt =
'(A)')
'DATASET UNSTRUCTURED_GRID'
148 class(*),
target,
intent(inout) :: data
150 call neko_error(
'VTK file read not implemented')
156 type(
mesh_t),
intent(inout) :: msh
157 integer :: i, j, vtk_type
158 integer,
dimension(8),
parameter :: vcyc_to_sym = [1, 2, 4, 3, &
161 write(unit, fmt =
'(A,I8,A)')
'POINTS', msh%mpts,
' double'
163 write(unit, fmt =
'(F15.8,F15.8,F15.8)')
real(msh%points(i)%x,
dp)
167 write(unit, fmt =
'(A,I8,I8)')
'CELLS', msh%nelv, msh%nelv*(msh%npts+1)
170 write(unit, fmt =
'(I8,8I8)') msh%npts, &
171 (msh%get_local(msh%elements(i)%e%pts(vcyc_to_sym(j))%p) - 1, &
176 write(unit, fmt =
'(A,I8)')
'CELL_TYPES', msh%nelv
178 if (msh%gdim .eq. 3) vtk_type = 12
180 write(unit, fmt =
'(I2)') vtk_type
191 write(unit, fmt =
'(A,I8)')
'CELL_DATA', mfld%msh%nelv
192 write(unit, fmt =
'(A,A,A,I8)')
'SCALARS ', trim(mfld%name),
' int', 1
193 write(unit, fmt =
'(A)')
'LOOKUP_TABLE default'
195 do i = 1, mfld%msh%nelv
196 write(unit, fmt =
'(I8)') mfld%data(i)
206 type(
field_t),
intent(inout) :: fld
207 real(kind=
dp),
allocatable :: point_data(:)
208 integer :: i, j, lx, ly, lz, id(8)
210 if ( (fld%Xh%lx - 1 .gt. 1) .or. &
211 (fld%Xh%ly - 1 .gt. 1) .or. &
212 (fld%Xh%lz - 1 .gt. 1))
then
213 call neko_log%warning(
"Interpolate high-order data onto a " // &
217 write(unit, fmt =
'(A,I8)')
'POINT_DATA', fld%msh%mpts
218 write(unit, fmt =
'(A,A,A,I8)')
'SCALARS ', trim(fld%name),
' double', 1
219 write(unit, fmt =
'(A)')
'LOOKUP_TABLE default'
224 allocate(point_data(fld%msh%mpts))
226 do i = 1, fld%msh%nelv
227 do j = 1, fld%msh%npts
228 id(j) = fld%msh%get_local(fld%msh%elements(i)%e%pts(j)%p)
231 point_data(id(1)) =
real(fld%x(1, 1, 1, i),
dp)
232 point_data(id(2)) =
real(fld%x(lx, 1, 1, i),
dp)
233 point_data(id(3)) =
real(fld%x(1, ly, 1, i),
dp)
234 point_data(id(4)) =
real(fld%x(lx, ly, 1, i),
dp)
236 if (fld%msh%gdim .eq. 3)
then
237 point_data(id(5)) =
real(fld%x(1, 1, lz, i),
dp)
238 point_data(id(6)) =
real(fld%x(lx, 1, lz, i),
dp)
239 point_data(id(7)) =
real(fld%x(1, ly, lz, i),
dp)
240 point_data(id(8)) =
real(fld%x(lx, ly, lz, i),
dp)
245 write(unit, *) point_data
247 deallocate(point_data)
255 integer :: i, j, k, l
257 write(unit, fmt =
'(A,I8,A)')
'POINTS',
size(dm%x),
' double'
259 do i = 1, dm%msh%nelv
263 write(unit, fmt =
'(F15.8,F15.8,F15.8)') &
264 real(dm%x(j,k,l,i), dp), &
265 real(dm%y(j,k,l,i), dp), &
266 real(dm%z(j,k,l,i), dp)
272 write(unit, fmt =
'(A,I8,I8)')
'VERTICES',
size(dm%x), 2*
size(dm%x)
274 write(unit, fmt =
'(I8,I8)') 1, i-1
284 integer :: i, j, k, l
286 write(unit, fmt =
'(A,I8)')
'POINT_DATA',
size(dm%dof)
287 write(unit, fmt =
'(A,A,A,I8)')
'SCALARS ',
'dof_id',
' integer', 1
288 write(unit, fmt =
'(A)')
'LOOKUP_TABLE default'
290 do i = 1, dm%msh%nelv
294 write(unit, fmt =
'(I8)')
real(dm%dof(j,k,l,i),
dp)
300 write(unit, fmt =
'(A,A,A,I8)')
'SCALARS ',
'shared_dof',
' integer', 1
301 write(unit, fmt =
'(A)')
'LOOKUP_TABLE default'
303 do i = 1, dm%msh%nelv
307 if (dm%shared_dof(j,k,l,i))
then
308 write(unit, fmt =
'(I8)') 1
310 write(unit, fmt =
'(I8)') 0
323 integer,
parameter :: npts = 4
324 integer :: i, j, vtk_type
327 write(unit, fmt =
'(A,I8,A)')
'POINTS', tet_msh%msh%mpts,
' double'
328 do i = 1, tet_msh%msh%mpts
329 write(unit, fmt =
'(F15.8,F15.8,F15.8)') &
330 real(tet_msh%msh%points(i)%x, dp)
334 write(unit, fmt =
'(A,I8,I8)')
'CELLS', tet_msh%nelv, tet_msh%nelv*(npts+1)
336 do i = 1, tet_msh%nelv
337 write(unit, fmt =
'(I8,8I8)') npts, &
338 (tet_msh%msh%get_local(tet_msh%el(i)%pts(j)%p) - 1, &
343 write(unit, fmt =
'(A,I8)')
'CELL_TYPES', tet_msh%nelv
345 do i = 1, tet_msh%nelv
346 write(unit, fmt =
'(I2)') vtk_type
355 integer,
parameter :: npts = 3
356 integer :: i, j, vtk_type
359 write(unit, fmt =
'(A,I8,A)')
'POINTS', tri_msh%mpts,
' double'
360 do i = 1, tri_msh%mpts
361 write(unit, fmt =
'(F15.8,F15.8,F15.8)')
real(tri_msh%points(i)%x,
dp)
365 write(unit, fmt =
'(A,I8,I8)')
'CELLS', tri_msh%nelv, tri_msh%nelv*(npts+1)
367 do i = 1, tri_msh%nelv
368 write(unit, fmt =
'(I8,8I8)') npts, &
369 (tri_msh%el(i)%pts(j)%p%id() - 1, j = 1, npts)
373 write(unit, fmt =
'(A,I8)')
'CELL_TYPES', tri_msh%nelv
375 do i = 1, tri_msh%nelv
376 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.
type(log_t), public neko_log
Global log stream.
integer, parameter, public dp
integer, parameter, public rp
Global precision used in computations.
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.
Interface for legacy VTK files.