GEOS
EpetraVector.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_LINEARALGEBRA_INTERFACES_EPETRAVECTOR_HPP_
21 #define GEOS_LINEARALGEBRA_INTERFACES_EPETRAVECTOR_HPP_
22 
24 
25 class Epetra_Vector;
26 
27 namespace geos
28 {
29 
33 class EpetraVector final : private VectorBase< EpetraVector >
34 {
35 public:
36 
41 
47 
52  EpetraVector( EpetraVector const & src );
53 
58  EpetraVector( EpetraVector && src ) noexcept;
59 
66 
72  EpetraVector & operator=( EpetraVector && src ) noexcept;
73 
78 
80 
85 
86  using VectorBase::setName;
87  using VectorBase::closed;
88  using VectorBase::ready;
89  using VectorBase::open;
90  using VectorBase::zero;
91  using VectorBase::values;
92 
96  virtual bool created() const override;
97 
98  virtual void create( localIndex const localSize,
99  MPI_Comm const & comm ) override;
100 
101  virtual void close() override;
102 
103  virtual void touch() override;
104 
105  virtual void reset() override;
106 
107  virtual void set( real64 const value ) override;
108 
109  virtual void rand( unsigned const seed ) override;
110 
111  virtual void scale( real64 const scalingFactor ) override;
112 
113  virtual void reciprocal() override;
114 
115  virtual real64 dot( EpetraVector const & vec ) const override;
116 
117  virtual void copy( EpetraVector const & x ) override;
118 
119  virtual void axpy( real64 const alpha,
120  EpetraVector const & x ) override;
121 
122  virtual void axpby( real64 const alpha,
123  EpetraVector const & x,
124  real64 const beta ) override;
125 
126  virtual void pointwiseProduct( EpetraVector const & x,
127  EpetraVector & y ) const override;
128 
132  virtual real64 norm1() const override;
133 
137  virtual real64 norm2() const override;
138 
142  virtual real64 normInf() const override;
143 
147  virtual globalIndex globalSize() const override;
148 
152  virtual localIndex localSize() const override;
153 
157  virtual globalIndex ilower() const override;
158 
162  virtual globalIndex iupper() const override;
163 
167  virtual MPI_Comm comm() const override;
168 
169  virtual void print( std::ostream & os = std::cout ) const override;
170 
171  virtual void write( string const & filename,
172  LAIOutputFormat const format = LAIOutputFormat::MATRIX_MARKET ) const override;
173 
175 
180  Epetra_Vector const & unwrapped() const;
181 
186  Epetra_Vector & unwrapped();
187 
188 private:
189 
191  std::unique_ptr< Epetra_Vector > m_vec;
192 };
193 
194 } // end geos namespace
195 
196 #endif /*GEOS_LINEARALGEBRA_INTERFACES_EPETRAVECTOR_HPP_*/
Wrapper around Trilinos' Epetra_Vector object.
EpetraVector()
Empty vector constructor. Create an empty (distributed) vector.
virtual void close() override
Close vector for modification.
virtual void scale(real64 const scalingFactor) override
Multiply all elements by factor.
virtual void touch() override
Notify the vector about external modification through direct data pointer.
EpetraVector & operator=(EpetraVector &&src) noexcept
Move assignment.
virtual void write(string const &filename, LAIOutputFormat const format=LAIOutputFormat::MATRIX_MARKET) const override
Write the vector to a file.
virtual void copy(EpetraVector const &x) override
Update vector y as y = x.
Epetra_Vector const & unwrapped() const
Returns a const pointer to the underlying Epetra object.
virtual real64 norm2() const override
2-norm of the vector.
virtual void print(std::ostream &os=std::cout) const override
Print the vector in Trilinos format to the terminal.
virtual void set(real64 const value) override
Set all elements to a constant value.
virtual void pointwiseProduct(EpetraVector const &x, EpetraVector &y) const override
Compute the component-wise multiplication y = v * x.
virtual globalIndex iupper() const override
Get upper bound of local partition.
virtual localIndex localSize() const override
Returns the local size of the vector.
virtual void reciprocal() override
Replace vector elements by their reciprocals.
EpetraVector(EpetraVector &&src) noexcept
Move constructor.
EpetraVector(EpetraVector const &src)
Copy constructor.
virtual void axpy(real64 const alpha, EpetraVector const &x) override
Update vector y as y = alpha*x + y.
virtual globalIndex ilower() const override
Get lower bound of local partition.
virtual void rand(unsigned const seed) override
Set vector elements to random entries.
EpetraVector & operator=(EpetraVector const &src)
Copy assignment.
virtual real64 normInf() const override
Infinity-norm of the vector.
virtual void create(localIndex const localSize, MPI_Comm const &comm) override
Create a vector based on local number of elements.
virtual globalIndex globalSize() const override
Returns the global of the vector.
virtual bool created() const override
Query vector creation status.
virtual void axpby(real64 const alpha, EpetraVector const &x, real64 const beta) override
Update vector y as y = alpha*x + beta*y.
Epetra_Vector & unwrapped()
Returns a non-const pointer to the underlying Epetra object.
virtual real64 dot(EpetraVector const &vec) const override
Dot product with the vector vec.
~EpetraVector()
Destructor.
virtual void reset() override
Reset the vector to default state.
virtual MPI_Comm comm() const override
Get the communicator used by this vector.
virtual real64 norm1() const override
1-norm of the vector.
Common base template for all vector wrapper types.
Definition: VectorBase.hpp:49
bool ready() const
Query vector ready status.
Definition: VectorBase.hpp:76
virtual arrayView1d< real64 > open()
Open the vector for modifying entries.
Definition: VectorBase.hpp:129
arrayView1d< real64 const > values() const
Definition: VectorBase.hpp:305
virtual void zero()
Set vector elements to zero.
Definition: VectorBase.hpp:181
bool closed() const
Query vector closed status.
Definition: VectorBase.hpp:64
void setName(string const &name)
Set a name for the vector (mainly used during various logging).
Definition: VectorBase.hpp:113
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:88
LAIOutputFormat
Definition: common.hpp:142
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85