Advanced Multi-Physics (AMP)
On-Line Documentation
GhostDataHelper.h
Go to the documentation of this file.
1#ifndef included_AMP_GhostDataHelper
2#define included_AMP_GhostDataHelper
3
4#include "AMP/vectors/CommunicationList.h"
5#include "AMP/vectors/data/VectorData.h"
6
7
8namespace AMP::LinearAlgebra {
9
10
11template<class TYPE = double, class Allocator = AMP::HostAllocator<void>>
13{
14public:
16 typename std::allocator_traits<Allocator>::template rebind_alloc<TYPE>;
18 typename std::allocator_traits<Allocator>::template rebind_alloc<size_t>;
19 using intAllocator_t = typename std::allocator_traits<Allocator>::template rebind_alloc<int>;
20
22 GhostDataHelper( std::shared_ptr<CommunicationList> );
24
25public: // Functions overloaded from VectorData
26 bool hasGhosts() const override { return d_ghostSize > 0; }
27 std::shared_ptr<CommunicationList> getCommunicationList() const override;
28 void setCommunicationList( std::shared_ptr<CommunicationList> comm ) override;
29 size_t getGhostSize() const override;
30 void fillGhosts( const Scalar & ) override;
31 void setNoGhosts() override;
32 bool containsGlobalElement( size_t ) const override;
33 void setGhostValuesByGlobalID( size_t num,
34 const size_t *indices,
35 const void *vals,
36 const typeID &id ) override;
37 void addGhostValuesByGlobalID( size_t num,
38 const size_t *indices,
39 const void *vals,
40 const typeID &id ) override;
41 void getGhostValuesByGlobalID( size_t num,
42 const size_t *indices,
43 void *vals,
44 const typeID &id ) const override;
46 const size_t *indices,
47 void *vals,
48 const typeID &id ) const;
50 const size_t *indices,
51 void *vals,
52 const typeID &id ) const override;
53 size_t getAllGhostValues( void *vals, const typeID &id ) const override;
55 void setUpdateStatus( UpdateState state ) override;
56 void setUpdateStatusPtr( std::shared_ptr<UpdateState> rhs ) override;
57 std::shared_ptr<UpdateState> getUpdateStatusPtr() const override;
58 void makeConsistent( ScatterType t ) override;
59 void dataChanged() override;
60 const AMP_MPI &getComm() const override;
61 void dumpGhostedData( std::ostream &out, size_t offset ) const override;
62 void copyGhostValues( const VectorData &rhs ) override;
63
69
70public: // Write/read restart data
71 void registerChildObjects( AMP::IO::RestartManager *manager ) const override;
72 void writeRestart( int64_t fid ) const override;
73 GhostDataHelper( int64_t fid, AMP::IO::RestartManager *manager );
74
75protected:
79 void allocateBuffers( size_t len );
80 virtual bool allGhostIndices( size_t N, const size_t *ndx ) const;
81
82protected:
83 std::shared_ptr<CommunicationList> d_CommList = nullptr;
84 std::shared_ptr<UpdateState> d_UpdateState = nullptr;
85
87 size_t d_ghostSize = 0;
88
90
91 std::vector<TYPE> d_Ghosts_h;
92 std::vector<TYPE> d_SendRecv_h;
93 std::vector<TYPE> d_AddBuffer_h;
94
95 TYPE *d_Ghosts = nullptr;
96 TYPE *d_AddBuffer = nullptr;
98 TYPE *d_SendRecv = nullptr;
99
100 // cache the receive dof list from CommunicationList
101 size_t *d_ReceiveDOFList = nullptr;
102
104 size_t d_numRemote = 0;
105
108
110 size_t *d_localRemote = nullptr;
111
112 // cache various communication buffers
113 int *d_sendSizes = nullptr;
114 int *d_recvSizes = nullptr;
115 int *d_sendDisplacements = nullptr;
116 int *d_recvDisplacements = nullptr;
117
118 // MPI communication tags
120};
121
122
123} // namespace AMP::LinearAlgebra
124
125#endif
Provides C++ wrapper around MPI routines.
Definition AMP_MPI.h:63
Class to manage reading/writing restart data.
size_t getGhostSize() const override
Number of entries "owned" by other cores stored on this core.
std::shared_ptr< UpdateState > getUpdateStatusPtr() const override
Return the current update state of this Vector.
std::shared_ptr< CommunicationList > getCommunicationList() const override
Get the CommunicationList for this Vector.
size_t d_numRemote
number of local ids that are remote
void getGhostValuesByGlobalID(size_t num, const size_t *indices, void *vals, const typeID &id) const override
Get ghost values in the vector by their global offset.
void setUpdateStatusPtr(std::shared_ptr< UpdateState > rhs) override
Tie the current update state to another.
void getGhostValuesByGlobalIDUnsorted(size_t num, const size_t *indices, void *vals, const typeID &id) const
void dataChanged() override
Notify listeners that data has changed in this vector.
GhostDataHelper(int64_t fid, AMP::IO::RestartManager *manager)
UpdateState getLocalUpdateStatus() const override
Return the current update state of the Vector.
size_t * d_localRemote
list of local ids that are remote
void dumpGhostedData(std::ostream &out, size_t offset) const override
Write data owned by other processors to an std::ostream.
void writeRestart(int64_t fid) const override
Write restart data to file.
typename std::allocator_traits< Allocator >::template rebind_alloc< size_t > sizetAllocator_t
void copyGhostValues(const VectorData &rhs) override
Copy ghosted vlues to a vector.
typename std::allocator_traits< Allocator >::template rebind_alloc< TYPE > ScalarAllocator_t
const AMP_MPI & getComm() const override
Get the communicator.
bool hasGhosts() const override
Check if any entries "owned" by other cores are stored on this core.
void setCommunicationList(std::shared_ptr< CommunicationList > comm) override
Set the CommunicationList for this Vector.
bool containsGlobalElement(size_t) const override
void registerChildObjects(AMP::IO::RestartManager *manager) const override
Register any child objects.
size_t d_ghostSize
size/length of ghost and add buffers
TYPE * d_SendRecv
Buffers for sending/receiving data.
void fillGhosts(const Scalar &) override
Zero all ghost data (does not modify consistent status)
std::shared_ptr< CommunicationList > d_CommList
typename std::allocator_traits< Allocator >::template rebind_alloc< int > intAllocator_t
std::shared_ptr< UpdateState > d_UpdateState
void setUpdateStatus(UpdateState state) override
Sets the current update state of the Vector.
void setNoGhosts() override
Ensure this vector has no ghosts.
virtual bool allGhostIndices(size_t N, const size_t *ndx) const
void makeConsistent(ScatterType t) override
Update shared values on entire communicator.
size_t getAllGhostValues(void *vals, const typeID &id) const override
Get all ghost values in the vector.
GhostDataHelper(std::shared_ptr< CommunicationList >)
void addGhostValuesByGlobalID(size_t num, const size_t *indices, const void *vals, const typeID &id) override
Add shared values using global identifier.
void getGhostAddValuesByGlobalID(size_t num, const size_t *indices, void *vals, const typeID &id) const override
get ghosted values to add to off-proc elements
void setGhostValuesByGlobalID(size_t num, const size_t *indices, const void *vals, const typeID &id) override
Set ghost values using global identifier.
A class used to hold vector data.
Definition VectorData.h:38
void getGhostAddValuesByGlobalID(size_t num, const size_t *indices, TYPE *vals) const
get ghosted values to add to off-proc elements
void addGhostValuesByGlobalID(size_t num, const size_t *indices, const TYPE *vals)
Add shared values using global identifier.
void setGhostValuesByGlobalID(size_t num, const size_t *indices, const TYPE *vals)
Set ghost values using global identifier.
void getGhostValuesByGlobalID(size_t num, const size_t *indices, TYPE *vals) const
Get ghost values in the vector by their global offset.
virtual void makeConsistent()
Update shared values on entire communicator.
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
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