22 if (keep_data) {
p.CopyFrom(
data,
size); }
33 :
Vector(num_nodes*vdim_), vdim(vdim_), ordering(ordering_)
40 :
Vector(vec), vdim(vdim_), ordering(ordering_)
43 "Incompatible Vector size of " << vec.
Size() <<
" given vdim " <<
vdim);
50 const bool nvals_use_dev = nvals.
UseDevice();
53 const auto d_src =
Read(use_dev);
54 auto d_dest = nvals.
Write(use_dev);
56 const int vdim_ =
vdim;
64 d_dest[c] = d_src[i + nv*c];
68 d_dest[c] = d_src[c + vdim_*i];
73 if (!nvals_use_dev && use_dev)
79 if (!use_dev && nvals_use_dev)
88 "GetValuesRef only valid when ordering byVDIM.");
115 "GetComponentsRef only valid when ordering byNODES.");
127 const int vdim_ =
vdim;
128 const int ordering_ = (int)
ordering;
135 d_dest[i + c*nv] = d_src[c];
139 d_dest[c + i*vdim_] = d_src[c];
146 int vdim_temp =
vdim;
166 "Particle index " << i <<
168 MFEM_ASSERT(comp <
vdim,
169 "Component index " << comp <<
170 " is invalid for vector dimension " <<
vdim);
188 "Particle index " << i <<
190 MFEM_ASSERT(comp <
vdim,
191 "Component index " << comp <<
192 " is invalid for vector dimension " <<
vdim);
208 if (indices.
Size() == 0) {
return; }
213 "Particle index " << indices.
Max() <<
214 " is out-of-range for number of particles " <<
218 for (
int l = 0; l < indices.
Size(); l++)
220 for (
int vd = 0; vd <
vdim; vd++)
230 for (
int l = 0; l < indices.
Size(); l++)
232 for (
int vd = 0; vd <
vdim; vd++)
273 if (keep_data &&
ordering != ordering_)
280 const auto d_src = old_data.
Read(use_dev);
281 auto d_dest =
Write(use_dev);
283 const int vdim_ =
vdim;
284 const int size_ =
size;
292 d_dest[i + d * num_particles] = d_src[k];
299 int d = k / num_particles;
300 int i = k % num_particles;
301 d_dest[d + i * vdim_] = d_src[k];
312 if (num_vectors == old_nv)
318 if (num_vectors > old_nv)
329 if (!keep_data) {
return; }
339 Vector old_copy(old_slice);
341 const auto d_src = old_copy.
Read(use_dev);
342 const int vdim_ =
vdim;
346 [=] MFEM_HOST_DEVICE (
int k)
348 const int d = k / old_nv;
349 const int i = k % old_nv;
350 d_dest[i + d*num_vectors] = d_src[k];
354 const int diff = num_vectors - old_nv;
356 [=] MFEM_HOST_DEVICE (
int k)
358 const int d = k / diff;
359 const int i = k % diff;
360 d_dest[d * num_vectors + old_nv + i] = 0.0;
365 const int start_idx = old_nv *
vdim;
366 const int end_idx = num_vectors *
vdim;
367 const int diff = end_idx - start_idx;
370 d_dest[start_idx + i] = 0.0;
378 for (
int i = 0; i < rm_indices.
Size(); i++)
380 rm_indices[i] = old_nv - rm_indices.
Size() + i;
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void Reserve(int capacity)
Ensures that the allocated size is at least the given size.
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
static MemoryClass GetHostMemoryClass()
Get the current Host MemoryClass. This is the MemoryClass used by most MFEM host Memory objects.
static MemoryClass GetDeviceMemoryClass()
Get the current Device MemoryClass. This is the MemoryClass used by most MFEM device kernels to acces...
Class used by MFEM to store pointers to host and/or device memory.
int Capacity() const
Return the size of the allocated memory.
bool UseDevice() const
Read the internal device flag.
MemoryType GetMemoryType() const
Return a MemoryType that is currently valid. If both the host and the device pointers are currently v...
const T * Read(MemoryClass mc, int size) const
Get read-only access to the memory with the given MemoryClass.
void Delete()
Delete the owned pointers and reset the Memory object.
ParticleVector carries vector data (of a given vector dimension) for an arbitrary number of particles...
Ordering::Type ordering
Ordering of Vector data in ParticleVector.
void SetValues(int i, const Vector &nvals)
Set particle i 's data to nvals .
real_t & operator()(int i, int comp)
Reference to particle i component comp value.
void GetValues(int i, Vector &nvals) const
Get a copy of particle i 's data.
int vdim
Vector dimension.
int GetNumParticles() const
Get the number of particle data in the ParticleVector.
void DeleteParticles(const Array< int > &indices)
Remove particle data at indices.
void SetNumParticles(int num_vectors, bool keep_data=true)
Set the number of particle Vector data to be held by the ParticleVector, keeping existing data.
void SetOrdering(Ordering::Type ordering_, bool keep_data=true)
Set the ordering of the particle Vector data in ParticleVector.
void GetComponents(int vd, Vector &comp)
Get a copy of component vd for all particle vector data.
void SetVDim(int vdim_, bool keep_data=true)
Set the vector dimension of the ParticleVector.
void GetValuesRef(int i, Vector &nref)
For GetOrdering == Ordering::byVDIM, set nref to refer to particle i 's data.
void SetComponents(int vd, const Vector &comp)
Set component vd values for all particle data to comp .
void GetComponentsRef(int vd, Vector &nref)
For GetOrdering == Ordering::byNODES, set nref to refer to component vd 's data.
void GrowSize(int min_num_vectors, bool keep_data)
Re-allocate + copy memory. See Array::GrowSize.
virtual const real_t * HostRead() const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), false).
virtual const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
virtual real_t * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
Memory< real_t > & GetMemory()
Return a reference to the Memory object used by the Vector.
real_t & operator[](int i)
Access Vector entries using [] for 0-based indexing.
void DeleteAt(const Array< int > &indices)
virtual bool UseDevice() const
Return the device flag of the Memory object used by the Vector.
int Size() const
Returns the size of the vector.
virtual void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
void SetSize(int s)
Resize the vector to size s.
int Capacity() const
Return the size of the currently allocated data array.
Vector & operator=(const real_t *v)
Copy Size() entries from v.
virtual real_t * HostReadWrite()
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), false).
virtual real_t * Write(bool on_dev=true)
Shortcut for mfem::Write(vec.GetMemory(), vec.Size(), on_dev).
void MakeRef(Vector &base, int offset, int size)
Reset the Vector to be a reference to a sub-vector of base.
void forall_switch(bool use_dev, int N, lambda &&body)
real_t p(const Vector &x, real_t t)