avoid code duplication

This commit is contained in:
Martin Diehl 2021-08-07 22:02:44 +02:00
parent 68eb930bf0
commit cf66b81e3a
6 changed files with 94 additions and 134 deletions

View File

@ -407,20 +407,20 @@ module subroutine plastic_dislotungsten_results(ph,group)
select case(trim(prm%output(ou))) select case(trim(prm%output(ou)))
case('rho_mob') case('rho_mob')
call results_writePhaseState(stt%rho_mob,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%rho_mob,group,trim(prm%output(ou)), &
'mobile dislocation density','1/m²') 'mobile dislocation density','1/m²',prm%systems_sl)
case('rho_dip') case('rho_dip')
call results_writePhaseState(stt%rho_dip,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%rho_dip,group,trim(prm%output(ou)), &
'dislocation dipole density','1/m²') 'dislocation dipole density','1/m²',prm%systems_sl)
case('gamma_sl') case('gamma_sl')
call results_writePhaseState(stt%gamma_sl,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%gamma_sl,group,trim(prm%output(ou)), &
'plastic shear','1') 'plastic shear','1',prm%systems_sl)
case('Lambda_sl') case('Lambda_sl')
call results_writePhaseState(dst%Lambda_sl,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(dst%Lambda_sl,group,trim(prm%output(ou)), &
'mean free path for slip','m') 'mean free path for slip','m',prm%systems_sl)
case('tau_pass') case('tau_pass')
call results_writePhaseState(dst%tau_pass,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(dst%tau_pass,group,trim(prm%output(ou)), &
'threshold stress for slip','Pa') 'threshold stress for slip','Pa',prm%systems_sl)
end select end select
enddo enddo

View File

@ -802,30 +802,30 @@ module subroutine plastic_dislotwin_results(ph,group)
select case(trim(prm%output(ou))) select case(trim(prm%output(ou)))
case('rho_mob') case('rho_mob')
call results_writePhaseState(stt%rho_mob,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%rho_mob,group,trim(prm%output(ou)), &
'mobile dislocation density','1/m²') 'mobile dislocation density','1/m²',prm%systems_sl)
case('rho_dip') case('rho_dip')
call results_writePhaseState(stt%rho_dip,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%rho_dip,group,trim(prm%output(ou)), &
'dislocation dipole density','1/m²') 'dislocation dipole density','1/m²',prm%systems_sl)
case('gamma_sl') case('gamma_sl')
call results_writePhaseState(stt%gamma_sl,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%gamma_sl,group,trim(prm%output(ou)), &
'plastic shear','1') 'plastic shear','1',prm%systems_sl)
case('Lambda_sl') case('Lambda_sl')
call results_writePhaseState(dst%Lambda_sl,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(dst%Lambda_sl,group,trim(prm%output(ou)), &
'mean free path for slip','m') 'mean free path for slip','m',prm%systems_sl)
case('tau_pass') case('tau_pass')
call results_writePhaseState(dst%tau_pass,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(dst%tau_pass,group,trim(prm%output(ou)), &
'passing stress for slip','Pa') 'passing stress for slip','Pa',prm%systems_sl)
case('f_tw') case('f_tw')
call results_writePhaseState(stt%f_tw,group,trim(prm%output(ou)),prm%systems_tw, & call results_writeDataset(stt%f_tw,group,trim(prm%output(ou)), &
'twinned volume fraction','m³/m³') 'twinned volume fraction','m³/m³',prm%systems_tw)
case('Lambda_tw') case('Lambda_tw')
call results_writePhaseState(dst%Lambda_tw,group,trim(prm%output(ou)),prm%systems_tw, & call results_writeDataset(dst%Lambda_tw,group,trim(prm%output(ou)), &
'mean free path for twinning','m') 'mean free path for twinning','m',prm%systems_tw)
case('tau_hat_tw') case('tau_hat_tw')
call results_writePhaseState(dst%tau_hat_tw,group,trim(prm%output(ou)),prm%systems_tw, & call results_writeDataset(dst%tau_hat_tw,group,trim(prm%output(ou)), &
'threshold stress for twinning','Pa') 'threshold stress for twinning','Pa',prm%systems_tw)
case('f_tr') case('f_tr')
if(prm%sum_N_tr>0) call results_writeDataset(stt%f_tr,group,trim(prm%output(ou)), & if(prm%sum_N_tr>0) call results_writeDataset(stt%f_tr,group,trim(prm%output(ou)), &

View File

@ -363,23 +363,23 @@ module subroutine plastic_kinehardening_results(ph,group)
select case(trim(prm%output(ou))) select case(trim(prm%output(ou)))
case ('xi') case ('xi')
call results_writePhaseState(stt%xi,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%xi,group,trim(prm%output(ou)), &
'resistance against plastic slip','Pa') 'resistance against plastic slip','Pa',prm%systems_sl)
case ('chi') case ('chi')
call results_writePhaseState(stt%chi,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%chi,group,trim(prm%output(ou)), &
'back stress','Pa') 'back stress','Pa',prm%systems_sl)
case ('sgn(gamma)') case ('sgn(gamma)')
call results_writePhaseState(int(stt%sgn_gamma),group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(int(stt%sgn_gamma),group,trim(prm%output(ou)), &
'sense of shear','1') 'sense of shear','1',prm%systems_sl)
case ('chi_0') case ('chi_0')
call results_writePhaseState(stt%chi_0,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%chi_0,group,trim(prm%output(ou)), &
'back stress at last switch of stress sense','Pa') 'back stress at last switch of stress sense','Pa',prm%systems_sl)
case ('gamma_0') case ('gamma_0')
call results_writePhaseState(stt%gamma_0,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%gamma_0,group,trim(prm%output(ou)), &
'plastic shear at last switch of stress sense','1') 'plastic shear at last switch of stress sense','1',prm%systems_sl)
case ('gamma') case ('gamma')
call results_writePhaseState(stt%gamma,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%gamma,group,trim(prm%output(ou)), &
'plastic shear','1') 'plastic shear','1',prm%systems_sl)
end select end select
enddo enddo

