def __init__(self, N=4, alphaImplicit=1., alphaExplicit=0., gamma=0., zeta=0., nu=0.01, dt=-1.0, folder=".", order='linear', side='outside'): DirectForcingSolver.__init__(self, N, alphaImplicit, alphaExplicit, gamma, zeta, nu, dt, folder) self.gamma = 0. self.zeta = 0. self.order = order self.side = side
ORDER = 'linear' FOLDER = str(START_SIZE)+'-'+ORDER print "\nInterpolation type: %s\n" % (ORDER) h = 2*np.pi/START_SIZE x = np.arange(h, 2*np.pi+h, h) y = np.arange(h/2., 2*np.pi, h) X, Y = np.meshgrid(x,y) print "-"*80 print "Direct Forcing solver" print "-"*80 size = START_SIZE print size, 'x', size solver = DirectForcingSolver(N=size, alphaExplicit=0., alphaImplicit=1., nu=0.1, dt=0.0001, order=ORDER, folder=FOLDER+"/DF"+str(size), side='outside', coarsest=START_SIZE) solver.runSimulation(nt=NT, nsave=NT) umask, vmask = solver.createMask() print " " u0 = np.reshape(solver.q[::2]/solver.h, (size, size)) v0 = np.reshape(solver.q[1::2]/solver.h, (size, size)) #plotField(u0, size) plotField(u0*umask, size, size, FOLDER) size *= 3 print size, 'x', size solver = DirectForcingSolver(N=size, alphaExplicit=0., alphaImplicit=1., nu=0.1, dt=0.0001, order=ORDER, folder=FOLDER+"/DF"+str(size), side='outside', coarsest=START_SIZE) solver.runSimulation(nt=NT, nsave=NT) u1 = np.reshape(solver.q[::2]/solver.h, (size, size)) v1 = np.reshape(solver.q[1::2]/solver.h, (size, size)) e10u = la.norm((u1[1::3,2::3]-u0)*umask)
h = 2 * np.pi / START_SIZE x = np.arange(h, 2 * np.pi + h, h) y = np.arange(h / 2., 2 * np.pi, h) X, Y = np.meshgrid(x, y) print "-" * 80 print "Direct Forcing solver" print "-" * 80 size = START_SIZE print size, 'x', size solver = DirectForcingSolver(N=size, alphaExplicit=0., alphaImplicit=1., nu=0.1, dt=0.0001, order=ORDER, folder=FOLDER + "/DF" + str(size), side='outside', coarsest=START_SIZE) solver.runSimulation(nt=NT, nsave=NT) umask, vmask = solver.createMask() print " " u0 = np.reshape(solver.q[::2] / solver.h, (size, size)) v0 = np.reshape(solver.q[1::2] / solver.h, (size, size)) #plotField(u0, size) plotField(u0 * umask, size, size, FOLDER) size *= 3 print size, 'x', size solver = DirectForcingSolver(N=size,
if __name__ == "__main__": NT = 20 START_SIZE = 15 h = 2*np.pi/START_SIZE x = np.arange(h, 2*np.pi+h, h) y = np.arange(h/2., 2*np.pi, h) X, Y = np.meshgrid(x,y) print "-"*80 print "Direct Forcing solver" print "-"*80 size = START_SIZE print size, 'x', size solver = DirectForcingSolver(N=size, alphaExplicit=0., alphaImplicit=1., nu=0.05, dt=0.0001, order='linear', folder="DF"+str(size), side='outside') solver.runSimulation(nt=NT, nsave=NT) print " " u0 = np.reshape(solver.q[::2]/solver.h, (size, size)) newU0 = interpolatedField(u0, size, 9) plotField(newU0, size*9, str(size)) size *= 3 print size, 'x', size solver = DirectForcingSolver(N=size, alphaExplicit=0., alphaImplicit=1., nu=0.05, dt=0.0001, order='linear', folder="DF"+str(size), side='outside') solver.runSimulation(nt=NT, nsave=NT) print " " u1 = np.reshape(solver.q[::2]/solver.h, (size, size)) newU1 = interpolatedField(u1, size, 3) plotField(newU1, size*3, str(size)) #u1 = np.reshape(solver.qZeroed[::2]/solver.h, (size, size))
START_SIZE = 15 h = 2 * np.pi / START_SIZE x = np.arange(h, 2 * np.pi + h, h) y = np.arange(h / 2., 2 * np.pi, h) X, Y = np.meshgrid(x, y) print "-" * 80 print "Direct Forcing solver" print "-" * 80 size = START_SIZE print size, 'x', size solver = DirectForcingSolver(N=size, alphaExplicit=0., alphaImplicit=1., nu=0.05, dt=0.0001, order='linear', folder="DF" + str(size), side='outside') solver.runSimulation(nt=NT, nsave=NT) print " " u0 = np.reshape(solver.q[::2] / solver.h, (size, size)) newU0 = interpolatedField(u0, size, 9) plotField(newU0, size * 9, str(size)) size *= 3 print size, 'x', size solver = DirectForcingSolver(N=size, alphaExplicit=0., alphaImplicit=1., nu=0.05,