diff --git a/code/constitutive.f90 b/code/constitutive.f90 index ee6712e48..ae8657266 100644 --- a/code/constitutive.f90 +++ b/code/constitutive.f90 @@ -55,9 +55,7 @@ module constitutive constitutive_LpAndItsTangent, & constitutive_TandItsTangent, & constitutive_collectDotState, & -#ifndef NEWSTATE constitutive_collectDeltaState, & -#endif constitutive_postResults private :: & @@ -262,17 +260,17 @@ subroutine constitutive_init endif #endif - ElemLoop:do e = 1_pInt,mesh_NcpElems ! loop over elements + ElemLoop:do e = 1_pInt,mesh_NcpElems ! loop over elements myNgrains = homogenization_Ngrains(mesh_element(3,e)) - IPloop:do i = 1_pInt,FE_Nips(FE_geomtype(mesh_element(2,e))) ! loop over IPs - GrainLoop:do g = 1_pInt,myNgrains ! loop over grains + IPloop:do i = 1_pInt,FE_Nips(FE_geomtype(mesh_element(2,e))) ! loop over IPs + GrainLoop:do g = 1_pInt,myNgrains ! loop over grains select case(phase_elasticity(material_phase(g,i,e))) case default ! so far no output for elasticity end select phase = material_phase(g,i,e) instance = phase_plasticityInstance(phase) #if defined(HDF) || defined(NEWSTATE) - ConstitutivePosition(phase) = ConstitutivePosition(phase)+1_pInt ! not distinguishing between instances of same phase + ConstitutivePosition(phase) = ConstitutivePosition(phase)+1_pInt ! not distinguishing between instances of same phase mappingConstitutive(1:2,g,i,e) = [ConstitutivePosition(phase),phase] #endif select case(phase_plasticity(material_phase(g,i,e))) @@ -938,10 +936,10 @@ subroutine constitutive_collectDotState(Tstar_v, FeArray, FpArray, Temperature, end subroutine constitutive_collectDotState !-------------------------------------------------------------------------------------------------- -!> @brief contains the constitutive equation for calculating the incremental change of -!> microstructure based on the current stress and state +!> @brief for constitutive models having an instantaneous change of state (so far, only nonlocal) +!> will return false if delta state is not needed/supported by the constitutive model !-------------------------------------------------------------------------------------------------- -subroutine constitutive_collectDeltaState(Tstar_v, ipc, ip, el) +logical function constitutive_collectDeltaState(Tstar_v, ipc, ip, el) use prec, only: & pLongInt use debug, only: & @@ -978,6 +976,7 @@ subroutine constitutive_collectDeltaState(Tstar_v, ipc, ip, el) select case (phase_plasticity(material_phase(ipc,ip,el))) case (PLASTICITY_NONLOCAL_ID) + constitutive_collectDeltaState = .true. #ifdef NEWSTATE call constitutive_nonlocal_deltaState(mappingConstitutive, Tstar_v,ipc,ip,el) #else @@ -985,10 +984,8 @@ subroutine constitutive_collectDeltaState(Tstar_v, ipc, ip, el) constitutive_state(ipc,ip,el), Tstar_v,ipc,ip,el) #endif case default -#ifdef NEWSTATE - plasticState(mappingConstitutive(2,ipc,ip,el))%deltaState(:,mappingConstitutive(2,ipc,ip,el)) = & - 0.0_pReal -#else + constitutive_collectDeltaState = .false. +#ifndef NEWSTATE constitutive_deltaState(ipc,ip,el)%p = 0.0_pReal !ToDo: needed or will it remain zero anyway? #endif end select @@ -1003,7 +1000,9 @@ subroutine constitutive_collectDeltaState(Tstar_v, ipc, ip, el) !$OMP END CRITICAL (debugTimingDeltaState) endif -end subroutine constitutive_collectDeltaState +end function constitutive_collectDeltaState + + !-------------------------------------------------------------------------------------------------- !> @brief returns array of constitutive results !-------------------------------------------------------------------------------------------------- diff --git a/code/constitutive_j2.f90 b/code/constitutive_j2.f90 index d20c91788..79e1e95ca 100644 --- a/code/constitutive_j2.f90 +++ b/code/constitutive_j2.f90 @@ -322,7 +322,6 @@ subroutine constitutive_j2_init(fileUnit) allocate(plasticState(phase)%state_backup (sizeState,NofMyPhase),source=0.0_pReal) allocate(plasticState(phase)%aTolState (NofMyPhase),source=constitutive_j2_aTolResistance(instance)) allocate(plasticState(phase)%dotState (sizeDotState,NofMyPhase),source=0.0_pReal) - allocate(plasticState(phase)%deltaState (sizeDotState,NofMyPhase),source=0.0_pReal) allocate(plasticState(phase)%dotState_backup (sizeDotState,NofMyPhase),source=0.0_pReal) if (any(numerics_integrator == 1_pInt)) then allocate(plasticState(phase)%previousDotState (sizeDotState,NofMyPhase),source=0.0_pReal) diff --git a/code/constitutive_phenopowerlaw.f90 b/code/constitutive_phenopowerlaw.f90 index 4808036ab..08cce95b6 100644 --- a/code/constitutive_phenopowerlaw.f90 +++ b/code/constitutive_phenopowerlaw.f90 @@ -516,7 +516,6 @@ allocate(constitutive_phenopowerlaw_sizePostResults(maxNinstance), allocate(plasticState(phase)%state_backup (sizeState,NofMyPhase), source=0.0_pReal) allocate(plasticState(phase)%dotState (sizeDotState,NofMyPhase), source=0.0_pReal) - allocate(plasticState(phase)%deltaState (sizeDotState,NofMyPhase), source=0.0_pReal) allocate(plasticState(phase)%dotState_backup(sizeDotState,NofMyPhase), source=0.0_pReal) if (any(numerics_integrator == 1_pInt)) then allocate(plasticState(phase)%previousDotState (sizeDotState,NofMyPhase),source=0.0_pReal) diff --git a/code/crystallite.f90 b/code/crystallite.f90 index 151a029ea..633c7b5b6 100644 --- a/code/crystallite.f90 +++ b/code/crystallite.f90 @@ -3339,6 +3339,7 @@ end subroutine crystallite_integrateStateFPI !-------------------------------------------------------------------------------------------------- !> @brief calculates a jump in the state according to the current state and the current stress +!> returns true, if state jump was successfull or not needed. false indicates NaN in delta state !-------------------------------------------------------------------------------------------------- logical function crystallite_stateJump(g,i,e) use debug, only: & @@ -3361,8 +3362,8 @@ logical function crystallite_stateJump(g,i,e) #endif homogenization_Ngrains use constitutive, only: & -#ifndef NEWSTATE constitutive_collectDeltaState, & +#ifndef NEWSTATE constitutive_sizeDotState, & constitutive_state, & constitutive_deltaState @@ -3380,40 +3381,40 @@ logical function crystallite_stateJump(g,i,e) mySizeDotState - crystallite_stateJump = .false. -#ifndef NEWSTATE - call constitutive_collectDeltaState(crystallite_Tstar_v(1:6,g,i,e), g,i,e) -#endif + if (constitutive_collectDeltaState(crystallite_Tstar_v(1:6,g,i,e), g,i,e)) then #ifdef NEWSTATE - mySizeDotState = plasticState(mappingConstitutive(2,g,i,e))%sizeDotState - if( any(plasticState(mappingConstitutive(2,g,i,e))%deltaState(:,mappingConstitutive(1,g,i,e)) & - /= plasticState(mappingConstitutive(2,g,i,e))%deltaState(:,mappingConstitutive(1,g,i,e)))) then ! NaN occured in dotState - return - endif - plasticState(mappingConstitutive(2,g,i,e))%state(1:mySizeDotState,mappingConstitutive(1,g,i,e)) = & - plasticState(mappingConstitutive(2,g,i,e))%state(1:mySizeDotState,mappingConstitutive(1,g,i,e)) & - + plasticState(mappingConstitutive(2,g,i,e))%deltaState(1:mySizeDotState,mappingConstitutive(1,g,i,e)) + mySizeDotState = plasticState(mappingConstitutive(2,g,i,e))%sizeDotState + if( any(plasticState(mappingConstitutive(2,g,i,e))%deltaState(:,mappingConstitutive(1,g,i,e)) & + /= plasticState(mappingConstitutive(2,g,i,e))%deltaState(:,mappingConstitutive(1,g,i,e)))) then ! NaN occured in deltaState + crystallite_stateJump = .false. + return + endif + plasticState(mappingConstitutive(2,g,i,e))%state(1:mySizeDotState,mappingConstitutive(1,g,i,e)) = & + plasticState(mappingConstitutive(2,g,i,e))%state(1:mySizeDotState,mappingConstitutive(1,g,i,e)) & + + plasticState(mappingConstitutive(2,g,i,e))%deltaState(1:mySizeDotState,mappingConstitutive(1,g,i,e)) #else - mySizeDotState = constitutive_sizeDotState(g,i,e) - if (any(constitutive_deltaState(g,i,e)%p(1:mySizeDotState) & - /= constitutive_deltaState(g,i,e)%p(1:mySizeDotState))) then - return - endif + mySizeDotState = constitutive_sizeDotState(g,i,e) + if (any(constitutive_deltaState(g,i,e)%p(1:mySizeDotState) & + /= constitutive_deltaState(g,i,e)%p(1:mySizeDotState))) then + crystallite_stateJump = .false. + return + endif - constitutive_state(g,i,e)%p(1:mySizeDotState) = constitutive_state(g,i,e)%p(1:mySizeDotState) & + constitutive_state(g,i,e)%p(1:mySizeDotState) = constitutive_state(g,i,e)%p(1:mySizeDotState) & + constitutive_deltaState(g,i,e)%p(1:mySizeDotState) #ifndef _OPENMP - if (any(constitutive_deltaState(g,i,e)%p(1:mySizeDotState) /= 0.0_pReal) & - .and. iand(debug_level(debug_crystallite), debug_levelExtensive) /= 0_pInt & - .and. ((e == debug_e .and. i == debug_i .and. g == debug_g) & - .or. .not. iand(debug_level(debug_crystallite), debug_levelSelective) /= 0_pInt)) then - write(6,'(a,i8,1x,i2,1x,i3, /)') '<< CRYST >> update state at el ip g ',e,i,g - write(6,'(a,/,(12x,12(e12.5,1x)),/)') '<< CRYST >> deltaState', constitutive_deltaState(g,i,e)%p(1:mySizeDotState) - write(6,'(a,/,(12x,12(e12.5,1x)),/)') '<< CRYST >> new state', constitutive_state(g,i,e)%p(1:mySizeDotState) - endif + if (any(constitutive_deltaState(g,i,e)%p(1:mySizeDotState) /= 0.0_pReal) & + .and. iand(debug_level(debug_crystallite), debug_levelExtensive) /= 0_pInt & + .and. ((e == debug_e .and. i == debug_i .and. g == debug_g) & + .or. .not. iand(debug_level(debug_crystallite), debug_levelSelective) /= 0_pInt)) then + write(6,'(a,i8,1x,i2,1x,i3, /)') '<< CRYST >> update state at el ip g ',e,i,g + write(6,'(a,/,(12x,12(e12.5,1x)),/)') '<< CRYST >> deltaState', constitutive_deltaState(g,i,e)%p(1:mySizeDotState) + write(6,'(a,/,(12x,12(e12.5,1x)),/)') '<< CRYST >> new state', constitutive_state(g,i,e)%p(1:mySizeDotState) + endif #endif -#endif +#endif + endif crystallite_stateJump = .true.