GEOSX
LinearOperator.hpp
Go to the documentation of this file.
1 /*
2  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3  * Copyright (c) 2019, Lawrence Livermore National Security, LLC.
4  *
5  * Produced at the Lawrence Livermore National Laboratory
6  *
7  * LLNL-CODE-746361
8  *
9  * All rights reserved. See COPYRIGHT for details.
10  *
11  * This file is part of the GEOSX Simulation Framework.
12  *
13  * GEOSX is a free software; you can redistribute it and/or modify it under
14  * the terms of the GNU Lesser General Public License (as published by the
15  * Free Software Foundation) version 2.1 dated February 1999.
16  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17  */
18 
23 #ifndef GEOSX_LINEARALGEBRA_INTERFACES_LINEAROPERATOR_HPP_
24 #define GEOSX_LINEARALGEBRA_INTERFACES_LINEAROPERATOR_HPP_
25 
26 #include "common/DataTypes.hpp"
27 
28 namespace geosx
29 {
30 
36 template< typename VECTOR >
38 {
39 public:
40 
42  using Vector = VECTOR;
43 
47  LinearOperator() = default;
48 
52  virtual ~LinearOperator() = default;
53 
61  virtual void apply( Vector const & src, Vector & dst ) const = 0;
62 
73  virtual void residual( Vector const & x, Vector const & b, Vector & r ) const
74  {
75  this->apply( x, r );
76  r.axpby( 1.0, b, -1.0 );
77  }
78 
83  virtual globalIndex numGlobalRows() const = 0;
84 
89  virtual globalIndex numGlobalCols() const = 0;
90 };
91 
92 }
93 
94 #endif //GEOSX_LINEARALGEBRA_INTERFACES_LINEAROPERATOR_HPP_
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
virtual globalIndex numGlobalCols() const =0
Get the number of global columns.
LinearOperator()=default
Constructor.
virtual void residual(Vector const &x, Vector const &b, Vector &r) const
Compute residual r = Ax - b.
virtual globalIndex numGlobalRows() const =0
Get the number of global rows.
virtual void apply(Vector const &src, Vector &dst) const =0
Apply operator to a vector.
Abstract base class for linear operators.
TrilinosInterface ::ParallelVector Vector
Alias for template parameter.
virtual ~LinearOperator()=default
Destructor.