Hi again, in my simulations I have a CellVariable called potential defined on a 3D mesh generated in gmsh. And now I'd like to convert the data into a numpy array so that I can do some more math with it, e.g. integrate along a path (e.g. z-axis).
I have noticed, that the __call__ method of CellVariable expects a list
of lists of coordinate components, e.g.
>>> potential( [[2.2],[1.1],[1.0]] )
It also possible to query multiple (e.g. 2) points in one call manually
>>> potential( [[2.2,4.4],[1.1,1.1],[1.0,1.0]] )
but when I try to go to the next level of querying the entire cube at
once I get a ValueError:
>>> import numpy
>>> x,y,z = numpy.mgrid[-6.5:50.5:60j,-6.5:50.5:60j,1:24:20j]
>>> P = potential([ x.flatten(), y.flatten(), z.flatten() ])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/usr/local/lib/python2.6/dist-packages/FiPy-2.1.3-py2.6.egg/fipy/variables/cellVariable.py",
line 197, in __call__
nearestCellIDs = self.getMesh()._getNearestCellID(points)
File
"/usr/local/lib/python2.6/dist-packages/FiPy-2.1.3-py2.6.egg/fipy/meshes/common/mesh.py",
line 772, in _getNearestCellID
points = numerix.resize(points, (self.globalNumberOfCells,
len(points), len(points[0]))).swapaxes(0,1)
File "/usr/lib/python2.6/dist-packages/numpy/core/fromnumeric.py",
line 738, in resize
a = concatenate( (a,)*n_copies)
ValueError: negative dimensions are not allowed
I have tried to convert the arrays (e.g. x.flatten()) into lists (
"list(x.flatten())" and "[x.flatten()]" ) without any success.
At the moment I have to loop over all three axes and query single points
in the cube.
Is the idea of my attempt of using "potential([ x.flatten(),
y.flatten(), z.flatten() ])" correct?
Cu andi
--
Andreas Hasenkopf
Phone: +49 151 11728439
Homepage: http://www.hasenkopf2000.net
GPG Pub Key: http://goo.gl/4mOsM
signature.asc
Description: OpenPGP digital signature
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
