started introducing new state structure in homogenisation

This commit is contained in:
Luv Sharma 2014-08-21 17:48:20 +00:00
parent 9d26bfa375
commit e555ce4827
8 changed files with 438 additions and 24 deletions

View File

@ -147,6 +147,10 @@ subroutine CPFEM_init
use material, only: & use material, only: &
homogenization_maxNgrains, & homogenization_maxNgrains, &
material_phase, & material_phase, &
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
phase_plasticity, & phase_plasticity, &
plasticState plasticState
use crystallite, only: & use crystallite, only: &
@ -157,8 +161,10 @@ subroutine CPFEM_init
crystallite_Tstar0_v, & crystallite_Tstar0_v, &
crystallite_localPlasticity crystallite_localPlasticity
use homogenization, only: & use homogenization, only: &
homogenization_sizeState, & #ifndef NEWSTATE
homogenization_state0 homogenization_state0, &
#endif
homogenization_sizeState
implicit none implicit none
integer(pInt) :: i,j,k,l,m,ph integer(pInt) :: i,j,k,l,m,ph
@ -222,7 +228,11 @@ subroutine CPFEM_init
do k = 1,mesh_NcpElems; do j = 1,mesh_maxNips do k = 1,mesh_NcpElems; do j = 1,mesh_maxNips
do l = 1,homogenization_sizeState(j,k) do l = 1,homogenization_sizeState(j,k)
m = m+1_pInt m = m+1_pInt
#ifdef NEWSTATE
read(777,rec=m) homogState(mappingHomogenization(2,j,k))%state0(l,mappingHomogenization(1,j,k))
#else
read(777,rec=m) homogenization_state0(j,k)%p(l) read(777,rec=m) homogenization_state0(j,k)%p(l)
#endif
enddo enddo
enddo; enddo enddo; enddo
@ -304,6 +314,10 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature, dt, elFE, ip)
microstructure_elemhomo, & microstructure_elemhomo, &
plasticState, & plasticState, &
damageState, & damageState, &
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
thermalState, & thermalState, &
mappingConstitutive, & mappingConstitutive, &
material_phase, & material_phase, &
@ -322,8 +336,10 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature, dt, elFE, ip)
crystallite_temperature crystallite_temperature
use homogenization, only: & use homogenization, only: &
homogenization_sizeState, & homogenization_sizeState, &
#ifndef NEWSTATE
homogenization_state, & homogenization_state, &
homogenization_state0, & homogenization_state0, &
#endif
materialpoint_F, & materialpoint_F, &
materialpoint_F0, & materialpoint_F0, &
materialpoint_P, & materialpoint_P, &
@ -417,7 +433,12 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature, dt, elFE, ip)
do k = 1,mesh_NcpElems do k = 1,mesh_NcpElems
do j = 1,mesh_maxNips do j = 1,mesh_maxNips
if (homogenization_sizeState(j,k) > 0_pInt) & if (homogenization_sizeState(j,k) > 0_pInt) &
#ifdef NEWSTATE
homogState(mappingHomogenization(2,j,k))%state0(:,mappingHomogenization(1,j,k)) = &
homogState(mappingHomogenization(2,j,k))%state(:,mappingHomogenization(1,j,k)) ! internal state of homogenization scheme
#else
homogenization_state0(j,k)%p = homogenization_state(j,k)%p ! internal state of homogenization scheme homogenization_state0(j,k)%p = homogenization_state(j,k)%p ! internal state of homogenization scheme
#endif
enddo enddo
enddo enddo
!$OMP END PARALLEL DO !$OMP END PARALLEL DO
@ -468,7 +489,11 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature, dt, elFE, ip)
do k = 1,mesh_NcpElems; do j = 1,mesh_maxNips do k = 1,mesh_NcpElems; do j = 1,mesh_maxNips
do l = 1,homogenization_sizeState(j,k) do l = 1,homogenization_sizeState(j,k)
m = m+1_pInt m = m+1_pInt
#ifdef NEWSTATE
write(777,rec=m) homogState(mappingHomogenization(2,j,k))%state0(l,mappingHomogenization(1,j,k))
#else
write(777,rec=m) homogenization_state0(j,k)%p(l) write(777,rec=m) homogenization_state0(j,k)%p(l)
#endif
enddo enddo
enddo; enddo enddo; enddo
close (777) close (777)

View File

@ -117,6 +117,11 @@ RUN_PATH :=$(RUN_PATH),-rpath,$(HDF5_ROOT)/lib64,-rpath,$(HDF5_ROOT)/lib
INCLUDE_DIRS +=-I$(HDF5_ROOT)/include -DHDF INCLUDE_DIRS +=-I$(HDF5_ROOT)/include -DHDF
endif endif
#newstate
ifeq "$(STATE)" "NEWH"
INCLUDE_DIRS +=-DNEWSTATE
endif
ifdef STANDARD_CHECK ifdef STANDARD_CHECK
STANDARD_CHECK_ifort =$(STANDARD_CHECK) STANDARD_CHECK_ifort =$(STANDARD_CHECK)
STANDARD_CHECK_gfortran =$(STANDARD_CHECK) STANDARD_CHECK_gfortran =$(STANDARD_CHECK)

View File

