avoid global variables

This commit is contained in:
Martin Diehl 2020-10-24 14:56:03 +02:00
parent 5e4815cddf
commit a1ab526456
7 changed files with 30 additions and 36 deletions

View File

@ -1571,7 +1571,7 @@ subroutine crystallite_restartWrite
call HDF5_closeGroup(groupHandle) call HDF5_closeGroup(groupHandle)
groupHandle = HDF5_addGroup(fileHandle,'materialpoint') groupHandle = HDF5_addGroup(fileHandle,'materialpoint')
do i = 1, material_Nhomogenization do i = 1, size(material_name_homogenization)
write(datasetName,'(i0,a)') i,'_omega_homogenization' write(datasetName,'(i0,a)') i,'_omega_homogenization'
call HDF5_write(groupHandle,homogState(i)%state,datasetName) call HDF5_write(groupHandle,homogState(i)%state,datasetName)
enddo enddo
@ -1612,7 +1612,7 @@ subroutine crystallite_restartRead
call HDF5_closeGroup(groupHandle) call HDF5_closeGroup(groupHandle)
groupHandle = HDF5_openGroup(fileHandle,'materialpoint') groupHandle = HDF5_openGroup(fileHandle,'materialpoint')
do i = 1, material_Nhomogenization do i = 1,size(material_name_homogenization)
write(datasetName,'(i0,a)') i,'_omega_homogenization' write(datasetName,'(i0,a)') i,'_omega_homogenization'
call HDF5_read(groupHandle,homogState(i)%state0,datasetName) call HDF5_read(groupHandle,homogState(i)%state0,datasetName)
enddo enddo
@ -1645,7 +1645,7 @@ subroutine crystallite_forward
do j = 1,phase_Nsources(i) do j = 1,phase_Nsources(i)
sourceState(i)%p(j)%state0 = sourceState(i)%p(j)%state sourceState(i)%p(j)%state0 = sourceState(i)%p(j)%state
enddo; enddo enddo; enddo
do i = 1, material_Nhomogenization do i = 1,size(material_name_homogenization)
homogState (i)%state0 = homogState (i)%state homogState (i)%state0 = homogState (i)%state
thermalState(i)%state0 = thermalState(i)%state thermalState(i)%state0 = thermalState(i)%state
damageState (i)%state0 = damageState (i)%state damageState (i)%state0 = damageState (i)%state

View File

@ -20,7 +20,7 @@ subroutine damage_none_init
print'(/,a)', ' <<<+- damage_none init -+>>>'; flush(6) print'(/,a)', ' <<<+- damage_none init -+>>>'; flush(6)
do h = 1, material_Nhomogenization do h = 1, size(material_name_homogenization)
if (damage_type(h) /= DAMAGE_NONE_ID) cycle if (damage_type(h) /= DAMAGE_NONE_ID) cycle
NofMyHomog = count(material_homogenizationAt == h) NofMyHomog = count(material_homogenizationAt == h)

View File

@ -210,7 +210,7 @@ program DAMASK_grid
if(.not. step_discretization%contains('t')) call IO_error(error_ID=837,ext_msg = 't missing') if(.not. step_discretization%contains('t')) call IO_error(error_ID=837,ext_msg = 't missing')
if(.not. step_discretization%contains('N')) call IO_error(error_ID=837,ext_msg = 'N missing') if(.not. step_discretization%contains('N')) call IO_error(error_ID=837,ext_msg = 'N missing')
loadCases(l)%time = step_discretization%get_asFloat('t') loadCases(l)%time = step_discretization%get_asFloat('t')
loadCases(l)%incs = step_discretization%get_asFloat('N') loadCases(l)%incs = step_discretization%get_asInt ('N')
loadCases(l)%logscale = step_discretization%get_asBool ('log_timestep', defaultVal= .false.) loadCases(l)%logscale = step_discretization%get_asBool ('log_timestep', defaultVal= .false.)
loadCases(l)%outputfrequency = step_discretization%get_asInt ('f_out', defaultVal=1) loadCases(l)%outputfrequency = step_discretization%get_asInt ('f_out', defaultVal=1)
loadCases(l)%restartfrequency = step_discretization%get_asInt ('f_restart', defaultVal=huge(0)) loadCases(l)%restartfrequency = step_discretization%get_asInt ('f_restart', defaultVal=huge(0))

