# Custom Newton solver for mixed element spaces

**URL:** <https://fenicsproject.discourse.group/t/custom-newton-solver-for-mixed-element-spaces/10038>\
**Category:** dolfinx\
**Created:** [December 25, 2022, 3:25am UTC](https://fenicsproject.discourse.group/t/custom-newton-solver-for-mixed-element-spaces/10038 "2022-12-25T03:25:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbhasan](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@sbhasan](https://fenicsproject.discourse.group/u/sbhasan)\
**Post date:** [December 25, 2022, 3:25am UTC](https://fenicsproject.discourse.group/t/custom-newton-solver-for-mixed-element-spaces/10038/1 "2022-12-25T03:25:25Z")

</div>

Hi,

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

[https://jorgensd.github.io/dolfinx-tutorial/chapter4/newton-solver.html](https://jorgensd.github.io/dolfinx-tutorial/chapter4/newton-solver.html)

I am unable to go past the following line:

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

```

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

```auto
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

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [December 25, 2022, 6:15am UTC](https://fenicsproject.discourse.group/t/custom-newton-solver-for-mixed-element-spaces/10038/2 "2022-12-25T06:15:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sbhasan](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@sbhasan](https://fenicsproject.discourse.group/u/sbhasan)\
**Post date:** [December 25, 2022, 1:28pm UTC](https://fenicsproject.discourse.group/t/custom-newton-solver-for-mixed-element-spaces/10038/3 "2022-12-25T13:28:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [December 25, 2022, 2:36pm UTC](https://fenicsproject.discourse.group/t/custom-newton-solver-for-mixed-element-spaces/10038/4 "2022-12-25T14:36:04Z")

</div>

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

> [@sbhasan](#):
>
> 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.

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](https://fenicsproject.discourse.group/t/assigning-a-scalar-expression-to-mixed-function-space/9075/4)
