gmarkall / manycore_form_compiler

MCFC is deprecated. See https://code.launchpad.net/~grm08/ffc/pyop2
https://code.launchpad.net/~grm08/ffc/pyop2
GNU General Public License v3.0
3 stars 1 forks source link

Only the use of Coefficients on fields with the same basis as a test or trial function works #42

Open gmarkall opened 12 years ago

gmarkall commented 12 years ago

At the moment, there is an assumption (not explicitly written, but encoded in the logic) in the generate() function in parameters.py that all of the Coefficients have the same basis as the test or trial functions (Arguments) in the form.

This is because, after traversing the tree to find out which derivatives are present, it builds a list of derivatives called argumentDerivatives. This contains a list of SpatialDerivatives of Arguments with the element of the Coefficient that had its derivative taken (see lines 63-80). However, there wasn't necessarily an argument in the original form which had the same element.

This causes a problem because the last loop in generate(), which generates the parameters for the spatial derivatives, (line 109-125), tries to find the very same argument in formArguments, which doesn't necessarily exist.

This problem can be triggered by:

t=state.scalar_fields["Tracer"]
u=state.vector_fields["Velocity"]

p=TrialFunction(t)
q=TestFunction(t)

rhs=dt*(dot(grad(q),u)*t-q*t*div(u))*dx

I'm just starting to think about the correct thing to do to make this work - somehow we need to generate the parameters for spatial derivatives of Coefficients, even when there wasn't an Argument with the same basis.

gmarkall commented 12 years ago

In the example, the div(u) is the problem - it computes an IndexSum of the SpatialDerivative of the Coefficient u - however, there is no argument that is equal to Argument(u.element()).

gmarkall commented 12 years ago

In https://github.com/gmarkall/manycore_form_compiler/commit/3e4cb3202055933c7bca09f3a1353594c26f5925 there is a potential fix - this is to use the scalar basis parameter whenever we have a coefficient on a vector basis. I wonder if this is adequate up until the time when we use fiat-tabulated basis functions? It allows the code for rk4-advection to be generated, but there are some unrelated issues in the generated code.

kynan commented 12 years ago

I think this has been solved as a by-product of eliminating the KernelParameterGenerator. Now coefficients are not tied to argument any more for parameter generation.

Above commit seems to have been cleaned up.