2012-06-15 21:40:21 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2013-04-18 22:10:49 +05:30
|
|
|
!> @author Franz Roters, Max-Planck-Institut für Eisenforschung GmbH
|
|
|
|
!> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH
|
|
|
|
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
2019-06-07 15:51:12 +05:30
|
|
|
!> @brief Parse geometry file to set up discretization and geometry for nonlocal model
|
2012-06-15 21:40:21 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2020-03-20 11:28:55 +05:30
|
|
|
module discretization_grid
|
2019-06-06 17:29:16 +05:30
|
|
|
#include <petsc/finclude/petscsys.h>
|
2019-06-07 15:51:12 +05:30
|
|
|
use PETScsys
|
2019-06-08 14:08:10 +05:30
|
|
|
|
2019-06-07 15:51:12 +05:30
|
|
|
use prec
|
2020-09-13 13:49:38 +05:30
|
|
|
use parallelization
|
2019-06-07 15:51:12 +05:30
|
|
|
use system_routines
|
2020-09-12 18:13:04 +05:30
|
|
|
use base64
|
|
|
|
use zlib
|
2019-06-07 15:51:12 +05:30
|
|
|
use DAMASK_interface
|
|
|
|
use IO
|
2020-08-15 19:32:10 +05:30
|
|
|
use config
|
2019-11-24 12:14:17 +05:30
|
|
|
use results
|
2019-06-07 15:51:12 +05:30
|
|
|
use discretization
|
|
|
|
use geometry_plastic_nonlocal
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2019-06-07 15:51:12 +05:30
|
|
|
implicit none
|
|
|
|
private
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2019-06-07 15:51:12 +05:30
|
|
|
integer, dimension(3), public, protected :: &
|
|
|
|
grid !< (global) grid
|
|
|
|
integer, public, protected :: &
|
|
|
|
grid3, & !< (local) grid in 3rd direction
|
|
|
|
grid3Offset !< (local) grid offset in 3rd direction
|
|
|
|
real(pReal), dimension(3), public, protected :: &
|
2019-12-13 13:38:48 +05:30
|
|
|
geomSize !< (global) physical size
|
2019-06-07 15:51:12 +05:30
|
|
|
real(pReal), public, protected :: &
|
|
|
|
size3, & !< (local) size in 3rd direction
|
|
|
|
size3offset !< (local) size offset in 3rd direction
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2019-06-07 15:51:12 +05:30
|
|
|
public :: &
|
2020-03-20 11:28:55 +05:30
|
|
|
discretization_grid_init
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2012-03-09 01:55:28 +05:30
|
|
|
contains
|
2007-03-21 21:48:33 +05:30
|
|
|
|
2009-01-20 00:12:31 +05:30
|
|
|
|
2012-06-15 21:40:21 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2019-06-08 14:08:10 +05:30
|
|
|
!> @brief reads the geometry file to obtain information on discretization
|
2012-06-15 21:40:21 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2020-05-06 21:20:59 +05:30
|
|
|
subroutine discretization_grid_init(restart)
|
|
|
|
|
|
|
|
logical, intent(in) :: restart
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2019-06-07 15:51:12 +05:30
|
|
|
include 'fftw3-mpi.f03'
|
2019-06-08 14:08:10 +05:30
|
|
|
real(pReal), dimension(3) :: &
|
2019-12-13 13:38:48 +05:30
|
|
|
mySize, & !< domain size of this process
|
|
|
|
origin !< (global) distance to origin
|
2019-06-08 14:08:10 +05:30
|
|
|
integer, dimension(3) :: &
|
|
|
|
myGrid !< domain grid of this process
|
|
|
|
|
|
|
|
integer, dimension(:), allocatable :: &
|
2020-11-12 19:10:25 +05:30
|
|
|
materialAt, materialAt_global
|
2019-06-08 14:08:10 +05:30
|
|
|
|
2020-06-18 21:13:25 +05:30
|
|
|
integer :: &
|
|
|
|
j, &
|
2020-11-12 19:10:25 +05:30
|
|
|
debug_element, debug_ip, &
|
|
|
|
ierr
|
2019-06-08 14:08:10 +05:30
|
|
|
integer(C_INTPTR_T) :: &
|
|
|
|
devNull, z, z_offset
|
2020-11-12 19:10:25 +05:30
|
|
|
integer, dimension(worldsize) :: &
|
|
|
|
displs, sendcounts
|
2019-06-07 15:51:12 +05:30
|
|
|
|
2020-09-22 16:39:12 +05:30
|
|
|
print'(/,a)', ' <<<+- discretization_grid init -+>>>'; flush(IO_STDOUT)
|
2019-06-07 15:51:12 +05:30
|
|
|
|
2021-02-17 22:26:39 +05:30
|
|
|
if(worldrank == 0) then
|
|
|
|
call readVTR(grid,geomSize,origin,materialAt_global)
|
|
|
|
else
|
|
|
|
allocate(materialAt_global(0)) ! needed for IntelMPI
|
|
|
|
endif
|
2020-11-12 19:10:25 +05:30
|
|
|
|
2021-04-09 11:55:30 +05:30
|
|
|
|
2020-11-12 19:10:25 +05:30
|
|
|
call MPI_Bcast(grid,3,MPI_INTEGER,0,PETSC_COMM_WORLD, ierr)
|
|
|
|
if (ierr /= 0) error stop 'MPI error'
|
2021-04-11 13:28:40 +05:30
|
|
|
if (grid(1) < 2) call IO_error(844, ext_msg='cells(1) must be larger than 1')
|
2020-11-12 19:10:25 +05:30
|
|
|
call MPI_Bcast(geomSize,3,MPI_DOUBLE,0,PETSC_COMM_WORLD, ierr)
|
|
|
|
if (ierr /= 0) error stop 'MPI error'
|
|
|
|
call MPI_Bcast(origin,3,MPI_DOUBLE,0,PETSC_COMM_WORLD, ierr)
|
|
|
|
if (ierr /= 0) error stop 'MPI error'
|
2019-06-07 15:51:12 +05:30
|
|
|
|
2020-12-04 02:28:24 +05:30
|
|
|
print'(/,a,3(i12 ))', ' cells a b c: ', grid
|
2020-09-14 00:51:55 +05:30
|
|
|
print'(a,3(es12.5))', ' size x y z: ', geomSize
|
|
|
|
print'(a,3(es12.5))', ' origin x y z: ', origin
|
|
|
|
|
2019-06-08 14:08:10 +05:30
|
|
|
if(worldsize>grid(3)) call IO_error(894, ext_msg='number of processes exceeds grid(3)')
|
2019-06-07 15:51:12 +05:30
|
|
|
|
2019-06-08 14:08:10 +05:30
|
|
|
call fftw_mpi_init
|
2019-06-07 15:51:12 +05:30
|
|
|
devNull = fftw_mpi_local_size_3d(int(grid(3),C_INTPTR_T), &
|
|
|
|
int(grid(2),C_INTPTR_T), &
|
|
|
|
int(grid(1),C_INTPTR_T)/2+1, &
|
|
|
|
PETSC_COMM_WORLD, &
|
2019-06-08 14:08:10 +05:30
|
|
|
z, & ! domain grid size along z
|
|
|
|
z_offset) ! domain grid offset along z
|
2020-11-12 12:21:07 +05:30
|
|
|
if(z==0_C_INTPTR_T) call IO_error(894, ext_msg='Cannot distribute MPI processes')
|
2020-11-11 17:17:13 +05:30
|
|
|
|
2019-06-08 14:08:10 +05:30
|
|
|
grid3 = int(z)
|
|
|
|
grid3Offset = int(z_offset)
|
2019-06-07 15:51:12 +05:30
|
|
|
size3 = geomSize(3)*real(grid3,pReal) /real(grid(3),pReal)
|
|
|
|
size3Offset = geomSize(3)*real(grid3Offset,pReal)/real(grid(3),pReal)
|
2019-06-08 14:08:10 +05:30
|
|
|
myGrid = [grid(1:2),grid3]
|
|
|
|
mySize = [geomSize(1:2),size3]
|
|
|
|
|
2020-11-12 19:10:25 +05:30
|
|
|
call MPI_Gather(product(grid(1:2))*grid3Offset,1,MPI_INTEGER,displs, 1,MPI_INTEGER,0,PETSC_COMM_WORLD,ierr)
|
|
|
|
if (ierr /= 0) error stop 'MPI error'
|
|
|
|
call MPI_Gather(product(myGrid), 1,MPI_INTEGER,sendcounts,1,MPI_INTEGER,0,PETSC_COMM_WORLD,ierr)
|
|
|
|
if (ierr /= 0) error stop 'MPI error'
|
2020-06-18 21:13:25 +05:30
|
|
|
|
2020-11-12 19:10:25 +05:30
|
|
|
allocate(materialAt(product(myGrid)))
|
|
|
|
call MPI_scatterv(materialAt_global,sendcounts,displs,MPI_INTEGER,materialAt,size(materialAt),MPI_INTEGER,0,PETSC_COMM_WORLD,ierr)
|
|
|
|
if (ierr /= 0) error stop 'MPI error'
|
2019-06-07 03:34:20 +05:30
|
|
|
|
2020-09-24 00:55:14 +05:30
|
|
|
call discretization_init(materialAt, &
|
2019-09-28 03:24:02 +05:30
|
|
|
IPcoordinates0(myGrid,mySize,grid3Offset), &
|
2019-09-29 06:34:00 +05:30
|
|
|
Nodes0(myGrid,mySize,grid3Offset),&
|
2020-09-24 22:35:10 +05:30
|
|
|
merge((grid(1)+1) * (grid(2)+1) * (grid3+1),& ! write top layer...
|
|
|
|
(grid(1)+1) * (grid(2)+1) * grid3,& ! ...unless not last process
|
|
|
|
worldrank+1==worldsize))
|
2019-06-07 15:51:12 +05:30
|
|
|
|
2019-11-24 12:14:17 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! store geometry information for post processing
|
2020-05-06 21:20:59 +05:30
|
|
|
if(.not. restart) then
|
|
|
|
call results_openJobFile
|
|
|
|
call results_closeGroup(results_addGroup('geometry'))
|
2020-12-04 02:28:24 +05:30
|
|
|
call results_addAttribute('cells', grid, '/geometry')
|
|
|
|
call results_addAttribute('size', geomSize,'/geometry')
|
|
|
|
call results_addAttribute('origin',origin, '/geometry')
|
2020-05-06 21:20:59 +05:30
|
|
|
call results_closeJobFile
|
|
|
|
endif
|
2020-07-14 00:43:53 +05:30
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! geometry information required by the nonlocal CP model
|
|
|
|
call geometry_plastic_nonlocal_setIPvolume(reshape([(product(mySize/real(myGrid,pReal)),j=1,product(myGrid))], &
|
|
|
|
[1,product(myGrid)]))
|
2020-01-29 19:18:15 +05:30
|
|
|
call geometry_plastic_nonlocal_setIParea (cellSurfaceArea(mySize,myGrid))
|
|
|
|
call geometry_plastic_nonlocal_setIPareaNormal (cellSurfaceNormal(product(myGrid)))
|
2019-06-08 14:45:01 +05:30
|
|
|
call geometry_plastic_nonlocal_setIPneighborhood(IPneighborhood(myGrid))
|
|
|
|
|
2020-11-12 19:10:25 +05:30
|
|
|
!-------------------------------------------------------------------------------------------------
|
|
|
|
! debug parameters
|
|
|
|
debug_element = config_debug%get_asInt('element',defaultVal=1)
|
|
|
|
if (debug_element < 1 .or. debug_element > product(myGrid)) call IO_error(602,ext_msg='element')
|
|
|
|
debug_ip = config_debug%get_asInt('integrationpoint',defaultVal=1)
|
|
|
|
if (debug_ip /= 1) call IO_error(602,ext_msg='IP')
|
2019-05-14 09:36:01 +05:30
|
|
|
|
2020-03-20 11:28:55 +05:30
|
|
|
end subroutine discretization_grid_init
|
2009-01-20 00:12:31 +05:30
|
|
|
|
2019-02-02 19:40:35 +05:30
|
|
|
|
2020-09-12 18:13:04 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Parse vtk rectilinear grid (.vtr)
|
|
|
|
!> @details https://vtk.org/Wiki/VTK_XML_Formats
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2020-09-24 00:55:14 +05:30
|
|
|
subroutine readVTR(grid,geomSize,origin,material)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
integer, dimension(3), intent(out) :: &
|
2020-09-13 22:02:49 +05:30
|
|
|
grid ! grid (across all processes!)
|
2020-09-12 18:13:04 +05:30
|
|
|
real(pReal), dimension(3), intent(out) :: &
|
2020-09-13 22:02:49 +05:30
|
|
|
geomSize, & ! size (across all processes!)
|
|
|
|
origin ! origin (across all processes!)
|
2020-09-12 18:13:04 +05:30
|
|
|
integer, dimension(:), intent(out), allocatable :: &
|
2020-09-24 00:55:14 +05:30
|
|
|
material
|
2020-09-12 18:13:04 +05:30
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
character(len=:), allocatable :: fileContent, dataType, headerType
|
2020-09-13 22:02:49 +05:30
|
|
|
logical :: inFile,inGrid,gotCoordinates,gotCellData,compressed
|
2020-09-12 18:13:04 +05:30
|
|
|
integer :: fileUnit, myStat, coord
|
|
|
|
integer(pI64) :: &
|
|
|
|
fileLength, & !< length of the geom file (in characters)
|
|
|
|
startPos, endPos, &
|
|
|
|
s
|
|
|
|
|
|
|
|
grid = -1
|
|
|
|
geomSize = -1.0_pReal
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! read raw data as stream
|
2020-09-13 14:35:42 +05:30
|
|
|
inquire(file = trim(interface_geomFile), size=fileLength)
|
|
|
|
open(newunit=fileUnit, file=trim(interface_geomFile), access='stream',&
|
2020-09-12 18:13:04 +05:30
|
|
|
status='old', position='rewind', action='read',iostat=myStat)
|
2020-09-13 14:35:42 +05:30
|
|
|
if(myStat /= 0) call IO_error(100,ext_msg=trim(interface_geomFile))
|
2020-09-12 18:13:04 +05:30
|
|
|
allocate(character(len=fileLength)::fileContent)
|
|
|
|
read(fileUnit) fileContent
|
|
|
|
close(fileUnit)
|
|
|
|
|
2020-09-13 22:02:49 +05:30
|
|
|
inFile = .false.
|
|
|
|
inGrid = .false.
|
|
|
|
gotCoordinates = .false.
|
|
|
|
gotCelldata = .false.
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2020-09-13 22:02:49 +05:30
|
|
|
! interpret XML file
|
2020-09-12 18:13:04 +05:30
|
|
|
startPos = 1_pI64
|
|
|
|
do while (startPos < len(fileContent,kind=pI64))
|
|
|
|
endPos = startPos + index(fileContent(startPos:),IO_EOL,kind=pI64) - 2_pI64
|
|
|
|
if (endPos < startPos) endPos = len(fileContent,kind=pI64) ! end of file without new line
|
|
|
|
|
|
|
|
if(.not. inFile) then
|
|
|
|
if(index(fileContent(startPos:endPos),'<VTKFile',kind=pI64) /= 0_pI64) then
|
|
|
|
inFile = .true.
|
2020-09-13 22:02:49 +05:30
|
|
|
if(.not. fileFormatOk(fileContent(startPos:endPos))) call IO_error(error_ID = 844, ext_msg='file format')
|
2020-09-13 10:28:34 +05:30
|
|
|
headerType = merge('UInt64','UInt32',getXMLValue(fileContent(startPos:endPos),'header_type')=='UInt64')
|
2020-09-12 18:13:04 +05:30
|
|
|
compressed = getXMLValue(fileContent(startPos:endPos),'compressor') == 'vtkZLibDataCompressor'
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
if(.not. inGrid) then
|
2020-09-13 10:28:34 +05:30
|
|
|
if(index(fileContent(startPos:endPos),'<RectilinearGrid',kind=pI64) /= 0_pI64) inGrid = .true.
|
2020-09-12 18:13:04 +05:30
|
|
|
else
|
|
|
|
if(index(fileContent(startPos:endPos),'<CellData>',kind=pI64) /= 0_pI64) then
|
2020-09-13 22:02:49 +05:30
|
|
|
gotCellData = .true.
|
2020-09-12 18:13:04 +05:30
|
|
|
do while (index(fileContent(startPos:endPos),'</CellData>',kind=pI64) == 0_pI64)
|
|
|
|
if(index(fileContent(startPos:endPos),'<DataArray',kind=pI64) /= 0_pI64 .and. &
|
2020-09-24 00:38:42 +05:30
|
|
|
getXMLValue(fileContent(startPos:endPos),'Name') == 'material' ) then
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
if(getXMLValue(fileContent(startPos:endPos),'format') /= 'binary') &
|
|
|
|
call IO_error(error_ID = 844, ext_msg='format (materialpoint)')
|
2020-09-13 10:28:34 +05:30
|
|
|
dataType = getXMLValue(fileContent(startPos:endPos),'type')
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
startPos = endPos + 2_pI64
|
|
|
|
endPos = startPos + index(fileContent(startPos:),IO_EOL,kind=pI64) - 2_pI64
|
|
|
|
s = startPos + verify(fileContent(startPos:endPos),IO_WHITESPACE,kind=pI64) -1_pI64 ! start (no leading whitespace)
|
2020-09-24 00:55:14 +05:30
|
|
|
material = as_Int(fileContent(s:endPos),headerType,compressed,dataType)
|
2020-09-12 18:13:04 +05:30
|
|
|
exit
|
|
|
|
endif
|
|
|
|
startPos = endPos + 2_pI64
|
2020-09-24 00:38:42 +05:30
|
|
|
endPos = startPos + index(fileContent(startPos:),IO_EOL,kind=pI64) - 2_pI64
|
2020-09-12 18:13:04 +05:30
|
|
|
enddo
|
|
|
|
elseif(index(fileContent(startPos:endPos),'<Coordinates>',kind=pI64) /= 0_pI64) then
|
2020-09-13 22:02:49 +05:30
|
|
|
gotCoordinates = .true.
|
2020-09-12 18:13:04 +05:30
|
|
|
startPos = endPos + 2_pI64
|
|
|
|
|
|
|
|
coord = 0
|
|
|
|
do while (startPos<fileLength)
|
|
|
|
endPos = startPos + index(fileContent(startPos:),IO_EOL,kind=pI64) - 2_pI64
|
|
|
|
if(index(fileContent(startPos:endPos),'<DataArray',kind=pI64) /= 0_pI64) then
|
|
|
|
|
|
|
|
if(getXMLValue(fileContent(startPos:endPos),'format') /= 'binary') &
|
|
|
|
call IO_error(error_ID = 844, ext_msg='format (coordinates)')
|
2020-09-13 10:28:34 +05:30
|
|
|
dataType = getXMLValue(fileContent(startPos:endPos),'type')
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
startPos = endPos + 2_pI64
|
|
|
|
endPos = startPos + index(fileContent(startPos:),IO_EOL,kind=pI64) - 2_pI64
|
|
|
|
s = startPos + verify(fileContent(startPos:endPos),IO_WHITESPACE,kind=pI64) -1_pI64 ! start (no leading whitespace)
|
|
|
|
|
|
|
|
coord = coord + 1
|
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
call gridSizeOrigin(fileContent(s:endPos),headerType,compressed,dataType,coord)
|
2020-09-12 18:13:04 +05:30
|
|
|
endif
|
|
|
|
if(index(fileContent(startPos:endPos),'</Coordinates>',kind=pI64) /= 0_pI64) exit
|
|
|
|
startPos = endPos + 2_pI64
|
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2020-09-13 22:02:49 +05:30
|
|
|
if(gotCellData .and. gotCoordinates) exit
|
2020-09-12 18:13:04 +05:30
|
|
|
startPos = endPos + 2_pI64
|
|
|
|
|
|
|
|
end do
|
2020-10-10 01:49:53 +05:30
|
|
|
material = material + 1
|
2020-09-24 00:55:14 +05:30
|
|
|
if(.not. allocated(material)) call IO_error(error_ID = 844, ext_msg='material data not found')
|
|
|
|
if(size(material) /= product(grid)) call IO_error(error_ID = 844, ext_msg='size(material)')
|
2020-09-24 13:06:19 +05:30
|
|
|
if(any(geomSize<=0)) call IO_error(error_ID = 844, ext_msg='size')
|
|
|
|
if(any(grid<1)) call IO_error(error_ID = 844, ext_msg='grid')
|
2020-10-10 01:49:53 +05:30
|
|
|
if(any(material<0)) call IO_error(error_ID = 844, ext_msg='material ID < 0')
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief determine size and origin from coordinates
|
|
|
|
!------------------------------------------------------------------------------------------------
|
2020-09-13 10:28:34 +05:30
|
|
|
subroutine gridSizeOrigin(base64_str,headerType,compressed,dataType,direction)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
character(len=*), intent(in) :: base64_str, & ! base64 encoded string of 1D coordinates
|
2020-09-13 10:28:34 +05:30
|
|
|
headerType, & ! header type (UInt32 or Uint64)
|
|
|
|
dataType ! data type (Int32, Int64, Float32, Float64)
|
2020-09-12 18:13:04 +05:30
|
|
|
logical, intent(in) :: compressed ! indicate whether data is zlib compressed
|
|
|
|
integer, intent(in) :: direction ! direction (1=x,2=y,3=z)
|
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
real(pReal), dimension(:), allocatable :: coords,delta
|
|
|
|
|
|
|
|
coords = as_pReal(base64_str,headerType,compressed,dataType)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
delta = coords(2:) - coords(:size(coords)-1)
|
2020-09-14 17:36:09 +05:30
|
|
|
if(any(delta<0.0_pReal) .or. dNeq(maxval(delta),minval(delta),1.0e-8_pReal*maxval(abs(coords)))) &
|
2020-09-13 10:28:34 +05:30
|
|
|
call IO_error(error_ID = 844, ext_msg = 'grid spacing')
|
2020-09-12 18:13:04 +05:30
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
grid(direction) = size(coords)-1
|
|
|
|
origin(direction) = coords(1)
|
2020-09-12 18:13:04 +05:30
|
|
|
geomSize(direction) = coords(size(coords)) - coords(1)
|
|
|
|
|
|
|
|
end subroutine
|
|
|
|
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Interpret Base64 string in vtk XML file as integer of default kind
|
|
|
|
!------------------------------------------------------------------------------------------------
|
2020-09-13 10:28:34 +05:30
|
|
|
function as_Int(base64_str,headerType,compressed,dataType)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
character(len=*), intent(in) :: base64_str, & ! base64 encoded string
|
2020-09-13 10:28:34 +05:30
|
|
|
headerType, & ! header type (UInt32 or Uint64)
|
|
|
|
dataType ! data type (Int32, Int64, Float32, Float64)
|
2020-09-12 18:13:04 +05:30
|
|
|
logical, intent(in) :: compressed ! indicate whether data is zlib compressed
|
|
|
|
|
|
|
|
integer, dimension(:), allocatable :: as_Int
|
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
select case(dataType)
|
2020-09-12 18:13:04 +05:30
|
|
|
case('Int32')
|
2020-09-13 23:44:34 +05:30
|
|
|
as_Int = int(prec_bytesToC_INT32_T(asBytes(base64_str,headerType,compressed)))
|
2020-09-12 18:13:04 +05:30
|
|
|
case('Int64')
|
2020-09-13 23:44:34 +05:30
|
|
|
as_Int = int(prec_bytesToC_INT64_T(asBytes(base64_str,headerType,compressed)))
|
2020-09-12 18:13:04 +05:30
|
|
|
case('Float32')
|
2020-09-13 23:44:34 +05:30
|
|
|
as_Int = int(prec_bytesToC_FLOAT (asBytes(base64_str,headerType,compressed)))
|
2020-09-12 18:13:04 +05:30
|
|
|
case('Float64')
|
2020-09-13 23:44:34 +05:30
|
|
|
as_Int = int(prec_bytesToC_DOUBLE (asBytes(base64_str,headerType,compressed)))
|
2020-09-12 18:13:04 +05:30
|
|
|
case default
|
2020-09-13 10:28:34 +05:30
|
|
|
call IO_error(844_pInt,ext_msg='unknown data type: '//trim(dataType))
|
2020-09-12 18:13:04 +05:30
|
|
|
end select
|
|
|
|
|
|
|
|
end function as_Int
|
|
|
|
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Interpret Base64 string in vtk XML file as integer of pReal kind
|
|
|
|
!------------------------------------------------------------------------------------------------
|
2020-09-13 10:28:34 +05:30
|
|
|
function as_pReal(base64_str,headerType,compressed,dataType)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
character(len=*), intent(in) :: base64_str, & ! base64 encoded string
|
2020-09-13 10:28:34 +05:30
|
|
|
headerType, & ! header type (UInt32 or Uint64)
|
|
|
|
dataType ! data type (Int32, Int64, Float32, Float64)
|
2020-09-12 18:13:04 +05:30
|
|
|
logical, intent(in) :: compressed ! indicate whether data is zlib compressed
|
|
|
|
|
|
|
|
real(pReal), dimension(:), allocatable :: as_pReal
|
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
select case(dataType)
|
2020-09-12 18:13:04 +05:30
|
|
|
case('Int32')
|
2020-09-13 23:44:34 +05:30
|
|
|
as_pReal = real(prec_bytesToC_INT32_T(asBytes(base64_str,headerType,compressed)),pReal)
|
2020-09-12 18:13:04 +05:30
|
|
|
case('Int64')
|
2020-09-13 23:44:34 +05:30
|
|
|
as_pReal = real(prec_bytesToC_INT64_T(asBytes(base64_str,headerType,compressed)),pReal)
|
2020-09-12 18:13:04 +05:30
|
|
|
case('Float32')
|
2020-09-13 23:44:34 +05:30
|
|
|
as_pReal = real(prec_bytesToC_FLOAT (asBytes(base64_str,headerType,compressed)),pReal)
|
2020-09-12 18:13:04 +05:30
|
|
|
case('Float64')
|
2020-09-13 23:44:34 +05:30
|
|
|
as_pReal = real(prec_bytesToC_DOUBLE (asBytes(base64_str,headerType,compressed)),pReal)
|
2020-09-12 18:13:04 +05:30
|
|
|
case default
|
2020-09-13 10:28:34 +05:30
|
|
|
call IO_error(844_pInt,ext_msg='unknown data type: '//trim(dataType))
|
2020-09-12 18:13:04 +05:30
|
|
|
end select
|
|
|
|
|
|
|
|
end function as_pReal
|
|
|
|
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Interpret Base64 string in vtk XML file as bytes
|
|
|
|
!------------------------------------------------------------------------------------------------
|
2020-09-13 10:28:34 +05:30
|
|
|
function asBytes(base64_str,headerType,compressed) result(bytes)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
character(len=*), intent(in) :: base64_str, & ! base64 encoded string
|
2020-09-13 10:28:34 +05:30
|
|
|
headerType ! header type (UInt32 or Uint64)
|
2020-09-12 18:13:04 +05:30
|
|
|
logical, intent(in) :: compressed ! indicate whether data is zlib compressed
|
|
|
|
|
|
|
|
integer(C_SIGNED_CHAR), dimension(:), allocatable :: bytes
|
|
|
|
|
|
|
|
if(compressed) then
|
2020-09-13 10:28:34 +05:30
|
|
|
bytes = asBytes_compressed(base64_str,headerType)
|
2020-09-12 18:13:04 +05:30
|
|
|
else
|
2020-09-13 10:28:34 +05:30
|
|
|
bytes = asBytes_uncompressed(base64_str,headerType)
|
2020-09-12 18:13:04 +05:30
|
|
|
endif
|
|
|
|
|
|
|
|
end function asBytes
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Interpret compressed Base64 string in vtk XML file as bytes
|
|
|
|
!> @details A compressed Base64 string consists of a header block and a data block
|
|
|
|
! [#blocks/#u-size/#p-size/#c-size-1/#c-size-2/.../#c-size-#blocks][DATA-1/DATA-2...]
|
|
|
|
! #blocks = Number of blocks
|
|
|
|
! #u-size = Block size before compression
|
|
|
|
! #p-size = Size of last partial block (zero if it not needed)
|
|
|
|
! #c-size-i = Size in bytes of block i after compression
|
|
|
|
!------------------------------------------------------------------------------------------------
|
2020-09-13 10:28:34 +05:30
|
|
|
function asBytes_compressed(base64_str,headerType) result(bytes)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
character(len=*), intent(in) :: base64_str, & ! base64 encoded string
|
2020-09-13 10:28:34 +05:30
|
|
|
headerType ! header type (UInt32 or Uint64)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
2020-09-13 02:25:30 +05:30
|
|
|
integer(C_SIGNED_CHAR), dimension(:), allocatable :: bytes, bytes_inflated
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
integer(pI64), dimension(:), allocatable :: temp, size_inflated, size_deflated
|
2020-09-13 10:28:34 +05:30
|
|
|
integer(pI64) :: headerLen, nBlock, b,s,e
|
2020-09-12 18:13:04 +05:30
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
if (headerType == 'UInt32') then
|
2020-09-13 23:44:34 +05:30
|
|
|
temp = int(prec_bytesToC_INT32_T(base64_to_bytes(base64_str(:base64_nChar(4_pI64)))),pI64)
|
2020-09-13 10:28:34 +05:30
|
|
|
nBlock = int(temp(1),pI64)
|
|
|
|
headerLen = 4_pI64 * (3_pI64 + nBlock)
|
2020-09-13 23:44:34 +05:30
|
|
|
temp = int(prec_bytesToC_INT32_T(base64_to_bytes(base64_str(:base64_nChar(headerLen)))),pI64)
|
2020-09-13 10:28:34 +05:30
|
|
|
elseif(headerType == 'UInt64') then
|
2020-09-13 23:44:34 +05:30
|
|
|
temp = int(prec_bytesToC_INT64_T(base64_to_bytes(base64_str(:base64_nChar(8_pI64)))),pI64)
|
2020-09-13 10:28:34 +05:30
|
|
|
nBlock = int(temp(1),pI64)
|
|
|
|
headerLen = 8_pI64 * (3_pI64 + nBlock)
|
2020-09-13 23:44:34 +05:30
|
|
|
temp = int(prec_bytesToC_INT64_T(base64_to_bytes(base64_str(:base64_nChar(headerLen)))),pI64)
|
2020-09-12 18:13:04 +05:30
|
|
|
endif
|
|
|
|
|
2020-09-13 10:28:34 +05:30
|
|
|
allocate(size_inflated(nBlock),source=temp(2))
|
|
|
|
size_inflated(nBlock) = merge(temp(3),temp(2),temp(3)/=0_pI64)
|
2020-09-12 18:13:04 +05:30
|
|
|
size_deflated = temp(4:)
|
2020-09-13 10:28:34 +05:30
|
|
|
bytes_inflated = base64_to_bytes(base64_str(base64_nChar(headerLen)+1_pI64:))
|
2020-09-12 18:13:04 +05:30
|
|
|
|
2020-12-05 17:16:48 +05:30
|
|
|
allocate(bytes(sum(size_inflated)))
|
2020-09-12 18:13:04 +05:30
|
|
|
e = 0_pI64
|
2020-09-13 10:28:34 +05:30
|
|
|
do b = 1, nBlock
|
2020-09-12 18:13:04 +05:30
|
|
|
s = e + 1_pI64
|
|
|
|
e = s + size_deflated(b) - 1_pI64
|
2020-12-05 17:16:48 +05:30
|
|
|
bytes(sum(size_inflated(:b-1))+1_pI64:sum(size_inflated(:b))) = zlib_inflate(bytes_inflated(s:e),size_inflated(b))
|
2020-09-12 18:13:04 +05:30
|
|
|
enddo
|
|
|
|
|
|
|
|
end function asBytes_compressed
|
|
|
|
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Interprete uncompressed Base64 string in vtk XML file as bytes
|
|
|
|
!> @details An uncompressed Base64 string consists of N headers blocks and a N data blocks
|
|
|
|
![#bytes-1/DATA-1][#bytes-2/DATA-2]...
|
|
|
|
!------------------------------------------------------------------------------------------------
|
2020-09-13 10:28:34 +05:30
|
|
|
function asBytes_uncompressed(base64_str,headerType) result(bytes)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
character(len=*), intent(in) :: base64_str, & ! base64 encoded string
|
2020-09-13 10:28:34 +05:30
|
|
|
headerType ! header type (UInt32 or Uint64)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
integer(pI64) :: s
|
2020-09-13 10:28:34 +05:30
|
|
|
integer(pI64), dimension(1) :: nByte
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
integer(C_SIGNED_CHAR), dimension(:), allocatable :: bytes
|
|
|
|
allocate(bytes(0))
|
|
|
|
|
|
|
|
s=0_pI64
|
2020-09-13 10:28:34 +05:30
|
|
|
if (headerType == 'UInt32') then
|
2020-09-12 18:13:04 +05:30
|
|
|
do while(s+base64_nChar(4_pI64)<(len(base64_str,pI64)))
|
2020-09-13 23:44:34 +05:30
|
|
|
nByte = int(prec_bytesToC_INT32_T(base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(4_pI64)))),pI64)
|
2020-09-13 10:28:34 +05:30
|
|
|
bytes = [bytes,base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(4_pI64+nByte(1))),5_pI64)]
|
|
|
|
s = s + base64_nChar(4_pI64+nByte(1))
|
2020-09-12 18:13:04 +05:30
|
|
|
enddo
|
2020-09-13 10:28:34 +05:30
|
|
|
elseif(headerType == 'UInt64') then
|
2020-09-12 18:13:04 +05:30
|
|
|
do while(s+base64_nChar(8_pI64)<(len(base64_str,pI64)))
|
2020-09-13 23:44:34 +05:30
|
|
|
nByte = int(prec_bytesToC_INT64_T(base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(8_pI64)))),pI64)
|
2020-09-13 10:28:34 +05:30
|
|
|
bytes = [bytes,base64_to_bytes(base64_str(s+1_pI64:s+base64_nChar(8_pI64+nByte(1))),9_pI64)]
|
|
|
|
s = s + base64_nChar(8_pI64+nByte(1))
|
2020-09-12 18:13:04 +05:30
|
|
|
enddo
|
|
|
|
endif
|
|
|
|
|
|
|
|
end function asBytes_uncompressed
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Get XML string value for given key
|
|
|
|
!------------------------------------------------------------------------------------------------
|
|
|
|
pure function getXMLValue(line,key)
|
|
|
|
|
|
|
|
character(len=*), intent(in) :: line, key
|
|
|
|
|
|
|
|
character(len=:), allocatable :: getXMLValue
|
|
|
|
|
|
|
|
integer :: s,e
|
|
|
|
#ifdef __INTEL_COMPILER
|
|
|
|
character :: q
|
|
|
|
#endif
|
|
|
|
|
|
|
|
s = index(line," "//key,back=.true.)
|
|
|
|
if(s==0) then
|
|
|
|
getXMLValue = ''
|
|
|
|
else
|
2020-09-13 10:28:34 +05:30
|
|
|
e = s + 1 + scan(line(s+1:),"'"//'"')
|
|
|
|
if(scan(line(s:e-2),'=') == 0) then
|
|
|
|
getXMLValue = ''
|
|
|
|
else
|
|
|
|
s = e
|
|
|
|
! https://community.intel.com/t5/Intel-Fortran-Compiler/ICE-for-merge-with-strings/m-p/1207204#M151657
|
2020-09-12 18:13:04 +05:30
|
|
|
#ifdef __INTEL_COMPILER
|
2020-09-13 10:28:34 +05:30
|
|
|
q = line(s-1:s-1)
|
|
|
|
e = s + index(line(s:),q) - 1
|
2020-09-12 18:13:04 +05:30
|
|
|
#else
|
2020-09-13 10:28:34 +05:30
|
|
|
e = s + index(line(s:),merge("'",'"',line(s-1:s-1)=="'")) - 1
|
2020-09-12 18:13:04 +05:30
|
|
|
#endif
|
2020-09-13 10:28:34 +05:30
|
|
|
getXMLValue = line(s:e-1)
|
|
|
|
endif
|
2020-09-12 18:13:04 +05:30
|
|
|
endif
|
|
|
|
|
|
|
|
end function
|
|
|
|
|
|
|
|
|
|
|
|
!------------------------------------------------------------------------------------------------
|
2020-09-13 22:02:49 +05:30
|
|
|
!> @brief check for supported file format
|
2020-09-12 18:13:04 +05:30
|
|
|
!------------------------------------------------------------------------------------------------
|
2020-09-13 22:02:49 +05:30
|
|
|
pure function fileFormatOk(line)
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
character(len=*),intent(in) :: line
|
2020-09-13 22:02:49 +05:30
|
|
|
logical :: fileFormatOk
|
2020-09-12 18:13:04 +05:30
|
|
|
|
2020-09-13 22:02:49 +05:30
|
|
|
fileFormatOk = getXMLValue(line,'type') == 'RectilinearGrid' .and. &
|
|
|
|
getXMLValue(line,'byte_order') == 'LittleEndian' .and. &
|
|
|
|
getXMLValue(line,'compressor') /= 'vtkLZ4DataCompressor' .and. &
|
|
|
|
getXMLValue(line,'compressor') /= 'vtkLZMADataCompressor'
|
2020-09-12 18:13:04 +05:30
|
|
|
|
2020-09-13 22:02:49 +05:30
|
|
|
end function fileFormatOk
|
2020-09-12 18:13:04 +05:30
|
|
|
|
|
|
|
end subroutine readVTR
|
|
|
|
|
|
|
|
|
2019-05-14 02:48:02 +05:30
|
|
|
!---------------------------------------------------------------------------------------------------
|
2020-01-12 01:03:29 +05:30
|
|
|
!> @brief Calculate undeformed position of IPs/cell centers (pretend to be an element)
|
2019-05-14 02:48:02 +05:30
|
|
|
!---------------------------------------------------------------------------------------------------
|
2019-09-28 03:18:51 +05:30
|
|
|
function IPcoordinates0(grid,geomSize,grid3Offset)
|
2019-05-14 02:24:18 +05:30
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
integer, dimension(3), intent(in) :: grid ! grid (for this process!)
|
|
|
|
real(pReal), dimension(3), intent(in) :: geomSize ! size (for this process!)
|
|
|
|
integer, intent(in) :: grid3Offset ! grid(3) offset
|
2019-05-14 02:24:18 +05:30
|
|
|
|
2019-09-28 03:24:02 +05:30
|
|
|
real(pReal), dimension(3,product(grid)) :: ipCoordinates0
|
2019-06-08 14:45:01 +05:30
|
|
|
|
|
|
|
integer :: &
|
|
|
|
a,b,c, &
|
|
|
|
i
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
i = 0
|
|
|
|
do c = 1, grid(3); do b = 1, grid(2); do a = 1, grid(1)
|
|
|
|
i = i + 1
|
2019-09-28 03:24:02 +05:30
|
|
|
IPcoordinates0(1:3,i) = geomSize/real(grid,pReal) * (real([a,b,grid3Offset+c],pReal) -0.5_pReal)
|
2019-06-08 14:45:01 +05:30
|
|
|
enddo; enddo; enddo
|
2012-08-27 13:34:47 +05:30
|
|
|
|
2019-09-28 03:18:51 +05:30
|
|
|
end function IPcoordinates0
|
2012-08-27 13:34:47 +05:30
|
|
|
|
|
|
|
|
2019-05-14 02:48:02 +05:30
|
|
|
!---------------------------------------------------------------------------------------------------
|
2019-09-28 03:18:51 +05:30
|
|
|
!> @brief Calculate position of undeformed nodes (pretend to be an element)
|
2019-05-14 02:48:02 +05:30
|
|
|
!---------------------------------------------------------------------------------------------------
|
2019-09-28 03:18:51 +05:30
|
|
|
pure function nodes0(grid,geomSize,grid3Offset)
|
2019-05-14 02:48:02 +05:30
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
integer, dimension(3), intent(in) :: grid ! grid (for this process!)
|
|
|
|
real(pReal), dimension(3), intent(in) :: geomSize ! size (for this process!)
|
|
|
|
integer, intent(in) :: grid3Offset ! grid(3) offset
|
2019-05-14 02:48:02 +05:30
|
|
|
|
2019-09-28 03:24:02 +05:30
|
|
|
real(pReal), dimension(3,product(grid+1)) :: nodes0
|
2019-05-14 02:48:02 +05:30
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
integer :: &
|
|
|
|
a,b,c, &
|
|
|
|
n
|
2019-05-14 02:48:02 +05:30
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
n = 0
|
|
|
|
do c = 0, grid3; do b = 0, grid(2); do a = 0, grid(1)
|
|
|
|
n = n + 1
|
2019-09-28 03:18:51 +05:30
|
|
|
nodes0(1:3,n) = geomSize/real(grid,pReal) * real([a,b,grid3Offset+c],pReal)
|
2019-06-08 14:45:01 +05:30
|
|
|
enddo; enddo; enddo
|
2013-05-08 21:22:29 +05:30
|
|
|
|
2019-09-28 03:18:51 +05:30
|
|
|
end function nodes0
|
2013-04-22 14:31:58 +05:30
|
|
|
|
|
|
|
|
2019-06-07 15:51:12 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2019-06-08 14:45:01 +05:30
|
|
|
!> @brief Calculate IP interface areas
|
2019-06-07 15:51:12 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2020-01-29 19:18:15 +05:30
|
|
|
pure function cellSurfaceArea(geomSize,grid)
|
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
real(pReal), dimension(3), intent(in) :: geomSize ! size (for this process!)
|
|
|
|
integer, dimension(3), intent(in) :: grid ! grid (for this process!)
|
2019-06-07 15:51:12 +05:30
|
|
|
|
2020-01-29 19:18:15 +05:30
|
|
|
real(pReal), dimension(6,1,product(grid)) :: cellSurfaceArea
|
|
|
|
|
|
|
|
cellSurfaceArea(1:2,1,:) = geomSize(2)/real(grid(2)) * geomSize(3)/real(grid(3))
|
|
|
|
cellSurfaceArea(3:4,1,:) = geomSize(3)/real(grid(3)) * geomSize(1)/real(grid(1))
|
|
|
|
cellSurfaceArea(5:6,1,:) = geomSize(1)/real(grid(1)) * geomSize(2)/real(grid(2))
|
|
|
|
|
|
|
|
end function cellSurfaceArea
|
2019-06-07 15:51:12 +05:30
|
|
|
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2019-06-08 14:45:01 +05:30
|
|
|
!> @brief Calculate IP interface areas normals
|
2019-06-07 15:51:12 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2020-01-29 19:18:15 +05:30
|
|
|
pure function cellSurfaceNormal(nElems)
|
2019-06-07 15:51:12 +05:30
|
|
|
|
|
|
|
integer, intent(in) :: nElems
|
2019-06-08 14:45:01 +05:30
|
|
|
|
2020-01-29 19:18:15 +05:30
|
|
|
real(pReal), dimension(3,6,1,nElems) :: cellSurfaceNormal
|
|
|
|
|
|
|
|
cellSurfaceNormal(1:3,1,1,:) = spread([+1.0_pReal, 0.0_pReal, 0.0_pReal],2,nElems)
|
|
|
|
cellSurfaceNormal(1:3,2,1,:) = spread([-1.0_pReal, 0.0_pReal, 0.0_pReal],2,nElems)
|
|
|
|
cellSurfaceNormal(1:3,3,1,:) = spread([ 0.0_pReal,+1.0_pReal, 0.0_pReal],2,nElems)
|
|
|
|
cellSurfaceNormal(1:3,4,1,:) = spread([ 0.0_pReal,-1.0_pReal, 0.0_pReal],2,nElems)
|
|
|
|
cellSurfaceNormal(1:3,5,1,:) = spread([ 0.0_pReal, 0.0_pReal,+1.0_pReal],2,nElems)
|
|
|
|
cellSurfaceNormal(1:3,6,1,:) = spread([ 0.0_pReal, 0.0_pReal,-1.0_pReal],2,nElems)
|
|
|
|
|
|
|
|
end function cellSurfaceNormal
|
2019-06-07 15:51:12 +05:30
|
|
|
|
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Build IP neighborhood relations
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
pure function IPneighborhood(grid)
|
|
|
|
|
|
|
|
integer, dimension(3), intent(in) :: grid ! grid (for this process!)
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2020-01-29 22:45:49 +05:30
|
|
|
integer, dimension(3,6,1,product(grid)) :: IPneighborhood !< 6 neighboring IPs as [element ID, IP ID, face ID]
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
integer :: &
|
|
|
|
x,y,z, &
|
|
|
|
e
|
|
|
|
|
|
|
|
e = 0
|
|
|
|
do z = 0,grid(3)-1; do y = 0,grid(2)-1; do x = 0,grid(1)-1
|
|
|
|
e = e + 1
|
2020-01-27 02:26:08 +05:30
|
|
|
! element ID
|
2019-06-08 14:45:01 +05:30
|
|
|
IPneighborhood(1,1,1,e) = z * grid(1) * grid(2) &
|
|
|
|
+ y * grid(1) &
|
|
|
|
+ modulo(x+1,grid(1)) &
|
|
|
|
+ 1
|
|
|
|
IPneighborhood(1,2,1,e) = z * grid(1) * grid(2) &
|
|
|
|
+ y * grid(1) &
|
|
|
|
+ modulo(x-1,grid(1)) &
|
|
|
|
+ 1
|
|
|
|
IPneighborhood(1,3,1,e) = z * grid(1) * grid(2) &
|
|
|
|
+ modulo(y+1,grid(2)) * grid(1) &
|
|
|
|
+ x &
|
|
|
|
+ 1
|
|
|
|
IPneighborhood(1,4,1,e) = z * grid(1) * grid(2) &
|
|
|
|
+ modulo(y-1,grid(2)) * grid(1) &
|
|
|
|
+ x &
|
|
|
|
+ 1
|
|
|
|
IPneighborhood(1,5,1,e) = modulo(z+1,grid(3)) * grid(1) * grid(2) &
|
|
|
|
+ y * grid(1) &
|
|
|
|
+ x &
|
|
|
|
+ 1
|
|
|
|
IPneighborhood(1,6,1,e) = modulo(z-1,grid(3)) * grid(1) * grid(2) &
|
|
|
|
+ y * grid(1) &
|
|
|
|
+ x &
|
|
|
|
+ 1
|
2020-01-27 02:26:08 +05:30
|
|
|
! IP ID
|
|
|
|
IPneighborhood(2,:,1,e) = 1
|
|
|
|
|
|
|
|
! face ID
|
|
|
|
IPneighborhood(3,1,1,e) = 2
|
|
|
|
IPneighborhood(3,2,1,e) = 1
|
|
|
|
IPneighborhood(3,3,1,e) = 4
|
|
|
|
IPneighborhood(3,4,1,e) = 3
|
|
|
|
IPneighborhood(3,5,1,e) = 6
|
|
|
|
IPneighborhood(3,6,1,e) = 5
|
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
enddo; enddo; enddo
|
2020-01-29 19:18:15 +05:30
|
|
|
|
2019-06-08 14:45:01 +05:30
|
|
|
end function IPneighborhood
|
2019-06-07 15:51:12 +05:30
|
|
|
|
|
|
|
|
2020-03-20 11:28:55 +05:30
|
|
|
end module discretization_grid
|