diff --git a/code/DAMASK_spectral_utilities.f90 b/code/DAMASK_spectral_utilities.f90 index 75b6ba336..1bff60bb6 100644 --- a/code/DAMASK_spectral_utilities.f90 +++ b/code/DAMASK_spectral_utilities.f90 @@ -13,6 +13,9 @@ module DAMASK_spectral_utilities pInt implicit none +#ifdef PETSc +#include +#endif logical, public :: cutBack =.false. !< cut back of BVP solver in case convergence is not achieved or a material point is terminally ill !-------------------------------------------------------------------------------------------------- @@ -47,7 +50,8 @@ module DAMASK_spectral_utilities debugDivergence, & !< debugging of divergence calculation (comparison to function used for post processing) debugRestart, & !< debbuging of restart features debugFFTW, & !< doing additional FFT on scalar field and compare to results of strided 3D FFT - debugRotation !< also printing out results in lab frame + debugRotation, & !< also printing out results in lab frame + debugPETSc !< use some in debug defined options for more verbose PETSc solution !-------------------------------------------------------------------------------------------------- ! derived types @@ -99,7 +103,8 @@ subroutine utilities_init() DAMASK_NumThreadsInt, & fftw_planner_flag, & fftw_timelimit, & - memory_efficient + memory_efficient, & + petsc_options use debug, only: & debug_level, & debug_spectral, & @@ -107,14 +112,21 @@ subroutine utilities_init() debug_spectralDivergence, & debug_spectralRestart, & debug_spectralFFTW, & +#ifdef PETSc + debug_spectralPETSc, & + PETScDebug, & +#endif debug_spectralRotation use mesh, only: & res, & res1_red, & virt_dim use math ! must use the whole module for use of FFTW - + implicit none +#ifdef PETSc + PetscErrorCode :: ierr +#endif integer(pInt) :: i, j, k integer(pInt), dimension(3) :: k_s type(C_PTR) :: & @@ -122,7 +134,6 @@ subroutine utilities_init() scalarField_realC, & !< field cotaining data for FFTW in real space when debugging FFTW (no in place) scalarField_fourierC, & !< field cotaining data for FFTW in fourier space when debugging FFTW (no in place) divergence !< field cotaining data for FFTW in real and fourier space when debugging divergence (in place) - write(6,'(/,a)') ' <<<+- DAMASK_spectral_utilities init -+>>>' write(6,'(a)') ' $Id$' #include "compilation_info.f90" @@ -135,7 +146,17 @@ subroutine utilities_init() debugRestart = iand(debug_level(debug_spectral),debug_spectralRestart) /= 0 debugFFTW = iand(debug_level(debug_spectral),debug_spectralFFTW) /= 0 debugRotation = iand(debug_level(debug_spectral),debug_spectralRotation) /= 0 - +#ifdef PETSc + debugPETSc = iand(debug_level(debug_spectral),debug_spectralPETSc) /= 0 + if(debugPETSc) write(6,'(a)') ' Initializing PETSc with debug options: ', trim(PETScDebug), & + ' add more using the PETSc_Options keyword in numerics.config ' + call PetscOptionsClear(ierr) + CHKERRQ(ierr) + if(debugPETSc) call PetscOptionsInsertString(trim(PETScDebug),ierr) + CHKERRQ(ierr) + call PetscOptionsInsertString(trim(petsc_options),ierr) + CHKERRQ(ierr) +#endif !-------------------------------------------------------------------------------------------------- ! allocation allocate (xi(3,res1_red,res(2),res(3)),source = 0.0_pReal) ! frequencies, only half the size for first dimension diff --git a/code/config/debug.config b/code/config/debug.config index a17cc35cc..5def15b2e 100644 --- a/code/config/debug.config +++ b/code/config/debug.config @@ -16,10 +16,10 @@ constitutive # constitutive_*.f90 possible values: ba crystallite # crystallite.f90 possible values: basic, extensive, selective homogenization # homogenization_*.f90 possible values: basic, extensive, selective CPFEM # CPFEM.f90 possible values: basic, extensive, selective -spectral # DAMASK_spectral.f90 possible values: basic, fft, restart, divergence +spectral # DAMASK_spectral.f90 possible values: basic, fft, restart, divergence, rotation, petsc abaqus # ABAQUS FEM solver possible values: basic # # Parameters for selective element 1 # selected element for debugging (synonymous: "el", "e") ip 1 # selected integration point for debugging (synonymous: "integrationpoint", "i") -grain 1 # selected grain at ip for debugging (synonymous: "gr", "g") \ No newline at end of file +grain 1 # selected grain at ip for debugging (synonymous: "gr", "g") diff --git a/code/debug.f90 b/code/debug.f90 index 39f19c3c4..d3653ad7d 100644 --- a/code/debug.f90 +++ b/code/debug.f90 @@ -44,7 +44,8 @@ module debug debug_spectralRestart = debug_maxGeneral*2_pInt**1_pInt, & debug_spectralFFTW = debug_maxGeneral*2_pInt**2_pInt, & debug_spectralDivergence = debug_maxGeneral*2_pInt**3_pInt, & - debug_spectralRotation = debug_maxGeneral*2_pInt**4_pInt + debug_spectralRotation = debug_maxGeneral*2_pInt**4_pInt, & + debug_spectralPETSc = debug_maxGeneral*2_pInt**5_pInt integer(pInt), parameter, public :: & debug_debug = 1_pInt, & @@ -104,6 +105,10 @@ module debug character(len=64), parameter, private :: & debug_configFile = 'debug.config' ! name of configuration file +#ifdef PETSc + character(len=1024), parameter, public :: & + PETScDebug = ' -snes_view -snes_monitor' +#endif public :: debug_init, & debug_reset, & debug_info @@ -139,7 +144,6 @@ subroutine debug_init integer(pInt), dimension(1+2*maxNchunks) :: positions character(len=64) :: tag character(len=1024) :: line - !$OMP CRITICAL (write2out) write(6,*) write(6,*) '<<<+- debug init -+>>>' @@ -235,6 +239,8 @@ subroutine debug_init debug_level(what) = ior(debug_level(what), debug_spectralDivergence) case('rotation') debug_level(what) = ior(debug_level(what), debug_spectralRotation) + case('petsc') + debug_level(what) = ior(debug_level(what), debug_spectralPETSc) end select enddo endif @@ -310,6 +316,7 @@ subroutine debug_init if(iand(debug_level(i),debug_spectralFFTW) /= 0) write(6,'(a)') ' FFTW' if(iand(debug_level(i),debug_spectralDivergence)/= 0) write(6,'(a)') ' divergence' if(iand(debug_level(i),debug_spectralRotation) /= 0) write(6,'(a)') ' rotation' + if(iand(debug_level(i),debug_spectralPETSc) /= 0) write(6,'(a)') ' PETSc' !$OMP END CRITICAL (write2out) endif enddo diff --git a/code/numerics.f90 b/code/numerics.f90 index 62556b023..6a4024fd7 100644 --- a/code/numerics.f90 +++ b/code/numerics.f90 @@ -25,9 +25,6 @@ module numerics use prec, only: pInt, pReal implicit none -#ifdef PETSc -#include -#endif character(len=64), parameter, private :: & numerics_configFile = 'numerics.config' !< name of configuration file @@ -98,7 +95,8 @@ character(len=64), protected, public :: & myspectralsolver = 'basic' , & !< spectral solution method myfilter = 'none' !< spectral filtering method character(len=1024), protected, public :: & - petsc_options = '-snes_type ngmres -snes_ngmres_anderson -snes_view' + petsc_options = '-snes_type ngmres & + -snes_ngmres_anderson ' integer(pInt), protected, public :: & fftw_planner_flag = 32_pInt, & !< conversion of fftw_plan_mode to integer, basically what is usually done in the include file of fftw itmax = 20_pInt, & !< maximum number of iterations @@ -122,24 +120,23 @@ contains subroutine numerics_init use, intrinsic :: iso_fortran_env ! to get compiler_version and compiler_options (at least for gfortran 4.6 at the moment) - use IO, only: IO_error, & - IO_open_file_stat, & - IO_isBlank, & - IO_stringPos, & - IO_stringValue, & - IO_lc, & - IO_floatValue, & - IO_intValue, & - IO_warning + use IO, only: & + IO_error, & + IO_open_file_stat, & + IO_isBlank, & + IO_stringPos, & + IO_stringValue, & + IO_lc, & + IO_floatValue, & + IO_intValue, & + IO_warning + #ifndef Marc !$ use OMP_LIB, only: omp_set_num_threads ! Use the standard conforming module file for omp if not using MSC.Marc #endif implicit none #ifdef Marc !$ include "omp_lib.h" ! use the non F90 standard include file to prevent crashes with some versions of MSC.Marc -#endif -#ifdef PETSc - PetscErrorCode :: ierr #endif integer(pInt), parameter :: fileunit = 300_pInt ,& maxNchunks = 2_pInt @@ -338,13 +335,6 @@ subroutine numerics_init fftw_planner_flag = 32_pInt end select #endif -#ifdef PETSc - write(6,'(a)') ' Initializing PETSc' - call PetscOptionsClear(ierr) - CHKERRQ(ierr) - call PetscOptionsInsertString(petsc_options,ierr) - CHKERRQ(ierr) -#endif numerics_timeSyncing = numerics_timeSyncing .and. all(numerics_integrator==2_pInt) ! timeSyncing only allowed for explicit Euler integrator