Advanced Multi-Physics (AMP)
On-Line Documentation
MultiVector.h
Go to the documentation of this file.
1#ifndef included_AMP_MultiVector
2#define included_AMP_MultiVector
3
4
5#include "AMP/vectors/Vector.h"
6
7
8namespace AMP::LinearAlgebra {
9
10
16class MultiVector final : public Vector
17{
18public: // Create and view functions
23 static std::shared_ptr<MultiVector> create( std::shared_ptr<Variable> name,
24 const AMP_MPI &comm );
25
30 static std::shared_ptr<MultiVector> create( const std::string &name, const AMP_MPI &comm );
31
37 static std::shared_ptr<MultiVector> create( std::shared_ptr<Variable> name,
38 const AMP_MPI &comm,
39 const std::vector<Vector::shared_ptr> &vecs );
40
46 static std::shared_ptr<MultiVector> create( const std::string &name,
47 const AMP_MPI &comm,
48 const std::vector<Vector::shared_ptr> &vecs );
49
55 static std::shared_ptr<const MultiVector>
56 const_create( std::shared_ptr<Variable> name,
57 const AMP_MPI &comm,
58 const std::vector<Vector::const_shared_ptr> &vecs );
59
65 static std::shared_ptr<const MultiVector>
66 const_create( const std::string &name,
67 const AMP_MPI &comm,
68 const std::vector<Vector::const_shared_ptr> &vecs );
69
77 static std::shared_ptr<MultiVector> view( Vector::shared_ptr vec,
78 const AMP_MPI &comm = AMP_COMM_NULL );
79
87 static std::shared_ptr<const MultiVector> constView( Vector::const_shared_ptr vec,
88 const AMP_MPI &comm = AMP_COMM_NULL );
89
90
91public:
93 inline auto begin() { return d_vVectors.begin(); }
94
96 inline auto begin() const { return d_vVectors.begin(); }
97
99 inline auto end() { return d_vVectors.end(); }
100
102 inline auto end() const { return d_vVectors.end(); }
103
105 inline const std::vector<std::shared_ptr<Vector>> &getVecs() { return d_vVectors; }
106
108 std::vector<std::shared_ptr<const Vector>> getVecs() const;
109
110
116
117
127
132 virtual void addVector( Vector::shared_ptr vec );
133
138 virtual void addVector( std::vector<Vector::shared_ptr> vec );
139
143 virtual void eraseVector( Vector::shared_ptr vec );
144
149 virtual Vector::shared_ptr getVector( size_t i );
150
155 virtual Vector::const_shared_ptr getVector( size_t i ) const;
156
160 size_t getNumberOfSubvectors() const;
161
162 std::string type() const override;
163
164 std::unique_ptr<Vector> rawClone() const override;
165
166 void swapVectors( Vector &other ) override;
167
168 void reset() override;
169
170public: // Write/read restart data
177
183 void writeRestart( int64_t fid ) const override;
184
192
193
194public: // public constructor/destructors
199 explicit MultiVector( const std::string &name, const AMP_MPI &comm );
200
206 explicit MultiVector( const std::string &name,
207 const AMP_MPI &comm,
208 const std::vector<Vector::shared_ptr> &vecs );
209
213 explicit MultiVector( std::shared_ptr<Vector> vec );
214
215
216public: // default constructor/destructors
217 MultiVector() = default;
218 MultiVector( MultiVector && ) = delete;
219 MultiVector( const MultiVector & ) = delete;
221 MultiVector &operator=( const MultiVector & ) = delete;
222 virtual ~MultiVector();
223
224
225protected:
228
234 const Vector::shared_ptr &getVector( const Vector &vec, size_t which ) const;
235
241 Vector::shared_ptr &getVector( Vector &vec, size_t which ) const;
242
243
244protected:
246 std::vector<Vector::shared_ptr> d_vVectors;
247
248
249private:
250 // Helper function to add a vector without updating the DOF manager
252
253 // Helper function to reset the vector data
254 inline void resetVectorData();
255
256 // Helper function to reset the vector operations
258};
259
260
261} // namespace AMP::LinearAlgebra
262
263
264#endif
#define AMP_COMM_NULL
Definition AMP_MPI.h:30
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
Class to manage reading/writing restart data.
A collection of AMP Vectors that appear as one vector.
Definition MultiVector.h:17
void swapVectors(Vector &other) override
Swap the data in this Vector for another.
virtual Vector::shared_ptr getVector(size_t i)
Return the i-th Vector in this MultiVector.
const std::vector< std::shared_ptr< Vector > > & getVecs()
Return one past the last vector in the MultiVector.
MultiVector(const std::string &name, const AMP_MPI &comm, const std::vector< Vector::shared_ptr > &vecs)
virtual void addVector(Vector::shared_ptr vec)
Add a vector to a MultiVector. Note: this is a collective operation, vec may be NULL on some processo...
const Vector::shared_ptr & getVector(const Vector &vec, size_t which) const
A convenience method for extracting vectors from a base class.
static std::shared_ptr< const MultiVector > const_create(const std::string &name, const AMP_MPI &comm, const std::vector< Vector::const_shared_ptr > &vecs)
Create a new multivector in parallel.
std::unique_ptr< Vector > rawClone() const override
Allocate space in the same fashion as this
std::vector< Vector::shared_ptr > d_vVectors
The list of AMP Vectors that comprise this Vector.
Vector::shared_ptr selectInto(const VectorSelector &) override
Selects a portion of this vector and puts a view into a vector.
void addVectorHelper(Vector::shared_ptr vec)
auto begin()
Return the first vector in the MultiVector.
Definition MultiVector.h:93
MultiVector(const std::string &name, const AMP_MPI &comm)
MultiVector & operator=(MultiVector &&)=delete
bool containsPointer(const Vector::shared_ptr p) const
Determine if a Vector is a constituent.
static std::shared_ptr< MultiVector > create(std::shared_ptr< Variable > name, const AMP_MPI &comm, const std::vector< Vector::shared_ptr > &vecs)
Create a new multivector in parallel.
std::vector< std::shared_ptr< const Vector > > getVecs() const
Return one past the last vector in the MultiVector.
static std::shared_ptr< const MultiVector > constView(Vector::const_shared_ptr vec, const AMP_MPI &comm=AMP_COMM_NULL)
Create a multivector view of a vector.
void writeRestart(int64_t fid) const override
Write restart data to file.
size_t getNumberOfSubvectors() const
Obtain the number of Vector objects in this MultiVector.
MultiVector(const MultiVector &)=delete
static std::shared_ptr< MultiVector > create(const std::string &name, const AMP_MPI &comm)
Create a new (empty) multivector.
MultiVector(int64_t fid, AMP::IO::RestartManager *manager)
Read restart data to file.
static std::shared_ptr< MultiVector > view(Vector::shared_ptr vec, const AMP_MPI &comm=AMP_COMM_NULL)
Create a multivector view of a vector.
MultiVector & operator=(const MultiVector &)=delete
Vector::shared_ptr & getVector(Vector &vec, size_t which) const
A convenience method for extracting vectors from a base class.
virtual void replaceSubVector(Vector::shared_ptr oldVec, Vector::shared_ptr newVec)
Replace a vector in a MultiVector.
auto end() const
Return one past the last vector in the MultiVector.
static std::shared_ptr< const MultiVector > const_create(std::shared_ptr< Variable > name, const AMP_MPI &comm, const std::vector< Vector::const_shared_ptr > &vecs)
Create a new multivector in parallel.
MultiVector(MultiVector &&)=delete
virtual Vector::const_shared_ptr getVector(size_t i) const
Return the i-th Vector in this MultiVector.
static std::shared_ptr< MultiVector > create(const std::string &name, const AMP_MPI &comm, const std::vector< Vector::shared_ptr > &vecs)
Create a new multivector in parallel.
auto begin() const
Return the first vector in the MultiVector.
Definition MultiVector.h:96
Vector::const_shared_ptr selectInto(const VectorSelector &criterion) const override
MultiVector(std::shared_ptr< Vector > vec)
auto end()
Return one past the last vector in the MultiVector.
Definition MultiVector.h:99
void registerChildObjects(AMP::IO::RestartManager *manager) const override
Register any child objects.
virtual void addVector(std::vector< Vector::shared_ptr > vec)
Add vector(s) to a MultiVector. Note: This is a collective operation, vec may be different sizes on d...
virtual void eraseVector(Vector::shared_ptr vec)
Remove a vector from a MultiVector.
static std::shared_ptr< MultiVector > create(std::shared_ptr< Variable > name, const AMP_MPI &comm)
Create a new (empty) multivector.
void reset() override
Reset.
std::string type() const override
Return the name of the vector.
A class used by Vector::select and Vector::selectInto to create vectors with particular data.
Abstraction of a discrete Vector in a linear simulation.
Definition Vector.h:54
std::shared_ptr< Vector > shared_ptr
Shorthand for shared pointer to Vector.
Definition Vector.h:60
std::shared_ptr< const Vector > const_shared_ptr
Definition Vector.h:65



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page