12 #include "../general/array.hpp"
39 numBlocks(bOffsets.Size()-1),
40 blockOffsets(bOffsets.GetData())
47 :
Vector(bOffsets.Last(), mt),
48 numBlocks(bOffsets.Size()-1),
49 blockOffsets(bOffsets.GetData())
58 numBlocks(v.numBlocks),
59 blockOffsets(v.blockOffsets)
67 Vector(data, bOffsets.Last()),
68 numBlocks(bOffsets.Size()-1),
69 blockOffsets(bOffsets.GetData())
77 numBlocks(bOffsets.Size()-1),
78 blockOffsets(bOffsets.GetData())
133 if (i < 0) {
return; }
134 if (
blocks[i].
Size() != bOffsets[i+1] - bOffsets[i]) {
break; }
136 "invalid blocks[" << i <<
']');
159 mfem_error(
"Number of Blocks don't match in BlockVector::operator=");
166 mfem_error(
"Size of Blocks don't match in BlockVector::operator=");
~BlockVector()
Destructor.
int Size() const
Return the logical size of the array.
void NewDataAndSize(double *d, int s)
Set the Vector data and size, deleting the old data, if owned.
void GetBlockView(int i, Vector &blockView)
Get the i-th vector in the block.
A class to handle Vectors in a block fashion.
void SetSize(int s)
Resize the vector to size s.
BlockVector()
empty constructor
const int * blockOffsets
Offset for each block start. (length numBlocks+1)
T * GetData()
Returns the data.
int Size() const
Returns the size of the vector.
void SyncToBlocks() const
Synchronize the memory location flags (i.e. the memory validity flags) of the big/monolithic block-ve...
void Update(double *data, const Array< int > &bOffsets)
Update method.
void SyncAliasMemory(const Vector &v) const
Update the alias memory location of the vector to match v.
double * GetData() const
Return a pointer to the beginning of the Vector data.
MemoryType GetMemoryType() const
Return a MemoryType that is currently valid. If both the host and the device pointers are currently v...
Vector & operator=(const double *v)
Copy Size() entries from v.
bool OwnsData() const
Read the Vector data (host pointer) ownership flag.
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
int numBlocks
Number of blocks in the blockVector.
void SyncMemory(const Vector &v) const
Update the memory location of the vector to match v.
BlockVector & operator=(const BlockVector &original)
Assignment operator. this and original must have the same block structure.
MemoryType
Memory types supported by MFEM.
void Destroy()
Destroy a vector.
void SyncFromBlocks() const
Synchronize the memory location flags (i.e. the memory validity flags) of the big/monolithic block-ve...
T & Last()
Return the last element in the array.
void MakeRef(Vector &base, int offset, int size)
Reset the Vector to be a reference to a sub-vector of base.
Vector * blocks
array of Vector objects used to extract blocks without allocating memory.