[Trilinos-Users] Fwd: extracting sub-matrix

Bart Janssens bart.janssens at lid.kviv.be
Sat Mar 2 01:28:13 MST 2013


Forgot to CC the list (is it deliberate that the list is not Reply-To?)


Bui,

I'm using Teko::Epetra::BlockedEpetraOperator from the teko package
for this purpose. It takes a vector of vectors of GIDS that represent
each block that you want to create. You can then use the GetBlock
function to extract the blocks. I don't know if this is the only or
the most efficient method.

Cheers,

---------- Forwarded message ----------
From: Bart Janssens <bart.janssens at lid.kviv.be>
Date: Sat, Mar 2, 2013 at 9:24 AM
Subject: Re: [Trilinos-Users] extracting sub-matrix
To: Hoang Giang Bui <hgbk2008 at gmail.com>


On Sat, Mar 2, 2013 at 6:42 AM, Hoang Giang Bui <hgbk2008 at gmail.com> wrote:
> Thank you very much for the tip. Below is a snippet that I used to test the
> method above, but it does not work as expected. Can you help to show me the
> error in this. Basically, I try to extract the first 4x4 block of the
> matrix.
>
>     Epetra_CrsMatrix * Mat = Gal.GetMatrix();
>
>     std::vector<int> gids1;
>     gids1.push_back(0);
>     gids1.push_back(1);
>     gids1.push_back(2);
>     gids1.push_back(3);

>    std::vector<std::vector<int> > vars;
>   vars.push_back(gids1);

>   Teuchos::RCP<const Epetra_Operator> matOp = Teuchos::rcp(Mat);
>   Teko::Epetra::BlockedEpetraOperator blkExtractor(vars,matOp,"sub-matrix");

>   Teuchos::RCP<const Epetra_Operator> blk1 = blkExtractor.GetBlock(0,0);

>   WATCH(blk1);

I think the problem here is that you have to cover all indices of the
matrix. So if your complete matrix is 12x12, you need to add a gids2
with GIDs 4...11, and then GetBlock(0,0) should give you the first
4x4, GetBlock(0,1) the 4x8 and so on.

Cheers,

--
Bart


-- 
Bart



More information about the Trilinos-Users mailing list