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

« back to all changes in this revision

Viewing changes to examples/gengeo_crack.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
 
 
15
#An example python script to generate a bonded rectangle of particles with a discrete fracture network included
 
16
 
 
17
width = 50.0
 
18
height = width
 
19
# Define region extremities:
 
20
minPoint = Vector3(0.0,0.0,0.0)
 
21
maxPoint = Vector3(width,height,0.0)
 
22
 
 
23
# Define the geometrical constraints for packing
 
24
#       (e.g. lines bordering a rectangular region in 2D)
 
25
# QUESTION: Is there a particular order for defining endpoints of lines?
 
26
top_line = Line2D (
 
27
   startPoint = Vector3(width,0.0,0.0),
 
28
   endPoint = minPoint
 
29
)
 
30
 
 
31
bottom_line = Line2D (
 
32
   startPoint = maxPoint,
 
33
   endPoint = Vector3(0.0,height,0.0)
 
34
)
 
35
 
 
36
left_line = Line2D (
 
37
   startPoint = Vector3(width,0.0,0.0),
 
38
   endPoint = maxPoint
 
39
)
 
40
 
 
41
right_line = Line2D (
 
42
   startPoint = minPoint,
 
43
   endPoint = Vector3(0.0,height,0.0)
 
44
)
 
45
 
 
46
# Define the Volume to be filled with spheres:
 
47
#       (e.g. a BoxWithLines2D)
 
48
box = BoxWithLines2D (
 
49
   minPoint = minPoint,
 
50
   maxPoint = maxPoint
 
51
)
 
52
 
 
53
box.addLine(top_line)
 
54
box.addLine(bottom_line)
 
55
box.addLine(left_line)
 
56
box.addLine(right_line)
 
57
 
 
58
 
 
59
# Create a multi-group neighbour table to contain the particles:
 
60
mntable = MNTable2D (
 
61
   minPoint = minPoint,
 
62
   maxPoint = maxPoint,
 
63
   gridSize = 2.5
 
64
)
 
65
 
 
66
# Fill the volume with particles:
 
67
packer = InsertGenerator2D (
 
68
   minRadius = 0.1,
 
69
   maxRadius = 1.0,
 
70
   insertFails = 10000,
 
71
   maxIterations = 10000,
 
72
   tolerance = 1.0e-6
 
73
)
 
74
 
 
75
packer.generatePacking( volume = box, ntable = mntable, tag = 0)
 
76
 
 
77
# create bonds between neighbouring particles:
 
78
mntable.generateBonds(
 
79
   tolerance = 1.0e-5,
 
80
   bondID = 0
 
81
)
 
82
 
 
83
#Add a discrete fracture network
 
84
brkLine = LineSegment2D (
 
85
   startPoint = Vector3(0.4*width,0.4*height,0.0),
 
86
   endPoint = Vector3(0.6*width,0.6*height,0.0)
 
87
)
 
88
 
 
89
mntable.breakBondsAlongLineSegment(
 
90
   lineSegment = brkLine,
 
91
   distance = 0.25,
 
92
   tag = 0
 
93
)
 
94
 
 
95
# write a geometry file
 
96
mntable.write(
 
97
   fileName = "temp/geo_crack.geo",
 
98
   outputStyle = 1
 
99
)
 
100
# write a vtk file
 
101
mntable.write(
 
102
   fileName = "temp/geo_crack.vtu",
 
103
   outputStyle = 2
 
104
)