Debian Codegraph @

examples/gengeo_example8.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 *
14 from math import sqrt
15 #An example python script to generate a regular aggregate of hexagonal grains
16 # with bonds broken along lines
17
18 # Define region extremities:
19 size = 150.0
20 xsize = size
21 ysize = size
22 minPoint = Vector3(0.0,0.0,0.0)
23 maxPoint = Vector3(xsize,ysize,0.0)
24
25 # Define the geometrical constraints for packing
26 top_line = Line2D (
27 startPoint = minPoint,
28 endPoint = Vector3(size,0.0,0.0)
29 )
30
31 bottom_line = Line2D (
32 startPoint = Vector3(0.0,40.,0.0),
33 endPoint = Vector3(40.,40.,0.0)
34 )
35
36 #or compact form:
37 left_line = Line2D(Vector3(40.,40.,0.0),Vector3(40.,0.0,0.0))
38 right_line = Line2D(minPoint, Vector3(0.0,ysize,0.0))
39
40 box = BoxWithLines2D (
41 minPoint = minPoint,
42 maxPoint = maxPoint
43 )
44 box.addLine(top_line)
45 box.addLine(bottom_line)
46 box.addLine(left_line)
47 box.addLine(right_line)
48
49 # Create a multi-group neighbour table to contain the particles:
50 mntable = MNTable2D (
51 minPoint = minPoint,
52 maxPoint = maxPoint,
53 gridSize = 1.25
54 )
55
56 # Fill the volume with particles:
57 packer = HGrainGenerator2D (
58 radius = 0.5
59 )
60
61 # Generate the packing
62 packer.generatePacking(
63 volume = box,
64 ntable = mntable,
65 tag = 0
66 )
67
68 # bond the particles
69 #mntable.generateBonds(0,1.0e-5,3)
70
71 # tag particles along the boundary lines (e.g. top_line, left_line etc.)
72 # using the compact form:
73 mntable.tagParticlesAlongLineWithMask(bottom_line, 5.0, 4, -1, 0)
74 mntable.tagParticlesAlongLineWithMask(top_line, 5.0, 8, -1, 0)
75 mntable.tagParticlesAlongLineWithMask(left_line, 8.0, 16, -1, 0)
76 mntable.tagParticlesAlongLineWithMask(right_line, 8.0, 32,-1, 0)
77
78 # write a geometry file in VTK format
79 mntable.write(
80 fileName = "temp/geo_example8.vtu",
81 outputStyle = 2
82 )
83
84 # write a geometry file in ESyS-Particle geo format
85 mntable.write(
86 fileName = "temp/geo_example8.geo",
87 outputStyle = 1
88 )