fixed restarting for Polarisation and AL, updated corresponding test and polished output in python (some statements are screwed up when making them Python3 compatible)

This commit is contained in:
Martin Diehl 2013-09-20 14:22:37 +00:00
parent 1915215c6f
commit a0f304021f
4 changed files with 35 additions and 38 deletions

View File

@ -208,30 +208,26 @@ subroutine AL_init(temperature)
if (restartInc == 1_pInt) then ! no deformation (no restart)
F_lastInc = spread(spread(spread(math_I3,3,grid(1)),4,grid(2)),5,grid(3)) ! initialize to identity
F_lastInc2 = F_lastInc
F_lambda_lastInc = F_lastInc
F = reshape(F_lastInc,[9,grid(1),grid(2),grid(3)])
F_lambda = F
F_lambda_lastInc = F_lastInc
elseif (restartInc > 1_pInt) then
if (iand(debug_level(debug_spectral),debug_spectralRestart)/= 0) &
write(6,'(/,a,'//IO_intOut(restartInc-1_pInt)//',a)') &
'reading values of increment', restartInc - 1_pInt, 'from file'
flush(6)
call IO_read_realFile(777,'F',&
trim(getSolverJobName()),size(F))
call IO_read_realFile(777,'F', trim(getSolverJobName()),size(F))
read (777,rec=1) F
close (777)
call IO_read_realFile(777,'F_lastInc',&
trim(getSolverJobName()),size(F_lastInc))
call IO_read_realFile(777,'F_lastInc', trim(getSolverJobName()),size(F_lastInc))
read (777,rec=1) F_lastInc
close (777)
call IO_read_realFile(777,'F_lastInc2',&
trim(getSolverJobName()),size(F_lastInc2))
call IO_read_realFile(777,'F_lastInc2', trim(getSolverJobName()),size(F_lastInc2))
read (777,rec=1) F_lastInc2
close (777)
F_aim = reshape(sum(sum(sum(F,dim=4),dim=3),dim=2) * wgt, [3,3]) ! average of F
F_aim_lastInc = sum(sum(sum(F_lastInc,dim=5),dim=4),dim=3) * wgt ! average of F_lastInc
call IO_read_realFile(777,'F_lambda',&
trim(getSolverJobName()),size(F_lambda))
call IO_read_realFile(777,'F_lambda',trim(getSolverJobName()),size(F_lambda))
read (777,rec=1) F_lambda
close (777)
call IO_read_realFile(777,'F_lambda_lastInc',&
@ -264,9 +260,9 @@ subroutine AL_init(temperature)
C_volAvg = temp3333_Real
endif
call Utilities_updateGamma(temp3333_Real2,.True.)
C_scale = temp3333_Real2
S_scale = math_invSym3333(temp3333_Real2)
call Utilities_updateGamma(C_minMaxAvg,.True.)
C_scale = C_minMaxAvg
S_scale = math_invSym3333(C_minMaxAvg)
end subroutine AL_init
@ -348,6 +344,9 @@ use mesh, only: &
call IO_write_jobRealFile(777,'F_lastInc',size(F_lastInc)) ! writing F_lastInc field to file
write (777,rec=1) F_lastInc
close (777)
call IO_write_jobRealFile(777,'F_lastInc2',size(F_lastInc2)) ! writing F_lastInc field to file
write (777,rec=1) F_lastInc2
close (777)
call IO_write_jobRealFile(777,'F_lambda',size(F_lambda)) ! writing deformation gradient field to file
write (777,rec=1) F_lambda
close (777)

View File

@ -187,7 +187,7 @@ subroutine basicPETSc_init(temperature)
call DMDAVecGetArrayF90(da,solution_vec,F,ierr); CHKERRQ(ierr) ! get the data out of PETSc to work with
if (restartInc == 1_pInt) then ! no deformation (no restart)
F_lastInc = spread(spread(spread(math_I3,3,grid(1)),4,grid(2)),5,grid(3)) ! initialize to identity
F_lastInc = spread(spread(spread(math_I3,3,grid(1)),4,grid(2)),5,grid(3)) ! initialize to identity
F = reshape(F_lastInc,[9,grid(1),grid(2),grid(3)])
F_lastInc2 = F_lastInc
elseif (restartInc > 1_pInt) then ! using old values from file
@ -195,16 +195,13 @@ subroutine basicPETSc_init(temperature)
write(6,'(/,a,'//IO_intOut(restartInc-1_pInt)//',a)') &
'reading values of increment', restartInc - 1_pInt, 'from file'
flush(6)
call IO_read_realFile(777,'F',&
trim(getSolverJobName()),size(F))
call IO_read_realFile(777,'F',trim(getSolverJobName()),size(F))
read (777,rec=1) F
close (777)
call IO_read_realFile(777,'F_lastInc',&
trim(getSolverJobName()),size(F_lastInc))
call IO_read_realFile(777,'F_lastInc',trim(getSolverJobName()),size(F_lastInc))
read (777,rec=1) F_lastInc
close (777)
call IO_read_realFile(777,'F_lastInc2',&
trim(getSolverJobName()),size(F_lastInc2))
call IO_read_realFile(777,'F_lastInc2',trim(getSolverJobName()),size(F_lastInc2))
read (777,rec=1) F_lastInc2
close (777)
F_aim = reshape(sum(sum(sum(F,dim=4),dim=3),dim=2) * wgt, [3,3]) ! average of F

View File

@ -216,22 +216,18 @@ subroutine Polarisation_init(temperature)
write(6,'(/,a,'//IO_intOut(restartInc-1_pInt)//',a)') &
'reading values of increment', restartInc - 1_pInt, 'from file'
flush(6)
call IO_read_realFile(777,'F',&
trim(getSolverJobName()),size(F))
call IO_read_realFile(777,'F',trim(getSolverJobName()),size(F))
read (777,rec=1) F
close (777)
call IO_read_realFile(777,'F_lastInc',&
trim(getSolverJobName()),size(F_lastInc))
call IO_read_realFile(777,'F_lastInc',trim(getSolverJobName()),size(F_lastInc))
read (777,rec=1) F_lastInc
close (777)
call IO_read_realFile(777,'F_lastInc2',&
trim(getSolverJobName()),size(F_lastInc2))
call IO_read_realFile(777,'F_lastInc2',trim(getSolverJobName()),size(F_lastInc2))
read (777,rec=1) F_lastInc2
close (777)
F_aim = reshape(sum(sum(sum(F,dim=4),dim=3),dim=2) * wgt, [3,3]) ! average of F
F_aim_lastInc = sum(sum(sum(F_lastInc,dim=5),dim=4),dim=3) * wgt ! average of F_lastInc
call IO_read_realFile(777,'F_tau',&
trim(getSolverJobName()),size(F_tau))
call IO_read_realFile(777,'F_tau',trim(getSolverJobName()),size(F_tau))
read (777,rec=1) F_tau
close (777)
call IO_read_realFile(777,'F_tau_lastInc',&
@ -348,6 +344,9 @@ use mesh, only: &
call IO_write_jobRealFile(777,'F_lastInc',size(F_lastInc)) ! writing F_lastInc field to file
write (777,rec=1) F_lastInc
close (777)
call IO_write_jobRealFile(777,'F_lastInc2',size(F_lastInc2)) ! writing F_lastInc field to file
write (777,rec=1) F_lastInc2
close (777)
call IO_write_jobRealFile(777,'F_tau',size(F_tau)) ! writing deformation gradient field to file
write (777,rec=1) F_tau
close (777)

View File

@ -159,7 +159,7 @@ class Test():
try:
shutil.copy2(self.fileInReference(file),self.fileInCurrent(targetfiles[i]))
except:
print('Reference2Current: Unable to copy file ', file)
print('Reference2Current: Unable to copy file %s'%file)
def copy_Base2Current(self,sourceDir,sourcefiles=[],targetfiles=[]):
@ -170,7 +170,7 @@ class Test():
shutil.copy2(os.path.join(source,file),self.fileInCurrent(targetfiles[i]))
except:
print(os.path.join(source,file))
print('Base2Current: Unable to copy file ', file)
print('Base2Current: Unable to copy file %s'%file)
def copy_Current2Reference(self,sourcefiles=[],targetfiles=[]):
@ -179,7 +179,7 @@ class Test():
try:
shutil.copy2(self.fileInCurrent(file),self.fileInReference(targetfiles[i]))
except:
print('Current2Reference: Unable to copy file ', file)
print('Current2Reference: Unable to copy file %s'%file)
def copy_Proof2Current(self,sourcefiles=[],targetfiles=[]):
@ -188,7 +188,7 @@ class Test():
try:
shutil.copy2(self.fileInProof(file),self.fileInCurrent(targetfiles[i]))
except:
print('Proof2Current: Unable to copy file ', file)
print('Proof2Current: Unable to copy file %s'%file)
def copy_Current2Current(self,sourcefiles=[],targetfiles=[]):
@ -196,7 +196,7 @@ class Test():
try:
shutil.copy2(self.fileInReference(file),self.fileInCurrent(targetfiles[i]))
except:
print('Current2Current: Unable to copy file ', file)
print('Current2Current: Unable to copy file %s'%file)
def execute_inCurrentDir(self,cmd,outfile='execute_log.txt'):
@ -210,7 +210,7 @@ class Test():
def compare_Array(self,File1,File2):
import numpy
print('comparing\n ' , File1,'\n ', File2)
print('comparing\n '+File1+'\n '+File2)
refFile = open(File1)
table = damask.ASCIItable(refFile)
table.head_read()
@ -224,7 +224,8 @@ class Test():
max_loc=numpy.argmax(abs(refArrayNonZero[curArray.nonzero()]/curArray[curArray.nonzero()]-1.))
refArrayNonZero = refArrayNonZero[curArray.nonzero()]
curArray = curArray[curArray.nonzero()]
print(' ********\n * maximum relative error ',max_err,' for ', refArrayNonZero[max_loc],' and ',curArray[max_loc],'\n ********')
print(' ********\n * maximum relative error %f for %i and %i\n ********'
%(max_err, refArrayNonZero[max_loc],curArray[max_loc]))
return max_err
else:
raise Exception('mismatch in array size to compare')
@ -246,7 +247,7 @@ class Test():
absoluteTolerance=False,perLine=False,skipLines=[]):
import numpy
print('comparing ASCII Tables\n' , file0,'\n', file1)
print('comparing ASCII Tables\n' + file0 + '\n' + file1)
if normHeadings == '': normHeadings = headings0
if len(headings0) == len(headings1) == len(normHeadings): #check if comparison is possible and determine lenght of columns
@ -330,7 +331,8 @@ class Test():
for i in xrange(dataLength):
myData = numpy.array(map(float,table1.data[column[1][i]:\
column[1][i]+length[i]]),'d')
maxError[i] = max(maxError[i],numpy.linalg.norm(numpy.reshape(myData-data[i][line1-len(skipLines),:],shape[i]))/norm[i][line1-len(skipLines)])
maxError[i] = max(maxError[i],numpy.linalg.norm(numpy.reshape(myData-data[i][line1-len(skipLines),:],shape[i]))/
norm[i][line1-len(skipLines)])
line1 +=1
if (line0 != line1): raise Exception('found ', line0, ' lines in 1. table and ', line1, ' in 2. table')
@ -338,9 +340,9 @@ class Test():
print(' ********')
for i in xrange(dataLength):
if absTol[i]:
print(' * maximum absolute error ',maxError[i],' for ', headings0[i]['label'],' and ',headings1[i]['label'])
print(' * maximum absolute error %f for %s and %s'%(maxError[i],headings0[i]['label'],headings1[i]['label']))
else:
print(' * maximum relative error ',maxError[i],' for ', headings0[i]['label'],' and ',headings1[i]['label'])
print(' * maximum relative error %f for %s and %s'%(maxError[i],headings0[i]['label'],headings1[i]['label']))
print(' ********')
return maxError