Debian Codegraph @

examples/gengeo_example7.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, print_function
14 from gengeo import *
15 #An example python script to generate an aggregate of hexagonal grains
16 # with circular boundary conditions and tagging of particles along lines
17
18 # Define region extremities:
19 size = 5.0
20 minPoint = Vector3(0.0,0.0,0.0)
21 maxPoint = Vector3(size,size,0.0)
22
23 # Define the geometrical constraints for packing
24 top_line = Line2D (
25 startPoint = Vector3(size,0.0,0.0),
26 endPoint = minPoint
27 )
28
29 bottom_line = Line2D (
30 startPoint = maxPoint,
31 endPoint = Vector3(0.0,size,0.0)
32 )
33
34 box = BoxWithLines2DSubVol (
35 minPoint = minPoint-Vector3(-0.5,0.0,0.0),
36 maxPoint = maxPoint+Vector3(0.5,0.0,0.0),
37 svdim_x = 2.5,
38 svdim_y = 2.5
39 )
40 box.addLine(top_line)
41 box.addLine(bottom_line)
42
43 # Create a multi-group neighbour table to contain the particles:
44 mntable = CircMNTable2D (
45 minPoint = minPoint,
46 maxPoint = maxPoint,
47 gridSize = 2.5
48 )
49
50 # Fill the volume with particles:
51 packer = HexAggregateInsertGenerator2D (
52 minRadius = 0.1,
53 maxRadius = 1.0,
54 insertFails = 1000,
55 maxIterations = 1000,
56 tolerance = 1.0e-6
57 )
58
59 # Generate the packing
60 packer.generatePacking(
61 volume = box,
62 ntable = mntable,
63 tag = 0
64 )
65
66 # tag particles along the top_line and bottom_line
67 mntable.tagParticlesAlongLineWithMask(
68 line = top_line,
69 distance = 0.5,
70 tag = 4,
71 mask = 4
72 )
73
74 #and the compact form:
75 mntable.tagParticlesAlongLineWithMask(bottom_line, 0.5, 8, 8, 0)
76
77 #print the porosity of the particle packing:
78 volume = size*size
79 porosity = (volume - mntable.getSumVolume())/volume
80 print("Porosity: ",porosity)
81
82 # write a geometry file in VTK format
83 mntable.write(
84 fileName = "temp/geo_example7.vtu",
85 outputStyle = 2
86 )
87
88 # write a geometry file in ESyS-Particle geo format
89 mntable.write(
90 fileName = "temp/geo_example7.geo",
91 outputStyle = 1
92 )