114 lines
3.0 KiB
Fortran
114 lines
3.0 KiB
Fortran
program test_vtk_output
|
|
use fem_precision
|
|
use fem_error
|
|
use fem_database
|
|
use fem_output_csv
|
|
use fem_output_vtk
|
|
implicit none
|
|
|
|
integer :: ierr
|
|
character(len=*), parameter :: OUT_DIR = &
|
|
'vtk_output_auto_dir/nested'
|
|
character(len=*), parameter :: VTK_FILE = &
|
|
'vtk_output_auto_dir/nested/result_00000007.vtk'
|
|
|
|
call setup_c3d4(ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(1)
|
|
|
|
u(dof_id(1,2)) = 0.125_rk
|
|
v(dof_id(2,3)) = -0.25_rk
|
|
a(dof_id(3,4)) = 0.5_rk
|
|
|
|
call output_csv_set_directory(OUT_DIR, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(2)
|
|
|
|
call output_vtk_write(7, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(3)
|
|
|
|
call require_contains(VTK_FILE, 'DATASET UNSTRUCTURED_GRID', 4)
|
|
call require_contains(VTK_FILE, 'POINTS', 5)
|
|
call require_contains(VTK_FILE, 'CELLS', 6)
|
|
call require_contains(VTK_FILE, 'CELL_TYPES', 7)
|
|
call require_contains(VTK_FILE, 'VECTORS displacement double', 8)
|
|
call require_contains(VTK_FILE, 'VECTORS velocity double', 9)
|
|
call require_contains(VTK_FILE, 'VECTORS acceleration double', 10)
|
|
call require_contains(VTK_FILE, 'SCALARS element_status int 1', 11)
|
|
call require_contains(VTK_FILE, 'TENSORS stress double', 12)
|
|
call require_contains(VTK_FILE, 'TENSORS strain double', 13)
|
|
call require_contains(VTK_FILE, 'SCALARS eqps double 1', 14)
|
|
|
|
call database_finalize(ierr)
|
|
if (ierr .ne. FEM_SUCCESS) call fail(15)
|
|
|
|
contains
|
|
|
|
subroutine setup_c3d4(ierr)
|
|
integer, intent(out) :: ierr
|
|
integer :: node
|
|
integer :: idir
|
|
integer :: counter
|
|
|
|
call database_allocate_basic(4, 1, 12, ierr)
|
|
if (ierr .ne. FEM_SUCCESS) return
|
|
|
|
counter = 0
|
|
do node = 1, 4
|
|
node_id_ext(node) = node
|
|
do idir = 1, NDIM
|
|
counter = counter + 1
|
|
dof_id(idir,node) = counter
|
|
end do
|
|
end do
|
|
|
|
coord0(:,1) = (/ ZERO, ZERO, ZERO /)
|
|
coord0(:,2) = (/ ONE, ZERO, ZERO /)
|
|
coord0(:,3) = (/ ZERO, ONE, ZERO /)
|
|
coord0(:,4) = (/ ZERO, ZERO, ONE /)
|
|
coord = coord0
|
|
|
|
elem_id_ext(1) = 1
|
|
elem_type(1) = 'C3D4'
|
|
elem_nnode(1) = 4
|
|
elem_conn(:,1) = 0
|
|
elem_conn(1:4,1) = (/ 1, 2, 3, 4 /)
|
|
elem_status(1) = 0
|
|
|
|
ierr = FEM_SUCCESS
|
|
end subroutine setup_c3d4
|
|
|
|
subroutine require_contains(filename, pattern, code)
|
|
character(len=*), intent(in) :: filename
|
|
character(len=*), intent(in) :: pattern
|
|
integer, intent(in) :: code
|
|
character(len=512) :: line
|
|
integer :: unit_id
|
|
integer :: ios
|
|
logical :: found
|
|
|
|
found = .false.
|
|
unit_id = 71
|
|
open(unit=unit_id, file=trim(filename), status='old', action='read', iostat=ios)
|
|
if (ios .ne. 0) call fail(code)
|
|
|
|
do
|
|
read(unit_id,'(A)',iostat=ios) line
|
|
if (ios .ne. 0) exit
|
|
if (index(line, trim(pattern)) .gt. 0) then
|
|
found = .true.
|
|
exit
|
|
end if
|
|
end do
|
|
|
|
close(unit_id)
|
|
if (.not. found) call fail(code)
|
|
end subroutine require_contains
|
|
|
|
subroutine fail(code)
|
|
integer, intent(in) :: code
|
|
|
|
write(*,*) 'test_vtk_output failed:', code
|
|
stop 1
|
|
end subroutine fail
|
|
|
|
end program test_vtk_output
|