@ -16,8 +16,10 @@ module homogenization
! General variables for the homogenization at a material point ! General variables for the homogenization at a material point
implicit none implicit none
private private
#ifndef NEWSTATE
type(p_vec), dimension(:,:), allocatable, public :: & type(p_vec), dimension(:,:), allocatable, public :: &
homogenization_state0 !< pointer array to homogenization state at start of FE increment homogenization_state0 !< pointer array to homogenization state at start of FE increment
#endif
real(pReal), dimension(:,:,:,:), allocatable, public :: & real(pReal), dimension(:,:,:,:), allocatable, public :: &
materialpoint_F0, & !< def grad of IP at start of FE increment materialpoint_F0, & !< def grad of IP at start of FE increment
materialpoint_F, & !< def grad of IP to be reached at end of FE increment materialpoint_F, & !< def grad of IP to be reached at end of FE increment
@ -26,9 +28,10 @@ module homogenization
materialpoint_dPdF !< tangent of first P--K stress at IP materialpoint_dPdF !< tangent of first P--K stress at IP
real(pReal), dimension(:,:,:), allocatable, public :: & real(pReal), dimension(:,:,:), allocatable, public :: &
materialpoint_results !< results array of material point materialpoint_results !< results array of material point
#ifndef NEWSTATE
type(p_vec), dimension(:,:), allocatable, public, protected :: & type(p_vec), dimension(:,:), allocatable, public, protected :: &
homogenization_state !< pointer array to current homogenization state (end of converged time step) homogenization_state !< pointer array to current homogenization state (end of converged time step)
#endif
integer(pInt), dimension(:,:), allocatable, public, protected :: & integer(pInt), dimension(:,:), allocatable, public, protected :: &
homogenization_sizeState !< size of state array per grain homogenization_sizeState !< size of state array per grain
integer(pInt), public, protected :: & integer(pInt), public, protected :: &
@ -175,9 +178,11 @@ subroutine homogenization_init()
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! allocate and initialize global variables ! allocate and initialize global variables
#ifndef NEWSTATE
allocate(homogenization_state0(mesh_maxNips,mesh_NcpElems)) allocate(homogenization_state0(mesh_maxNips,mesh_NcpElems))
allocate(homogenization_subState0(mesh_maxNips,mesh_NcpElems)) allocate(homogenization_subState0(mesh_maxNips,mesh_NcpElems))
allocate(homogenization_state(mesh_maxNips,mesh_NcpElems)) allocate(homogenization_state(mesh_maxNips,mesh_NcpElems))
#endif
allocate(homogenization_sizeState(mesh_maxNips,mesh_NcpElems), source=0_pInt) allocate(homogenization_sizeState(mesh_maxNips,mesh_NcpElems), source=0_pInt)
allocate(homogenization_sizePostResults(mesh_maxNips,mesh_NcpElems), source=0_pInt) allocate(homogenization_sizePostResults(mesh_maxNips,mesh_NcpElems), source=0_pInt)
allocate(materialpoint_heat(mesh_maxNips,mesh_NcpElems), source=0.0_pReal) allocate(materialpoint_heat(mesh_maxNips,mesh_NcpElems), source=0.0_pReal)
@ -207,18 +212,34 @@ subroutine homogenization_init()
#endif #endif
select case(homogenization_type(mesh_element(3,e))) select case(homogenization_type(mesh_element(3,e)))
case (HOMOGENIZATION_none_ID) case (HOMOGENIZATION_none_ID)
#ifdef NEWSTATE
homogenization_sizePostResults(i,e) = homogState(mappingHomogenization(2,i,e))%sizePostResults
#else
homogenization_sizePostResults(i,e) = 0_pInt homogenization_sizePostResults(i,e) = 0_pInt
#endif
case (HOMOGENIZATION_ISOSTRAIN_ID) case (HOMOGENIZATION_ISOSTRAIN_ID)
#ifdef NEWSTATE
homogenization_sizePostResults(i,e) = homogState(mappingHomogenization(2,i,e))%sizePostResults
#else
homogenization_sizePostResults(i,e) = homogenization_isostrain_sizePostResults(myInstance) homogenization_sizePostResults(i,e) = homogenization_isostrain_sizePostResults(myInstance)
#endif
case (HOMOGENIZATION_RGC_ID) case (HOMOGENIZATION_RGC_ID)
if (homogenization_RGC_sizeState(myInstance) > 0_pInt) then if (homogenization_RGC_sizeState(myInstance) > 0_pInt) then
#ifdef NEWSTATE
homogenization_sizeState(i,e) = homogState(mappingHomogenization(2,i,e))%sizeState
#else
allocate(homogenization_state0(i,e)%p(homogenization_RGC_sizeState(myInstance))) allocate(homogenization_state0(i,e)%p(homogenization_RGC_sizeState(myInstance)))
allocate(homogenization_subState0(i,e)%p(homogenization_RGC_sizeState(myInstance))) allocate(homogenization_subState0(i,e)%p(homogenization_RGC_sizeState(myInstance)))
allocate(homogenization_state(i,e)%p(homogenization_RGC_sizeState(myInstance))) allocate(homogenization_state(i,e)%p(homogenization_RGC_sizeState(myInstance)))
homogenization_state0(i,e)%p = 0.0_pReal homogenization_state0(i,e)%p = 0.0_pReal
homogenization_sizeState(i,e) = homogenization_RGC_sizeState(myInstance) homogenization_sizeState(i,e) = homogenization_RGC_sizeState(myInstance)
#endif
endif endif
#ifdef NEWSTATE
homogenization_sizePostResults(i,e) = homogState(mappingHomogenization(2,i,e))%sizePostResults
#else
homogenization_sizePostResults(i,e) = homogenization_RGC_sizePostResults(myInstance) homogenization_sizePostResults(i,e) = homogenization_RGC_sizePostResults(myInstance)
#endif
end select end select
enddo IpLooping enddo IpLooping
enddo elementLooping enddo elementLooping
@ -247,9 +268,11 @@ subroutine homogenization_init()
write(6,'(a15,a)') ' Current time: ',IO_timeStamp() write(6,'(a15,a)') ' Current time: ',IO_timeStamp()
#include "compilation_info.f90" #include "compilation_info.f90"
if (iand(debug_level(debug_homogenization), debug_levelBasic) /= 0_pInt) then if (iand(debug_level(debug_homogenization), debug_levelBasic) /= 0_pInt) then
#ifndef NEWSTATE
write(6,'(a32,1x,7(i8,1x))') 'homogenization_state0: ', shape(homogenization_state0) write(6,'(a32,1x,7(i8,1x))') 'homogenization_state0: ', shape(homogenization_state0)
write(6,'(a32,1x,7(i8,1x))') 'homogenization_subState0: ', shape(homogenization_subState0) write(6,'(a32,1x,7(i8,1x))') 'homogenization_subState0: ', shape(homogenization_subState0)
write(6,'(a32,1x,7(i8,1x))') 'homogenization_state: ', shape(homogenization_state) write(6,'(a32,1x,7(i8,1x))') 'homogenization_state: ', shape(homogenization_state)
#endif
write(6,'(a32,1x,7(i8,1x))') 'homogenization_sizeState: ', shape(homogenization_sizeState) write(6,'(a32,1x,7(i8,1x))') 'homogenization_sizeState: ', shape(homogenization_sizeState)
write(6,'(a32,1x,7(i8,1x),/)') 'homogenization_sizePostResults: ', shape(homogenization_sizePostResults) write(6,'(a32,1x,7(i8,1x),/)') 'homogenization_sizePostResults: ', shape(homogenization_sizePostResults)
write(6,'(a32,1x,7(i8,1x))') 'materialpoint_dPdF: ', shape(materialpoint_dPdF) write(6,'(a32,1x,7(i8,1x))') 'materialpoint_dPdF: ', shape(materialpoint_dPdF)
@ -301,6 +324,10 @@ subroutine materialpoint_stressAndItsTangent(updateJaco,dt)
plasticState, & plasticState, &
damageState, & damageState, &
thermalState, & thermalState, &
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
mappingConstitutive, & mappingConstitutive, &
homogenization_Ngrains homogenization_Ngrains
@ -388,8 +415,14 @@ subroutine materialpoint_stressAndItsTangent(updateJaco,dt)
materialpoint_converged(i,e) = .false. ! pretend failed step of twice the required size materialpoint_converged(i,e) = .false. ! pretend failed step of twice the required size
materialpoint_requested(i,e) = .true. ! everybody requires calculation materialpoint_requested(i,e) = .true. ! everybody requires calculation
endforall endforall
#ifdef NEWSTATE
forall(i = FEsolving_execIP(1,e):FEsolving_execIP(2,e), homogenization_sizeState(i,e) > 0_pInt) &
homogState(mappingHomogenization(2,i,e))%subState0(:,mappingHomogenization(1,i,e)) = &
homogState(mappingHomogenization(2,i,e))%State0(:,mappingHomogenization(1,i,e)) ! ...internal homogenization state
#else
forall(i = FEsolving_execIP(1,e):FEsolving_execIP(2,e), homogenization_sizeState(i,e) > 0_pInt) & forall(i = FEsolving_execIP(1,e):FEsolving_execIP(2,e), homogenization_sizeState(i,e) > 0_pInt) &
homogenization_subState0(i,e)%p = homogenization_state0(i,e)%p ! ...internal homogenization state homogenization_subState0(i,e)%p = homogenization_state0(i,e)%p ! ...internal homogenization state
#endif
enddo enddo
NiterationHomog = 0_pInt NiterationHomog = 0_pInt
@ -437,7 +470,12 @@ subroutine materialpoint_stressAndItsTangent(updateJaco,dt)
thermalState(mappingConstitutive(2,g,i,e))%state(:,mappingConstitutive(1,g,i,e)) thermalState(mappingConstitutive(2,g,i,e))%state(:,mappingConstitutive(1,g,i,e))
end forall end forall
if (homogenization_sizeState(i,e) > 0_pInt) & if (homogenization_sizeState(i,e) > 0_pInt) &
#ifdef NEWSTATE
homogState(mappingHomogenization(2,i,e))%subState0(:,mappingHomogenization(1,i,e)) = &
homogState(mappingHomogenization(2,i,e))%state(:,mappingHomogenization(1,i,e))
#else
homogenization_subState0(i,e)%p = homogenization_state(i,e)%p ! ...internal state of homog scheme homogenization_subState0(i,e)%p = homogenization_state(i,e)%p ! ...internal state of homog scheme
#endif
materialpoint_subF0(1:3,1:3,i,e) = materialpoint_subF(1:3,1:3,i,e) ! ...def grad materialpoint_subF0(1:3,1:3,i,e) = materialpoint_subF(1:3,1:3,i,e) ! ...def grad
!$OMP FLUSH(materialpoint_subF0) !$OMP FLUSH(materialpoint_subF0)
elseif (materialpoint_requested(i,e)) then steppingNeeded ! already at final time (??) elseif (materialpoint_requested(i,e)) then steppingNeeded ! already at final time (??)
@ -491,7 +529,12 @@ subroutine materialpoint_stressAndItsTangent(updateJaco,dt)
thermalState(mappingConstitutive(2,g,i,e))%partionedState0(:,mappingConstitutive(1,g,i,e)) thermalState(mappingConstitutive(2,g,i,e))%partionedState0(:,mappingConstitutive(1,g,i,e))
end forall end forall
if (homogenization_sizeState(i,e) > 0_pInt) & if (homogenization_sizeState(i,e) > 0_pInt) &
#ifdef NEWSTATE
homogState(mappingHomogenization(2,i,e))%state(:,mappingHomogenization(1,i,e)) = &
homogState(mappingHomogenization(2,i,e))%subState0(:,mappingHomogenization(1,i,e))
#else
homogenization_state(i,e)%p = homogenization_subState0(i,e)%p ! ...internal state of homog scheme homogenization_state(i,e)%p = homogenization_subState0(i,e)%p ! ...internal state of homog scheme
#endif
endif endif
endif converged endif converged
@ -703,12 +746,21 @@ subroutine homogenization_partitionDeformation(ip,el)
materialpoint_subF(1:3,1:3,ip,el),& materialpoint_subF(1:3,1:3,ip,el),&
el) el)
case (HOMOGENIZATION_RGC_ID) chosenHomogenization case (HOMOGENIZATION_RGC_ID) chosenHomogenization
#ifdef NEWSTATE
call homogenization_RGC_partitionDeformation(&
crystallite_partionedF(1:3,1:3,1:homogenization_maxNgrains,ip,el), &
materialpoint_subF(1:3,1:3,ip,el),&
ip, &
el)
#else
call homogenization_RGC_partitionDeformation(& call homogenization_RGC_partitionDeformation(&
crystallite_partionedF(1:3,1:3,1:homogenization_maxNgrains,ip,el), & crystallite_partionedF(1:3,1:3,1:homogenization_maxNgrains,ip,el), &
materialpoint_subF(1:3,1:3,ip,el),& materialpoint_subF(1:3,1:3,ip,el),&
homogenization_state(ip,el), & homogenization_state(ip,el), &
ip, & ip, &
el) el)
#endif
end select chosenHomogenization end select chosenHomogenization
end subroutine homogenization_partitionDeformation end subroutine homogenization_partitionDeformation
@ -743,7 +795,17 @@ function homogenization_updateState(ip,el)
case (HOMOGENIZATION_RGC_ID) chosenHomogenization case (HOMOGENIZATION_RGC_ID) chosenHomogenization
homogenization_updateState = & homogenization_updateState = &
homogenization_RGC_updateState( homogenization_state(ip,el), & #ifdef NEWSTATE
homogenization_RGC_updateState(crystallite_P(1:3,1:3,1:homogenization_maxNgrains,ip,el), &
crystallite_partionedF(1:3,1:3,1:homogenization_maxNgrains,ip,el), &
crystallite_partionedF0(1:3,1:3,1:homogenization_maxNgrains,ip,el),&
materialpoint_subF(1:3,1:3,ip,el),&
materialpoint_subdt(ip,el), &
crystallite_dPdF(1:3,1:3,1:3,1:3,1:homogenization_maxNgrains,ip,el), &
ip, &
el)
#else
homogenization_RGC_updateState(homogenization_state(ip,el), &
homogenization_subState0(ip,el), & homogenization_subState0(ip,el), &
crystallite_P(1:3,1:3,1:homogenization_maxNgrains,ip,el), & crystallite_P(1:3,1:3,1:homogenization_maxNgrains,ip,el), &
crystallite_partionedF(1:3,1:3,1:homogenization_maxNgrains,ip,el), & crystallite_partionedF(1:3,1:3,1:homogenization_maxNgrains,ip,el), &
@ -753,6 +815,7 @@ function homogenization_updateState(ip,el)
crystallite_dPdF(1:3,1:3,1:3,1:3,1:homogenization_maxNgrains,ip,el), & crystallite_dPdF(1:3,1:3,1:3,1:3,1:homogenization_maxNgrains,ip,el), &
ip, & ip, &
el) el)
#endif
case default chosenHomogenization case default chosenHomogenization
homogenization_updateState = .true. homogenization_updateState = .true.
end select chosenHomogenization end select chosenHomogenization
@ -869,12 +932,22 @@ function homogenization_postResults(ip,el)
materialpoint_P(1:3,1:3,ip,el), & materialpoint_P(1:3,1:3,ip,el), &
materialpoint_F(1:3,1:3,ip,el)) materialpoint_F(1:3,1:3,ip,el))
case (HOMOGENIZATION_RGC_ID) chosenHomogenization case (HOMOGENIZATION_RGC_ID) chosenHomogenization
#ifdef NEWSTATE
homogenization_postResults = homogenization_RGC_postResults(&
ip, &
el, &
materialpoint_P(1:3,1:3,ip,el), &
materialpoint_F(1:3,1:3,ip,el))
#else
homogenization_postResults = homogenization_RGC_postResults(& homogenization_postResults = homogenization_RGC_postResults(&
homogenization_state(ip,el),& homogenization_state(ip,el),&
ip, & ip, &
el, & el, &
materialpoint_P(1:3,1:3,ip,el), & materialpoint_P(1:3,1:3,ip,el), &
materialpoint_F(1:3,1:3,ip,el)) materialpoint_F(1:3,1:3,ip,el))
#endif
end select chosenHomogenization end select chosenHomogenization
end function homogenization_postResults end function homogenization_postResults

