store debug options once

This commit is contained in:
Sharan Roongta 2020-07-01 19:54:14 +02:00
parent 57e4d01a6b
commit b0ce55de7a
2 changed files with 68 additions and 39 deletions

View File

@ -51,6 +51,17 @@ module CPFEM
type(tNumerics), private :: num
type, private :: tDebugOptions
logical :: &
basic, &
extensive
integer:: &
element, &
ip
end type tDebugOptions
type(tDebugOptions), private :: debug
public :: &
CPFEM_general, &
CPFEM_initAll, &
@ -108,10 +119,18 @@ subroutine CPFEM_init
num_commercialFEM => numerics_root%get('commercialFEM',defaultVal=emptyDict)
num%iJacoStiffness = num_commercialFEM%get_asInt('ijacostiffness',defaultVal=1)
if (num%iJacoStiffness < 1) call IO_error(301,ext_msg='iJacoStiffness')
!------------------------------------------------------------------------------
! read debug options
debug_CPFEM => debug_root%get('cpfem',defaultVal=emptyList)
if(debug_CPFEM%contains('basic')) then
debug%basic = debug_CPFEM%contains('basic')
debug%extensive = debug_CPFEM%contains('extensive')
debug%selective = debug_CPFEM%contains('selective')
debug%element = debug_root%get_asInt('element',defaultVal = 1)
debug%ip = debug_root%get_asInt('integrationpoint',defaultVal = 1)
if(debug%basic) then
write(6,'(a32,1x,6(i8,1x))') 'CPFEM_cs: ', shape(CPFEM_cs)
write(6,'(a32,1x,6(i8,1x))') 'CPFEM_dcsdE: ', shape(CPFEM_dcsdE)
write(6,'(a32,1x,6(i8,1x),/)') 'CPFEM_dcsdE_knownGood: ', shape(CPFEM_dcsdE_knownGood)
@ -149,16 +168,11 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature_inp, dt, elFE, ip, cauchyS
real(pReal), parameter :: ODD_STRESS = 1e15_pReal, & !< return value for stress if terminallyIll
ODD_JACOBIAN = 1e50_pReal !< return value for jacobian if terminallyIll
class(tNode), pointer :: &
debug_CPFEM
elCP = mesh_FEM2DAMASK_elem(elFE)
debug_CPFEM => debug_root%get('cpfem',defaultVal=emptyList)
if (debug_CPFEM%contains('basic') &
.and. elCP == debug_root%get_asInt('element',defaultVal=1) &
.and. ip == debug_root%get_asInt('integrationpoint',defaultVal=1)) then
if (debug%basic .and. elCP == debug%element &
.and. ip == debug%ip) then
write(6,'(/,a)') '#############################################'
write(6,'(a1,a22,1x,i8,a13)') '#','element', elCP, '#'
write(6,'(a1,a22,1x,i8,a13)') '#','ip', ip, '#'
@ -196,7 +210,7 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature_inp, dt, elFE, ip, cauchyS
updateJaco = mod(cycleCounter,num%iJacoStiffness) == 0
FEsolving_execElem = elCP
FEsolving_execIP = ip
if (debug_CPFEM%contains('extensive')) &
if (debug%extensive) &
write(6,'(a,i8,1x,i2)') '<< CPFEM >> calculation for elFE ip ',elFE,ip
call materialpoint_stressAndItsTangent(updateJaco, dt)
@ -233,10 +247,9 @@ subroutine CPFEM_general(mode, ffn, ffn1, temperature_inp, dt, elFE, ip, cauchyS
endif terminalIllness
endif validCalculation
if (debug_CPFEM%contains('extensive') &
.and. ((debug_root%get_asInt('element',defaultVal=1) == elCP &
.and. debug_root%get_asInt('integrationpoint',defaultVal=1) == ip) &
.or. .not. debug_CPFEM%contains('selective'))) then
if (debug%extensive &
.and. (debug%element == elCP .and. debug%ip == ip) &
.or. .not. debug%selective) then
write(6,'(a,i8,1x,i2,/,12x,6(f10.3,1x)/)') &
'<< CPFEM >> stress/MPa at elFE ip ', elFE, ip, CPFEM_cs(1:6,ip,elCP)*1.0e-6_pReal
write(6,'(a,i8,1x,i2,/,6(12x,6(f10.3,1x)/))') &

View File

@ -98,6 +98,22 @@ module crystallite
type(tNumerics) :: num ! numerics parameters. Better name?
#ifdef DEBUG
type :: tDebugOptions
logical :: &
basic, &
extensive, &
selective
integer :: &
element, &
ip, &
grain
end type tDebugOptions
type(tDebugOptions) :: debug
#endif
procedure(integrateStateFPI), pointer :: integrateState
public :: &
@ -135,6 +151,17 @@ subroutine crystallite_init
write(6,'(/,a)') ' <<<+- crystallite init -+>>>'
#ifdef DEBUG
debug_crystallite => debug_root%get('crystallite', defaultVal=emptyList)
debug%basic = debug_crystallite%contains('basic')
debug%extensive = debug_crystallite%contains('extensive')
debug%selective = debug_crystallite%contains('selective')
debug%element = debug_root%get_asInt('element', defaultVal=1)
debug%ip = debug_root%get_asInt('integrationpoint', defaultVal=1)
debug%grain = debug_root%get_asInt('grain', defaultVal=1)
#endif
cMax = homogenization_maxNgrains
iMax = discretization_nIP
eMax = discretization_nElem
@ -271,8 +298,7 @@ subroutine crystallite_init
call crystallite_stressTangent
#ifdef DEBUG
debug_crystallite => debug_root%get('crystallite',defaultVal=emptyList)
if (debug_crystallite%contains('basic')) then
if (debug%basic) then
write(6,'(a42,1x,i10)') ' # of elements: ', eMax
write(6,'(a42,1x,i10)') ' # of integration points/element: ', iMax
write(6,'(a42,1x,i10)') 'max # of constituents/integration point: ', cMax
@ -298,38 +324,28 @@ function crystallite_stress()
i, & !< counter in integration point loop
e, & !< counter in element loop
startIP, endIP, &
s, &
debug_e, &
debug_g, &
debug_i
s
logical, dimension(homogenization_maxNgrains,discretization_nIP,discretization_nElem) :: todo !ToDo: need to set some values to false for different Ngrains
class(tNode), pointer :: &
debug_crystallite
todo = .false.
#ifdef DEBUG
debug_e = debug_root%get_asInt('element',defaultVal=1)
debug_i = debug_root%get_asInt('integrationpoint',defaultVal=1)
debug_g = debug_root%get_asInt('grain',defaultVal=1)
debug_crystallite => debug_root%get('crystallite',defaultVal=emptyList)
if (debug_crystallite%contains('selective') &
.and. FEsolving_execElem(1) <= debug_e &
.and. debug_e <= FEsolving_execElem(2)) then
#ifdef DEBUG
if (debug%selective &
.and. FEsolving_execElem(1) <= debug%element &
.and. debug%element <= FEsolving_execElem(2)) then
write(6,'(/,a,i8,1x,i2,1x,i3)') '<< CRYST stress >> boundary and initial values at el ip ipc ', &
debug_e,debug_i, debug_g
debug%element,debug%ip, debug%grain
write(6,'(a,/,3(12x,3(f14.9,1x)/))') '<< CRYST stress >> F ', &
transpose(crystallite_partionedF(1:3,1:3,debug_g,debug_i,debug_e))
transpose(crystallite_partionedF(1:3,1:3,debug%grain,debug%ip,debug%element))
write(6,'(a,/,3(12x,3(f14.9,1x)/))') '<< CRYST stress >> F0 ', &
transpose(crystallite_partionedF0(1:3,1:3,debug_g,debug_i,debug_e))
transpose(crystallite_partionedF0(1:3,1:3,debug%grain,debug%ip,debug%element))
write(6,'(a,/,3(12x,3(f14.9,1x)/))') '<< CRYST stress >> Fp0', &
transpose(crystallite_partionedFp0(1:3,1:3,debug_g,debug_i,debug_e))
transpose(crystallite_partionedFp0(1:3,1:3,debug%grain,debug%ip,debug%element))
write(6,'(a,/,3(12x,3(f14.9,1x)/))') '<< CRYST stress >> Fi0', &
transpose(crystallite_partionedFi0(1:3,1:3,debug_g,debug_i,debug_e))
transpose(crystallite_partionedFi0(1:3,1:3,debug%grain,debug%ip,debug%element))
write(6,'(a,/,3(12x,3(f14.9,1x)/))') '<< CRYST stress >> Lp0', &
transpose(crystallite_partionedLp0(1:3,1:3,debug_g,debug_i,debug_e))
transpose(crystallite_partionedLp0(1:3,1:3,debug%grain,debug%ip,debug%element))
write(6,'(a,/,3(12x,3(f14.9,1x)/))') '<< CRYST stress >> Li0', &
transpose(crystallite_partionedLi0(1:3,1:3,debug_g,debug_i,debug_e))
transpose(crystallite_partionedLi0(1:3,1:3,debug%grain,debug%ip,debug%element))
endif
#endif
@ -375,7 +391,7 @@ function crystallite_stress()
NiterationCrystallite = NiterationCrystallite + 1
#ifdef DEBUG
if (debug_crystallite%contains('extensive')) &
if (debug%extensive) &
write(6,'(a,i6)') '<< CRYST stress >> crystallite iteration ',NiterationCrystallite
#endif
!$OMP PARALLEL DO PRIVATE(formerSubStep)