Esempio n. 1
0
    sensitivity.itoCorrection(boundary, temperature)

    # Time step associated with the iteration.
    timeStep = pyslsm.MutableFloat()

    # Constraint distance vector.
    constraintDistances = pyslsm.VectorDouble()

    # Current area mismatch.
    mismatch = computeMismatch(levelSet.mesh, targetArea)

    # Push current distance from constraint violation into vector.
    constraintDistances.append(meshArea * maxMismatch - mismatch)

    # Initialise the optimisation object.
    optimise = pyslsm.Optimise(boundary.points, constraintDistances, \
        lambdas, timeStep, levelSet.moveLimit)

    # Perform the optimisation.
    optimise.solve()

    # Extend boundary point velocities to all narrow band nodes.
    levelSet.computeVelocities(boundary.points, timeStep, temperature, rng)

    # Compute gradient of the signed distance function within the narrow band.
    levelSet.computeGradients()

    # Update the level set function.
    isReinitialised = levelSet.update(timeStep.value)

    # Reinitialise the signed distance function, if necessary.
    if not isReinitialised:
Esempio n. 2
0
print("---------------")

# Integrate until we exceed the maximum time.
while runningTime < maxTime:

    # Assign boundary point sensitivities.
    for i in range(0, len(boundary.points)):
        boundary.points[i].sensitivities[0] = 1.0

    # Time step associated with the iteration.
    timeStep = pyslsm.MutableFloat()

    # Initialise the optimisation object.
    #  Since there are no constraints we pass an empty vector for the
    #  constraint distances argument.
    optimise = pyslsm.Optimise(boundary.points, pyslsm.VectorDouble(), \
        lambdas, timeStep, moveLimit)

    # Perform the optimisation.
    optimise.solve()

    # Extend boundary point velocities to all narrow band nodes.
    levelSet.computeVelocities(boundary.points)

    # Compute gradient of the signed distance function within the narrow band.
    levelSet.computeGradients()

    # Update the level set function.
    isReinitialised = levelSet.update(timeStep.value)

    # Reinitialise the signed distance function, if necessary.
    if not isReinitialised: