~ubuntu-branches/ubuntu/maverick/dolfin/maverick

« back to all changes in this revision

Viewing changes to bench/la/sparse-matrix/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2009-10-12 14:13:18 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091012141318-hkbxl0sq555vqv7d
Tags: 0.9.4-1
* New upstream release. This version cleans up the design of the
  function class by adding a new abstraction for user-defined
  functions called Expression. A number of minor bugfixes and
  improvements have also been made.
* debian/watch: Update for new flat directory structure.
* Update debian/copyright.
* debian/rules: Use explicit paths to PETSc 3.0.0 and SLEPc 3.0.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
using namespace boost::tuples;
16
16
 
17
17
//-----------------------------------------------------------------------------
 
18
/*
18
19
template<class Mat, class Vec = uBLASVector>
19
20
struct MatrixAssemble
20
21
{
 
22
 
21
23
  //---------------------------------------------------------------------------
22
24
  static double assemble(Form& a, const dolfin::uint N)
23
25
  {
24
 
    dolfin_set("output destination", "silent");  
 
26
    logging(false);  
25
27
    UnitSquare mesh(N, N);
26
28
    Mat A;
27
29
  
32
34
  //---------------------------------------------------------------------------
33
35
  static double assemble(Form& a, Mat& A, const dolfin::uint N)
34
36
  {
35
 
    dolfin_set("output destination", "silent");  
 
37
    logging(false);  
36
38
    UnitSquare mesh(N, N);
37
39
 
38
40
    tic();
42
44
  //---------------------------------------------------------------------------
43
45
  static tuple<double, double> assemble(dolfin::uint N)
44
46
  {
45
 
    dolfin_set("output destination", "silent");
 
47
    logging(false);  
46
48
    tuple<double, double> timing;
47
49
    Mat A;
48
50
    A.init(2*N, 2*N);
59
61
      jpos[0] = i+1; jpos[1] = i;   jpos[2] = N+i+1; jpos[3] = N+i;
60
62
      A.add(block, 4, ipos, 4, jpos);
61
63
    }
62
 
//    get<0>(timing) = toc();  
63
64
    timing.get<0>() = toc();  
64
65
  
65
66
    tic();
71
72
  //---------------------------------------------------------------------------
72
73
  static double vector_multiply(const dolfin::uint N, const dolfin::uint n)
73
74
  {
74
 
    dolfin_set("output destination", "silent");
75
 
    VectorPoissonBilinearForm a;
 
75
    logging(false);
 
76
    VectorPoisson::BilinearForm a;
76
77
    Mat A;
77
78
    Vec x, y;
78
79
    UnitSquare mesh(N,N);  
94
95
  double time;
95
96
  const dolfin::uint n = 3;
96
97
  const dolfin::uint N[n] = {5, 10, 40};
97
 
  PoissonBilinearForm a;
98
 
  VectorPoissonBilinearForm a_vector;
 
98
  Poisson::BilinearForm a;
 
99
  VectorPoisson::BilinearForm a_vector;
99
100
 
100
101
  begin("Assemble a sparse matrix for scalar Poisson equation on an square N x N mesh");
101
102
#ifdef HAS_PETSC  
138
139
  const dolfin::uint N = 5000;
139
140
  tuple<double, double> timing;
140
141
 
141
 
  dolfin_set("output destination", "terminal");
 
142
  logging(true);  
142
143
  begin("Assemble a sparse matrix in quasi-random order (size = 2N x 2N)" );
143
144
#ifdef HAS_PETSC  
144
145
  timing = MatrixAssemble< PETScMatrix >::assemble(N);
161
162
  const dolfin::uint N = 20;
162
163
  double time;
163
164
 
164
 
  dolfin_set("output destination", "terminal");
 
165
  logging(true);  
165
166
  begin("Sparse matrix-vector multiplication (size N x N, repeated n times)");
166
167
#ifdef HAS_PETSC 
167
168
  time = MatrixAssemble< PETScMatrix, PETScVector >::vector_multiply(N, n);
174
175
 
175
176
  end();
176
177
}
 
178
*/
177
179
//-----------------------------------------------------------------------------
178
180
int main()
179
181
{
180
 
  cout << "Initialisation of a sparse matrix needs updating for this benchmark." << endl;
 
182
  info("Initialisation of a sparse matrix needs updating for this benchmark.");
181
183
  return 0;  
182
184
 
 
185
  /*
183
186
  begin("Sparse matrix benchmark timings");
184
 
  dolfin_set("output destination", "silent");
 
187
  logging(false);  
185
188
 
186
189
  // Assembly of a sparse matrix
187
190
  AssembleSparseMatrices();  
193
196
  MatrixVectorMultiply();  
194
197
 
195
198
  return 0;
 
199
  */
196
200
}
 
201
//-----------------------------------------------------------------------------
 
202