22 """Generates discretization of circle so that area of all nodes are same"""
23
24
25 sim_particle_r = radius
26
27
28 sim_particles = []
29
30
31 sim_particles_area = []
32
33
34 sim_num_theta = num_theta
35 sim_theta_interval = 2. * np.pi / (float(sim_num_theta))
36 angle = 0.
37
38
39 for i in xrange(num_r_points+1):
40
41 x = [radius - i * radius / (float(num_r_points)), 0.]
42
43 sim_particles.append(x)
44
45 x_next = [0., 0.]
46 if i < num_r_points - 1:
47 x_next = [radius - (i+1.) * radius / (float(num_r_points)), 0.]
48
49 x_prev = [0., 0.]
50 if i > 0:
51 x_prev = [radius - (i-1.) * radius / (float(num_r_points)), 0.]
52
53
54 area_new = 0.
55 if i == 0:
56 area_new = sim_theta_interval * (1. - (x[0] + x_next[0]) * (x[0] + x_next[0]) * 0.25)
57 elif i == num_r_points:
58 area_new = np.pi * ((x_prev[0] + x[0]) * (x_prev[0] + x[0]) * 0.25)
59 else:
60 area_new = sim_theta_interval * ((x_prev[0] + x[0]) * (x_prev[0] + x[0]) * 0.25 - (x_next[0] + x[0]) * (x_next[0] + x[0]) * 0.25)
61
62 sim_particles_area.append(area_new)
63 print_point(x, area_new)
64
65
66 sim_particles_new = []
67 sim_particles_area_new = []
68 for theta in xrange(sim_num_theta):
69 angle = theta * sim_theta_interval
70
71
72 matrix = []
73 a = [np.cos(angle), -np.sin(angle)]
74 matrix.append(a)
75 a = [np.sin(angle), np.cos(angle)]
76 matrix.append(a)
77
78 for i in xrange(len(sim_particles)):
79
80 x_old = [sim_particles[i][0], sim_particles[i][1]]
81 area = sim_particles_area[i]
82
83 x_new = mult(matrix, x_old)
84
85 continue_i = True
86 if i == len(sim_particles) - 1 and theta > 0:
87 continue_i = False
88
89 if continue_i == True:
90 sim_particles_new.append(x_new)
91 sim_particles_area_new.append(area)
92
93
94
95 inpf = open('circle_mesh.csv','w')
96
97
98 inpf.write("id, x, y, volume\n")
99
100 for i in xrange(len(sim_particles_new)):
101 inpf.write("%d, %Lf, %Lf,%Lf\n" % (i, sim_particles_new[i][0], sim_particles_new[i][1], sim_particles_area_new[i]))
102
103 inpf.close()
104