avoid code repetition

This commit is contained in:
Martin Diehl 2018-10-14 20:16:30 +02:00
parent a311cc7673
commit 767ca0edd4
2 changed files with 53 additions and 23 deletions

View File

@ -283,6 +283,7 @@ module material
public :: &
material_init, &
material_allocatePlasticState ,&
ELASTICITY_hooke_ID ,&
PLASTICITY_none_ID, &
PLASTICITY_isotropic_ID, &
@ -1069,6 +1070,55 @@ subroutine material_parseTexture
end subroutine material_parseTexture
!--------------------------------------------------------------------------------------------------
!> @brief allocates the plastic state of a phase
!--------------------------------------------------------------------------------------------------
subroutine material_allocatePlasticState(phase,NofMyPhase,sizeState,sizeDotState,sizeDeltaState,&
Nslip,Ntwin,Ntrans)
use numerics, only: &
numerics_integrator2 => numerics_integrator ! compatibility hack
implicit none
integer(pInt), intent(in) :: &
phase, &
NofMyPhase, &
sizeState, &
sizeDotState, &
sizeDeltaState, &
Nslip, &
Ntwin, &
Ntrans
integer(pInt) :: numerics_integrator ! compatibility hack
numerics_integrator = numerics_integrator2(1) ! compatibility hack
plasticState(phase)%sizeState = sizeState
plasticState(phase)%sizeDotState = sizeDotState
plasticState(phase)%sizeDeltaState = sizeDeltaState
plasticState(phase)%Nslip = Nslip
plasticState(phase)%Ntwin = Ntwin
plasticState(phase)%Ntrans= Ntrans
allocate(plasticState(phase)%aTolState (sizeState), source=0.0_pReal)
allocate(plasticState(phase)%state0 (sizeState,NofMyPhase), source=0.0_pReal)
allocate(plasticState(phase)%partionedState0 (sizeState,NofMyPhase), source=0.0_pReal)
allocate(plasticState(phase)%subState0 (sizeState,NofMyPhase), source=0.0_pReal)
allocate(plasticState(phase)%state (sizeState,NofMyPhase), source=0.0_pReal)
allocate(plasticState(phase)%dotState (sizeDotState,NofMyPhase), source=0.0_pReal)
if (numerics_integrator == 1_pInt) then
allocate(plasticState(phase)%previousDotState (sizeDotState,NofMyPhase), source=0.0_pReal)
allocate(plasticState(phase)%previousDotState2 (sizeDotState,NofMyPhase), source=0.0_pReal)
endif
if (numerics_integrator == 4_pInt) &
allocate(plasticState(phase)%RK4dotState (sizeDotState,NofMyPhase), source=0.0_pReal)
if (numerics_integrator == 5_pInt) &
allocate(plasticState(phase)%RKCK45dotState (6,sizeDotState,NofMyPhase), source=0.0_pReal)
allocate(plasticState(phase)%deltaState (sizeDeltaState,NofMyPhase), source=0.0_pReal)
end subroutine material_allocatePlasticState
!--------------------------------------------------------------------------------------------------
!> @brief populates the grains
!> @details populates the grains by identifying active microstructure/homogenization pairs,

View File

@ -361,31 +361,11 @@ subroutine plastic_phenopowerlaw_init
sizeState = size(['tau_slip ','gamma_slip']) * prm%TotalNslip &
+ size(['tau_twin ','gamma_twin']) * prm%TotalNtwin &
+ size(['sum(gamma)','sum(f) ']) ! ToDo: only needed if either twin or slip active!
!--------------------------------------------------------------------------------------------------
! ToDo: This could be done by a function (in constitutive?)
sizeDotState = sizeState
plasticState(p)%sizeState = sizeState
plasticState(p)%sizeDotState = sizeDotState
plasticState(p)%sizePostResults = sum(plastic_phenopowerlaw_sizePostResult(:,phase_plasticityInstance(p)))
plasticState(p)%nSlip = prm%totalNslip
plasticState(p)%nTwin = prm%totalNtwin
allocate(plasticState(p)%aTolState ( sizeState), source=0.0_pReal)
allocate(plasticState(p)%state0 ( sizeState,NipcMyPhase), source=0.0_pReal)
allocate(plasticState(p)%partionedState0 ( sizeState,NipcMyPhase), source=0.0_pReal)
allocate(plasticState(p)%subState0 ( sizeState,NipcMyPhase), source=0.0_pReal)
allocate(plasticState(p)%state ( sizeState,NipcMyPhase), source=0.0_pReal)
allocate(plasticState(p)%dotState (sizeDotState,NipcMyPhase), source=0.0_pReal)
allocate(plasticState(p)%deltaState (0_pInt,NipcMyPhase), source=0.0_pReal)
if (any(numerics_integrator == 1_pInt)) then
allocate(plasticState(p)%previousDotState (sizeDotState,NipcMyPhase),source=0.0_pReal)
allocate(plasticState(p)%previousDotState2(sizeDotState,NipcMyPhase),source=0.0_pReal)
endif
if (any(numerics_integrator == 4_pInt)) &
allocate(plasticState(p)%RK4dotState (sizeDotState,NipcMyPhase), source=0.0_pReal)
if (any(numerics_integrator == 5_pInt)) &
allocate(plasticState(p)%RKCK45dotState (6,sizeDotState,NipcMyPhase), source=0.0_pReal)
call material_allocatePlasticState(p,NipcMyPhase,sizeState,sizeDotState,0_pInt, &
prm%totalNslip,prm%totalNtwin,0_pInt)
plasticState(p)%sizePostResults = sum(plastic_phenopowerlaw_sizePostResult(:,instance))
!--------------------------------------------------------------------------------------------------