From 60440b1a5474f2995b89903d2f7ae7f1d74f21d6 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 31 Jan 2018 12:09:14 -0500 Subject: [PATCH 1/5] polished output and streamlined code in test-class, added new consistency check in PRIVATE --- PRIVATE | 2 +- lib/damask/test/test.py | 53 ++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/PRIVATE b/PRIVATE index bdbf2da71..5fc3188c8 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit bdbf2da71cd9e0825d17f673ec2fbabc2c8027f8 +Subproject commit 5fc3188c86ea1f4159db87529ac3e3169fb56e5d diff --git a/lib/damask/test/test.py b/lib/damask/test/test.py index 341a85c97..3869d45f2 100644 --- a/lib/damask/test/test.py +++ b/lib/damask/test/test.py @@ -322,8 +322,10 @@ class Test(): cur1Name = self.fileInCurrent(cur1) return self.compare_Array(cur0Name,cur1Name) - def compare_Table(self,headings0,file0,headings1,file1,normHeadings='',normType=None, - absoluteTolerance=False,perLine=False,skipLines=[]): + def compare_Table(self,headings0,file0, + headings1,file1, + normHeadings='',normType=None, + absoluteTolerance=False,perLine=False,skipLines=[]): import numpy as np logging.info('\n '.join(['comparing ASCII Tables',file0,file1])) @@ -337,7 +339,7 @@ class Test(): data = [[] for i in range(dataLength)] maxError = [0.0 for i in range(dataLength)] absTol = [absoluteTolerance for i in range(dataLength)] - column = [[1 for i in range(dataLength)] for j in range(2)] + column = [[1 for i in range(dataLength)] for j in range(2)] norm = [[] for i in range(dataLength)] normLength = [1 for i in range(dataLength)] @@ -368,11 +370,11 @@ class Test(): key1 = ('1_' if length[i]>1 else '') + headings1[i]['label'] normKey = ('1_' if normLength[i]>1 else '') + normHeadings[i]['label'] if key0 not in table0.labels(raw = True): - raise Exception('column {} not found in 1. table...\n'.format(key0)) + raise Exception('column "{}" not found in first table...\n'.format(key0)) elif key1 not in table1.labels(raw = True): - raise Exception('column {} not found in 2. table...\n'.format(key1)) + raise Exception('column "{}" not found in second table...\n'.format(key1)) elif normKey not in table0.labels(raw = True): - raise Exception('column {} not found in 1. table...\n'.format(normKey)) + raise Exception('column "{}" not found in first table...\n'.format(normKey)) else: column[0][i] = table0.label_index(key0) column[1][i] = table1.label_index(key1) @@ -400,9 +402,9 @@ class Test(): norm[i] = [1.0 for j in range(line0-len(skipLines))] absTol[i] = True if perLine: - logging.warning('At least one norm of {} in 1. table is 0.0, using absolute tolerance'.format(headings0[i]['label'])) + logging.warning('At least one norm of "{}" in first table is 0.0, using absolute tolerance'.format(headings0[i]['label'])) else: - logging.warning('Maximum norm of {} in 1. table is 0.0, using absolute tolerance'.format(headings0[i]['label'])) + logging.warning('Maximum norm of "{}" in first table is 0.0, using absolute tolerance'.format(headings0[i]['label'])) line1 = 0 while table1.data_read(): # read next data line of ASCII table @@ -414,7 +416,7 @@ class Test(): norm[i][line1-len(skipLines)]) line1 +=1 - if (line0 != line1): raise Exception('found {} lines in 1. table but {} in 2. table'.format(line0,line1)) + if (line0 != line1): raise Exception('found {} lines in first table but {} in second table'.format(line0,line1)) logging.info(' ********') for i in range(dataLength): @@ -561,25 +563,28 @@ class Test(): return allclose - def compare_TableRefCur(self,headingsRef,ref,headingsCur='',cur='',normHeadings='',normType=None,\ - absoluteTolerance=False,perLine=False,skipLines=[]): + def compare_TableRefCur(self,headingsRef,ref,headingsCur='',cur='', + normHeadings='',normType=None, + absoluteTolerance=False,perLine=False,skipLines=[]): - if cur == '': cur = ref - if headingsCur == '': headingsCur = headingsRef - refName = self.fileInReference(ref) - curName = self.fileInCurrent(cur) - return self.compare_Table(headingsRef,refName,headingsCur,curName,normHeadings,normType, - absoluteTolerance,perLine,skipLines) + return self.compare_Table(headingsRef, + self.fileInReference(ref), + headingsRef if headingsCur == '' else headingsCur, + self.fileInReference(ref if cur == '' else cur), + normHeadings,normType, + absoluteTolerance,perLine,skipLines) - def compare_TableCurCur(self,headingsCur0,Cur0,Cur1,headingsCur1='',normHeadings='',normType=None,\ - absoluteTolerance=False,perLine=False,skipLines=[]): + def compare_TableCurCur(self,headingsCur0,Cur0,Cur1, + headingsCur1='', + normHeadings='',normType=None, + absoluteTolerance=False,perLine=False,skipLines=[]): - if headingsCur1 == '': headingsCur1 = headingsCur0 - cur0Name = self.fileInCurrent(Cur0) - cur1Name = self.fileInCurrent(Cur1) - return self.compare_Table(headingsCur0,cur0Name,headingsCur1,cur1Name,normHeadings,normType, - absoluteTolerance,perLine,skipLines) + return self.compare_Table(headingsCur0, + self.fileInCurrent(Cur0), + headingsCur0 if headingsCur1 == '' else headingsCur1, + self.fileInCurrent(Cur1), + normHeadings,normType,absoluteTolerance,perLine,skipLines) def report_Success(self,culprit): From 85147605adcdf78fd1850670caaf4305a48a8c4d Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 31 Jan 2018 12:35:50 -0500 Subject: [PATCH 2/5] bugfix: use fileInCurrent instead of fileInRef --- lib/damask/test/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/damask/test/test.py b/lib/damask/test/test.py index 3869d45f2..0e1a0284c 100644 --- a/lib/damask/test/test.py +++ b/lib/damask/test/test.py @@ -570,7 +570,7 @@ class Test(): return self.compare_Table(headingsRef, self.fileInReference(ref), headingsRef if headingsCur == '' else headingsCur, - self.fileInReference(ref if cur == '' else cur), + self.fileInCurrent(ref if cur == '' else cur), normHeadings,normType, absoluteTolerance,perLine,skipLines) From 8776b525619c3f9c2ca22cb5a61034179482408b Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 1 Feb 2018 07:34:53 +0100 Subject: [PATCH 3/5] [skip ci] updated version information after successful test of v2.0.1-1033-g8514760 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3c048e8c8..8f9e4d0c0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.1-1029-ge304ce3 +v2.0.1-1033-g8514760 From d80a25573680a25307f374058a13e485fa8e8971 Mon Sep 17 00:00:00 2001 From: Franz Roters Date: Fri, 2 Feb 2018 15:06:13 +0100 Subject: [PATCH 4/5] new Marc2017 file format finally working! --- src/IO.f90 | 6 ++--- src/mesh.f90 | 64 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index a6c3a7da8..d877379c7 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -1268,7 +1268,7 @@ integer(pInt) function IO_countNumericalDataLines(fileUnit) line = IO_read(fileUnit) chunkPos = IO_stringPos(line) tmp = IO_lc(IO_stringValue(line,chunkPos,1_pInt)) - if (scan(tmp,"abcdefghijklmnopqrstuvwxyz")/=0) then ! found keyword + if (verify(trim(tmp) ,"0123456789")/=0) then ! found keyword line = IO_read(fileUnit, .true.) ! reset IO_read exit else @@ -1839,12 +1839,12 @@ integer(pInt) function IO_verifyIntValue (string,validChars,myName) invalidWhere = verify(string,validChars) if (invalidWhere == 0_pInt) then read(UNIT=string,iostat=readStatus,FMT=*) IO_verifyIntValue ! no offending chars found - if (readStatus /= 0_pInt) & ! error during string to float conversion + if (readStatus /= 0_pInt) & ! error during string to integer conversion call IO_warning(203_pInt,ext_msg=myName//'"'//string//'"') else call IO_warning(202_pInt,ext_msg=myName//'"'//string//'"') ! complain about offending characters read(UNIT=string(1_pInt:invalidWhere-1_pInt),iostat=readStatus,FMT=*) IO_verifyIntValue ! interpret remaining string - if (readStatus /= 0_pInt) & ! error during string to float conversion + if (readStatus /= 0_pInt) & ! error during string to integer conversion call IO_warning(203_pInt,ext_msg=myName//'"'//string(1_pInt:invalidWhere-1_pInt)//'"') endif diff --git a/src/mesh.f90 b/src/mesh.f90 index 827875d2f..d7d0f8c06 100644 --- a/src/mesh.f90 +++ b/src/mesh.f90 @@ -1642,11 +1642,12 @@ subroutine mesh_marc_get_matNumber(fileUnit) if (len(trim(line))/=0_pInt) then chunkPos = IO_stringPos(line) data_blocks = IO_intValue(line,chunkPos,1_pInt) - endif + endif + allocate(Marc_matNumber(data_blocks)) do i=1_pInt,data_blocks ! read all data blocks read (fileUnit,610,END=620) line chunkPos = IO_stringPos(line) - Marc_matNumber = (/Marc_matNumber, IO_intValue(line,chunkPos,1_pInt)/) + Marc_matNumber(i) = IO_intValue(line,chunkPos,1_pInt) do j=1_pint,2_pInt + hypoelasticTableStyle ! read 2 or 3 remaining lines of data block read (fileUnit,610,END=620) line enddo @@ -1809,12 +1810,11 @@ subroutine mesh_marc_count_cpElements(fileUnit) do i=1_pInt,3_pInt+hypoelasticTableStyle ! Skip 3 or 4 lines read (fileUnit,610,END=620) line enddo - mesh_NcpElems = mesh_NcpElems + IO_countContinuousIntValues(fileUnit) ! why not simply mesh_NcpElems = IO_countContinuousIntValues(fileUnit)? keyword hypoelastic might appear several times so the next line probably should not be there + mesh_NcpElems = mesh_NcpElems + IO_countContinuousIntValues(fileUnit) ! why not simply mesh_NcpElems = IO_countContinuousIntValues(fileUnit)? not fully correct as hypoelastic can have multiple data fields, needs update exit endif enddo - else ! Marc2017 and later - call IO_error(error_ID=701_pInt) + else ! Marc2017 and later do read (fileUnit,610,END=620) line chunkPos = IO_stringPos(line) @@ -1839,6 +1839,7 @@ subroutine mesh_marc_map_elements(fileUnit) use math, only: math_qsort use IO, only: IO_lc, & + IO_intValue, & IO_stringValue, & IO_stringPos, & IO_continuousIntValues @@ -1847,7 +1848,8 @@ subroutine mesh_marc_map_elements(fileUnit) integer(pInt), intent(in) :: fileUnit integer(pInt), allocatable, dimension(:) :: chunkPos - character(len=300) :: line + character(len=300) :: line, & + tmp integer(pInt), dimension (1_pInt+mesh_NcpElems) :: contInts integer(pInt) :: i,cpElem = 0_pInt @@ -1856,25 +1858,47 @@ subroutine mesh_marc_map_elements(fileUnit) 610 FORMAT(A300) + contInts = 0_pInt rewind(fileUnit) do read (fileUnit,610,END=660) line chunkPos = IO_stringPos(line) - if( IO_lc(IO_stringValue(line,chunkPos,1_pInt)) == 'hypoelastic' ) then - do i=1_pInt,3_pInt+hypoelasticTableStyle ! skip three (or four if new table style!) lines - read (fileUnit,610,END=660) line - enddo - contInts = IO_continuousIntValues(fileUnit,mesh_NcpElems,mesh_nameElemSet,& + if (MarcVersion < 13) then ! Marc 2016 or earlier + if( IO_lc(IO_stringValue(line,chunkPos,1_pInt)) == 'hypoelastic' ) then + do i=1_pInt,3_pInt+hypoelasticTableStyle ! skip three (or four if new table style!) lines + read (fileUnit,610,END=660) line + enddo + contInts = IO_continuousIntValues(fileUnit,mesh_NcpElems,mesh_nameElemSet,& mesh_mapElemSet,mesh_NelemSets) - do i = 1_pInt,contInts(1) - cpElem = cpElem+1_pInt - mesh_mapFEtoCPelem(1,cpElem) = contInts(1_pInt+i) - mesh_mapFEtoCPelem(2,cpElem) = cpElem - enddo - endif - enddo - -660 call math_qsort(mesh_mapFEtoCPelem,1_pInt,int(size(mesh_mapFEtoCPelem,2_pInt),pInt)) ! should be mesh_NcpElems + exit + endif + else ! Marc2017 and later + if ( IO_lc(IO_stringValue(line,chunkPos,1_pInt)) == 'connectivity') then + read (fileUnit,610,END=660) line + chunkPos = IO_stringPos(line) + if(any(Marc_matNumber==IO_intValue(line,chunkPos,6_pInt))) then + do + read (fileUnit,610,END=660) line + chunkPos = IO_stringPos(line) + tmp = IO_lc(IO_stringValue(line,chunkPos,1_pInt)) + if (verify(trim(tmp),"0123456789")/=0) then ! found keyword + exit + else + contInts(1) = contInts(1) + 1_pInt + read (tmp,*) contInts(contInts(1)+1) + endif + enddo + endif + endif + endif + enddo +660 do i = 1_pInt,contInts(1) + cpElem = cpElem+1_pInt + mesh_mapFEtoCPelem(1,cpElem) = contInts(1_pInt+i) + mesh_mapFEtoCPelem(2,cpElem) = cpElem + enddo + +call math_qsort(mesh_mapFEtoCPelem,1_pInt,int(size(mesh_mapFEtoCPelem,2_pInt),pInt)) ! should be mesh_NcpElems end subroutine mesh_marc_map_elements From 911fb84e81a1154e77df472f014bc49516a917d9 Mon Sep 17 00:00:00 2001 From: Test User Date: Sat, 3 Feb 2018 03:57:56 +0100 Subject: [PATCH 5/5] [skip ci] updated version information after successful test of v2.0.1-1035-gd80a255 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 8f9e4d0c0..35191bcab 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.1-1033-g8514760 +v2.0.1-1035-gd80a255