Skip to content

Commit 0abe763

Browse files
committed
Merge branch '382-missing-damage-type-error' into 'development'
better consistency checks for thermal and damage Closes #382 See merge request damask/DAMASK!1017
2 parents 8c09d93 + a4c661b commit 0abe763

5 files changed

+52
-26
lines changed

src/IO.f90

+1-3
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,7 @@ subroutine IO_error(error_ID,ext_msg,label1,ID1,label2,ID2)
373373
!--------------------------------------------------------------------------------------------------
374374
! plasticity error messages
375375
case (200)
376-
msg = 'unknown elasticity specified:'
377-
case (201)
378-
msg = 'unknown plasticity specified:'
376+
msg = 'unknown type specified:'
379377

380378
case (211)
381379
msg = 'material parameter out of bounds:'

src/phase_damage.f90

+36-15
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ module subroutine damage_init()
7272
type(tDict), pointer :: &
7373
phases, &
7474
phase, &
75-
source
76-
character(len=:), allocatable :: refs
75+
damage
76+
character(len=:), allocatable :: &
77+
refs, &
78+
extmsg
7779
logical:: damage_active
7880

7981

@@ -85,40 +87,59 @@ module subroutine damage_init()
8587
allocate(damageState(phases%length))
8688
allocate(param(phases%length))
8789

90+
extmsg = ''
8891
damage_active = .false.
8992
do ph = 1,phases%length
9093

9194
Nmembers = count(material_ID_phase == ph)
92-
9395
allocate(current(ph)%phi(Nmembers),source=1.0_pREAL)
9496

9597
phase => phases%get_dict(ph)
96-
source => phase%get_dict('damage',defaultVal=emptyDict)
97-
if (source%length > 0) then
98+
if (damage_active) then
99+
damage => phase%get_dict('damage')
100+
else
101+
damage => phase%get_dict('damage',defaultVal=emptyDict)
102+
end if
103+
104+
if (damage%length > 0) then
105+
damage_active = .true.
106+
98107
print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph)
99-
refs = config_listReferences(source,indent=3)
108+
refs = config_listReferences(damage,indent=3)
100109
if (len(refs) > 0) print'(/,1x,a)', refs
101-
damage_active = .true.
102-
param(ph)%mu = source%get_asReal('mu')
103-
param(ph)%l_c = source%get_asReal('l_c')
110+
111+
param(ph)%mu = damage%get_asReal('mu')
112+
param(ph)%l_c = damage%get_asReal('l_c')
113+
114+
! sanity checks
115+
if (param(ph)%mu < 0.0_pREAL) extmsg = trim(extmsg)//' mu'
116+
if (param(ph)%l_c < 0.0_pREAL) extmsg = trim(extmsg)//' l_c'
117+
if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg))
118+
104119
end if
105120

106121
end do
107122

108123
allocate(damage_type(phases%length), source = UNDEFINED)
109124

125+
where(isobrittle_init() ) damage_type = DAMAGE_ISOBRITTLE
126+
where(anisobrittle_init()) damage_type = DAMAGE_ANISOBRITTLE
127+
phase_damage_maxSizeDotState = maxval(damageState%sizeDotState)
128+
110129
if (damage_active) then
111-
where(isobrittle_init() ) damage_type = DAMAGE_ISOBRITTLE
112-
where(anisobrittle_init()) damage_type = DAMAGE_ANISOBRITTLE
130+
do ph = 1,phases%length
131+
phase => phases%get_dict(ph)
132+
damage => phase%get_dict('damage')
133+
if (any(damage%keys() == 'type') .and. damage_type(ph) == UNDEFINED) &
134+
call IO_error(200,label1='damage',ext_msg=damage%get_asStr('type'))
135+
end do
113136
end if
114137

115-
phase_damage_maxSizeDotState = maxval(damageState%sizeDotState)
116-
117138
end subroutine damage_init
118139

119140

120141
!--------------------------------------------------------------------------------------------------
121-
!> @brief calculate stress (P)
142+
!> @brief t.b.d.
122143
!--------------------------------------------------------------------------------------------------
123144
module function phase_damage_constitutive(Delta_t,co,ce) result(status)
124145

@@ -141,7 +162,7 @@ end function phase_damage_constitutive
141162

