matrix_vector_product.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 // Include guards
27 #ifndef OOMPH_MATRIX_VECTOR_PRODUCT_HEADER
28 #define OOMPH_MATRIX_VECTOR_PRODUCT_HEADER
29 
30 
31 // Config header generated by autoconfig
32 #ifdef HAVE_CONFIG_H
33 #include <oomph-lib-config.h>
34 #endif
35 
36 #include "matrices.h"
38 #ifdef OOMPH_HAS_TRILINOS
39 #include "trilinos_helpers.h"
40 #endif
41 
42 namespace oomph
43 {
44  //=============================================================================
49  //=============================================================================
51  {
52  public:
55  {
56  // null pointers
57 #ifdef OOMPH_HAS_TRILINOS
58  Epetra_matrix_pt = 0;
59 #endif
60  Oomph_matrix_pt = 0;
62  }
63 
66 
68  void operator=(const MatrixVectorProduct&) = delete;
69 
72  {
73  this->clean_up_memory();
74  }
75 
78  {
79 #ifdef OOMPH_HAS_TRILINOS
80  delete Epetra_matrix_pt;
81  Epetra_matrix_pt = 0;
82 #endif
83  delete Oomph_matrix_pt;
84  Oomph_matrix_pt = 0;
87  }
88 
98  void setup(CRDoubleMatrix* matrix_pt,
99  const LinearAlgebraDistribution* col_dist_pt = 0);
100 
103  void multiply(const DoubleVector& x, DoubleVector& y) const;
104 
107  void multiply_transpose(const DoubleVector& x, DoubleVector& y) const;
108 
110  const unsigned& ncol() const
111  {
112  return Ncol;
113  }
114 
115  private:
116 #ifdef OOMPH_HAS_TRILINOS
118  void trilinos_multiply_helper(const DoubleVector& x, DoubleVector& y) const;
119 
121  void trilinos_multiply_transpose_helper(const DoubleVector& x,
122  DoubleVector& y) const;
123 
125  Epetra_CrsMatrix* Epetra_matrix_pt;
126 #endif
127 
131 
134 
138 
140  unsigned Ncol;
141  };
142 } // namespace oomph
143 #endif
Definition: matrices.h:888
Definition: linear_algebra_distribution.h:435
Definition: double_vector.h:58
Definition: linear_algebra_distribution.h:64
Definition: matrix_vector_product.h:51
void multiply_transpose(const DoubleVector &x, DoubleVector &y) const
Definition: matrix_vector_product.cc:177
MatrixVectorProduct(const MatrixVectorProduct &)=delete
Broken copy constructor.
void clean_up_memory()
clear the memory
Definition: matrix_vector_product.h:77
CRDoubleMatrix * Oomph_matrix_pt
an oomph-lib matrix
Definition: matrix_vector_product.h:133
LinearAlgebraDistribution * Column_distribution_pt
Definition: matrix_vector_product.h:137
const unsigned & ncol() const
Access function to the number of columns.
Definition: matrix_vector_product.h:110
void multiply(const DoubleVector &x, DoubleVector &y) const
Definition: matrix_vector_product.cc:108
bool Using_trilinos
Definition: matrix_vector_product.h:130
~MatrixVectorProduct()
Destructor.
Definition: matrix_vector_product.h:71
unsigned Ncol
number of columns of the matrix
Definition: matrix_vector_product.h:140
void setup(CRDoubleMatrix *matrix_pt, const LinearAlgebraDistribution *col_dist_pt=0)
Definition: matrix_vector_product.cc:41
MatrixVectorProduct()
Constructor.
Definition: matrix_vector_product.h:54
void operator=(const MatrixVectorProduct &)=delete
Broken assignment operator.
Scalar * y
Definition: level1_cplx_impl.h:128
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28