示例#1
0
    verbose = True
    fesolver = CooFESolver(verbose=verbose)
    optimizer = Topopt(fesolver, young, poisson, verbose=verbose)

    # compute
    history = False
    x = optimizer.init(load, density_constraint)
    x, x_more = optimizer.layout(load, density_constraint, x, penal, rmin,
                                 delta, loopy, history)

    print('Elapsed time is: ', time.time() - t, 'seconds.')

    if history:
        x_history = x_more
        loop = len(x_history)
    else:
        loop = x_more
        x_history = None

    # save
    if x_history:
        import imageio
        imageio.mimsave('topopt.gif', x_history)

    # plot
    pl = Plot(x, load, nelx, nely)
    pl.figure(title='loop ' + str(loop))
    pl.boundary()
    pl.loading()
    pl.show()
示例#2
0
    # create optimizer object and initialise the problem
    optimizer = Topopt(den_con,
                       load,
                       fesolver,
                       verbose=verbose,
                       history=history)

    # compute
    t = time.time()
    x, x_history, ki = optimizer.layout(penal, rmin, delta, loopy, filt)
    print('Elapsed time is: ', time.time() - t, 'seconds.')

    # plotting
    pl = Plot(load, directory)
    pl.loading(load)
    pl.boundary(load)

    if history:
        for i in x_history:
            pl.add(i, animated=True)
        pl.save('video')

    pl.add(x, animated=False)

    if save_plot:
        pl.save('figure')

    if plotting:
        pl.show()

    if save_pointcloud: