phd-scripts/Unpublished/3D_Voxel_Assign/GeomGenPost2.f90

74 lines
No EOL
2.3 KiB
Fortran

!This program calculates the distance from each element
!to its nearest grain boundary
Program GeomGenPost
!
! Parameters
parameter(max_elements=1000000)
parameter(max_neigh_per_elem=6)
!
! Declare Variables
character*256 input,input2(2)
integer active(max_elements)
integer cellstat(max_elements)
integer elem_neighbours(max_neigh_per_elem)
!
! Initialise Variables
active=0
elem_neighbours=0
!
! Copy new data into updated input file
open(unit=10,file='GeomGenTemp.inp',status='unknown')
open(unit=12,file='GeomGenINP.inp',status='unknown')
input2(1)='**'
do while (index(input2(1),'*End Assembly')==0)
read(10,'(a)')input2(2)
write(12,'(a)')input2(1)
input2(1)=input2(2)
enddo
write(12,'(a)')'*End Assembly'
write(12,*)'*INITIAL CONDITIONS,TYPE=SOLUTION'
open(unit=13,file='ecor.dat',status='old')
active=0
ierr=0
do while (ierr==0)
read(13,*,iostat=ierr)ielnum
if(ierr==0)active(ielnum)=1
enddo
open(unit=14,file='testout.dat',status='old')
ierr=0
do while (ierr==0)
read(13,*,iostat=ierr)ielnum,icell
if(ierr==0)cellstat(ielnum)=icell
enddo
! Open GeomGen output file and read element connectivity, cell, face and
! vertice data.
open(unit=11,file='vertout.dat',status='old')
read(11,*)num_cells
do i=1,num_cells
read(11,*)num_elements
do j=1,num_elements
read(11,*)ielem_label
read(11,*)num_neighbours
do k=1,num_neighbours
read(11,*)elem_neighbours(k)
enddo
read(11,*)distance
write(12,'(a,8(i6,a))')'Assembly.CorPart.',ielem_label,',',elem_neighbours(1),&
& ',',elem_neighbours(2),',',elem_neighbours(3),',',elem_neighbours(4),&
& ',',elem_neighbours(5),',',elem_neighbours(6),',',0,','
write(12,'(2(i6,a),f18.6,a,5(i6,a))')ielem_label,',',active(elem_label),',',&
& distance,',',cellstat(ielem_label),',',0,',',0,',',0,',',0,','
write(12,'(8(i6,a))')0,',',0,',',0,',',0,',',1,',',0,',',0,',',0,','
write(12,'(6(i6,a),f18.6)')0,',',0,',',0,',',0,',',0,',',0,',',0.
enddo
enddo
ierr=0
do while (ierr==0)
read(10,'(a)',iostat=ierr)input2(1)
if(ierr==0)write(12,'(a)')input2(1)
enddo
close(unit=10)
close(unit=11)
close(unit=12)
close(unit=13)
End Program