Hi Dr. Wheeler,

I drew a circle and then passed it to computeDistanceFunction2d through cython 
wrapper from you. I found out if the resolution (dL) of the mesh is smaller 
than 1e-8, there is some error with computeDistanceFunction2d. 

For example, in the test.py file as attached, the plot would be a perfect 
circle if "Magnification" variable is set to be bigger than 1e3. Otherwise, the 
circle would be wavy on the boundary. However, when the 
computeDistanceFunction2d was commented out, it would be a perfect circle 
again.  In other words, if I use meters as my base unit of length, the code 
fails. But if I use mm as my base unit of length, the code is fine.
This doesn't make sense to me since the meshes are self similar.

Is there any way to solve that? I don't want to rescale the mesh to different 
units.

Best,

Attachment: m=1e6.pdf
Description: Adobe PDF document

Yunbo Wang
from fipy import CellVariable, buildAdvectionEquation, Grid2D
from pylsmlib import computeExtensionFields2d, computeDistanceFunction2d
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure, show
from matplotlib.pylab import rcParams

N = 100
nsteps = 100
Magification =1.0#e6
L = 1.0e-6 * Magification
dt = 2.0e-4
radius = L/4


m = Grid2D(nx=N, ny=N, Lx=L, Ly=L)
phi = CellVariable(mesh=m, name='distance function')


phi[:] = (m.x - L/2.0)**2 + (m.y - L/2.0)**2 - radius**2

phi[:] = computeDistanceFunction2d(phi.value, nx=m.nx, ny=m.ny, dx=m.dx, dy=m.dy)

X = m.x[0:N]
Y = X
X1, Y1 = np.meshgrid(X, Y)
values = phi.value

values = values.reshape((N,N))

###Plotting
fig = plt.figure(1, figsize=(8,8))
ax = fig.add_subplot(111)
ax.contour(X1, Y1, values, 1,
           linewidths=3, color='blue')
plt.savefig('figure_validation/plot_%.3d.pdf' % 000)

    

Attachment: m=1.pdf
Description: Adobe PDF document

_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

Reply via email to