Hello!A month ago I wanted to add a fortran program, in the wiki page, that allowed a "Gambit file" to be converted into a ".ucd file", which can be read by Deal II.
But when I tried to access to Wiki page, I obtained an error message.
Since some people seem to be interested in it, I have decided to attach it in the listing mail. The explanation of the program is in its text and I also attach a readme file.
It is very simple, but it worked fine in the cases I tested. So, I hope it is useful.
If there are some mistakes, sorry :-[ Best regards Isa
c Ruhollah Tavakoli wrote a small Fortran program to convert "gambit format" to ".ucd format" for his specific use.
c I (Maria Isabel Gil) changed it to be able to convert a ".neu file" (a Gambit format), working with 2D dimensions,
c in a ".ucd file", also in 2D dimensions, whose structure can be read by DealII.
c It must be remarked that the ".neu file" must suffer from some modifications before executing this code over it. Read "readme.txt" file.
PROGRAM CONVERTOR
INTEGER CON(1000000, 4)
INTEGER MAT(1000000)
INTEGER MAT_MEM(1000000)
REAL*8 X1,X2
INTEGER PORO_MEM,PORO
INTEGER II
CHARACTER*50 CH
INTEGER DUMMY, ZERO
ZERO = 0
c ".neu file" to be converted.
OPEN(UNIT=1,FILE='isabel.neu')
c ".ucd file" created by this executable.
OPEN(UNIT=2,FILE='isabel2.ucd')
READ(1,*)
READ(1,*)
READ(1,*)
READ(1,*)
READ(1,*)
READ(1,*)
c We read the number of points, number of elements and number of boundary conditions.
READ(1,*) NP, NE, DUMMY, NBC
c The variable "N_OFF" is added because we must include the number of cells that belong to the inlet, the outlet and those ones that belong to the wall.
INTEGER N_OFF
c In my case, N_OFF takes the following value:
N_OFF=40+60+372
WRITE(2,*) NP, (NE+NOFF), ZERO, ZERO, ZERO
READ(1,*)
READ(1,*)
c We read the coordinates of every point.
DO I=1,NP
READ(1,*) IP, X1, X2
c In the ".neu file" we work with millimeters(mm) and we want to work with meters(m).
X1=X1*1E-3
X2=X2*1E-3
WRITE(2,*) IP, X1, X2, ZERO
ENDDO
READ(1,*)
READ(1,*)
c We read the number of cells and their four vertices (2D dimensions).
DO I=1,NE
READ(1,*) IE, DUMMY, DUMMY,CON(I,1),CON(I,2),CON(I,3),CON(I,4)
ENDDO
c We know that there are material conditions and that, in my case, there are two different types:
c 1) We read the number of cells that are PORO (the first material type).
READ(1,*) NGDL
READ(1,*) PORO
c 1) We save, through a vector, the values of these cells.
READ(1,*)(MAT(i), i=1,NGDL)
c 2) We read the number of cells that are PORO_MEM (the second material type).
READ(1,*) NMEM
READ(1,*) PORO_MEM
c 2) We save, through a vector, the values of these cells.
READ(1,*) (MAT_MEM(i), i=1,NMEM)
c We want to write each cell along with its own material. In my case "0" is used if there isn't any material at all, "1" if they are cells with the first
c material condition and "2" if they are cells belonging to the second material condition.
c Firstly we must classify the cells and then write them out.
1000 DO I=1,NE
CUENTO=0;
DO J=1,max(NGDL,NMEM)
IF (I.EQ.MAT(J)) THEN
WRITE(2,*) I, PORO, ' quad',CON(I,1),CON(I,2),CON(I,3),CON(I,4)
EXIT
ELSE IF (I.EQ.MAT_MEM(J)) THEN
WRITE(2,*) I, PORO_MEM, ' quad',CON(I,1),CON(I,2),CON(I,3),CON(I,4)
EXIT
ELSE
CUENTO=CUENTO+1;
ENDIF
ENDDO
IF (CUENTO.EQ.max(NGDL,NMEM)) THEN
WRITE(2,*) I, ZERO, ' quad',CON(I,1),CON(I,2),CON(I,3),CON(I,4)
ENDIF
ENDDO
c WRITE(*,*)'BIEN6'
c Besides the previous number of cells, we have to add the lines containing the boundary conditions.
II=NE
DO IBC =1,NBC
c WRITE(*,*)'BIEN7'
READ(1,*) CH
READ(1,*) IDBC, NIN, DUMMY, DUMMY
WRITE(*,*) NIN
DO J=1, NIN
II=II+1
READ(1,*) IELE, DUMMY, IEDGE
IP1=IEDGE
IP2=IEDGE + 1
IF(IP2.GT.4) IP2=1
WRITE(2,*) II,IDBC, ' line',CON(IELE,IP1),CON(IELE,IP2)
ENDDO
ENDDO
READ(1,*)
CLOSE(1)
CLOSE(2)
END
readme.pdf
Description: Adobe PDF document
_______________________________________________
