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

« back to all changes in this revision

Viewing changes to examples/gengeo_DFN.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
   endPoint = Vector3(0.0,height,0.0)
 
35
)
 
36
 
 
37
left_line = Line2D (
 
38
   startPoint = Vector3(width,0.0,0.0),
 
39
   endPoint = maxPoint
 
40
)
 
41
 
 
42
right_line = Line2D (
 
43
   startPoint = minPoint,
 
44
   endPoint = Vector3(0.0,height,0.0)
 
45
)
 
46
 
 
47
# Define the Volume to be filled with spheres:
 
48
#       (e.g. a BoxWithLines2D)
 
49
box = BoxWithLines2D (
 
50
   minPoint = minPoint,
 
51
   maxPoint = maxPoint
 
52
)
 
53
 
 
54
box.addLine(top_line)
 
55
box.addLine(bottom_line)
 
56
box.addLine(left_line)
 
57
box.addLine(right_line)
 
58
 
 
59
 
 
60
# Create a multi-group neighbour table to contain the particles:
 
61
mntable = MNTable2D (
 
62
   minPoint = minPoint,
 
63
   maxPoint = maxPoint,
 
64
   gridSize = 2.5
 
65
)
 
66
 
 
67
# Fill the volume with particles:
 
68
packer = InsertGenerator2D (
 
69
   minRadius = 0.1,
 
70
   maxRadius = 1.0,
 
71
   insertFails = 10000,
 
72
   maxIterations = 10000,
 
73
   tolerance = 1.0e-6
 
74
)
 
75
 
 
76
packer.generatePacking( volume = box, ntable = mntable, tag = 0)
 
77
 
 
78
# create bonds between neighbouring particles:
 
79
mntable.generateBonds(
 
80
   tolerance = 1.0e-5,
 
81
   bondID = 0
 
82
)
 
83
 
 
84
#Add a discrete fracture network
 
85
n_faults = 10
 
86
breakLines = []
 
87
for f in range(n_faults):
 
88
 
 
89
   x0 = random()*0.8*width + 0.1*width
 
90
   y0 = random()*0.8*height + 0.1*height
 
91
   x1 = random()*0.8*width + 0.1*width
 
92
   y1 = random()*0.8*height + 0.1*height
 
93
 
 
94
   brkLine = LineSegment2D (
 
95
      startPoint = Vector3(x0,y0,0.0),
 
96
      endPoint = Vector3(x1,y1,0.0)
 
97
   )
 
98
   breakLines.append(brkLine)
 
99
 
 
100
   mntable.breakBondsAlongLineSegment(
 
101
      lineSegment = brkLine,
 
102
      distance = 0.25,
 
103
      tag = 0
 
104
   )
 
105
 
 
106
# write a geometry file
 
107
mntable.write(
 
108
   fileName = "temp/geo_DFN_2.vtu",
 
109
   outputStyle = 2
 
110
)