#box_geometry.txt: 
#================
#
#An example GenGeo Python script to construct a box of spherical particles
#
#D. Weatherley, UQ, 2018.
#
#import the GenGeo module:
from gengeo import *

#Specify the min/max points of the spatial domain:
minPoint = Vector3 (-5,-5,-5)
maxPoint = Vector3 (10,10,10)

#Specify the range of particle radii:
Rmax = 0.5
Rmin = 0.2

#define a cube of side length, s=5 with one corner at the origin:
box = BoxWithPlanes3D (
   minPoint = Vector3 (0,0,0),
   maxPoint = Vector3 (5,5,5)
)

#add planar walls to each side of the cube:
#left side wall:
box.addPlane (
   Plane (Vector3(0,0,0), Vector3(1,0,0))
)
#bottom wall:
box.addPlane (Plane(Vector3(0,0,0), Vector3(0,1,0)))
#front wall:
box.addPlane (Plane(Vector3(0,0,0), Vector3(0,0,1)))
#right wall:
box.addPlane (Plane(Vector3(5,5,5), Vector3(-1,0,0)))
#top wall:
box.addPlane (Plane(Vector3(5,5,5), Vector3(0,-1,0)))
#back wall:
box.addPlane (Plane(Vector3(5,5,5), Vector3(0,0,-1)))


#Construct a neighbour table to store particles inserted within the cube:
ntable = MNTable3D (
   minPoint = minPoint,
   maxPoint = maxPoint,
   gridSize = 2.5 * Rmax, 
   numGroups = 1
)

#Construct a "packer" to insert particles into the cube:
packer = InsertGenerator3D (
   minRadius = Rmin,
   maxRadius = Rmax,
   insertFails = 10000,   # a good default value is 10000
   maxIterations = 100,	  # a good default value is 100
   tolerance = 1.0e-6,	  # a small number, typically 1.0e-6
   seed = True		  # generates random packings if seed=True
)

#Instruct the packer to fill the cube with particles:
packer.generatePacking (
   volume = box,
   ntable = ntable,
   groupID = 0,
   tag = 1
)

#Set tag=2 for all particles within a distance d=0.5 
# of the bottom side of the cube:

ntable.tagParticlesAlongPlane (
   plane = Plane(Vector3(0,0,0),Vector3(0,1,0)),
   distance = 0.5,
   tag = 2,
   groupID = 0
)

#write the particle geometry to a GenGeo geometry file:
ntable.write(fileName = "mybox.geo", outputStyle = 1)

#write the particle geometry to a VTK file for visualisation:
ntable.write(fileName = "mybox.vtu", outputStyle = 2)
GlossyBlue theme adapted by David Gilbert
Powered by PmWiki
www.000webhost.com