Hi all, I would vote either mandatory argument or a warning.
I'm coming at FEniCS from an engineering / physics background and as such am picking up a lot of the numerical / computational subtleties as I go, usually at the expenses of a good deal of blood, sweat and tears. I haven't (as far as I know, but now I am worried) encountered this one but it is exactly the sort of pitfall I would prefer to avoid if the trade off is writing 'order = 2' at the end of my expression declarations, or ignoring a warning about integrating an expression. Incidentally, this sort of subtlety is especially vicious since the results actually seems reasonable! Mike On Tue, Aug 12, 2014 at 1:51 PM, Nico Schlömer <[email protected]> wrote: > Hi all, > > recently, a discussion [1] came up about a long-standing weirdness > with Dolfin `Expression`s: > ``` > from dolfin import * > mesh = UnitIntervalMesh(1) > e1 = Expression("x[0] * x[0]") > print assemble(e1 * dx(mesh)) > ``` > This looks like it's integrating the function x^2 over the interval > [0, 1], but the result – surprisingly to some –, is 0.5 instead of > 0.33333. The reason for this behavior is that `e1` gets interpreted as > a linear function by the quadrature. (The optional argument `degree` > of `Expression` defaults to 1.) > > While most would agree that this is surprising and that probably > numerous FEniCS codes suffer from bugs related to this, it is unclear > what we should best do about this. > > The options include: > > * improve the documentation > * add a log message/warning when `Expression` interpolation happens > * add an extra mandatory argument to `Expression`, specifying > - the element or > - the function space; > * introduce functions that evaluate pointwise ("Expressions") to > UFL/UFC/FCC and let dolfin Expression inherit from those; > * ... > > Arguments in favor of adding a mandatory argument include > * The Python Zen: "Explicit is better than implicit." -- It's just > too easy to make a mistake here. > > Arguments for leaving the API as it is include: > * The user cannot expect to have arbitrary Expressions integrate > exactly. Why should he/she expect it for any function? > > What do you think about this? Does the above `assemble()` result > surprise you at all? Do you think we should force user code to be > explicit here or would you think that adding documentation is > sufficient? > > Cheers, > Nico > > > [1] > https://bitbucket.org/fenics-project/dolfin/issue/355/expression-s-interpolate-to-linear > _______________________________________________ > fenics mailing list > [email protected] > http://fenicsproject.org/mailman/listinfo/fenics >
_______________________________________________ fenics mailing list [email protected] http://fenicsproject.org/mailman/listinfo/fenics
