[Trilinos-Users] Epetra_VbrMatrix -- Input Coefficients?

Williams, Alan B william at sandia.gov
Wed Mar 17 17:20:50 MDT 2010


Hi John,
You have a couple of options.
1. If you construct a matrix with a graph, that graph needs to first be initialized with the appropriate structure. In other words, loop over your rows and columns and initialize each of the non-zero positions in the graph (telling the graph which columns are non-zero for each row). Then call fillComplete on the graph and then construct the matrix.

otherwise,

2. just construct the matrix with the rowMap (no colMap, no graph), and use insert instead of suminto to load the coefficients. the matrix will internally create the needed structure.

Alan


> -----Original Message-----
> From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-
> users-bounces at software.sandia.gov] On Behalf Of John Mitchell
> Sent: Wednesday, March 17, 2010 5:05 PM
> To: trilinos-users at software.sandia.gov
> Subject: [Trilinos-Users] Epetra_VbrMatrix -- Input Coefficients?
> 
> Hi,
> 
> Any help would be appreciated.
> 
> I'm trying to populate the entries in a Epetra_VbrMatrix.  I'm having
> trouble getting past the "EndSubmitEntries()" function.   I get a
> non-zero return value from this function on the first row?
> 
> There seems to be a lot of "preconditions" for getting a matrix to work
> and I must not be quite satisfying those conditions.
> 
> Not sure if I am properly initializing the graph.  I used
> FillComplete()
> so that indices would be local thus allowing me to "SumIntoMyValues()"
> 
> As a starter, I just created a SerialDenseMatrix to populate each block
> entry;
> 
> I have rowMap and a colMap -- in general these are different.  But the
> size of each element is vectorNDF.
> 
> Exact code is below.
> 
> Thanks,
> John
> 
>      const int vectorNDF=3;
>     Epetra_BlockMap rowMap   = ...
>     Epetra_BlockMap colMap = ...
>     int *numNeigh = (int*)list.getNumNeigh();
>     Epetra_CrsGraph graph(Copy,rowMap,colMap,numNeigh);
> graph.FillComplete();
>     Epetra_VbrMatrix m(Copy,graph);
>     for(int row=0;row<rowMap.NumMyElements();row++){
>         int numCol = list.getNumNeigh(row);
>         BOOST_CHECK(s[row]==numCol);
>         int *cols = (int*)list.getNeighborhood(row);
>         int err = m.BeginSumIntoMyValues(row,numCol,cols);
>         if(0!=err){
>             std::cerr << "Error
> m.BeginSumIntoMyValues(row,numCol,cols);";
>             std::exit(-1);
>         }
>         /*
>          * loop over columns in row and submit block entry
>          */
> 
>         for(int col=0;col<numCol;col++){
>             err=0;
>             Epetra_SerialDenseMatrix k(vectorNDF,vectorNDF);
>             err = m.SubmitBlockEntry(k);
>             if(0!=err){
>                 std::cerr << "Error m.SubmitBlockEntry(k);";
>                 std::exit(-1);
>             }
> 
>         }
>         err = m.EndSubmitEntries();
>         if(0!=err){
>             std::cerr << "Error m.EndSubmitEntries();";
>             std::exit(-1);
>         }
>     }
> 
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users



More information about the Trilinos-Users mailing list