Debian Codegraph @

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