added ID (integer, enum) case switching for phenopowerlaw and isostrain

This commit is contained in:
Martin Diehl 2013-11-27 11:39:28 +00:00
parent 7b82f46f3b
commit 6c2ab1f1f8
2 changed files with 112 additions and 42 deletions

View File

@ -93,7 +93,21 @@ module constitutive_phenopowerlaw
constitutive_phenopowerlaw_hardeningMatrix_TwinSlip, & constitutive_phenopowerlaw_hardeningMatrix_TwinSlip, &
constitutive_phenopowerlaw_hardeningMatrix_TwinTwin, & constitutive_phenopowerlaw_hardeningMatrix_TwinTwin, &
constitutive_phenopowerlaw_Cslip_66 constitutive_phenopowerlaw_Cslip_66
enum, bind(c)
enumerator :: resistance_slip_ID, &
accumulatedshear_slip_ID, &
shearrate_slip_ID, &
resolvedstress_slip_ID, &
totalshear_ID, &
resistance_twin_ID, &
accumulatedshear_twin_ID, &
shearrate_twin_ID, &
resolvedstress_twin_ID, &
totalvolfrac_ID
end enum
integer(kind(resistance_slip_ID)), dimension(:,:), allocatable, private :: &
constitutive_phenopowerlaw_outputID !< ID of each post result output
public :: & public :: &
constitutive_phenopowerlaw_init, & constitutive_phenopowerlaw_init, &
constitutive_phenopowerlaw_stateInit, & constitutive_phenopowerlaw_stateInit, &
@ -171,6 +185,8 @@ subroutine constitutive_phenopowerlaw_init(myFile)
constitutive_phenopowerlaw_sizePostResult = 0_pInt constitutive_phenopowerlaw_sizePostResult = 0_pInt
allocate(constitutive_phenopowerlaw_output(maxval(phase_Noutput),maxNinstance)) allocate(constitutive_phenopowerlaw_output(maxval(phase_Noutput),maxNinstance))
constitutive_phenopowerlaw_output = '' constitutive_phenopowerlaw_output = ''
allocate(constitutive_phenopowerlaw_outputID(maxval(phase_Noutput),maxNinstance))
constitutive_phenopowerlaw_outputID = -1
allocate(constitutive_phenopowerlaw_Noutput(maxNinstance)) allocate(constitutive_phenopowerlaw_Noutput(maxNinstance))
constitutive_phenopowerlaw_Noutput = 0_pInt constitutive_phenopowerlaw_Noutput = 0_pInt
allocate(constitutive_phenopowerlaw_structureName(maxNinstance)) allocate(constitutive_phenopowerlaw_structureName(maxNinstance))
@ -264,6 +280,28 @@ subroutine constitutive_phenopowerlaw_init(myFile)
constitutive_phenopowerlaw_Noutput(i) = constitutive_phenopowerlaw_Noutput(i) + 1_pInt constitutive_phenopowerlaw_Noutput(i) = constitutive_phenopowerlaw_Noutput(i) + 1_pInt
constitutive_phenopowerlaw_output(constitutive_phenopowerlaw_Noutput(i),i) = & constitutive_phenopowerlaw_output(constitutive_phenopowerlaw_Noutput(i),i) = &
IO_lc(IO_stringValue(line,positions,2_pInt)) IO_lc(IO_stringValue(line,positions,2_pInt))
select case(IO_lc(IO_stringValue(line,positions,2_pInt)))
case ('resistance_slip')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = resistance_slip_ID
case ('accumulatedshear_slip')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = accumulatedshear_slip_ID
case ('shearrate_slip')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = shearrate_slip_ID
case ('resolvedstress_slip')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = resolvedstress_slip_ID
case ('totalshear')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = totalshear_ID
case ('resistance_twin')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = resistance_twin_ID
case ('accumulatedshear_twin')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = accumulatedshear_twin_ID
case ('shearrate_twin')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = shearrate_twin_ID
case ('resolvedstress_twin')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = resolvedstress_twin_ID
case ('totalvolfrac')
constitutive_phenopowerlaw_outputID(constitutive_phenopowerlaw_Noutput(i),i) = totalvolfrac_ID
end select
case ('lattice_structure') case ('lattice_structure')
constitutive_phenopowerlaw_structureName(i) = IO_lc(IO_stringValue(line,positions,2_pInt)) constitutive_phenopowerlaw_structureName(i) = IO_lc(IO_stringValue(line,positions,2_pInt))
configNchunks = lattice_configNchunks(constitutive_phenopowerlaw_structureName(i)) configNchunks = lattice_configNchunks(constitutive_phenopowerlaw_structureName(i))
@ -476,21 +514,21 @@ subroutine constitutive_phenopowerlaw_init(myFile)
instancesLoop: do i = 1_pInt,maxNinstance instancesLoop: do i = 1_pInt,maxNinstance
outputsLoop: do o = 1_pInt,constitutive_phenopowerlaw_Noutput(i) outputsLoop: do o = 1_pInt,constitutive_phenopowerlaw_Noutput(i)
select case(constitutive_phenopowerlaw_output(o,i)) select case(constitutive_phenopowerlaw_outputID(o,i))
case('resistance_slip', & case(resistance_slip_ID, &
'shearrate_slip', & shearrate_slip_ID, &
'accumulatedshear_slip', & accumulatedshear_slip_ID, &
'resolvedstress_slip' & resolvedstress_slip_ID &
) )
mySize = constitutive_phenopowerlaw_totalNslip(i) mySize = constitutive_phenopowerlaw_totalNslip(i)
case('resistance_twin', & case(resistance_twin_ID, &
'shearrate_twin', & shearrate_twin_ID, &
'accumulatedshear_twin', & accumulatedshear_twin_ID, &
'resolvedstress_twin' & resolvedstress_twin_ID &
) )
mySize = constitutive_phenopowerlaw_totalNtwin(i) mySize = constitutive_phenopowerlaw_totalNtwin(i)
case('totalshear', & case(totalshear_ID, &
'totalvolfrac' & totalvolfrac_ID &
) )
mySize = 1_pInt mySize = 1_pInt
case default case default
@ -1053,17 +1091,17 @@ pure function constitutive_phenopowerlaw_postResults(Tstar_v,state,ipc,ip,el)
c = 0_pInt c = 0_pInt
outputsLoop: do o = 1_pInt,phase_Noutput(material_phase(ipc,ip,el)) outputsLoop: do o = 1_pInt,phase_Noutput(material_phase(ipc,ip,el))
select case(constitutive_phenopowerlaw_output(o,matID)) select case(constitutive_phenopowerlaw_outputID(o,matID))
case ('resistance_slip') case (resistance_slip_ID)
constitutive_phenopowerlaw_postResults(c+1_pInt:c+nSlip) = state(ipc,ip,el)%p(1:nSlip) constitutive_phenopowerlaw_postResults(c+1_pInt:c+nSlip) = state(ipc,ip,el)%p(1:nSlip)
c = c + nSlip c = c + nSlip
case ('accumulatedshear_slip') case (accumulatedshear_slip_ID)
constitutive_phenopowerlaw_postResults(c+1_pInt:c+nSlip) = state(ipc,ip,el)%p(index_accshear_slip:& constitutive_phenopowerlaw_postResults(c+1_pInt:c+nSlip) = state(ipc,ip,el)%p(index_accshear_slip:&
index_accshear_slip+nSlip) index_accshear_slip+nSlip)
c = c + nSlip c = c + nSlip
case ('shearrate_slip') case (shearrate_slip_ID)
j = 0_pInt j = 0_pInt
slipFamiliesLoop1: do f = 1_pInt,lattice_maxNslipFamily slipFamiliesLoop1: do f = 1_pInt,lattice_maxNslipFamily
index_myFamily = sum(lattice_NslipSystem(1:f-1_pInt,structID)) ! at which index starts my family index_myFamily = sum(lattice_NslipSystem(1:f-1_pInt,structID)) ! at which index starts my family
@ -1085,7 +1123,7 @@ pure function constitutive_phenopowerlaw_postResults(Tstar_v,state,ipc,ip,el)
enddo slipFamiliesLoop1 enddo slipFamiliesLoop1
c = c + nSlip c = c + nSlip
case ('resolvedstress_slip') case (resolvedstress_slip_ID)
j = 0_pInt j = 0_pInt
slipFamiliesLoop2: do f = 1_pInt,lattice_maxNslipFamily slipFamiliesLoop2: do f = 1_pInt,lattice_maxNslipFamily
index_myFamily = sum(lattice_NslipSystem(1:f-1_pInt,structID)) ! at which index starts my family index_myFamily = sum(lattice_NslipSystem(1:f-1_pInt,structID)) ! at which index starts my family
@ -1097,22 +1135,22 @@ pure function constitutive_phenopowerlaw_postResults(Tstar_v,state,ipc,ip,el)
enddo slipFamiliesLoop2 enddo slipFamiliesLoop2
c = c + nSlip c = c + nSlip
case ('totalshear') case (totalshear_ID)
constitutive_phenopowerlaw_postResults(c+1_pInt) = & constitutive_phenopowerlaw_postResults(c+1_pInt) = &
state(ipc,ip,el)%p(index_Gamma) state(ipc,ip,el)%p(index_Gamma)
c = c + 1_pInt c = c + 1_pInt
case ('resistance_twin') case (resistance_twin_ID)
constitutive_phenopowerlaw_postResults(c+1_pInt:c+nTwin) = & constitutive_phenopowerlaw_postResults(c+1_pInt:c+nTwin) = &
state(ipc,ip,el)%p(1_pInt+nSlip:nTwin+nSlip) state(ipc,ip,el)%p(1_pInt+nSlip:nTwin+nSlip)
c = c + nTwin c = c + nTwin
case ('accumulatedshear_twin') case (accumulatedshear_twin_ID)
constitutive_phenopowerlaw_postResults(c+1_pInt:c+nTwin) = & constitutive_phenopowerlaw_postResults(c+1_pInt:c+nTwin) = &
state(ipc,ip,el)%p(index_accshear_twin:index_accshear_twin+nTwin) state(ipc,ip,el)%p(index_accshear_twin:index_accshear_twin+nTwin)
c = c + nTwin c = c + nTwin
case ('shearrate_twin') case (shearrate_twin_ID)
j = 0_pInt j = 0_pInt
twinFamiliesLoop1: do f = 1_pInt,lattice_maxNtwinFamily twinFamiliesLoop1: do f = 1_pInt,lattice_maxNtwinFamily
index_myFamily = sum(lattice_NtwinSystem(1:f-1_pInt,structID)) ! at which index starts my family index_myFamily = sum(lattice_NtwinSystem(1:f-1_pInt,structID)) ! at which index starts my family
@ -1127,7 +1165,7 @@ pure function constitutive_phenopowerlaw_postResults(Tstar_v,state,ipc,ip,el)
enddo twinFamiliesLoop1 enddo twinFamiliesLoop1
c = c + nTwin c = c + nTwin
case ('resolvedstress_twin') case (resolvedstress_twin_ID)
j = 0_pInt j = 0_pInt
twinFamiliesLoop2: do f = 1_pInt,lattice_maxNtwinFamily twinFamiliesLoop2: do f = 1_pInt,lattice_maxNtwinFamily
index_myFamily = sum(lattice_NtwinSystem(1:f-1_pInt,structID)) ! at which index starts my family index_myFamily = sum(lattice_NtwinSystem(1:f-1_pInt,structID)) ! at which index starts my family
@ -1139,7 +1177,7 @@ pure function constitutive_phenopowerlaw_postResults(Tstar_v,state,ipc,ip,el)
enddo twinFamiliesLoop2 enddo twinFamiliesLoop2
c = c + nTwin c = c + nTwin
case ('totalvolfrac') case (totalvolfrac_ID)
constitutive_phenopowerlaw_postResults(c+1_pInt) = state(ipc,ip,el)%p(index_F) constitutive_phenopowerlaw_postResults(c+1_pInt) = state(ipc,ip,el)%p(index_F)
c = c + 1_pInt c = c + 1_pInt

