Debian Codegraph @

examples/gengeo_example6.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 __future__ import division
14 from gengeo import *
15 #An example python script to generate a triangular prism of bonded particles
16
17 size=5.0
18 # Define region extremities:
19 minPoint = Vector3(-1.0*size,-1.0*size,-1.0*size)
20 maxPoint = Vector3(size,size,size)
21
22 # Define the volume to be filled with spheres:
23 tribox = TriBox (
24 minPoint = minPoint,
25 maxPoint = maxPoint,
26 inverted = False
27 )
28 tribox.addPlane(Plane(minPoint,Vector3(0.0,1.0,0.0)))
29 tribox.addPlane(Plane(minPoint,Vector3(0.0,0.0,1.0)))
30 tribox.addPlane(Plane(maxPoint,Vector3(0.0,0.0,-1.0)))
31
32 delta = maxPoint-minPoint
33 dx = delta.X()
34 dy = delta.Y()
35 tribox.addPlane(Plane(minPoint, Vector3(dy,-0.5*dx,0.0).unit()))
36 tribox.addPlane(Plane(maxPoint-Vector3(dx/2.0,0.0,0.0), Vector3(-1.0*dy,-0.5*dx,0.0).unit()))
37
38 # Create a multi-group neighbour table to contain the particles:
39 mntable = MNTable3D (
40 minPoint = minPoint,
41 maxPoint = maxPoint,
42 gridSize = 2.5
43 )
44
45 # Fill the volume with particles:
46 packer = InsertGenerator3D (
47 minRadius = 0.2,
48 maxRadius = 1.0,
49 insertFails = 1000,
50 maxIterations = 1000,
51 tolerance = 1.0e-6
52 )
53
54 # Generate the packing
55 packer.generatePacking(
56 volume = tribox,
57 ntable = mntable
58 )
59
60 # generate bonds between neighbouring particles
61 mntable.generateBonds(
62 tolerance = 1.0e-5,
63 bondID = 0
64 )
65
66 # write a geometry file in VTK format
67 mntable.write(
68 fileName = "temp/geo_example6.vtu",
69 outputStyle = 2
70 )
71
72 # write a geometry file in ESyS-Particle geo format
73 mntable.write(
74 fileName = "temp/geo_example6.geo",
75 outputStyle = 1
76 )