Mixed problems involving 2D meshes and 1D lineic meshes

Dear all
We are experimenting with the newly introduced 1d lineic meshes.
We have cases where we have to build matrix block where variable is lineic and test function is surfacic or vice versa.

The first situation works correctly but not the second one… see attached example.

 load "isoline"
load "msh3"

// Generating a 2D mesh for a half disk

real R = 1;
border axis(t=-R,R){x=t; y=0;label=6;};
border surface(t=0,pi){x=R*cos(t); y=R*sin(t);label=7;};
mesh Th = buildmesh(axis(20)+surface(30));
plot(Th);

// Extracting the 1D mesh corresponding to the half circle

int[int] l7=[7]; 
meshL Thlin = extract(Th,refedge=l7); //lineic mesh corresponding to boundary 7

// test of mixed problems

fespace Vh(Th,P1); 
fespace Vhlin(Thlin,P1); 

Vh f,g;
Vhlin flin,glin;

varf Test1(flin,g) =  int1d(Thlin)(flin*g); 
matrix Mtest1 = Test1(Vhlin,Vh); 

varf Test2(f,glin) =  int1d(Thlin)(f*glin);
matrix Mtest2 = Test2(Vh,Vhlin);

The error is as follows :
matrix Mtest2 = Test2(Vh,Vhlin) error operator <6C_args>, <PP5v_fes>, <PP6v_fesL>
List of choices
( <15Call_FormLinearIN5Fem2D4MeshE5v_fesE> : <6C_args>, , <PP5v_fes> )
( <17Call_FormBilinearIN5Fem2D5MeshSE6v_fesS5v_fesE> : <6C_args>, <PP6v_fesS>, <PP5v_fes> )
( <17Call_FormBilinearIN5Fem2D5MeshLE6v_fesL5v_fesE> : <6C_args>, <PP6v_fesL>, <PP5v_fes> )
( <17Call_FormBilinearIN5Fem2D5MeshLE6v_fesL6v_fesSE> : <6C_args>, <PP6v_fesL>, <PP6v_fesS> )
( <17Call_FormBilinearIN5Fem2D5MeshSE6v_fesS6v_fesLE> : <6C_args>, <PP6v_fesS>, <PP6v_fesL> )
( <17Call_FormBilinearIN5Fem2D5MeshLE6v_fesLS2_E> : <6C_args>, <PP6v_fesL>, <PP6v_fesL> )
( <15Call_FormLinearIN5Fem2D5MeshLE6v_fesLE> : <6C_args>, , <PP6v_fesL> )
( <17Call_FormBilinearIN5Fem2D5MeshSE6v_fesSS2_E> : <6C_args>, <PP6v_fesS>, <PP6v_fesS> )
( <15Call_FormLinearIN5Fem2D5MeshSE6v_fesSE> : <6C_args>, , <PP6v_fesS> )
( <17Call_FormBilinearIN5Fem2D5Mesh3E6v_fes3S2_E> : <6C_args>, <PP6v_fes3>, <PP6v_fes3> )
( <15Call_FormLinearIN5Fem2D5Mesh3E6v_fes3E> : <6C_args>, , <PP6v_fes3> )
( <17Call_FormBilinearIN5Fem2D4MeshE5v_fesS2_E> : <6C_args>, <PP5v_fes>, <PP5v_fes> )

 Error line number 29, in file Test_meshL_MixedFormulations.edp, before  token )

  current line = 29
Compile error : 
	line number :29, )
error Compile error : 
	line number :29, )
 code = 1 mpirank: 0

Thanks for help !
David & Nabil

Just for information. When we do :

varf Test2(f,glin) =  int1d(Th,7)(f*glin);
matrix Mtest2 = Test2(Vh,Vhlin);

We have the same error message.

Sorry, building matrices from two finite element spaces defined on different mesh types is currently not possible, although it is in the works.
What you can do however, is define a restriction matrix from the 2D to the 1D finite element space, and use that matrix to define the off-diagonal blocks of your coupled problem:

