Debian Codegraph @

examples/gengeo_crack.py

raw
1 #############################################################
2 ## ##
3 ## Copyright (c) 2007-2017 by The University of Queensland ##
4 ## Centre for Geoscience Computing ##
5 ## http://earth.uq.edu.au/centre-geoscience-computing ##
6 ## ##
7 ## Primary Business: Brisbane, Queensland, Australia ##
8 ## Licensed under the Open Software License version 3.0 ##
9 ## http://www.apache.org/licenses/LICENSE-2.0 ##
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 )