trilinos / Trilinos

Primary repository for the Trilinos Project
https://trilinos.org/
Other
1.2k stars 564 forks source link

epetra: create Epetra_FECrsMatrix from Epetra_FEVbrMatrix to solve linear system with direct solver (amesos) #12610

Open swiesheier opened 9 months ago

swiesheier commented 9 months ago

Question

I use a wrapper to Epetra_FEVbrMatrix to assemble a 2x2 block system matrix arising from finite elements.

To use one of the direct solvers from amesos package, I have to pass an object of type Epetra_FECrsMatrix.

So given a Epetra_FEVbrMatrix, how can I create Epetra_FECrsMatrix in an efficient manner? The dimension of the matrix is moderate (more than 50k degrees of freedom, but not more than 500k dofs).

To have the flexibility to use iterative solvers (where I have to develop a block preconditioner), I decided to use an Epetra_FEVbrMatrix although I use an direct solver in some cases.

Thank you!

cgcgcg commented 9 months ago

@swiesheier Is this in the context of a legacy code base? Otherwise, please do not use Epetra anymore, it will get dropped in the near future. Use Tpetra instead.

swiesheier commented 9 months ago

@cgcgcg I have access to trilinos@13.4.1. Once I upgrade my software packages, I will link to a newer version of trilinos. But for now and the near future, I have to use 13.4.1.

cgcgcg commented 9 months ago

Tpetra is part of Trilinos 13.4.1 and has been for a while. I want to avoid that any new code is developed against Epetra, given that it will get dropped. (Also, no development of the Epetra stack has happened in years.)

swiesheier commented 9 months ago

@cgcgcg Makes sense. However, the wrapper class I use from my pde package (deal.ii) uses the Epetra class I mentioned.

So in 13.4.1, what could be a way to solve my problem? I mean looping over the elements of the block matrix is a way, but probably very inefficient.

cgcgcg commented 9 months ago

(Caveat: I am not an Epetra user.) Looking at the documentation, maybe try using Epetra_VbrRowMatrix. My understanding is that it allows to wrap an Epetra_VbrMatrix and implements the Epetra_RowMatrix interface.

swiesheier commented 9 months ago

@cgcgcg

I double-checked my implementation. Basically the data structure I am working with consists of 4 Epetra_FECrsMatrix objects that represent the individual blocks of my 2x2 block system. My objective is to combine them into one Epetra_FECrsMatrix object to use the amesos direct solvers.

How could I realize this?

cgcgcg commented 9 months ago

You could use the Teko package to manage your 2x2 system.

swiesheier commented 9 months ago

As I said, I only use wrappers to Trilinos from within my pde software package (deal.ii). Things get too complicated if I start to interface with Trilinos directly from within deal.ii. So what I can work with is the "vector of size 4" of Epetra_FECrsMatrix objects which I somehow have to merge in a single Epetra_FECrsMatrix.