1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| c23456 cp tetra_f.txt tetra.f
c23456 cp tetra.f tetra_f.txt
c23456 gfortran tetra.f -o tetra
c23456 echo; echo; echo; ./tetra
c23456 echo; echo; echo; gdb ./tetra<RUN
c23456----------------------------------------------------------------|
program tetra
implicit none
integer Nnoeud
integer Nelem
parameter(Nnoeud=12)
parameter(Nelem=22)
character*80 line
integer i
integer j
integer k
integer element(Nelem) ! il y a Nelem elements
integer element_type(Nelem)
integer N1(Nelem)
integer N2(Nelem)
integer N3(Nelem)
integer N4(Nelem)
integer N(Nnoeud) ! ça c'est pour les numéros de nuds
integer tmp
real a12, a14, a23 ! longueurs des côtés N1-N2
real p1, p2, p3, p4 ! demi-sommes des longueurs des côtés de la face opposée a N
real s1, s2, s3, s4 ! surface de la face opposée a N
real XN(Nnoeud), YN(Nnoeud), ZN(Nnoeud) ! ça c'est pour les coordonnées du noeud N=1->9
common//N
c23456----------------------------------------------------------------|
print'(/A)', '--------------------------------- debut '//
+ 'de tetra ------------------------------|'
c23456----------------------------------------------------------------|
c Ouvertures sous linux à la maison :
open(1, file="/home/david/F90/coords")
open(2, File="/home/david/F90/tetareda")
c
c23456----------------------------------------------------------------|
c Ouvertures sous linux au boulot :
c open(1, File="/data/home/dvanaelst/F90/FDEV/coords")
c open(2, File="/data/home/dvanaelst/F90/FDEV/tetareda")
c
c23456----------------------------------------------------------------|
c Ouvertures sous DOS/windows :
c open(1, file="c:\coords")
c open(2, File="c:\tetareda")
c23456----------------------------------------------------------------|
c Lecture des coordonnées des noeuds : (9/10 noeuds seulement, pour qq elts)
do i=1, Nnoeud
10 read(1, '(A)', end=15) line
if(line(1:1)=='#') print'(/A)', line
if(line(1:1)=='#') goto 10
write(6, '(3X,A)') trim(line)
read(line, *) N(i), XN(i), YN(i), ZN(i)
write(6, '(I2,I6,F7.2,F12.2,F12.2)')
+i, N(i), XN(i), YN(i), ZN(i) ! pour contrôler
enddo
15 close(1)
print*, ' N(12)=', N(12), ', XN(12)=', ZN(12)
print*, ' YN(12)=', YN(12), ', ZN(12)=', ZN(12)
c23456----------------------------------------------------------------|
c Lecture des éléments :
do j=1, 3 ! Nelem
20 read(2, '(A)', end=25) line
if(line(1:1)=='#') print'(/A)', line
if(line(1:1)=='#') goto 20
print'(A)', line
read(line, *) element(j), element_type(j),
+N1(j), N2(j), N3(j), N4(j)
print'(2I6, 5I12)', j, element(j), element_type(j),
+N1(j), N2(j), N3(j), N4(j) ! pour contrôler
enddo
25 close(2)
print*, ' N4(2)=', N4(2), ', N(12)=', N(12)
c23456----------------------------------------------------------------|
c Formule de Héron, permet le calcul de l'aire S, connaissant les longueurs
c des trois côtés a, b et c d'un triangle, et donc aussi leur demi-somme p :
c S =sqrt(p x ( p − a ) x ( p − b ) x ( p − c ))
c23456----------------------------------------------------------------|
c Traitement des noeuds des faces :
c Il me faut connaître le N° d'ordre i d'un noeud N, que je vais appeler,
c K(N), avec N=N1(j) ou N2(j) ou N3(j) ou N4(j), j étant un N° d'élément.
do j=1, 3 ! Nelem
print'(/A,I2)', 'Elt j=', j
print'(4(A,I6))', 'Noeuds : N1(j)=', N1(j),
+', N2(j)=', N2(j),
+', N3(j)=', N3(j),
+', opposés à N4(j)=', N4(j)
print'(A,I2, A,I6, A,I6, 3(/6X,A,I6, A,I6 ,X))',' j=', j,
+', N1(j)=', N1(j), ', K(N1(j))=', K(N1(j)),
+' N2(j)=', N2(j), ', K(N2(j))=', K(N2(j)),
+' N3(j)=', N3(j), ', K(N3(j))=', K(N3(j)),
+' N4(j)=', N4(j), ', K(N4(j))=', K(N4(j))
print'(3(A, F6.2, X))',
+' XN(K(N1(j)))=', XN(K(N1(j))),
+', YN(K(N1(j)))=', YN(K(N1(j))),
+', ZN(K(N1(j)))=', ZN(K(N1(j)))
print'(3(A, F6.2, X))',
+' XN(K(N2(j)))=', XN(K(N2(j))),
+', YN(K(N2(j)))=', YN(K(N2(j))),
+', ZN(K(N2(j)))=', ZN(K(N2(j)))
print'(3(A, F6.2, X))',
+' XN(K(N3(j)))=', XN(K(N3(j))),
+', YN(K(N3(j)))=', YN(K(N3(j))),
+', ZN(K(N3(j)))=', ZN(K(N3(j)))
c arête 12=N1(j), N2(j)
a12=sqrt( (XN(K(N2(j)))-XN(K(N1(j))) )**2
+ + (YN(K(N2(j)))-YN(K(N1(j))) )**2
+ + (ZN(K(N2(j)))-ZN(K(N1(j))) )**2 )
print'(A,I2, 2(A,I6))', 'Elt j=', j,
+', arête a12, de N1(j)=', N1(j), ' à N2(j)=', N2(j)
print'(2(A,I6), A,F8.3)', 'soit de K(N1(j))=', K(N1(j)),
+' à K(N2(j))=', K(N2(j)), '; long.=', a12
c arête 14=N1(j), N4(j) (+)
a14=sqrt( (XN(K(N4(j)))-XN(K(N1(j))) )**2
+ + (YN(K(N4(j)))-YN(K(N1(j))) )**2
+ + (ZN(K(N4(j)))-ZN(K(N1(j))) )**2 )
print'(A,I2, 2(A,I6))', 'Elt j=', j,
+', arête a14, de N1(j)=', N1(j), ' à N4(j)=', N4(j)
print'(2(A,I6), A,F8.3)', 'soit de K(N1(j))=', K(N1(j)),
+' à K(N4(j))=', K(N4(j)), '; long.=', a14
c arête 23=N2(j), N3(j)
a23=sqrt( (XN(K(N3(j)))-XN(K(N2(j))) )**2
+ + (YN(K(N3(j)))-YN(K(N2(j))) )**2
+ + (ZN(K(N3(j)))-ZN(K(N2(j))) )**2 )
print'(A,I2, 2(A,I6))', 'Elt j=', j,
+', arête a23, de N2(j)=', N2(j), ' à N3(j)=', N3(j)
print'(2(A,I6), A,F8.3)', 'soit de K(N2(j))=', K(N2(j)),
+' à K(N3(j))=', K(N3(j)), '; long.=', a23
p4=(a12+a14+a23)/2
s4=sqrt(p4 * (p4-a12) * (p4-a14) * (p4-a23) )/2.
print'(A,I2, 3(A,I6))', 'Elt j=', j,
+', face opposée à N4, N1(j)=', N1(j), ', N2(j)=', N2(j),
+' et N3(j))=', N3(j)
print'(3(A,I6), A,F8.3)', ' soit de K(N3(j))=', N3(j),
+' à K(N2(j))=', K(N2(j)), ' et K(N3(j))=', K(N3(j)),
+'; surf.=', s4
print*, ' surf.=', s4
c
c??? N1(j), N2(j), N4(j) ! face opposée au noeud 3
c arête 12=N1(j), N2(j) (-)
c arête 14=N1(j), N4(j) (+/-)
c arête 24=N2(j), N4(j)
c
c??? N1(j), N3(j), N4(j) ! face opposée au noeud 2
c arête 13=N1(j), N3(j)
c arête 14=N1(j), N4(j) (+/-)
c arête 34=N3(j), N4(j)
c
c??? N2(j), N3(j), N4(j) ! face opposée au noeud 1
c arête 23=N2(j), N3(j) (-)
c arête 24=N2(j), N4(j) (+/-)
c arête 34=N3(j), N4(j) (-)
end do
c23456----------------------------------------------------------------|
print'(A/)', '----------------------------------- fin '//
+ 'de tetra ------------------------------|'
stop
end
c
c23456----------------------------------------------------------------|
function K(NN)
implicit none
integer Nnoeud
parameter(Nnoeud=12)
integer i
integer K ! indice du noeud passé en argument
integer N(Nnoeud)
integer NN ! N° du noeud dont on cherche l'indice
common//N
do i=1, Nnoeud
if(NN.eq.N(i))then
K=i
return
endif
enddo
print'(A,I2, A,I6)', 'Err. fonc.K(NN), i=', i, ', NN=', NN
stop
end
c23456----------------------------------------------------------------| |
Partager