Dear Edouard,
In your example, 'a' seems to be a data, so that it has to be declared
md.add_fem_data('a', fem)
If you declare it as a variable, the matrix given by gf.asm will have
some entries for the variable 'a'.
And concerning your second example, you can of course reference a
matrix data. For instance for a 3x3 matrix field with
md.add_initialized_fem_data('M', fem, VM, [3,3])
where VM is the vector of the values of the matrix field in each dof
(and in the fortran order for the components of the matrices).
Best regards,
Yves
Le 18/06/2021 à 19:36, Edouard Oudet a écrit :
Dear getfem users,
I am interested in computing the following fem matrices on a domain
Omega for Lagrange elements of order k
1) ∫∂Ω (∇u.n) v a dσ
where a is a vector of length the number of dof, u and v are test
functions and n the normal. I tried the following steps
md = gf.Model("real")
md.add_fem_variable('u', fem)
md.add_fem_variable('a', fem)
md.set_variable('a', ones(nbdof))
faces = gf.Mesh.get(tmesh, 'outer_faces')
bregion_id = 1
tmesh.set_region(bregion_id, faces)
B = gf.asm('generic', mim, 2, 'Normal.Grad_Test_u * Test2_u. a',
bregion_id, md)
Does it look correct?
2) ∫Ω (M ∇u) . ∇v dx
where again u and v are scalar functions and M a matrix field
(defined for every dof). I had in mind to do something like
A = gf.asm("generic", mim, 2, "(M * Grad_Test2_u).Grad_Test_u", -1, md)
but I do not know how how to define the matrix field and how to
manage its product with my gradients.
Any comments are welcome..
I apologize one again for these naive questions,
best
Edouard.