Hi,

Followed up the previous question, now I  calculated the curvature everywhere 
for the mesh and found the accuracy was not that within second order. Is my 
mesh not stable?

Here is my mesh:

mesh = Grid2D(dx=1.0, dy=1.0, nx=100, ny=100)

var = DistanceVariable(name='Test',
                       mesh=mesh,
                       value=-1.0,
                       hasOld=1)

For initial value,

var.setValue(1.0, where = ((x-50.0)**2+(y-50.0)**2>625.0))  

var.calcDistanceFunction()


For this case, what is the best way to calculate the curvature?


Thanks,

Regards,

Yunbo





On Jan 20, 2012, at 10:47 AM, Daniel Wheeler wrote:

> On Thu, Jan 19, 2012 at 6:34 PM, wang yunbo <[email protected]> wrote:
> I'm trying to calculate the curvature of a circle in 2D.
> 
> Sounds reasonable. 
>  
> Firstly I set up a distance variable "var" to represent the circular shape.   
> To calculate the curvature, I took the gradient of "var" and then the 
> divergence as shown below:
>                                       (var.getFaceGrad()).getDivergence()
> 
> Should work with second order accuracy on a well structured mesh.
>  
> My trouble is :
> 
> My expectation is to obtain a matrix of curvature and 
>  at the boundary of circle (where var=0). However,  the obtained result from 
> my program showed 
>  at the boundary.
> 
> The boundary of the domain assumes a zero gradient. It doesn't use any other 
> information about the field. In version 2.1 there is nothing to be done other 
> than ignore the cells close to the boundary. However, In FiPy 3.0 (not yet 
> released) this will work:
> 
>   from fipy import *
>   m = Grid2D(nx=4, ny=4)
>   v = CellVariable(mesh=m, value=m.x**2 + m.y**2)
>   X, Y = m.faceCenters
>   v.faceGrad.constrain((2 * X, 2 * Y), where=m.exteriorFaces)
>   print v.faceGrad.divergence
>   [ 4.  4.  4.  4.  4.  4.  4.  4.  4.  4.  4.  4.  4.  4.  4.  4.]
> 
> Cheers.
> 
> -- 
> Daniel Wheeler
> _______________________________________________
> fipy mailing list
> [email protected]
> http://www.ctcms.nist.gov/fipy
>  [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]

_______________________________________________
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