corrected some bugs concerning the regridding
prevented FEsolving from potentially write to a none existing file started to introduce petsc into the make chain (nothing happens if PETSC_DIR is not set)
This commit is contained in:
parent
5923d6b413
commit
d650972904
|
@ -42,23 +42,31 @@ parser.set_defaults(loadcase= '')
|
|||
parser.set_defaults(geometry= '')
|
||||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
||||
out=subprocess.Popen(['DAMASK_spectral.exe', '-l', '%s'%options.loadcase, '-g', '%s'%options.geometry],stderr=subprocess.PIPE)
|
||||
stderr = out.communicate()
|
||||
stderrLines = string.split(stderr[1],'\n')
|
||||
exitCode = int(stderrLines[-2])
|
||||
print 'exit code', exitCode
|
||||
if exitCode==2:
|
||||
start = int(re.search('\d',stderrLines[0]).group(0))
|
||||
start = 1
|
||||
exitCode=2
|
||||
print 'load case', options.loadcase
|
||||
print 'geometry', options.geometry
|
||||
f=open('monitor','w')
|
||||
while exitCode == 2:
|
||||
print 'restart at ', start
|
||||
out=subprocess.Popen(['DAMASK_spectral', '-l', '%s'%options.loadcase, '-g', '%s'%options.geometry, '--regrid', '%i'%start],stderr=subprocess.PIPE,stdout=f)
|
||||
stderr = out.communicate()
|
||||
stderrLines = string.split(stderr[1],'\n')
|
||||
exitCode = int(stderrLines[-2])
|
||||
print 'exit code', exitCode
|
||||
if exitCode==2:
|
||||
os.system('rm -rf %i'%start)
|
||||
os.system('mkdir %i'%start)
|
||||
os.system('cp * %i/.'%start)
|
||||
start = int(string.split(re.search('restart at\s+\d+',stderr[1]).group(0))[2])
|
||||
#------------regridding----------------------------------------------
|
||||
#--------------------------------------------------------------------
|
||||
damask.core.prec.prec_init()
|
||||
damask.core.damask_interface.damask_interface_init(options.loadcase,options.geometry)
|
||||
damask.core.io.io_init()
|
||||
damask.core.numerics.numerics_init()
|
||||
damask.core.debug.debug_init()
|
||||
damask.core.math.math_init()
|
||||
damask.core.fesolving.fe_init()
|
||||
damask.core.mesh.mesh_init(1,1)
|
||||
damask.core.mesh.mesh_regrid()
|
||||
damask.core.prec.prec_init()
|
||||
damask.core.damask_interface.damask_interface_init(options.loadcase,options.geometry)
|
||||
damask.core.io.io_init()
|
||||
damask.core.numerics.numerics_init()
|
||||
damask.core.debug.debug_init()
|
||||
damask.core.math.math_init()
|
||||
damask.core.fesolving.fe_init()
|
||||
damask.core.mesh.mesh_init(1,1)
|
||||
damask.core.mesh.mesh_regrid([0,0,0])
|
||||
|
|
|
@ -108,6 +108,14 @@ program DAMASK_spectral
|
|||
materialpoint_results
|
||||
|
||||
implicit none
|
||||
|
||||
#ifdef PETSC
|
||||
#include <finclude/petscsys.h>
|
||||
#include <finclude/petscvec.h>
|
||||
#include <finclude/petscsnes.h>
|
||||
#include <finclude/petscvec.h90>
|
||||
#include <finclude/petscsnes.h90>
|
||||
#endif
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
! variables related to information from load case and geom file
|
||||
real(pReal), dimension(9) :: &
|
||||
|
@ -246,6 +254,10 @@ program DAMASK_spectral
|
|||
!##################################################################################################
|
||||
! reading of information from load case file and geometry file
|
||||
!##################################################################################################
|
||||
#ifdef PETSC
|
||||
integer :: ierr_psc
|
||||
call PetscInitialize(PETSC_NULL_CHARACTER, ierr_psc)
|
||||
#endif
|
||||
call DAMASK_interface_init
|
||||
write(6,'(a)') ''
|
||||
write(6,'(a)') ' <<<+- DAMASK_spectral init -+>>>'
|
||||
|
@ -595,10 +607,10 @@ program DAMASK_spectral
|
|||
! write header of output file
|
||||
if (appendToOutFile) then
|
||||
open(538,file=trim(getSolverWorkingDirectoryName())//trim(getSolverJobName())//'.spectralOut',&
|
||||
form='UNFORMATTED',status='REPLACE')
|
||||
form='UNFORMATTED', position='APPEND', status='OLD')
|
||||
else
|
||||
open(538,file=trim(getSolverWorkingDirectoryName())//trim(getSolverJobName())//'.spectralOut',&
|
||||
form='UNFORMATTED',status='REPLACE',position='APPEND')
|
||||
form='UNFORMATTED',status='REPLACE')
|
||||
write(538) 'load', trim(loadCaseFile)
|
||||
write(538) 'workingdir', trim(getSolverWorkingDirectoryName())
|
||||
write(538) 'geometry', trim(geometryFile)
|
||||
|
@ -777,7 +789,9 @@ program DAMASK_spectral
|
|||
C = C + dPdF
|
||||
enddo; enddo; enddo
|
||||
call debug_info()
|
||||
|
||||
! for test of regridding
|
||||
!if(mod(inc-1,bc(loadcase)%restartFrequency) == 0_pInt .and. restartInc/=inc) &
|
||||
! call quit(-1*(restartInc+1)) ! trigger exit to regrid
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
! copy one component of the stress field to to a single FT and check for mismatch
|
||||
|
@ -1085,6 +1099,6 @@ program DAMASK_spectral
|
|||
call fftw_destroy_plan(plan_scalarField_forth)
|
||||
call fftw_destroy_plan(plan_scalarField_back)
|
||||
endif
|
||||
if (notConvergedCounter > 0_pInt) call quit(2_pInt)
|
||||
if (notConvergedCounter > 0_pInt) call quit(3_pInt)
|
||||
call quit(0_pInt)
|
||||
end program DAMASK_spectral
|
||||
|
|
|
@ -101,8 +101,9 @@ subroutine FE_init
|
|||
integer(pInt), dimension(1_pInt+2_pInt*maxNchunks) :: positions
|
||||
#endif
|
||||
|
||||
#ifdef Spectral
|
||||
modelName = getSolverJobName()
|
||||
|
||||
#ifdef Spectral
|
||||
restartInc = spectralRestartInc
|
||||
if(restartInc <= 0_pInt) then
|
||||
call IO_warning(warning_ID=34_pInt)
|
||||
|
@ -110,7 +111,7 @@ subroutine FE_init
|
|||
endif
|
||||
restartRead = restartInc > 1_pInt ! only read in if "true" restart requested
|
||||
#else
|
||||
call IO_open_inputFile(fileunit,getSolverJobName())
|
||||
call IO_open_inputFile(fileunit,modelName)
|
||||
rewind(fileunit)
|
||||
do
|
||||
read (fileunit,'(a1024)',END=100) line
|
||||
|
@ -167,8 +168,6 @@ subroutine FE_init
|
|||
enddo
|
||||
#endif
|
||||
200 close(fileunit)
|
||||
else
|
||||
modelName = getSolverJobName()
|
||||
endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,11 +45,11 @@ F90 ?=ifort
|
|||
COMPILERNAME ?= $(F90)
|
||||
|
||||
INCLUDE_DIRS +=-I$(DAMASK_ROOT)/lib
|
||||
|
||||
ifdef PETSC_DIR
|
||||
INCLUDE_DIRS +=-I$(PETSC_DIR)/include
|
||||
INCLUDE_DIRS +=-I$(PETSC_DIR)/$(PETSC_ARCH)/include
|
||||
# just for the moment, as long as PETSC is non standard
|
||||
INCLUDE_DIRS +=-DPETSC
|
||||
include ${PETSC_DIR}/conf/variables
|
||||
INCLUDE_DIRS +=${PETSC_FC_INCLUDES} -DPETSC
|
||||
LIBRARIES +=${PETSC_WITH_EXTERNAL_LIB}
|
||||
endif
|
||||
|
||||
ifeq "$(FASTBUILD)" "YES"
|
||||
|
|
|
@ -207,8 +207,8 @@ python module core ! in
|
|||
|
||||
function mesh_regrid(resNewInput,minRes) ! in :mesh:mesh.f90
|
||||
integer, dimension(3) :: mesh_regrid
|
||||
integer, dimension(3), intent(in), optional :: resNewInput
|
||||
integer, dimension(3), intent(in), optional :: minRes
|
||||
integer, dimension(3), intent(in), optional :: resNewInput = -1
|
||||
integer, dimension(3), intent(in), optional :: minRes = -1
|
||||
end function mesh_regrid
|
||||
end module mesh
|
||||
end interface
|
||||
|
|
|
@ -826,7 +826,9 @@ function mesh_regrid(resNewInput,minRes)
|
|||
pInt, &
|
||||
pReal
|
||||
use DAMASK_interface, only: &
|
||||
getSolverJobName
|
||||
getSolverWorkingDirectoryName, &
|
||||
getSolverJobName, &
|
||||
GeometryFile
|
||||
use IO, only: &
|
||||
IO_read_jobBinaryFile ,&
|
||||
IO_write_jobBinaryFile, &
|
||||
|
@ -837,7 +839,7 @@ function mesh_regrid(resNewInput,minRes)
|
|||
deformed_FFT, &
|
||||
math_mul33x3
|
||||
character(len=1024):: formatString, N_Digits
|
||||
integer(pInt), dimension(3), optional, intent(in) :: resNewInput
|
||||
integer(pInt), dimension(3), optional, intent(in) :: resNewInput ! f2py cannot handle optional arguments correctly (they are always present)
|
||||
integer(pInt), dimension(3), optional, intent(in) :: minRes
|
||||
integer(pInt), dimension(3) :: mesh_regrid, ratio
|
||||
integer(pInt), dimension(3,2) :: possibleResNew
|
||||
|
@ -898,16 +900,18 @@ function mesh_regrid(resNewInput,minRes)
|
|||
! ----For 2D /3D case----------------------------------
|
||||
if (res(3)== 1_pInt) then
|
||||
spatialDim = 2_pInt
|
||||
if (minRes(3) > 1_pInt) call IO_error(890_pInt)
|
||||
if (minRes(3) > 1_pInt) call IO_error(890_pInt) ! as f2py has problems with present, use pyf file for initialization to -1
|
||||
!check 1 and 2 for odd number, 3 should be even or 1
|
||||
else
|
||||
spatialDim = 3_pInt
|
||||
if (minRes(3) <= 1_pInt) call IO_error(891_pInt)
|
||||
! if ( minRes(3) <= 1_pInt) call IO_error(891_pInt)
|
||||
!check for odd numbers
|
||||
endif
|
||||
|
||||
geomdimNew = math_mul33x3(Favg,geomdim)
|
||||
!---- Automatic detection based on current geom -----------------
|
||||
|
||||
if (.not. present(resNewInput)) then
|
||||
if (any(resNewInput<0_pInt)) then
|
||||
ratio = floor(real(res,pReal) * (geomdimNew/geomdim), pInt)
|
||||
possibleResNew = 1_pInt
|
||||
|
||||
|
@ -966,15 +970,15 @@ function mesh_regrid(resNewInput,minRes)
|
|||
deallocate(coordinatesNew)
|
||||
|
||||
!----- write out indices--------------------------------------------
|
||||
write(N_Digits, '(a)') 1_pInt + int(log10(real(maxval(indices),pReal)),pInt)
|
||||
write(N_Digits, '(I16.16)') 1_pInt + int(log10(real(maxval(indices),pReal)),pInt)
|
||||
N_Digits = adjustl(N_Digits)
|
||||
formatString = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//')'
|
||||
formatString = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//',a)'
|
||||
|
||||
call IO_write_jobFile(777,'idx') ! make it a general open-write file
|
||||
write(777, '(A)') '1 header'
|
||||
write(777, '(A)') 'Numbered indices as per the large set'
|
||||
do i = 1_pInt, Npoints
|
||||
write(777,trim(formatString),advance='no') indices(i)
|
||||
write(777,trim(formatString),advance='no') indices(i), ' '
|
||||
if(mod(i,res(1)) == 0_pInt) write(777,'(A)') ''
|
||||
enddo
|
||||
close(777)
|
||||
|
@ -984,17 +988,18 @@ function mesh_regrid(resNewInput,minRes)
|
|||
enddo
|
||||
|
||||
!------Adjusting the point-to-grain association---------------------
|
||||
write(N_Digits, '(a)') 1_pInt + int(log10(real(NpointsNew,pReal)),pInt)
|
||||
write(N_Digits, '(I16.16)') 1_pInt + int(log10(real(NpointsNew,pReal)),pInt)
|
||||
N_Digits = adjustl(N_Digits)
|
||||
formatString = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//')'
|
||||
formatString = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//',a)'
|
||||
|
||||
call IO_write_jobFile(777,'geom')
|
||||
!call IO_write_jobFile(777,'geom')
|
||||
open(777,file=trim(getSolverWorkingDirectoryName())//trim(GeometryFile),status='REPLACE')
|
||||
write(777, '(A)') '3 header'
|
||||
write(777, '(A, I8, A, I8, A, I8)') 'resolution a ', resNew(1), ' b ', resNew(2), ' c ', resNew(3)
|
||||
write(777, '(A, g17.10, A, g17.10, A, g17.10)') 'dimension x ', geomdim(1), ' y ', geomdim(2), ' z ', geomdim(3)
|
||||
write(777, '(A)') 'homogenization 1'
|
||||
do i = 1_pInt, NpointsNew
|
||||
write(777,trim(formatString),advance='no') mesh_element(4,indices(i))
|
||||
write(777,trim(formatString),advance='no') mesh_element(4,indices(i)), ' '
|
||||
if(mod(i,resNew(1)) == 0_pInt) write(777,'(A)') ''
|
||||
enddo
|
||||
close(777)
|
||||
|
|
|
@ -54,10 +54,10 @@ subroutine quit(stop_id)
|
|||
dateAndTime(6),':',&
|
||||
dateAndTime(7)
|
||||
if (stop_id == 0_pInt) stop 0 ! normal termination
|
||||
if (stop_id == 2_pInt) stop 2 ! not all steps converged
|
||||
if (stop_id < 0_pInt) then ! trigger regridding
|
||||
write(0,'(a,i6)') 'restart a', stop_id*(-1_pInt)
|
||||
write(0,'(a,i6)') 'restart at ', stop_id*(-1_pInt)
|
||||
stop 2
|
||||
endif
|
||||
stop 1 ! error
|
||||
if (stop_id == 3_pInt) stop 3 ! not all steps converged
|
||||
stop 1 ! error (message from IO_error)
|
||||
end subroutine
|
||||
|
|
Loading…
Reference in New Issue