From: kronbichler Date: Sat, 22 Nov 2008 14:30:58 +0000 (+0000) Subject: Added some tests for Trilinos collective add and set operations. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27aaa70c01d3e593c736002e8b11ae341794f26c;p=dealii-svn.git Added some tests for Trilinos collective add and set operations. git-svn-id: https://svn.dealii.org/trunk@17682 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/trilinos/block_sparse_matrix_add_01.cc b/tests/trilinos/block_sparse_matrix_add_01.cc new file mode 100644 index 0000000000..40ee8d58f7 --- /dev/null +++ b/tests/trilinos/block_sparse_matrix_add_01.cc @@ -0,0 +1,167 @@ +//------------- trilinos_block_sparse_matrix_add_01.cc ------------------- +// $Id: 01.cc 17484 2008-11-06 10:21:30Z kronbichler $ +// Version: $Name$ +// +// Copyright (C) 2004, 2005, 2008 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//------------- trilinos_block_sparse_matrix_add_01.cc ------------------- + + +// compare collective adding of elements in a trilinos matrix using +// TrilinosWrappers::BlockSparseMatrix::add() and a FullMatrix with +// setting the same elements on an element-by-element level. Use the entries +// as they would result from a vector-valued problem with a Laplace operator +// in 1D in each component + +#include "../tests.h" +#include +#include +#include +#include +#include + + +void test () +{ + // first set a few entries one-by-one in + // a small matrix + const unsigned int block_size = 16; + TrilinosWrappers::SparseMatrix m_small (block_size,block_size,3); + for (unsigned int i=0; i0 && i full_matrix(2*m.n_block_rows(),2*m.n_block_cols()); + for (unsigned int block_row = 0; block_row local_row_indices (2*m.n_block_rows()); + std::vector local_col_indices (2*m.n_block_cols()); + + for (unsigned int i=0; i with +// setting the same elements on an entry-by-entry. Use the entries as they +// would result from a vector-valued problem with a Laplace operator in 1D +// in each component + +#include "../tests.h" +#include +#include +#include +#include +#include + + +void test () +{ + // first set a few entries one-by-one in + // a small matrix + const unsigned int block_size = 16; + TrilinosWrappers::SparseMatrix m_small (block_size,block_size,3); + for (unsigned int i=0; i full_matrix(2*m.n_block_rows(),2*m.n_block_cols()); + for (unsigned int block_row = 0; block_row local_row_indices (2*m.n_block_rows()); + std::vector local_col_indices (2*m.n_block_cols()); + + for (unsigned int i=0; i +#include +#include +#include + + +void test (TrilinosWrappers::SparseMatrix &m) +{ + TrilinosWrappers::SparseMatrix m2(m.m(), m.n(), m.m()/3+1); + + // first set a few entries one-by-one + for (unsigned int i=0; i col_indices (m.n()/3+1); + std::vector col_values (m.n()/3+1); + for (unsigned int i=0; i with +// setting the same elements on an element-by-element level. Use the entries +// as they would result from a Laplace operator in 1D. + +#include "../tests.h" +#include +#include +#include +#include +#include + + +void test (TrilinosWrappers::SparseMatrix &m) +{ + TrilinosWrappers::SparseMatrix m2(m.m(), m.n(), 3); + + // first set a few entries one-by-one and + // initialize the sparsity pattern for m2 + for (unsigned int i=0; i0 && i full_matrix(2,2); + full_matrix(0,0) = full_matrix(1,1) = 1.; + full_matrix(0,1) = full_matrix(1,0) = -1.; + std::vector local_indices (2); + + for (unsigned int i=0; i +#include +#include +#include + + +void test (TrilinosWrappers::SparseMatrix &m) +{ + // first set a few entries one-by-one + for (unsigned int i=0; i col_indices (m.n()/3+1); + std::vector col_values (m.n()/3+1); + for (unsigned int i=0; i with +// setting the same elements on an element-by-element level. Use the entries +// as they would result from a Laplace operator in 1D. + +#include "../tests.h" +#include +#include +#include +#include +#include + + +void test (TrilinosWrappers::SparseMatrix &m) +{ + TrilinosWrappers::SparseMatrix m2(m.m(), m.n(), 3); + + // first set a few entries one-by-one and + // initialize the sparsity pattern for m2 + for (unsigned int i=0; i0 && i full_matrix(2,2); + full_matrix(0,0) = full_matrix(1,1) = 1.; + full_matrix(0,1) = full_matrix(1,0) = -1.; + std::vector local_indices (2); + + for (unsigned int i=0; i