PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
discretize_circle_dense Namespace Reference

Functions

 print_point (point, area, prefix="")
 
 mult (matrix, vector)
 
 discretize_circle (radius, num_r_points)
 

Function Documentation

◆ discretize_circle()

discretize_circle_dense.discretize_circle (   radius,
  num_r_points 
)
Generates discretization of circle so that area of all nodes are same

Definition at line 21 of file discretize_circle_dense.py.

21def discretize_circle(radius, num_r_points):
22 """Generates discretization of circle so that area of all nodes are same"""
23
24 # particle data
25 sim_particle_r = radius
26
27 # store location of nodes
28 sim_particles = []
29
30 # store area of nodes
31 sim_particles_area = []
32
33 # width of annuli
34 sim_num_r_points = num_r_points
35 sim_annlui_width = 1. / sim_num_r_points
36
37 # loop over annulus
38 for i in xrange(sim_num_r_points):
39
40 radius_inner = (i + 1.) * sim_annlui_width
41 radius_outer = (i) * sim_annlui_width
42
43 # num divisions in angle
44 dn = 6 * (i + 1) - 3
45 dtheta = 2. * np.pi / float(dn)
46
47 # loop over theta
48 for theta in xrange(dn):
49
50 # get point
51 radius_quad = (i - 1. / 2.) * sim_annlui_width
52 x = [radius_quad * np.cos(theta * dtheta), radius_quad * np.sin(theta * dtheta)]
53
54 area = sim_annlui_width * sim_annlui_width * np.pi / 3.
55
56 sim_particles.append(x)
57 sim_particles_area.append(area)
58 print_point(x, area)
59
60 # End loop over theta
61
62 # End loop over annulus
63
64 #
65 # loop over points again and scale them to circle of given radius
66 #
67 sim_particles_new = []
68 sim_particles_area_new = []
69 for i in xrange(len(sim_particles)):
70
71 x = [radius * sim_particles[i][0], radius * sim_particles[i][1]]
72 area = radius * radius * sim_particles_area[i]
73 sim_particles_new.append(x)
74 sim_particles_area_new.append(area)
75
76 # End loop over particles
77
78 # print points to csv file
79 # generate csv file
80 inpf = open('mesh_cir.csv','w')
81
82 # header
83 inpf.write("id, x, y, volume\n")
84
85 for i in xrange(len(sim_particles_new)):
86 inpf.write("%d, %4.6e, %4.6e, %4.6e\n" % (i, sim_particles_new[i][0], sim_particles_new[i][1], sim_particles_area_new[i]))
87
88 inpf.close()
89

References print_point().

Here is the call graph for this function:

◆ mult()

discretize_circle_dense.mult (   matrix,
  vector 
)

Definition at line 18 of file discretize_circle_dense.py.

18def mult(matrix, vector):
19 return [matrix[0][0] * vector[0] + matrix[0][1] * vector[1], matrix[1][0] * vector[0] + matrix[1][1] * vector[1]]
20

◆ print_point()

discretize_circle_dense.print_point (   point,
  area,
  prefix = "" 
)

Definition at line 6 of file discretize_circle_dense.py.

6def print_point(point, area, prefix = ""):
7 str = prefix + " area = " + "%4.6e" %(area) + ", point = ["
8 N = 2
9 for i in xrange(N):
10 str += "%4.6e" % (point[i])
11 if i < N - 1:
12 str += ", "
13 else:
14 str += "]\n"
15
16 print(str)
17

Referenced by discretize_circle().

Here is the caller graph for this function: