Debian Codegraph @

examples/gengeo_example11.py

raw
1 #############################################################
2 ## ##
3 ## Copyright (c) 2007-2017 by The University of Queensland ##
4 ## Centre for Geoscience Computing ##
5 ## http://earth.uq.edu.au/centre-geoscience-computing ##
6 ## ##
7 ## Primary Business: Brisbane, Queensland, Australia ##
8 ## Licensed under the Open Software License version 3.0 ##
9 ## http://www.apache.org/licenses/LICENSE-2.0 ##
10 ## ##
11 #############################################################
12
13 from gengeo import Vector3, Line2D, BoxWithLines2D, MNTable2D, InsertGenerator2D, CircleVol
14
15 # An example python script to generate a 2D rectangle of particles
16 # containing a circular cluster of bonded particles
17
18 # Define region extremities:
19 minPoint = Vector3(0.0,0.0,0.0)
20 maxPoint = Vector3(10.0,10.0,0.0)
21
22 # Define the volume to be filled with spheres:
23 box = BoxWithLines2D (
24 minPoint = minPoint,
25 maxPoint = maxPoint
26 )
27
28 # Define the geometrical constraints for packing
29 top_line = Line2D (
30 startPoint = Vector3(10.0,0.0,0.0),
31 endPoint = minPoint
32 )
33
34 bottom_line = Line2D (
35 startPoint = maxPoint,
36 endPoint = Vector3(0.0,10.0,0.0)
37 )
38
39 left_line = Line2D (
40 startPoint = Vector3(10.0,0.0,0.0),
41 endPoint = maxPoint
42 )
43
44 right_line = Line2D (
45 startPoint = minPoint,
46 endPoint = Vector3(0.0,10.0,0.0)
47 )
48
49
50 box.addLine(top_line)
51 box.addLine(bottom_line)
52 box.addLine(left_line)
53 box.addLine(right_line)
54
55 # Create a multi-group neighbour table to contain the particles:
56 mntable = MNTable2D (
57 minPoint = minPoint, # specific regional extremities
58 maxPoint = maxPoint,
59 gridSize = 2.5 # neighbour search algorithm grid size
60 )
61
62 # Fill the volume with particles:
63 packer = InsertGenerator2D (
64 minRadius = 0.1, # minimum radius of spheres to insert
65 maxRadius = 0.4, # maximum radius of spheres to insert
66 insertFails = 5000, # maximum number of insertion failures
67 maxIterations = 1000, # max. iterations for Newton-Raphson solver
68 tolerance = 1.0e-6 # max. allowable overlap of spheres
69 )
70
71 packer.generatePacking( volume = box, ntable = mntable, tag = 0)
72
73 # define circular area
74 center = Vector3(5.0,5.0,0.0)
75 radius = 2.5
76
77 circ_area=CircleVol(center,radius)
78
79 # tag particles in circular area
80 mntable.tagParticlesInVolume(circ_area,2,0)
81
82
83 # create bonds between neighbouring particles with tag 2:
84 mntable.generateBondsWithMask(
85 tolerance = 1.0e-5, # max. gap between "touching" particles
86 bondID = 0, # bond ID of created bonds
87 tag = 2,
88 mask = 2
89 )
90
91 # write the geometry to a file in raw format
92 mntable.write(
93 fileName = "temp/geo_example11.txt",
94 outputStyle = 0
95 )
96
97 # write the geometry to an ESyS-Particle geometry file
98 mntable.write(
99 fileName = "temp/geo_example11.geo",
100 outputStyle = 1
101 )
102
103 # write the geometry as a VTK file
104 mntable.write(
105 fileName = "temp/geo_example11.vtu",
106 outputStyle = 2
107 )