include origin do DADF5

requires updat of file version
This commit is contained in:
Martin Diehl 2019-12-13 09:08:48 +01:00
parent ee56b82c8a
commit 63fc125398
4 changed files with 37 additions and 14 deletions

View File

@ -37,7 +37,7 @@ class DADF5():
self.version_major = f.attrs['DADF5-major']
self.version_minor = f.attrs['DADF5-minor']
if self.version_major != 0 or not 2 <= self.version_minor <= 4:
if self.version_major != 0 or not 2 <= self.version_minor <= 5:
raise TypeError('Unsupported DADF5 version {} '.format(f.attrs['DADF5-version']))
self.structured = 'grid' in f['geometry'].attrs.keys()
@ -45,6 +45,9 @@ class DADF5():
if self.structured:
self.grid = f['geometry'].attrs['grid']
self.size = f['geometry'].attrs['size']
if self.version_major == 0 and self.version_minor >= 5:
self.origin = f['geometry'].attrs['origin']
r=re.compile('inc[0-9]+')
increments_unsorted = {int(i[3:]):i for i in f.keys() if r.match(i)}
@ -830,7 +833,7 @@ class DADF5():
N_not_calculated = len(todo)
while N_not_calculated > 0:
result = results.get()
with h5py.File(self.fname,'a') as f: # write to file
with h5py.File(self.fname,'a') as f: # write to file
dataset_out = f[result['group']].create_dataset(result['label'],data=result['data'])
for k in result['meta'].keys():
dataset_out.attrs[k] = result['meta'][k].encode()

View File

@ -14,10 +14,10 @@ module CPFEM2
use material
use lattice
use IO
use HDF5
use DAMASK_interface
use results
use discretization
use HDF5
use HDF5_utilities
use homogenization
use constitutive

View File

@ -27,9 +27,8 @@ module mesh_grid
integer, public, protected :: &
grid3, & !< (local) grid in 3rd direction
grid3Offset !< (local) grid offset in 3rd direction
real(pReal), dimension(3), public, protected :: &
geomSize
geomSize !< (global) physical size
real(pReal), public, protected :: &
size3, & !< (local) size in 3rd direction
size3offset !< (local) size offset in 3rd direction
@ -49,7 +48,8 @@ subroutine mesh_init(ip,el)
include 'fftw3-mpi.f03'
real(pReal), dimension(3) :: &
mySize !< domain size of this process
mySize, & !< domain size of this process
origin !< (global) distance to origin
integer, dimension(3) :: &
myGrid !< domain grid of this process
@ -61,9 +61,9 @@ subroutine mesh_init(ip,el)
integer(C_INTPTR_T) :: &
devNull, z, z_offset
write(6,'(/,a)') ' <<<+- mesh_grid init -+>>>'
write(6,'(/,a)') ' <<<+- mesh_grid init -+>>>'; flush(6)
call readGeom(grid,geomSize,microstructureAt,homogenizationAt)
call readGeom(grid,geomSize,origin,microstructureAt,homogenizationAt)
!--------------------------------------------------------------------------------------------------
! grid solver specific quantities
@ -104,8 +104,9 @@ subroutine mesh_init(ip,el)
! store geometry information for post processing
call results_openJobFile
call results_closeGroup(results_addGroup('geometry'))
call results_addAttribute('grid',grid,'geometry')
call results_addAttribute('size',geomSize,'geometry')
call results_addAttribute('grid', grid, 'geometry')
call results_addAttribute('size', geomSize,'geometry')
call results_addAttribute('origin',origin, 'geometry')
call results_closeJobFile
!--------------------------------------------------------------------------------------------------
@ -129,10 +130,13 @@ end subroutine mesh_init
!> @details important variables have an implicit "save" attribute. Therefore, this function is
! supposed to be called only once!
!--------------------------------------------------------------------------------------------------
subroutine readGeom(grid,geomSize,microstructure,homogenization)
subroutine readGeom(grid,geomSize,origin,microstructure,homogenization)
integer, dimension(3), intent(out) :: grid ! grid (for all processes!)
real(pReal), dimension(3), intent(out) :: geomSize ! size (for all processes!)
integer, dimension(3), intent(out) :: &
grid ! grid (for all processes!)
real(pReal), dimension(3), intent(out) :: &
geomSize, & ! size (for all processes!)
origin ! origin (for all processes!)
integer, dimension(:), intent(out), allocatable :: &
microstructure, &
homogenization
@ -181,6 +185,7 @@ subroutine readGeom(grid,geomSize,microstructure,homogenization)
!--------------------------------------------------------------------------------------------------
! read and interprete header
origin = 0.0_pReal
l = 0
do while (l < headerLength .and. startPos < len(rawData))
endPos = startPos + index(rawData(startPos:),new_line('')) - 1
@ -221,8 +226,23 @@ subroutine readGeom(grid,geomSize,microstructure,homogenization)
enddo
endif
case ('origin')
if (chunkPos(1) > 6) then
do j = 2,6,2
select case (IO_lc(IO_stringValue(line,chunkPos,j)))
case('x')
origin(1) = IO_floatValue(line,chunkPos,j+1)
case('y')
origin(2) = IO_floatValue(line,chunkPos,j+1)
case('z')
origin(3) = IO_floatValue(line,chunkPos,j+1)
end select
enddo
endif
case ('homogenization')
if (chunkPos(1) > 1) h = IO_intValue(line,chunkPos,2)
end select
enddo

View File

@ -70,7 +70,7 @@ subroutine results_init
resultsFile = HDF5_openFile(trim(getSolverJobName())//'.hdf5','w',.true.)
call HDF5_addAttribute(resultsFile,'DADF5_version_major',0)
call HDF5_addAttribute(resultsFile,'DADF5_version_minor',4)
call HDF5_addAttribute(resultsFile,'DADF5_version_minor',5)
call HDF5_addAttribute(resultsFile,'DAMASK_version',DAMASKVERSION)
call get_command(commandLine)
call HDF5_addAttribute(resultsFile,'call',trim(commandLine))