Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using pure UFL in Python, replacing DOLFIN wrapper classes for UFL types? #150

Closed
w1th0utnam3 opened this issue Aug 7, 2018 · 6 comments
Labels
proposal Suggested change or addition

Comments

@w1th0utnam3
Copy link
Contributor

Currently, it isn't really possible for a user to assemble a system using a pure UFL form + separate DOLFIN objects for the problem instance. DOLFIN wrapper classes have to or should be used to define the form in the first place. Even if conversion between an UFL form and DOLFIN form were possible it seems a little bit weird from a user's perspective to have these two groups of classes that have similar (or the same) names but use different constructor arguments etc.

Maybe it would be clearer and more straight forward to drop all DOLFIN Python wrapper classes for UFL objects, use pure UFL forms for form definitions and ask for function spaces, meshes, etc. only during assembly.

@w1th0utnam3 w1th0utnam3 added the proposal Suggested change or addition label Aug 7, 2018
@garth-wells
Copy link
Member

This isn't really clear to me. DOLFIN cannot assemble a UFL form directly - it needs to be made into a concrete implementation. Can you clarify?

The naming issue can/will be fixed with proper importing and namespacing, e.g. ufl.Form and dolfin.fem.Form. The present mixing of the namespaces is indeed confusing.

@w1th0utnam3
Copy link
Contributor Author

Yes, sorry, I thought that some parts of the idea were already established because @blechta suggested that it was already discussed sometime. Maybe I'm also missing some points because I don't have the whole picture.

So, FFC can compile a form defined using only UFL classes. In order to solve a problem with DOLFIN, problem instance specific information is needed as you said. I think the idea was to also split these two parts when using DOLFIN. Define the form using pure UFL first (so that it could be compiled by FFC), followed by attaching the problem specific information. The latter could be done e.g. using arguments for the assembly function.

I guess that one motivation of the current approach of using the DOLFIN wrappers is to make the the problem definition look more math like and more intuitive for a user? That would probably require some thinking in a split approach.

Initially I asked in Slack about the compatibility between UFL and Dolfin forms because I benchmarked the code generated by FFC from UFL forms (by supplying random data to the generated tabulate_tensor functions). When I wanted to benchmark the assembly using DOLFIN afterwards, I noticed that I basically have to create a second list of forms, by rewriting all forms using DOLFIN classes instead of just being able to attach some data to the UFL forms.

@blechta
Copy link
Member

blechta commented Aug 7, 2018

I agree with @w1th0utnam3 that this is a known problem. DOLFIN does not allow to use pure UFL for assembly along the lines of

e = ufl.FiniteElement("P", ufl.triangle, 1)
u, v = ufl.TrialFunction(e), ufl.TestFunction(e)
a = u*v*ufl.dx

V = dolfin.FunctionSpace(mesh, e)
dolfin.assemble(a, function_spaces=[V, V])

Instead DOLFIN requires that DOLFIN/UFL wrappers (for form arguments and coefficients which already live on dolfin function space) are used to make it more user friendly. We have already seen elsewhere that (#1) that mixing FE aspects of DOLFIN and UFL for convenience is problematic and arguably should not be done. I believe this aspect has been mentioned when drafting FEniCS-X roadmap.

@garth-wells
Copy link
Member

garth-wells commented Aug 7, 2018

Related issue that should help fix this is FEniCS/ffcx#5.

UFL has a concept of meshes and function spaces (element + continuity + mesh). This is abstract in that a UFL mesh is cell shape(s) and geometric dimension. A UFL form (and the FFC generated code) will know the cell type and dim, and DOLFIN can compliment this with a real dolfin.Mesh, with checking on the dimension and cell types performed at the appropriate point.

The code snippets from @blechta would need some thought on checking the element type.

@w1th0utnam3 w1th0utnam3 changed the title Use pure UFL in Python, remove DOLFIN wrapper classes for UFL types Consider using pure UFL in Python, replacing DOLFIN wrapper classes for UFL types? Aug 8, 2018
@jorgensd
Copy link
Sponsor Member

@garth-wells Is there more left in this issue?

@garth-wells
Copy link
Member

No recent activity, so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Suggested change or addition
Projects
None yet
Development

No branches or pull requests

4 participants