read from memory, not from file
This commit is contained in:
parent
f33a99d125
commit
2b68c108f0
46
src/IO.f90
46
src/IO.f90
|
@ -44,7 +44,6 @@ module IO
|
||||||
IO_extractValue, &
|
IO_extractValue, &
|
||||||
IO_countDataLines
|
IO_countDataLines
|
||||||
#elif defined(Marc4DAMASK)
|
#elif defined(Marc4DAMASK)
|
||||||
IO_skipChunks, &
|
|
||||||
IO_fixedNoEFloatValue, &
|
IO_fixedNoEFloatValue, &
|
||||||
IO_fixedIntValue, &
|
IO_fixedIntValue, &
|
||||||
IO_countNumericalDataLines
|
IO_countNumericalDataLines
|
||||||
|
@ -189,17 +188,17 @@ integer function IO_open_binary(fileName,mode)
|
||||||
m = 'r'
|
m = 'r'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if (m == 'w') then
|
if (m == 'w') then
|
||||||
open(newunit=IO_open_binary, file=trim(fileName),&
|
open(newunit=IO_open_binary, file=trim(fileName),&
|
||||||
status='replace',access='stream',action='write',iostat=ierr)
|
status='replace',access='stream',action='write',iostat=ierr)
|
||||||
if (ierr /= 0) call IO_error(100,ext_msg='could not open file (w): '//trim(fileName))
|
if (ierr /= 0) call IO_error(100,ext_msg='could not open file (w): '//trim(fileName))
|
||||||
elseif(m == 'r') then
|
elseif(m == 'r') then
|
||||||
open(newunit=IO_open_binary, file=trim(fileName),&
|
open(newunit=IO_open_binary, file=trim(fileName),&
|
||||||
status='old', access='stream',action='read', iostat=ierr)
|
status='old', access='stream',action='read', iostat=ierr)
|
||||||
if (ierr /= 0) call IO_error(100,ext_msg='could not open file (r): '//trim(fileName))
|
if (ierr /= 0) call IO_error(100,ext_msg='could not open file (r): '//trim(fileName))
|
||||||
else
|
else
|
||||||
call IO_error(100,ext_msg='unknown access mode: '//m)
|
call IO_error(100,ext_msg='unknown access mode: '//m)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
end function IO_open_binary
|
end function IO_open_binary
|
||||||
|
|
||||||
|
@ -403,7 +402,7 @@ pure function IO_stringPos(string)
|
||||||
left = right + verify(string(right+1:),SEP)
|
left = right + verify(string(right+1:),SEP)
|
||||||
right = left + scan(string(left:),SEP) - 2
|
right = left + scan(string(left:),SEP) - 2
|
||||||
if ( string(left:left) == '#' ) exit
|
if ( string(left:left) == '#' ) exit
|
||||||
IO_stringPos = [IO_stringPos,left, right]
|
IO_stringPos = [IO_stringPos,left,right]
|
||||||
IO_stringPos(1) = IO_stringPos(1)+1
|
IO_stringPos(1) = IO_stringPos(1)+1
|
||||||
endOfString: if (right < left) then
|
endOfString: if (right < left) then
|
||||||
IO_stringPos(IO_stringPos(1)*2+1) = len_trim(string)
|
IO_stringPos(IO_stringPos(1)*2+1) = len_trim(string)
|
||||||
|
@ -1023,27 +1022,6 @@ integer function IO_countNumericalDataLines(fileUnit)
|
||||||
backspace(fileUnit)
|
backspace(fileUnit)
|
||||||
|
|
||||||
end function IO_countNumericalDataLines
|
end function IO_countNumericalDataLines
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief reads file to skip (at least) N chunks (may be over multiple lines)
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
subroutine IO_skipChunks(fileUnit,N)
|
|
||||||
|
|
||||||
integer, intent(in) :: fileUnit, & !< file handle
|
|
||||||
N !< minimum number of chunks to skip
|
|
||||||
|
|
||||||
integer :: remainingChunks
|
|
||||||
character(len=65536) :: line
|
|
||||||
|
|
||||||
line = ''
|
|
||||||
remainingChunks = N
|
|
||||||
|
|
||||||
do while (trim(line) /= IO_EOF .and. remainingChunks > 0)
|
|
||||||
line = IO_read(fileUnit)
|
|
||||||
remainingChunks = remainingChunks - (size(IO_stringPos(line))-1)/2
|
|
||||||
enddo
|
|
||||||
end subroutine IO_skipChunks
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,7 @@ subroutine mesh_init(ip,el)
|
||||||
call geometry_plastic_nonlocal_setIParea(norm2(x,1))
|
call geometry_plastic_nonlocal_setIParea(norm2(x,1))
|
||||||
call geometry_plastic_nonlocal_results
|
call geometry_plastic_nonlocal_results
|
||||||
|
|
||||||
|
|
||||||
end subroutine mesh_init
|
end subroutine mesh_init
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
@ -224,7 +225,7 @@ subroutine inputRead(elem,node0_elem,connectivity_elem,microstructureAt,homogeni
|
||||||
call inputRead_mapNodes(inputFile)
|
call inputRead_mapNodes(inputFile)
|
||||||
|
|
||||||
call inputRead_elemType(elem, &
|
call inputRead_elemType(elem, &
|
||||||
nElems,FILEUNIT)
|
nElems,inputFile)
|
||||||
call inputRead_elemNodes(node0_elem, &
|
call inputRead_elemNodes(node0_elem, &
|
||||||
Nnodes,inputFile)
|
Nnodes,inputFile)
|
||||||
|
|
||||||
|
@ -355,7 +356,7 @@ end subroutine inputRead_NnodesAndElements
|
||||||
!> @brief Count overall number of element sets in mesh.
|
!> @brief Count overall number of element sets in mesh.
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
subroutine inputRead_NelemSets(nElemSets,maxNelemInSet,&
|
subroutine inputRead_NelemSets(nElemSets,maxNelemInSet,&
|
||||||
fileUnit)
|
fileUnit)
|
||||||
|
|
||||||
integer, intent(out) :: nElemSets, maxNelemInSet
|
integer, intent(out) :: nElemSets, maxNelemInSet
|
||||||
integer, intent(in) :: fileUnit
|
integer, intent(in) :: fileUnit
|
||||||
|
@ -421,62 +422,61 @@ subroutine inputRead_mapElemSets(nameElemSet,mapElemSet,fileUnit)
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
subroutine inputRead_mapElems(tableStyle,nameElemSet,mapElemSet,fileFormatVersion,matNumber,fileUnit)
|
subroutine inputRead_mapElems(tableStyle,nameElemSet,mapElemSet,fileFormatVersion,matNumber,fileUnit)
|
||||||
|
|
||||||
integer, intent(in) :: fileUnit,tableStyle,fileFormatVersion
|
integer, intent(in) :: fileUnit,tableStyle,fileFormatVersion
|
||||||
integer, dimension(:), intent(in) :: matNumber
|
integer, dimension(:), intent(in) :: matNumber
|
||||||
character(len=64), intent(in), dimension(:) :: nameElemSet
|
character(len=64), intent(in), dimension(:) :: nameElemSet
|
||||||
integer, dimension(:,:), intent(in) :: &
|
integer, dimension(:,:), intent(in) :: &
|
||||||
mapElemSet
|
mapElemSet
|
||||||
|
|
||||||
integer, allocatable, dimension(:) :: chunkPos
|
integer, allocatable, dimension(:) :: chunkPos
|
||||||
character(len=300) :: line, &
|
character(len=300) :: line, &
|
||||||
tmp
|
tmp
|
||||||
|
|
||||||
integer, dimension(:), allocatable :: contInts
|
integer, dimension(:), allocatable :: contInts
|
||||||
integer :: i,cpElem
|
integer :: i,cpElem
|
||||||
|
|
||||||
allocate(contInts(size(mesh_mapFEtoCPelem,2)+1))
|
allocate(contInts(size(mesh_mapFEtoCPelem,2)+1))
|
||||||
|
|
||||||
cpElem = 0
|
cpElem = 0
|
||||||
contInts = 0
|
contInts = 0
|
||||||
rewind(fileUnit)
|
rewind(fileUnit)
|
||||||
do
|
do
|
||||||
read (fileUnit,'(A300)',END=620) line
|
read (fileUnit,'(A300)',END=620) line
|
||||||
chunkPos = IO_stringPos(line)
|
chunkPos = IO_stringPos(line)
|
||||||
if (fileFormatVersion < 13) then ! Marc 2016 or earlier
|
Marc2016andEarlier: if (fileFormatVersion < 13) then
|
||||||
if( IO_lc(IO_stringValue(line,chunkPos,1)) == 'hypoelastic' ) then
|
if( IO_lc(IO_stringValue(line,chunkPos,1)) == 'hypoelastic' ) then
|
||||||
do i=1,3+TableStyle ! skip three (or four if new table style!) lines
|
skipLines: do i=1,3+TableStyle
|
||||||
read (fileUnit,'(A300)') line
|
read (fileUnit,'(A300)') line
|
||||||
enddo
|
enddo skipLines
|
||||||
contInts = IO_continuousIntValues(fileUnit,size(mesh_mapFEtoCPelem,2),nameElemSet,&
|
contInts = IO_continuousIntValues(fileUnit,size(mesh_mapFEtoCPelem,2),nameElemSet,&
|
||||||
mapElemSet,size(nameElemSet))
|
mapElemSet,size(nameElemSet))
|
||||||
|
exit
|
||||||
exit
|
endif
|
||||||
endif
|
else Marc2016andEarlier
|
||||||
else ! Marc2017 and later
|
if ( IO_lc(IO_stringValue(line,chunkPos,1)) == 'connectivity') then
|
||||||
if ( IO_lc(IO_stringValue(line,chunkPos,1)) == 'connectivity') then
|
read (fileUnit,'(A300)',END=620) line
|
||||||
read (fileUnit,'(A300)',END=620) line
|
chunkPos = IO_stringPos(line)
|
||||||
chunkPos = IO_stringPos(line)
|
if(any(matNumber==IO_intValue(line,chunkPos,6))) then
|
||||||
if(any(matNumber==IO_intValue(line,chunkPos,6))) then
|
do
|
||||||
do
|
read (fileUnit,'(A300)',END=620) line
|
||||||
read (fileUnit,'(A300)',END=620) line
|
chunkPos = IO_stringPos(line)
|
||||||
chunkPos = IO_stringPos(line)
|
tmp = IO_lc(IO_stringValue(line,chunkPos,1))
|
||||||
tmp = IO_lc(IO_stringValue(line,chunkPos,1))
|
if (verify(trim(tmp),"0123456789")/=0) then ! found keyword
|
||||||
if (verify(trim(tmp),"0123456789")/=0) then ! found keyword
|
exit
|
||||||
exit
|
else
|
||||||
else
|
contInts(1) = contInts(1) + 1
|
||||||
contInts(1) = contInts(1) + 1
|
read (tmp,*) contInts(contInts(1)+1)
|
||||||
read (tmp,*) contInts(contInts(1)+1)
|
endif
|
||||||
endif
|
enddo
|
||||||
enddo
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif Marc2016andEarlier
|
||||||
endif
|
enddo
|
||||||
enddo
|
|
||||||
620 do i = 1,contInts(1)
|
620 do i = 1,contInts(1)
|
||||||
cpElem = cpElem+1
|
cpElem = cpElem+1
|
||||||
mesh_mapFEtoCPelem(1,cpElem) = contInts(1+i)
|
mesh_mapFEtoCPelem(1,cpElem) = contInts(1+i)
|
||||||
mesh_mapFEtoCPelem(2,cpElem) = cpElem
|
mesh_mapFEtoCPelem(2,cpElem) = cpElem
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
call math_sort(mesh_mapFEtoCPelem)
|
call math_sort(mesh_mapFEtoCPelem)
|
||||||
|
|
||||||
|
@ -545,35 +545,34 @@ end subroutine inputRead_elemNodes
|
||||||
!> @brief Gets element type (and checks if the whole mesh comprises of only one type)
|
!> @brief Gets element type (and checks if the whole mesh comprises of only one type)
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
subroutine inputRead_elemType(elem, &
|
subroutine inputRead_elemType(elem, &
|
||||||
nElem,fileUnit)
|
nElem,fileContent)
|
||||||
|
|
||||||
type(tElement), intent(out) :: elem
|
type(tElement), intent(out) :: elem
|
||||||
integer, intent(in) :: &
|
integer, intent(in) :: nElem
|
||||||
nElem, &
|
character(len=pStringLen), dimension(:), intent(in) :: fileContent !< file content, separated per lines
|
||||||
fileUnit
|
|
||||||
|
|
||||||
integer, allocatable, dimension(:) :: chunkPos
|
integer, allocatable, dimension(:) :: chunkPos
|
||||||
character(len=300) :: line
|
integer :: i,j,t,l,remainingChunks
|
||||||
integer :: i,t
|
|
||||||
|
|
||||||
t = -1
|
t = -1
|
||||||
|
j = 0
|
||||||
rewind(fileUnit)
|
do l = 1, size(fileContent)
|
||||||
do
|
chunkPos = IO_stringPos(fileContent(l))
|
||||||
read (fileUnit,'(A300)',END=620) line
|
if( IO_lc(IO_stringValue(fileContent(l),chunkPos,1)) == 'connectivity' ) then
|
||||||
chunkPos = IO_stringPos(line)
|
|
||||||
if( IO_lc(IO_stringValue(line,chunkPos,1)) == 'connectivity' ) then
|
|
||||||
read (fileUnit,'(A300)') line ! Garbage line
|
|
||||||
do i=1,nElem ! read all elements
|
do i=1,nElem ! read all elements
|
||||||
read (fileUnit,'(A300)') line
|
chunkPos = IO_stringPos(fileContent(l+1+i+j))
|
||||||
chunkPos = IO_stringPos(line)
|
|
||||||
if (t == -1) then
|
if (t == -1) then
|
||||||
t = mapElemtype(IO_stringValue(line,chunkPos,2))
|
t = mapElemtype(IO_stringValue(fileContent(l+1+i+j),chunkPos,2))
|
||||||
call elem%init(t)
|
call elem%init(t)
|
||||||
else
|
else
|
||||||
if (t /= mapElemtype(IO_stringValue(line,chunkPos,2))) call IO_error(191,el=t,ip=i)
|
if (t /= mapElemtype(IO_stringValue(fileContent(l+1+i+j),chunkPos,2))) call IO_error(191,el=t,ip=i)
|
||||||
endif
|
endif
|
||||||
call IO_skipChunks(fileUnit,elem%nNodes-(chunkPos(1)-2))
|
remainingChunks = elem%nNodes - (chunkPos(1) - 2)
|
||||||
|
do while(remainingChunks > 0)
|
||||||
|
j = j + 1
|
||||||
|
chunkPos = IO_stringPos(fileContent(l+1+i+j))
|
||||||
|
remainingChunks = remainingChunks - chunkPos(1)
|
||||||
|
enddo
|
||||||
enddo
|
enddo
|
||||||
exit
|
exit
|
||||||
endif
|
endif
|
||||||
|
@ -622,10 +621,10 @@ subroutine inputRead_elemType(elem, &
|
||||||
call IO_error(error_ID=190,ext_msg=IO_lc(what))
|
call IO_error(error_ID=190,ext_msg=IO_lc(what))
|
||||||
end select
|
end select
|
||||||
|
|
||||||
end function mapElemtype
|
end function mapElemtype
|
||||||
|
|
||||||
|
|
||||||
620 end subroutine inputRead_elemType
|
end subroutine inputRead_elemType
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue