polishing

This commit is contained in:
Sharan Roongta 2020-06-17 18:02:22 +02:00
parent d4d29ff376
commit d3f9e9f115
5 changed files with 65 additions and 73 deletions

View File

@ -320,7 +320,7 @@ program DAMASK_grid
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! doing initialization depending on active solvers ! doing initialization depending on active solvers
call Utilities_init call spectral_Utilities_init
do field = 1, nActiveFields do field = 1, nActiveFields
select case (loadCases(1)%ID(field)) select case (loadCases(1)%ID(field))
case(FIELD_MECH_ID) case(FIELD_MECH_ID)

View File

@ -136,7 +136,7 @@ module spectral_utilities
spectral_derivative_ID spectral_derivative_ID
public :: & public :: &
utilities_init, & spectral_utilities_init, &
utilities_updateGamma, & utilities_updateGamma, &
utilities_FFTtensorForward, & utilities_FFTtensorForward, &
utilities_FFTtensorBackward, & utilities_FFTtensorBackward, &
@ -173,7 +173,7 @@ contains
!> level chosen. !> level chosen.
!> Initializes FFTW. !> Initializes FFTW.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine utilities_init subroutine spectral_utilities_init
PetscErrorCode :: ierr PetscErrorCode :: ierr
integer :: i, j, k, & integer :: i, j, k, &
@ -382,7 +382,7 @@ subroutine utilities_init
allocate (gamma_hat(3,3,3,3,grid1Red,grid(2),grid3), source = cmplx(0.0_pReal,0.0_pReal,pReal)) allocate (gamma_hat(3,3,3,3,grid1Red,grid(2),grid3), source = cmplx(0.0_pReal,0.0_pReal,pReal))
endif endif
end subroutine utilities_init end subroutine spectral_utilities_init
!--------------------------------------------------------------------------------------------------- !---------------------------------------------------------------------------------------------------

View File

@ -236,7 +236,7 @@ program DAMASK_mesh
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! doing initialization depending on active solvers ! doing initialization depending on active solvers
call Utilities_init call FEM_Utilities_init
do field = 1, nActiveFields do field = 1, nActiveFields
select case (loadCases(1)%fieldBC(field)%ID) select case (loadCases(1)%fieldBC(field)%ID)
case(FIELD_MECH_ID) case(FIELD_MECH_ID)

View File

@ -85,7 +85,7 @@ module FEM_utilities
end type tLoadCase end type tLoadCase
public :: & public :: &
utilities_init, & FEM_utilities_init, &
utilities_constitutiveResponse, & utilities_constitutiveResponse, &
utilities_projectBCValues, & utilities_projectBCValues, &
FIELD_MECH_ID, & FIELD_MECH_ID, &
@ -99,7 +99,7 @@ contains
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief allocates all neccessary fields, sets debug flags !> @brief allocates all neccessary fields, sets debug flags
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine utilities_init subroutine FEM_utilities_init
character(len=pStringLen) :: petsc_optionsOrder character(len=pStringLen) :: petsc_optionsOrder
class(tNode), pointer :: & class(tNode), pointer :: &
@ -141,7 +141,7 @@ subroutine utilities_init
wgt = 1.0/real(mesh_maxNips*mesh_NcpElemsGlobal,pReal) wgt = 1.0/real(mesh_maxNips*mesh_NcpElemsGlobal,pReal)
end subroutine utilities_init end subroutine FEM_utilities_init
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------

View File

