# [SciPy-user] FEM sol interpolation

Daniel Wheeler daniel.wheeler2@gmail....
Wed Feb 25 10:30:34 CST 2009

```Hi Bernado,

I have tried doing this with scipy/numpy. If you check previous
problem is going from an unstructured mesh to another unstructured
mesh. If the grid you are interpolating from is regular then it is a
much easier problem. When both meshes are irregular than it seems like
the functions available in scipy/numpy require a lot of memory
(Nele*Mele, where N and M are the number of cells in each domain, I

Anyhow, the way the problem is tackled in fipy is to use the call
method to pass the set of points from one grid to a variable which
knows its mesh and holds the values.

<http://matforge.org/fipy/browser/trunk/fipy/variables/cellVariable.py#L139>

The above basically calls a nearest neighbor search and then projects
the value using the gradient. For general meshes we use this method
for the nearest cell:

<http://matforge.org/fipy/browser/trunk/fipy/meshes/common/mesh.py#L612>

The method above is heinous for memory usage and efficiency this is
something we have to work on as we want to have adaptive grids etc in
fipy, but at least it works. It is generally used for interpolating
too a single point or a small number of points. If the mesh is regular
we do much better in terms of efficiency and memory

<http://matforge.org/fipy/browser/trunk/fipy/meshes/numMesh/uniformGrid2D.py#L523>

Cheers

On Mon, Feb 23, 2009 at 8:48 AM, Bernardo M. Rocha
<bernardo.rocha@meduni-graz.at> wrote:
> Hi Guys,
>
> I would like to know how can I interpolate some data (a FEM solution)
> from a coarse grid to a finer grid....
>
> I would like to do something like (available in FEMLAB/COMSOL):
>
> u_int = postinterp(fem_sol, 'u', p_ref);
>
> Where fem_sol is my solution at some coarse grid and p_ref is my
> reference mesh (where I also have a fem_ref solution defined).
>
> If this is not clear, I need to compute e = fem_ref - fem_sol.
>
> Bernardo M. Rocha
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>

--
Daniel Wheeler
```