# Mixing of composite and non-composite fe spaces

**URL:** <https://community.freefem.org/t/mixing-of-composite-and-non-composite-fe-spaces/3510>\
**Category:** Feature Request\
**Created:** [September 23, 2024, 10:33am UTC](https://community.freefem.org/t/mixing-of-composite-and-non-composite-fe-spaces/3510 "2024-09-23T10:33:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhg](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mhg](https://community.freefem.org/u/mhg)\
**Post date:** [September 23, 2024, 10:33am UTC](https://community.freefem.org/t/mixing-of-composite-and-non-composite-fe-spaces/3510/1 "2024-09-23T10:33:27Z")

</div>

It seems that currently the mixing of composite and non-composite fe spaces in a varf is not possible. For me it would be nice to do things like in the following simplified example:

```auto
int nn = 30;
mesh Th=square(nn,nn);
mesh Tht = trunc(Th, 1, split=2);

fespace Uh(Th,P1);
fespace Ph(Tht,P2);
fespace Xh=Uh*Ph;

varf testVarf([u,p], [v]) = int2d(Th)(u*v) + int2d(Th)(p*v);
matrix M = testVarf(Xh,Uh);

```

---

<div class="post-metadata">

**Author:** ![phtournier](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@phtournier](https://community.freefem.org/u/phtournier)\
**Post date:** [September 23, 2024, 12:22pm UTC](https://community.freefem.org/t/mixing-of-composite-and-non-composite-fe-spaces/3510/2 "2024-09-23T12:22:21Z")

</div>

You can define a composite space which wraps a scalar fe space, like this:

```auto
int nn = 30;
mesh Th=square(nn,nn);
mesh Tht = trunc(Th, 1, split=2);

fespace Uh(Th,P1);
fespace Ph(Tht,P2);
fespace Xh=Uh*Ph;

fespace Uhc=<Uh>;

varf testVarf([u,p], [v]) = int2d(Th)(u*v) + int2d(Th)(p*v);
matrix M = testVarf(Xh,Uhc);

```