@ -4,10 +4,10 @@
!> @brief Managing of parameters related to numerics !> @brief Managing of parameters related to numerics
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
module numerics module numerics
use prec use prec
use IO use IO
use YAML_types use YAML_types
use YAML_parse use YAML_parse
#ifdef PETSc #ifdef PETSc
#include <petsc/finclude/petscsys.h> #include <petsc/finclude/petscsys.h>
@ -15,38 +15,38 @@ module numerics
#endif #endif
!$ use OMP_LIB !$ use OMP_LIB
implicit none implicit none
private private
class(tNode), pointer, public :: & class(tNode), pointer, public :: &
numerics_root numerics_root
integer, protected, public :: & integer, protected, public :: &
worldrank = 0, & !< MPI worldrank (/=0 for MPI simulations only) worldrank = 0, & !< MPI worldrank (/=0 for MPI simulations only)
worldsize = 1 !< MPI worldsize (/=1 for MPI simulations only) worldsize = 1 !< MPI worldsize (/=1 for MPI simulations only)
integer(4), protected, public :: & integer(4), protected, public :: &
DAMASK_NumThreadsInt = 0 !< value stored in environment variable DAMASK_NUM_THREADS, set to zero if no OpenMP directive DAMASK_NumThreadsInt = 0 !< value stored in environment variable DAMASK_NUM_THREADS, set to zero if no OpenMP directive
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! field parameters: ! field parameters:
integer, protected, public :: & integer, protected, public :: &
itmax = 250, & !< maximum number of iterations itmax = 250, & !< maximum number of iterations
itmin = 1 !< minimum number of iterations itmin = 1 !< minimum number of iterations
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! spectral parameters: ! spectral parameters:
#ifdef Grid #ifdef Grid
character(len=pStringLen), protected, public :: & character(len=pStringLen), protected, public :: &
petsc_options = '' petsc_options = ''
#endif #endif
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! Mesh parameters: ! Mesh parameters:
#ifdef Mesh #ifdef Mesh
character(len=pStringLen), protected, public :: & character(len=pStringLen), protected, public :: &
petsc_options = '' petsc_options = ''
#endif #endif
public :: numerics_init public :: numerics_init
contains contains
@ -56,22 +56,22 @@ contains
! a sanity check ! a sanity check
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine numerics_init subroutine numerics_init
!$ integer :: gotDAMASK_NUM_THREADS = 1 !$ integer :: gotDAMASK_NUM_THREADS = 1
integer :: i, ierr integer :: i, ierr
character(len=:), allocatable :: & character(len=:), allocatable :: &
numerics_input, & numerics_input, &
numerics_inFlow, & numerics_inFlow
key class (tNode), pointer :: &
class (tNode), pointer :: & num_grid
num_grid logical :: fexist
logical :: fexist
!$ character(len=6) DAMASK_NumThreadsString ! environment variable DAMASK_NUM_THREADS !$ character(len=6) DAMASK_NumThreadsString ! environment variable DAMASK_NUM_THREADS
#ifdef PETSc #ifdef PETSc
call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,ierr);CHKERRQ(ierr) call MPI_Comm_rank(PETSC_COMM_WORLD,worldrank,ierr);CHKERRQ(ierr)
call MPI_Comm_size(PETSC_COMM_WORLD,worldsize,ierr);CHKERRQ(ierr) call MPI_Comm_size(PETSC_COMM_WORLD,worldsize,ierr);CHKERRQ(ierr)
#endif #endif
write(6,'(/,a)') ' <<<+- numerics init -+>>>' write(6,'(/,a)') ' <<<+- numerics init -+>>>'
!$ call GET_ENVIRONMENT_VARIABLE(NAME='DAMASK_NUM_THREADS',VALUE=DAMASK_NumThreadsString,STATUS=gotDAMASK_NUM_THREADS) ! get environment variable DAMASK_NUM_THREADS... !$ call GET_ENVIRONMENT_VARIABLE(NAME='DAMASK_NUM_THREADS',VALUE=DAMASK_NumThreadsString,STATUS=gotDAMASK_NUM_THREADS) ! get environment variable DAMASK_NUM_THREADS...
!$ if(gotDAMASK_NUM_THREADS /= 0) then ! could not get number of threads, set it to 1 !$ if(gotDAMASK_NUM_THREADS /= 0) then ! could not get number of threads, set it to 1
@ -83,35 +83,27 @@ subroutine numerics_init
!$ endif !$ endif
!$ call omp_set_num_threads(DAMASK_NumThreadsInt) ! set number of threads for parallel execution !$ call omp_set_num_threads(DAMASK_NumThreadsInt) ! set number of threads for parallel execution
numerics_root => emptyDict numerics_root => emptyDict
inquire(file='numerics.yaml', exist=fexist) inquire(file='numerics.yaml', exist=fexist)
fileExists: if (fexist) then fileExists: if (fexist) then
write(6,'(a,/)') ' using values from config file' write(6,'(a,/)') ' using values from config file'
flush(6) flush(6)
numerics_input = IO_read('numerics.yaml') numerics_input = IO_read('numerics.yaml')
numerics_inFlow = to_flow(numerics_input) numerics_inFlow = to_flow(numerics_input)
numerics_root => parse_flow(numerics_inFlow,defaultVal=emptyDict) numerics_root => parse_flow(numerics_inFlow,defaultVal=emptyDict)
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! spectral parameters ! grid parameters
num_grid => numerics_root%get('grid',defaultVal=emptyDict) num_grid => numerics_root%get('grid',defaultVal=emptyDict)
do i=1,num_grid%length itmax = num_grid%get_asInt('itmax',defaultVal=250)
key = num_grid%getKey(i) itmin = num_grid%get_asInt('itmin',defaultVal=1)
select case(key)
case ('itmax')
itmax = num_grid%get_asInt(key)
case ('itmin')
itmin = num_grid%get_asInt(key)
#ifdef PETSC #ifdef PETSC
case ('petsc_options') petsc_options = num_grid%get_asString('petsc_options',defaultVal = '')
petsc_options = num_grid%get_asString(key)
#endif #endif
endselect else fileExists
enddo write(6,'(a,/)') ' using standard values'
else fileExists flush(6)
write(6,'(a,/)') ' using standard values' endif fileExists
flush(6)
endif fileExists
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! openMP parameter ! openMP parameter
@ -119,18 +111,18 @@ subroutine numerics_init
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! field parameters ! field parameters
write(6,'(a24,1x,i8)') ' itmax: ',itmax write(6,'(a24,1x,i8)') ' itmax: ',itmax
write(6,'(a24,1x,i8)') ' itmin: ',itmin write(6,'(a24,1x,i8)') ' itmin: ',itmin
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
#ifdef PETSC #ifdef PETSC
write(6,'(a24,1x,a)') ' PETSc_options: ',trim(petsc_options) write(6,'(a24,1x,a)') ' PETSc_options: ',trim(petsc_options)
#endif #endif
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! sanity checks ! sanity checks
if (itmax <= 1) call IO_error(301,ext_msg='itmax') if (itmax <= 1) call IO_error(301,ext_msg='itmax')
if (itmin > itmax .or. itmin < 1) call IO_error(301,ext_msg='itmin') if (itmin > itmax .or. itmin < 1) call IO_error(301,ext_msg='itmin')
end subroutine numerics_init end subroutine numerics_init