Advanced Multi-Physics (AMP)
On-Line Documentation
MatrixData.h
Go to the documentation of this file.
1#ifndef included_AMP_MatrixData_h
2#define included_AMP_MatrixData_h
3
4#include <memory>
5
6#include "AMP/matrices/MatrixParametersBase.h"
7#include "AMP/utils/AMP_MPI.h"
8#include "AMP/utils/Utilities.h"
9#include "AMP/utils/enable_shared_from_this.h"
10#include "AMP/utils/typeid.h"
11#include "AMP/vectors/CommunicationList.h"
12#include "AMP/vectors/Scalar.h"
13#include "AMP/vectors/Variable.h"
14
15namespace AMP::IO {
16class RestartManager;
17}
18
19namespace AMP::Discretization {
20class DOFManager;
21}
22
23namespace AMP::LinearAlgebra {
24
25class Vector;
26
27class MatrixData : public AMP::enable_shared_from_this<MatrixData>
28{
29public:
33 explicit MatrixData( std::shared_ptr<MatrixParametersBase> params );
34
36 virtual ~MatrixData();
37
40
42 MatrixData( const MatrixData & ) = delete;
43
45 virtual std::shared_ptr<MatrixData> cloneMatrixData() const = 0;
46
48 virtual std::shared_ptr<MatrixData> transpose() const = 0;
49
51 virtual void removeRange( AMP::Scalar bnd_lo, AMP::Scalar bnd_up ) = 0;
52
54 virtual std::string type() const = 0;
55
57 virtual std::uint16_t mode() const { return std::numeric_limits<std::uint16_t>::max(); }
58
69 template<class TYPE>
70 void addValuesByGlobalID( size_t num_rows,
71 size_t num_cols,
72 const size_t *rows,
73 const size_t *cols,
74 const TYPE *values );
75
86 template<class TYPE>
87 void setValuesByGlobalID( size_t num_rows,
88 size_t num_cols,
89 const size_t *rows,
90 const size_t *cols,
91 const TYPE *values );
92
102 template<class TYPE>
103 void getValuesByGlobalID( size_t num_rows,
104 size_t num_cols,
105 const size_t *rows,
106 const size_t *cols,
107 TYPE *values ) const;
108
114 virtual void getRowByGlobalID( size_t row,
115 std::vector<size_t> &cols,
116 std::vector<double> &values ) const = 0;
117
129 virtual void addValuesByGlobalID( size_t num_rows,
130 size_t num_cols,
131 const size_t *rows,
132 const size_t *cols,
133 const void *values,
134 const typeID &id ) = 0;
135
147 virtual void setValuesByGlobalID( size_t num_rows,
148 size_t num_cols,
149 const size_t *rows,
150 const size_t *cols,
151 const void *values,
152 const typeID &id ) = 0;
153
164 virtual void getValuesByGlobalID( size_t num_rows,
165 size_t num_cols,
166 const size_t *rows,
167 const size_t *cols,
168 void *values,
169 const typeID &id ) const = 0;
170
174 virtual size_t numberColumnIDs( size_t row ) const = 0;
175
179 virtual std::vector<size_t> getColumnIDs( size_t row ) const = 0;
180
185
191 virtual std::shared_ptr<Discretization::DOFManager> getRightDOFManager() const = 0;
192
198 virtual std::shared_ptr<Discretization::DOFManager> getLeftDOFManager() const = 0;
199
205 virtual std::shared_ptr<Variable> getRightVariable() const
206 {
207 return d_pParameters->getRightVariable();
208 }
209
215 virtual std::shared_ptr<Variable> getLeftVariable() const
216 {
217 return d_pParameters->getLeftVariable();
218 }
219
223 virtual size_t numLocalRows() const;
224
228 virtual size_t numGlobalRows() const;
229
233 virtual size_t numLocalColumns() const;
234
238 virtual size_t numGlobalColumns() const;
239
243 virtual size_t beginRow() const;
244
248 virtual size_t endRow() const;
249
253 virtual size_t beginCol() const;
254
258 virtual size_t endCol() const;
259
261 inline virtual AMP_MPI getComm() const
262 {
264 return d_pParameters->getComm();
265 }
266
268 inline virtual AMP::Utilities::Backend getBackend() const
269 {
271 return d_pParameters->d_backend;
272 }
273
274 inline virtual void setBackend( AMP::Utilities::Backend backend )
275 {
277 d_pParameters->d_backend = backend;
278 }
279
282 virtual typeID getCoeffType() const = 0;
283
284
285public: // Non virtual functions
287 uint64_t getID() const;
288
289
290public: // Write/read restart data
296 virtual void registerChildObjects( AMP::IO::RestartManager *manager ) const;
297
303 virtual void writeRestart( int64_t fid ) const;
304
305 MatrixData( int64_t fid, AMP::IO::RestartManager *manager );
306
307protected:
308 std::shared_ptr<MatrixParametersBase> d_pParameters;
309
310 // unique hash to identify this object
311 uint64_t d_hash = 0;
312};
313
314} // namespace AMP::LinearAlgebra
315
316#include "AMP/matrices/data/MatrixData.hpp"
317
318#endif
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
Class to manage reading/writing restart data.
virtual size_t numLocalColumns() const
Get the number of local columns in the matrix.
virtual std::uint16_t mode() const
Return CSR mode of the matrix.
Definition MatrixData.h:57
virtual std::shared_ptr< Discretization::DOFManager > getRightDOFManager() const =0
Get the DOFManager associated with a right vector ( For , is a right vector )
virtual size_t numLocalRows() const
Get the number of local rows in the matrix.
virtual std::shared_ptr< Variable > getLeftVariable() const
Get the variable associated with a left vector ( For , is a left vector )
Definition MatrixData.h:215
void getValuesByGlobalID(size_t num_rows, size_t num_cols, const size_t *rows, const size_t *cols, TYPE *values) const
Get values in the matrix.
virtual void makeConsistent(AMP::LinearAlgebra::ScatterType t)=0
Perform communication to ensure values in the matrix are the same across cores.
uint64_t getID() const
Get a unique id hash for the vector.
virtual std::shared_ptr< Discretization::DOFManager > getLeftDOFManager() const =0
Get the DOFManager associated with a left vector ( For , is a left vector )
virtual void addValuesByGlobalID(size_t num_rows, size_t num_cols, const size_t *rows, const size_t *cols, const void *values, const typeID &id)=0
Add values to those in the matrix.
virtual AMP_MPI getComm() const
Get the comm.
Definition MatrixData.h:261
void setValuesByGlobalID(size_t num_rows, size_t num_cols, const size_t *rows, const size_t *cols, const TYPE *values)
Set values in the matrix.
virtual size_t beginRow() const
Get the global id of the beginning row.
virtual AMP::Utilities::Backend getBackend() const
Get the backend.
Definition MatrixData.h:268
virtual void removeRange(AMP::Scalar bnd_lo, AMP::Scalar bnd_up)=0
Remove matrix entries within given range.
MatrixData()
Empty constructor.
void addValuesByGlobalID(size_t num_rows, size_t num_cols, const size_t *rows, const size_t *cols, const TYPE *values)
Add values to those in the matrix.
virtual size_t endRow() const
Get the global id of the ending row.
std::shared_ptr< MatrixParametersBase > d_pParameters
Definition MatrixData.h:308
virtual std::string type() const =0
Return the type of the matrix.
virtual void registerChildObjects(AMP::IO::RestartManager *manager) const
Register any child objects.
virtual void getRowByGlobalID(size_t row, std::vector< size_t > &cols, std::vector< double > &values) const =0
Retrieve a row of the matrix in compressed format.
virtual ~MatrixData()
Destructor.
virtual void getValuesByGlobalID(size_t num_rows, size_t num_cols, const size_t *rows, const size_t *cols, void *values, const typeID &id) const =0
Get values in the matrix.
virtual size_t endCol() const
Get the global id of last column in diagonal block.
MatrixData(std::shared_ptr< MatrixParametersBase > params)
Constructor.
virtual size_t numGlobalColumns() const
Get the number of global columns in the matrix.
virtual std::shared_ptr< MatrixData > cloneMatrixData() const =0
Clone the data.
virtual size_t numberColumnIDs(size_t row) const =0
Given a row, retrieve the number of non-zero column indices of the matrix.
virtual void setBackend(AMP::Utilities::Backend backend)
Definition MatrixData.h:274
virtual std::shared_ptr< MatrixData > transpose() const =0
Transpose.
virtual void writeRestart(int64_t fid) const
Write restart data to file.
virtual size_t numGlobalRows() const
Get the number of global rows in the matrix.
virtual void setValuesByGlobalID(size_t num_rows, size_t num_cols, const size_t *rows, const size_t *cols, const void *values, const typeID &id)=0
Set values in the matrix.
virtual typeID getCoeffType() const =0
Return the typeid of the matrix coeffs.
virtual size_t beginCol() const
Get the global id of first column in diagonal block.
MatrixData(const MatrixData &)=delete
Copy constructor.
MatrixData(int64_t fid, AMP::IO::RestartManager *manager)
virtual std::vector< size_t > getColumnIDs(size_t row) const =0
Given a row, retrieve the non-zero column indices of the matrix in compressed format.
virtual std::shared_ptr< Variable > getRightVariable() const
Get the variable associated with a right vector ( For , is a right vector )
Definition MatrixData.h:205
Scalar is a class used to store a scalar variable that may be different types/precision.
Definition Scalar.h:21
Enhancement of std::enable_shared_from_this.
#define AMP_ASSERT(EXP)
Assert error.
ScatterType
Flag to choose algorithm for makeConsistent.
Definition Variable.h:21
Backend
Enum to store the backend used for gpu acceleration.
Definition Backend.h:21
Class to store type info.
Definition typeid.h:210



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:40.
Comments on this page