1#ifndef included_AMP_VectorData
2#define included_AMP_VectorData
4#include "AMP/utils/AMP_MPI.h"
5#include "AMP/utils/enable_shared_from_this.h"
6#include "AMP/utils/typeid.h"
7#include "AMP/vectors/Scalar.h"
8#include "AMP/vectors/Variable.h"
9#include "AMP/vectors/data/DataChangeFirer.h"
23class CommunicationList;
24template<
typename TYPE>
25class VectorDataIterator;
110 virtual std::shared_ptr<const VectorData>
getComponent(
size_t i = 0 )
const;
288 const size_t *indices,
314 const size_t *indices,
328 const size_t *indices,
330 const typeID &
id )
const = 0;
353 const size_t *indices,
355 const typeID &
id )
const = 0;
410 virtual std::shared_ptr<VectorData>
cloneData(
const std::string &name =
"" )
const = 0;
435 dumpOwnedData( std::ostream &out,
size_t GIDoffset = 0,
size_t LIDoffset = 0 )
const;
534 print( std::ostream &os,
const std::string &name =
"A",
const std::string &prefix =
"" )
const;
547 template<
class TYPE =
double>
551 template<
class TYPE =
double>
555 template<
class TYPE =
double>
568 template<
class TYPE =
double>
572 template<
class TYPE =
double>
576 template<
class TYPE =
double>
584 template<
typename RETURN_TYPE>
592 template<
typename RETURN_TYPE>
598 template<
typename TYPE>
604 template<
typename TYPE>
692#include "AMP/vectors/data/VectorData.inline.h"
Provides C++ wrapper around MPI routines.
Class to manage reading/writing restart data.
Interface for managing classes that need to know when managed data has changed.
Iterator for local data in a vector.
A class used to hold vector data.
virtual void makeConsistent(ScatterType t)=0
Update shared values on entire communicator.
virtual void dataChanged()=0
Notify listeners that data has changed in this vector.
virtual void addValuesByLocalID(size_t num, const size_t *indices, const void *vals, const typeID &id)=0
Add values to vector entities by their local offset.
virtual std::shared_ptr< CommunicationList > getCommunicationList() const =0
Get the CommunicationList for this Vector.
virtual void getGhostAddValuesByGlobalID(size_t num, const size_t *indices, void *vals, const typeID &id) const =0
get ghosted values to add to off-proc elements
void getGhostAddValuesByGlobalID(size_t num, const size_t *indices, TYPE *vals) const
get ghosted values to add to off-proc elements
virtual const void * getRawDataBlockAsVoid(size_t i) const =0
Return a pointer to a particular block of memory in the vector.
virtual void setUpdateStatus(UpdateState state)=0
Sets the current update state of the Vector.
virtual size_t getGhostSize() const =0
Number of entries "owned" by other cores stored on this core.
virtual bool containsGlobalElement(size_t GID) const =0
virtual void setValuesByLocalID(size_t num, const size_t *indices, const void *vals, const typeID &id)=0
Set values in the vector by their local offset.
virtual void swapData(VectorData &rhs)=0
Swap the data with another VectorData object.
virtual void dumpGhostedData(std::ostream &out, size_t offset=0) const =0
Write data owned by other processors to an std::ostream.
void getRawData(TYPE *buf) const
Copy data out of this vector.
virtual typeID getType(size_t block) const =0
Return the typeid of the given block.
virtual void copyGhostValues(const VectorData &rhs)=0
Copy ghosted vlues to a vector.
virtual UpdateState getLocalUpdateStatus() const =0
Return the current update state of the Vector.
virtual void setUpdateStatusPtr(std::shared_ptr< UpdateState > rhs)=0
Tie the current update state to another.
virtual uint64_t getDataID() const =0
A unique id for the underlying data allocation.
RETURN_TYPE * getRawDataBlock(size_t i=0)
Obtain a particular contiguous block of data cast to RETURN_TYPE.
virtual std::vector< size_t > getLocalSizes() const
The local sizes on each rank.
virtual bool hasGhosts() const =0
Check if any entries "owned" by other cores are stored on this core.
virtual void fillGhosts(const Scalar &x)=0
Zero all ghost data (does not modify consistent status)
VectorData(const VectorData &)=delete
uint64_t getID() const
Get a unique id hash for the vector.
virtual bool isAnAliasOf(const VectorData &rhs) const
Check if the two VectorData objects are alias of each other.
bool isBlockType(size_t i=0) const
Check if the data is of the given type.
size_t getAllGhostValues(TYPE *vals) const
Get all ghost values.
virtual bool hasContiguousData() const
returns whether all data for the vector on a single process is contiguous
virtual void print(std::ostream &os, const std::string &name="A", const std::string &prefix="") const
VectorDataIterator< TYPE > end()
Return an iterator to the end of the data.
virtual std::shared_ptr< const VectorData > getComponent(size_t i=0) const
Number of elements in the ith component.
virtual void setGhostValuesByGlobalID(size_t num, const size_t *indices, const void *vals, const typeID &id)=0
Set ghost values using global identifier.
virtual size_t getAllGhostValues(void *vals, const typeID &id) const =0
Get all ghost values in the vector.
size_t getLocalSize() const
Number of elements "owned" by this core.
virtual void dumpOwnedData(std::ostream &out, size_t GIDoffset=0, size_t LIDoffset=0) const
Write owned data to an std::ostream.
VectorData(int64_t fid, AMP::IO::RestartManager *manager)
virtual size_t sizeofDataBlockType(size_t i) const =0
Return the result of sizeof(TYPE) for the given data block.
VectorDataIterator< const TYPE > begin() const
Return an iterator to the beginning of the data.
virtual std::shared_ptr< VectorData > cloneData(const std::string &name="") const =0
Clone the data.
void getValuesByGlobalID(size_t num, const size_t *indices, TYPE *vals) const
get values in the vector by their local offset
virtual void setCommunicationList(std::shared_ptr< CommunicationList > comm)=0
Set the CommunicationList for this Vector.
virtual void registerChildObjects(AMP::IO::RestartManager *manager) const
Register any child objects.
VectorData()=default
Default constructors.
virtual void getRawData(void *buf, const typeID &id) const =0
Copy data out of this vector.
virtual void setNoGhosts()
Ensure this vector has no ghosts.
void getValuesByLocalID(size_t num, const size_t *indices, TYPE *vals) const
Get local values in the vector by their global offset.
virtual const AMP_MPI & getComm() const =0
Get the communicator.
virtual void * getRawDataBlockAsVoid(size_t i)=0
Return a pointer to a particular block of memory in the vector.
void setValuesByGlobalID(size_t num, const size_t *indices, const TYPE *vals)
Set owned or shared values using global identifier.
virtual void writeRestart(int64_t fid) const
Write restart data to file.
bool isType() const
Check if the data is of the given type.
void putRawData(const TYPE *buf)
Copy data into this vector.
virtual std::string VectorDataName() const =0
Get the type name.
virtual void getValuesByLocalID(size_t num, const size_t *indices, void *vals, const typeID &id) const =0
Get local values in the vector by their global offset.
virtual std::shared_ptr< VectorData > getComponent(size_t i=0)
Number of elements in the ith component.
size_t d_globalSize
Number of local values.
size_t getLocalStartID() const
get local start id core.
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.
virtual size_t numberOfDataBlocks() const =0
Number of blocks of contiguous data in the Vector.
void setValuesByLocalID(size_t num, const size_t *indices, const TYPE *vals)
Set values in the vector by their local offset.
VectorDataIterator< TYPE > begin()
Return an iterator to the beginning of the data.
virtual std::shared_ptr< UpdateState > getUpdateStatusPtr() const =0
Return the current update state of this Vector.
virtual void addGhostValuesByGlobalID(size_t num, const size_t *indices, const void *vals, const typeID &id)=0
Add shared values using global identifier.
virtual AMP::Utilities::MemoryType getMemoryLocation() const
returns the memory location for data
virtual void putRawData(const void *buf, const typeID &id)=0
Copy data into this vector.
virtual size_t getNumberOfComponents() const
Return integer number of data components.
void addValuesByGlobalID(size_t num, const size_t *indices, const TYPE *vals)
Add owned or shared values using global identifier.
virtual void getGhostValuesByGlobalID(size_t num, const size_t *indices, void *vals, const typeID &id) const =0
Get ghost values in the vector by their global offset.
size_t d_localStart
Number of global values.
virtual void reset()
reset the vector data object
virtual ~VectorData()
Virtual destructor.
void addValuesByLocalID(size_t num, const size_t *indices, const TYPE *vals)
Add values to vector entities by their local offset.
VectorDataIterator< const TYPE > constEnd() const
Return an iterator to the end of the data.
virtual void assemble()
This method is used to implement the assemble interface of PETSc.
VectorDataIterator< const TYPE > end() const
Return an iterator to the end of the data.
void getGhostValuesByGlobalID(size_t num, const size_t *indices, TYPE *vals) const
Get ghost values in the vector by their global offset.
virtual size_t sizeOfDataBlock(size_t i=0) const =0
Number of elements in a data block.
UpdateState getGlobalUpdateStatus() const
Return the current update state of the Vector.
size_t getGlobalSize() const
Number of total entries in this vector across all cores.
const RETURN_TYPE * getRawDataBlock(size_t i=0) const
Obtain a particular contiguous block of data cast to RETURN_TYPE.
virtual void makeConsistent()
Update shared values on entire communicator.
bool isType(const typeID &id, size_t block) const
Is the data of the given type.
VectorDataIterator< const TYPE > constBegin() const
Return an iterator to the beginning of the data.
A class used to hold vector operations.
Scalar is a class used to store a scalar variable that may be different types/precision.
Enhancement of std::enable_shared_from_this.
UpdateState
The four states a Vector can be in.
ScatterType
Flag to choose algorithm for makeConsistent.
MemoryType
Enum to store pointer type.
Class to store type info.