made two loops faster

the most annoying one is still slow.
This commit is contained in:
Martin Diehl 2022-04-14 01:06:47 +02:00
parent ca0df3389a
commit 563d566a3f
2 changed files with 34 additions and 18 deletions

View File

@ -145,7 +145,7 @@ module YAML_types
end type tDict end type tDict
type :: tItem type, public :: tItem
character(len=:), allocatable :: key character(len=:), allocatable :: key
class(tNode), pointer :: node => NULL() class(tNode), pointer :: node => NULL()
class(tItem), pointer :: next => NULL() class(tItem), pointer :: next => NULL()

View File

@ -91,6 +91,7 @@ subroutine parse()
homogenizations, & homogenizations, &
homogenization homogenization
class(tItem), pointer :: item
integer, dimension(:), allocatable :: & integer, dimension(:), allocatable :: &
counterPhase, & counterPhase, &
counterHomogenization counterHomogenization
@ -102,6 +103,7 @@ subroutine parse()
co, ce, & co, ce, &
ma ma
materials => config_material%get('material') materials => config_material%get('material')
phases => config_material%get('phase') phases => config_material%get('phase')
homogenizations => config_material%get('homogenization') homogenizations => config_material%get('homogenization')
@ -169,8 +171,12 @@ subroutine parse()
allocate(material_O_0(materials%length)) allocate(material_O_0(materials%length))
allocate(material_F_i_0(materials%length)) allocate(material_F_i_0(materials%length))
! manual iteration for performance
select type(materials)
class is(tList)
item => materials%first
do ma = 1, materials%length do ma = 1, materials%length
material => materials%get(ma) material => item%node
constituents => material%get('constituents') constituents => material%get('constituents')
allocate(material_O_0(ma)%data(constituents%length)) allocate(material_O_0(ma)%data(constituents%length))
allocate(material_F_i_0(ma)%data(1:3,1:3,constituents%length)) allocate(material_F_i_0(ma)%data(1:3,1:3,constituents%length))
@ -178,8 +184,10 @@ subroutine parse()
constituent => constituents%get(co) constituent => constituents%get(co)
call material_O_0(ma)%data(co)%fromQuaternion(constituent%get_as1dFloat('O',requiredSize=4)) call material_O_0(ma)%data(co)%fromQuaternion(constituent%get_as1dFloat('O',requiredSize=4))
material_F_i_0(ma)%data(1:3,1:3,co) = constituent%get_as2dFloat('F_i',defaultVal=math_I3,requiredShape=[3,3]) material_F_i_0(ma)%data(1:3,1:3,co) = constituent%get_as2dFloat('F_i',defaultVal=math_I3,requiredShape=[3,3])
enddo end do
enddo item => item%next
end do
end select
end subroutine parse end subroutine parse
@ -195,17 +203,25 @@ subroutine sanityCheck(materials,homogenizations)
class(tNode), pointer :: material, & class(tNode), pointer :: material, &
homogenization, & homogenization, &
constituents constituents
class(tItem), pointer :: item
integer :: m integer :: m
if (maxval(discretization_materialAt) > materials%length) & if (maxval(discretization_materialAt) > materials%length) &
call IO_error(155,ext_msg='More materials requested than found in material.yaml') call IO_error(155,ext_msg='More materials requested than found in material.yaml')
! manual iteration for performance
select type(materials)
class is(tList)
item => materials%first
do m = 1, materials%length do m = 1, materials%length
material => materials%get(m) material => materials%get(m)
constituents => material%get('constituents') constituents => material%get('constituents')
homogenization => homogenizations%get(material%get_asString('homogenization')) homogenization => homogenizations%get(material%get_asString('homogenization'))
if (constituents%length /= homogenization%get_asInt('N_constituents')) call IO_error(148) if (constituents%length /= homogenization%get_asInt('N_constituents')) call IO_error(148)
item => item%next
end do end do
end select
end subroutine sanityCheck end subroutine sanityCheck