# PhasicFlow: src/phasicFlow/containers/VectorHD/VectorDual.hpp Source File

VectorDual.hpp
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.
-----------------------------------------------------------------------------*/
#ifndef __VectorDual_hpp__
#define __VectorDual_hpp__
#include "globalSettings.hpp"
#include "types.hpp"
#include "typeInfo.hpp"
#include "Vector.hpp"
#include "streams.hpp"
#include "KokkosTypes.hpp"
#include "ViewAlgorithms.hpp"
#ifndef __RESERVE__
#define __RESERVE__
struct RESERVE{};
#endif
namespace pFlow
{
template<typename T, typename MemorySpace>
class VectorDual;
template<typename T, typename MemorySpace=void>
class VectorDual
{
public:
using iterator = T*;
using constIterator = const T*;
using reference = T&;
using constReference = const T&;
using valueType = T;
using pointer = T*;
using constPointer = const T*;
using VectorType = VectorDual<T, MemorySpace>;
// dualViewType (view of data host and device)
using dualViewType = Kokkos::DualView<T*, MemorySpace>;
// mirror scape of device view
using hostMirrorSpace = typename dualViewType::host_mirror_space;
// - viewType of data on device
using deviceViewType = typename dualViewType::t_dev;
// - viewType of data on host
using hostViewType = typename dualViewType::t_host;
using deviceType = typename deviceViewType::device_type;
using hostType = typename hostViewType::device_type;
// to be consistent
using viewType = dualViewType;
// we assume device view is the primary side
using memory_space = typename viewType::memory_space;
// we assume device view is the primary side
using execution_space = typename deviceType::execution_space;
protected:
size_t size_ = 0;
size_t capacity_ = 0;
dualViewType dualView_;
mutable deviceViewType deviceSubView_;
mutable hostViewType hostSubView_;
mutable bool subViewsUpdated_ = false;
static const inline real growthFactor_ = vectorGrowthFactor__;
// is host accepsibble from device prespective
static constexpr bool isHostAccessible_ =
Kokkos::SpaceAccessibility<execution_space,Kokkos::HostSpace>::accessible;
// host-device name
static inline const word hdName__ =
word(hostType::memory_space::name())+
word(deviceType::memory_space::name());
constexpr static inline const char* memoerySpaceName()
{
return hdName__.data();
}
static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
{
return static_cast<size_t>(n*growthFactor_+1);
}
// use actualCap = true only for reserve
INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
{
if(n >= capacity_ )
{
if(actualCap)
capacity_ = n;
else
capacity_ = evalCapacity(n);
dualView_.resize(capacity_);
subViewsUpdated_ = false;
syncViews();
}
if(!actualCap)
{
setSize(n);
}
}
INLINE_FUNCTION_H void setSize(size_t n) {
size_ = n;
subViewsUpdated_ = false;
}
// - seems strange, since we actually are updating values,
// but in fact the content of object is actually const.
INLINE_FUNCTION_H void updateSubViews()const
{
if(subViewsUpdated_)return;
hostSubView_ = Kokkos::subview(dualView_.h_view, Kokkos::make_pair(0,int(size_)));
deviceSubView_ = Kokkos::subview(dualView_.d_view, Kokkos::make_pair(0,int(size_)));
subViewsUpdated_ = true;
}
public:
// - type info
TypeInfoTemplateNV2("VectorDual", T, memoerySpaceName());
// - empty
VectorDual()
:
VectorDual("VectorDual")
{
}
VectorDual(const word& name)
:
size_(0),
capacity_(2),
dualView_(name,capacity_)
{
changeSize(size_);
}
// - with size n
VectorDual(size_t n)
:
VectorDual("VectorDual",n)
{}
// - with name and size n
VectorDual(const word& name, size_t n)
:
size_(n),
capacity_(evalCapacity(n)),
dualView_(name, capacity_)
{
changeSize(size_);
}
// with size and value, apply on both views
VectorDual(size_t n, const T& val)
:
VectorDual("VectorDual", n , val)
{}
// with name, size and value, apply on both views
VectorDual(const word& name, size_t n, const T& val)
:
VectorDual(name, n)
{
assign(n, val);
}
VectorDual(size_t cap, size_t n, RESERVE )
:
VectorDual("VectorDual", cap, n, RESERVE())
{}
VectorDual(const word& name, size_t cap, size_t n, RESERVE )
:
VectorDual(name)
{
reallocate(cap);
setSize(n);
}
VectorDual(const Vector<T> & src)
:
VectorDual("VectorDual", src)
{}
VectorDual(const word& name, const Vector<T> & src)
:
VectorDual(name)
{
assign(src);
}
// - copy construct (perform deep copy)
// preserve the sync status of the views
VectorDual(const VectorDual& src)
:
VectorDual(src.name(), src.capacity(), src.size(), RESERVE())
{
// transfer the sync status
if(src.hostRequiresSync())
{
modifyOnDevice();
}else if( src.deviceRequiresSync())
{
modifyOnHost();
}else
{
dualView_.clear_sync_state();
}
Kokkos::deep_copy(hostVector(), src.hostVector());
Kokkos::deep_copy(deviceVector(), src.deviceVector());
}
// copy construct with new name
VectorDual(const word& name, const VectorDual& src)
:
VectorDual(name, src.capacity(), src.size(), RESERVE())
{
// transfer the sync status
if(src.hostRequiresSync())
{
modifyOnDevice();
}else if( src.deviceRequiresSync())
{
modifyOnHost();
}else
{
dualView_.clear_sync_state();
}
Kokkos::deep_copy(hostVector(), src.hostVector());
Kokkos::deep_copy(deviceVector(), src.deviceVector());
}
// - copy assignment
VectorDual& operator = (const VectorDual& rhs)
{
if(&rhs == this) return *this;
VectorDual temp(rhs);
capacity_ = temp.capacity();
setSize( temp.size());
dualView_ = temp.dualView_;
return *this;
}
// no move construct
VectorDual(VectorDual&&) = delete;
// no move assignment
VectorDual& operator= (VectorDual&&) = delete;
// - clone as a uniquePtr
INLINE_FUNCTION_H uniquePtr<VectorDual> clone() const
{
return makeUnique<VectorDual>(*this);
}
// - clone as a pointer
INLINE_FUNCTION_H VectorDual* clonePtr()const
{
return new VectorDual(*this);
}
// - return *this
INLINE_FUNCTION_H
VectorType& VectorField()
{
return *this;
}
// - return *this
INLINE_FUNCTION_H
const VectorType& VectorField()const
{
return *this;
}
// - Device vector
INLINE_FUNCTION_H deviceViewType& deviceVectorAll(){
return dualView_.d_view;
}
// - Device vector
INLINE_FUNCTION_H const deviceViewType& deviceVectorAll() const {
return dualView_.d_view;
}
// - Host vector
INLINE_FUNCTION_H hostViewType& hostVectorAll(){
return dualView_.h_view;
}
// - Host Vector
INLINE_FUNCTION_H const hostViewType& hostVectorAll() const {
return dualView_.h_view;
}
INLINE_FUNCTION_H deviceViewType& deviceVector(){
updateSubViews();
return deviceSubView_;
}
INLINE_FUNCTION_H const deviceViewType& deviceVector() const{
updateSubViews();
return deviceSubView_;
}
INLINE_FUNCTION_H hostViewType& hostVector(){
updateSubViews();
return hostSubView_;
}
INLINE_FUNCTION_H const hostViewType& hostVector()const{
updateSubViews();
return hostSubView_;
}
INLINE_FUNCTION_H
hostViewType hostVector(int32 start, int32 end)const
{
return Kokkos::subview(dualView_.h_view, Kokkos::make_pair(start,end));
}
INLINE_FUNCTION_H
deviceViewType deviceVector(int32 start, int32 end)const
{
return Kokkos::subview(dualView_.d_view, Kokkos::make_pair(start,end));
}
INLINE_FUNCTION_H const word name()const
{
return dualView_.h_view.label();
}
INLINE_FUNCTION_H size_t size()const
{
return size_;
}
INLINE_FUNCTION_H size_t capacity()const
{
return capacity_;
}
INLINE_FUNCTION_H bool empty()const
{
return size_==0;
}
// - reserve capacity for vector
// preserve the content
INLINE_FUNCTION_H void reserve(size_t cap)
{
changeSize(cap, true);
}
// resize the views
// no syncronization occurs
INLINE_FUNCTION_H void resize(size_t n)
{
changeSize(n);
}
INLINE_FUNCTION_H void reallocate(size_t cap)
{
capacity_ = cap;
setSize(0);
dualView_.realloc(cap);
dualView_.clear_sync_state();
}
INLINE_FUNCTION_H void resizeSync(size_t n)
{
changeSize(n);
syncViews();
}
// resize the view and assign value to the most recent view (most updated)
// no syncronization occurs
INLINE_FUNCTION_H void resize(size_t n, const T& val) {
assign(n, val);
}
// resize the view and assign value to the most recent view (most updated)
// and syncronize both views
INLINE_FUNCTION_H void resizeSync(size_t n, const T& val){
assign(n,val);
syncViews();
}
INLINE_FUNCTION_H void clear() {
setSize(0);
dualView_.clear_sync_state();
}
// - fill both views with val
INLINE_FUNCTION_H void fill(const T& val)
{
if(empty())return;
Kokkos::deep_copy(deviceVector(),val);
Kokkos::deep_copy(hostVector(),val);
dualView_.clear_sync_state();
}
INLINE_FUNCTION_H void fillHost(const T& val)
{
if(empty())return;
Kokkos::deep_copy(hostVector(),val);
modifyOnHost();
}
INLINE_FUNCTION_H void fillDevice(const T& val)
{
if(empty())return;
Kokkos::deep_copy(deviceVector(),val);
modifyOnDevice();
}
// - host calls only
// - assign n first elements to val
// resize views
// assign value to both sides (device&host)
FUNCTION_H void assign(size_t n, const T& val)
{
if( n>= capacity_ )
{
reallocate(evalCapacity(n));
}
setSize(n);
fill(val);
}
// - host calls only
// - assign source vector
// resize views
// assign to both sides (device&host)
FUNCTION_H void assign(const Vector<T>& src)
{
auto srcSize = src.size();
if( capacity() < srcSize )
{
reallocate( evalCapacity(srcSize) );
}
setSize(0);
dualView_.clear_sync_state();
for( auto& elem:src )
{
this->push_back(elem);
}
syncViews();
}
// TODO: this part may be implemented in parallel
bool deleteElement
(
const Vector<label>& indices
)
{
if( indices.size() == 0 )return true;
if( *(indices.end()-1) >= size() ) return false;
auto oldSize = this->size();
auto nextInd = indices.begin();
label j = indices[0];
for(label i=indices[0]; i < oldSize; ++i)
{
if( nextInd != indices.end() && i == *nextInd )
{
++nextInd;
}
else
{
dualView_.h_view[j] = dualView_.h_view[i];
++j;
}
}
setSize( oldSize - indices.size() );
modifyOnHost();
// TODO: deep_copy should be changed to a range shorter than the vector size
syncViews();
return true;
}
INLINE_FUNCTION_H
bool insertSetElement(const int32IndexContainer& indices, const T& val)
{
if(indices.size() == 0)return true;
auto maxInd = indices.max();
if(this->empty() || maxInd > size()-1 )
{
resize(maxInd+1);
}
fillSelected(hostVectorAll(), indices.hostView(), indices.size(), val);
auto dIndices = indices.deviceView();
auto dVals = deviceVectorAll();
Kokkos::parallel_for(
"fillSelected",
indices.size(),
LAMBDA_HD(int32 i){
dVals[dIndices[i]]= val;
});
Kokkos::fence();
return true;
}
template<typename side=HostSide>
INLINE_FUNCTION_H
bool insertSetElement
(
const int32IndexContainer& indices,
const Vector<T>& vals
)
{
if(indices.size() == 0)return true;
if(indices.size() != vals.size())return false;
auto maxInd = indices.max();
auto minInd = indices.min();
if(this->empty() || maxInd > size()-1 )
{
resize(maxInd+1);
}
if constexpr (std::is_same<side,HostSide>::value )
{
hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
//fillSelected(hostVector(), indices.hostView(), hVecVals, indices.size());
pFlow::algorithms::KOKKOS::fillSelected<T, int32, DefaultHostExecutionSpace>(
hostVectorAll().data(),
indices.hostView().data(),
hVecVals.data(),
indices.size());
modifyOnHost();
syncViews(minInd, maxInd+1);
}
else
{
pFlow::hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
pFlow::deviceViewType1D<T> dVecVals("dVecVals", indices.size());
Kokkos::deep_copy(dVecVals, hVecVals);
//fillSelected(deviceVector(), indices.deviceView(), dVecVals, indices.size());
pFlow::algorithms::KOKKOS::fillSelected<T, int32, execution_space>(
deviceVectorAll().data(),
indices.deviceView().data(),
dVecVals.data(),
indices.size());
modifyOnDevice();
// TODO: deep_copy should be changed to a range shorter than the vector size
syncViews(minInd, maxInd+1);
}
return true;
}
template<typename side=HostSide>
INLINE_FUNCTION_H
bool insertSetElement(const Vector<int32>& indices, const T& val)
{
if(indices.size() == 0)return true;
auto maxInd = max(indices);
auto minInd = min(indices);
if(this->empty() || maxInd > size()-1 )
{
resize(maxInd+1);
}
if constexpr (std::is_same<side,HostSide>::value )
{
hostViewType1D<int32> hVecInd( const_cast< int32*>(indices.data()), indices.size());
fillSelected( hostVectorAll(), hVecInd, indices.size(), val);
modifyOnHost();
syncViews(minInd, maxInd+1);
return true;
}
else
{
hostViewType1D<int32> hVecInd( const_cast< int32*>(indices.data()), indices.size());
deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
Kokkos::deep_copy(dVecInd, hVecInd);
fillSelected(deviceVectorAll(), dVecInd, indices.size(), val);
modifyOnDevice();
// TODO: deep_copy should be changed to a range shorter than the vector size
syncViews(minInd, maxInd+1);
return true;
}
return false;
}
template<typename side=HostSide>
INLINE_FUNCTION_H
bool insertSetElement
(
const Vector<int32>& indices,
const Vector<T>& vals
)
{
if(indices.size() == 0)return true;
if(indices.size() != vals.size())return false;
auto maxInd = max(indices);
auto minInd = min(indices);
if(this->empty() || maxInd > size()-1 )
{
resize(maxInd+1);
}
if constexpr (std::is_same<side,HostSide>::value )
{
hostViewType1D<int32> hVecInd( const_cast< int32*>(indices.data()), indices.size());
hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
fillSelected(hostVectorAll(), hVecInd, hVecVals, indices.size());
modifyOnHost();
syncViews(minInd, maxInd+1);
}
else
{
pFlow::hostViewType1D<int32> hVecInd( const_cast< int32*>(indices.data()), indices.size());
pFlow::deviceViewType1D<int32> dVecInd("dVecInd", indices.size());
pFlow::hostViewType1D<T> hVecVals( const_cast<T*>(vals.data()), vals.size());
pFlow::deviceViewType1D<T> dVecVals("dVecVals", indices.size());
Kokkos::deep_copy(dVecVals, hVecVals);
Kokkos::deep_copy(dVecInd, hVecInd);
fillSelected(deviceVectorAll(), dVecInd, dVecVals, indices.size());
modifyOnDevice();
// TODO: deep_copy should be changed to a range shorter than the vector size
syncViews(minInd, maxInd+1);
}
return true;
}
// push a new element at the end
// resize if necessary
// first sycn to host side
void push_back(const T& val)
{
syncToHost();
modifyOnHost();
if(size_ == capacity_) changeSize(capacity_);
data()[size_++] = val;
subViewsUpdated_ = false;
}
INLINE_FUNCTION_H pointer data(){
return dualView_.h_view.data();
}
INLINE_FUNCTION_H constPointer data()const{
return dualView_.h_view.data();
}
// host call
// returns begin iterator
INLINE_FUNCTION_H iterator begin(){
return data();
}
// host call
// returns begin iterator
INLINE_FUNCTION_H constIterator begin()const {
return data();
}
// host call
// returns end iterator
INLINE_FUNCTION_H iterator end(){
return size_ > 0 ? data() + size_: data();
}
// host call
// returns end iterator
INLINE_FUNCTION_H constIterator end()const{
return size_ > 0 ? data() + size_: data();
}
INLINE_FUNCTION_H reference operator[](label i){
return dualView_.h_view[i];
}
INLINE_FUNCTION_H constReference operator[](label i)const{
return dualView_.h_view[i];
}
INLINE_FUNCTION_H void modifyOnHost()
{
dualView_.modify_host();
}
INLINE_FUNCTION_H void modifyOnDevice()
{
dualView_.modify_device();
}
INLINE_FUNCTION_H bool hostRequiresSync()const
{
return dualView_.template need_sync<hostType>();
}
INLINE_FUNCTION_H bool deviceRequiresSync()const
{
return dualView_.template need_sync<deviceType>();
}
INLINE_FUNCTION_H bool areViewsSimilar()const
{
return std::is_same<hostType,deviceType>::value;
}
// - copy from host to device
// set both views to updated
INLINE_FUNCTION_H void copyHostToDevice()
{
if(empty())return;
Kokkos::deep_copy(deviceVector(), hostVector());
dualView_.clear_sync_state();
}
INLINE_FUNCTION_H
void copyHostToDevice(int32 start, int32 end, bool setUpdated = true)
{
if(empty())return;
Kokkos::deep_copy(deviceVector(start, end), hostVector(start, end));
if(setUpdated)
dualView_.clear_sync_state();
}
// - copy from device to host
// set both views to updated
INLINE_FUNCTION_H void copyDeviceToHost()
{
if(empty())return;
Kokkos::deep_copy(hostVector(), deviceVector());
dualView_.clear_sync_state();
}
INLINE_FUNCTION_H
void copyDeviceToHost(int32 start, int32 end, bool setUpdated = true)
{
if(empty())return;
Kokkos::deep_copy(hostVector(start, end), deviceVector(start, end));
if(setUpdated)
dualView_.clear_sync_state();
}
INLINE_FUNCTION_H void syncToHost()
{
if(hostRequiresSync())
{
copyDeviceToHost();
}
}
INLINE_FUNCTION_H void syncToDevice()
{
if(deviceRequiresSync())
{
copyHostToDevice();
}
}
// - check which side requires update and
// apply the update
INLINE_FUNCTION_H void syncViews()
{
if(deviceRequiresSync())
{
copyHostToDevice();
}
else if(hostRequiresSync())
{
copyDeviceToHost();
}
}
INLINE_FUNCTION_H void syncViews(int32 start, int32 end)
{
if(deviceRequiresSync())
{
copyHostToDevice(start, end);
}
else if(hostRequiresSync())
{
copyDeviceToHost(start, end);
}
}
FUNCTION_H
bool read(iIstream& is)
{
Vector<T> vecFromFile;
if( !vecFromFile.read(is) ) return false;
this->assign(vecFromFile);
return true;
}
FUNCTION_H
bool write(iOstream& os) const
{
// since the object should be const, no way to syncViews
Vector<T, noConstructAllocator<T>> vecToFile(this->size());
hostViewType1D<T> mirror(vecToFile.data(), vecToFile.size());
if(hostRequiresSync()) // device is updated
{
//const auto dVec = Kokkos::subview(dualView_.d_view, Kokkos::make_pair(0,int(size_)));
Kokkos::deep_copy(mirror,deviceVector());
}
else // either host is updated or both sides are syncronized
{
//const auto hVec = Kokkos::subview(dualView_.h_view, Kokkos::make_pair(0,int(size_)));
Kokkos::deep_copy(mirror,hostVector());
}
return vecToFile.write(os);
}
};
template<typename T, typename memory_space>
inline iIstream& operator >> (iIstream & is, VectorDual<T, memory_space> & ivec )
{
if( !ivec.read(is) )
{
ioErrorInFile (is.name(), is.lineNumber());
fatalExit;
}
return is;
}
template<typename T, typename memory_space>
inline iOstream& operator << (iOstream& os, const VectorDual<T, memory_space>& ovec )
{
if( !ovec.write(os) )
{
ioErrorInFile(os.name(), os.lineNumber());
fatalExit;
}
return os;
}
} // pFlow
#include "VectorDualAlgorithms.hpp"
#endif //__VectorDual_hpp__
pFlow::vectorGrowthFactor__
const double vectorGrowthFactor__
Definition: globalSettings.hpp:29
pFlow::VectorDual::empty
INLINE_FUNCTION_H bool empty() const
Definition: VectorDual.hpp:401
pFlow::Vector::read
bool read(iIstream &is)
Definition: Vector.hpp:378
pFlow::VectorDual::resizeSync
INLINE_FUNCTION_H void resizeSync(size_t n, const T &val)
Definition: VectorDual.hpp:443
pFlow::VectorDual< int8 >::hostType
typename hostViewType::device_type hostType
Definition: VectorDual.hpp:81
pFlow::VectorDual< int8 >::deviceViewType
typename dualViewType::t_dev deviceViewType
Definition: VectorDual.hpp:74
pFlow::VectorDual< int8 >::iterator
int8 * iterator
Definition: VectorDual.hpp:51
pFlow::VectorDual::hostVector
const INLINE_FUNCTION_H hostViewType & hostVector() const
Definition: VectorDual.hpp:369
pFlow::VectorDual::VectorDual
VectorDual(size_t n)
Definition: VectorDual.hpp:189
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews()
Definition: VectorDual.hpp:875
pFlow::VectorDual::begin
INLINE_FUNCTION_H iterator begin()
Definition: VectorDual.hpp:763
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
VectorDualAlgorithms.hpp
pFlow::VectorDual::hostVectorAll
INLINE_FUNCTION_H hostViewType & hostVectorAll()
Definition: VectorDual.hpp:345
pFlow::VectorDual< int8 >::memory_space
typename viewType::memory_space memory_space
Definition: VectorDual.hpp:87
pFlow::VectorDual::VectorDual
VectorDual(size_t cap, size_t n, RESERVE)
Definition: VectorDual.hpp:218
pFlow::VectorDual::clonePtr
INLINE_FUNCTION_H VectorDual * clonePtr() const
Definition: VectorDual.hpp:313
pFlow::VectorDual::hostVector
INLINE_FUNCTION_H hostViewType hostVector(int32 start, int32 end) const
Definition: VectorDual.hpp:375
pFlow::indexContainer::max
INLINE_FUNCTION_HD IndexType max() const
Definition: indexContainer.hpp:125
pFlow::VectorDual::fill
INLINE_FUNCTION_H void fill(const T &val)
Definition: VectorDual.hpp:455
pFlow::VectorDual::syncToDevice
INLINE_FUNCTION_H void syncToDevice()
Definition: VectorDual.hpp:866
types.hpp
pFlow::VectorDual::deviceVector
INLINE_FUNCTION_H deviceViewType deviceVector(int32 start, int32 end) const
Definition: VectorDual.hpp:381
pFlow::VectorDual::resize
INLINE_FUNCTION_H void resize(size_t n)
Definition: VectorDual.hpp:414
pFlow::VectorDual::VectorDual
VectorDual(const VectorDual &src)
Definition: VectorDual.hpp:246
pFlow::VectorDual::push_back
void push_back(const T &val)
Definition: VectorDual.hpp:741
pFlow::VectorDual::VectorDual
VectorDual(const word &name, const Vector< T > &src)
Definition: VectorDual.hpp:237
pFlow::VectorDual::clone
INLINE_FUNCTION_H uniquePtr< VectorDual > clone() const
Definition: VectorDual.hpp:307
pFlow::VectorDual::hdName__
static const word hdName__
Definition: VectorDual.hpp:113
pFlow::VectorDual::data
INLINE_FUNCTION_H pointer data()
Definition: VectorDual.hpp:753
pFlow::VectorDual::operator[]
INLINE_FUNCTION_H reference operator[](label i)
Definition: VectorDual.hpp:785
ViewAlgorithms.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
KokkosTypes.hpp
pFlow::VectorDual::copyDeviceToHost
INLINE_FUNCTION_H void copyDeviceToHost(int32 start, int32 end, bool setUpdated=true)
Definition: VectorDual.hpp:850
pFlow::VectorDual::assign
FUNCTION_H void assign(const Vector< T > &src)
Definition: VectorDual.hpp:496
pFlow::VectorDual::assign
FUNCTION_H void assign(size_t n, const T &val)
Definition: VectorDual.hpp:481
pFlow::indexContainer::size
INLINE_FUNCTION_HD size_t size() const
Definition: indexContainer.hpp:107
pFlow::Vector::size
auto size() const
Definition: Vector.hpp:299
pFlow::VectorDual::name
const INLINE_FUNCTION_H word name() const
Definition: VectorDual.hpp:386
pFlow::VectorDual::capacity
INLINE_FUNCTION_H size_t capacity() const
Definition: VectorDual.hpp:396
pFlow::VectorDual::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const Vector< int32 > &indices, const T &val)
Definition: VectorDual.hpp:641
pFlow::VectorDual::reserve
INLINE_FUNCTION_H void reserve(size_t cap)
Definition: VectorDual.hpp:408
pFlow::VectorDual< int8 >::deviceType
typename deviceViewType::device_type deviceType
Definition: VectorDual.hpp:79
pFlow::VectorDual::modifyOnHost
INLINE_FUNCTION_H void modifyOnHost()
Definition: VectorDual.hpp:796
pFlow::VectorDual::read
FUNCTION_H bool read(iIstream &is)
Definition: VectorDual.hpp:901
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
Definition: KokkosTypes.hpp:93
pFlow::VectorDual::syncToHost
INLINE_FUNCTION_H void syncToHost()
Definition: VectorDual.hpp:858
pFlow::VectorDual::deviceVectorAll
const INLINE_FUNCTION_H deviceViewType & deviceVectorAll() const
Definition: VectorDual.hpp:340
pFlow
Definition: demComponent.hpp:28
pFlow::VectorDual::operator=
VectorDual & operator=(const VectorDual &rhs)
Definition: VectorDual.hpp:288
pFlow::VectorDual::hostVectorAll
const INLINE_FUNCTION_H hostViewType & hostVectorAll() const
Definition: VectorDual.hpp:350
pFlow::VectorDual::modifyOnDevice
INLINE_FUNCTION_H void modifyOnDevice()
Definition: VectorDual.hpp:801
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::VectorDual::VectorDual
VectorDual(const word &name, size_t n, const T &val)
Definition: VectorDual.hpp:211
pFlow::VectorDual< int8 >::dualViewType
Kokkos::DualView< int8 *, void > dualViewType
Definition: VectorDual.hpp:68
pFlow::VectorDual::deviceSubView_
deviceViewType deviceSubView_
Definition: VectorDual.hpp:100
pFlow::indexContainer::min
INLINE_FUNCTION_HD IndexType min() const
Definition: indexContainer.hpp:119
RESERVE
Definition: Vector.hpp:38
pFlow::VectorDual::deviceVectorAll
INLINE_FUNCTION_H deviceViewType & deviceVectorAll()
Definition: VectorDual.hpp:335
pFlow::VectorDual::operator[]
INLINE_FUNCTION_H constReference operator[](label i) const
Definition: VectorDual.hpp:789
pFlow::VectorDual< int8 >::pointer
int8 * pointer
Definition: VectorDual.hpp:61
pFlow::VectorDual::VectorDual
VectorDual(const word &name, size_t n)
Definition: VectorDual.hpp:195
pFlow::VectorDual::VectorDual
VectorDual(const word &name, const VectorDual &src)
Definition: VectorDual.hpp:267
pFlow::VectorDual::end
INLINE_FUNCTION_H iterator end()
Definition: VectorDual.hpp:775
n
int32 n
Definition: NBSCrossLoop.hpp:24
pFlow::VectorDual::resize
INLINE_FUNCTION_H void resize(size_t n, const T &val)
Definition: VectorDual.hpp:437
pFlow::VectorDual::setSize
INLINE_FUNCTION_H void setSize(size_t n)
Definition: VectorDual.hpp:149
globalSettings.hpp
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::indexContainer::hostView
const HostViewType & hostView() const
Definition: indexContainer.hpp:143
pFlow::VectorDual< int8 >::execution_space
typename deviceType::execution_space execution_space
Definition: VectorDual.hpp:90
pFlow::VectorDual::clear
INLINE_FUNCTION_H void clear()
Definition: VectorDual.hpp:448
pFlow::VectorDual::updateSubViews
INLINE_FUNCTION_H void updateSubViews() const
Definition: VectorDual.hpp:156
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::VectorDual
Definition: VectorDual.hpp:43
pFlow::VectorDual::copyHostToDevice
INLINE_FUNCTION_H void copyHostToDevice()
Definition: VectorDual.hpp:823
pFlow::VectorDual< int8 >::valueType
int8 valueType
Definition: VectorDual.hpp:59
pFlow::VectorDual::hostVector
INLINE_FUNCTION_H hostViewType & hostVector()
Definition: VectorDual.hpp:364
pFlow::VectorDual::syncViews
INLINE_FUNCTION_H void syncViews(int32 start, int32 end)
Definition: VectorDual.hpp:887
pFlow::VectorDual::deviceVector
const INLINE_FUNCTION_H deviceViewType & deviceVector() const
Definition: VectorDual.hpp:359
pFlow::VectorDual< int8 >::reference
int8 & reference
Definition: VectorDual.hpp:55
pFlow::VectorDual::copyDeviceToHost
INLINE_FUNCTION_H void copyDeviceToHost()
Definition: VectorDual.hpp:842
pFlow::VectorDual::changeSize
INLINE_FUNCTION_H void changeSize(size_t n, bool actualCap=false)
Definition: VectorDual.hpp:129
pFlow::VectorDual::VectorField
INLINE_FUNCTION_H VectorType & VectorField()
Definition: VectorDual.hpp:322
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::VectorDual::VectorField
const INLINE_FUNCTION_H VectorType & VectorField() const
Definition: VectorDual.hpp:329
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::VectorDual::capacity_
size_t capacity_
Definition: VectorDual.hpp:96
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::VectorDual::evalCapacity
static INLINE_FUNCTION_H size_t evalCapacity(size_t n)
Definition: VectorDual.hpp:123
pFlow::VectorDual::VectorDual
VectorDual(const word &name)
Definition: VectorDual.hpp:179
pFlow::VectorDual::reallocate
INLINE_FUNCTION_H void reallocate(size_t cap)
Definition: VectorDual.hpp:419
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
pFlow::VectorDual::deviceRequiresSync
INLINE_FUNCTION_H bool deviceRequiresSync() const
Definition: VectorDual.hpp:811
streams.hpp
pFlow::max
T max(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:164
pFlow::VectorDual< int8 >::constIterator
const int8 * constIterator
Definition: VectorDual.hpp:53
pFlow::VectorDual< int8 >::constReference
const int8 & constReference
Definition: VectorDual.hpp:57
pFlow::VectorDual::areViewsSimilar
INLINE_FUNCTION_H bool areViewsSimilar() const
Definition: VectorDual.hpp:816
pFlow::VectorDual::resizeSync
INLINE_FUNCTION_H void resizeSync(size_t n)
Definition: VectorDual.hpp:429
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
Definition: KokkosTypes.hpp:104
pFlow::Vector::write
bool write(iOstream &os) const
Definition: Vector.hpp:383
pFlow::VectorDual::VectorDual
VectorDual(const Vector< T > &src)
Definition: VectorDual.hpp:232
pFlow::VectorDual::VectorDual
VectorDual(const word &name, size_t cap, size_t n, RESERVE)
Definition: VectorDual.hpp:223
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::VectorDual::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: VectorDual.hpp:118
LAMBDA_HD
#define LAMBDA_HD
Definition: pFlowMacros.hpp:54
pFlow::VectorDual::copyHostToDevice
INLINE_FUNCTION_H void copyHostToDevice(int32 start, int32 end, bool setUpdated=true)
Definition: VectorDual.hpp:832
pFlow::VectorDual::deviceVector
INLINE_FUNCTION_H deviceViewType & deviceVector()
Definition: VectorDual.hpp:354
pFlow::VectorDual::VectorDual
VectorDual()
Definition: VectorDual.hpp:173
pFlow::VectorDual::data
INLINE_FUNCTION_H constPointer data() const
Definition: VectorDual.hpp:757
pFlow::VectorDual::growthFactor_
static const real growthFactor_
Definition: VectorDual.hpp:106
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::VectorDual::end
INLINE_FUNCTION_H constIterator end() const
Definition: VectorDual.hpp:781
typeInfo.hpp
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::VectorDual::insertSetElement
INLINE_FUNCTION_H bool insertSetElement(const int32IndexContainer &indices, const T &val)
Definition: VectorDual.hpp:549
pFlow::VectorDual::fillHost
INLINE_FUNCTION_H void fillHost(const T &val)
Definition: VectorDual.hpp:463
pFlow::VectorDual::VectorDual
VectorDual(size_t n, const T &val)
Definition: VectorDual.hpp:205
pFlow::VectorDual::write
FUNCTION_H bool write(iOstream &os) const
Definition: VectorDual.hpp:912
pFlow::VectorDual< int8 >::constPointer
const int8 * constPointer
Definition: VectorDual.hpp:63
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
pFlow::VectorDual::deleteElement
bool deleteElement(const Vector< label > &indices)
Definition: VectorDual.hpp:515
pFlow::VectorDual::hostRequiresSync
INLINE_FUNCTION_H bool hostRequiresSync() const
Definition: VectorDual.hpp:806
pFlow::VectorDual::subViewsUpdated_
bool subViewsUpdated_
Definition: VectorDual.hpp:104
pFlow::VectorDual< int8 >::hostViewType
typename dualViewType::t_host hostViewType
Definition: VectorDual.hpp:77
pFlow::Vector
Definition: Vector.hpp:46
pFlow::VectorDual< int8 >::hostMirrorSpace
typename dualViewType::host_mirror_space hostMirrorSpace
Definition: VectorDual.hpp:71
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::VectorDual::dualView_
dualViewType dualView_
Definition: VectorDual.hpp:98
pFlow::VectorDual< int8 >::viewType
dualViewType viewType
Definition: VectorDual.hpp:84
pFlow::VectorDual::size
INLINE_FUNCTION_H size_t size() const
Definition: VectorDual.hpp:391
pFlow::min
T min(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:138
pFlow::VectorDual::isHostAccessible_
static constexpr bool isHostAccessible_
Definition: VectorDual.hpp:109
pFlow::fillSelected
bool fillSelected(ViewType1D< Type, properties... > view, const ViewType1D< indexType, indexProperties... > indices, const int32 numElems, const Type val, typename std::enable_if_t< areAccessible< typename ViewType1D< Type, properties... >::execution_space, typename ViewType1D< indexType, indexProperties... >::memory_space >(), bool >=true)
Definition: ViewAlgorithms.hpp:147
Vector.hpp
pFlow::VectorDual::hostSubView_
hostViewType hostSubView_
Definition: VectorDual.hpp:102
pFlow::indexContainer< int32 >
pFlow::VectorDual::begin
INLINE_FUNCTION_H constIterator begin() const
Definition: VectorDual.hpp:769
pFlow::indexContainer::deviceView
const DeviceViewType & deviceView() const
Definition: indexContainer.hpp:148
pFlow::VectorDual::size_
size_t size_
Definition: VectorDual.hpp:94
pFlow::VectorDual::TypeInfoTemplateNV2
TypeInfoTemplateNV2("VectorDual", T, memoerySpaceName())
pFlow::VectorDual::fillDevice
INLINE_FUNCTION_H void fillDevice(const T &val)
Definition: VectorDual.hpp:470