# PhasicFlow: src/phasicFlow/containers/VectorHD/VectorSingle.cpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

VectorSingle.cpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::uint32 pFlow::VectorSingle<T,MemorySpace>::changeSize
(
uint32 n,
bool withInit
)
{
if(n > this->capacity() )
{
uint32 newCap = evalCapacity(n);
changeCapacity(newCap, withInit);
}
return setSize(n);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::uint32 pFlow::VectorSingle<T,MemorySpace>::changeCapacitySize
(
uint32 actualCap,
uint32 n,
bool withInit
)
{
changeCapacity(actualCap, withInit);
return setSize(n);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::changeCapacity
(
uint32 actualCap,
bool withInit
)
{
if(withInit)
{
resizeInit(view_, actualCap);
}
else
{
resizeNoInit(view_, actualCap);
}
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::uint32 pFlow::VectorSingle<T,MemorySpace>::reallocateCapacitySize
(
uint32 cap,
uint32 s
)
{
reallocNoInit(view_, cap);
return setSize(s);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::uint32 pFlow::VectorSingle<T,MemorySpace>::setSize(uint32 n)
{
auto os = size_;
size_ = n;
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle()
:
VectorSingle("VectorSingle")
{}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle(const word& name)
:
size_(0),
view_(name,2)
{}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle
(
const word& name,
uint32 n
)
:
size_(n),
view_(name, evalCapacity(n))
{}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle
(
const word& name,
uint32 n,
const T& val
)
:
VectorSingle(name, n)
{
assign(n, val);
}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle
(
const word& name,
uint32 cap,
uint32 n,
RESERVE
)
:
size_(n),
view_(name, cap)
{}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle
(
const word& name,
const std::vector<T> & src
)
:
VectorSingle(name)
{
assign(src);
}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle
(
const word& name,
const std::vector<T> & src,
uint32 cap
)
:
VectorSingle(name)
{
assign(src, cap);
}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle
(
const VectorSingle& src
)
:
VectorSingle(src.name(), src)
{}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle
(
const word& name,
const VectorSingle& src
)
:
VectorSingle(name, src.capacity(), src.size(), RESERVE())
{
copy(deviceView(), src.deviceView());
}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::VectorSingle
(
const word& name,
const ViewType1D<T, MemorySpace>& src
)
:
VectorSingle(name, src.size(), src.size(), RESERVE())
{
copy(deviceView(), src);
}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>&
pFlow::VectorSingle<T,MemorySpace>::operator = (const VectorSingle& rhs)
{
if(&rhs == this) return *this;
VectorSingle temp(rhs);
size_ = temp.size();
view_ = temp.view_;
return *this;
}
template<typename T, typename MemorySpace>
pFlow::VectorSingle<T,MemorySpace>::~VectorSingle()
{
view_ = viewType();
size_ = 0;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::uniquePtr<pFlow::VectorSingle<T,MemorySpace>>
pFlow::VectorSingle<T,MemorySpace>::clone() const
{
return makeUnique<VectorSingle>( this->name(), *this);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::VectorSingle<T,MemorySpace>&
pFlow::VectorSingle<T,MemorySpace>::VectorField()
{
return *this;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
const pFlow::VectorSingle<T,MemorySpace>&
pFlow::VectorSingle<T,MemorySpace>::VectorField()const
{
return *this;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
const auto& pFlow::VectorSingle<T,MemorySpace>::deviceViewAll() const
{
return view_;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
auto& pFlow::VectorSingle<T,MemorySpace>::deviceViewAll()
{
return view_;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
auto pFlow::VectorSingle<T,MemorySpace>::deviceView()const
{
return Kokkos::subview(
view_,
Kokkos::make_pair(0u,static_cast< uint32 >(size_)));
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
auto pFlow::VectorSingle<T,MemorySpace>::hostViewAll()const
{
auto hView = Kokkos::create_mirror_view(view_);
copy(hView, view_);
return hView;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
auto pFlow::VectorSingle<T,MemorySpace>::hostView()const
{
auto hView = Kokkos::create_mirror_view(deviceView());
copy(hView, deviceView());
return hView;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::word pFlow::VectorSingle<T,MemorySpace>::name()const
{
return view_.label();
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::uint32 pFlow::VectorSingle<T,MemorySpace>::size()const
{
return size_;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
pFlow::uint32 pFlow::VectorSingle<T,MemorySpace>::capacity()const
{
return view_.extent(0);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
bool pFlow::VectorSingle<T,MemorySpace>::empty()const
{
return size_==0;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::reserve(uint32 cap)
{
if(cap == capacity() ) return;
changeCapacity(cap);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::reallocate(uint32 cap)
{
reallocateCapacitySize(cap, 0);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::reallocate
(
uint32 cap,
uint32 newSize
)
{
reallocateCapacitySize(cap, newSize);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::resize(uint32 n)
{
changeSize(n);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::resize(uint32 n, const T& val)
{
assign(n, val);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::clear()
{
size_ = 0;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::fill(const T& val)
{
if(empty())return;
pFlow::fill(view_, rangeU32(0 ,size_) ,val);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::fill
(
rangeU32 r,
const T& val
)
{
changeSize(r.end());
pFlow::fill(view_, r, val);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::assign
(
size_t n,
const T& val
)
{
if( n > capacity() )
{
reallocateCapacitySize(evalCapacity(n), n);
}
else
{
setSize(n);
}
this->fill(val);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::assign
(
const std::vector<T>& src,
uint32 cap
)
{
// make sure that vector has enough capacity
uint32 newCap = max(static_cast< uint32 >(src.size()), cap);
uint32 srcSize = src.size();
if(newCap != capacity())
{
reallocateCapacitySize(newCap, srcSize);
}
else
{
changeSize(srcSize);
}
// - unmanaged view in the host
hostViewType1D<const T> temp(src.data(), srcSize );
copy(deviceView(), temp);
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::assign
(
const std::vector<T>& src
)
{
assign(src, this->capacity());
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::assignFromHost(const VectorTypeHost& src)
{
uint32 srcSize = src.size();
uint32 srcCap = src.capacity();
if(srcCap != capacity())
{
reallocateCapacitySize(srcCap, srcSize);
}
else
{
changeSize(srcSize);
}
copy(deviceView(), src.hostView());
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::assign
(
const VectorType& src,
bool srcCapacity
)
{
uint32 srcSize = src.size();
uint32 srcCap = src.capacity();
if(srcCapacity && srcCap != capacity())
{
reallocateCapacitySize(srcCap, srcSize);
}
else
{
changeSize(srcSize);
}
copy(deviceView(), src.deviceView());
}
template<typename T, typename MemorySpace>
template<typename MSpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T,MemorySpace>::assignFromDevice(
const VectorSingle<T, MSpace>& src,
bool srcCapacity
)
{
uint32 srcSize = src.size();
uint32 srcCap = src.capacity();
if(srcCapacity && srcCap != capacity()){
reallocateCapacitySize(srcCap, srcSize);
}
else {
changeSize(srcSize);
}
copy(deviceView(), src.deviceView());
}
template <typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T, MemorySpace>::append(const ViewType1D<T,MemorySpace>& appVec)
{
uint32 appSize = appVec.size();
if(appSize == 0) return;
uint32 oldS = size();
uint32 newSize = oldS + appSize;
changeSize(newSize);
auto appendView = Kokkos::subview(
view_,
Kokkos::make_pair<uint32>(oldS, newSize));
copy(appendView, appVec);
}
template <typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T, MemorySpace>::append
(
const std::vector<T> &appVec
)
{
if(appVec.empty())return;
auto srcSize = appVec.size();
uint32 oldSize = size();
uint32 newSize = srcSize + oldSize;
changeSize(newSize);
hostViewType1D<const T> temp(appVec.data(), srcSize );
auto dest = Kokkos::subview(view_, Kokkos::make_pair<uint32>(oldSize,newSize));
copy(dest, temp);
}
template <typename T, typename MemorySpace>
INLINE_FUNCTION_H
void pFlow::VectorSingle<T, MemorySpace>::append
(
const VectorType& appVec
)
{
uint32 appSize = appVec.size();
if(appSize == 0) return;
uint32 oldS = size();
uint32 newSize = oldS + appSize;
changeSize(newSize);
auto appendView = Kokkos::subview(
view_,
Kokkos::make_pair<uint32>(oldS, newSize));
copy(appendView, appVec.deviceView());
}
template <typename T, typename MemorySpace>
INLINE_FUNCTION_H auto pFlow::VectorSingle<T, MemorySpace>::getSpan()
{
return span<T>(view_.data(), size());
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
auto pFlow::VectorSingle<T,MemorySpace>::getSpan()const
{
return span<T>(const_cast<T*>(view_.data()), this->size());
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
bool pFlow::VectorSingle<T,MemorySpace>::insertSetElement(const uint32IndexContainer& indices, const T& val)
{
if(indices.empty()) return true;
auto maxInd = indices.max();
if(this->empty() || maxInd > size()-1 )
{
resize(maxInd+1);
}
using policy = Kokkos::RangePolicy<execution_space,Kokkos::IndexType<uint32>>;
if constexpr( isDeviceAccessible_ )
{
auto v = view_;
auto ind = indices.deviceView();
Kokkos::parallel_for(
"VectorSingle::insertSetElement",
policy(0,indices.size()),
LAMBDA_HD(uint32 i){
v[ind[i]]= val;
});
Kokkos::fence();
}
else
{
auto v = view_;
auto ind = indices.hostView();
Kokkos::parallel_for(
"VectorSingle::insertSetElement",
policy(0,indices.size()),
LAMBDA_HD(uint32 i){
v[ind[i]]= val;
});
Kokkos::fence();
}
return true;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
bool pFlow::VectorSingle<T,MemorySpace>::insertSetElement
(
const uint32IndexContainer& indices,
const std::vector<T>& vals
)
{
if(indices.empty())return true;
if(indices.size() != vals.size())return false;
auto maxInd = indices.max();
if(this->empty() || maxInd > size()-1 )
{
resize(maxInd+1);
}
using policy = Kokkos::RangePolicy<execution_space,Kokkos::IndexType<uint32>>;
hostViewType1D<const T> hVals( vals.data(), vals.size());
if constexpr( isDeviceAccessible_ )
{
deviceViewType1D<T> dVals("dVals", indices.size());
copy(dVals, hVals);
auto dVec = view_;
auto ind = indices.deviceView();
Kokkos::parallel_for(
"VectorSingle::insertSetElement",
policy(0,indices.size()), LAMBDA_HD(uint32 i){
dVec(ind(i))= dVals(i);});
Kokkos::fence();
}
else
{
auto dVec = view_;
auto ind = indices.hostView();
Kokkos::parallel_for(
"VectorSingle::insertSetElement",
policy(0,indices.size()), LAMBDA_HD(uint32 i){
dVec(ind(i))= hVals(i);});
Kokkos::fence();
}
return true;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
bool pFlow::VectorSingle<T,MemorySpace>::insertSetElement
(
const uint32IndexContainer& indices,
const ViewType1D<T, memory_space> vals
)
{
if(indices.empty())return true;
if(indices.size() != vals.size())return false;
auto maxInd = indices.max();
if(this->empty() || maxInd > size()-1 )
{
resize(maxInd+1);
}
using policy = Kokkos::RangePolicy<
execution_space,
Kokkos::IndexType<uint32>>;
if constexpr( isDeviceAccessible_ )
{
auto dVec = view_;
auto dVals = vals;
auto ind = indices.deviceView();
Kokkos::parallel_for(
"VectorSingle::insertSetElement",
policy(0,indices.size()), LAMBDA_HD(uint32 i){
dVec(ind(i))= dVals(i);});
Kokkos::fence();
}
else
{
auto dVec = view_;
auto hVals = vals;
auto ind = indices.hostView();
Kokkos::parallel_for(
"VectorSingle::insertSetElement",
policy(0,indices.size()), LAMBDA_HD(uint32 i){
dVec(ind(i))= hVals(i);});
Kokkos::fence();
}
return true;
}
template<typename T, typename MemorySpace>
INLINE_FUNCTION_H
bool pFlow::VectorSingle<T,MemorySpace>::reorderItems(const uint32IndexContainer& indices)
{
if(indices.size() == 0)
{
setSize(0);
return true;
}
auto maxInd = indices.max();
if(maxInd >= this->size())
{
fatalErrorInFunction<<"In reordering the VectorSingle ("
<< this->name()<< ") maximum index ("<< maxInd <<
") exceeds the size of the vector (" << this->size()<<")"<<endl;
return false;
}
uint32 newSize = indices.size();
viewType sortedView(this->name(), newSize);
using policy = Kokkos::RangePolicy< execution_space,Kokkos::IndexType<uint32>>;
if constexpr( isDeviceAccessible_)
{
auto d_indices = indices.deviceView();
auto d_view = view_;
Kokkos::parallel_for
(
"VectorSingle::sortItems",
policy(0,newSize),
LAMBDA_HD(uint32 i)
{
sortedView(i) = d_view(d_indices(i));
}
);
Kokkos::fence();
}
else
{
auto h_indices = indices.hostView();
auto d_view = view_;
Kokkos::parallel_for
(
"VectorSingle::sortItems",
policy(0,newSize),
LAMBDA_HD(uint32 i)
{
sortedView(i) = d_view(h_indices(i));
}
);
Kokkos::fence();
}
setSize(newSize);
copy(deviceView(), sortedView);
return true;
}
pFlow::span
Definition: span.hpp:31
pFlow::VectorSingle::fill
INLINE_FUNCTION_H void fill(const T &val)
Fill the range [0,size) with val.
Definition: VectorSingle.cpp:365
pFlow::VectorSingle::reserve
INLINE_FUNCTION_H void reserve(uint32 cap)
Reserve capacity for vector Preserve the content.
Definition: VectorSingle.cpp:318
pFlow::VectorSingle::resize
INLINE_FUNCTION_H void resize(uint32 n)
Resize the vector and preserve the content.
Definition: VectorSingle.cpp:344
pFlow::resizeNoInit
INLINE_FUNCTION_H void resizeNoInit(ViewType1D< Type, Properties... > &view, uint32 newLen)
Definition: KokkosUtilities.hpp:151
pFlow::VectorSingle::append
INLINE_FUNCTION_H void append(const ViewType1D< T, MemorySpace > &appVec)
Definition: VectorSingle.cpp:506
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
pFlow::empty
Definition: empty.hpp:30
pFlow::VectorSingle::VectorSingle
VectorSingle()
Empty vector.
Definition: VectorSingle.cpp:95
pFlow::VectorSingle::assignFromDevice
INLINE_FUNCTION_H void assignFromDevice(const VectorSingle< T, MSpace > &src, bool srcCapacity=true)
Definition: VectorSingle.cpp:487
pFlow::indexContainer::max
INLINE_FUNCTION_HD IndexType max() const
Max value of indices.
Definition: indexContainer.hpp:196
pFlow::Range::end
INLINE_FUNCTION_HD T & end()
End.
Definition: Range.hpp:101
pFlow::algorithms::KOKKOS::max
INLINE_FUNCTION_H Type max(const Type *first, uint32 numElems)
Definition: kokkosAlgorithms.hpp:104
pFlow::copy
INLINE_FUNCTION_H void copy(const ViewType1D< dType, dProperties... > &dst, const ViewType1D< sType, sProperties... > &src)
Definition: ViewAlgorithms.hpp:234
pFlow::VectorSingle::reallocate
INLINE_FUNCTION_H void reallocate(uint32 cap)
Reallocate memory to new cap and set size to 0.
Definition: VectorSingle.cpp:326
pFlow::VectorSingle::clear
INLINE_FUNCTION_H void clear()
Clear the vector, but keep the allocated memory unchanged.
Definition: VectorSingle.cpp:358
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::VectorSingle::setSize
INLINE_FUNCTION_H uint32 setSize(uint32 n)
Definition: VectorSingle.cpp:84
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::reallocNoInit
INLINE_FUNCTION_H void reallocNoInit(ViewType1D< Type, Properties... > &view, uint32 len)
Definition: KokkosUtilities.hpp:64
pFlow::VectorSingle::clone
INLINE_FUNCTION_H uniquePtr< VectorSingle > clone() const
Clone as a uniquePtr (perform deep copy)
Definition: VectorSingle.cpp:225
pFlow::VectorSingle::changeCapacitySize
INLINE_FUNCTION_H uint32 changeCapacitySize(uint32 actualCap, uint32 n, bool withInit=false)
Change the size and capacity of Vector.
Definition: VectorSingle.cpp:40
pFlow::rangeU32
Range< uint32 > rangeU32
Definition: Range.hpp:143
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::VectorSingle::empty
INLINE_FUNCTION_H bool empty() const
If vector is empty.
Definition: VectorSingle.cpp:311
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
policy
Kokkos::RangePolicy< pFlow::DefaultExecutionSpace, Kokkos::Schedule< Kokkos::Static >, Kokkos::IndexType< pFlow::uint32 > > policy
Definition: grainParticlesKernels.cpp:25
pFlow::VectorSingle< uint32, HostSpace >::execution_space
typename viewType::execution_space execution_space
Definition: VectorSingle.hpp:76
pFlow::VectorSingle::reorderItems
INLINE_FUNCTION_H bool reorderItems(const uint32IndexContainer &indices)
Definition: VectorSingle.cpp:738
pFlow::VectorSingle::deviceView
INLINE_FUNCTION_H auto deviceView() const
Device view range [0, size)
Definition: VectorSingle.cpp:263
pFlow::VectorSingle::name
INLINE_FUNCTION_H word name() const
Name of the vector.
Definition: VectorSingle.cpp:290
pFlow::VectorSingle::changeCapacity
INLINE_FUNCTION_H void changeCapacity(uint32 actualCap, bool withInit=false)
Definition: VectorSingle.cpp:53
RESERVE
Definition: Vector.hpp:40
pFlow::indexContainer::hostView
const HostViewType & hostView() const
Return Host veiw.
Definition: indexContainer.hpp:202
pFlow::VectorSingle::assignFromHost
INLINE_FUNCTION_H void assignFromHost(const VectorTypeHost &src)
Assign source vector from host side.
Definition: VectorSingle.cpp:442
pFlow::VectorSingle::~VectorSingle
~VectorSingle()
Descructor This may not destroy the underlying memory, sice view is shared_ptr and maybe referenced b...
Definition: VectorSingle.cpp:216
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::VectorSingle::getSpan
INLINE_FUNCTION_H auto getSpan()
Definition: VectorSingle.cpp:569
pFlow::VectorSingle::changeSize
INLINE_FUNCTION_H uint32 changeSize(uint32 n, bool withInit=false)
Change size to n and preserve the conetent if realloc occurs
Definition: VectorSingle.cpp:24
pFlow::VectorSingle::hostView
INLINE_FUNCTION_H auto hostView() const
Return a view accessible on Host in range [0,size)
Definition: VectorSingle.cpp:281
fill
void fill(Vector< T, Allocator > &vec, const T &val)
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::indexContainer::empty
INLINE_FUNCTION_HD bool empty() const
If the container empty.
Definition: indexContainer.hpp:182
pFlow::resizeInit
INLINE_FUNCTION_H void resizeInit(ViewType1D< Type, Properties... > &view, uint32 newLen)
Definition: KokkosUtilities.hpp:144
pFlow::VectorSingle
Definition: VectorSingle.hpp:44
pFlow::Range< uint32 >
pFlow::VectorSingle::deviceViewAll
INLINE_FUNCTION_H auto & deviceViewAll()
Device view range [0,capcity)
Definition: VectorSingle.cpp:249
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
1D veiw as a vector
Definition: KokkosTypes.hpp:93
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
1D array (vector with host memeory space)
Definition: KokkosTypes.hpp:136
pFlow::VectorSingle::hostViewAll
INLINE_FUNCTION_H auto hostViewAll() const
Return a view accessible on Host in range [0,capacity)
Definition: VectorSingle.cpp:272
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::VectorSingle::assign
INLINE_FUNCTION_H void assign(size_t n, const T &val)
Change size of the vector and assign val to vector and.
Definition: VectorSingle.cpp:386
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:58
pFlow::VectorSingle::capacity
INLINE_FUNCTION_H uint32 capacity() const
Definition: VectorSingle.cpp:304
pFlow::VectorSingle::VectorField
INLINE_FUNCTION_H VectorType & VectorField()
Return *this.
Definition: VectorSingle.cpp:234
pFlow::indexContainer::size
INLINE_FUNCTION_HD auto size() const
Size.
Definition: indexContainer.hpp:175
pFlow::VectorSingle::reallocateCapacitySize
INLINE_FUNCTION_H uint32 reallocateCapacitySize(uint32 cap, uint32 s)
Definition: VectorSingle.cpp:73
pFlow::VectorSingle::operator=
VectorSingle & operator=(const VectorSingle &rhs)
Copy assignment (perform deep copy from rhs to *this)
Definition: VectorSingle.cpp:204
pFlow::VectorSingle::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const uint32IndexContainer &indices, const T &val)
Definition: VectorSingle.cpp:583
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39
pFlow::VectorSingle::size
INLINE_FUNCTION_H uint32 size() const
Size of the vector.
Definition: VectorSingle.cpp:297
pFlow::indexContainer::deviceView
const DeviceViewType & deviceView() const
Return Device view.
Definition: indexContainer.hpp:208
pFlow::VectorSingle< uint32, HostSpace >::viewType
ViewType1D< uint32, HostSpace > viewType
Definition: VectorSingle.hpp:70
pFlow::VectorSingle::view_
viewType view_
view of the vector
Definition: VectorSingle.hpp:86