error: request for member ‘reinit’ in ‘A_TM’, which is of non-class type ‘dealii::PETScWrappers::BlockSparseMatrix()’
> 1. Now, how do I efficiently setup the block matrix? Ideally, I would like to use a functionality where I can define the number of (block) rows and columns and then place pointers to the existing sparse matrices. I set out by trying to use the PETScWrappers::BlockSparseMatrix class, but it isn't clear from the documentation if I can achieve what I want.
It does not quite work like this.PETScWrappers::BlockSparseMatrix *is* a PETScWrappers::SparseMatrix.
The block renumbering makes it look like a block matrix is some internal wizardry (if I remember correctly this is covered by operators in a BaseClass functionality).
I do not believe it is possible to *efficiently* do what you want to do (but I like your idea!), The only method I know of is to copy your four individual matrices into a BlockSparseMatrix element-wise. That, unfortunately is very not efficient! Additionally, you have no solvers for the problem you want set up..
I recommend you assemble a block matrix directly (see section "Block solvers and preconditioners" in the examples).
Can that be done for your case? Is there a specific reason you want to do this?
Best,
Toby
I recommend you assemble a block matrix directly (see section "Block solvers and preconditioners" in the examples).
Can that be done for your case? Is there a specific reason you want to do this?
Why don't you create the BlockSparseMatrix and them assemble into
matrix.block(i,j) (which is of type SparseMatrix)?
unsigned int i,j,k,Ns=3, Nn=2;
//Ns is the number of rows/columns and Nn is the number of non-zero entries per rowstd::vector< std::vector<unsigned int> > indices(Ns,std::vector<unsigned int>(Nn));for(i=0; i<Ns; ++i){ //square matrix, so store the diagonal entry first indices[i][0] = i; //Store the rest of the coln indices in increasing order for(j=1; j<Nn; ++j){ //some placeholder here to ensure sanity, won't work if Nn>2 k = (i+1)%Ns; //k is the actual coln number that is non-zero indices[i][j] = k; }}//Copy this structure into the sparsity patternSparsityPattern sp;sp.copy_from(Ns,Ns,indices.begin(),indices.end());
//Assemble the sparse matrixSparseMatrix<double> mat;//Using reinit sets all the sparse matrix entries to zero so we can use add latermat.reinit(sp);for(i=0; i<Ns; ++i){ for(j=0; j<Nn; j++){ mat.add(i,indices[i][j],i+j); }}BlockSparsityPattern bsp(2,2);for(i=0; i<2; i++){ for(j=0; j<2; j++){ bsp.block(i,j).copy_from(sp); }}BlockSparseMatrix<double> bmat;bmat.reinit(bsp);
Aha! The complex problem. Double up on the real-space size and solve
as a 2x2 real matrix problem.
This can easily be done without BlockSparseMatrix. Right now, I can
not remember how I do this.
If you are interested I can send you a code sample when I get back to school.
you need to call collect_sizes() after changing the size of any block.
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/tMZLz9u7Qac/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.