Exemplo n.º 1
0
	z[:] = r

	for jx in range(MX):
		for jy in range(MY):
			cvodes.denGETRS(data.P[jx][jy], NUM_SPECIES, data.pivot[jx][jy], z.ptrto(jx*NUM_SPECIES + jy*NSMX))

	return 0

u = cvodes.NVector([0.0]*(NEQ))

#Allocate and initialise user data
t = cvodes.realtype(0)
data = UserData()
for jx in range(MX):
	for jy in range(MY):
		data.P[jx][jy] = cvodes.denalloc(NUM_SPECIES, NUM_SPECIES)
		data.Jbd[jx][jy] = cvodes.denalloc(NUM_SPECIES, NUM_SPECIES)
		data.pivot[jx][jy] = cvodes.denallocpiv(NUM_SPECIES)

data.om = PI/HALFDAY
data.dx = (XMAX-XMIN)/(MX-1)
data.dy = (YMAX-YMIN)/(MY-1)
data.hdco = KH/(data.dx**2)
data.haco = VEL/(2.0*data.dx)
data.vdco = (1.0/(data.dy**2))*KV0
pdata = ctypes.pointer(data)

SetInitialProfiles(u, data.dx, data.dy)
abstol= cvodes.realtype(1.0e-5*100)
reltol= cvodes.realtype(1.0e-5)
Exemplo n.º 2
0
		igy = wdata.jigy[jy]
		for jx in range(wdata.mx):
			igx = wdata.jigx[jx]
			ig = igx + igy*wdata.ngx
			cvodes.denGETRS(wdata.P[ig], wdata.mp, wdata.pivot[ig], z.ptrto(iv))
			iv += wdata.mp
	
	return 0

tnext = 1e-08
t = cvodes.realtype(T0)
ncheck = ctypes.c_int(0)
rewt = cvodes.NVector([0]*NEQ)
wdata = WebData()
for i in range(NGRP):
	wdata.P[i] = cvodes.denalloc(NS,NS)
	wdata.pivot[i] = cvodes.denallocpiv(NS)
wdata.rewt = rewt.data
InitUserData(wdata)

c = cvodes.NVector([0]*(NEQ))
CInit(c, wdata)

print "\nCreate and allocate CVODES memory for forward run"
cvode_mem = cvodes.CVodeCreate(cvodes.CV_BDF, cvodes.CV_NEWTON)
wdata.cvode_memF = cvode_mem.obj
cvodes.CVodeSetFdata(cvode_mem, ctypes.pointer(wdata))
cvodes.CVodeMalloc(cvode_mem, f, T0, c, cvodes.CV_SS, RTOL, ATOL)

cvodes.CVSpgmr(cvode_mem, cvodes.PREC_LEFT, 0)
cvodes.CVSpilsSetPreconditioner(cvode_mem, Precond, PSolve, ctypes.pointer(wdata))