# Hat functions in product (vectorial) of fespace(s)

**URL:** <https://community.freefem.org/t/hat-functions-in-product-vectorial-of-fespace-s/1931>\
**Category:** General Discussion\
**Created:** [August 6, 2022, 12:08pm UTC](https://community.freefem.org/t/hat-functions-in-product-vectorial-of-fespace-s/1931 "2022-08-06T12:08:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![murea](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@murea](https://community.freefem.org/u/murea)\
**Post date:** [August 6, 2022, 12:08pm UTC](https://community.freefem.org/t/hat-functions-in-product-vectorial-of-fespace-s/1931/1 "2022-08-06T12:08:15Z")

</div>

Hi,

mesh Th=square(2,2);

fespace Wh(Th,P1b);  
fespace Mh(Th,P1);  
fespace Xh(Th,[P1b,P1]);

If 0 \<= i \< Wh.ndof=17, and  
phi\_i is a hat function of Wh, then  
[phi\_i,0]=eta\_k is a hat function of Xh  
whre 0 \<= k \< Wh.ndof=26  
How, can I get the function i → k ?

Wh u1;  
Mh u2;  
Xh [y1,y2];

// 0 \<= i \< Wh.ndof=17  
int i = 2;  
u1=0;  
u1[i]=1;  
cout \<\< u1 \<\< endl;  
plot(u1,fill=1,dim=3,value=1,wait=1,cmm=“u1”);

u2=0;  
plot(u2,fill=1,dim=3,value=1,wait=1,cmm=“u2”);

[y1,y2]=[u1,u2];  
cout \<\< y1 \<\< endl;  
// 0 \<= k \< Xh.ndof=26  
// k=3

Here, for i=2 → k=3

I need this to treat Dirichlet boundary condition on rectangular matrix  
matrix A = StokesForces3(Xh,Wh);  
I can not use “+on” since Xh \neq Wh

Thank you!
