示例#1
0
targetHoles = pyslsm.VectorHole()

# Create a dumbbell from two vertically offset holes.
targetHoles.append(pyslsm.Hole(50, 69, 20))
targetHoles.append(pyslsm.Hole(50, 31, 20))

# Store dumbbell data (needed for sensitivity callback).
upperLobeCentre = targetHoles[0].coord.y
lowerLobeCentre = targetHoles[1].coord.y
lobeSeparation = upperLobeCentre - lowerLobeCentre

# Initialise the system with a circle in the upper lobe.
initialHoles.append(pyslsm.Hole(50, 69, 15))

# Initialise a 100x100 level set domain.
levelSet = pyslsm.LevelSet(100, 100, initialHoles, targetHoles, moveLimit, 6,
                           True)

# Store the mesh area.
meshArea = levelSet.mesh.width * levelSet.mesh.height

# Initialise io object.
io = pyslsm.InputOutput()

# Reinitialise the level set to a signed distance function.
levelSet.reinitialise()

# Initialise the boundary object.
boundary = pyslsm.Boundary()

# Initialise target area fraction vector.
targetArea = pyslsm.VectorDouble()
示例#2
0
points = pyslsm.VectorCoord()

# Read the shape file (assume we're in the root folder).
try:
    file = open("demos/shapes/stanford-bunny.txt", "r")

    for line in file.readlines():
        cols = line.split()
        points.append(pyslsm.Coord(float(cols[0]), float(cols[1])))

except (OSError, IOError):
    print("Shape file not found!")
    sys.exit()

# Initialise the level set domain.
levelSet = pyslsm.LevelSet(400, 400, holes, points, moveLimit, 6, True)

# Initialise io object.
io = pyslsm.InputOutput()

# Reinitialise the level set to a signed distance function.
levelSet.reinitialise()

# Initialise the boundary object.
boundary = pyslsm.Boundary()

# Initialise target area fraction vector.
targetArea = pyslsm.VectorDouble()

# Discretise the target structure.
boundary.discretise(levelSet, True)
示例#3
0
# Set maximum running time.
maxTime = 50

# Set sampling interval.
sampleInterval = 1

# Set time of the next sample.
nextSample = 1

# Create a hole at position (100, 100) with a radius of 80 grid units.
holes = pyslsm.VectorHole()
holes.append(pyslsm.Hole(100, 100, 80))

# Initialise a 200x200 level set domain.
levelSet = pyslsm.LevelSet(200, 200, holes, moveLimit, 6, True)

# Initialise io object.
io = pyslsm.InputOutput()

# Reinitialise the level set to a signed distance function.
levelSet.reinitialise()

# Initialise the boundary object.
boundary = pyslsm.Boundary()

# Perform initial boundary discretisation.
boundary.discretise(levelSet)

# Number of cycles since signed distance reinitialisation.
nReinit = 0
示例#4
0
#        hence
#            0 < g < 1/(upper-lower)

# The variable gravityMult is g.(upper-lower).
reduce = 1.0 - gravityMult

# Position and size of the initial trial circle.
initialHoleX = xCentre
initialHoleY = 0.5 * yCentre
initialHoleRad = 0.5 * radius

# Push the trial shape into the vector.
initialHoles.append(pyslsm.Hole(initialHoleX, initialHoleY, initialHoleRad))

# Initialise the level set domain.
levelSet = pyslsm.LevelSet(width, height, initialHoles, targetHoles, moveLimit,
                           6, True)

# Store the mesh area.
meshArea = levelSet.mesh.width * levelSet.mesh.height

# Initialise io object.
io = pyslsm.InputOutput()

# Reinitialise the level set to a signed distance function.
levelSet.reinitialise()

# Initialise the boundary object.
boundary = pyslsm.Boundary()

# Initialise target area fraction vector.
targetArea = pyslsm.VectorDouble()