View File

@ -63,9 +63,6 @@ module material
integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable, public, protected :: & integer(kind(HOMOGENIZATION_undefined_ID)), dimension(:), allocatable, public, protected :: &
homogenization_type !< type of each homogenization homogenization_type !< type of each homogenization
integer, public, protected :: &
material_Nhomogenization !< number of homogenizations
integer, public, protected :: & integer, public, protected :: &
homogenization_maxNconstituent !< max number of grains in any USED homogenization homogenization_maxNconstituent !< max number of grains in any USED homogenization
@ -185,17 +182,17 @@ subroutine material_init(restart)
if(homogenization_maxNconstituent > size(material_phaseAt,1)) call IO_error(148) if(homogenization_maxNconstituent > size(material_phaseAt,1)) call IO_error(148)
allocate(homogState (material_Nhomogenization)) allocate(homogState (size(material_name_homogenization)))
allocate(thermalState (material_Nhomogenization)) allocate(thermalState (size(material_name_homogenization)))
allocate(damageState (material_Nhomogenization)) allocate(damageState (size(material_name_homogenization)))
allocate(thermalMapping (material_Nhomogenization)) allocate(thermalMapping (size(material_name_homogenization)))
allocate(damageMapping (material_Nhomogenization)) allocate(damageMapping (size(material_name_homogenization)))
allocate(temperature (material_Nhomogenization)) allocate(temperature (size(material_name_homogenization)))
allocate(damage (material_Nhomogenization)) allocate(damage (size(material_name_homogenization)))
allocate(temperatureRate (material_Nhomogenization)) allocate(temperatureRate (size(material_name_homogenization)))
if (.not. restart) then if (.not. restart) then
@ -210,7 +207,7 @@ subroutine material_init(restart)
allocate(mappingHomogenizationConst( discretization_nIP,discretization_nElem),source=1) allocate(mappingHomogenizationConst( discretization_nIP,discretization_nElem),source=1)
! hack needed to initialize field values used during constitutive initialization ! hack needed to initialize field values used during constitutive initialization
do myHomog = 1,material_Nhomogenization do myHomog = 1, size(material_name_homogenization)
thermalMapping (myHomog)%p => mappingHomogenizationConst thermalMapping (myHomog)%p => mappingHomogenizationConst
damageMapping (myHomog)%p => mappingHomogenizationConst damageMapping (myHomog)%p => mappingHomogenizationConst
allocate(temperature (myHomog)%p(1), source=thermal_initialT(myHomog)) allocate(temperature (myHomog)%p(1), source=thermal_initialT(myHomog))
@ -234,12 +231,11 @@ subroutine material_parseNconstituent
integer :: h integer :: h
material_homogenization => config_material%get('homogenization') material_homogenization => config_material%get('homogenization')
material_Nhomogenization = material_homogenization%length
allocate(homogenization_Nconstituent(material_Nhomogenization)) allocate(homogenization_Nconstituent(size(material_name_homogenization)))
do h=1, material_Nhomogenization do h=1, size(material_name_homogenization)
homog => material_homogenization%get(h) homog => material_homogenization%get(h)
homogenization_Nconstituent(h) = homog%get_asInt('N_constituents') homogenization_Nconstituent(h) = homog%get_asInt('N_constituents')
enddo enddo
@ -266,19 +262,18 @@ subroutine material_parseHomogenization
material_homogenization => config_material%get('homogenization') material_homogenization => config_material%get('homogenization')
allocate(homogenization_type(material_Nhomogenization), source=HOMOGENIZATION_undefined_ID) allocate(homogenization_type(size(material_name_homogenization)), source=HOMOGENIZATION_undefined_ID)
allocate(thermal_type(material_Nhomogenization), source=THERMAL_isothermal_ID) allocate(thermal_type(size(material_name_homogenization)), source=THERMAL_isothermal_ID)
allocate(damage_type (material_Nhomogenization), source=DAMAGE_none_ID) allocate(damage_type (size(material_name_homogenization)), source=DAMAGE_none_ID)
allocate(homogenization_typeInstance(material_Nhomogenization), source=0) allocate(homogenization_typeInstance(size(material_name_homogenization)), source=0)
allocate(thermal_typeInstance(material_Nhomogenization), source=0) allocate(thermal_typeInstance(size(material_name_homogenization)), source=0)
allocate(damage_typeInstance(material_Nhomogenization), source=0) allocate(damage_typeInstance(size(material_name_homogenization)), source=0)
allocate(thermal_initialT(material_Nhomogenization), source=300.0_pReal) allocate(thermal_initialT(size(material_name_homogenization)), source=300.0_pReal)
allocate(damage_initialPhi(material_Nhomogenization), source=1.0_pReal) allocate(damage_initialPhi(size(material_name_homogenization)), source=1.0_pReal)
do h=1, material_Nhomogenization do h=1, size(material_name_homogenization)
homog => material_homogenization%get(h) homog => material_homogenization%get(h)
homogMech => homog%get('mech') homogMech => homog%get('mech')
homogenization_Nconstituent(h) = homog%get_asInt('N_constituents')
select case (homogMech%get_asString('type')) select case (homogMech%get_asString('type'))
case('none') case('none')
homogenization_type(h) = HOMOGENIZATION_NONE_ID homogenization_type(h) = HOMOGENIZATION_NONE_ID
@ -324,7 +319,7 @@ subroutine material_parseHomogenization
endif endif
enddo enddo
do h=1, material_Nhomogenization do h=1, size(material_name_homogenization)
homogenization_typeInstance(h) = count(homogenization_type(1:h) == homogenization_type(h)) homogenization_typeInstance(h) = count(homogenization_type(1:h) == homogenization_type(h))
thermal_typeInstance(h) = count(thermal_type (1:h) == thermal_type (h)) thermal_typeInstance(h) = count(thermal_type (1:h) == thermal_type (h))
damage_typeInstance(h) = count(damage_type (1:h) == damage_type (h)) damage_typeInstance(h) = count(damage_type (1:h) == damage_type (h))
@ -387,7 +382,6 @@ subroutine material_parseMaterial
allocate(material_orientation0(maxNconstituents,discretization_nIP,discretization_nElem)) allocate(material_orientation0(maxNconstituents,discretization_nIP,discretization_nElem))
do e = 1, discretization_nElem do e = 1, discretization_nElem
material => materials%get(discretization_materialAt(e)) material => materials%get(discretization_materialAt(e))
constituents => material%get('constituents') constituents => material%get('constituents')

