Advanced Multi-Physics (AMP)
On-Line Documentation
MultiVectorData.h
Go to the documentation of this file.
1#ifndef included_AMP_MultiVectorData
2#define included_AMP_MultiVectorData
3
4#include "AMP/discretization/DOF_Manager.h"
5#include "AMP/discretization/MultiDOFHelper.h"
6#include "AMP/vectors/data/DataChangeListener.h"
7#include "AMP/vectors/data/VectorData.h"
8
9#include <cstddef>
10
11
12namespace AMP::Discretization {
13class multiDOFManager;
14}
15
16
17namespace AMP::LinearAlgebra {
18
19
30{
31
32public: // Virtual functions
34 virtual ~MultiVectorData() {}
35
36
38 std::string VectorDataName() const override { return "MultiVectorData"; }
39
40
41public: // Basic virtual functions
42 size_t numberOfDataBlocks() const override;
43 size_t sizeOfDataBlock( size_t i = 0 ) const override;
44 void putRawData( const void *buf, const typeID &id ) override;
45 void getRawData( void *buf, const typeID &id ) const override;
46 void setValuesByLocalID( size_t, const size_t *, const void *, const typeID & ) override;
47 void addValuesByLocalID( size_t, const size_t *, const void *, const typeID & ) override;
48 void getValuesByLocalID( size_t, const size_t *, void *, const typeID & ) const override;
49 void setGhostValuesByGlobalID( size_t, const size_t *, const void *, const typeID & ) override;
50 void addGhostValuesByGlobalID( size_t, const size_t *, const void *, const typeID & ) override;
51 void getGhostValuesByGlobalID( size_t, const size_t *, void *, const typeID & ) const override;
52 void
53 getGhostAddValuesByGlobalID( size_t, const size_t *, void *, const typeID & ) const override;
54 size_t getAllGhostValues( void *, const typeID & ) const override;
55 size_t getGhostSize() const override;
56 void fillGhosts( const Scalar & ) override;
57 void makeConsistent() override;
58 void makeConsistent( ScatterType t ) override;
60 void setUpdateStatus( UpdateState state ) override;
61 size_t getNumberOfComponents() const override;
62 std::shared_ptr<VectorData> getComponent( size_t i = 0 ) override;
63 std::shared_ptr<const VectorData> getComponent( size_t i = 0 ) const override;
64 bool hasContiguousData() const override { return ( numberOfDataBlocks() <= 1 ); }
65 std::vector<size_t> getLocalSizes() const override;
66
67public:
68 std::shared_ptr<CommunicationList> getCommunicationList() const override;
69 void setCommunicationList( std::shared_ptr<CommunicationList> comm ) override;
70 void dataChanged() override;
71 void setUpdateStatusPtr( std::shared_ptr<UpdateState> rhs ) override;
72 std::shared_ptr<UpdateState> getUpdateStatusPtr() const override;
73 bool containsGlobalElement( size_t ) const override;
74 void copyGhostValues( const VectorData &rhs ) override;
75 void setNoGhosts() override;
76 bool hasGhosts() const override;
77
78public: // Advanced virtual functions
86 uint64_t getDataID() const override;
87
91 void *getRawDataBlockAsVoid( size_t i ) override;
92
97 const void *getRawDataBlockAsVoid( size_t i ) const override;
98
102 size_t sizeofDataBlockType( size_t i ) const override;
103
107 typeID getType( size_t block ) const override;
108
112 void swapData( VectorData &rhs ) override;
113
116 std::shared_ptr<VectorData> cloneData( const std::string &name = "" ) const override;
117
119
120 void
121 dumpOwnedData( std::ostream &out, size_t GIDoffset = 0, size_t LIDoffset = 0 ) const override;
122 void dumpGhostedData( std::ostream &out, size_t offset = 0 ) const override;
123
125 const VectorData *getVectorData( size_t i ) const;
126
127 size_t getVectorDataSize() const { return d_data.size(); }
128
129 const AMP_MPI &getComm() const override { return d_comm; }
130
131 void assemble() override;
132
133
134public:
135 void receiveDataChanged() override { fireDataChange(); }
136
137 explicit MultiVectorData( const AMP::AMP_MPI &comm ) : d_comm( comm ) {}
138
140 const AMP::Discretization::DOFManager *manager = nullptr );
141
143 const std::vector<VectorData *> &data );
144
145public: // Write/read restart data
151 void registerChildObjects( AMP::IO::RestartManager *manager ) const override;
152
158 void writeRestart( int64_t fid ) const override;
159
166 MultiVectorData( int64_t fid, AMP::IO::RestartManager *manager );
167
168
169protected:
182 void partitionGlobalValues( const int num,
183 const size_t *indices,
184 const void *vals,
185 const size_t bytes,
186 std::vector<std::vector<size_t>> &out_indices,
187 std::vector<std::vector<std::byte>> &out_vals,
188 std::vector<std::vector<int>> *remap = nullptr ) const;
189
202 void partitionLocalValues( const int num,
203 const size_t *indices,
204 const void *vals,
205 const size_t bytes,
206 std::vector<std::vector<size_t>> &out_indices,
207 std::vector<std::vector<std::byte>> &out_vals,
208 std::vector<std::vector<int>> *remap = nullptr ) const;
209
210 // Get all ghost values
211 template<class TYPE>
212 size_t getAllGhostValues( TYPE * ) const;
213
214
215protected:
216 // Internal data
218 std::vector<VectorData *> d_data;
220 std::shared_ptr<UpdateState> d_UpdateState;
221};
222
223
224} // namespace AMP::LinearAlgebra
225
226
227#endif
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
A class to manage mapping multiple DOFs to global indicies.
Class to manage reading/writing restart data.
virtual void fireDataChange()
Notify all listeners of a data change event.
Interface for managing classes that need to know when managed data has changed.
A class used to hold vector data.
std::shared_ptr< UpdateState > getUpdateStatusPtr() const override
Return the current update state of this Vector.
std::shared_ptr< UpdateState > d_UpdateState
std::shared_ptr< CommunicationList > getCommunicationList() const override
Get the CommunicationList for this Vector.
void assemble() override
This method is used to implement the assemble interface of PETSc.
std::vector< size_t > getLocalSizes() const override
The local sizes on each rank.
void setUpdateStatus(UpdateState state) override
Sets the current update state of the Vector.
size_t sizeofDataBlockType(size_t i) const override
Return the result of sizeof(TYPE) for the given data block.
void dataChanged() override
Notify listeners that data has changed in this vector.
void setValuesByLocalID(size_t, const size_t *, const void *, const typeID &) override
Set values in the vector by their local offset.
virtual ~MultiVectorData()
Virtual destructor.
void putRawData(const void *buf, const typeID &id) override
Copy data into this vector.
AMP::Utilities::MemoryType getMemoryLocation() const override
returns the memory location for data
void copyGhostValues(const VectorData &rhs) override
Copy ghosted vlues to a vector.
void getValuesByLocalID(size_t, const size_t *, void *, const typeID &) const override
Get local values in the vector by their global offset.
bool hasGhosts() const override
Check if any entries "owned" by other cores are stored on this core.
const void * getRawDataBlockAsVoid(size_t i) const override
Return a pointer to a particular block of memory in the vector.
void registerChildObjects(AMP::IO::RestartManager *manager) const override
Register any child objects.
size_t getNumberOfComponents() const override
Return integer number of data components.
void makeConsistent(ScatterType t) override
Update shared values on entire communicator.
size_t numberOfDataBlocks() const override
Number of blocks of contiguous data in the Vector.
void setGhostValuesByGlobalID(size_t, const size_t *, const void *, const typeID &) override
Set ghost values using global identifier.
void partitionLocalValues(const int num, const size_t *indices, const void *vals, const size_t bytes, std::vector< std::vector< size_t > > &out_indices, std::vector< std::vector< std::byte > > &out_vals, std::vector< std::vector< int > > *remap=nullptr) const
void setUpdateStatusPtr(std::shared_ptr< UpdateState > rhs) override
Tie the current update state to another.
MultiVectorData(const AMP::AMP_MPI &comm)
void addValuesByLocalID(size_t, const size_t *, const void *, const typeID &) override
Add values to vector entities by their local offset.
void receiveDataChanged() override
The method called when a data change event occurs.
const VectorData * getVectorData(size_t i) const
void partitionGlobalValues(const int num, const size_t *indices, const void *vals, const size_t bytes, std::vector< std::vector< size_t > > &out_indices, std::vector< std::vector< std::byte > > &out_vals, std::vector< std::vector< int > > *remap=nullptr) const
void dumpOwnedData(std::ostream &out, size_t GIDoffset=0, size_t LIDoffset=0) const override
Write owned data to an std::ostream.
AMP::Discretization::multiDOFHelper d_dofMap
size_t getAllGhostValues(void *, const typeID &) const override
Get all ghost values in the vector.
void resetMultiVectorData(const AMP::Discretization::DOFManager *manager, const std::vector< VectorData * > &data)
void dumpGhostedData(std::ostream &out, size_t offset=0) const override
Write data owned by other processors to an std::ostream.
void setCommunicationList(std::shared_ptr< CommunicationList > comm) override
Set the CommunicationList for this Vector.
std::vector< VectorData * > d_data
size_t getGhostSize() const override
Number of entries "owned" by other cores stored on this core.
void addGhostValuesByGlobalID(size_t, const size_t *, const void *, const typeID &) override
Add shared values using global identifier.
size_t getAllGhostValues(TYPE *) const
MultiVectorData(int64_t fid, AMP::IO::RestartManager *manager)
Write restart data to file.
bool containsGlobalElement(size_t) const override
UpdateState getLocalUpdateStatus() const override
Return the current update state of the Vector.
void getRawData(void *buf, const typeID &id) const override
Copy data out of this vector.
uint64_t getDataID() const override
A unique id for the underlying data allocation.
MultiVectorData(VectorData *data, const AMP::Discretization::DOFManager *manager=nullptr)
size_t sizeOfDataBlock(size_t i=0) const override
Number of elements in a data block.
void getGhostValuesByGlobalID(size_t, const size_t *, void *, const typeID &) const override
Get ghost values in the vector by their global offset.
bool hasContiguousData() const override
returns whether all data for the vector on a single process is contiguous
void getGhostAddValuesByGlobalID(size_t, const size_t *, void *, const typeID &) const override
get ghosted values to add to off-proc elements
void fillGhosts(const Scalar &) override
Zero all ghost data (does not modify consistent status)
void setNoGhosts() override
Ensure this vector has no ghosts.
typeID getType(size_t block) const override
Return the typeid of the given block.
std::shared_ptr< VectorData > cloneData(const std::string &name="") const override
Clone the data.
void swapData(VectorData &rhs) override
Swap the data with another VectorData object.
const AMP_MPI & getComm() const override
Get the communicator.
void * getRawDataBlockAsVoid(size_t i) override
Return a pointer to a particular block of memory in the vector.
std::string VectorDataName() const override
Get the type name.
std::shared_ptr< const VectorData > getComponent(size_t i=0) const override
Number of elements in the ith component.
void makeConsistent() override
Update shared values on entire communicator.
std::shared_ptr< VectorData > getComponent(size_t i=0) override
Number of elements in the ith component.
VectorData * getVectorData(size_t i)
void writeRestart(int64_t fid) const override
Write restart data to file.
A class used to hold vector data.
Definition VectorData.h:38
Scalar is a class used to store a scalar variable that may be different types/precision.
Definition Scalar.h:21
UpdateState
The four states a Vector can be in.
Definition Variable.h:26
ScatterType
Flag to choose algorithm for makeConsistent.
Definition Variable.h:21
MemoryType
Enum to store pointer type.
Definition Memory.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:41.
Comments on this page