DAMASK_EICMD/src/homogenization_damage.f90

175 lines
6.3 KiB
Fortran
Raw Normal View History

2021-01-21 01:24:31 +05:30
!--------------------------------------------------------------------------------------------------
!> @author Martin Diehl, KU Leuven
!--------------------------------------------------------------------------------------------------
submodule(homogenization) homogenization_damage
2021-01-24 23:17:19 +05:30
use lattice
type :: tDataContainer
real(pReal), dimension(:), allocatable :: phi
end type tDataContainer
type(tDataContainer), dimension(:), allocatable :: current
type :: tParameters
character(len=pStringLen), allocatable, dimension(:) :: &
output
end type tParameters
type(tparameters), dimension(:), allocatable :: &
param
2021-01-21 01:24:31 +05:30
contains
2021-01-21 01:24:31 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief Allocate variables and set parameters.
!--------------------------------------------------------------------------------------------------
module subroutine damage_init()
class(tNode), pointer :: &
configHomogenizations, &
configHomogenization, &
configHomogenizationDamage
integer :: ho
2021-01-21 01:24:31 +05:30
2021-01-27 15:14:03 +05:30
print'(/,a)', ' <<<+- homogenization:damage init -+>>>'
print'(/,a)', ' <<<+- homogenization:damage:isodamage init -+>>>'
configHomogenizations => config_material%get('homogenization')
allocate(param(configHomogenizations%length))
allocate(current(configHomogenizations%length))
do ho = 1, configHomogenizations%length
allocate(current(ho)%phi(count(material_homogenizationAt2==ho)), source=1.0_pReal)
configHomogenization => configHomogenizations%get(ho)
associate(prm => param(ho))
if (configHomogenization%contains('damage')) then
configHomogenizationDamage => configHomogenization%get('damage')
#if defined (__GFORTRAN__)
prm%output = output_asStrings(configHomogenizationDamage)
#else
prm%output = configHomogenizationDamage%get_asStrings('output',defaultVal=emptyStringArray)
#endif
else
prm%output = emptyStringArray
endif
end associate
enddo
2021-01-21 01:24:31 +05:30
end subroutine damage_init
!--------------------------------------------------------------------------------------------------
!> @brief Partition temperature onto the individual constituents.
!--------------------------------------------------------------------------------------------------
module subroutine damage_partition(ce)
2021-01-21 01:24:31 +05:30
real(pReal) :: phi
2021-01-21 01:24:31 +05:30
integer, intent(in) :: ce
integer :: co
2021-02-12 14:01:02 +05:30
if(damageState_h(material_homogenizationAt2(ce))%sizeState < 1) return
phi = damagestate_h(material_homogenizationAt2(ce))%state(1,material_homogenizationMemberAt2(ce))
2021-01-21 01:24:31 +05:30
do co = 1, homogenization_Nconstituents(material_homogenizationAt2(ce))
2021-02-09 03:51:53 +05:30
call phase_damage_set_phi(phi,co,ce)
2021-01-21 01:24:31 +05:30
enddo
end subroutine damage_partition
2021-01-24 23:17:19 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief Returns homogenized nonlocal damage mobility
!--------------------------------------------------------------------------------------------------
module function damage_nonlocal_getMobility(ip,el) result(M)
integer, intent(in) :: &
ip, & !< integration point number
el !< element number
integer :: &
co
real(pReal) :: M
M = 0.0_pReal
do co = 1, homogenization_Nconstituents(material_homogenizationAt(el))
M = M + lattice_M(material_phaseAt(co,el))
enddo
M = M/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal)
end function damage_nonlocal_getMobility
2021-01-25 03:14:47 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief calculates homogenized damage driving forces
!--------------------------------------------------------------------------------------------------
module subroutine damage_nonlocal_getSourceAndItsTangent(phiDot, dPhiDot_dPhi, phi, ip, el)
integer, intent(in) :: &
ip, & !< integration point number
el !< element number
real(pReal), intent(in) :: &
phi
real(pReal) :: &
phiDot, dPhiDot_dPhi
phiDot = 0.0_pReal
dPhiDot_dPhi = 0.0_pReal
2021-02-09 03:51:53 +05:30
call phase_damage_getRateAndItsTangents(phiDot, dPhiDot_dPhi, phi, ip, el)
2021-01-25 03:14:47 +05:30
phiDot = phiDot/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal)
dPhiDot_dPhi = dPhiDot_dPhi/real(homogenization_Nconstituents(material_homogenizationAt(el)),pReal)
end subroutine damage_nonlocal_getSourceAndItsTangent
2021-01-25 19:43:17 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief updated nonlocal damage field with solution from damage phase field PDE
!--------------------------------------------------------------------------------------------------
module subroutine damage_nonlocal_putNonLocalDamage(phi,ip,el)
integer, intent(in) :: &
ip, & !< integration point number
el !< element number
real(pReal), intent(in) :: &
phi
integer :: &
homog, &
offset
homog = material_homogenizationAt(el)
offset = material_homogenizationMemberAt(ip,el)
2021-02-12 04:42:57 +05:30
damagestate_h(homog)%state(1,offset) = phi
2021-01-25 19:43:17 +05:30
end subroutine damage_nonlocal_putNonLocalDamage
!--------------------------------------------------------------------------------------------------
!> @brief writes results to HDF5 output file
!--------------------------------------------------------------------------------------------------
module subroutine damage_nonlocal_results(ho,group)
2021-01-25 19:43:17 +05:30
integer, intent(in) :: ho
2021-01-25 19:43:17 +05:30
character(len=*), intent(in) :: group
integer :: o
associate(prm => param(ho))
2021-01-25 19:43:17 +05:30
outputsLoop: do o = 1,size(prm%output)
select case(prm%output(o))
case ('phi')
call results_writeDataset(group,damagestate_h(ho)%state(1,:),prm%output(o),&
2021-01-25 19:43:17 +05:30
'damage indicator','-')
end select
enddo outputsLoop
end associate
end subroutine damage_nonlocal_results
2021-01-21 01:24:31 +05:30
end submodule homogenization_damage