~ubuntu-branches/ubuntu/quantal/python-demgengeo/quantal

« back to all changes in this revision

Viewing changes to examples/gengeo_example6.py

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2011-11-18 21:47:18 UTC
  • Revision ID: package-import@ubuntu.com-20111118214718-4ysqm3dhpqwdd7gd
Tags: upstream-0.99~bzr106
ImportĀ upstreamĀ versionĀ 0.99~bzr106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#############################################################
 
2
##                                                         ##
 
3
## Copyright (c) 2007-2011 by The University of Queensland ##
 
4
## Earth Systems Science Computational Centre (ESSCC)      ##
 
5
## http://www.uq.edu.au/esscc                              ##
 
6
##                                                         ##
 
7
## Primary Business: Brisbane, Queensland, Australia       ##
 
8
## Licensed under the Open Software License version 3.0    ##
 
9
## http://www.opensource.org/licenses/osl-3.0.php          ##
 
10
##                                                         ##
 
11
#############################################################
 
12
 
 
13
from gengeo import *
 
14
#An example python script to generate a triangular prism of bonded particles
 
15
 
 
16
size=5.0
 
17
# Define region extremities:
 
18
minPoint = Vector3(-1.0*size,-1.0*size,-1.0*size)
 
19
maxPoint = Vector3(size,size,size)
 
20
 
 
21
# Define the volume to be filled with spheres:
 
22
tribox = TriBox (
 
23
   minPoint = minPoint,
 
24
   maxPoint = maxPoint,
 
25
   inverted = False
 
26
)
 
27
tribox.addPlane(Plane(minPoint,Vector3(0.0,1.0,0.0)))
 
28
tribox.addPlane(Plane(minPoint,Vector3(0.0,0.0,1.0)))
 
29
tribox.addPlane(Plane(maxPoint,Vector3(0.0,0.0,-1.0)))
 
30
 
 
31
delta = maxPoint-minPoint
 
32
dx = delta.X()
 
33
dy = delta.Y()
 
34
tribox.addPlane(Plane(minPoint, Vector3(dy,-0.5*dx,0.0).unit()))
 
35
tribox.addPlane(Plane(maxPoint-Vector3(dx/2.0,0.0,0.0), Vector3(-1.0*dy,-0.5*dx,0.0).unit()))
 
36
 
 
37
# Create a multi-group neighbour table to contain the particles:
 
38
mntable = MNTable3D (
 
39
   minPoint = minPoint,
 
40
   maxPoint = maxPoint,
 
41
   gridSize = 2.5
 
42
)
 
43
 
 
44
# Fill the volume with particles:
 
45
packer = InsertGenerator3D (
 
46
   minRadius = 0.2,
 
47
   maxRadius = 1.0,
 
48
   insertFails = 1000,
 
49
   maxIterations = 1000,
 
50
   tolerance = 1.0e-6
 
51
)
 
52
 
 
53
# Generate the packing
 
54
packer.generatePacking(
 
55
   volume = tribox, 
 
56
   ntable = mntable
 
57
)
 
58
 
 
59
# generate bonds between neighbouring particles
 
60
mntable.generateBonds(
 
61
   tolerance = 1.0e-5,
 
62
   bondID = 0
 
63
)
 
64
 
 
65
# write a geometry file in VTK format
 
66
mntable.write(
 
67
   fileName = "temp/geo_example6.vtu",
 
68
   outputStyle = 2
 
69
)
 
70
 
 
71
# write a geometry file in ESyS-Particle geo format
 
72
mntable.write(
 
73
   fileName = "temp/geo_example6.geo",
 
74
   outputStyle = 1
 
75
)