GEOSX
NormalOperator.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 
18 #ifndef GEOS_LINEARALGEBRA_NORMALOPERATOR_HPP_
19 #define GEOS_LINEARALGEBRA_NORMALOPERATOR_HPP_
20 
22 
23 namespace geos
24 {
25 
30 template< typename LAI >
31 class NormalOperator : public LinearOperator< typename LAI::ParallelVector >
32 {
33 public:
34 
37 
39  using Vector = typename Base::Vector;
40 
42  using Matrix = typename LAI::ParallelMatrix;
43 
48  explicit NormalOperator( Matrix const & mat )
49  : m_matrix( mat )
50  {}
51 
55  virtual ~NormalOperator() override = default;
56 
64  void apply( Vector const & src, Vector & dst ) const override
65  {
66  m_matrix.gemv( 1.0, src, 0.0, dst, false );
67  m_matrix.gemv( 1.0, dst, 0.0, dst, true );
68  }
69 
73  globalIndex numGlobalRows() const override
74  {
75  return m_matrix.numGlobalCols();
76  }
77 
81  globalIndex numGlobalCols() const override
82  {
83  return m_matrix.numGlobalCols();
84  }
85 
89  localIndex numLocalRows() const override
90  {
91  return m_matrix.numLocalCols();
92  }
93 
97  localIndex numLocalCols() const override
98  {
99  return m_matrix.numLocalCols();
100  }
101 
105  MPI_Comm comm() const override
106  {
107  return m_matrix.comm();
108  }
109 
110 private:
111 
113  Matrix const & m_matrix;
114 };
115 
116 } // namespace geos
117 
118 #endif //GEOS_LINEARALGEBRA_NORMALOPERATOR_HPP_
Abstract base class for linear operators.
VECTOR Vector
Alias for template parameter.
Wraps a matrix A and represents A^T * A as a linear operator.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
typename Base::Vector Vector
Alias for vector type.
virtual ~NormalOperator() override=default
Destructor.
NormalOperator(Matrix const &mat)
Constructor.
void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
localIndex numLocalCols() const override
MPI_Comm comm() const override
localIndex numLocalRows() const override
globalIndex numGlobalCols() const override
globalIndex numGlobalRows() const override
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