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

« back to all changes in this revision

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