View File

@ -75,6 +75,9 @@ contains
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine homogenization_RGC_init(fileUnit) subroutine homogenization_RGC_init(fileUnit)
use, intrinsic :: iso_fortran_env ! to get compiler_version and compiler_options (at least for gfortran 4.6 at the moment) use, intrinsic :: iso_fortran_env ! to get compiler_version and compiler_options (at least for gfortran 4.6 at the moment)
use prec, only: &
pReal, &
pInt
use debug, only: & use debug, only: &
debug_level, & debug_level, &
debug_homogenization, & debug_homogenization, &
@ -100,6 +103,13 @@ subroutine homogenization_RGC_init(fileUnit)
integer(pInt), intent(in) :: fileUnit !< file pointer to material configuration integer(pInt), intent(in) :: fileUnit !< file pointer to material configuration
integer(pInt), parameter :: MAXNCHUNKS = 4_pInt integer(pInt), parameter :: MAXNCHUNKS = 4_pInt
integer(pInt), dimension(1_pInt+2_pInt*MAXNCHUNKS) :: positions integer(pInt), dimension(1_pInt+2_pInt*MAXNCHUNKS) :: positions
#ifdef NEWSTATE
integer :: &
homog, &
NofMyHomog, &
instance, &
sizeHState
#endif
integer(pInt) :: section=0_pInt, maxNinstance, i,j,e, output=-1_pInt, mySize, myInstance integer(pInt) :: section=0_pInt, maxNinstance, i,j,e, output=-1_pInt, mySize, myInstance
character(len=65536) :: & character(len=65536) :: &
tag = '', & tag = '', &
@ -267,14 +277,36 @@ subroutine homogenization_RGC_init(fileUnit)
+ 8_pInt ! (1) Average constitutive work, (2-4) Overall mismatch, (5) Average penalty energy, + 8_pInt ! (1) Average constitutive work, (2-4) Overall mismatch, (5) Average penalty energy,
! (6) Volume discrepancy, (7) Avg relaxation rate component, (8) Max relaxation rate component ! (6) Volume discrepancy, (7) Avg relaxation rate component, (8) Max relaxation rate component
enddo enddo
#ifdef NEWSTATE
initializeInstances: do homog = 1_pInt, material_Nhomogenization
myhomog: if (homogenization_type(homog) == HOMOGENIZATION_RGC_ID) then
NofMyHomog = count(material_homog == homog)
! instance = phase_plasticityInstance(phase)
! allocate homogenization state arrays
sizeHState = homogenization_RGC_sizeState(homog)
homogState(homog)%sizeState = sizeHState
homogState(homog)%sizePostResults = homogenization_RGC_sizePostResults(homog)
allocate(homogState(homog)%state0 ( sizeHState,NofMyHomog), source=0.0_pReal)
allocate(homogState(homog)%subState0 ( sizeHState,NofMyHomog), source=0.0_pReal)
allocate(homogState(homog)%state ( sizeHState,NofMyHomog), source=0.0_pReal)
endif myhomog
enddo initializeInstances
#endif
end subroutine homogenization_RGC_init end subroutine homogenization_RGC_init
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief partitions the deformation gradient onto the constituents !> @brief partitions the deformation gradient onto the constituents
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
#ifdef NEWSTATE
subroutine homogenization_RGC_partitionDeformation(F,avgF,ip,el)
#else
subroutine homogenization_RGC_partitionDeformation(F,avgF,state,ip,el) subroutine homogenization_RGC_partitionDeformation(F,avgF,state,ip,el)
#endif
use prec, only: & use prec, only: &
p_vec p_vec
use debug, only: & use debug, only: &
@ -286,6 +318,10 @@ subroutine homogenization_RGC_partitionDeformation(F,avgF,state,ip,el)
use material, only: & use material, only: &
homogenization_maxNgrains, & homogenization_maxNgrains, &
homogenization_Ngrains,& homogenization_Ngrains,&
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
homogenization_typeInstance homogenization_typeInstance
use FEsolving, only: & use FEsolving, only: &
theInc,& theInc,&
@ -294,7 +330,9 @@ subroutine homogenization_RGC_partitionDeformation(F,avgF,state,ip,el)
implicit none implicit none
real(pReal), dimension (3,3,homogenization_maxNgrains), intent(out) :: F !< partioned F per grain real(pReal), dimension (3,3,homogenization_maxNgrains), intent(out) :: F !< partioned F per grain
real(pReal), dimension (3,3), intent(in) :: avgF !< averaged F real(pReal), dimension (3,3), intent(in) :: avgF !< averaged F
#ifndef NEWSTATE
type(p_vec), intent(in) :: state type(p_vec), intent(in) :: state
#endif
integer(pInt), intent(in) :: & integer(pInt), intent(in) :: &
ip, & !< integration point number ip, & !< integration point number
el !< element number el !< element number
@ -326,7 +364,11 @@ subroutine homogenization_RGC_partitionDeformation(F,avgF,state,ip,el)
iGrain3 = homogenization_RGC_grain1to3(iGrain,homID) iGrain3 = homogenization_RGC_grain1to3(iGrain,homID)
do iFace = 1_pInt,nFace do iFace = 1_pInt,nFace
intFace = homogenization_RGC_getInterface(iFace,iGrain3) ! identifying 6 interfaces of each grain intFace = homogenization_RGC_getInterface(iFace,iGrain3) ! identifying 6 interfaces of each grain
#ifdef NEWSTATE
aVect = homogenization_RGC_relaxationVector(intFace,homID, ip, el) ! get the relaxation vectors for each interface from global relaxation vector array
#else
aVect = homogenization_RGC_relaxationVector(intFace,state,homID) ! get the relaxation vectors for each interface from global relaxation vector array aVect = homogenization_RGC_relaxationVector(intFace,state,homID) ! get the relaxation vectors for each interface from global relaxation vector array
#endif
nVect = homogenization_RGC_interfaceNormal(intFace,ip,el) ! get the normal of each interface nVect = homogenization_RGC_interfaceNormal(intFace,ip,el) ! get the normal of each interface
forall (i=1_pInt:3_pInt,j=1_pInt:3_pInt) & forall (i=1_pInt:3_pInt,j=1_pInt:3_pInt) &
F(i,j,iGrain) = F(i,j,iGrain) + aVect(i)*nVect(j) ! calculating deformation relaxations due to interface relaxation F(i,j,iGrain) = F(i,j,iGrain) + aVect(i)*nVect(j) ! calculating deformation relaxations due to interface relaxation
@ -355,7 +397,11 @@ end subroutine homogenization_RGC_partitionDeformation
!> @brief update the internal state of the homogenization scheme and tell whether "done" and !> @brief update the internal state of the homogenization scheme and tell whether "done" and
! "happy" with result ! "happy" with result
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
#ifdef NEWSTATE
function homogenization_RGC_updateState( P,F,F0,avgF,dt,dPdF,ip,el)
#else
function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el) function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el)
#endif
use prec, only: & use prec, only: &
p_vec p_vec
use debug, only: & use debug, only: &
@ -371,6 +417,10 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
use material, only: & use material, only: &
homogenization_maxNgrains, & homogenization_maxNgrains, &
homogenization_typeInstance, & homogenization_typeInstance, &
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
homogenization_Ngrains homogenization_Ngrains
use numerics, only: & use numerics, only: &
absTol_RGC, & absTol_RGC, &
@ -384,8 +434,10 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
refRelaxRate_RGC refRelaxRate_RGC
implicit none implicit none
#ifndef NEWSTATE
type(p_vec), intent(inout) :: state !< current state type(p_vec), intent(inout) :: state !< current state
type(p_vec), intent(in) :: state0 !< initial state type(p_vec), intent(in) :: state0 !< initial state
#endif
real(pReal), dimension (3,3,homogenization_maxNgrains), intent(in) :: & real(pReal), dimension (3,3,homogenization_maxNgrains), intent(in) :: &
P,& !< array of P P,& !< array of P
F,& !< array of F F,& !< array of F
@ -429,16 +481,28 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
! allocate the size of the global relaxation arrays/jacobian matrices depending on the size of the cluster ! allocate the size of the global relaxation arrays/jacobian matrices depending on the size of the cluster
allocate(resid(3_pInt*nIntFaceTot), source=0.0_pReal) allocate(resid(3_pInt*nIntFaceTot), source=0.0_pReal)
allocate(tract(nIntFaceTot,3), source=0.0_pReal) allocate(tract(nIntFaceTot,3), source=0.0_pReal)
#ifdef NEWSTATE
allocate(relax(3_pInt*nIntFaceTot)); relax= homogState(mappingHomogenization(2,ip,el))% &
state(1:3_pInt*nIntFaceTot,mappingHomogenization(1,ip,el))
allocate(drelax(3_pInt*nIntFaceTot)); drelax= homogState(mappingHomogenization(2,ip,el))% &
state(1:3_pInt*nIntFaceTot,mappingHomogenization(1,ip,el)) - &
homogState(mappingHomogenization(2,ip,el))% &
state0(1:3_pInt*nIntFaceTot,mappingHomogenization(1,ip,el))
#else
allocate(relax(3_pInt*nIntFaceTot)); relax=state%p(1:3_pInt*nIntFaceTot) allocate(relax(3_pInt*nIntFaceTot)); relax=state%p(1:3_pInt*nIntFaceTot)
allocate(drelax(3_pInt*nIntFaceTot)); drelax=state%p(1:3_pInt*nIntFaceTot)-state0%p(1:3_pInt*nIntFaceTot) allocate(drelax(3_pInt*nIntFaceTot)); drelax=state%p(1:3_pInt*nIntFaceTot)-state0%p(1:3_pInt*nIntFaceTot)
#endif
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! debugging the obtained state ! debugging the obtained state
if (iand(debug_level(debug_homogenization),debug_levelExtensive) /= 0_pInt) then if (iand(debug_level(debug_homogenization),debug_levelExtensive) /= 0_pInt) then
!$OMP CRITICAL (write2out) !$OMP CRITICAL (write2out)
write(6,'(1x,a30)')'Obtained state: ' write(6,'(1x,a30)')'Obtained state: '
do i = 1_pInt,3_pInt*nIntFaceTot do i = 1_pInt,3_pInt*nIntFaceTot
#ifdef NEWSTATE
write(6,'(1x,2(e15.8,1x))')homogState(mappingHomogenization(2,ip,el))%state(i,mappingHomogenization(1,ip,el))
#else
write(6,'(1x,2(e15.8,1x))')state%p(i) write(6,'(1x,2(e15.8,1x))')state%p(i)
#endif
enddo enddo
write(6,*)' ' write(6,*)' '
!$OMP END CRITICAL (write2out) !$OMP END CRITICAL (write2out)
@ -552,8 +616,13 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! compute/update the state for postResult, i.e., all energy densities computed by time-integration ! compute/update the state for postResult, i.e., all energy densities computed by time-integration
#ifdef NEWSTATE
constitutiveWork = homogState(mappingHomogenization(2,ip,el))%state(3*nIntFaceTot+1,mappingHomogenization(1,ip,el))
penaltyEnergy = homogState(mappingHomogenization(2,ip,el))%state(3*nIntFaceTot+5,mappingHomogenization(1,ip,el))
#else
constitutiveWork = state%p(3*nIntFaceTot+1) constitutiveWork = state%p(3*nIntFaceTot+1)
penaltyEnergy = state%p(3*nIntFaceTot+5) penaltyEnergy = state%p(3*nIntFaceTot+5)
#endif
do iGrain = 1_pInt,homogenization_Ngrains(mesh_element(3,el)) ! time-integration loop for the calculating the work and energy do iGrain = 1_pInt,homogenization_Ngrains(mesh_element(3,el)) ! time-integration loop for the calculating the work and energy
do i = 1_pInt,3_pInt do i = 1_pInt,3_pInt
do j = 1_pInt,3_pInt do j = 1_pInt,3_pInt
@ -562,6 +631,26 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
enddo enddo
enddo enddo
enddo enddo
#ifdef NEWSTATE
homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+1,mappingHomogenization(1,ip,el)) = constitutiveWork ! the bulk mechanical/constitutive work
homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+2,mappingHomogenization(1,ip,el)) = sum(NN(1,:))/real(nGrain,pReal) ! the overall mismatch of all interface normal to e1-direction
homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+3,mappingHomogenization(1,ip,el)) = sum(NN(2,:))/real(nGrain,pReal) ! the overall mismatch of all interface normal to e2-direction
homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+4,mappingHomogenization(1,ip,el)) = sum(NN(3,:))/real(nGrain,pReal) ! the overall mismatch of all interface normal to e3-direction
homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+5,mappingHomogenization(1,ip,el)) = penaltyEnergy ! the overall penalty energy
homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+6,mappingHomogenization(1,ip,el)) = volDiscrep ! the overall volume discrepancy
homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+7,mappingHomogenization(1,ip,el)) = &
sum(abs(drelax))/dt/real(3_pInt*nIntFaceTot,pReal) ! the average rate of relaxation vectors
homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+8,mappingHomogenization(1,ip,el)) = maxval(abs(drelax))/dt ! the maximum rate of relaxation vectors
#else
state%p(3*nIntFaceTot+1) = constitutiveWork ! the bulk mechanical/constitutive work state%p(3*nIntFaceTot+1) = constitutiveWork ! the bulk mechanical/constitutive work
state%p(3*nIntFaceTot+2) = sum(NN(1,:))/real(nGrain,pReal) ! the overall mismatch of all interface normal to e1-direction state%p(3*nIntFaceTot+2) = sum(NN(1,:))/real(nGrain,pReal) ! the overall mismatch of all interface normal to e1-direction
state%p(3*nIntFaceTot+3) = sum(NN(2,:))/real(nGrain,pReal) ! the overall mismatch of all interface normal to e2-direction state%p(3*nIntFaceTot+3) = sum(NN(2,:))/real(nGrain,pReal) ! the overall mismatch of all interface normal to e2-direction
@ -571,6 +660,7 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
state%p(3*nIntFaceTot+7) = sum(abs(drelax))/dt/real(3_pInt*nIntFaceTot,pReal) ! the average rate of relaxation vectors state%p(3*nIntFaceTot+7) = sum(abs(drelax))/dt/real(3_pInt*nIntFaceTot,pReal) ! the average rate of relaxation vectors
state%p(3*nIntFaceTot+8) = maxval(abs(drelax))/dt ! the maximum rate of relaxation vectors state%p(3*nIntFaceTot+8) = maxval(abs(drelax))/dt ! the maximum rate of relaxation vectors
#endif
if (iand(debug_level(debug_homogenization),debug_levelExtensive) /= 0_pInt & if (iand(debug_level(debug_homogenization),debug_levelExtensive) /= 0_pInt &
.and. debug_e == el .and. debug_i == ip) then .and. debug_e == el .and. debug_i == ip) then
!$OMP CRITICAL (write2out) !$OMP CRITICAL (write2out)
@ -639,8 +729,8 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
do i=1_pInt,3_pInt; do j=1_pInt,3_pInt; do k=1_pInt,3_pInt; do l=1_pInt,3_pInt do i=1_pInt,3_pInt; do j=1_pInt,3_pInt; do k=1_pInt,3_pInt; do l=1_pInt,3_pInt
smatrix(3*(iNum-1)+i,3*(iMun-1)+j) = smatrix(3*(iNum-1)+i,3*(iMun-1)+j) + dPdF(i,k,j,l,iGrN)*normN(k)*mornN(l) smatrix(3*(iNum-1)+i,3*(iMun-1)+j) = smatrix(3*(iNum-1)+i,3*(iMun-1)+j) + dPdF(i,k,j,l,iGrN)*normN(k)*mornN(l)
enddo;enddo;enddo;enddo enddo;enddo;enddo;enddo
! projecting the material tangent dPdF into the interface ! projecting the material tangent dPdF into the interface
! to obtain the Jacobian matrix contribution of dPdF ! to obtain the Jacobian matrix contribution of dPdF
endif endif
enddo enddo
@ -685,8 +775,13 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
do ipert = 1_pInt,3_pInt*nIntFaceTot do ipert = 1_pInt,3_pInt*nIntFaceTot
p_relax = relax p_relax = relax
p_relax(ipert) = relax(ipert) + pPert_RGC ! perturb the relaxation vector p_relax(ipert) = relax(ipert) + pPert_RGC ! perturb the relaxation vector
#ifdef NEWSTATE
homogState(mappingHomogenization(2,ip,el))%state(1:3*nIntFaceTot,mappingHomogenization(1,ip,el)) = p_relax
call homogenization_RGC_grainDeformation(pF,avgF,ip,el) ! compute the grains deformation from perturbed state
#else
state%p(1:3*nIntFaceTot) = p_relax state%p(1:3*nIntFaceTot) = p_relax
call homogenization_RGC_grainDeformation(pF,avgF,state,ip,el) ! compute the grains deformation from perturbed state call homogenization_RGC_grainDeformation(pF,avgF,state,ip,el) ! compute the grains deformation from perturbed state
#endif
call homogenization_RGC_stressPenalty(pR,pNN,avgF,pF,ip,el,homID) ! compute stress penalty due to interface mismatch from perturbed state call homogenization_RGC_stressPenalty(pR,pNN,avgF,pF,ip,el,homID) ! compute stress penalty due to interface mismatch from perturbed state
call homogenization_RGC_volumePenalty(pD,volDiscrep,pF,avgF,ip,el) ! compute stress penalty due to volume discrepancy from perturbed state call homogenization_RGC_volumePenalty(pD,volDiscrep,pF,avgF,ip,el) ! compute stress penalty due to volume discrepancy from perturbed state
@ -801,7 +896,11 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
enddo enddo
enddo enddo
relax = relax + drelax ! Updateing the state variable for the next iteration relax = relax + drelax ! Updateing the state variable for the next iteration
#ifdef NEWSTATE
homogState(mappingHomogenization(2,ip,el))%state(1:3*nIntFaceTot,mappingHomogenization(1,ip,el)) = relax
#else
state%p(1:3*nIntFaceTot) = relax state%p(1:3*nIntFaceTot) = relax
#endif
if (any(abs(drelax) > maxdRelax_RGC)) then ! Forcing cutback when the incremental change of relaxation vector becomes too large if (any(abs(drelax) > maxdRelax_RGC)) then ! Forcing cutback when the incremental change of relaxation vector becomes too large
homogenization_RGC_updateState = [.true.,.false.] homogenization_RGC_updateState = [.true.,.false.]
!$OMP CRITICAL (write2out) !$OMP CRITICAL (write2out)
@ -817,7 +916,11 @@ function homogenization_RGC_updateState( state, state0,P,F,F0,avgF,dt,dPdF,ip,el
!$OMP CRITICAL (write2out) !$OMP CRITICAL (write2out)
write(6,'(1x,a30)')'Returned state: ' write(6,'(1x,a30)')'Returned state: '
do i = 1_pInt,3_pInt*nIntFaceTot do i = 1_pInt,3_pInt*nIntFaceTot
#ifdef NEWSTATE
write(6,'(1x,2(e15.8,1x))')homogState(mappingHomogenization(2,ip,el))%state(i,mappingHomogenization(1,ip,el))
#else
write(6,'(1x,2(e15.8,1x))')state%p(i) write(6,'(1x,2(e15.8,1x))')state%p(i)
#endif
enddo enddo
write(6,*)' ' write(6,*)' '
flush(6) flush(6)
@ -838,7 +941,14 @@ subroutine homogenization_RGC_averageStressAndItsTangent(avgP,dAvgPdAvgF,P,dPdF,
debug_homogenization,& debug_homogenization,&
debug_levelExtensive debug_levelExtensive
use mesh, only: mesh_element use mesh, only: mesh_element
use material, only: homogenization_maxNgrains,homogenization_Ngrains,homogenization_typeInstance use material, only: &
homogenization_maxNgrains, &
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
homogenization_Ngrains, &
homogenization_typeInstance
use math, only: math_Plain3333to99 use math, only: math_Plain3333to99
implicit none implicit none
@ -881,7 +991,11 @@ end subroutine homogenization_RGC_averageStressAndItsTangent
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief return array of homogenization results for post file inclusion !> @brief return array of homogenization results for post file inclusion
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
#ifdef NEWSTATE
pure function homogenization_RGC_postResults(ip,el,avgP,avgF)
#else
pure function homogenization_RGC_postResults(state,ip,el,avgP,avgF) pure function homogenization_RGC_postResults(state,ip,el,avgP,avgF)
#endif
use prec, only: & use prec, only: &
p_vec p_vec
use mesh, only: & use mesh, only: &
@ -889,6 +1003,10 @@ pure function homogenization_RGC_postResults(state,ip,el,avgP,avgF)
mesh_ipCoordinates mesh_ipCoordinates
use material, only: & use material, only: &
homogenization_typeInstance,& homogenization_typeInstance,&
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
homogenization_Noutput homogenization_Noutput
use crystallite, only: & use crystallite, only: &
crystallite_temperature crystallite_temperature
@ -900,8 +1018,10 @@ pure function homogenization_RGC_postResults(state,ip,el,avgP,avgF)
real(pReal), dimension(3,3), intent(in) :: & real(pReal), dimension(3,3), intent(in) :: &
avgP, & !< average stress at material point avgP, & !< average stress at material point
avgF !< average deformation gradient at material point avgF !< average deformation gradient at material point
#ifndef NEWSTATE
type(p_vec), intent(in) :: & type(p_vec), intent(in) :: &
state ! my State state ! my State
#endif
integer(pInt) homID,o,c,nIntFaceTot integer(pInt) homID,o,c,nIntFaceTot
real(pReal), dimension(homogenization_RGC_sizePostResults(homogenization_typeInstance(mesh_element(3,el)))) :: & real(pReal), dimension(homogenization_RGC_sizePostResults(homogenization_typeInstance(mesh_element(3,el)))) :: &
homogenization_RGC_postResults homogenization_RGC_postResults
@ -928,25 +1048,63 @@ pure function homogenization_RGC_postResults(state,ip,el,avgP,avgF)
homogenization_RGC_postResults(c+1_pInt:c+3_pInt) = mesh_ipCoordinates(1:3,ip,el) ! current ip coordinates homogenization_RGC_postResults(c+1_pInt:c+3_pInt) = mesh_ipCoordinates(1:3,ip,el) ! current ip coordinates
c = c + 3_pInt c = c + 3_pInt
case (constitutivework_ID) case (constitutivework_ID)
#ifdef NEWSTATE
homogenization_RGC_postResults(c+1) = homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+1,mappingHomogenization(1,ip,el))
#else
homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+1) homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+1)
#endif
c = c + 1_pInt c = c + 1_pInt
case (magnitudemismatch_ID) case (magnitudemismatch_ID)
#ifdef NEWSTATE
homogenization_RGC_postResults(c+1) = homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+2,mappingHomogenization(1,ip,el))
homogenization_RGC_postResults(c+2) = homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+3,mappingHomogenization(1,ip,el))
homogenization_RGC_postResults(c+3) = homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+4,mappingHomogenization(1,ip,el))
#else
homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+2) homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+2)
homogenization_RGC_postResults(c+2) = state%p(3*nIntFaceTot+3) homogenization_RGC_postResults(c+2) = state%p(3*nIntFaceTot+3)
homogenization_RGC_postResults(c+3) = state%p(3*nIntFaceTot+4) homogenization_RGC_postResults(c+3) = state%p(3*nIntFaceTot+4)
#endif
c = c + 3_pInt c = c + 3_pInt
case (penaltyenergy_ID) case (penaltyenergy_ID)
#ifdef NEWSTATE
homogenization_RGC_postResults(c+1) = homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+5,mappingHomogenization(1,ip,el))
c = c + 1_pInt
#else
homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+5) homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+5)
c = c + 1_pInt c = c + 1_pInt
#endif
case (volumediscrepancy_ID) case (volumediscrepancy_ID)
#ifdef NEWSTATE
homogenization_RGC_postResults(c+1) = homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+6,mappingHomogenization(1,ip,el))
c = c + 1_pInt
#else
homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+6) homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+6)
c = c + 1_pInt c = c + 1_pInt
#endif
case (averagerelaxrate_ID) case (averagerelaxrate_ID)
#ifdef NEWSTATE
homogenization_RGC_postResults(c+1) = homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+7,mappingHomogenization(1,ip,el))
c = c + 1_pInt
#else
homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+7) homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+7)
c = c + 1_pInt c = c + 1_pInt
#endif
case (maximumrelaxrate_ID) case (maximumrelaxrate_ID)
#ifdef NEWSTATE
homogenization_RGC_postResults(c+1) = homogState(mappingHomogenization(2,ip,el))% &
state(3*nIntFaceTot+8,mappingHomogenization(1,ip,el))
c = c + 1_pInt
#else
homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+8) homogenization_RGC_postResults(c+1) = state%p(3*nIntFaceTot+8)
c = c + 1_pInt c = c + 1_pInt
#endif
end select end select
enddo enddo
@ -972,6 +1130,10 @@ subroutine homogenization_RGC_stressPenalty(rPen,nMis,avgF,fDef,ip,el,homID)
math_invert33 math_invert33
use material, only: & use material, only: &
homogenization_maxNgrains,& homogenization_maxNgrains,&
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
homogenization_Ngrains homogenization_Ngrains
use numerics, only: & use numerics, only: &
xSmoo_RGC xSmoo_RGC
@ -1111,6 +1273,10 @@ subroutine homogenization_RGC_volumePenalty(vPen,vDiscrep,fDef,fAvg,ip,el)
math_inv33 math_inv33
use material, only: & use material, only: &
homogenization_maxNgrains,& homogenization_maxNgrains,&
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
homogenization_Ngrains homogenization_Ngrains
use numerics, only: & use numerics, only: &
maxVolDiscr_RGC,& maxVolDiscr_RGC,&
@ -1170,6 +1336,11 @@ function homogenization_RGC_surfaceCorrection(avgF,ip,el)
use math, only: & use math, only: &
math_invert33, & math_invert33, &
math_mul33x33 math_mul33x33
#ifdef NEWSTATE
use material, only: &
homogState, &
mappingHomogenization
#endif
implicit none implicit none
real(pReal), dimension(3) :: homogenization_RGC_surfaceCorrection real(pReal), dimension(3) :: homogenization_RGC_surfaceCorrection
@ -1239,14 +1410,28 @@ end function homogenization_RGC_equivalentModuli
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief collect relaxation vectors of an interface !> @brief collect relaxation vectors of an interface
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
#ifdef NEWSTATE
function homogenization_RGC_relaxationVector(intFace,homID, ip, el)
#else
function homogenization_RGC_relaxationVector(intFace,state,homID) function homogenization_RGC_relaxationVector(intFace,state,homID)
#endif
use prec, only: & use prec, only: &
p_vec p_vec
#ifdef NEWSTATE
use material, only: &
homogState, &
mappingHomogenization
#endif
implicit none implicit none
#ifdef NEWSTATE
integer(pInt), intent(in) :: ip, el
#endif
real(pReal), dimension (3) :: homogenization_RGC_relaxationVector real(pReal), dimension (3) :: homogenization_RGC_relaxationVector
integer(pInt), dimension (4), intent(in) :: intFace !< set of interface ID in 4D array (normal and position) integer(pInt), dimension (4), intent(in) :: intFace !< set of interface ID in 4D array (normal and position)
#ifndef NEWSTATE
type(p_vec), intent(in) :: state !< set of global relaxation vectors type(p_vec), intent(in) :: state !< set of global relaxation vectors
#endif
integer(pInt), dimension (3) :: nGDim integer(pInt), dimension (3) :: nGDim
integer(pInt) :: & integer(pInt) :: &
iNum, & iNum, &
@ -1257,7 +1442,12 @@ function homogenization_RGC_relaxationVector(intFace,state,homID)
homogenization_RGC_relaxationVector = 0.0_pReal homogenization_RGC_relaxationVector = 0.0_pReal
nGDim = homogenization_RGC_Ngrains(1:3,homID) nGDim = homogenization_RGC_Ngrains(1:3,homID)
iNum = homogenization_RGC_interface4to1(intFace,homID) ! identify the position of the interface in global state array iNum = homogenization_RGC_interface4to1(intFace,homID) ! identify the position of the interface in global state array
#ifdef NEWSTATE
if (iNum > 0_pInt) homogenization_RGC_relaxationVector = homogState(mappingHomogenization(2,ip,el))% &
state((3*iNum-2):(3*iNum),mappingHomogenization(1,ip,el)) ! get the corresponding entries
#else
if (iNum > 0_pInt) homogenization_RGC_relaxationVector = state%p((3*iNum-2):(3*iNum)) ! get the corresponding entries if (iNum > 0_pInt) homogenization_RGC_relaxationVector = state%p((3*iNum-2):(3*iNum)) ! get the corresponding entries
#endif
end function homogenization_RGC_relaxationVector end function homogenization_RGC_relaxationVector
@ -1471,7 +1661,11 @@ end function homogenization_RGC_interface1to4
!> @brief calculating the grain deformation gradient (the same with !> @brief calculating the grain deformation gradient (the same with
! homogenization_RGC_partionDeformation, but used only for perturbation scheme) ! homogenization_RGC_partionDeformation, but used only for perturbation scheme)
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
#ifdef NEWSTATE
subroutine homogenization_RGC_grainDeformation(F, avgF, ip, el)
#else
subroutine homogenization_RGC_grainDeformation(F, avgF, state, ip, el) subroutine homogenization_RGC_grainDeformation(F, avgF, state, ip, el)
#endif
use prec, only: & use prec, only: &
p_vec p_vec
use mesh, only: & use mesh, only: &
@ -1479,12 +1673,18 @@ subroutine homogenization_RGC_grainDeformation(F, avgF, state, ip, el)
use material, only: & use material, only: &
homogenization_maxNgrains,& homogenization_maxNgrains,&
homogenization_Ngrains, & homogenization_Ngrains, &
#ifdef NEWSTATE
homogState, &
mappingHomogenization, &
#endif
homogenization_typeInstance homogenization_typeInstance
implicit none implicit none
real(pReal), dimension (3,3,homogenization_maxNgrains), intent(out) :: F !< partioned F per grain real(pReal), dimension (3,3,homogenization_maxNgrains), intent(out) :: F !< partioned F per grain
real(pReal), dimension (3,3), intent(in) :: avgF !< real(pReal), dimension (3,3), intent(in) :: avgF !<
#ifndef NEWSTATE
type(p_vec), intent(in) :: state type(p_vec), intent(in) :: state
#endif
integer(pInt), intent(in) :: & integer(pInt), intent(in) :: &
el, & !< element number el, & !< element number
ip !< integration point number ip !< integration point number
@ -1502,7 +1702,11 @@ subroutine homogenization_RGC_grainDeformation(F, avgF, state, ip, el)
iGrain3 = homogenization_RGC_grain1to3(iGrain,homID) iGrain3 = homogenization_RGC_grain1to3(iGrain,homID)
do iFace = 1_pInt,nFace do iFace = 1_pInt,nFace
intFace = homogenization_RGC_getInterface(iFace,iGrain3) intFace = homogenization_RGC_getInterface(iFace,iGrain3)
#ifdef NEWSTATE
aVect = homogenization_RGC_relaxationVector(intFace,homID, ip, el)
#else
aVect = homogenization_RGC_relaxationVector(intFace,state,homID) aVect = homogenization_RGC_relaxationVector(intFace,state,homID)
#endif
nVect = homogenization_RGC_interfaceNormal(intFace,ip,el) nVect = homogenization_RGC_interfaceNormal(intFace,ip,el)
forall (i=1_pInt:3_pInt,j=1_pInt:3_pInt) & forall (i=1_pInt:3_pInt,j=1_pInt:3_pInt) &
F(i,j,iGrain) = F(i,j,iGrain) + aVect(i)*nVect(j) ! effective relaxations F(i,j,iGrain) = F(i,j,iGrain) + aVect(i)*nVect(j) ! effective relaxations

