Hello,
Wondering if it is possible to use node values of FEs in varf. Something like the following.
Thank you!
//
mesh Th=square(10,10);
fespace V1h(Th,P1);
V1h u, uh;
varf ma(u,uh)
= int2d(Th) (u[Th[nuTriangle][0]]*uh[u[Th[nuTriangle][0]]]);
Hello,
Wondering if it is possible to use node values of FEs in varf. Something like the following.
Thank you!
//
mesh Th=square(10,10);
fespace V1h(Th,P1);
V1h u, uh;
varf ma(u,uh)
= int2d(Th) (u[Th[nuTriangle][0]]*uh[u[Th[nuTriangle][0]]]);
Hello,
One possibility is to modify the quadrature formula for triangles as
int2d(Th,qft=qf1pTlump)
With qf1pTlump the integral of f over a triangle is computed by |T|(f(V1)+f(V2)+f(V3))/3
where V_i are the vertices of the triangle.
If you put a cutoff function \phi you can get quite a large number of possibilities writing
int2d(Th,qft=qf1pTlump)(phi*u*uh)
Thank you for the suggestion.
I have thought about it, but it does not solve my problem, because u and uh are on different meshes and the compiler complains.
The meshes are “equivalent” in the sense that one is movemesh of the other. In this case mapu and mapt work, but I prefer to build the matrix in a direct way.
It seems that the modification of the matrix M from varf is the way. But this requires knowing the ordering of dofs, ie to which dof corresponds the entry M(i,j), which in the case of vector FE spaces, such as [P1b,P1b,P1] seems not available in the docs - I have posted a message with this regard at Order of variables in matrix generated with varf with a [P1, P1, P0] fespace - #6 by pi.3.141.
When you write (for example)
fespace X(Th,[P1b,P1b,P1]);
fespace Y(Th,[P1,P1]);
varf aa([x1,x2,x3],[y1,y2]) = int2d(Th)(…);
matrix M=aa(X,Y);
the coefficient M(i,j)
of M corresponds to
i (line number) = index of dof of Y
j (column number) = index of dof of X
Then in order to understand the dofs of a product space like X above, you can make a loop over triangles and dofs of X in each triangle, as
for (int k=0;k<Th.nt;++k) {// loop on triangles of the mesh
for (int j=0;j<X.ndofK;++j) {//loop over the dofs in triangle k
cout << "X(k,j)=" << X(k,j) << endl;
}
}
Then X(k,j) is the index of the dof of X (which is required above as column number of M).
The incrementation of j
from 0 to X.ndofK-1 corresponds in order to first the dofs in triangle of the first space in product (here P1b), then listing the dofs in triangle of the second space in product (here P1b), then the dofs in triangle of the third space in product (here P1).
The order of dofs in triangle for each space (P1b or P1 or other) is specific to this space.
For P1, the order corresponds to listing the vertices 0,1,2, as numbered by Th[k][j]
For P1b, the order is first listing the 3 vertices 0,1,2 as for P1, then the bubble.
For P2, the order is first the 3 vertices 0,1,2, then the three edge middles, which are in order opposite to the vertices 0,1,2.
An example is here Order of variables in matrix generated with varf with a [P1, P1, P0] fespace - #2 by fb77
I think you have all the information for your purpose.
Thank you, Francois, for the detailed information!