~ubuntu-branches/ubuntu/saucy/python-demgengeo/saucy

« back to all changes in this revision

Viewing changes to examples/gengeo_exampleShapeList.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 bonded rectangular prism
 
15
 
 
16
# Define region extremities:
 
17
maxRadius = 1.0
 
18
size = 4.0
 
19
minPoint = Vector3(0.0,0.0,0.0)
 
20
maxPoint = Vector3(size,2.0*size,size)
 
21
 
 
22
# Define the volume to be filled with spheres:
 
23
#       (e.g. a box bounded by planes)
 
24
# QUESTION: Are there constraints on normals e.g. inward facing?
 
25
box = BoxWithPlanes3D (
 
26
   minPoint = minPoint,
 
27
   maxPoint = maxPoint
 
28
)
 
29
 
 
30
box.addPlane(
 
31
   Plane(
 
32
      origin = minPoint, 
 
33
      normal = Vector3(1.0,0.0,0.0)
 
34
   )
 
35
)
 
36
#or the compact form:
 
37
box.addPlane(Plane(minPoint, Vector3(0.0,1.0,0.0)))
 
38
box.addPlane(Plane(minPoint, Vector3(0.0,0.0,1.0)))
 
39
box.addPlane(Plane(maxPoint, Vector3(-1.0,0.0,0.0)))
 
40
box.addPlane(Plane(maxPoint, Vector3(0.0,-1.0,0.0)))
 
41
box.addPlane(Plane(maxPoint, Vector3(0.0,0.0,-1.0)))
 
42
 
 
43
# Create a multi-group neighbour table to contain the particles:
 
44
mntable = MNTable3D (
 
45
   minPoint = minPoint,
 
46
   maxPoint = maxPoint,
 
47
   gridSize = 2.5*maxRadius
 
48
)
 
49
 
 
50
 
 
51
sList = ShapeList()
 
52
 
 
53
sList.addGenericShape(
 
54
   db = "shapeDatabase.db",
 
55
   name = "sphere",
 
56
   bias = 1,
 
57
   random = 1,
 
58
   particleTag = 1,
 
59
   bondTag = 1
 
60
)
 
61
 
 
62
sList.addGenericShape(
 
63
   db = "shapeDatabase.db",
 
64
   name = "test",
 
65
   bias = 5,
 
66
   random = 1,
 
67
   particleTag = 2,
 
68
   bondTag = 2 
 
69
)
 
70
   
 
71
# Fill the volume with particles:
 
72
packer = InsertGenerator3D (
 
73
   minRadius = 0.2,
 
74
   maxRadius = maxRadius,
 
75
   insertFails = 1000,
 
76
   maxIterations = 1000,
 
77
   tolerance = 1.0e-6
 
78
)
 
79
 
 
80
packer.generatePacking(
 
81
   volume = box, 
 
82
   ntable = mntable,
 
83
   tag = 0,
 
84
   shapeList = sList
 
85
)
 
86
 
 
87
# print the porosity:
 
88
volume = 2.0*size*size*size
 
89
porosity = (volume - mntable.getSumVolume())/volume
 
90
print "Porosity:  ", porosity
 
91
 
 
92
# write a geometry file in VTK format
 
93
mntable.write(
 
94
   fileName = "temp/geo_exampleShapeList.vtu",
 
95
   outputStyle = 2      
 
96
)
 
97
 
 
98
# write a geometry file in raw (debug) format
 
99
mntable.write(
 
100
   fileName = "temp/geo_exampleShapeList.raw",
 
101
   outputStyle = 0              
 
102
)
 
103
 
 
104
# write a geometry file in gengeo file format
 
105
mntable.write(
 
106
   fileName = "temp/geo_exampleShapeList.geo",
 
107
   outputStyle = 1                      
 
108
)
 
109