# Interpolate into complex-valued vector function

**URL:** <https://fenicsproject.discourse.group/t/interpolate-into-complex-valued-vector-function/9178>\
**Category:** dolfinx\
**Created:** [August 31, 2022, 4:01pm UTC](https://fenicsproject.discourse.group/t/interpolate-into-complex-valued-vector-function/9178 "2022-08-31T16:01:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![conpierce8](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/conpierce8/32/2464_2.png) [@conpierce8](https://fenicsproject.discourse.group/u/conpierce8)\
**Post date:** [August 31, 2022, 10:04pm UTC](https://fenicsproject.discourse.group/t/interpolate-into-complex-valued-vector-function/9178/2 "2022-08-31T22:04:42Z")

</div>

I don’t think you’re doing anything wrong. You should, however, consider interpolating to a DG-1 function space and using `VTXWriter` for exporting results, as noted here:

> [@Maxwell solver example does not work after 0.5 update](https://fenicsproject.discourse.group/t/maxwell-solver-example-does-not-work-after-0-5-update/9100/2):
>
> Please note that you should **never** use `XDMFFile` for post-processing `Nedelec-kind` elements (as it interpolates into CG-1, which is not well defined).
> 
> You should use `VTXWriter` after interpolating the solution into DG-1.

Below, I compare the real part of the y-component, exported with interpolation into a DG-1 space (plots labeled “VTK”) and without interpolation into a DG-1 space (plots labeled “XDMF”). You can see that the error depends on the type of discretization (left, right, or crossed).

 ![screenshot](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/7/7bf5291d25c5d8c25ded94dfd2191b2111de988a.png)

In general, the erroneous nonzero y-component is very small, as you can see by plotting your interpolated field with a “Glyph” filter, so I would guess that the interpolation is giving you the best representation of the plane wave that you can achieve with RT elements.

 ![screenshot2](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/3/37275858402e9bc458ed34cfd21d13418472de27.png)

---

_[View the full topic](https://fenicsproject.discourse.group/t/interpolate-into-complex-valued-vector-function/9178)._
