Revisited version of constitutive_parse_MatTexDat() Some polishing added

This commit is contained in:
Luc Hantcherli 2007-03-22 16:29:06 +00:00
parent edc2632067
commit 1c04045359
1 changed files with 228 additions and 232 deletions

View File

@ -193,7 +193,7 @@ subroutine constitutive_init()
!************************************** !**************************************
call constitutive_calc_SchmidM() call constitutive_calc_SchmidM()
call constitutive_calc_hardeningM() call constitutive_calc_hardeningM()
call constitutive_parse_materialDat() call constitutive_parse_MatTexDat('materials_textures.mpie')
end subroutine end subroutine
@ -279,192 +279,187 @@ enddo
end subroutine end subroutine
function constitutive_parse_MaterialPart(pass)
!*********************************************************** !***********************************************************
!* INPUT: i_pass *
!* OUTPUT: constitutive_Nmats,next_part *
!*********************************************************** !***********************************************************
use prec, only: pReal,pInt SUBROUTINE constitutive_countSections(file,count,part)
use IO
use prec, only: pInt
use IO, only: IO_stringPos,IO_stringValue,IO_lc
implicit none implicit none
!* Definition of variables integer(pInt) file,count,pos
character(len=*) line integer(pInt), dimension(3) :: positions
character(len=*) consititutive_parse_MaterialPart character(len=80) part,line,tag
integer(pInt) pass,positions(5)
!* Reading line of the opened file count = 0
do while(.true.) part = ''
read(200,610,END=220) line
select case(line(1:1)) do
!* CASE1-1: A new part beginns read(unit=file,fmt='(a80)',end=100) line
case ('<') positions = IO_stringPos(line,1)
if (line(1:1).EQ.'<') tag = IO_lc(IO_stringValue(line,positions,1))
positions=IO_stringPos(line,1) if (tag(1:1)=='<' .and. tag(len(tag):len(tag)=='>') then
consititutive_parse_MaterialPart=IO_lc(IO_stringValue(line,positions,1)) part = tag(2:len(tag)-1)
return exit
elseif (tag(1:1)=='[' .and. tag(len(tag):len(tag)==']') then
count = count+1
endif endif
!* CASE1-2: Current line contains [comments] end do
case ('[') 100 return
constitutive_Nmats=constitutive_Nmats+1
!* CASE1-3: Current line contains material parameters END SUBROUTINE
case default
if (pass.EQ.2) then
positions=IO_stringPos(line,2) !***********************************************************
select case(IO_lc(IO_stringValue(line,positions,1))) !***********************************************************
!* CASE2-1: Reading crystal structure character(len=80) function constitutive_parse_unknownPart(file)
case ('crystal_structure')
constitutive_crystal_structure(constitutive_Nmats)=IO_intValue(line,positions,2) use prec, only: pInt
!* CASE2-2: Reading number of slip systems use IO, only: IO_stringPos,IO_stringValue,IO_lc
implicit none
integer(pInt), parameter :: maxNchunks = 1
integer(pInt) file
integer(pInt), dimension(1+2*maxNchunks) :: positions
character(len=80) line,tag
constitutive_parse_unknownPart = ''
do
read(unit=file,fmt='(a80)',end=100) line
positions = IO_stringPos(line,maxNchunks)
tag = IO_lc(IO_stringValue(line,positions,1))
if (tag(1:1)=='<' .and. tag(len(tag):len(tag)=='>') then
constitutive_parse_unknownPart = tag(2:len(tag)-1)
exit
endif
end do
100 return
END FUNCTION
!***********************************************************
!***********************************************************
character(len=80) function constitutive_parse_materialPart(file)
use prec, only: pInt
use IO, only: IO_stringPos,IO_stringValue,IO_lc
implicit none
integer(pInt), parameter :: maxNchunks = 2! may be more than 2 chunks ..?
integer(pInt) file,section
integer(pInt), dimension(1+2*maxNchunks) :: positions
character(len=80) line,tag
section = 0
constitutive_parse_materialPart = ''
do
read(unit=file,fmt='(a80)',end=100) line
positions = IO_stringPos(line,maxNchunks) ! parse leading chunks
tag = IO_lc(IO_stringValue(line,positions,1))
if (tag(1:1)=='#') then ! skip comment line
cycle
elseif (tag(1:1)=='<' .and. tag(len(tag):len(tag)=='>') then
constitutive_parse_materialPart = tag(2:len(tag)-1)
exit
elseif (tag(1:1)=='[' .and. tag(len(tag):len(tag)==']') then
section = section+1
else
if (section>0) then
select case(tag)
case ('crystal_structure') ! crystal structure
constitutive_crystal_structure(section)=IO_intValue(line,positions,2)
case ('nslip') case ('nslip')
constitutive_Nslip(constitutive_Nmats)=IO_intValue(line,positions,2) constitutive_Nslip(section)=IO_intValue(line,positions,2)
!* CASE2-3: Reading C11 elastic constant
case ('C11') case ('C11')
constitutive_C11(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_C11(section)=IO_floatValue(line,positions,2)
!* CASE2-4: Reading C12 elastic constant
case ('C12') case ('C12')
constitutive_C12(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_C12(section)=IO_floatValue(line,positions,2)
!* CASE2-5: Reading C13 elastic constant
case ('C13') case ('C13')
constitutive_C13(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_C13(section)=IO_floatValue(line,positions,2)
!* CASE2-6: Reading C33 elastic constant
case ('C33') case ('C33')
constitutive_C33(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_C33(section)=IO_floatValue(line,positions,2)
!* CASE2-7: Reading C44 elastic constant
case ('C44') case ('C44')
constitutive_C44(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_C44(section)=IO_floatValue(line,positions,2)
!* CASE2-8: Reading initial slip resistance
case ('s0_slip') case ('s0_slip')
constitutive_s0_slip(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_s0_slip(section)=IO_floatValue(line,positions,2)
!* CASE2-9: Reading slip rate reference
case ('gdot0_slip') case ('gdot0_slip')
constitutive_gdot0_slip(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_gdot0_slip(section)=IO_floatValue(line,positions,2)
!* CASE32-10: Reading slip rate sensitivity
case ('n_slip') case ('n_slip')
constitutive_n_slip(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_n_slip(section)=IO_floatValue(line,positions,2)
!* CASE2-11: Reading initial hardening slope
case ('h0') case ('h0')
constitutive_h0(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_h0(section)=IO_floatValue(line,positions,2)
!* CASE2-12: Reading saturation stress value
case ('s_sat') case ('s_sat')
constitutive_s_sat(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_s_sat(section)=IO_floatValue(line,positions,2)
!* CASE2-13: Reading hardening sensitivity
case ('w0') case ('w0')
constitutive_w0(constitutive_Nmats)=IO_floatValue(line,positions,2) constitutive_w0(section)=IO_floatValue(line,positions,2)
!* CASE2-14: Reading unknown parameter
case default case default
write(6,*) 'Unknown material parameter ',line write(6,*) 'Unknown material parameter ',line
end select end select
endif endif
end select endif
enddo end do
consititutive_parse_MaterialPart='NoOtherPart' 100 return
return
220 call IO_error(220) END FUNCTION
end function
function constitutive_parse_TexturePart(pass)
!*********************************************************** !***********************************************************
!* *
!*********************************************************** !***********************************************************
use prec, only: pReal,pInt character(len=80) function constitutive_parse_texturePart(file)
use IO
use prec, only: pInt
use IO, only: IO_stringPos,IO_stringValue,IO_lc
implicit none implicit none
!* Definition of variables integer(pInt), parameter :: maxNchunks = 10 ! may be more than 10 chunks ..?
character(len=*) line integer(pInt) file,pos,section
character(len=*) constitutive_parse_TexturePart integer(pInt), dimension(1+2*maxNchunks) :: positions
integer(pInt) positions(3) character(len=80) line,tag
!* Reading line of the opened file section = 0
do while(.true.) constitutive_parse_texturePart = ''
read(200,610,END=220) line
select case(line(1:1)) do
!* CASE1-1: A new part beginns read(unit=file,fmt='(a80)',end=100) line
case ('<') positions = IO_stringPos(line,maxNchunks) ! parse leading chunks
if (line(1:1).EQ.'<') tag = IO_lc(IO_stringValue(line,positions,1))
positions=IO_stringPos(line,1) if (tag(1:1)=='#') then ! skip comment line
consititutive_parse_TexturePart=IO_lc(IO_stringValue(line,positions,1)) cycle
return elseif (tag(1:1)=='<' .and. tag(len(tag):len(tag)=='>') then
endif constitutive_parse_texturePart = tag(2:len(tag)-1)
!* CASE1-2: Current line contains [comments] exit
case ('[') elseif (tag(1:1)=='[' .and. tag(len(tag):len(tag)==']') then
constitutive_Ntexts=constitutive_Ntexts+1 section = section+1
!* CASE1-3: Current line contains material parameters else
case default if (section>0) then
if (pass.EQ.2) then select case(tag)
positions=IO_stringPos(line,2)
select case(IO_lc(IO_stringValue(line,positions,1)))
!* CASE5-1: Reading ODF file
case ('hybridIA') case ('hybridIA')
constitutive_ODFfile(constitutive_Ntexts)=IO_stringValue(line,positions,2) constitutive_ODFfile(section)=IO_stringValue(line,positions,2)
!* CASE5-2: Reading Gauss component
case ('gauss') case ('gauss')
!* CASE5-3: Reading Fiber component
case ('fiber') case ('fiber')
!* CASE5-4: Reading number of grains
case ('ngrains') case ('ngrains')
constitutive_Ngrains(constitutive_Ntexts)=IO_intValue(line,positions,2) constitutive_Ngrains(section)=IO_intValue(line,positions,2)
!* CASE5-5: Reading symmetry
case ('symmetry') case ('symmetry')
constitutive_symmetry(constitutive_Ntexts)=IO_stringValue(line,positions,2) constitutive_symmetry(section)=IO_stringValue(line,positions,2)
!* CASE5-6: Reading unknown texture parameter
case default case default
write(6,*) 'Unknown texture parameter ',line write(6,*) 'Unknown texture parameter ',line
end select end select
endif endif
end select
enddo
consititutive_parse_TexturePart='NoOtherPart'
return
220 call IO_error(220)
end function
function constitutive_parse_UnknownPart()
!***********************************************************
!* OUTPUT: next_part *
!***********************************************************
use prec, only: pReal,pInt
use IO
implicit none
!* Definition of variables
character(len=*) line
character(len=*) constitutive_parse_UnknownPart
integer(pInt) positions(3)
!* Reading line of the opened file
do while(.true.)
read(200,610,END=220) line
if (line(1:1).EQ.'<')
positions=IO_stringPos(line,1)
constitutive_parse_UnknownPart=IO_lc(IO_stringValue(line,positions,1))
return
endif endif
enddo end do
constitutive_parse_UnknownPart='NoOtherPart' 100 return
return
220 call IO_error(220) END FUNCTION
end function
subroutine constitutive_parse_MatTexDat(filename)
subroutine constitutive_parse_MatTexDat()
!*********************************************************** !***********************************************************
!* Reading material parameters and texture components file * !* Reading material parameters and texture components file *
!*********************************************************** !***********************************************************
@ -472,77 +467,78 @@ use prec, only: pReal,pInt
use IO use IO
implicit none implicit none
!* Definition of variables character(len=*) filename
character(len=*) line character(len=80) part,formerPart
integer(pInt) pass,i,j,k,l integer(pInt) sectionCount,i,j,m
integer(pInt) positions(3)
!* Open materials_textures.mpie file open(200,FILE=filename,ACTION='READ',STATUS='OLD',ERR=100)
open(200,FILE='materials_textures.mpie',ACTION='READ',STATUS='OLD',ERR=100)
!* Reading file part = '_dummy_'
!* Reading in 2 passes: do while (part/='')
!* - 1rt: to get Nmats and Ntexts | to allocate arrays formerPart = part
!* - 2nd: to store material parameters and texture components call constitutive_countSections(200,sectionCount,part)
do pass=1,2 select case (formerPart)
!* Allocation of arrays case ('materials')
if (pass.EQ.2) then materials_maxN = sectionCount
allocate(constitutive_ODFfile(constitutive_Ntexts)) ; constitutive_ODFfile='' case ('textures')
allocate(constitutive_Ngrains(constitutive_Ntexts)) ; constitutive_Ngrains=0_pInt textures_maxN = sectionCount
allocate(constitutive_symmetry(constitutive_Ntexts)) ; constitutive_symmetry=''
allocate(constitutive_crystal_structure(constitutive_Nmats)) ; constitutive_crystal_structure=0_pInt
allocate(constitutive_Nslip(constitutive_Nmats)) ; constitutive_Nslip=0_pInt
allocate(constitutive_C11(constitutive_Nmats)) ; constitutive_C11=0.0_pReal
allocate(constitutive_C12(constitutive_Nmats)) ; constitutive_C12=0.0_pReal
allocate(constitutive_C13(constitutive_Nmats)) ; constitutive_C13=0.0_pReal
allocate(constitutive_C33(constitutive_Nmats)) ; constitutive_C33=0.0_pReal
allocate(constitutive_C44(constitutive_Nmats)) ; constitutive_C44=0.0_pReal
allocate(constitutive_s0_slip(constitutive_Nmats)) ; constitutive_s0_slip=0.0_pReal
allocate(constitutive_gdot0_slip(constitutive_Nmats)) ; constitutive_gdot0_slip=0.0_pReal
allocate(constitutive_n_slip(constitutive_Nmats)) ; constitutive_n_slip=0.0_pReal
allocate(constitutive_h0(constitutive_Nmats)) ; constitutive_h0=0.0_pReal
allocate(constitutive_s_sat(constitutive_Nmats)) ; constitutive_s_sat=0.0_pReal
allocate(constitutive_w0(constitutive_Nmats)) ; constitutive_w0=0.0_pReal
endif
!* Initialisation of numbers of materials and textures
constitutive_Nmats=0_pInt
constitutive_Ntexts=0_pInt
!* Reading first line
!* use functions parse_MaterialPart/TexturePart/UnknownPart
next_part=constitutive_parse_UnknownPart()
do while()
select case(next_part)
!* CASE1-1: the new part is <MATERIALS>
case ('<material>')
next_part=constitutive_parse_MaterialPart(pass)
!* CASE1-2: the new part is <TEXTURES>
case ('<textures>')
next_part=constitutive_parse_TexturePart(pass)
!* CASE1-3: the new part is unknown
case default
end select end select
enddo end do
enddo
!* Close file allocate(constitutive_ODFfile(constitutive_Ntexts)) ; constitutive_ODFfile=''
220 continue allocate(constitutive_Ngrains(constitutive_Ntexts)) ; constitutive_Ngrains=0_pInt
allocate(constitutive_symmetry(constitutive_Ntexts)) ; constitutive_symmetry=''
allocate(constitutive_crystal_structure(constitutive_Nmats)) ; constitutive_crystal_structure=0_pInt
allocate(constitutive_Nslip(constitutive_Nmats)) ; constitutive_Nslip=0_pInt
allocate(constitutive_C11(constitutive_Nmats)) ; constitutive_C11=0.0_pReal
allocate(constitutive_C12(constitutive_Nmats)) ; constitutive_C12=0.0_pReal
allocate(constitutive_C13(constitutive_Nmats)) ; constitutive_C13=0.0_pReal
allocate(constitutive_C33(constitutive_Nmats)) ; constitutive_C33=0.0_pReal
allocate(constitutive_C44(constitutive_Nmats)) ; constitutive_C44=0.0_pReal
allocate(constitutive_s0_slip(constitutive_Nmats)) ; constitutive_s0_slip=0.0_pReal
allocate(constitutive_gdot0_slip(constitutive_Nmats)) ; constitutive_gdot0_slip=0.0_pReal
allocate(constitutive_n_slip(constitutive_Nmats)) ; constitutive_n_slip=0.0_pReal
allocate(constitutive_h0(constitutive_Nmats)) ; constitutive_h0=0.0_pReal
allocate(constitutive_s_sat(constitutive_Nmats)) ; constitutive_s_sat=0.0_pReal
allocate(constitutive_w0(constitutive_Nmats)) ; constitutive_w0=0.0_pReal
part = '_dummy_'
do while (part/='')
select case (part)
case ('materials')
part = constitutive_parse_materialPart(200)
case ('textures')
part = constitutive_parse_texturePart(200)
case default
part = constitutive_parse_unknownPart(200)
end select
end do
close(200) close(200)
!* NOT IMPLEMENTED YET *! do m=1,material_maxN
! ** Defintion of stiffness matrices ** material_Cslip_66(:,:,m) = 0.0_pReal
! MISSING: this needs to be iterated over the materials select case (material_crystal_structure)
Cslip_66 = 0.0_pRe case (1:2) ! cubic structure
do i=1,3 do i=1,3
do j=1,3 do j=1,3
Cslip_66(i,j) = C12 material_Cslip_66(i,j,m) = C12
enddo enddo
Cslip_66(i,i) = C11 material_Cslip_66(i,i,m) = C11
Cslip_66(i+3,i+3) = C44 material_Cslip_66(i+3,i+3,m) = C44
enddo enddo
case (3) ! hcp structure MISSING correct
Cslip_3333(:,:,:,:) = math_66to3333(Cslip_66(:,:)) do i=1,3
do j=1,3
material_Cslip_66(i,j,m) = C12
enddo
material_Cslip_66(i,i,m) = C11
material_Cslip_66(i+3,i+3,m) = C44
enddo
end select
material_Cslip_3333(:,:,:,:,m) = math_66to3333(Cslip_66(:,:,m))
end do
! *** Transformation to get the MARC order *** ! *** Transformation to get the MARC order ***
! *** 11,22,33,12,23,13 *** ! *** 11,22,33,12,23,13 ***
@ -557,10 +553,10 @@ close(200)
Cslip_66(:,6)=2.0d0*Cslip_66(:,5) Cslip_66(:,6)=2.0d0*Cslip_66(:,5)
Cslip_66(:,5)=2.0d0*temp Cslip_66(:,5)=2.0d0*temp
! MISSING some consistency checks may be..?
return return
100 call IO_error(110) 100 call IO_error(110) ! corrupt matarials_textures file
200 call IO_error(210)
end subroutine end subroutine