GEOSX
TransposeOperator.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2019 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2019 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2019 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All right reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_LINEARALGEBRA_TRANSPOSEMATRIXOPERATOR_HPP_
20 #define GEOS_LINEARALGEBRA_TRANSPOSEMATRIXOPERATOR_HPP_
21 
23 
24 namespace geos
25 {
26 
31 template< typename LAI >
32 class TransposeOperator : public LinearOperator< typename LAI::ParallelVector >
33 {
34 public:
35 
38 
40  using Vector = typename Base::Vector;
41 
43  using Matrix = typename LAI::ParallelMatrix;
44 
49  explicit TransposeOperator( Matrix const & mat )
50  : Base(),
51  m_matrix( mat )
52  { }
53 
57  virtual ~TransposeOperator() override = default;
58 
66  virtual void apply( Vector const & src, Vector & dst ) const override
67  {
68  m_matrix.applyTranspose( src, dst );
69  }
70 
75  virtual globalIndex numGlobalRows() const override
76  {
77  return m_matrix.numGlobalCols();
78  }
79 
84  virtual globalIndex numGlobalCols() const override
85  {
86  return m_matrix.numGlobalRows();
87  }
88 
93  virtual localIndex numLocalRows() const override
94  {
95  return m_matrix.numLocalCols();
96  }
97 
102  virtual localIndex numLocalCols() const override
103  {
104  return m_matrix.numLocalRows();
105  }
106 
111  virtual MPI_Comm comm() const override
112  {
113  return m_matrix.comm();
114  }
115 
116 private:
117 
118  Matrix const & m_matrix;
119 };
120 
121 }
122 
123 #endif //GEOS_LINEARALGEBRA_TRANSPOSEMATRIXOPERATOR_HPP_
Abstract base class for linear operators.
VECTOR Vector
Alias for template parameter.
Simple class that wraps a matrix and represents its transpose as a linear operator.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
virtual globalIndex numGlobalCols() const override
Get the number of global columns.
virtual localIndex numLocalCols() const override
Get the number of local columns.
virtual localIndex numLocalRows() const override
Get the number of local rows.
virtual ~TransposeOperator() override=default
Destructor.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
virtual globalIndex numGlobalRows() const override
Get the number of global rows.
virtual MPI_Comm comm() const override
Get the MPI communicator the matrix was created with.
TransposeOperator(Matrix const &mat)
Constructor.
typename Base::Vector Vector
Alias for vector type.
GEOSX_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
LAInterface::ParallelMatrix ParallelMatrix
Alias for ParallelMatrix.
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125