def setInitialCondition(self,U0): if np.shape(self.U) != np.shape(U0): print "Wrong shape",np.shape(U0)," of initial condition! Must match shape of mesh",np.shape(self.mesh),". Exiting" # U0 = U0[:np.shape(self.U)[0],:np.shape(self.U)[-1]] import sys sys.exit(0) self.Up = U0
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