Hi Jamie, Sorry for the delayed reply.
On Thu, Jul 21, 2016 at 11:31 AM, James Pringle <jprin...@unh.edu> wrote: > > However, I am still getting large errors in estimates of the gradient even > when the mesh is nearly perfectly orthogonal. These errors DO NOT become > smaller as resolution is increased. I have two question: > > Are these errors to be expected in unstructured meshes? Cell centered FV has two issues with unstructured meshes. You know about the orthogonality issue, but there is a second issue. The docstring from the following code might help explain, https://github.com/usnistgov/fipy/blob/develop/fipy/variables/cellVariable.py#L257 See, `\frac{1}{V_P} \sum_f \vec{n} \phi_f A_f`. This is the discretized gradient calculation. In this formulation using the triangular mesh, the calculated \phi_f is not the correct average for the face as the line between the cell centers doesn't cross the face in the middle of the face. I think this is called non-conjunctionality in finite volume speak. See equation 9.8 in the following link for further explanation (we should probably implement this approach). http://bit.ly/2aqRiHt I believe that this is the source of the error in the gradient calculation. It's a consistent error independent of the mesh refinement I think (or maybe first order). An alternative gradient calculation is the least squares gradient, see https://github.com/usnistgov/fipy/blob/develop/fipy/variables/cellVariable.py#L270 Using that ~~~~ import fipy as fp nx = 25 dx = 1. / nx mesh = fp.Tri2D(nx=nx, ny=nx, dx=dx, dy=dx) psi = fp.CellVariable(mesh=mesh) psi.constrain(1.0, where=mesh.facesLeft) psi.faceGrad.constrain(1.0, where=mesh.facesRight) eq = fp.DiffusionTerm().solve(psi) print psi.leastSquaresGrad[:, :100] ~~~~ seems to give lots of 1s and 0s which seems correct. The cells next to the boundary are not correct as they aren't using the boundary conditions in the calculation. I'm not sure about the order of accuracy of the least squares or why it happens to work for this mesh. > Is it acceptable to average the gradient over space to reduce the error? I don't think so unless it can be shown to improve the accuracy with analysis. -- Daniel Wheeler _______________________________________________ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]