On Tue, Dec 23, 2014 at 3:50 PM, Kyle Briton Lawlor <[email protected]> wrote: > Hi again, Fipy. > > Suppose that with a solution variable phi (that is a cellVariable), I > construct a vector field so that there is a vector associated to each point > on the cell centers of the mesh, is there a way I could compute the gradient > of that vector field with FiPy?
Hi Kyle, I think that works, at least this does In [1]: import fipy as fp In [2]: m = fp.Grid2D(nx=3, ny=3) In [4]: v = fp.CellVariable(mesh=m, rank=1) In [5]: v.shape Out[5]: (2, 9) In [6]: v[0] = m.x In [7]: v[1] = m.x * m.y In [10]: print v.getGrad() [[[ 0.5 1. 0.5 0.5 1. 0.5 0.5 1. 0.5 ] [ 0.25 0.5 0.25 0.75 1.5 0.75 1.25 2.5 1.25]] [[ 0. 0. 0. 0. 0. 0. 0. 0. 0. ] [ 0.25 0.75 1.25 0.5 1.5 2.5 0.25 0.75 1.25]]] In [11]: print v.getGrad().shape (2, 2, 9) The first index is the direction, the second index is the direction for the gradient operator and the last index is over the cells. In [12]: print v.getGrad()[0] [[ 0.5 1. 0.5 0.5 1. 0.5 0.5 1. 0.5 ] [ 0.25 0.5 0.25 0.75 1.5 0.75 1.25 2.5 1.25]] In [13]: print v.getGrad()[:,0] [[ 0.5 1. 0.5 0.5 1. 0.5 0.5 1. 0.5] [ 0. 0. 0. 0. 0. 0. 0. 0. 0. ]] -- Daniel Wheeler _______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
