set_segments_from_grid.F90
3.01 KB
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
nxmin=conductor_data(conductor)%nxmin
nxmax=conductor_data(conductor)%nxmax
nymin=conductor_data(conductor)%nymin
nymax=conductor_data(conductor)%nymax
layer_number=0
if (conductor_data(conductor)%mesh_to_layer_type.EQ.1) then
! each marked cell in the grid becomes a layer and hence a segment
do ix=nxmin,nxmax
do iy=nymin,nymax
if ( conductor_data(conductor)%grid(ix,iy).EQ.1 ) then
layer_number=layer_number+1
apx=conductor_data(conductor)%xc+real(ix)*conductor_data(conductor)%dl
apy=conductor_data(conductor)%yc+real(iy)*conductor_data(conductor)%dl
conductor_data(conductor)%x(layer_number)=apx
conductor_data(conductor)%y(layer_number)=apy
conductor_data(conductor)%w(layer_number)=conductor_data(conductor)%dl
conductor_data(conductor)%h(layer_number)=conductor_data(conductor)%dl
conductor_data(conductor)%d(layer_number)=0.0
conductor_data(conductor)%anwinc(layer_number)=conductor_data(conductor)%nwinc
conductor_data(conductor)%anhinc(layer_number)=conductor_data(conductor)%nwinc
end if
end do
end do
else if (conductor_data(conductor)%mesh_to_layer_type.EQ.2) then
! each row of cells in the grid becomes a segment
do iy=nymin,nymax
in_conductor=.FALSE.
cx1=0
cx2=0
do ix=nxmin,nxmax
if ( (.NOT.in_conductor).AND.(conductor_data(conductor)%grid(ix,iy).EQ.1) ) then
! we have moved from air to conductor so save this x cell number
cx1=ix
in_conductor=.TRUE.
else if ( (in_conductor).AND.(conductor_data(conductor)%grid(ix,iy).EQ.0) ) then
! we have moved from air to conductor so save this x cell number
cx2=ix-1
in_conductor=.FALSE.
layer_number=layer_number+1
cw=real(cx2-cx1+1)*conductor_data(conductor)%dl
ch=conductor_data(conductor)%dl
apx=conductor_data(conductor)%xc+real(cx2+cx1)/2.0
apy=conductor_data(conductor)%yc+real(iy)*conductor_data(conductor)%dl
conductor_data(conductor)%x(layer_number)=apx
conductor_data(conductor)%y(layer_number)=apy
conductor_data(conductor)%w(layer_number)=cw
conductor_data(conductor)%h(layer_number)=ch
conductor_data(conductor)%d(layer_number)=0.0
conductor_data(conductor)%anwinc(layer_number)=conductor_data(conductor)%nwinc
conductor_data(conductor)%anhinc(layer_number)=conductor_data(conductor)%nwinc
cx1=0
cx2=0
end if
end do ! next col
end do ! next row
else
write(*,*)'Unknown mesh_to_layer_type:',conductor_data(conductor)%mesh_to_layer_type, &
'in conductor',conductor
STOP 1
end if
! the number of layers may have changed if we have combined grid cells
conductor_data(conductor)%tot_n_layers=layer_number