# Emptymesh and the integration with its mother mesh

**URL:** <https://community.freefem.org/t/emptymesh-and-the-integration-with-its-mother-mesh/4273>\
**Category:** General Discussion\
**Created:** [May 10, 2026, 4:54am UTC](https://community.freefem.org/t/emptymesh-and-the-integration-with-its-mother-mesh/4273 "2026-05-10T04:54:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pi.3.141](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@pi.3.141](https://community.freefem.org/u/pi.3.141)\
**Post date:** [May 10, 2026, 4:54am UTC](https://community.freefem.org/t/emptymesh-and-the-integration-with-its-mother-mesh/4273/1 "2026-05-10T04:54:37Z")

</div>

Hello there,

I am facing a strange problem when working with an emptymesh. The piece of code is the following. It computes the normal velocity on the boundary and stores it on a boundary function.

```auto
mesh Th=square(10, 10);

fespace UVh(Th, [P2, P2]);
UVh [u,v], [uh,vh];

mesh Thb=emptymesh(Th);	// 
fespace	Pbh(Thb, P1);
Pbh	g, gh; // if Pbh is P2 then solveg below runs with errors! 

solve solveuv( [u, v], [uh,vh])
= int2d(Th)( u*uh + v*vh + 
             dx(u)*dx(uh) + dy(u)*dy(uh) + dx(v)*dx(vh) + dy(v)*dy(vh) )
- int2d(Th) ( uh + vh );
solveuv;

problem solveg( g, gh ) 
= int1d(Thb) ( g*gh ) - int1d(Thb) ( (u*N.x + v*N.y)*gh );
solveg;

```

It shows that when the boundary space Pbh is P1, the function solveg computes well the normal velocity. If Pbh is P2 then the following error is shown:

```auto
// 1 UMFPACK WARNING singular matrix 
// 1 UMFPACK WARNING singular matrix 
// -- Solve : 
// min -nan max -nan

```

Any suggestion how to avoid the error?

Btw, I have not found any info for the emptymesh. It would be appreciated if anyone can share info about it, for example :

- can one write u=g, and if yes, does it mean u updates its boundary values to g?
- similar question for g=u.
- how one can solve a laplace-beltrami equation on Pbh?
- …

Thank you!

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [May 11, 2026, 8:46am UTC](https://community.freefem.org/t/emptymesh-and-the-integration-with-its-mother-mesh/4273/2 "2026-05-11T08:46:57Z")

</div>

It is normal because you have no information on middle internal middle dog,

you can add them like `int2d(Thb)(1e-7` _`* g`_ `* gh )`

or better use meshL to solve this problem like in :

[bbb.edp](https://community.freefem.org/uploads/short-url/iouTWoqeh5WMgBKj0zsB0jdgV3K.edp) (514 Bytes)

---

<div class="post-metadata">

**Author:** ![pi.3.141](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@pi.3.141](https://community.freefem.org/u/pi.3.141)\
**Post date:** [May 11, 2026, 4:31pm UTC](https://community.freefem.org/t/emptymesh-and-the-integration-with-its-mother-mesh/4273/3 "2026-05-11T16:31:16Z")

</div>

Thank you for the comment and the suggestion.

1. Adding `int2d(Thb)(1e-7` _`* g`_ `* gh )`indeed makes the function solveg run properly, even when we take P2 in Thb .

So, emptymesh creates a 2d mesh, just tweaked so that the fe on Thb and those in Th, when restricted to the boundary are the same. Nice!

Then we can do

`p=g and p=g, with p in Th and g in Thb,`

which hides an interpolation in the background. Very useful.

1. But with meshL, freefem takes a different approach - if I understand it properly. It creates a proper boundary fe space.

I have run the code you sent. It finishes without errors but the solution is zero - so incorrect. I am not sure where the error is.

Also, I tried to do

`p=g and p=g, with p in Th and g in Thb,`

but it did not work. So, how one would transfer from Thb to Th and vice-versa in the case of Thb=extract(Th)?

Thank you again!
