read file only once
This commit is contained in:
parent
62865e779d
commit
830b05005f
18
src/IO.f90
18
src/IO.f90
|
@ -23,7 +23,6 @@ module IO
|
||||||
public :: &
|
public :: &
|
||||||
IO_init, &
|
IO_init, &
|
||||||
IO_read_ASCII, &
|
IO_read_ASCII, &
|
||||||
IO_open_file, & ! deprecated, use IO_read_ASCII
|
|
||||||
IO_open_jobFile_binary, &
|
IO_open_jobFile_binary, &
|
||||||
IO_isBlank, &
|
IO_isBlank, &
|
||||||
IO_getTag, &
|
IO_getTag, &
|
||||||
|
@ -125,23 +124,6 @@ function IO_read_ASCII(fileName) result(fileContent)
|
||||||
end function IO_read_ASCII
|
end function IO_read_ASCII
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
!> @brief opens existing file for reading to given unit. Path to file is relative to working
|
|
||||||
!! directory
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
|
||||||
subroutine IO_open_file(fileUnit,path)
|
|
||||||
|
|
||||||
integer, intent(in) :: fileUnit !< file unit
|
|
||||||
character(len=*), intent(in) :: path !< relative path from working directory
|
|
||||||
|
|
||||||
integer :: myStat
|
|
||||||
|
|
||||||
open(fileUnit,status='old',iostat=myStat,file=path,action='read',position='rewind')
|
|
||||||
if (myStat /= 0) call IO_error(100,el=myStat,ext_msg=path)
|
|
||||||
|
|
||||||
end subroutine IO_open_file
|
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @brief opens an existing file for reading or a new file for writing. Name is the job name
|
!> @brief opens an existing file for reading or a new file for writing. Name is the job name
|
||||||
!> @details replaces an existing file when writing
|
!> @details replaces an existing file when writing
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
!-------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
||||||
!> @brief Reads in the material configuration from file
|
!> @brief Reads in the material configuration from file
|
||||||
!> @details Reads the material configuration file, where solverJobName.materialConfig takes
|
!> @details Reads the material configuration file, where solverJobName.materialConfig takes
|
||||||
|
|
|
@ -39,9 +39,6 @@ module mesh
|
||||||
integer, dimension(:,:), allocatable :: &
|
integer, dimension(:,:), allocatable :: &
|
||||||
mesh_element !DEPRECATED
|
mesh_element !DEPRECATED
|
||||||
|
|
||||||
real(pReal), dimension(:,:), allocatable :: &
|
|
||||||
mesh_node !< node x,y,z coordinates (after deformation! ONLY FOR MARC!!!)
|
|
||||||
|
|
||||||
real(pReal), dimension(:,:), allocatable :: &
|
real(pReal), dimension(:,:), allocatable :: &
|
||||||
mesh_ipVolume, & !< volume associated with IP (initially!)
|
mesh_ipVolume, & !< volume associated with IP (initially!)
|
||||||
mesh_node0 !< node x,y,z coordinates (initially!)
|
mesh_node0 !< node x,y,z coordinates (initially!)
|
||||||
|
@ -71,20 +68,18 @@ subroutine mesh_init
|
||||||
integer, dimension(1), parameter:: FE_geomtype = [1] !< geometry type of particular element type
|
integer, dimension(1), parameter:: FE_geomtype = [1] !< geometry type of particular element type
|
||||||
integer, dimension(1) :: FE_Nips !< number of IPs in a specific type of element
|
integer, dimension(1) :: FE_Nips !< number of IPs in a specific type of element
|
||||||
|
|
||||||
integer, parameter :: FILEUNIT = 222
|
integer :: j, l
|
||||||
integer :: j
|
|
||||||
integer, allocatable, dimension(:) :: chunkPos
|
integer, allocatable, dimension(:) :: chunkPos
|
||||||
integer :: dimPlex, &
|
integer :: dimPlex, &
|
||||||
mesh_Nnodes !< total number of nodes in mesh
|
mesh_Nnodes !< total number of nodes in mesh
|
||||||
integer, parameter :: &
|
integer, parameter :: &
|
||||||
mesh_ElemType=1 !< Element type of the mesh (only support homogeneous meshes)
|
mesh_ElemType=1 !< Element type of the mesh (only support homogeneous meshes)
|
||||||
character(len=pStringLen) :: &
|
logical :: found
|
||||||
line
|
|
||||||
logical :: flag
|
|
||||||
PetscSF :: sf
|
PetscSF :: sf
|
||||||
DM :: globalMesh
|
DM :: globalMesh
|
||||||
PetscInt :: nFaceSets
|
PetscInt :: nFaceSets
|
||||||
PetscInt, pointer :: pFaceSets(:)
|
PetscInt, pointer, dimension(:) :: pFaceSets
|
||||||
|
character(len=pStringLen), dimension(:), allocatable :: fileContent
|
||||||
IS :: faceSetIS
|
IS :: faceSetIS
|
||||||
PetscErrorCode :: ierr
|
PetscErrorCode :: ierr
|
||||||
|
|
||||||
|
@ -122,31 +117,25 @@ subroutine mesh_init
|
||||||
endif
|
endif
|
||||||
call MPI_Bcast(mesh_boundaries,mesh_Nboundaries,MPI_INTEGER,0,PETSC_COMM_WORLD,ierr)
|
call MPI_Bcast(mesh_boundaries,mesh_Nboundaries,MPI_INTEGER,0,PETSC_COMM_WORLD,ierr)
|
||||||
|
|
||||||
! this read in function should ignore C and C++ style comments
|
|
||||||
! it is used for BC only?
|
|
||||||
if (worldrank == 0) then
|
if (worldrank == 0) then
|
||||||
|
fileContent = IO_read_ASCII(geometryFile)
|
||||||
j = 0
|
j = 0
|
||||||
flag = .false.
|
l = 0
|
||||||
call IO_open_file(FILEUNIT,trim(geometryFile))
|
found = .false.
|
||||||
do
|
do
|
||||||
read(FILEUNIT,'(a)') line
|
l = l + 1
|
||||||
if (trim(line) == IO_EOF) exit ! skip empty lines
|
if (IO_isBlank(fileContent(l))) cycle ! need also to ignore C and C++ style comments?
|
||||||
if (trim(line) == '$Elements') then
|
if (trim(fileContent(l)) == '$EndElements') exit
|
||||||
read(FILEUNIT,'(A)') line ! number of elements (ignore)
|
if (trim(fileContent(l)) == '$Elements') found = .true.
|
||||||
read(FILEUNIT,'(A)') line
|
if (found) then
|
||||||
flag = .true.
|
chunkPos = IO_stringPos(fileContent(l))
|
||||||
endif
|
if (chunkPos(1) == 3+IO_intValue(fileContent(l),chunkPos,3)+dimPlex+1) then
|
||||||
if (trim(line) == '$EndElements') exit
|
call DMSetLabelValue(globalMesh,'material',j,IO_intValue(fileContent(l),chunkPos,4),ierr)
|
||||||
if (flag) then
|
|
||||||
chunkPos = IO_stringPos(line)
|
|
||||||
if (chunkPos(1) == 3+IO_intValue(line,chunkPos,3)+dimPlex+1) then
|
|
||||||
call DMSetLabelValue(globalMesh,'material',j,IO_intValue(line,chunkPos,4),ierr)
|
|
||||||
CHKERRQ(ierr)
|
CHKERRQ(ierr)
|
||||||
j = j + 1
|
j = j + 1
|
||||||
endif ! count all identifiers to allocate memory and do sanity check
|
endif ! count all identifiers to allocate memory and do sanity check
|
||||||
endif
|
endif
|
||||||
enddo
|
enddo
|
||||||
close (FILEUNIT)
|
|
||||||
call DMClone(globalMesh,geomMesh,ierr)
|
call DMClone(globalMesh,geomMesh,ierr)
|
||||||
CHKERRQ(ierr)
|
CHKERRQ(ierr)
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue