Hi Daniel
Thanks for the very quick reply.
I looked at the skfmm code again and unfortunately I think the array
nature of dx in the travel_time() function is just to pass different
grid sizes in the (dx, dy, dz) directions when you have a
multidimensional grid. I don't believe it allows the grid to change
spacing along any given direction. The most relevant section of the
code to demonstrate that comes in the pre_process function within
pffm.py, where it rearranges the input parameters before passing them to
the c code. It takes the input dx and does the following:
if type(dx) is float or type(dx) is int:
dx = [dx for x in range(len(phi.shape))]
dx = np.array(dx)
If I understand that right, if you have for example a 3D grid, so
len(phi.shape) = 3, but you pass for example a single dx, for example
dx=0.1, then it turns that into (0.1, 0.1, 0.1) and feeds that to the C
code. However, you have the option of passing something like [0.1, 0.2,
0.3] if you want your dx, dy, and dz spacings to be different.
Regarding a very simple example to demonstrate the problem, take the
"examples.levelSet.distanceFunction.mesh1D" code and just replace the
two lines
dx = 0.5
nx = 10
with
nx = 25
dx = 0.05 * (1.1 ** numerix.arange(nx))
and replace the var initialization statement with
var.setValue(1, where=x > x[12])
When you call var.calcDistanceFunction() you get the error message:
ValueError: dx must be a 1D array of doubles. Using lsmlib produces a
slightly different error also complaining about the nature of dx.
Thanks again for your help. I've appended a full listing of the test below.
Thanks again.
Bob Howell
-------Here's a full listing of the test------------------------------
# IPython log file
# Testing FiPy 3.1 with skfmm and non-uniform grid
# Before starting iPython, do following to use skfmm rather than lsmlib:
# export FIPY_LSM=skfmm
# Started iPthon with: ipython qtconsole --pylab --colors lightBG&
# logstart -o 2014_07_22a.pjr
from fipy import *
nx = 25
dx = 0.05 * (1.1 ** numerix.arange(nx))
dx
# Edited the following [OUT] slightly to avoid mailer line wrap
#[Out]# array([ 0.05 , 0.055 , 0.060 , 0.066 , 0.073 ,
#[Out]# 0.080 , 0.088 , 0.097 , 0.107 , 0.117 ,
#[Out]# 0.129 , 0.142 , 0.156 , 0.172 , 0.189 ,
#[Out]# 0.208 , 0.229 , 0.252 , 0.277 , 0.305 ,
#[Out]# 0.336 , 0.370 , 0.407 , 0.447 , 0.492 ])
from fipy.tools import serialComm
mesh = Grid1D(dx=dx, nx=nx, communicator=serialComm)
var = DistanceVariable(name='level set variable', mesh=mesh, value=-1.,
hasOld=1)
x = mesh.cellCenters[0]
var.setValue(1, where=x > x[12])
var.calcDistanceFunction()
# Just got: ValueError: dx must be a 1D array of doubles
exit()
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]