# How to get the mesh/geometry function space?

**URL:** <https://fenicsproject.discourse.group/t/how-to-get-the-mesh-geometry-function-space/14539>\
**Category:** mesh\
**Created:** [May 5, 2024, 10:02am UTC](https://fenicsproject.discourse.group/t/how-to-get-the-mesh-geometry-function-space/14539 "2024-05-05T10:02:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sermarc](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/sermarc/32/5090_2.png) [@sermarc](https://fenicsproject.discourse.group/u/sermarc)\
**Post date:** [May 5, 2024, 10:02am UTC](https://fenicsproject.discourse.group/t/how-to-get-the-mesh-geometry-function-space/14539/1 "2024-05-05T10:02:33Z")

</div>

In our optimization codes, we have been differentiating with respect to the geometry degrees of freedom. This was accomplished by:

```auto
 c_el = domain.ufl_domain().ufl_coordinate_element()
 meshFunctionSpace = fem.FunctionSpace(domain, c_el)

```

However this code does not run with newer versions, giving the error:

```auto
FunctionSpace. __init__ () missing 1 required positional argument: 'cppV'

```

What is the current accepted method/best practice to get such function space?

---

<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:** [May 5, 2024, 11:31am UTC](https://fenicsproject.discourse.group/t/how-to-get-the-mesh-geometry-function-space/14539/2 "2024-05-05T11:31:35Z")

</div>

This is an API update from v0.7.x to v0.8.x.  
You should use `dolfinx.fem.functionspace(domain, c_el)`.

---

<div class="post-metadata">

**Author:** ![sermarc](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/sermarc/32/5090_2.png) [@sermarc](https://fenicsproject.discourse.group/u/sermarc)\
**Post date:** [May 5, 2024, 1:37pm UTC](https://fenicsproject.discourse.group/t/how-to-get-the-mesh-geometry-function-space/14539/3 "2024-05-05T13:37:16Z")

</div>

Many thanks, works great!