View File

@ -37,10 +37,22 @@ module homogenization_isostrain
character(len=64), dimension(:,:), allocatable, target, public :: & character(len=64), dimension(:,:), allocatable, target, public :: &
homogenization_isostrain_output !< name of each post result output homogenization_isostrain_output !< name of each post result output
character(len=64), dimension(:), allocatable, private :: &
homogenization_isostrain_mapping
integer(pInt), dimension(:), allocatable, private :: & integer(pInt), dimension(:), allocatable, private :: &
homogenization_isostrain_Ngrains homogenization_isostrain_Ngrains
enum, bind(c)
enumerator :: ncomponents, &
temperature, &
ipcoords, &
avgdefgrad, &
avgfirstpiola
enumerator :: parallel, &
average
end enum
integer(kind(ncomponents)), dimension(:,:), allocatable, private :: &
homogenization_isostrain_outputID !< ID of each post result output
integer(kind(average)), dimension(:), allocatable, private :: &
homogenization_isostrain_mapping !< ID of each post result output
public :: & public :: &
homogenization_isostrain_init, & homogenization_isostrain_init, &
@ -90,9 +102,11 @@ subroutine homogenization_isostrain_init(myUnit)
allocate(homogenization_isostrain_Ngrains(maxNinstance)) allocate(homogenization_isostrain_Ngrains(maxNinstance))
homogenization_isostrain_Ngrains = 0_pInt homogenization_isostrain_Ngrains = 0_pInt
allocate(homogenization_isostrain_mapping(maxNinstance)) allocate(homogenization_isostrain_mapping(maxNinstance))
homogenization_isostrain_mapping = 'avg' homogenization_isostrain_mapping = average
allocate(homogenization_isostrain_output(maxval(homogenization_Noutput),maxNinstance)) allocate(homogenization_isostrain_output(maxval(homogenization_Noutput),maxNinstance))
homogenization_isostrain_output = '' homogenization_isostrain_output = ''
allocate(homogenization_isostrain_outputID(maxval(homogenization_Noutput),maxNinstance))
homogenization_isostrain_outputID = -1
rewind(myUnit) rewind(myUnit)
section = 0_pInt section = 0_pInt
@ -118,10 +132,31 @@ subroutine homogenization_isostrain_init(myUnit)
case ('(output)') case ('(output)')
output = output + 1_pInt output = output + 1_pInt
homogenization_isostrain_output(output,i) = IO_lc(IO_stringValue(line,positions,2_pInt)) homogenization_isostrain_output(output,i) = IO_lc(IO_stringValue(line,positions,2_pInt))
select case(homogenization_isostrain_output(output,i))
case('ngrains','ncomponents')
homogenization_isostrain_outputID(output,i) = ncomponents
case('temperature')
homogenization_isostrain_outputID(output,i) = temperature
case('ipcoords')
homogenization_isostrain_outputID(output,i) = ipcoords
case('avgdefgrad','avgf')
homogenization_isostrain_outputID(output,i) = avgdefgrad
case('avgp','avgfirstpiola','avg1stpiola')
homogenization_isostrain_outputID(output,i) = avgfirstpiola
case default
mySize = 0_pInt
end select
case ('ngrains','ncomponents') case ('ngrains','ncomponents')
homogenization_isostrain_Ngrains(i) = IO_intValue(line,positions,2_pInt) homogenization_isostrain_Ngrains(i) = IO_intValue(line,positions,2_pInt)
case ('mapping') case ('mapping')
homogenization_isostrain_mapping(i) = IO_lc(IO_stringValue(line,positions,2_pInt)) select case(IO_lc(IO_stringValue(line,positions,2_pInt)))
case ('parallel','sum')
homogenization_isostrain_mapping(i) = parallel
case ('average','mean','avg')
homogenization_isostrain_mapping(i) = average
case default
print*, 'There should be an error here'
end select
end select end select
endif endif
endif endif
@ -131,12 +166,12 @@ subroutine homogenization_isostrain_init(myUnit)
homogenization_isostrain_sizeState(i) = 0_pInt homogenization_isostrain_sizeState(i) = 0_pInt
do j = 1_pInt,maxval(homogenization_Noutput) do j = 1_pInt,maxval(homogenization_Noutput)
select case(homogenization_isostrain_output(j,i)) select case(homogenization_isostrain_outputID(j,i))
case('ngrains','ncomponents','temperature') case(ncomponents, temperature)
mySize = 1_pInt mySize = 1_pInt
case('ipcoords') case(ipcoords)
mySize = 3_pInt mySize = 3_pInt
case('avgdefgrad','avgf','avgp','avgfirstpiola','avg1stpiola') case(avgdefgrad, avgfirstpiola)
mySize = 9_pInt mySize = 9_pInt
case default case default
mySize = 0_pInt mySize = 0_pInt
@ -203,13 +238,10 @@ subroutine homogenization_isostrain_averageStressAndItsTangent(avgP,dAvgPdAvgF,P
Ngrains = homogenization_Ngrains(mesh_element(3,el)) Ngrains = homogenization_Ngrains(mesh_element(3,el))
select case (homogenization_isostrain_mapping(homID)) select case (homogenization_isostrain_mapping(homID))
case ('parallel','sum') case (parallel)
avgP = sum(P,3) avgP = sum(P,3)
dAvgPdAvgF = sum(dPdF,5) dAvgPdAvgF = sum(dPdF,5)
case ('average','mean','avg') case (average)
avgP = sum(P,3) /real(Ngrains,pReal)
dAvgPdAvgF = sum(dPdF,5)/real(Ngrains,pReal)
case default
avgP = sum(P,3) /real(Ngrains,pReal) avgP = sum(P,3) /real(Ngrains,pReal)
dAvgPdAvgF = sum(dPdF,5)/real(Ngrains,pReal) dAvgPdAvgF = sum(dPdF,5)/real(Ngrains,pReal)
end select end select
@ -252,20 +284,20 @@ pure function homogenization_isostrain_postResults(ip,el,avgP,avgF)
homogenization_isostrain_postResults = 0.0_pReal homogenization_isostrain_postResults = 0.0_pReal
do o = 1_pInt,homogenization_Noutput(mesh_element(3,el)) do o = 1_pInt,homogenization_Noutput(mesh_element(3,el))
select case(homogenization_isostrain_output(o,homID)) select case(homogenization_isostrain_outputID(o,homID))
case ('ngrains','ncomponents') case (ncomponents)
homogenization_isostrain_postResults(c+1_pInt) = real(homogenization_isostrain_Ngrains(homID),pReal) homogenization_isostrain_postResults(c+1_pInt) = real(homogenization_isostrain_Ngrains(homID),pReal)
c = c + 1_pInt c = c + 1_pInt
case ('temperature') case (temperature)
homogenization_isostrain_postResults(c+1_pInt) = crystallite_temperature(ip,el) homogenization_isostrain_postResults(c+1_pInt) = crystallite_temperature(ip,el)
c = c + 1_pInt c = c + 1_pInt
case ('avgdefgrad','avgf') case (avgdefgrad)
homogenization_isostrain_postResults(c+1_pInt:c+9_pInt) = reshape(avgF,[9]) homogenization_isostrain_postResults(c+1_pInt:c+9_pInt) = reshape(avgF,[9])
c = c + 9_pInt c = c + 9_pInt
case ('avgp','avgfirstpiola','avg1stpiola') case (avgfirstpiola)
homogenization_isostrain_postResults(c+1_pInt:c+9_pInt) = reshape(avgP,[9]) homogenization_isostrain_postResults(c+1_pInt:c+9_pInt) = reshape(avgP,[9])
c = c + 9_pInt c = c + 9_pInt
case ('ipcoords') case (ipcoords)
homogenization_isostrain_postResults(c+1_pInt:c+3_pInt) = mesh_ipCoordinates(1:3,ip,el) ! current ip coordinates homogenization_isostrain_postResults(c+1_pInt:c+3_pInt) = mesh_ipCoordinates(1:3,ip,el) ! current ip coordinates
c = c + 3_pInt c = c + 3_pInt
end select end select