Exemplo n.º 1
0
r = 0.4
h = 0.01
ratio_ellipse = 0.8
smoothingKernelFunc = 2
speedsound = 1
density = 1
shearmodulus = 1
bulkmodulus = 1
pack = pyck.CylindricalPacker(center, r, ratio_ellipse, h, 5)
pack.updateStates(center, r - 7 * h + 0.001, ratio_ellipse, 2)
positions = pack.getPositions()
states = pack.getStates()
numParticles = pack.GetNumParticles()
dim = pack.getDim()

model = pyck.Model(positions, states, numParticles, dim)

stateField = model.CreateIntField("State", 1)
model.SetIntField(stateField, 5, 5)
model.SetIntField(stateField, 2, 2)

velocityField = model.CreateDoubleField("Velocity", 3)
model.SetDoubleField(velocityField, 5, [0.0, 0.0, 0.0])
model.SetDoubleField(velocityField, 2, [0.0, 0.0, 0.0])

densityField = model.CreateDoubleField("Density", 1)
model.SetDoubleField(densityField, 5, 1)
model.SetDoubleField(densityField, 2, 1)

model.SetParameter(
    "Mass", "%f" % (density *
Exemplo n.º 2
0
# function call as it will be destroyed, blame SWIG developers
pack = pyck.StructuredPack(cubic)

# Create some shapes, see shapes directory for options and reference
# First argument is always a tag for these particles
# Mapping operations are applied sequentially
tri = pyck.TriPrism(1, [1.5, 3.0, 0.0], [3, 0, 0], [0, 0, 0], 2)

# Map the shapes and generate the pack
# pack.AddShape(cube); # As with creating the cubic packer, do not create the shapes within the function call here
# pack.AddShape(sphere);
pack.AddShape(tri)
pack.Process()

# Create a new model from the pack
model = pyck.Model(pack)

# Create a new field of n-dimensional integers
# Arguments are CreateIntField(label,dimensions)
# label - label for this field in the vtp file
# dimensions - dimensionality of this field, doesnt have to correspond to model dimensions
# Create field of doubles in the same way with CreateDoubleField
stateField = model.CreateIntField("State", 1)

# Arguments are SetIntField(field,tag,value(s))
# field - returned from CreateIntField
# tag - tag applied to particles during shape Mapping
# value(s) - singular value or array of values [v1, v2,...vn] to set of particles with a matching tag
# model.SetIntField(stateField,1,10);
# model.SetIntField(stateField,2,20);
model.SetIntField(stateField, 1, 30)
Exemplo n.º 3
0
# Mapping operations are applied sequentially
cube = pyck.Cuboid(1, [2, 2, 2], [6, 6, 6])
sphere = pyck.Sphere(2, [2, 2, 2], 5)

# Map the shapes and generate the pack
# As with creating the cubic packer, do not create the shapes within the
# function call here
pack.AddShape(cube)
pack.AddShape(sphere)
pack.Process()

# Create a new model from the pack
# model = pyck.Model() # Create an empty model
# model = pyck.Model(pack) # Create a model from a pack
model = pyck.Model([10.0, 10.0, 10.0, 11.0, 11.0, 11.0, 12.0, 12.0, 12.0],
                   [3, 3, 3], 3,
                   3)  # Create a model from points generated in python
model.AddPack(pack)  # Add a pyck pack to an existing model
model.AddPack([13.0, 13.0, 13.0, 14.0, 14.0, 14.0, 15.0, 15.0, 15.0],
              [3, 3, 3], 3,
              3)  # Add points generated in python to an existing pack

# Create a new field of n-dimensional integers
# Arguments are CreateIntField(label,dimensions)
# label - label for this field in the vtp file
# dimensions - dimensionality of this field, doesnt have to correspond to model dimensions
# Create field of doubles in the same way with CreateDoubleField
stateField = model.CreateIntField("State", 1)

# Arguments are SetIntField(field,tag,value(s))
# field - returned from CreateIntField