On Jun 8, 2012, at 4:13 AM, Yun Tao wrote: > However, I ran into problems trying to do the same for 2-D. Using the same > template, I have > > >>> mesh = Grid2D(nx=nx, ny=ny, dx=dx, dy=dy) > >>> pos = FaceVariable(mesh=mesh, value=mesh.getFaceCenters(), rank=1) > >>> pos_x = pos[0] > >>> pos_y = pos[1] > >>> eq = TransientTerm() == DiffusionTerm(coeff=1.0) + > >>> convection(coeff=((np.tanh(pos[0])),(np.tanh(pos[0])))) > > I know it likely has to do with the way I defined pos_x and pos_y. But I > can't figure out how to convert them into the usable MeshVariable for this > case.
((np.tanh(pos[0])),(np.tanh(pos[0]))) is equivalent to (np.tanh(pos[0]),np.tanh(pos[0])) due to the way Python tuples work. This is not oriented the right way for a FiPy vector. Either (note the commas) ((np.tanh(pos[0]),),(np.tanh(pos[0]),)) or [[np.tanh(pos[0])],[np.tanh(pos[0])]] should work. _______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
