| 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 |
# Define region extremities: |
| 16 |
minPoint = Vector3(0.0,25.0,0.0) |
| 17 |
maxPoint = Vector3(30.0,40.0,0.0) |
| 18 |
|
| 19 |
top_line = Line2D ( |
| 20 |
startPoint = Vector3(30.0,25.0,0.0), |
| 21 |
endPoint = minPoint |
| 22 |
) |
| 23 |
|
| 24 |
bottom_line = Line2D ( |
| 25 |
startPoint = maxPoint, |
| 26 |
endPoint = Vector3(0.0,40.0,0.0) |
| 27 |
) |
| 28 |
|
| 29 |
left_line = Line2D ( |
| 30 |
startPoint = Vector3(30.0,25.0,0.0), |
| 31 |
endPoint = maxPoint |
| 32 |
) |
| 33 |
|
| 34 |
right_line = Line2D ( |
| 35 |
startPoint = minPoint, |
| 36 |
endPoint = Vector3(0.0,40.0,0.0) |
| 37 |
) |
| 38 |
|
| 39 |
box = BoxWithLines2D ( |
| 40 |
minPoint = minPoint, |
| 41 |
maxPoint = maxPoint |
| 42 |
) |
| 43 |
|
| 44 |
box.addLine(top_line) |
| 45 |
box.addLine(bottom_line) |
| 46 |
box.addLine(left_line) |
| 47 |
box.addLine(right_line) |
| 48 |
|
| 49 |
mntable = MNTable2D ( |
| 50 |
minPoint = Vector3(0.0,0.0,0.0), |
| 51 |
maxPoint = Vector3(30.0,40.0,0.0), |
| 52 |
gridSize = 1.25 |
| 53 |
) |
| 54 |
|
| 55 |
packer = InsertGenerator2D ( |
| 56 |
minRadius = 0.4, |
| 57 |
maxRadius = 0.6, |
| 58 |
insertFails = 5000, |
| 59 |
maxIterations = 10000, |
| 60 |
tolerance = 1.0e-6 |
| 61 |
) |
| 62 |
|
| 63 |
packer.generatePacking( volume = box, ntable = mntable, tag = 0) |
| 64 |
|
| 65 |
#tri = PolygonWithLines2D ( |
| 66 |
# centre = Vector3(15.0,15.0,0.0), |
| 67 |
# radius = 10.0, |
| 68 |
# nsides = 3, |
| 69 |
# smooth_edges = True |
| 70 |
#) |
| 71 |
|
| 72 |
left_tri = TriWithLines2D ( |
| 73 |
vertex0 = Vector3(0.0,0.0,0.0), |
| 74 |
vertex1 = Vector3(10.0,0.0,0.0), |
| 75 |
vertex2 = Vector3(0.0,17.0,0.0) |
| 76 |
) |
| 77 |
|
| 78 |
right_tri = TriWithLines2D ( |
| 79 |
vertex0 = Vector3(20.0,0.0,0.0), |
| 80 |
vertex1 = Vector3(30.0,0.0,0.0), |
| 81 |
vertex2 = Vector3(30.0,17.0,0.0) |
| 82 |
) |
| 83 |
|
| 84 |
obstacle = BoxWithLines2D ( |
| 85 |
minPoint = Vector3(10.0,15.0,0.0), |
| 86 |
maxPoint = Vector3(20.0,23.0,0.0) |
| 87 |
) |
| 88 |
|
| 89 |
t_line = Line2D ( |
| 90 |
startPoint = Vector3(10.0,23.0,0.0), |
| 91 |
endPoint = Vector3(20.0,23.0,0.0) |
| 92 |
) |
| 93 |
obstacle.addLine(t_line) |
| 94 |
|
| 95 |
b_line = Line2D ( |
| 96 |
startPoint = Vector3(10.0,15.0,0.0), |
| 97 |
endPoint = Vector3(20.0,15.0,0.0) |
| 98 |
) |
| 99 |
obstacle.addLine(b_line) |
| 100 |
|
| 101 |
l_line = Line2D ( |
| 102 |
startPoint = Vector3(10.0,15.0,0.0), |
| 103 |
endPoint = Vector3(10.0,23.0,0.0) |
| 104 |
) |
| 105 |
obstacle.addLine(l_line) |
| 106 |
|
| 107 |
r_line = Line2D ( |
| 108 |
startPoint = Vector3(20.0,15.0,0.0), |
| 109 |
endPoint = Vector3(20.0,23.0,0.0) |
| 110 |
) |
| 111 |
obstacle.addLine(r_line) |
| 112 |
|
| 113 |
packer2 = InsertGenerator2D ( |
| 114 |
minRadius = 0.1, |
| 115 |
maxRadius = 1.0, |
| 116 |
insertFails = 5000, |
| 117 |
maxIterations = 10000, |
| 118 |
tolerance = 1.0e-6 |
| 119 |
) |
| 120 |
|
| 121 |
packer2.generatePacking( volume = left_tri, ntable = mntable, tag = 999) |
| 122 |
packer2.generatePacking( volume = right_tri, ntable = mntable, tag = 999) |
| 123 |
packer2.generatePacking( volume = obstacle, ntable = mntable, tag = 999) |
| 124 |
|
| 125 |
# write a geometry file |
| 126 |
mntable.write( |
| 127 |
fileName = "temp/obstructed_flow.vtu", |
| 128 |
outputStyle = 2 |
| 129 |
) |
| 130 |
|
| 131 |
mntable.write( |
| 132 |
fileName = "temp/obstructed_flow.geo", |
| 133 |
outputStyle = 1 |
| 134 |
) |
| 135 |
|
| 136 |
mntable.write( |
| 137 |
fileName = "temp/obstructed_flow.raw", |
| 138 |
outputStyle = 0 |
| 139 |
) |