Custom Newton solver for mixed element spaces

Hi,

I am adapting the tutorial on custom Newton solver for Navier-Stokes equations:

https://jorgensd.github.io/dolfinx-tutorial/chapter4/newton-solver.html

I am unable to go past the following line:

coords = V.tabulate_dof_coordinates()[:, 0]

In my case, V is a mixed element function space which leads to the following error:

RuntimeError: Cannot tabulate coordinates for a mixed FunctionSpace.

I would appreciate if someone could help me on how to modify this. It would also help a lot if I could be pointed to an example based on mixed elements.

Kind regards,
Shakeeb

The coords variable in the original tutorial is used for plotting. Plotting a mixed element does not make sense, so what about commenting out that line snd subsequent calls related to it?

If you for some reason really want the coordinates, you Need to collapse each sub-space, and Get coordinates for each one.

Thanks for your quick reply!

In my case the mesh will evolve from one time step to another. Since the feature is not available in 0.5.x, I will have to interpolate manually the dofs from old mesh on to new one.

Are there community generated resources other than official tutorials whose knowledge might help with mixed elements in dolfinx?

There are many questions/answers regarding Mixed elements on the forum (both for legacy dolfin and dolfinx).

Then you must collapse the function into its sub space (and use the map stemning from FunctionSpace.collapse() to map from the sub space to the parent space.
See for instance: Assigning a scalar expression to mixed function space - #4 by dokken

1 Like