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 ]