View File

@ -54,7 +54,7 @@ subroutine thermal_adiabatic_init
allocate(param(maxNinstance)) allocate(param(maxNinstance))
material_homogenization => config_material%get('homogenization') material_homogenization => config_material%get('homogenization')
do h = 1, material_Nhomogenization do h = 1, size(material_name_homogenization)
if (thermal_type(h) /= THERMAL_adiabatic_ID) cycle if (thermal_type(h) /= THERMAL_adiabatic_ID) cycle
homog => material_homogenization%get(h) homog => material_homogenization%get(h)
homogThermal => homog%get('thermal') homogThermal => homog%get('thermal')

View File

@ -53,7 +53,7 @@ subroutine thermal_conduction_init
allocate(param(Ninstance)) allocate(param(Ninstance))
material_homogenization => config_material%get('homogenization') material_homogenization => config_material%get('homogenization')
do h = 1, material_Nhomogenization do h = 1, size(material_name_homogenization)
if (thermal_type(h) /= THERMAL_conduction_ID) cycle if (thermal_type(h) /= THERMAL_conduction_ID) cycle
homog => material_homogenization%get(h) homog => material_homogenization%get(h)
homogThermal => homog%get('thermal') homogThermal => homog%get('thermal')

View File

@ -20,7 +20,7 @@ subroutine thermal_isothermal_init
print'(/,a)', ' <<<+- thermal_isothermal init -+>>>'; flush(6) print'(/,a)', ' <<<+- thermal_isothermal init -+>>>'; flush(6)
do h = 1, material_Nhomogenization do h = 1, size(material_name_homogenization)
if (thermal_type(h) /= THERMAL_isothermal_ID) cycle if (thermal_type(h) /= THERMAL_isothermal_ID) cycle
NofMyHomog = count(material_homogenizationAt == h) NofMyHomog = count(material_homogenizationAt == h)