# How to solve local problem for each element cell of the mesh?

**URL:** <https://fenicsproject.discourse.group/t/how-to-solve-local-problem-for-each-element-cell-of-the-mesh/18350>\
**Category:** General\
**Created:** [November 9, 2025, 11:23am UTC](https://fenicsproject.discourse.group/t/how-to-solve-local-problem-for-each-element-cell-of-the-mesh/18350 "2025-11-09T11:23:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deep\_Math](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/deep_math/32/6225_2.png) [@Deep\_Math](https://fenicsproject.discourse.group/u/Deep_Math)\
**Post date:** [November 9, 2025, 11:23am UTC](https://fenicsproject.discourse.group/t/how-to-solve-local-problem-for-each-element-cell-of-the-mesh/18350/1 "2025-11-09T11:23:52Z")

</div>

I want to use FEnicsx to implement multiscale method, suppose that we have a mesh, then for each cell K of such mesh, then for each basis functions \phi\_{i} defined on K, we need to first refine K into finer mesh and use the finer meshes defined in K to solve L(\psi\_{i})=-L(\phi\_{i})$ and \psi\_{i}=0 on the boundary of K, we have to store the value of \psi\_{i} on the integration points for the finer meshes in K, how to do this?we need to solve this local functions for fine scale basis functions

---

<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:** [November 10, 2025, 7:53am UTC](https://fenicsproject.discourse.group/t/how-to-solve-local-problem-for-each-element-cell-of-the-mesh/18350/2 "2025-11-10T07:53:24Z")

</div>

You could use something along the lines of:

> [@Cell-wise assembly in v10.0.0](https://fenicsproject.discourse.group/t/cell-wise-assembly-in-v10-0-0/18233/2):
>
> This is due to a slight change in the API, where a void ptr is passed as the last argument, to make it possible to pass arbitrary data to (custom) kernels. (Ref: [Add void\* to tabulate\_tensor kernel by sclaus2 · Pull Request #753 · FEniCS/ffcx · GitHub](https://github.com/FEniCS/ffcx/pull/753)) By changing to self.kernel(ffi\_fb(A\_local), ffi\_fb(coeffs), ffi\_fb(self.consts), ffi\_fb(geometry), ffi\_fb(facet\_index), ffi\_fb(facet\_perm), self.ffi.NULL,) the code runs.

where you make a local assembler for lhs and rhs and solve for that (ref: [Invert DG block diagonal matrix - #5 by rosilho](https://fenicsproject.discourse.group/t/invert-dg-block-diagonal-matrix/12257/5))
