diff --git a/code/IO.f90 b/code/IO.f90 index 815678786..ac4491a95 100644 --- a/code/IO.f90 +++ b/code/IO.f90 @@ -83,6 +83,7 @@ module IO #ifdef HDF public:: HDF5_mappingConstitutive, & HDF5_mappingHomogenization, & + HDF5_mappingCells, & HDF5_closeJobFile #endif contains @@ -2274,5 +2275,88 @@ subroutine HDF5_mappingHomogenization(mapping) end subroutine HDF5_mappingHomogenization +!-------------------------------------------------------------------------------------------------- +!> @brief adds the unique cell to node mapping +!-------------------------------------------------------------------------------------------------- +subroutine HDF5_mappingCells(mapping) + use hdf5 + + implicit none + integer(pInt), intent(in), dimension(:) :: mapping + + integer :: hdf5err, Nnodes + integer(HID_T) :: mapping_id, dset_id, space_id + + Nnodes=size(mapping,1) + mapping_ID = HDF5_openGroup("mapping") + +!-------------------------------------------------------------------------------------------------- +! create dataspace + call h5screate_simple_f(1, int([Nnodes],HSIZE_T), space_id, hdf5err, & + int([Nnodes],HSIZE_T)) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingCells') + +!-------------------------------------------------------------------------------------------------- +! create Dataset + call h5dcreate_f(mapping_id, "Cell",H5T_NATIVE_INTEGER, space_id, dset_id, hdf5err) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingCells') + +!-------------------------------------------------------------------------------------------------- +! write data by fields in the datatype. Fields order is not important. + call h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, mapping, int([Nnodes],HSIZE_T), hdf5err) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingCells: h5dwrite_f instance_id') + +!-------------------------------------------------------------------------------------------------- +!close types, dataspaces + call h5dclose_f(dset_id, hdf5err) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingConstitutive: h5dclose_f') + call h5sclose_f(space_id, hdf5err) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingConstitutive: h5sclose_f') + call HDF5_closeGroup(mapping_ID) + +end subroutine HDF5_mappingCells + +!-------------------------------------------------------------------------------------------------- +!> @brief adds the unique cell to node mapping +!-------------------------------------------------------------------------------------------------- +subroutine HDF5_mappingCells(mapping) + use hdf5 + + implicit none + integer(pInt), intent(in), dimension(:) :: mapping + + integer :: hdf5err, Nnodes + integer(HID_T) :: mapping_id, dset_id, space_id + + Nnodes=size(mapping,1) + mapping_ID = HDF5_openGroup("mapping") + +!-------------------------------------------------------------------------------------------------- +! create dataspace + call h5screate_simple_f(1, int([Nnodes],HSIZE_T), space_id, hdf5err, & + int([Nnodes],HSIZE_T)) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingCells') + +!-------------------------------------------------------------------------------------------------- +! create Dataset + call h5dcreate_f(mapping_id, "Cell",H5T_NATIVE_INTEGER, space_id, dset_id, hdf5err) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingCells') + +!-------------------------------------------------------------------------------------------------- +! write data by fields in the datatype. Fields order is not important. + call h5dwrite_f(dset_id, H5T_NATIVE_INTEGER, mapping, int([Nnodes],HSIZE_T), hdf5err) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingCells: h5dwrite_f instance_id') + +!-------------------------------------------------------------------------------------------------- +!close types, dataspaces + call h5dclose_f(dset_id, hdf5err) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingConstitutive: h5dclose_f') + call h5sclose_f(space_id, hdf5err) + if (hdf5err < 0) call IO_error(1_pInt,ext_msg='IO_mappingConstitutive: h5sclose_f') + call HDF5_closeGroup(mapping_ID) + +end subroutine HDF5_mappingCells + + #endif end module IO diff --git a/code/constitutive.f90 b/code/constitutive.f90 index c650dcbce..fccc93315 100644 --- a/code/constitutive.f90 +++ b/code/constitutive.f90 @@ -135,9 +135,7 @@ subroutine constitutive_init character(len=64), dimension(:,:), pointer :: thisOutput character(len=32) :: outputName !< name of output, intermediate fix until HDF5 output is ready logical :: knownPlasticity, nonlocalConstitutionPresent -#ifdef HDF - integer(pInt) :: & - phase !< phase +#ifdef HDF !< phase integer(pInt), dimension(:,:,:), allocatable :: mappingConstitutive integer(pInt), dimension(:,:,:), allocatable :: mappingCrystallite integer(pInt), dimension(:), allocatable :: ConstitutivePosition diff --git a/code/mesh.f90 b/code/mesh.f90 index 85fb894e6..53fbc0c79 100644 --- a/code/mesh.f90 +++ b/code/mesh.f90 @@ -5076,6 +5076,9 @@ end subroutine mesh_build_FEdata !> @brief writes out initial cell geometry !-------------------------------------------------------------------------------------------------- subroutine mesh_write_cellGeom + + + use DAMASK_interface, only: & getSolverJobName, & getSolverWorkingDirectoryName @@ -5086,7 +5089,10 @@ subroutine mesh_write_cellGeom VTK_geo, & VTK_con, & VTK_end - +#ifdef HDF + use IO, only: & + HDF5_mappingCells + #endif implicit none integer(I4P), dimension(1:mesh_Ncells) :: celltype integer(I4P), dimension(mesh_Ncells*(1_pInt+FE_maxNcellnodesPerCell)) :: cellconnection @@ -5106,7 +5112,9 @@ subroutine mesh_write_cellGeom j = j + FE_NcellnodesPerCell(c) + 1_pInt enddo enddo - +#ifdef HDF + call HDF5_mappingCells(cellconnection(1:j)) +#endif error=VTK_ini(output_format = 'ASCII', & title=trim(getSolverJobName())//' cell mesh', & filename = trim(getSolverWorkingDirectoryName())//trim(getSolverJobName())//'_ipbased.vtk', &