diff --git a/src/IO.f90 b/src/IO.f90 index cc90cbbb2..33c4a778d 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -823,8 +823,6 @@ subroutine IO_error(error_ID,el,ip,g,instance,ext_msg) msg = 'microstructure count mismatch' case (846_pInt) msg = 'rotation for load case rotation ill-defined (R:RT != I)' - case (847_pInt) - msg = 'update of gamma operator not possible when pre-calculated' case (880_pInt) msg = 'mismatch of microstructure count and a*b*c in geom file' case (891_pInt) diff --git a/src/grid_mech_spectral_basic.f90 b/src/grid_mech_spectral_basic.f90 index d38090ae3..f17f2f8fd 100644 --- a/src/grid_mech_spectral_basic.f90 +++ b/src/grid_mech_spectral_basic.f90 @@ -23,6 +23,13 @@ module grid_mech_spectral_basic !-------------------------------------------------------------------------------------------------- ! derived types type(tSolutionParams), private :: params + + type, private :: tNumerics + logical :: & + update_gamma !< update gamma operator with current stiffness + end type tNumerics + + type(tNumerics) :: num ! numerics parameters. Better name? !-------------------------------------------------------------------------------------------------- ! PETSc data @@ -79,6 +86,8 @@ subroutine grid_mech_spectral_basic_init IO_open_jobFile_binary use FEsolving, only: & restartInc + use config, only :& + config_numerics use numerics, only: & worldrank, & worldsize, & @@ -117,6 +126,8 @@ subroutine grid_mech_spectral_basic_init write(6,'(/,a)') ' Shanthraj et al., International Journal of Plasticity 66:31–45, 2015' write(6,'(a)') ' https://doi.org/10.1016/j.ijplas.2014.02.006' + + num%update_gamma = config_numerics%getInt('update_gamma',defaultVal=0) > 0 !-------------------------------------------------------------------------------------------------- ! set default and user defined options for PETSc @@ -209,8 +220,6 @@ end subroutine grid_mech_spectral_basic_init !> @brief solution for the basic scheme with internal iterations !-------------------------------------------------------------------------------------------------- function grid_mech_spectral_basic_solution(incInfoIn,timeinc,timeinc_old,stress_BC,rotation_BC) result(solution) - use numerics, only: & - update_gamma use spectral_utilities, only: & tBoundaryCondition, & utilities_maskedCompliance, & @@ -243,7 +252,7 @@ function grid_mech_spectral_basic_solution(incInfoIn,timeinc,timeinc_old,stress_ !-------------------------------------------------------------------------------------------------- ! update stiffness (and gamma operator) S = Utilities_maskedCompliance(rotation_BC,stress_BC%maskLogical,C_volAvg) - if (update_gamma) call Utilities_updateGamma(C_minMaxAvg,restartWrite) + if (num%update_gamma) call Utilities_updateGamma(C_minMaxAvg,restartWrite) !-------------------------------------------------------------------------------------------------- ! set module wide available data diff --git a/src/grid_mech_spectral_polarisation.f90 b/src/grid_mech_spectral_polarisation.f90 index 0bebdcb82..0a5501e98 100644 --- a/src/grid_mech_spectral_polarisation.f90 +++ b/src/grid_mech_spectral_polarisation.f90 @@ -22,8 +22,15 @@ module grid_mech_spectral_polarisation !-------------------------------------------------------------------------------------------------- ! derived types - type(tSolutionParams), private :: params - + type(tSolutionParams), private :: params + + type, private :: tNumerics + logical :: & + update_gamma !< update gamma operator with current stiffness + end type tNumerics + + type(tNumerics) :: num ! numerics parameters. Better name? + !-------------------------------------------------------------------------------------------------- ! PETSc data DM, private :: da @@ -85,6 +92,8 @@ subroutine grid_mech_spectral_polarisation_init IO_open_jobFile_binary use FEsolving, only: & restartInc + use config, only :& + config_numerics use numerics, only: & worldrank, & worldsize, & @@ -94,9 +103,9 @@ subroutine grid_mech_spectral_polarisation_init use DAMASK_interface, only: & getSolverJobName use spectral_utilities, only: & - utilities_constitutiveResponse, & - utilities_updateGamma, & - utilities_updateIPcoords, & + utilities_constitutiveResponse, & + utilities_updateGamma, & + utilities_updateIPcoords, & wgt use mesh, only: & grid, & @@ -122,6 +131,8 @@ subroutine grid_mech_spectral_polarisation_init write(6,'(/,a)') ' Shanthraj et al., International Journal of Plasticity 66:31–45, 2015' write(6,'(a)') ' https://doi.org/10.1016/j.ijplas.2014.02.006' + + num%update_gamma = config_numerics%getInt('update_gamma',defaultVal=0) > 0 !-------------------------------------------------------------------------------------------------- ! set default and user defined options for PETSc @@ -226,8 +237,6 @@ end subroutine grid_mech_spectral_polarisation_init !> @brief solution for the Polarisation scheme with internal iterations !-------------------------------------------------------------------------------------------------- function grid_mech_spectral_polarisation_solution(incInfoIn,timeinc,timeinc_old,stress_BC,rotation_BC) result(solution) - use numerics, only: & - update_gamma use math, only: & math_invSym3333 use spectral_utilities, only: & @@ -262,7 +271,7 @@ function grid_mech_spectral_polarisation_solution(incInfoIn,timeinc,timeinc_old, !-------------------------------------------------------------------------------------------------- ! update stiffness (and gamma operator) S = Utilities_maskedCompliance(rotation_BC,stress_BC%maskLogical,C_volAvg) - if (update_gamma) then + if (num%update_gamma) then call utilities_updateGamma(C_minMaxAvg,restartWrite) C_scale = C_minMaxAvg S_scale = math_invSym3333(C_minMaxAvg) diff --git a/src/numerics.f90 b/src/numerics.f90 index b3bf664fb..955696219 100644 --- a/src/numerics.f90 +++ b/src/numerics.f90 @@ -94,9 +94,8 @@ module numerics &-thermal_snes_type ngmres ', & petsc_options = '' logical, protected, public :: & - continueCalculation = .false., & !< false:exit if BVP solver does not converge, true: continue calculation despite BVP solver not converging - memory_efficient = .true., & !< for fast execution (pre calculation of gamma_hat), Default .true.: do not precalculate - update_gamma = .false. !< update gamma operator with current stiffness, Default .false.: use initial stiffness + continueCalculation = .false. !< false:exit if BVP solver does not converge, true: continue calculation despite BVP solver not converging + #endif !-------------------------------------------------------------------------------------------------- @@ -321,8 +320,6 @@ subroutine numerics_init err_stress_tolabs = IO_floatValue(line,chunkPos,2_pInt) case ('continuecalculation') continueCalculation = IO_intValue(line,chunkPos,2_pInt) > 0_pInt - case ('update_gamma') - update_gamma = IO_intValue(line,chunkPos,2_pInt) > 0_pInt case ('petsc_options') petsc_options = trim(line(chunkPos(4):)) case ('err_curl_tolabs') @@ -432,7 +429,6 @@ subroutine numerics_init ! spectral parameters #ifdef Grid write(6,'(a24,1x,L8)') ' continueCalculation: ',continueCalculation - write(6,'(a24,1x,L8,/)') ' update_gamma: ',update_gamma write(6,'(a24,1x,es8.1)') ' err_stress_tolAbs: ',err_stress_tolAbs write(6,'(a24,1x,es8.1)') ' err_stress_tolRel: ',err_stress_tolRel write(6,'(a24,1x,es8.1)') ' err_div_tolAbs: ',err_div_tolAbs @@ -506,8 +502,6 @@ subroutine numerics_init if (err_damage_tolabs <= 0.0_pReal) call IO_error(301_pInt,ext_msg='err_damage_tolabs') if (err_damage_tolrel <= 0.0_pReal) call IO_error(301_pInt,ext_msg='err_damage_tolrel') #ifdef Grid - if (update_gamma .and. & - .not. memory_efficient) call IO_error(error_ID = 847_pInt) if (err_stress_tolrel <= 0.0_pReal) call IO_error(301_pInt,ext_msg='err_stress_tolRel') if (err_stress_tolabs <= 0.0_pReal) call IO_error(301_pInt,ext_msg='err_stress_tolAbs') if (err_div_tolRel < 0.0_pReal) call IO_error(301_pInt,ext_msg='err_div_tolRel') diff --git a/src/spectral_utilities.f90 b/src/spectral_utilities.f90 index c3f04f15d..a0512645f 100644 --- a/src/spectral_utilities.f90 +++ b/src/spectral_utilities.f90 @@ -104,16 +104,16 @@ module spectral_utilities real(pReal) :: timeincOld end type tSolutionParams - type, private :: tNumerics !< scales divergence/curl calculation: 0- no correction, 1- size scaled to 1, 2- size scaled to Npoints + type, private :: tNumerics real(pReal) :: & FFTW_timelimit !< timelimit for FFTW plan creation, see www.fftw.org integer :: & - divergence_correction + divergence_correction !< scale divergence/curl calculation: [0: no correction, 1: size scaled to 1, 2: size scaled to Npoints] logical :: & - memory_efficient + memory_efficient !< calculate gamma operator on the fly character(len=pStringLen) :: & - spectral_derivative, & - FFTW_plan_mode, & + spectral_derivative, & !< approximation used for derivatives in Fourier space + FFTW_plan_mode, & !< FFTW plan mode, see www.fftw.org PETSc_defaultOptions, & PETSc_options end type tNumerics @@ -405,13 +405,13 @@ subroutine utilities_init end subroutine utilities_init -!-------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------- !> @brief updates reference stiffness and potentially precalculated gamma operator !> @details Sets the current reference stiffness to the stiffness given as an argument. !> If the gamma operator is precalculated, it is calculated with this stiffness. !> In case of an on-the-fly calculation, only the reference stiffness is updated. !> Also writes out the current reference stiffness for restart. -!-------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------- subroutine utilities_updateGamma(C,saveReference) use IO, only: & IO_open_jobFile_binary