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
|
program random_irregular_cartesian_grid_v2
implicit none
real, parameter :: lx = 1., & ! Dimension du domaine selon l'axe Ox
ly = 1. ! Dimension du domaine selon l'axe Oy
real, parameter :: dmin = 0.05 ! Distance minimale entre 2 noeuds
integer, parameter :: nx = 10, & ! Nbr de colonnes
ny = 15 ! Nbr de lignes
real, dimension(nx) :: x ! grille (abscisses)
real, dimension(ny) :: y ! grille (ordonnees)
real, dimension(nx+ny-4) :: rnd ! Nombres pseudo-aléatoires 0 <= rnd <= 1
integer :: i, j, k, l
integer :: nxmax, nymax
real :: dx, dy, d, hx, hy
real :: time_begin,time_end
!**** Generation de la grille
nxmax = lx/dmin + 1; nymax = ly/dmin + 1
if (nx > nxmax) then
print *,"Contrainte impossible à satisfaire. Trop de noeuds selon Ox (nx > nxmax)"
stop
end if
if (ny > nxmax) then
print *,"Contrainte impossible à satisfaire. Trop de noeuds selon Oy (ny > nymax)"
stop
end if
call cpu_time(time_begin)
hx = lx/(nx-1); hy = ly/(ny-1) ! Pas du maillage régulier du domaine
x(1) = 0.; x(nx) = lx ! Les bords inf. et sup. du domaine sont mailles
y(1) = 0.; y(ny) = ly ! Les bords gauche et droit du domaine sont mailles
call random_number(rnd)
do i = 2, nx-1
x(i) = (i-1)*hx + (rnd(i-1)-0.5)*(hx-dmin)
end do
do i = 2, ny-1
y(i) = (i-1)*hy + (rnd(nx+i-3)-0.5)*(hy-dmin)
end do
call cpu_time(time_end)
print *,"*** Grille (Pt n°|x|y)",nx*ny," points."
do i = 1, nx
do j = 1, ny
print *,j+ny*(i-1),x(i),y(j)
end do
end do
print '("Generation",t20,": ",es7.1," s.")',(time_end-time_begin)
!*** Verification de la condition ||M_kl.M_ij|| >=
call cpu_time(time_begin)
do i = 1, nx
do j = 1, ny
do k = 1, nx
do l = 1, ny
dx = x(k) - x(i)
dy = y(l) - y(j)
d = sqrt(dx*dx + dy*dy)
if ((d < dmin).AND.((k /= i).OR.(l /= j))) then
print '("Error : Pt N°",i7," - ",i7," d = ",g9.3)',j+ny*(i-1),l+ny*(l-1),d
end if
end do
end do
end do
end do
call cpu_time(time_end)
print '("Verification",t20,": ",es7.1," s.")',(time_end-time_begin)
end program random_irregular_cartesian_grid_v2 |