added auto scaling of dimension to voronoi_tessellation.f90. If dimension(i) == 0, it will get the smallest step of the remaining dimensions in that direction. Same is now done by patchFromReconstructedBoundaries

setup_processing.py now gives executables the extension *.exe and removes the old executables before compiling
This commit is contained in:
Martin Diehl 2011-08-25 12:16:06 +00:00
parent 39b97f7b67
commit 272f7cc655
3 changed files with 105 additions and 85 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys,os,math,re import sys,os,math,re,string
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
@ -739,8 +739,8 @@ def fftbuild(rcData, height,xframe,yframe,resolution,extrusion): # bu
ysize = maxY+2*yframe ysize = maxY+2*yframe
xres=round(resolution/2.0)*2 # use only even resolution xres=round(resolution/2.0)*2 # use only even resolution
yres=round(xres/xsize*ysize/2.0)*2 # calculate other resolutions yres=round(xres/xsize*ysize/2.0)*2 # calculate other resolutions
zres=round(1) zres = 1
zsize = xsize/xres*zres # calculate z size zsize = min([xsize/xres,ysize/yres])
fftdata = {'fftpoints':[], \ fftdata = {'fftpoints':[], \
'resolution':(xres,yres,zres), \ 'resolution':(xres,yres,zres), \

View File

@ -127,7 +127,7 @@
endfunction endfunction
!******************************************************************** !********************************************************************
! locate at most N space-separated parts in line ! locate at most N space-separated parts in line
! return array containing number of parts in line and ! return array containing number of parts in line and
! the left/right positions of at most N to be used by IO_xxxVal ! the left/right positions of at most N to be used by IO_xxxVal
@ -172,10 +172,12 @@ program voronoi
logical gotN_Seeds, gotResolution logical gotN_Seeds, gotResolution
logical, dimension(:), allocatable :: grainCheck logical, dimension(:), allocatable :: grainCheck
character(len=1024) input_name, output_name, format1, format2, N_Digits, line, key character(len=1024) input_name, output_name, format1, format2, N_Digits, line, key
integer(pInt) a, b, c, N_Seeds, theGrain, i, j, k, l, m integer(pInt) N_Seeds, theGrain, i, j, k, l, m
integer(pInt), dimension (1+2*7) :: posGeom integer(pInt), dimension (1+2*7) :: posGeom
real(pReal), dimension(:,:), allocatable :: grainEuler, seeds real(pReal), dimension(:,:), allocatable :: grainEuler, seeds
real(pReal), dimension(3) :: step,dim,delta real(pReal), dimension(3) :: step,geomdim,delta
integer(pInt), dimension(3) :: resolution
logical, dimension(3) :: validDim
real(pReal) minDist, theDist real(pReal) minDist, theDist
real(pReal), parameter :: pi = 3.14159265358979323846264338327950288419716939937510_pReal real(pReal), parameter :: pi = 3.14159265358979323846264338327950288419716939937510_pReal
@ -209,11 +211,11 @@ program voronoi
do i = 2,6,2 do i = 2,6,2
select case (IO_lc(IO_stringValue(line,posGeom,i))) select case (IO_lc(IO_stringValue(line,posGeom,i)))
case('a') case('a')
a = IO_intValue(line,posGeom,i+1) resolution(1) = IO_intValue(line,posGeom,i+1)
case('b') case('b')
b = IO_intValue(line,posGeom,i+1) resolution(2) = IO_intValue(line,posGeom,i+1)
case('c') case('c')
c = IO_intValue(line,posGeom,i+1) resolution(3) = IO_intValue(line,posGeom,i+1)
end select end select
enddo enddo
end select end select
@ -225,24 +227,24 @@ program voronoi
allocate(grainCheck(N_Seeds)) allocate(grainCheck(N_Seeds))
grainCheck = .false. grainCheck = .false.
print*, 'resolution: ' ,a,b,c print*, 'resolution: ' ,resolution(1),resolution(2),resolution(3)
write(*, '(A)', advance = 'NO') 'resolution in x: ' write(*, '(A)', advance = 'NO') 'resolution in x: '
read(*, *), a read(*, *), resolution(1)
write(*, '(A)', advance = 'NO') 'resolution in y: ' write(*, '(A)', advance = 'NO') 'resolution in y: '
read(*, *), b read(*, *), resolution(2)
write(*, '(A)', advance = 'NO') 'resolution in z: ' write(*, '(A)', advance = 'NO') 'resolution in z: '
read(*, *), c read(*, *), resolution(3)
step(1) = 1.0_pReal/real(a,pReal) step(1) = 1.0_pReal/real(resolution(1),pReal)
step(2) = 1.0_pReal/real(b,pReal) step(2) = 1.0_pReal/real(resolution(2),pReal)
step(3) = 1.0_pReal/real(c,pReal) step(3) = 1.0_pReal/real(resolution(3),pReal)
write(*, '(A)', advance = 'NO') 'size in x: ' write(*, '(A)', advance = 'NO') 'size in x: '
read(*, *), dim(1) read(*, *), geomdim(1)
write(*, '(A)', advance = 'NO') 'size in y: ' write(*, '(A)', advance = 'NO') 'size in y: '
read(*, *), dim(2) read(*, *), geomdim(2)
write(*, '(A)', advance = 'NO') 'size in z: ' write(*, '(A)', advance = 'NO') 'size in z: '
read(*, *), dim(3) read(*, *), geomdim(3)
rewind(20) rewind(20)
read(20,'(a1024)') line read(20,'(a1024)') line
@ -264,7 +266,25 @@ program voronoi
enddo enddo
close(20) close(20)
!check dimensions, set dimension with 0 to smallest step of other dimensions
validDim = .false.
do i = 1,3
if(geomdim(i) .gt. 0.0) validDim(i) = .true.
enddo
if(all(validDim == .false.)) then
geomdim(maxval(maxloc(resolution))) = 1.0
validDim(maxval(maxloc(resolution))) = .true.
print*, 'no valid dimension specified, using automated setting'
endif
do i=1,3
if (validDim(i) == .false.) then
print*, 'rescaling ivalid dimension' , i
geomdim(i) = maxval(geomdim/real(resolution),validDim)*real(resolution(i))
endif
enddo
! calculate No. of digits needed for name of the grains ! calculate No. of digits needed for name of the grains
i = 1 + int( log10(real( N_Seeds ))) i = 1 + int( log10(real( N_Seeds )))
write(N_Digits, *) i write(N_Digits, *) i
@ -290,15 +310,14 @@ program voronoi
&' Phi2 ', grainEuler(i,3), ' scatter 0 fraction 1' &' Phi2 ', grainEuler(i,3), ' scatter 0 fraction 1'
end do end do
close(20) close(20)
print*, ''
print*, 'material.config done.' print*, 'material.config done.'
!write header of geom file !write header of geom file
open(20, file = ((trim(output_name))//'.geom')) open(20, file = ((trim(output_name))//'.geom'))
open(21, file = ((trim(output_name))//'.spectral')) open(21, file = ((trim(output_name))//'.spectral'))
write(20, '(A)'), '3 header' write(20, '(A)'), '3 header'
write(20, '(A, I8, A, I8, A, I8)'), 'resolution a ', a, ' b ', b, ' c ', c write(20, '(A, I8, A, I8, A, I8)'), 'resolution a ', resolution(1), ' b ', resolution(2), ' c ', resolution(3)
write(20, '(A, g15.10, A, g15.10, A, g15.10)'), 'dimension x ', dim(1), ' y ', dim(2), ' z ', dim(3) write(20, '(A, g15.10, A, g15.10, A, g15.10)'), 'dimension x ', geomdim(1), ' y ', geomdim(2), ' z ', geomdim(3)
write(20, '(A)'), 'homogenization 1' write(20, '(A)'), 'homogenization 1'
format1 = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//')' ! geom format format1 = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//')' ! geom format
@ -306,18 +325,18 @@ program voronoi
! perform voronoi tessellation and write result to files ! perform voronoi tessellation and write result to files
do i = 0, a*b*c-1 do i = 0, resolution(1)*resolution(2)*resolution(3)-1
minDist = dim(1)*dim(1)+dim(2)*dim(2)+dim(3)*dim(3) ! diagonal of rve minDist = geomdim(1)*geomdim(1)+geomdim(2)*geomdim(2)+geomdim(3)*geomdim(3) ! diagonal of rve
do j = 1, N_Seeds do j = 1, N_Seeds
delta(1) = step(1)*(mod(i , a)+0.5_pReal) - seeds(j,1) delta(1) = step(1)*(mod(i , resolution(1))+0.5_pReal) - seeds(j,1)
delta(2) = step(2)*(mod(i/a , b)+0.5_pReal) - seeds(j,2) delta(2) = step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal) - seeds(j,2)
delta(3) = step(3)*(mod(i/a/b, c)+0.5_pReal) - seeds(j,3) delta(3) = step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal) - seeds(j,3)
do k = -1, 1 ! left, me, right image do k = -1, 1 ! left, me, right image
do l = -1, 1 ! front, me, back image do l = -1, 1 ! front, me, back image
do m = -1, 1 ! lower, me, upper image do m = -1, 1 ! lower, me, upper image
theDist = ( dim(1) * ( delta(1)-real(k,pReal) ) )**2 + & theDist = ( geomdim(1) * ( delta(1)-real(k,pReal) ) )**2 + &
( dim(2) * ( delta(2)-real(l,pReal) ) )**2 + & ( geomdim(2) * ( delta(2)-real(l,pReal) ) )**2 + &
( dim(3) * ( delta(3)-real(m,pReal) ) )**2 ( geomdim(3) * ( delta(3)-real(m,pReal) ) )**2
if (theDist < minDist) then if (theDist < minDist) then
minDist = theDist minDist = theDist
theGrain = j theGrain = j
@ -329,9 +348,9 @@ program voronoi
grainCheck(theGrain) = .true. grainCheck(theGrain) = .true.
write(20, trim(format1)), theGrain write(20, trim(format1)), theGrain
write(21, trim(format2)), grainEuler(theGrain,1), grainEuler(theGrain,2), grainEuler(theGrain,3), & write(21, trim(format2)), grainEuler(theGrain,1), grainEuler(theGrain,2), grainEuler(theGrain,3), &
dim(1)*step(1)*(mod(i , a)+0.5_pReal), & geomdim(1)*step(1)*(mod(i , resolution(1))+0.5_pReal), &
dim(2)*step(2)*(mod(i/a , b)+0.5_pReal), & geomdim(2)*step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal), &
dim(3)*step(3)*(mod(i/a/b, c)+0.5_pReal), & geomdim(3)*step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal), &
theGrain, ' 1' theGrain, ' 1'
enddo enddo
close(20) close(20)

View File

@ -72,7 +72,8 @@ for dir in compile:
src = os.path.abspath(os.path.join(basedir,dir,file)) src = os.path.abspath(os.path.join(basedir,dir,file))
if os.path.isfile(src): if os.path.isfile(src):
print file print file
os.system('ifort -O3 -parallel -o%s %s'%(os.path.splitext(src)[0],src)) os.system('rm %s.exe'%(os.path.splitext(src)[0]))
os.system('ifort -O3 -parallel -o%s.exe %s'%(os.path.splitext(src)[0],src))
modules = glob.glob('*.mod') modules = glob.glob('*.mod')
for module in modules: for module in modules: