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 conductor to air so create a layer for this region 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 if (conductor_data(conductor)%mesh_to_layer_type.EQ.3) then ! specific process for cylinders... ! First find the central square region found_square=.FALSE. do ix=0,nxmax-2 iy=ix if ( (conductor_data(conductor)%grid(ix,iy).EQ.1).AND. & (conductor_data(conductor)%grid(ix+1,iy+1).EQ.0)) then layer_number=layer_number+1 cx1=ix cw=2d0*(real(ix)+0.5d0)*conductor_data(conductor)%dl ch=2d0*(real(iy)+0.5d0)*conductor_data(conductor)%dl apx=conductor_data(conductor)%xc ! centre of circle apy=conductor_data(conductor)%yc 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 if (conductor_data(conductor)%auto_grid_density) then CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%w(layer_number), & conductor_data(conductor)%rw,nw_auto) CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%h(layer_number), & conductor_data(conductor)%rh,nh_auto) conductor_data(conductor)%anwinc(layer_number)=nw_auto conductor_data(conductor)%anhinc(layer_number)=nh_auto else conductor_data(conductor)%anwinc(layer_number)=conductor_data(conductor)%nwinc conductor_data(conductor)%anhinc(layer_number)=conductor_data(conductor)%nwinc end if found_square=.TRUE. EXIT ! leave the loop end if ! found the corner end do ! next row if (.NOT.found_square) then write(*,*)'ERROR: not found central square...' STOP 1 end if ! now search out in the x directiion adding layers do ix=cx1+1,nxmax do iy=0,cx1 ! search in y to find the extent of this layer if ( (conductor_data(conductor)%grid(ix,iy).EQ.1).AND. & (conductor_data(conductor)%grid(ix,iy+1).EQ.0)) then ! we have moved from metal to air so add four segments ! add layer on xmax side layer_number=layer_number+1 cw=conductor_data(conductor)%dl ch=2d0*real(iy+0.5d0)*conductor_data(conductor)%dl apx=conductor_data(conductor)%xc+real(ix)*conductor_data(conductor)%dl apy=conductor_data(conductor)%yc 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 if (conductor_data(conductor)%auto_grid_density) then CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%w(layer_number), & conductor_data(conductor)%rw,nw_auto) CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%h(layer_number), & conductor_data(conductor)%rh,nh_auto) conductor_data(conductor)%anwinc(layer_number)=nw_auto conductor_data(conductor)%anhinc(layer_number)=nh_auto else conductor_data(conductor)%anwinc(layer_number)=conductor_data(conductor)%nwinc conductor_data(conductor)%anhinc(layer_number)=conductor_data(conductor)%nwinc end if ! add layer on xmin side layer_number=layer_number+1 cw=conductor_data(conductor)%dl ch=2d0*real(iy+0.5d0)*conductor_data(conductor)%dl apx=conductor_data(conductor)%xc-real(ix)*conductor_data(conductor)%dl apy=conductor_data(conductor)%yc 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 if (conductor_data(conductor)%auto_grid_density) then CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%w(layer_number), & conductor_data(conductor)%rw,nw_auto) CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%h(layer_number), & conductor_data(conductor)%rh,nh_auto) conductor_data(conductor)%anwinc(layer_number)=nw_auto conductor_data(conductor)%anhinc(layer_number)=nh_auto else conductor_data(conductor)%anwinc(layer_number)=conductor_data(conductor)%nwinc conductor_data(conductor)%anhinc(layer_number)=conductor_data(conductor)%nwinc end if ! add layer on ymax side layer_number=layer_number+1 cw=2d0*real(iy+0.5d0)*conductor_data(conductor)%dl ch=conductor_data(conductor)%dl apx=conductor_data(conductor)%xc apy=conductor_data(conductor)%yc+real(ix)*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 if (conductor_data(conductor)%auto_grid_density) then CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%w(layer_number), & conductor_data(conductor)%rw,nw_auto) CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%h(layer_number), & conductor_data(conductor)%rh,nh_auto) conductor_data(conductor)%anwinc(layer_number)=nw_auto conductor_data(conductor)%anhinc(layer_number)=nh_auto else conductor_data(conductor)%anwinc(layer_number)=conductor_data(conductor)%nwinc conductor_data(conductor)%anhinc(layer_number)=conductor_data(conductor)%nwinc end if ! add layer on ymin side layer_number=layer_number+1 cw=2d0*real(iy+0.5d0)*conductor_data(conductor)%dl ch=conductor_data(conductor)%dl apx=conductor_data(conductor)%xc apy=conductor_data(conductor)%yc-real(ix)*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 if (conductor_data(conductor)%auto_grid_density) then CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%w(layer_number), & conductor_data(conductor)%rw,nw_auto) CALL calc_nmin(conductor_data(conductor)%skin_depth,conductor_data(conductor)%h(layer_number), & conductor_data(conductor)%rh,nh_auto) conductor_data(conductor)%anwinc(layer_number)=nw_auto conductor_data(conductor)%anhinc(layer_number)=nh_auto else conductor_data(conductor)%anwinc(layer_number)=conductor_data(conductor)%nwinc conductor_data(conductor)%anhinc(layer_number)=conductor_data(conductor)%nwinc end if EXIT ! this layer has been set so go to the next x layer end if ! found the corner end do ! next y 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