def main(): from time import time from itertools import count from differentialLine import DifferentialLine from modules.helpers import print_stats from modules.helpers import get_exporter from modules.show import sandstroke from modules.show import show from modules.show import dots DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) exporter = get_exporter(NMAX) orderd_verts = zeros((NMAX, 2), 'double') ## arc # angles = sorted(random(INIT_NUM)*pi*1.5) # xys = [] # for a in angles: # x = 0.5 + cos(a)*0.2 # y = 0.5 + sin(a)*0.2 # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) angles = sorted(random(INIT_NUM) * TWOPI) DF.init_circle_segment(MID, MID, 0.2, angles) for i in count(): t_start = time() DF.optimize_position(STP) spawn_curl(DF, NEARL, 0.016) if i % EXPORT_ITT == 0: exporter( DF, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS, 'prefix': PREFIX }, i, ) t_stop = time() print_stats(i, t_stop - t_start, DF)
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show from modules.show import show_closed from differentialLine import DifferentialLine DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(NINIT)*TWOPI) DF.init_circle_segment(MID,MID,RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) spawn_curl(DF,NEARL) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: fn = './res/oryx_bb_{:010d}.png'.format(i) num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],fn) fn = './res/oryx_bb_closed_{:010d}.png'.format(i) num = DF.np_get_sorted_vert_coordinates(np_verts) show_closed(render,np_verts[:num,:],fn)
def main(): from time import time from itertools import count from differentialLine import DifferentialLine from iutils.render import Render from modules.helpers import print_stats from modules.show import sandstroke from modules.show import show from modules.show import dots np_coords = zeros(shape=(NMAX, 4), dtype='float') np_vert_coords = zeros(shape=(NMAX, 2), dtype='float') DF = DifferentialLine(NMAX, FARL * 2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(INIT_NUM) * TWOPI) DF.init_circle_segment(MID, MID, 0.025, angles) # arc # angles = sorted(random(INIT_NUM)*pi*1.5) # xys = [] # for a in angles: # x = 0.5 + cos(a)*0.2 # y = 0.5 + sin(a)*0.2 # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) # vertical line # yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xx = MID+0.005*(0.5-random(INIT_NUM)) # xys = [] # for x, y in zip(xx, yy): # xys.append((x, y)) # DF.init_line_segment(xys, lock_edges=1) # diagonal line # yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xx = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xys = [] # for x, y in zip(xx, yy): # xys.append((x, y)) # DF.init_line_segment(xys, lock_edges=1) for i in count(): t_start = time() DF.optimize_position(STP) spawn_curl(DF, NEARL, 0.016) if i % 500 == 0: fn = './res/chris_bd_{:04d}.png'.format(i) else: fn = None render.set_front(FRONT) num = DF.np_get_edges_coordinates(np_coords) #sandstroke(render, np_coords[:num, :], 20, fn) if random() < 0.05: sandstroke(render, np_coords[:num, :], 30, None) vert_num = DF.np_get_vert_coordinates(np_vert_coords) #dots(render, np_vert_coords[:vert_num, :], None) dots(render, np_vert_coords[:vert_num, :], fn) t_stop = time() print_stats(i, t_stop - t_start, DF)
def main(): from time import time from itertools import count from render.render import Render from modules.helpers import print_stats from modules.show import show # from modules.show import show_closed from differentialLine import DifferentialLine from modules.helpers import get_exporter from numpy.random import random from fn import Fn DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) fn = Fn(prefix='./res/') exporter = get_exporter( NMAX, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS } ) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) # spawn_curl(DF,NEARL) spawn(DF, NEARL, 0.03) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: name = fn.name() num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],name+'.png') exporter( DF, name+'.2obj' )
def main(): from time import time from itertools import count from iutils.render import Render from modules.helpers import print_stats from modules.show import show # from modules.show import show_closed from differentialLine import DifferentialLine from modules.helpers import get_exporter from numpy.random import random from fn import Fn DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) fn = Fn(prefix='./res/') exporter = get_exporter( NMAX, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS } ) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,INIT_RAD, angles) t_start = time() for i in count(): DF.optimize_position(STP) # spawn_curl(DF,NEARL) spawn(DF, NEARL, 0.03) if i % STAT_ITT == 0: print_stats(i,time()-t_start,DF) if i % EXPORT_ITT == 0: name = fn.name() num = DF.np_get_edges_coordinates(np_edges) show(render,np_edges[:num,:],name+'.png') exporter( DF, name+'.2obj' )
def main(): from time import time from itertools import count from differentialLine import DifferentialLine from render.render import Render from modules.helpers import print_stats from modules.show import sandstroke from modules.show import show from modules.show import dots np_coords = zeros(shape=(NMAX,4), dtype='float') np_vert_coords = zeros(shape=(NMAX,2), dtype='float') DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) render = Render(SIZE, BACK, FRONT) render.ctx.set_source_rgba(*FRONT) render.ctx.set_line_width(LINEWIDTH) ## arc angles = sorted(random(INIT_NUM)*pi*1.5) xys = [] for a in angles: x = 0.5 + cos(a)*0.2 y = 0.5 + sin(a)*0.2 xys.append((x,y)) DF.init_line_segment(xys, lock_edges=1) ## vertical line #yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) #xx = MID+0.005*(0.5-random(INIT_NUM)) #xys = [] #for x,y in zip(xx,yy): #xys.append((x,y)) #DF.init_line_segment(xys, lock_edges=1) ## diagonal line # yy = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xx = sorted(MID + 0.2*(1-2*random(INIT_NUM))) # xys = [] # for x,y in zip(xx,yy): # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) for i in count(): t_start = time() DF.optimize_position(STP) spawn_curl(DF,NEARL,0.016) if i%100==0: fn = './res/sider_arc_ac_{:04d}.png'.format(i) else: fn = None render.set_front(FRONT) num = DF.np_get_edges_coordinates(np_coords) sandstroke(render,np_coords[:num,:],20,fn) if random()<0.05: sandstroke(render,np_coords[:num,:],30,None) vert_num = DF.np_get_vert_coordinates(np_vert_coords) dots(render,np_vert_coords[:vert_num,:],None) t_stop = time() print_stats(i,t_stop-t_start,DF)
def main(): from time import time from itertools import count from numpy import pi from numpy.random import random from modules.growth import spawn_curl from modules.utils import get_exporter from modules.helpers import env_or_default from modules.helpers import print_stats from differentialLine import DifferentialLine comm = MPI.COMM_WORLD nodes = comm.Get_size() rank = comm.Get_rank() if rank == 0: size = env_or_default('SIZE', SIZE) nmax = env_or_default('NMAX', NMAX) one = 1.0/size export_itt = env_or_default('EXPORT_ITT', EXPORT_ITT) stat_itt = env_or_default('STAT_ITT', STAT_ITT) data = { 'size': size, 'nmax': nmax, 'vmax': env_or_default('VMAX', NMAX), 'procs': env_or_default('PROCS', PROCS), 'nodes': nodes, 'prefix': env_or_default('PREFIX', PREFIX), 'ninit': env_or_default('NINIT', NINIT), 'rad': env_or_default('RAD', RAD), 'one': one, 'stp': env_or_default('STP', STP)*one, 'nearl': env_or_default('NEARL', NEARL)*one, 'farl': env_or_default('FARL', FARL)*one } else: data = None data = comm.bcast(data, root=0) DF = DifferentialLine( data['nmax'], zonewidth = data['farl'], nearl = data['nearl'], farl = data['farl'], procs = data['procs'], nodes = data['nodes'] ) if rank == 0: angles = sorted(random(data['ninit'])*pi*2) DF.init_circle_segment(0.5, 0.5, data['rad'], angles) t_start = time() do_export = get_exporter(nmax, t_start) for i in count(): DF.optimize_position(data['stp']) if DF.get_vnum()>data['vmax']: if rank == 0: do_export(DF, data, i, final=True) return if rank == 0: spawn_curl(DF,data['nearl']) if i % stat_itt == 0: print_stats(i,time()-t_start,DF) if i % export_itt == 0: do_export(DF, data, i)
def main(): from time import time from itertools import count from differentialLine import DifferentialLine from modules.helpers import print_stats from modules.helpers import get_exporter from modules.show import sandstroke from modules.show import show from modules.show import dots DF = DifferentialLine(NMAX, FARL*2, NEARL, FARL, PROCS) exporter = get_exporter(NMAX) orderd_verts = zeros((NMAX,2), 'double') ## arc # angles = sorted(random(INIT_NUM)*pi*1.5) # xys = [] # for a in angles: # x = 0.5 + cos(a)*0.2 # y = 0.5 + sin(a)*0.2 # xys.append((x,y)) # DF.init_line_segment(xys, lock_edges=1) angles = sorted(random(INIT_NUM)*TWOPI) DF.init_circle_segment(MID,MID,0.2, angles) for i in count(): t_start = time() DF.optimize_position(STP) spawn_curl(DF,NEARL,0.016) if i % EXPORT_ITT == 0: exporter( DF, { 'nearl': NEARL, 'farl': FARL, 'stp': STP, 'size': SIZE, 'procs': PROCS, 'prefix': PREFIX }, i, ) t_stop = time() print_stats(i,t_stop-t_start,DF)