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() # Discretise the target structure. boundary.discretise(levelSet, True) io.saveBoundarySegmentsTXT(0, boundary) # Compute the element area fractions. levelSet.computeAreaFractions(boundary) # Store the target area fractions. for i in range(0, levelSet.mesh.nElements): targetArea.append(levelSet.mesh.elements[i].area) # Perform initial boundary discretisation. boundary.discretise(levelSet)
boundary.discretise(levelSet) # Compute the initial boundary point normal vectors. boundary.computeNormalVectors(levelSet) # Initialise random number generator. rng = pyslsm.MersenneTwister() # Number of cycles since signed distance reinitialisation. nReinit = 0 # Running time. runningTime = 0 # Time measurements. times = pyslsm.VectorDouble() # Boundary length measurements (objective). lengths = pyslsm.VectorDouble() # Material area fraction measurements (constraint). areas = pyslsm.VectorDouble() # Lambda values for the optimiser. # These are reused, i.e. the solution from the current iteration is # used as an estimate for the next, hence we declare the vector # outside of the main loop. lambdas = pyslsm.VectorDouble([0, 0]) print("\nStarting constrained perimeter minimisation demo...\n")
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 # Running time. runningTime = 0 # Time measurements. times = pyslsm.VectorDouble() # Boundary length measurements. lengths = pyslsm.VectorDouble() # Lambda values for the optimiser. lambdas = pyslsm.VectorDouble([0]) print("\nStarting unconstrained area minimisation demo...\n") # Print output header. print("---------------") print("%6s %8s" % ("Time", "Length")) print("---------------") # Integrate until we exceed the maximum time.
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) # Compute the element area fractions. levelSet.computeAreaFractions(boundary) # Store the target area fractions. for i in range(0, levelSet.mesh.nElements): targetArea.append(levelSet.mesh.elements[i].area) # Perform initial boundary discretisation. boundary.discretise(levelSet) # Initialise random number generator.