View File

@ -1477,56 +1477,56 @@ module subroutine plastic_nonlocal_results(ph,group)
select case(trim(prm%output(ou))) select case(trim(prm%output(ou)))
case('rho_u_ed_pos') case('rho_u_ed_pos')
call results_writePhaseState(stt%rho_sgl_mob_edg_pos,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_sgl_mob_edg_pos,group,trim(prm%output(ou)), &
'positive mobile edge density','1/m²') 'positive mobile edge density','1/m²', prm%systems_sl)
case('rho_b_ed_pos') case('rho_b_ed_pos')
call results_writePhaseState(stt%rho_sgl_imm_edg_pos,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_sgl_imm_edg_pos,group,trim(prm%output(ou)), &
'positive immobile edge density','1/m²') 'positive immobile edge density','1/m²', prm%systems_sl)
case('rho_u_ed_neg') case('rho_u_ed_neg')
call results_writePhaseState(stt%rho_sgl_mob_edg_neg,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_sgl_mob_edg_neg,group,trim(prm%output(ou)), &
'negative mobile edge density','1/m²') 'negative mobile edge density','1/m²', prm%systems_sl)
case('rho_b_ed_neg') case('rho_b_ed_neg')
call results_writePhaseState(stt%rho_sgl_imm_edg_neg,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_sgl_imm_edg_neg,group,trim(prm%output(ou)), &
'negative immobile edge density','1/m²') 'negative immobile edge density','1/m²', prm%systems_sl)
case('rho_d_ed') case('rho_d_ed')
call results_writePhaseState(stt%rho_dip_edg,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_dip_edg,group,trim(prm%output(ou)), &
'edge dipole density','1/m²') 'edge dipole density','1/m²', prm%systems_sl)
case('rho_u_sc_pos') case('rho_u_sc_pos')
call results_writePhaseState(stt%rho_sgl_mob_scr_pos,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_sgl_mob_scr_pos,group,trim(prm%output(ou)), &
'positive mobile screw density','1/m²') 'positive mobile screw density','1/m²', prm%systems_sl)
case('rho_b_sc_pos') case('rho_b_sc_pos')
call results_writePhaseState(stt%rho_sgl_imm_scr_pos,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_sgl_imm_scr_pos,group,trim(prm%output(ou)), &
'positive immobile screw density','1/m²') 'positive immobile screw density','1/m²', prm%systems_sl)
case('rho_u_sc_neg') case('rho_u_sc_neg')
call results_writePhaseState(stt%rho_sgl_mob_scr_neg,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_sgl_mob_scr_neg,group,trim(prm%output(ou)), &
'negative mobile screw density','1/m²') 'negative mobile screw density','1/m²', prm%systems_sl)
case('rho_b_sc_neg') case('rho_b_sc_neg')
call results_writePhaseState(stt%rho_sgl_imm_scr_neg,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_sgl_imm_scr_neg,group,trim(prm%output(ou)), &
'negative immobile screw density','1/m²') 'negative immobile screw density','1/m²', prm%systems_sl)
case('rho_d_sc') case('rho_d_sc')
call results_writePhaseState(stt%rho_dip_scr,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_dip_scr,group,trim(prm%output(ou)), &
'screw dipole density','1/m²') 'screw dipole density','1/m²', prm%systems_sl)
case('rho_f') case('rho_f')
call results_writePhaseState(stt%rho_forest,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%rho_forest,group,trim(prm%output(ou)), &
'forest density','1/m²') 'forest density','1/m²', prm%systems_sl)
case('v_ed_pos') case('v_ed_pos')
call results_writePhaseState(stt%v_edg_pos,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%v_edg_pos,group,trim(prm%output(ou)), &
'positive edge velocity','m/s') 'positive edge velocity','m/s', prm%systems_sl)
case('v_ed_neg') case('v_ed_neg')
call results_writePhaseState(stt%v_edg_neg,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%v_edg_neg,group,trim(prm%output(ou)), &
'negative edge velocity','m/s') 'negative edge velocity','m/s', prm%systems_sl)
case('v_sc_pos') case('v_sc_pos')
call results_writePhaseState(stt%v_scr_pos,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%v_scr_pos,group,trim(prm%output(ou)), &
'positive srew velocity','m/s') 'positive srew velocity','m/s', prm%systems_sl)
case('v_sc_neg') case('v_sc_neg')
call results_writePhaseState(stt%v_scr_neg,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%v_scr_neg,group,trim(prm%output(ou)), &
'negative screw velocity','m/s') 'negative screw velocity','m/s', prm%systems_sl)
case('gamma') case('gamma')
call results_writePhaseState(stt%gamma,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(stt%gamma,group,trim(prm%output(ou)), &
'plastic shear','1') 'plastic shear','1', prm%systems_sl)
case('tau_pass') case('tau_pass')
call results_writePhaseState(dst%tau_pass,group,trim(prm%output(ou)), prm%systems_sl, & call results_writeDataset(dst%tau_pass,group,trim(prm%output(ou)), &
'passing stress for slip','Pa') 'passing stress for slip','Pa', prm%systems_sl)
end select end select
enddo enddo

View File

@ -382,18 +382,18 @@ module subroutine plastic_phenopowerlaw_results(ph,group)
select case(trim(prm%output(ou))) select case(trim(prm%output(ou)))
case('xi_sl') case('xi_sl')
call results_writePhaseState(stt%xi_sl,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%xi_sl,group,trim(prm%output(ou)), &
'resistance against plastic slip','Pa') 'resistance against plastic slip','Pa',prm%systems_sl)
case('gamma_sl') case('gamma_sl')
call results_writePhaseState(stt%gamma_sl,group,trim(prm%output(ou)),prm%systems_sl, & call results_writeDataset(stt%gamma_sl,group,trim(prm%output(ou)), &
'plastic shear','1') 'plastic shear','1',prm%systems_sl)
case('xi_tw') case('xi_tw')
call results_writePhaseState(stt%xi_tw,group,trim(prm%output(ou)),prm%systems_tw, & call results_writeDataset(stt%xi_tw,group,trim(prm%output(ou)), &
'resistance against twinning','Pa') 'resistance against twinning','Pa',prm%systems_tw)
case('gamma_tw') case('gamma_tw')
call results_writePhaseState(stt%gamma_tw,group,trim(prm%output(ou)),prm%systems_tw, & call results_writeDataset(stt%gamma_tw,group,trim(prm%output(ou)), &
'twinning shear','1') 'twinning shear','1',prm%systems_tw)
end select end select

View File

