59 int main(
int argc,
char *argv[])
66 MPI_Init(&argc,&argv);
69 MPI_Comm_size(MPI_COMM_WORLD, &size);
70 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
83 int num_local_blocks=2;
91 for(
int i=0;i<Nrows;i++){
92 long long gid=Map.GID64(i);
93 long long gidm1=gid-1;
94 long long gidp1=gid+1;
110 List.
set(
"contiguous block size",blocksize);
111 List.
set(
"number of local blocks",num_local_blocks);
134 int* block_lids=
new int [Nrows];
135 int* block_starts=
new int[num_local_blocks+1];
136 for(
int i=0;i<num_local_blocks;i++){
137 block_starts[i]=i*blocksize;
138 for(
int j=0;j<blocksize;j++){
139 block_lids[i*blocksize+j] = i*blocksize+(blocksize-j-1);
143 block_starts[num_local_blocks]=Nrows;
147 List.
set(
"number of local blocks",num_local_blocks);
148 List.
set(
"block start index",block_starts);
149 List.
set(
"block entry lids",block_lids);
165 delete [] block_lids;
166 delete [] block_starts;
175 long long* block_gids=
new long long [Nrows];
176 int* block_starts=
new int[num_local_blocks+1];
177 for(
int i=0;i<num_local_blocks;i++){
178 block_starts[i]=i*blocksize;
179 for(
int j=0;j<blocksize;j++){
180 block_gids[i*blocksize+j] = Map.GID64(i*blocksize+(blocksize-j-1));
184 block_starts[num_local_blocks]=Nrows;
188 List.
set(
"number of local blocks",num_local_blocks);
189 List.
set(
"block start index",block_starts);
190 List.
set(
"block entry gids",block_gids);
206 delete [] block_gids;
207 delete [] block_starts;
213 if(total_norm > 1e-15){
214 if (Comm.
MyPID()==0) std::cout <<
"EpetraExt:: PointToBlockDiagPermute tests FAILED (||res||="<<total_norm<<
")." << std::endl;
221 if (Comm.
MyPID()==0) std::cout <<
"EpetraExt:: PointToBlockDiagPermute tests passed (||res||="<<total_norm<<
")." << std::endl;
EpetraExt_PointToBlockDiagPermute: A class for managing point-to-block-diagonal permutations.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets the parameter list.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
static int Multiply(const Epetra_CrsMatrix &A, bool transposeA, const Epetra_CrsMatrix &B, bool transposeB, Epetra_CrsMatrix &C, bool call_FillComplete_on_result=true, bool keep_all_hard_zeros=false)
Given Epetra_CrsMatrix objects A, B and C, form the product C = A*B.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
int FillComplete(bool OptimizeDataStorage=true)
int main(int argc, char **argv)
int NumMyElements() const
static int Add(const Epetra_CrsMatrix &A, bool transposeA, double scalarA, Epetra_CrsMatrix &B, double scalarB)
Given Epetra_CrsMatrix objects A and B, form the sum B = a*A + b*B.
virtual int Compute()
Extracts the block-diagonal, builds maps, etc.
virtual Epetra_FECrsMatrix * CreateFECrsMatrix()
Create an Epetra_FECrsMatrix from the BlockDiagMatrix.