GEOSX
EpetraVector.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOSX_LINEARALGEBRA_INTERFACES_EPETRAVECTOR_HPP_
20 #define GEOSX_LINEARALGEBRA_INTERFACES_EPETRAVECTOR_HPP_
21 
23 
24 class Epetra_FEVector;
25 
26 namespace geosx
27 {
28 
34 class EpetraVector final : private VectorBase< EpetraVector >
35 {
36 public:
37 
41 
47  EpetraVector();
48 
53  EpetraVector( EpetraVector const & src );
54 
59  EpetraVector( EpetraVector && src ) noexcept;
60 
66  EpetraVector & operator=( EpetraVector const & src );
67 
73  EpetraVector & operator=( EpetraVector && src ) noexcept;
74 
78  ~EpetraVector();
79 
81 
85 
87  using VectorBase::closed;
88  using VectorBase::ready;
89  using VectorBase::extract;
90 
94  virtual bool created() const override;
95 
96  virtual void createWithLocalSize( localIndex const localSize,
97  MPI_Comm const & comm ) override;
98 
99  virtual void createWithGlobalSize( globalIndex const globalSize,
100  MPI_Comm const & comm ) override;
101 
102  virtual void create( arrayView1d< real64 const > const & localValues,
103  MPI_Comm const & comm ) override;
104 
105  virtual void open() override;
106 
107  virtual void close() override;
108 
109  virtual void reset() override;
110 
111  virtual void set( globalIndex const globalRowIndex,
112  real64 const value ) override;
113 
114  virtual void add( globalIndex const globalRowIndex,
115  real64 const value ) override;
116 
117  virtual void set( globalIndex const * globalRowIndices,
118  real64 const * values,
119  localIndex size ) override;
120 
121  virtual void add( globalIndex const * globalRowIndices,
122  real64 const * values,
123  localIndex const size ) override;
124 
125  virtual void set( arraySlice1d< globalIndex const > const & globalRowIndices,
126  arraySlice1d< real64 const > const & values ) override;
127 
128  virtual void add( arraySlice1d< globalIndex const > const & globalRowIndices,
129  arraySlice1d< real64 const > const & values ) override;
130 
131  virtual void set( real64 const value ) override;
132 
133  virtual void zero() override;
134 
135  virtual void rand( unsigned const seed = 1984 ) override;
136 
137  virtual void scale( real64 const scalingFactor ) override;
138 
139  virtual void reciprocal() override;
140 
141  virtual real64 dot( EpetraVector const & vec ) const override;
142 
143  virtual void copy( EpetraVector const & x ) override;
144 
145  virtual void axpy( real64 const alpha,
146  EpetraVector const & x ) override;
147 
148  virtual void axpby( real64 const alpha,
149  EpetraVector const & x,
150  real64 const beta ) override;
151 
152  virtual void pointwiseProduct( EpetraVector const & x,
153  EpetraVector & y ) const override;
154 
158  virtual real64 norm1() const override;
159 
163  virtual real64 norm2() const override;
164 
168  virtual real64 normInf() const override;
169 
173  virtual globalIndex globalSize() const override;
174 
178  virtual localIndex localSize() const override;
179 
183  virtual globalIndex ilower() const override;
184 
188  virtual globalIndex iupper() const override;
189 
190  virtual real64 get( globalIndex globalRow ) const override;
191 
192  virtual void get( arraySlice1d< globalIndex const > const & globalIndices,
193  arraySlice1d< real64 > const & values ) const override;
194 
195  virtual localIndex getLocalRowID( globalIndex const globalRow ) const override;
196 
197  virtual globalIndex getGlobalRowID( localIndex const localRow ) const override;
198 
202  virtual real64 const * extractLocalVector() const override;
203 
207  virtual real64 * extractLocalVector() override;
208 
212  virtual MPI_Comm getComm() const override;
213 
214  virtual void print( std::ostream & os = std::cout ) const override;
215 
216  virtual void write( string const & filename,
217  LAIOutputFormat const format = LAIOutputFormat::MATRIX_MARKET ) const override;
218 
220 
225  Epetra_FEVector const & unwrapped() const;
226 
231  Epetra_FEVector & unwrapped();
232 
233 private:
234 
236  std::unique_ptr< Epetra_FEVector > m_vector;
237 };
238 
239 } // end geosx namespace
240 
241 #endif /*GEOSX_LINEARALGEBRA_INTERFACES_EPETRAVECTOR_HPP_*/
virtual void reciprocal() override
Replace vector elements by their reciprocals.
EpetraVector()
Empty vector constructor. Create an empty (distributed) vector.
~EpetraVector()
Destructor.
Common base template for all vector wrapper types.
Definition: VectorBase.hpp:47
virtual localIndex getLocalRowID(globalIndex const globalRow) const override
Map a global row index to local row index.
virtual void pointwiseProduct(EpetraVector const &x, EpetraVector &y) const override
Compute the componentwise multiplication y = v * x.
virtual void extract(arrayView1d< real64 > const &localVector) const
Extract local solution by copying into a user-provided array.
Definition: VectorBase.hpp:423
virtual void open() override
Open the vector for modifying entries.
virtual localIndex localSize() const override
Returns the local size of the vector.
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:128
virtual void print(std::ostream &os=std::cout) const override
Print the vector in Trilinos format to the terminal.
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
Definition: ArraySlice.hpp:89
bool closed() const
Query vector closed status.
Definition: VectorBase.hpp:104
std::string format(int NDIM, INDEX_TYPE const *const dims)
This function returns a string that may be used as the "type" in a call to TV_ttf_add_row(). This will either be a single value or an array.
Definition: tv_helpers.hpp:37
virtual real64 norm2() const override
2-norm of the vector.
virtual void reset() override
Reset the matrix to default state.
virtual void close() override
Assemble vector.
virtual void createWithLocalSize(localIndex const localSize, MPI_Comm const &comm) override
Create a vector based on local number of elements.
This class serves to provide a "view" of a multidimensional array.
Definition: ArrayView.hpp:67
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
virtual real64 dot(EpetraVector const &vec) const override
Dot product with the vector vec.
virtual void create(arrayView1d< real64 const > const &localValues, MPI_Comm const &comm) override
Construct parallel vector from a local array.
virtual void createWithGlobalSize(globalIndex const globalSize, MPI_Comm const &comm) override
Create a vector based on global number of elements.
virtual globalIndex iupper() const override
Get upper bound of local partition.
virtual void scale(real64 const scalingFactor) override
Multiply all elements by scalingFactor.
virtual void write(string const &filename, LAIOutputFormat const format=LAIOutputFormat::MATRIX_MARKET) const override
Write the vector to a file.
LAIOutputFormat
Definition: common.hpp:139
virtual real64 normInf() const override
Infinity-norm of the vector.
virtual void add(globalIndex const globalRowIndex, real64 const value) override
Add into vector value.
virtual MPI_Comm getComm() const override
Get the communicator used by this vector.
virtual globalIndex ilower() const override
Get lower bound of local partition.
virtual bool created() const override
Query vector creation status.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
virtual globalIndex getGlobalRowID(localIndex const localRow) const override
Map a local row index to global row index.
Epetra_FEVector const & unwrapped() const
Returns a const pointer to the underlying Epetra object.
virtual void zero() override
Set vector elements to zero.
virtual real64 norm1() const override
1-norm of the vector.
virtual globalIndex globalSize() const override
Returns the global of the vector.
This class creates and provides basic support for the Epetra_FEVector vector object type used in Tril...
virtual real64 const * extractLocalVector() const override
Extract a view of the local portion of the array.
virtual void axpby(real64 const alpha, EpetraVector const &x, real64 const beta) override
Update vector y as y = alpha*x + beta*y.
virtual void rand(unsigned const seed=1984) override
Set vector elements to random entries.
virtual void copy(EpetraVector const &x) override
Update vector y as y = x.
virtual void axpy(real64 const alpha, EpetraVector const &x) override
Update vector y as y = alpha*x + y.
EpetraVector & operator=(EpetraVector const &src)
Copy assignment.
bool ready() const
Query vector ready status.
Definition: VectorBase.hpp:116