@ -33,11 +33,6 @@ module results
module procedure results_writeVectorDataset_int module procedure results_writeVectorDataset_int
end interface results_writeDataset end interface results_writeDataset
interface results_writePhaseState
module procedure results_writePhaseState_real
module procedure results_writePhaseState_int
end interface results_writePhaseState
interface results_addAttribute interface results_addAttribute
module procedure results_addAttribute_str module procedure results_addAttribute_str
module procedure results_addAttribute_int module procedure results_addAttribute_int
@ -59,7 +54,6 @@ module results
results_closeGroup, & results_closeGroup, &
results_writeDataset, & results_writeDataset, &
results_writeDataset_str, & results_writeDataset_str, &
results_writePhaseState, &
results_setLink, & results_setLink, &
results_addAttribute, & results_addAttribute, &
results_removeLink, & results_removeLink, &
@ -385,69 +379,29 @@ end subroutine results_writeScalarDataset_real
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Store real vector dataset with associated metadata. !> @brief Store real vector dataset with associated metadata.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine results_writeVectorDataset_real(dataset,group,label,description,SIunit) subroutine results_writeVectorDataset_real(dataset,group,label,description,SIunit,systems)
character(len=*), intent(in) :: label,group,description character(len=*), intent(in) :: label,group,description
character(len=*), intent(in), optional :: SIunit character(len=*), intent(in), optional :: SIunit
character(len=*), intent(in), dimension(:), optional :: systems
real(pReal), intent(in), dimension(:,:) :: dataset real(pReal), intent(in), dimension(:,:) :: dataset
integer(HID_T) :: groupHandle integer(HID_T) :: groupHandle
if (present(systems)) then
if (size(systems)*size(dataset,2) == 0 ) return !ToDo: maybe also implement for other results_write (not sure about scalar)
endif
groupHandle = results_openGroup(group) groupHandle = results_openGroup(group)
call HDF5_write(dataset,groupHandle,label) call HDF5_write(dataset,groupHandle,label)
call executionStamp(group//'/'//label,description,SIunit) call executionStamp(group//'/'//label,description,SIunit)
if (present(systems)) call HDF5_addAttribute(resultsFile,'systems',systems,group//'/'//label)
call HDF5_closeGroup(groupHandle) call HDF5_closeGroup(groupHandle)
end subroutine results_writeVectorDataset_real end subroutine results_writeVectorDataset_real
!--------------------------------------------------------------------------------------------------
!> @brief Store real vector dataset with associated metadata for slip
!--------------------------------------------------------------------------------------------------
subroutine results_writePhaseState_real(dataset,group,label,systems,description,SIunit)
character(len=*), intent(in) :: label,group,description,SIunit
real(pReal), intent(in), dimension(:,:) :: dataset
character(len=*), intent(in), dimension(:) :: systems
integer(HID_T) :: groupHandle
if (size(systems)*size(dataset,2) == 0 ) return !ToDo: maybe also implement for other results_write (not sure about scalar)
groupHandle = results_openGroup(group)
call HDF5_write(dataset,groupHandle,label)
call executionStamp(group//'/'//label,description,SIunit)
call HDF5_addAttribute(resultsFile,'systems',systems,group//'/'//label)
call HDF5_closeGroup(groupHandle)
end subroutine results_writePhaseState_real
!--------------------------------------------------------------------------------------------------
!> @brief Store real vector dataset with associated metadata for slip
!--------------------------------------------------------------------------------------------------
subroutine results_writePhaseState_int(dataset,group,label,systems,description,SIunit)
character(len=*), intent(in) :: label,group,description,SIunit
integer, intent(in), dimension(:,:) :: dataset
character(len=*), intent(in), dimension(:) :: systems
integer(HID_T) :: groupHandle
if (size(systems)*size(dataset,2) == 0 ) return !ToDo: maybe also implement for other results_write (not sure about scalar)
groupHandle = results_openGroup(group)
call HDF5_write(dataset,groupHandle,label)
call executionStamp(group//'/'//label,description,SIunit)
call HDF5_addAttribute(resultsFile,'systems',systems,group//'/'//label)
call HDF5_closeGroup(groupHandle)
end subroutine results_writePhaseState_int
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Store real tensor dataset with associated metadata. !> @brief Store real tensor dataset with associated metadata.
!> @details Data is transposed to compenstate transposed storage order. !> @details Data is transposed to compenstate transposed storage order.
@ -491,18 +445,24 @@ end subroutine results_writeTensorDataset_real
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Store integer vector dataset with associated metadata. !> @brief Store integer vector dataset with associated metadata.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine results_writeVectorDataset_int(dataset,group,label,description,SIunit) subroutine results_writeVectorDataset_int(dataset,group,label,description,SIunit,systems)
character(len=*), intent(in) :: label,group,description character(len=*), intent(in) :: label,group,description
character(len=*), intent(in), optional :: SIunit character(len=*), intent(in), optional :: SIunit
character(len=*), intent(in), dimension(:), optional :: systems
integer, intent(in), dimension(:,:) :: dataset integer, intent(in), dimension(:,:) :: dataset
integer(HID_T) :: groupHandle integer(HID_T) :: groupHandle
if (present(systems)) then
if (size(systems)*size(dataset,2) == 0 ) return !ToDo: maybe also implement for other results_write (not sure about scalar)
endif
groupHandle = results_openGroup(group) groupHandle = results_openGroup(group)
call HDF5_write(dataset,groupHandle,label) call HDF5_write(dataset,groupHandle,label)
call executionStamp(group//'/'//label,description,SIunit) call executionStamp(group//'/'//label,description,SIunit)
if (present(systems)) call HDF5_addAttribute(resultsFile,'systems',systems,group//'/'//label)
call HDF5_closeGroup(groupHandle) call HDF5_closeGroup(groupHandle)
end subroutine results_writeVectorDataset_int end subroutine results_writeVectorDataset_int