142163

143164
!--------------------------------------------------------------------------------------------------
144-
!> @brief returns the degraded/modified elasticity matrix
165+
!> @brief Return the degraded/modified elasticity matrix.
145166
!--------------------------------------------------------------------------------------------------
146167
module function phase_damage_C66(C66,ph,en) result(C66_degraded)
147168

src/phase_mechanical_elastic.f90

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ module subroutine elastic_init(phases)
4646
print'(/,1x,a,1x,i0,a)', 'phase',ph,': '//phases%key(ph)
4747
refs = config_listReferences(elastic,indent=3)
4848
if (len(refs) > 0) print'(/,1x,a)', refs
49-
if (elastic%get_asStr('type') /= 'Hooke') call IO_error(200,ext_msg=elastic%get_asStr('type'))
49+
if (elastic%get_asStr('type') /= 'Hooke') &
50+
call IO_error(200,label1='elasticity',ext_msg=elastic%get_asStr('type'))
5051

5152
associate(prm => param(ph))
5253

src/phase_mechanical_plastic.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ module subroutine plastic_init
226226
where(plastic_dislotungsten_init()) mechanical_plasticity_type = MECHANICAL_PLASTICITY_DISLOTUNGSTEN
227227
where(plastic_nonlocal_init()) mechanical_plasticity_type = MECHANICAL_PLASTICITY_NONLOCAL
228228

229-
if (any(mechanical_plasticity_type == UNDEFINED)) call IO_error(201)
229+
if (any(mechanical_plasticity_type == UNDEFINED)) call IO_error(200, label1='plasticity')
230230

231231
end subroutine plastic_init
232232

src/phase_thermal.f90

+12-6
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,37 @@ module subroutine thermal_init(phases)
8282
integer :: &
8383
ph, so, &
8484
Nmembers
85-
85+
logical :: thermal_active
8686

8787
print'(/,1x,a)', '<<<+- phase:thermal init -+>>>'
8888

8989
allocate(current(phases%length))
9090
allocate(thermalState(phases%length))
9191
allocate(thermal_Nsources(phases%length),source = 0)
9292
allocate(param(phases%length))
93-
extmsg = ''
9493

94+
extmsg = ''
95+
thermal_active = .false.
9596
do ph = 1, phases%length
9697
Nmembers = count(material_ID_phase == ph)
9798
allocate(current(ph)%T(Nmembers),source=T_ROOM)
9899
allocate(current(ph)%dot_T(Nmembers),source=0.0_pREAL)
100+
99101
phase => phases%get_dict(ph)
100-
thermal => phase%get_dict('thermal',defaultVal=emptyDict)
102+
if (thermal_active) then
103+
thermal => phase%get_dict('thermal')
104+
else
105+
thermal => phase%get_dict('thermal',defaultVal=emptyDict)
106+
end if
101107

102108
! ToDo: temperature dependency of K and C_p
103109
if (thermal%length > 0) then
110+
thermal_active = .true.
111+
104112
print'(/,1x,a,i0,a)', 'phase ',ph,': '//phases%key(ph)
105113
refs = config_listReferences(thermal,indent=3)
106114
if (len(refs) > 0) print'(/,1x,a)', refs
115+
107116
param(ph)%C_p = thermal%get_asReal('C_p')
108117
param(ph)%K(1,1) = thermal%get_asReal('K_11')
109118
if (any(phase_lattice(ph) == ['hP','tI'])) param(ph)%K(3,3) = thermal%get_asReal('K_33')
@@ -113,9 +122,6 @@ module subroutine thermal_init(phases)
113122
if ( param(ph)%C_p <= 0.0_pREAL ) extmsg = trim(extmsg)//' C_p'
114123
if (any(param(ph)%K < 0.0_pREAL)) extmsg = trim(extmsg)//' K'
115124
if ( phase_rho(ph) <= 0.0_pREAL ) extmsg = trim(extmsg)//' rho'
116-
117-
!--------------------------------------------------------------------------------------------------
118-
! exit if any parameter is out of range
119125
if (extmsg /= '') call IO_error(211,ext_msg=trim(extmsg))
120126

121127
#if defined(__GFORTRAN__)

0 commit comments

Comments
 (0)