DAMASK_EICMD/src/homogenization_damage.f90

195 lines
6.2 KiB
Fortran
Raw Normal View History

2021-01-21 01:24:31 +05:30
!--------------------------------------------------------------------------------------------------
!> @author Martin Diehl, KU Leuven
!--------------------------------------------------------------------------------------------------
2021-04-06 15:25:30 +05:30
submodule(homogenization) damage
2021-01-21 01:24:31 +05:30
2021-01-24 23:17:19 +05:30
use lattice
2021-04-06 15:25:30 +05:30
interface
module subroutine pass_init
end subroutine pass_init
end interface
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, &
2021-04-07 16:52:22 +05:30
configHomogenizationDamage, &
num_generic, &
material_homogenization
integer :: ho
2021-04-07 16:52:22 +05:30
integer :: Ninstances,Nmaterialpoints,h
2021-01-21 01:24:31 +05:30
2021-01-27 15:14:03 +05:30
print'(/,a)', ' <<<+- homogenization:damage init -+>>>'
2021-04-07 12:17:46 +05:30
print'(/,a)', ' <<<+- homogenization:damage:pass init -+>>>'
configHomogenizations => config_material%get('homogenization')
allocate(param(configHomogenizations%length))
allocate(current(configHomogenizations%length))
do ho = 1, configHomogenizations%length
2021-04-06 15:08:44 +05:30
allocate(current(ho)%phi(count(material_homogenizationID==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__)
2021-03-11 22:30:07 +05:30
prm%output = output_as1dString(configHomogenizationDamage)
#else
2021-03-11 22:30:07 +05:30
prm%output = configHomogenizationDamage%get_as1dString('output',defaultVal=emptyStringArray)
#endif
else
prm%output = emptyStringArray
endif
end associate
enddo
2021-01-21 01:24:31 +05:30
2021-04-07 16:52:22 +05:30
!------------------------------------------------------------------------------------
! read numerics parameter
num_generic => config_numerics%get('generic',defaultVal= emptyDict)
num_damage%charLength = num_generic%get_asFloat('charLength',defaultVal=1.0_pReal)
Ninstances = count(damage_type == DAMAGE_nonlocal_ID)
material_homogenization => config_material%get('homogenization')
do h = 1, material_homogenization%length
if (damage_type(h) /= DAMAGE_NONLOCAL_ID) cycle
Nmaterialpoints = count(material_homogenizationAt == h)
damageState_h(h)%sizeState = 1
allocate(damageState_h(h)%state0 (1,Nmaterialpoints), source=1.0_pReal)
allocate(damageState_h(h)%state (1,Nmaterialpoints), source=1.0_pReal)
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
2021-04-06 15:08:44 +05:30
if(damageState_h(material_homogenizationID(ce))%sizeState < 1) return
phi = damagestate_h(material_homogenizationID(ce))%state(1,material_homogenizationEntry(ce))
2021-04-08 17:01:21 +05:30
call phase_set_phi(phi,1,ce)
2021-01-21 01:24:31 +05:30
end subroutine damage_partition
2021-01-24 23:17:19 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief Returns homogenized nonlocal damage mobility
!--------------------------------------------------------------------------------------------------
2021-04-09 03:10:20 +05:30
module function homogenization_mu_phi(ce) result(mu)
2021-01-24 23:17:19 +05:30
integer, intent(in) :: ce
2021-04-09 03:10:20 +05:30
real(pReal) :: mu
2021-01-24 23:17:19 +05:30
2021-04-11 11:05:43 +05:30
mu = lattice_mu_phi(material_phaseID(1,ce))
2021-01-24 23:17:19 +05:30
2021-04-08 17:01:21 +05:30
end function homogenization_mu_phi
2021-01-24 23:17:19 +05:30
2021-01-25 03:14:47 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief calculates homogenized damage driving forces
!--------------------------------------------------------------------------------------------------
2021-04-09 03:10:20 +05:30
module function homogenization_f_phi(phi,ce) result(f)
2021-01-25 03:14:47 +05:30
integer, intent(in) :: ce
2021-04-07 12:17:46 +05:30
real(pReal), intent(in) :: &
2021-01-25 03:14:47 +05:30
phi
2021-04-09 03:10:20 +05:30
real(pReal) :: f
2021-01-25 03:14:47 +05:30
2021-04-09 03:10:20 +05:30
f = phase_f_phi(phi, 1, ce)
2021-01-25 03:14:47 +05:30
2021-04-08 17:01:21 +05:30
end function homogenization_f_phi
2021-01-25 03:14:47 +05:30
2021-01-25 19:43:17 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief updated nonlocal damage field with solution from damage phase field PDE
!--------------------------------------------------------------------------------------------------
2021-04-08 00:36:29 +05:30
module subroutine homogenization_set_phi(phi,ce)
2021-01-25 19:43:17 +05:30
integer, intent(in) :: ce
2021-01-25 19:43:17 +05:30
real(pReal), intent(in) :: &
phi
integer :: &
ho, &
2021-04-06 15:08:44 +05:30
en
2021-01-25 19:43:17 +05:30
2021-04-06 15:08:44 +05:30
ho = material_homogenizationID(ce)
en = material_homogenizationEntry(ce)
damagestate_h(ho)%state(1,en) = phi
2021-04-07 18:26:11 +05:30
current(ho)%phi(en) = phi
2021-01-25 19:43:17 +05:30
2021-04-08 00:36:29 +05:30
end subroutine homogenization_set_phi
2021-01-25 19:43:17 +05:30
2021-04-11 11:18:54 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief returns homogenized non local damage diffusion tensor in reference configuration
!--------------------------------------------------------------------------------------------------
module function homogenization_K_phi(ce) result(K)
integer, intent(in) :: ce
real(pReal), dimension(3,3) :: K
K = crystallite_push33ToRef(1,ce,lattice_K_phi(1:3,1:3,material_phaseID(1,ce))) \
* num_damage%charLength**2
end function homogenization_K_phi
2021-01-25 19:43:17 +05:30
!--------------------------------------------------------------------------------------------------
!> @brief writes results to HDF5 output file
!--------------------------------------------------------------------------------------------------
2021-04-07 10:56:54 +05:30
module subroutine damage_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
2021-04-07 10:56:54 +05:30
end subroutine damage_results
2021-01-25 19:43:17 +05:30
2021-04-06 15:25:30 +05:30
end submodule damage