# Data generation from solution array

**URL:** <https://fenicsproject.discourse.group/t/data-generation-from-solution-array/14187>\
**Category:** General\
**Created:** [April 10, 2024, 10:21am UTC](https://fenicsproject.discourse.group/t/data-generation-from-solution-array/14187 "2024-04-10T10:21:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [April 10, 2024, 10:32am UTC](https://fenicsproject.discourse.group/t/data-generation-from-solution-array/14187/2 "2024-04-10T10:32:04Z")

</div>

I guess you are assuming a structured grid (as depicted), as it wouldn’t make sense to do this on an unstructured mesh that is not aligned with the coordinate axis.

What you could do is to build a distance matrix for every internal degree of freedom, similar to: [How to represent non-uniform first and second type boundary conditions? - #6 by dokken](https://fenicsproject.discourse.group/t/how-to-represent-non-uniform-first-and-second-type-boundary-conditions/13654/6)  
and find the 8 closest points.

However, as your grid is structured, I guess you know the location of the neighbouring points. If so, I would simply search for them in `tabulate_dof_coordinates` and extract the index of the matching degree of freedom (accessed in `u.x.array`).

---

_[View the full topic](https://fenicsproject.discourse.group/t/data-generation-from-solution-array/14187)._
