File: gengeo_example8.py

package info (click to toggle)
python-demgengeo 1.4-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,000 kB
  • sloc: cpp: 13,449; python: 1,260; makefile: 304; sh: 90
file content (88 lines) | stat: -rw-r--r-- 2,506 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#############################################################
##                                                         ##
## Copyright (c) 2007-2017 by The University of Queensland ##
## Centre for Geoscience Computing                         ##
## http://earth.uq.edu.au/centre-geoscience-computing      ##
##                                                         ##
## Primary Business: Brisbane, Queensland, Australia       ##
## Licensed under the Open Software License version 3.0    ##
## http://www.apache.org/licenses/LICENSE-2.0              ##
##                                                         ##
#############################################################

from gengeo import *
from math import sqrt
#An example python script to generate a regular aggregate of hexagonal grains
# with bonds broken along lines 

# Define region extremities:
size = 150.0
xsize = size
ysize = size
minPoint = Vector3(0.0,0.0,0.0)
maxPoint = Vector3(xsize,ysize,0.0)

# Define the geometrical constraints for packing
top_line = Line2D (
   startPoint = minPoint,
   endPoint = Vector3(size,0.0,0.0)
)

bottom_line = Line2D (
   startPoint = Vector3(0.0,40.,0.0),
   endPoint = Vector3(40.,40.,0.0)
)

#or compact form:
left_line = Line2D(Vector3(40.,40.,0.0),Vector3(40.,0.0,0.0))
right_line = Line2D(minPoint, Vector3(0.0,ysize,0.0))

box = BoxWithLines2D (
   minPoint = minPoint,
   maxPoint = maxPoint
)
box.addLine(top_line)
box.addLine(bottom_line)
box.addLine(left_line)
box.addLine(right_line)

# Create a multi-group neighbour table to contain the particles:
mntable = MNTable2D (
   minPoint = minPoint,
   maxPoint = maxPoint,
   gridSize = 1.25
)

# Fill the volume with particles:
packer = HGrainGenerator2D (
   radius = 0.5
)

# Generate the packing
packer.generatePacking(
   volume = box, 
   ntable = mntable,
   tag = 0
)

# bond the particles
#mntable.generateBonds(0,1.0e-5,3)

# tag particles along the boundary lines (e.g. top_line, left_line etc.)
#	using the compact form:
mntable.tagParticlesAlongLineWithMask(bottom_line, 5.0, 4, -1, 0)
mntable.tagParticlesAlongLineWithMask(top_line, 5.0, 8, -1, 0)
mntable.tagParticlesAlongLineWithMask(left_line, 8.0, 16, -1, 0)
mntable.tagParticlesAlongLineWithMask(right_line, 8.0, 32,-1, 0)

# write a geometry file in VTK format
mntable.write(
   fileName = "temp/geo_example8.vtu",
   outputStyle = 2
)

# write a geometry file in ESyS-Particle geo format
mntable.write(
   fileName = "temp/geo_example8.geo",
   outputStyle = 1
)