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,17 +171,23 @@ 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))
do ma = 1, materials%length ! manual iteration for performance
material => materials%get(ma) select type(materials)
constituents => material%get('constituents') class is(tList)
allocate(material_O_0(ma)%data(constituents%length)) item => materials%first
allocate(material_F_i_0(ma)%data(1:3,1:3,constituents%length)) do ma = 1, materials%length
do co = 1, constituents%length material => item%node
constituent => constituents%get(co) constituents => material%get('constituents')
call material_O_0(ma)%data(co)%fromQuaternion(constituent%get_as1dFloat('O',requiredSize=4)) allocate(material_O_0(ma)%data(constituents%length))
material_F_i_0(ma)%data(1:3,1:3,co) = constituent%get_as2dFloat('F_i',defaultVal=math_I3,requiredShape=[3,3]) allocate(material_F_i_0(ma)%data(1:3,1:3,constituents%length))
enddo do co = 1, constituents%length
enddo constituent => constituents%get(co)
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])
end do
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')
do m = 1, materials%length ! manual iteration for performance
material => materials%get(m) select type(materials)
constituents => material%get('constituents') class is(tList)
homogenization => homogenizations%get(material%get_asString('homogenization')) item => materials%first
if (constituents%length /= homogenization%get_asInt('N_constituents')) call IO_error(148) do m = 1, materials%length
end do material => materials%get(m)
constituents => material%get('constituents')
homogenization => homogenizations%get(material%get_asString('homogenization'))
if (constituents%length /= homogenization%get_asInt('N_constituents')) call IO_error(148)
item => item%next
end do
end select
end subroutine sanityCheck end subroutine sanityCheck