View File

@ -51,6 +51,9 @@ contains
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine homogenization_isostrain_init(fileUnit) subroutine homogenization_isostrain_init(fileUnit)
use, intrinsic :: iso_fortran_env ! to get compiler_version and compiler_options (at least for gfortran 4.6 at the moment) use, intrinsic :: iso_fortran_env ! to get compiler_version and compiler_options (at least for gfortran 4.6 at the moment)
use prec, only: &
pReal, &
pInt
use IO use IO
use material use material
@ -61,7 +64,15 @@ subroutine homogenization_isostrain_init(fileUnit)
integer(pInt) :: & integer(pInt) :: &
section = 0_pInt, i, j, output, mySize section = 0_pInt, i, j, output, mySize
integer :: & integer :: &
maxNinstance, k ! no pInt (stores a system dependen value from 'count' maxNinstance, &
#ifdef NEWSTATE
homog, &
NofMyHomog, &
instance, &
sizeHState, &
#endif
k
! no pInt (stores a system dependen value from 'count'
character(len=65536) :: & character(len=65536) :: &
tag = '', & tag = '', &
line = '' line = ''
@ -144,6 +155,24 @@ subroutine homogenization_isostrain_init(fileUnit)
endif endif
enddo enddo
#ifdef NEWSTATE
initializeInstances: do homog = 1_pInt, material_Nhomogenization
myhomog: if (homogenization_type(homog) == HOMOGENIZATION_ISOSTRAIN_ID) then
NofMyHomog = count(material_homog == homog)
! instance = phase_plasticityInstance(phase)
! allocate homogenization state arrays
sizeHState = 0_pInt
homogState(homog)%sizeState = sizeHState
homogState(homog)%sizePostResults = homogenization_isostrain_sizePostResults(homog)
allocate(homogState(homog)%state0 ( sizeHState,NofMyHomog), source=0.0_pReal)
allocate(homogState(homog)%subState0 ( sizeHState,NofMyHomog), source=0.0_pReal)
allocate(homogState(homog)%state ( sizeHState,NofMyHomog), source=0.0_pReal)
endif myhomog
enddo initializeInstances
#endif
do i = 1,maxNinstance do i = 1,maxNinstance
do j = 1_pInt,maxval(homogenization_Noutput) do j = 1_pInt,maxval(homogenization_Noutput)

View File

@ -21,18 +21,45 @@ contains
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine homogenization_none_init() subroutine homogenization_none_init()
use, intrinsic :: iso_fortran_env ! to get compiler_version and compiler_options (at least for gfortran 4.6 at the moment) use, intrinsic :: iso_fortran_env ! to get compiler_version and compiler_options (at least for gfortran 4.6 at the moment)
use prec, only: &
pReal, &
pInt
use IO, only: & use IO, only: &
IO_timeStamp IO_timeStamp
use material, only: & use material
HOMOGENIZATION_NONE_label
implicit none implicit none
#ifdef NEWSTATE
integer :: &
homog, &
NofMyHomog, &
instance, &
sizeHState
#endif
write(6,'(/,a)') ' <<<+- homogenization_'//HOMOGENIZATION_NONE_label//' init -+>>>' write(6,'(/,a)') ' <<<+- homogenization_'//HOMOGENIZATION_NONE_label//' init -+>>>'
write(6,'(a)') ' $Id$' write(6,'(a)') ' $Id$'
write(6,'(a15,a)') ' Current time: ',IO_timeStamp() write(6,'(a15,a)') ' Current time: ',IO_timeStamp()
#include "compilation_info.f90" #include "compilation_info.f90"
#ifdef NEWSTATE
initializeInstances: do homog = 1_pInt, material_Nhomogenization
myhomog: if (homogenization_type(homog) == HOMOGENIZATION_none_ID) then
NofMyHomog = count(material_homog == homog)
! instance = phase_plasticityInstance(phase)
! allocate homogenization state arrays
sizeHState = 0_pInt
homogState(homog)%sizeState = sizeHState
homogState(homog)%sizePostResults = 0_pInt
allocate(homogState(homog)%state0 ( sizeHState,NofMyHomog), source=0.0_pReal)
allocate(homogState(homog)%subState0 ( sizeHState,NofMyHomog), source=0.0_pReal)
allocate(homogState(homog)%state ( sizeHState,NofMyHomog), source=0.0_pReal)
endif myhomog
enddo initializeInstances
#endif
end subroutine homogenization_none_init end subroutine homogenization_none_init
end module homogenization_none end module homogenization_none

View File

@ -13,6 +13,9 @@ module material
pReal, & pReal, &
pInt, & pInt, &
tState, & tState, &
#ifdef NEWSTATE
hState, &
#endif
p_intvec p_intvec
implicit none implicit none
@ -116,12 +119,19 @@ module material
integer(pInt), dimension(:,:,:), allocatable, public :: & integer(pInt), dimension(:,:,:), allocatable, public :: &
material_phase !< phase (index) of each grain,IP,element material_phase !< phase (index) of each grain,IP,element
#ifdef NEWSTATE
integer(pInt), dimension(:,:), allocatable, public :: &
material_homog !< homogenization (index) of each IP,element
#endif
type(tState), allocatable, dimension(:), public :: & type(tState), allocatable, dimension(:), public :: &
plasticState, & plasticState, &
elasticState, & elasticState, &
damageState, & damageState, &
thermalState thermalState
#ifdef NEWSTATE
type(hState), allocatable, dimension(:), public :: &
homogState
#endif
integer(pInt), dimension(:,:,:), allocatable, public, protected :: & integer(pInt), dimension(:,:,:), allocatable, public, protected :: &
@ -177,8 +187,14 @@ module material
integer(pInt), dimension(:,:,:,:), allocatable, public, protected :: mappingConstitutive integer(pInt), dimension(:,:,:,:), allocatable, public, protected :: mappingConstitutive
integer(pInt), dimension(:,:,:), allocatable, public, protected :: mappingCrystallite integer(pInt), dimension(:,:,:), allocatable, public, protected :: mappingCrystallite
#ifdef NEWSTATE
integer(pInt), dimension(:,:,:), allocatable, public, protected :: mappingHomogenization
#endif
integer(pInt), dimension(:), allocatable :: ConstitutivePosition integer(pInt), dimension(:), allocatable :: ConstitutivePosition
integer(pInt), dimension(:), allocatable :: CrystallitePosition integer(pInt), dimension(:), allocatable :: CrystallitePosition
#ifdef NEWSTATE
integer(pInt), dimension(:), allocatable :: HomogenizationPosition
#endif
public :: & public :: &
@ -242,7 +258,7 @@ subroutine material_init
implicit none implicit none
integer(pInt), parameter :: FILEUNIT = 200_pInt integer(pInt), parameter :: FILEUNIT = 200_pInt
integer(pInt) :: m,c,h, myDebug integer(pInt) :: m,c,h, myDebug, myHomogInstance
integer(pInt) :: & integer(pInt) :: &
g, & !< grain number g, & !< grain number
i, & !< integration point number i, & !< integration point number
@ -273,7 +289,9 @@ subroutine material_init
allocate(elasticState(material_Nphase)) allocate(elasticState(material_Nphase))
allocate(damageState (material_Nphase)) allocate(damageState (material_Nphase))
allocate(thermalState(material_Nphase)) allocate(thermalState(material_Nphase))
#ifdef NEWSTATE
allocate(homogState(material_Nhomogenization))
#endif
do m = 1_pInt,material_Nmicrostructure do m = 1_pInt,material_Nmicrostructure
if(microstructure_crystallite(m) < 1_pInt .or. & if(microstructure_crystallite(m) < 1_pInt .or. &
microstructure_crystallite(m) > material_Ncrystallite) & microstructure_crystallite(m) > material_Ncrystallite) &
@ -313,11 +331,22 @@ subroutine material_init
call material_populateGrains call material_populateGrains
allocate(mappingConstitutive(2,homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems),source=0_pInt) allocate(mappingConstitutive(2,homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems),source=0_pInt)
#ifdef NEWSTATE
allocate(mappingHomogenization(2,mesh_maxNips,mesh_NcpElems),source=0_pInt)
#endif
allocate(mappingCrystallite (2,homogenization_maxNgrains,mesh_NcpElems),source=0_pInt) allocate(mappingCrystallite (2,homogenization_maxNgrains,mesh_NcpElems),source=0_pInt)
allocate(ConstitutivePosition(material_Nphase),source=0_pInt) allocate(ConstitutivePosition(material_Nphase),source=0_pInt)
#ifdef NEWSTATE
allocate(HomogenizationPosition(material_Nhomogenization),source=0_pInt)
#endif
allocate(CrystallitePosition(material_Nphase),source=0_pInt) allocate(CrystallitePosition(material_Nphase),source=0_pInt)
ElemLoop:do e = 1_pInt,mesh_NcpElems ! loop over elements ElemLoop:do e = 1_pInt,mesh_NcpElems ! loop over elements
myHomogInstance = homogenization_typeInstance(mesh_element(3,e))
IPloop:do i = 1_pInt,FE_Nips(FE_geomtype(mesh_element(2,e))) ! loop over IPs IPloop:do i = 1_pInt,FE_Nips(FE_geomtype(mesh_element(2,e))) ! loop over IPs
#ifdef NEWSTATE
HomogenizationPosition(myHomogInstance) = HomogenizationPosition(myHomogInstance)+1_pInt
mappingHomogenization(1:2,i,e) = [HomogenizationPosition(myHomogInstance),myHomogInstance]
#endif
GrainLoop:do g = 1_pInt,homogenization_Ngrains(mesh_element(3,e)) ! loop over grains GrainLoop:do g = 1_pInt,homogenization_Ngrains(mesh_element(3,e)) ! loop over grains
phase = material_phase(g,i,e) phase = material_phase(g,i,e)
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
@ -941,9 +970,9 @@ subroutine material_populateGrains
real(pReal), dimension (3) :: orientation real(pReal), dimension (3) :: orientation
real(pReal), dimension (3,3) :: symOrientation real(pReal), dimension (3,3) :: symOrientation
integer(pInt), dimension (:), allocatable :: phaseOfGrain, textureOfGrain integer(pInt), dimension (:), allocatable :: phaseOfGrain, textureOfGrain
integer(pInt) :: t,e,i,g,j,m,c,r,homog,micro,sgn,hme, myDebug, & integer(pInt) :: t,e,i,ii,g,j,m,c,r,homog,micro,sgn,hme, myDebug, &
phaseID,textureID,dGrains,myNgrains,myNorientations,myNconstituents, & phaseID,textureID,dGrains,myNgrains,myNorientations,myNconstituents, &
grain,constituentGrain,ipGrain,symExtension, ip grain,constituentGrain,ipGrain,symExtension, ip, HomogInstType
real(pReal) :: extreme,rnd real(pReal) :: extreme,rnd
integer(pInt), dimension (:,:), allocatable :: Nelems ! counts number of elements in homog, micro array integer(pInt), dimension (:,:), allocatable :: Nelems ! counts number of elements in homog, micro array
type(p_intvec), dimension (:,:), allocatable :: elemsOfHomogMicro ! lists element number in homog, micro array type(p_intvec), dimension (:,:), allocatable :: elemsOfHomogMicro ! lists element number in homog, micro array
@ -952,12 +981,25 @@ subroutine material_populateGrains
allocate(material_volume(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0.0_pReal) allocate(material_volume(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0.0_pReal)
allocate(material_phase(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0_pInt) allocate(material_phase(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0_pInt)
#ifdef NEWSTATE
allocate(material_homog(mesh_maxNips,mesh_NcpElems), source=0_pInt)
#endif
allocate(material_texture(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0_pInt) allocate(material_texture(homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems), source=0_pInt)
allocate(material_EulerAngles(3,homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems),source=0.0_pReal) allocate(material_EulerAngles(3,homogenization_maxNgrains,mesh_maxNips,mesh_NcpElems),source=0.0_pReal)
allocate(Ngrains(material_Nhomogenization,material_Nmicrostructure), source=0_pInt) allocate(Ngrains(material_Nhomogenization,material_Nmicrostructure), source=0_pInt)
allocate(Nelems(material_Nhomogenization,material_Nmicrostructure), source=0_pInt) allocate(Nelems(material_Nhomogenization,material_Nmicrostructure), source=0_pInt)
#ifdef NEWSTATE
! populating homogenization schemes in each
!--------------------------------------------------------------------------------------------------
do e = 1_pInt, mesh_NcpElems
! do i = 1_pInt:FE_Nips(FE_geomtype(mesh_element(2,e)))
material_homog(1_pInt:FE_Nips(FE_geomtype(mesh_element(2,e))),e)=homogenization_typeInstance(mesh_element(3,e))
! enddo
enddo
#endif
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! precounting of elements for each homog/micro pair ! precounting of elements for each homog/micro pair
do e = 1_pInt, mesh_NcpElems do e = 1_pInt, mesh_NcpElems

View File

@ -77,6 +77,15 @@ module prec
RK4dotState RK4dotState
real(pReal), allocatable, dimension(:,:,:) :: RKCK45dotState real(pReal), allocatable, dimension(:,:,:) :: RKCK45dotState
end type end type
#ifdef NEWSTATE
type, public :: hState
integer(pInt) :: sizeState = 0_pInt , &
sizePostResults = 0_pInt
real(pReal), allocatable, dimension(:,:) :: state, & ! material points, state size
state0, &
subState0
end type
#endif
public :: & public :: &
prec_init prec_init