From fa8218124ace56b392ec1b639379106e7738fce7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 18 Nov 2021 21:59:09 +0100 Subject: [PATCH] avoid conversions --- src/homogenization_mechanical_RGC.f90 | 8 ++++---- src/phase.f90 | 4 ++-- src/phase_damage.f90 | 8 ++++---- src/phase_damage_isobrittle.f90 | 6 +++++- src/phase_mechanical_elastic.f90 | 8 ++++---- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/homogenization_mechanical_RGC.f90 b/src/homogenization_mechanical_RGC.f90 index f0c2900e2..36a335370 100644 --- a/src/homogenization_mechanical_RGC.f90 +++ b/src/homogenization_mechanical_RGC.f90 @@ -643,17 +643,17 @@ module function RGC_updateState(P,F,avgF,dt,dPdF,ce) result(doneAndHappy) !------------------------------------------------------------------------------------------------- !> @brief compute the equivalent shear and bulk moduli from the elasticity tensor !------------------------------------------------------------------------------------------------- - real(pReal) function equivalentMu(grainID,ce) + real(pReal) function equivalentMu(co,ce) integer, intent(in) :: & - grainID,& + co,& ce real(pReal), dimension(6,6) :: C - C = phase_homogenizedC66(material_phaseID(grainID,ce),material_phaseEntry(grainID,ce)) - equivalentMu = lattice_equivalent_mu(C,'voigt') + C = phase_homogenizedC66(material_phaseID(co,ce),material_phaseEntry(co,ce)) + equivalentMu = lattice_equivalent_mu(math_sym3333to66(math_Voigt66to3333(C)),'voigt') !ToDo: Bug, should be Voigt not sym end function equivalentMu diff --git a/src/phase.f90 b/src/phase.f90 index dc8525939..22c35416b 100644 --- a/src/phase.f90 +++ b/src/phase.f90 @@ -234,10 +234,10 @@ module phase integer, intent(in) :: ph, en real(pReal), dimension(6,6) :: C end function phase_homogenizedC66 - module function phase_damage_C66(C66,ph,en) + module function phase_damage_C66(C66,ph,en) result(C66_degraded) real(pReal), dimension(6,6), intent(in) :: C66 integer, intent(in) :: ph,en - real(pReal), dimension(6,6) :: phase_damage_C66 + real(pReal), dimension(6,6) :: C66_degraded end function phase_damage_C66 module function phase_f_phi(phi,co,ce) result(f) diff --git a/src/phase_damage.f90 b/src/phase_damage.f90 index 5382d65e3..3b3ace8ab 100644 --- a/src/phase_damage.f90 +++ b/src/phase_damage.f90 @@ -151,18 +151,18 @@ end function phase_damage_constitutive !-------------------------------------------------------------------------------------------------- !> @brief returns the degraded/modified elasticity matrix !-------------------------------------------------------------------------------------------------- -module function phase_damage_C66(C66,ph,en) +module function phase_damage_C66(C66,ph,en) result(C66_degraded) real(pReal), dimension(6,6), intent(in) :: C66 integer, intent(in) :: ph,en - real(pReal), dimension(6,6) :: phase_damage_C66 + real(pReal), dimension(6,6) :: C66_degraded damageType: select case (phase_damage(ph)) case (DAMAGE_ISOBRITTLE_ID) damageType - phase_damage_C66 = C66 * damage_phi(ph,en)**2 + C66_degraded = C66 * damage_phi(ph,en)**2 case default damageType - phase_damage_C66 = C66 + C66_degraded = C66 end select damageType end function phase_damage_C66 diff --git a/src/phase_damage_isobrittle.f90 b/src/phase_damage_isobrittle.f90 index 25ce1d3e9..9d5b4f508 100644 --- a/src/phase_damage_isobrittle.f90 +++ b/src/phase_damage_isobrittle.f90 @@ -96,6 +96,7 @@ end function isobrittle_init !-------------------------------------------------------------------------------------------------- !> @brief calculates derived quantities from state +! ToDo: Use Voigt directly !-------------------------------------------------------------------------------------------------- module subroutine isobrittle_deltaState(C, Fe, ph,en) @@ -109,13 +110,16 @@ module subroutine isobrittle_deltaState(C, Fe, ph,en) epsilon real(pReal) :: & r_W + real(pReal), dimension(6,6) :: & + C_sym + C_sym = math_sym3333to66(math_Voigt66to3333(C)) epsilon = 0.5_pReal*math_sym33to6(matmul(transpose(Fe),Fe)-math_I3) associate(prm => param(ph), stt => state(ph), dlt => deltaState(ph)) - r_W = 2.0_pReal*dot_product(epsilon,matmul(C,epsilon))/prm%W_crit + r_W = 2.0_pReal*dot_product(epsilon,matmul(C_sym,epsilon))/prm%W_crit dlt%r_W(en) = merge(r_W - stt%r_W(en), 0.0_pReal, r_W > stt%r_W(en)) end associate diff --git a/src/phase_mechanical_elastic.f90 b/src/phase_mechanical_elastic.f90 index 0f7394e86..38bca44b4 100644 --- a/src/phase_mechanical_elastic.f90 +++ b/src/phase_mechanical_elastic.f90 @@ -152,12 +152,12 @@ module subroutine phase_hooke_SandItsTangents(S, dS_dFe, dS_dFi, & i, j - C = math_66toSym3333(phase_damage_C66(phase_homogenizedC66(ph,en),ph,en)) + C = math_Voigt66to3333(phase_damage_C66(phase_homogenizedC66(ph,en),ph,en)) E = 0.5_pReal*(matmul(transpose(Fe),Fe)-math_I3) !< Green-Lagrange strain in unloaded configuration S = math_mul3333xx33(C,matmul(matmul(transpose(Fi),E),Fi)) !< 2PK stress in lattice configuration in work conjugate with GL strain pulled back to lattice configuration - do i =1, 3;do j=1,3 + do i =1,3; do j=1,3 dS_dFe(i,j,1:3,1:3) = matmul(Fe,matmul(matmul(Fi,C(i,j,1:3,1:3)),transpose(Fi))) !< dS_ij/dFe_kl = C_ijmn * Fi_lm * Fi_on * Fe_ko dS_dFi(i,j,1:3,1:3) = 2.0_pReal*matmul(matmul(E,Fi),C(i,j,1:3,1:3)) !< dS_ij/dFi_kl = C_ijln * E_km * Fe_mn end do; end do @@ -176,9 +176,9 @@ module function phase_homogenizedC66(ph,en) result(C) plasticType: select case (phase_plasticity(ph)) case (PLASTICITY_DISLOTWIN_ID) plasticType - C = plastic_dislotwin_homogenizedC(ph,en) + C = math_3333toVoigt66(math_66toSym3333(plastic_dislotwin_homogenizedC(ph,en))) case default plasticType - C = math_sym3333to66(math_Voigt66to3333(elastic_C66(ph,en))) + C = elastic_C66(ph,en) end select plasticType end function phase_homogenizedC66