Exemple #1
0
	def __init__(self,mesh,PdeSolver=None):
		"""mesh is the x (and y) coordinates with correct spacing, say:
		mesh = [np.linspace(x0,x1,nx),np.linspace(y0,y1,ny)] or 
		mesh = [np.linspace(x0,x1,nx)] in 1d"""
		self.mesh = np.asanyarray(mesh)
		# print mesh
		self.d = np.shape(self.mesh)[0]
		if self.d >3:
			"This should be more robust"
			self.d = 1
		nx = len(mesh[0])
		ny = 1 if self.d == 1 else len(mesh[1])
		self.WalkSolvers = []
		self.Indeces = []
		self.PdeSolver = Diffusion(d=self.d) if PdeSolver is None else PdeSolver
		self.U = np.zeros((nx,ny)) if self.d == 2 else np.zeros(nx)
		# print self.U
		self.Up = np.zeros(np.shape(self.U))
		self.IterationCounter = 0
Exemple #2
0
		self.Up = self.U.copy()

t = 0
T = 20
def setup_plot():
	mpl.ion()
	fig  = mpl.figure()
	ax = fig.add_subplot(111,projection='3d')
	ax.set_autoscaley_on(False)
	return fig,ax

if __name__ == '__main__':
	if True:
		"2D"
		nx = 11; ny =11
		Up = np.zeros((nx,ny))
		Up[(nx)/2:,(nx)/2:] = 1
		area = [[0.3,0.3],[0.5,0.5]]
		fig,ax = setup_plot()
		X,Y = np.meshgrid(np.linspace(0,1,nx),np.linspace(0,1,ny))
		mesh = [np.linspace(0,1,nx),np.linspace(0,1,ny)]
		test = MultiscaleSolver(mesh)
		test.AddWalkArea(area)
		test.setInitialCondition(Up)
		wframe = ax.plot_wireframe(X,Y,test.Up)
		mpl.draw()
		while t<T:
			ax.collections.remove(wframe)
			test.Solve()
			wframe = ax.plot_wireframe(X,Y,test.Up)
			mpl.draw()