load "isoline"
load "msh3"

// Generating a 2D mesh for a half disk

real R = 1;
border axis(t=-R,R){x=t; y=0;label=6;};
border surface(t=0,pi){x=R*cos(t); y=R*sin(t);label=7;};
mesh Th = buildmesh(axis(20)+surface(30));
plot(Th);

// Extracting the 1D mesh corresponding to the half circle

int[int] l7=[7]; 
meshL Thlin = extract(Th,refedge=l7); //lineic mesh corresponding to boundary 7

// test of mixed problems

fespace Vh(Th,P1); 
fespace Vhlin(Thlin,P1); 

Vh f,g;
Vhlin flin,glin;

varf v(f,g) = int2d(Th)(f*g);
varf vlin(flin,glin) = int1d(Thlin)(flin*glin);

matrix A = v(Vh,Vh);
matrix Alin = vlin(Vhlin,Vhlin);

matrix M = interpolate(Vhlin,Vh);

matrix B = M'*Alin;

matrix Block = [[A, B], [B',Alin]];

display(Block);

Edit: Since the first situation works, you can also simply take the transpose of Mtest1 for the other off-diagonal block

2 Likes

Thanks for the tip !
I also realised that I can simply build it in the other way and transpose.
The ‘interpolate’ solution is fine too ! Some years ago we designed some ugly macros to build such interpolation matrices. Glad to see that it is now built-in.

Hi, very thanks for your tip with interpolate method to link 1D and 2D finite element space!
But I meet another problem here… I have a fespace Xh(Th,[P2,P1]) and Xh [u,p], I want to calculate: varf Test2(flin,[u,p]) = int1d(Thlin)(flin*p)

However, I meet the error that:

Error line number 23, in file test.edp, before token )
** Must have 1 or 2 array, one for unknown functions, one for test functions**
** current line = 23**
Compile error : Must have 1 or 2 array, one for unknown functions, one for test

So I use interpolate method as in this minimal example to calculate Mtest3. But I still have a little puzzle that whether matrix Mtest3 is just what I want as matrix Mtest2?

load “isoline”
load “msh3”
// Generating a 2D mesh for a half disk
real R = 1;
border axis(t=-R,R){x=t; y=0;label=6;};
border surface(t=0,pi){x=Rcos(t); y=Rsin(t);label=7;};
mesh Th = buildmesh(axis(20)+surface(30));
plot(Th);
// Extracting the 1D mesh corresponding to the half circle
int[int] l7=[7];
meshL Thlin = extract(Th,refedge=l7); //lineic mesh corresponding to boundary 7
// test of mixed problems
fespace Vh(Th,P1);
fespace Xh(Th,[P2,P1]);
fespace Vhlin(Thlin,P1);
Vh f,g;
Xh [u,p];
Xh [vu,vp];
Vhlin flin,glin;
varf Test1(flin,g) = int1d(Thlin)(flin*g);
matrix Mtest1 = Test1(Vhlin,Vh);

//varf Test2(flin,[u,p]) = int1d(Thlin)(flin*p);
//matrix Mtest2 = Test2(Vhlin,Xh);

varf Test31(flin,glin) = int1d(Thlin)(flin * glin);
varf Test32([u,p],[vu,vp]) = int2d(Th)(p * vp);
matrix Mtest31 = Test31(Vhlin,Vhlin);
matrix Mtest32 = Test32(Xh,Xh);
matrix M1 = interpolate(Vhlin,Xh);
matrix M2 = M1*Mtest32;
matrix Mtest3 = M2’*Mtest31;

Thanks very much~ (Maybe I should try composite element, but now I want to know more about this detail first)

Hi, this problem is solved. If I use (with “[” and “]”)

varf Test2([flin],[u,p]) = int1d(Thlin)(flin*p);
matrix Mtest2 = Test2(Vhlin,Xh);

instead of

varf Test2(flin,[u,p]) = int1d(Thlin)(flin*p);
matrix Mtest2 = Test2(Vhlin,Xh);

then no error message.

Thanks again~