2009-03-04 19:31:36 +05:30
|
|
|
!##############################################################
|
|
|
|
MODULE CPFEM
|
|
|
|
!##############################################################
|
|
|
|
! *** CPFEM engine ***
|
|
|
|
!
|
|
|
|
use prec, only: pReal,pInt
|
|
|
|
implicit none
|
|
|
|
!
|
|
|
|
! ****************************************************************
|
|
|
|
! *** General variables for the material behaviour calculation ***
|
|
|
|
! ****************************************************************
|
2009-05-07 21:57:36 +05:30
|
|
|
real(pReal), dimension (:,:,:), allocatable :: CPFEM_cs ! Cauchy stress
|
|
|
|
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_dcsdE ! Cauchy stress tangent
|
|
|
|
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_dcsdE_knownGood ! known good tangent
|
2009-03-04 19:31:36 +05:30
|
|
|
|
|
|
|
logical :: CPFEM_init_done = .false. ! remember whether init has been done already
|
|
|
|
logical :: CPFEM_calc_done = .false. ! remember whether first IP has already calced the results
|
|
|
|
|
|
|
|
real(pReal), parameter :: CPFEM_odd_stress = 1e15_pReal, CPFEM_odd_jacobian = 1e50_pReal
|
|
|
|
!
|
|
|
|
CONTAINS
|
|
|
|
!
|
|
|
|
!*********************************************************
|
|
|
|
!*** allocate the arrays defined in module CPFEM ***
|
|
|
|
!*** and initialize them ***
|
|
|
|
!*********************************************************
|
2009-05-07 21:57:36 +05:30
|
|
|
SUBROUTINE CPFEM_init()
|
|
|
|
|
|
|
|
use prec, only: pInt,pReal
|
|
|
|
use FEsolving, only: parallelExecution,symmetricSolver,FEsolving_execElem,FEsolving_execIP
|
|
|
|
use mesh, only: mesh_element,mesh_NcpElems,mesh_maxNips,FE_Nips
|
|
|
|
use material, only: homogenization_maxNgrains
|
|
|
|
use constitutive, only: constitutive_maxSizePostResults
|
|
|
|
use crystallite, only: crystallite_Nresults
|
|
|
|
use homogenization, only: homogenization_maxSizePostResults
|
|
|
|
|
2009-03-04 19:31:36 +05:30
|
|
|
implicit none
|
|
|
|
integer(pInt) e,i,g
|
|
|
|
|
2009-05-07 21:57:36 +05:30
|
|
|
allocate(CPFEM_cs(6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_cs = 0.0_pReal
|
|
|
|
allocate(CPFEM_dcsdE(6,6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_dcsde = 0.0_pReal
|
|
|
|
allocate(CPFEM_dcsdE_knownGood(6,6,mesh_maxNips,mesh_NcpElems)) ; CPFEM_dcsde_knownGood = 0.0_pReal
|
2009-03-04 19:31:36 +05:30
|
|
|
|
|
|
|
|
|
|
|
! *** Output to MARC output file ***
|
|
|
|
!$OMP CRITICAL (write2out)
|
|
|
|
write(6,*)
|
2009-05-07 21:57:36 +05:30
|
|
|
write(6,*) '<<<+- cpfem init -+>>>'
|
2009-03-04 19:31:36 +05:30
|
|
|
write(6,*)
|
2009-05-07 21:57:36 +05:30
|
|
|
write(6,'(a32,x,6(i5,x))') 'CPFEM_cs: ', shape(CPFEM_cs)
|
|
|
|
write(6,'(a32,x,6(i5,x))') 'CPFEM_dcsde: ', shape(CPFEM_dcsde)
|
|
|
|
write(6,'(a32,x,6(i5,x))') 'CPFEM_dcsde_knownGood: ', shape(CPFEM_dcsde_knownGood)
|
2009-03-04 19:31:36 +05:30
|
|
|
write(6,*)
|
|
|
|
write(6,*) 'parallelExecution: ', parallelExecution
|
2009-05-07 21:57:36 +05:30
|
|
|
write(6,*) 'symmetricSolver: ', symmetricSolver
|
2009-03-04 19:31:36 +05:30
|
|
|
call flush(6)
|
|
|
|
!$OMP END CRITICAL (write2out)
|
|
|
|
return
|
|
|
|
!
|
|
|
|
END SUBROUTINE
|
|
|
|
!
|
|
|
|
!
|
|
|
|
!***********************************************************************
|
|
|
|
!*** perform initialization at first call, update variables and ***
|
|
|
|
!*** call the actual material model ***
|
|
|
|
!
|
|
|
|
! CPFEM_mode computation mode (regular, collection, recycle)
|
|
|
|
! ffn deformation gradient for t=t0
|
|
|
|
! ffn1 deformation gradient for t=t1
|
|
|
|
! Temperature temperature
|
|
|
|
! CPFEM_dt time increment
|
|
|
|
! CPFEM_en element number
|
|
|
|
! CPFEM_in intergration point number
|
|
|
|
! CPFEM_stress stress vector in Mandel notation
|
|
|
|
! CPFEM_updateJaco flag to initiate computation of Jacobian
|
|
|
|
! CPFEM_jaco jacobian in Mandel notation
|
|
|
|
! CPFEM_ngens size of stress strain law
|
|
|
|
!***********************************************************************
|
2009-05-07 21:57:36 +05:30
|
|
|
subroutine CPFEM_general(CPFEM_mode, ffn, ffn1, Temperature, CPFEM_dt,&
|
|
|
|
CPFEM_en, CPFEM_in, CPFEM_stress, CPFEM_updateJaco, CPFEM_jaco, CPFEM_ngens)
|
2009-03-04 19:31:36 +05:30
|
|
|
! note: CPFEM_stress = Cauchy stress cs(6) and CPFEM_jaco = Consistent tangent dcs/de
|
|
|
|
!
|
2009-05-07 21:57:36 +05:30
|
|
|
use prec, only: pReal,pInt
|
2009-03-04 19:31:36 +05:30
|
|
|
use FEsolving
|
|
|
|
use debug
|
|
|
|
use math
|
2009-05-07 21:57:36 +05:30
|
|
|
use mesh, only: mesh_init,&
|
|
|
|
mesh_FEasCP,mesh_element,mesh_NcpElems,mesh_maxNips,FE_Nips
|
|
|
|
use lattice, only: lattice_init
|
|
|
|
use material, only: material_init, homogenization_maxNgrains
|
|
|
|
use constitutive, only: constitutive_init,&
|
|
|
|
constitutive_state0,constitutive_state
|
|
|
|
use crystallite
|
|
|
|
use homogenization
|
2009-03-04 19:31:36 +05:30
|
|
|
implicit none
|
2009-05-07 21:57:36 +05:30
|
|
|
|
2009-03-04 19:31:36 +05:30
|
|
|
integer(pInt) CPFEM_en, CPFEM_in, cp_en, CPFEM_ngens, i,j,k,l,m,n
|
2009-05-07 21:57:36 +05:30
|
|
|
real(pReal), dimension (3,3) :: ffn,ffn1,Kirchhoff
|
|
|
|
real(pReal), dimension (3,3,3,3) :: H, H_sym
|
2009-03-04 19:31:36 +05:30
|
|
|
real(pReal), dimension(CPFEM_ngens) :: CPFEM_stress
|
2009-03-05 19:48:50 +05:30
|
|
|
real(pReal), dimension(CPFEM_ngens,CPFEM_ngens) :: CPFEM_jaco
|
2009-03-04 19:31:36 +05:30
|
|
|
real(pReal) Temperature,CPFEM_dt,J_inverse
|
|
|
|
integer(pInt) CPFEM_mode ! 1: regular computation with aged results&
|
|
|
|
! 2: regular computation&
|
|
|
|
! 3: collection of FEM data&
|
|
|
|
! 4: recycling of former results (MARC speciality)&
|
|
|
|
! 5: record tangent from former converged inc&
|
|
|
|
! 6: restore tangent from former converged inc
|
2009-05-07 21:57:36 +05:30
|
|
|
integer(pInt) e
|
|
|
|
logical CPFEM_updateJaco
|
|
|
|
|
2009-03-04 19:31:36 +05:30
|
|
|
if (.not. CPFEM_init_done) then ! initialization step (three dimensional stress state check missing?)
|
|
|
|
call math_init()
|
|
|
|
call FE_init()
|
|
|
|
call mesh_init()
|
2009-05-07 21:57:36 +05:30
|
|
|
|
|
|
|
FEsolving_execElem = (/1,mesh_NcpElems/)
|
|
|
|
allocate(FEsolving_execIP(2,mesh_NcpElems)); FEsolving_execIP = 1_pInt
|
|
|
|
forall (e = 1:mesh_NcpElems) FEsolving_execIP(2,e) = FE_Nips(mesh_element(2,e))
|
|
|
|
|
2009-03-04 19:31:36 +05:30
|
|
|
call lattice_init()
|
|
|
|
call material_init()
|
|
|
|
call constitutive_init()
|
2009-05-07 21:57:36 +05:30
|
|
|
call crystallite_init()
|
|
|
|
call homogenization_init()
|
|
|
|
call CPFEM_init()
|
2009-03-04 19:31:36 +05:30
|
|
|
CPFEM_init_done = .true.
|
|
|
|
endif
|
2009-05-07 21:57:36 +05:30
|
|
|
|
2009-03-04 19:31:36 +05:30
|
|
|
cp_en = mesh_FEasCP('elem',CPFEM_en)
|
|
|
|
if (cp_en == 1 .and. CPFEM_in == 1) then
|
2009-05-07 21:57:36 +05:30
|
|
|
write(6,*) '#####################################'
|
2009-03-04 19:31:36 +05:30
|
|
|
write(6,'(a10,1x,f8.4,1x,a10,1x,i4,1x,a10,1x,i3,1x,a10,1x,i2,x,a10,1x,i2)') &
|
|
|
|
'theTime',theTime,'theInc',theInc,'theCycle',theCycle,'theLovl',theLovl,&
|
|
|
|
'mode',CPFEM_mode
|
2009-05-07 21:57:36 +05:30
|
|
|
write(6,*) '#####################################'
|
2009-03-04 19:31:36 +05:30
|
|
|
endif
|
2009-05-07 21:57:36 +05:30
|
|
|
|
2009-03-04 19:31:36 +05:30
|
|
|
select case (CPFEM_mode)
|
|
|
|
case (1,2) ! regular computation (with aging of results if mode == 1)
|
|
|
|
if (CPFEM_mode == 1) then ! age results at start of new increment
|
2009-05-07 21:57:36 +05:30
|
|
|
crystallite_F0 = crystallite_partionedF ! crystallite deformation (_subF is perturbed...)
|
|
|
|
crystallite_Fp0 = crystallite_Fp ! crystallite plastic deformation
|
|
|
|
crystallite_Lp0 = crystallite_Lp ! crystallite plastic velocity
|
2009-03-04 19:31:36 +05:30
|
|
|
forall (i = 1:homogenization_maxNgrains,&
|
|
|
|
j = 1:mesh_maxNips, &
|
|
|
|
k = 1:mesh_NcpElems) &
|
2009-05-07 21:57:36 +05:30
|
|
|
constitutive_state0(i,j,k)%p = constitutive_state(i,j,k)%p ! microstructure of crystallites
|
|
|
|
write(6,'(a10,/,4(3(f10.3,x),/))') 'aged state',constitutive_state(1,1,1)%p/1e6
|
|
|
|
do j = 1,mesh_maxNips
|
|
|
|
do k = 1,mesh_NcpElems
|
|
|
|
if (homogenization_sizeState(j,k) > 0_pInt) &
|
|
|
|
homogenization_state0(j,k)%p = homogenization_state(j,k)%p ! internal state of homogenization scheme
|
|
|
|
enddo
|
|
|
|
enddo
|
2009-03-04 19:31:36 +05:30
|
|
|
endif
|
|
|
|
|
2009-05-07 21:57:36 +05:30
|
|
|
if (outdatedFFN1 .or. any(abs(ffn1 - materialpoint_F(:,:,CPFEM_in,cp_en)) > relevantStrain)) then
|
|
|
|
if (.not. outdatedFFN1) write(6,'(a11,x,i5,x,i2,x,a10,/,3(3(f10.3,x),/))') 'outdated at',cp_en,CPFEM_in,'FFN1 now:',ffn1(:,1),ffn1(:,2),ffn1(:,3)
|
2009-03-04 19:31:36 +05:30
|
|
|
outdatedFFN1 = .true.
|
2009-05-07 21:57:36 +05:30
|
|
|
CPFEM_cs(1:CPFEM_ngens,CPFEM_in,cp_en) = CPFEM_odd_stress
|
|
|
|
CPFEM_dcsde(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en) = CPFEM_odd_jacobian*math_identity2nd(CPFEM_ngens)
|
2009-03-04 19:31:36 +05:30
|
|
|
else
|
|
|
|
if (.not. parallelExecution) then
|
2009-05-07 21:57:36 +05:30
|
|
|
FEsolving_execElem(1) = cp_en
|
|
|
|
FEsolving_execElem(2) = cp_en
|
|
|
|
FEsolving_execIP(1,cp_en) = CPFEM_in
|
|
|
|
FEsolving_execIP(2,cp_en) = CPFEM_in
|
|
|
|
call materialpoint_stressAndItsTangent(CPFEM_updateJaco, CPFEM_dt)
|
|
|
|
call materialpoint_postResults(CPFEM_dt)
|
2009-03-04 19:31:36 +05:30
|
|
|
elseif (.not. CPFEM_calc_done) then
|
2009-05-07 21:57:36 +05:30
|
|
|
call materialpoint_stressAndItsTangent(CPFEM_updateJaco, CPFEM_dt) ! parallel execution inside
|
|
|
|
call materialpoint_postResults(CPFEM_dt)
|
2009-03-04 19:31:36 +05:30
|
|
|
CPFEM_calc_done = .true.
|
|
|
|
endif
|
|
|
|
|
|
|
|
! translate from P and dP/dF to CS and dCS/dE
|
2009-05-07 21:57:36 +05:30
|
|
|
Kirchhoff = math_mul33x33(materialpoint_P(:,:,CPFEM_in, cp_en),transpose(materialpoint_F(:,:,CPFEM_in, cp_en)))
|
|
|
|
J_inverse = 1.0_pReal/math_det3x3(materialpoint_F(:,:,CPFEM_in, cp_en))
|
|
|
|
CPFEM_cs(1:CPFEM_ngens,CPFEM_in,cp_en) = math_Mandel33to6(J_inverse*Kirchhoff)
|
|
|
|
|
|
|
|
H = 0.0_pReal
|
2009-03-04 19:31:36 +05:30
|
|
|
forall(i=1:3,j=1:3,k=1:3,l=1:3,m=1:3,n=1:3) &
|
2009-05-07 21:57:36 +05:30
|
|
|
H(i,j,k,l) = H(i,j,k,l) + &
|
|
|
|
materialpoint_F(j,m,CPFEM_in,cp_en) * &
|
|
|
|
materialpoint_F(l,n,CPFEM_in,cp_en) * &
|
|
|
|
materialpoint_dPdF(i,m,k,n,CPFEM_in,cp_en) - &
|
|
|
|
math_I3(j,l)*materialpoint_F(i,m,CPFEM_in,cp_en)*materialpoint_P(k,m,CPFEM_in,cp_en) + &
|
|
|
|
0.5_pReal*(math_I3(i,k)*Kirchhoff(j,l) + math_I3(j,l)*Kirchhoff(i,k) + &
|
|
|
|
math_I3(i,l)*Kirchhoff(j,k) + math_I3(j,k)*Kirchhoff(i,l))
|
2009-03-04 19:31:36 +05:30
|
|
|
forall(i=1:3,j=1:3,k=1:3,l=1:3) &
|
2009-05-07 21:57:36 +05:30
|
|
|
H_sym(i,j,k,l)= 0.25_pReal*(H(i,j,k,l)+H(j,i,k,l)+H(i,j,l,k)+H(j,i,l,k)) ! where to use the symmetric version??
|
|
|
|
CPFEM_dcsde(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en) = math_Mandel3333to66(J_inverse*H)
|
2009-03-04 19:31:36 +05:30
|
|
|
endif
|
|
|
|
case (3) ! collect and return odd result
|
2009-05-07 21:57:36 +05:30
|
|
|
materialpoint_Temperature(CPFEM_in,cp_en) = Temperature
|
|
|
|
materialpoint_F0(:,:,CPFEM_in,cp_en) = ffn
|
|
|
|
materialpoint_F(:,:,CPFEM_in,cp_en) = ffn1
|
|
|
|
CPFEM_cs(1:CPFEM_ngens,CPFEM_in,cp_en) = CPFEM_odd_stress
|
|
|
|
CPFEM_dcsde(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en) = CPFEM_odd_jacobian*math_identity2nd(CPFEM_ngens)
|
2009-03-04 19:31:36 +05:30
|
|
|
CPFEM_calc_done = .false.
|
|
|
|
|
|
|
|
case (4) ! do nothing since we can recycle the former results (MARC specialty)
|
2009-05-07 21:57:36 +05:30
|
|
|
case (5) ! record consistent tangent at beginning of new FE increment (while recycling)
|
|
|
|
CPFEM_dcsde_knownGood = CPFEM_dcsde
|
|
|
|
case (6) ! restore consistent tangent after FE cutback
|
|
|
|
CPFEM_dcsde = CPFEM_dcsde_knownGood
|
2009-03-04 19:31:36 +05:30
|
|
|
end select
|
|
|
|
|
2009-05-07 21:57:36 +05:30
|
|
|
! return the local stress and the jacobian from storage
|
|
|
|
CPFEM_stress(1:CPFEM_ngens) = CPFEM_cs(1:CPFEM_ngens,CPFEM_in,cp_en)
|
|
|
|
CPFEM_jaco(1:CPFEM_ngens,1:CPFEM_ngens) = CPFEM_dcsdE(1:CPFEM_ngens,1:CPFEM_ngens,CPFEM_in,cp_en)
|
2009-03-04 19:31:36 +05:30
|
|
|
|
|
|
|
return
|
|
|
|
|
2009-05-07 21:57:36 +05:30
|
|
|
end subroutine
|
2009-03-04 19:31:36 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
END MODULE
|
2009-03-05 19:48:50 +05:30
|
|
|
!##############################################################
|