From 07ab7a4d578ef6cb673918469c5f51cd91bc1d9d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 29 Feb 2020 09:36:42 +0100 Subject: [PATCH] one loop is enough --- src/kinematics_cleavage_opening.f90 | 6 ++---- src/kinematics_slipplane_opening.f90 | 5 +---- src/kinematics_thermal_expansion.f90 | 20 +++++++++++--------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/kinematics_cleavage_opening.f90 b/src/kinematics_cleavage_opening.f90 index 5810cc1ca..ddf2bd7b7 100644 --- a/src/kinematics_cleavage_opening.f90 +++ b/src/kinematics_cleavage_opening.f90 @@ -56,13 +56,11 @@ subroutine kinematics_cleavage_opening_init if (iand(debug_level(debug_constitutive),debug_levelBasic) /= 0) & write(6,'(a16,1x,i5,/)') '# instances:',Ninstance + allocate(kinematics_cleavage_opening_instance(size(config_phase)), source=0) allocate(param(Ninstance)) - allocate(kinematics_cleavage_opening_instance(size(config_phase)), source=0) - - do p = 1, size(config_phase) - kinematics_cleavage_opening_instance(p) = count(phase_kinematics(:,1:p) == kinematics_cleavage_opening_ID) ! ToDo: count correct? + kinematics_cleavage_opening_instance(p) = count(phase_kinematics(:,1:p) == kinematics_cleavage_opening_ID) if (all(phase_kinematics(:,p) /= KINEMATICS_cleavage_opening_ID)) cycle associate(prm => param(kinematics_cleavage_opening_instance(p)), & diff --git a/src/kinematics_slipplane_opening.f90 b/src/kinematics_slipplane_opening.f90 index 549fa3e3c..61ed137cf 100644 --- a/src/kinematics_slipplane_opening.f90 +++ b/src/kinematics_slipplane_opening.f90 @@ -58,13 +58,10 @@ subroutine kinematics_slipplane_opening_init write(6,'(a16,1x,i5,/)') '# instances:',Ninstance allocate(kinematics_slipplane_opening_instance(size(config_phase)), source=0) - do p = 1, size(config_phase) - kinematics_slipplane_opening_instance(p) = count(phase_kinematics(:,1:p) == kinematics_slipplane_opening_ID) ! ToDo: count correct? - enddo - allocate(param(Ninstance)) do p = 1, size(config_phase) + kinematics_slipplane_opening_instance(p) = count(phase_kinematics(:,1:p) == kinematics_slipplane_opening_ID) if (all(phase_kinematics(:,p) /= KINEMATICS_slipplane_opening_ID)) cycle associate(prm => param(kinematics_slipplane_opening_instance(p)), & config => config_phase(p)) diff --git a/src/kinematics_thermal_expansion.f90 b/src/kinematics_thermal_expansion.f90 index a9cde9a22..faf72b344 100644 --- a/src/kinematics_thermal_expansion.f90 +++ b/src/kinematics_thermal_expansion.f90 @@ -15,6 +15,8 @@ module kinematics_thermal_expansion implicit none private + integer, dimension(:), allocatable :: kinematics_thermal_expansion_instance + type :: tParameters real(pReal), allocatable, dimension(:,:,:) :: & expansion @@ -46,15 +48,14 @@ subroutine kinematics_thermal_expansion_init if (iand(debug_level(debug_constitutive),debug_levelBasic) /= 0) & write(6,'(a16,1x,i5,/)') '# instances:',Ninstance + allocate(kinematics_thermal_expansion_instance(size(config_phase)), source=0) allocate(param(Ninstance)) do p = 1, size(config_phase) + kinematics_thermal_expansion_instance(p) = count(phase_kinematics(:,1:p) == KINEMATICS_thermal_expansion_ID) if (all(phase_kinematics(:,p) /= KINEMATICS_thermal_expansion_ID)) cycle associate(config => config_phase(p)) - ! ToDo: Here we need to decide how to extend the concept of instances to - ! kinetics and sources. I would suggest that the same mechanism exists at maximum once per phase - ! read up to three parameters (constant, linear, quadratic with T) temp = config%getFloats('thermal_expansion11') !lattice_thermalExpansion33(1,1,1:size(temp),p) = temp @@ -76,9 +77,10 @@ pure function kinematics_thermal_expansion_initialStrain(homog,phase,offset) integer, intent(in) :: & phase, & - homog, offset + homog, & + offset real(pReal), dimension(3,3) :: & - kinematics_thermal_expansion_initialStrain !< initial thermal strain (should be small strain, though) + kinematics_thermal_expansion_initialStrain !< initial thermal strain (should be small strain, though) kinematics_thermal_expansion_initialStrain = & (temperature(homog)%p(offset) - lattice_referenceTemperature(phase))**1 / 1. * & @@ -104,17 +106,17 @@ subroutine kinematics_thermal_expansion_LiAndItsTangent(Li, dLi_dTstar, ipc, ip, Li !< thermal velocity gradient real(pReal), intent(out), dimension(3,3,3,3) :: & dLi_dTstar !< derivative of Li with respect to Tstar (4th-order tensor defined to be zero) + integer :: & phase, & - homog, offset + homog real(pReal) :: & T, TRef, TDot phase = material_phaseAt(ipc,el) homog = material_homogenizationAt(el) - offset = thermalMapping(homog)%p(ip,el) - T = temperature(homog)%p(offset) - TDot = temperatureRate(homog)%p(offset) + T = temperature(homog)%p(thermalMapping(homog)%p(ip,el)) + TDot = temperatureRate(homog)%p(thermalMapping(homog)%p(ip,el)) TRef = lattice_referenceTemperature(phase) Li = TDot * ( &