This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Read matlab matrix into fenics

+1 vote

Hello
I want to read a vector/matrix "B" that is saved by matlab into fenics. In my fenics python program I want to read this matrix and compute

B*u

where u is a Function. I want to use B*u as boundary condition in a PDE.

I can read matrix using scipy.io. How can I form the product B*u ?

Thanks

asked Jan 24, 2014 by praveen FEniCS User (2,760 points)

Can you make it more clear to me, how and where you want to apply B. In particular, if u is a function, what should be the product of B and u?

1 Answer

+2 votes
 
Best answer

If B is a matrix with the same dimension as the number of
degrees of freedom in u,
you can take B*u.vector().array().
Then you let numpy do the matrix vector product.

If you want to let dolfin perform the matrix vector product you
would have to make a dolfin matrix out of B.

If B is a matrix with pointwise values then you should use
B in an Expression.

answered Jan 24, 2014 by Kent-Andre Mardal FEniCS Expert (14,380 points)
selected Jan 28, 2014 by praveen
...