1

I'm coding in c++ and i'm using FEniCS  fenics/2016.1.0. A part of my code is

Matrix A;
Vector f;
std::vector<std::shared_ptr<const DirichletBC>> dirichlet_matrici({dirichlet}); 
assemble_system(A,f,a,L,dirichlet_matrici);
solve(A, *(u.vector()), f);

I want so solve the system with Eigen, so I need to convert the dolfin::Matrix A and the dolfin::Vector f in Eigen objects. Is it possible? Thank you for your help

GregL
  • 11
  • 1
  • 1
    Duplicate (no answer, either): https://stackoverflow.com/questions/33565670/transform-dolfinmatrix-into-eigenmatrix – chtz Oct 06 '17 at 13:02

1 Answers1

0

I am not sure if it is possible to do a direct conversion. However, it is possible to create a new Eigen matrix and then feed each individual value from the first matrix into the second.

Devin Haslam
  • 747
  • 2
  • 12
  • 34
  • Do you know how to feed each individual value from the Dolfin::Matrix into the Eigen::Matrix. Because I don't understand how to return a particular value from a Dolfin::Matrix. I know just that exists this function: void get(double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const but i don't know what la_index is and how it works – GregL Oct 06 '17 at 15:08
  • 1
    I would check out the documentation: https://fenicsproject.org/olddocs/dolfin/2016.1.0/cpp/programmers-reference/adaptivity/index.html – Devin Haslam Oct 06 '17 at 15:13
  • The documentation doesn't say a lot for all methods and class constructions. For example for the function said before the description is: Get block of values. For la_index the description is: Index type for compatibility with linear algebra backend(s) – GregL Oct 06 '17 at 15:26
  • 1
    what about the array portion? https://fenicsproject.org/olddocs/dolfin/2016.1.0/cpp/programmers-reference/common/Array.html – Devin Haslam Oct 06 '17 at 16:11
  • 1
    @DevinHaslam I think the [`operator(i,j)`](https://fenicsproject.org/olddocs/dolfin/2016.1.0/cpp/programmers-reference/la/GenericMatrix.html#_CPPv2NK13GenericMatrixclEN6dolfin8la_indexEN6dolfin8la_indexE) or `getitem({i,j})` is what would be used for a matrix – PeterT Oct 06 '17 at 18:05