containers are modified for errors
This commit is before the first release of phasicFlow from develop to main (version 1.0)
This commit is contained in:
parent
0aa7f2dba9
commit
57850119ba
|
@ -188,6 +188,11 @@ public:
|
|||
{
|
||||
this->fill(span, val);
|
||||
}
|
||||
|
||||
void fillField(const T& val)
|
||||
{
|
||||
this->fill(val);
|
||||
}
|
||||
|
||||
//// - IO operations
|
||||
|
||||
|
|
|
@ -51,7 +51,9 @@ protected:
|
|||
anyListType anyList_;
|
||||
|
||||
/// List of variable names in anyList_
|
||||
wordList names_;
|
||||
wordList names_;
|
||||
|
||||
wordList types_;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -89,6 +91,7 @@ public:
|
|||
fatalExit;
|
||||
}
|
||||
names_.push_back(name);
|
||||
types_.push_back(getTypeName<T>());
|
||||
return anyList_.emplace_back(
|
||||
std::in_place_type<T>,
|
||||
std::forward<Args>(args)...);
|
||||
|
@ -106,6 +109,7 @@ public:
|
|||
fatalExit;
|
||||
}
|
||||
names_.push_back(name);
|
||||
types_.push_back(getTypeName<T>());
|
||||
return anyList_.emplace_back(std::in_place_type<T>, other);
|
||||
}
|
||||
|
||||
|
@ -121,6 +125,7 @@ public:
|
|||
fatalExit;
|
||||
}
|
||||
names_.push_back(name);
|
||||
types_.push_back(getTypeName<T>());
|
||||
return anyList_.emplace_back(std::in_place_type<T>, std::move(other));
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
using hashmapType = std::unordered_map<Key, T, Hash>;
|
||||
|
||||
using hasher = typename hashmapType::hasher;
|
||||
|
||||
using iterator = typename hashmapType::iterator;
|
||||
|
||||
using constIterator = typename hashmapType::const_iterator;
|
||||
|
@ -75,46 +77,24 @@ public:
|
|||
{}
|
||||
|
||||
// - Copy construct
|
||||
hashMap(const hashMapType & src)
|
||||
:
|
||||
hashmapType(src)
|
||||
{}
|
||||
hashMap(const hashMapType & src) = default;
|
||||
|
||||
// - Move construct
|
||||
hashMap( hashMapType&& src)
|
||||
:
|
||||
hashmapType(std::move(src))
|
||||
{}
|
||||
hashMap( hashMapType&& src) = default;
|
||||
|
||||
// - Copy assignment
|
||||
hashMapType& operator=(const hashMapType& rhs)
|
||||
{
|
||||
hashmapType::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
hashMapType& operator=(const hashMapType& rhs) = default;
|
||||
|
||||
// - Move assignment
|
||||
hashMapType& operator=(hashMapType&& rhs)
|
||||
{
|
||||
hashmapType::operator=( std::move(rhs));
|
||||
return *this;
|
||||
}
|
||||
|
||||
hashMapType& operator=(hashMapType&& rhs) = default;
|
||||
|
||||
uniquePtr<hashMapType> clone()const
|
||||
{
|
||||
return makeUnique<hashMapType>(*this);
|
||||
}
|
||||
|
||||
hashMapType* clonePtr()const
|
||||
{
|
||||
return new hashMapType(*this);
|
||||
}
|
||||
|
||||
~hashMap()
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
|
||||
~hashMap() = default;
|
||||
|
||||
|
||||
//// - Methods
|
||||
|
||||
|
|
|
@ -509,7 +509,7 @@ void pFlow::VectorSingle<T,MemorySpace>::assign
|
|||
|
||||
template<typename T, typename MemorySpace>
|
||||
INLINE_FUNCTION_H
|
||||
void pFlow::VectorSingle<T,MemorySpace>::assign(const VectorTypeHost& src)
|
||||
void pFlow::VectorSingle<T,MemorySpace>::assignFromHost(const VectorTypeHost& src)
|
||||
{
|
||||
uint32 srcSize = src.size();
|
||||
uint32 srcCap = src.capacity();
|
||||
|
@ -540,7 +540,45 @@ void pFlow::VectorSingle<T,MemorySpace>::assign(const VectorTypeHost& src)
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
setSize(srcSize);
|
||||
}
|
||||
|
||||
if constexpr(isTriviallyCopyable_)
|
||||
{
|
||||
copy(deviceView(), src.deviceView());
|
||||
}
|
||||
else if constexpr( isHostAccessible_)
|
||||
{
|
||||
for(auto i=0u; i<src.size(); i++)
|
||||
{
|
||||
view_[i] = src.view_[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert("Not a valid operation for this data type on device memory");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename MemorySpace>
|
||||
INLINE_FUNCTION_H
|
||||
void pFlow::VectorSingle<T, MemorySpace>::append
|
||||
(
|
||||
const std::vector<T> &appVec
|
||||
|
@ -575,6 +613,41 @@ void pFlow::VectorSingle<T, MemorySpace>::append
|
|||
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
setSize(newSize);
|
||||
auto appendView = Kokkos::subview(
|
||||
view_,
|
||||
Kokkos::make_pair<uint32>(oldS, newSize));
|
||||
|
||||
if constexpr( isTriviallyCopyable_)
|
||||
{
|
||||
copy(appendView, appVec.deviceView());
|
||||
}
|
||||
else if constexpr( isHostAccessible_)
|
||||
{
|
||||
for(auto i=0u; i<appVec.size(); i++)
|
||||
{
|
||||
appendView[i] = appVec.view_[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static_assert("not a valid operation for this data type on device memory");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename MemorySpace>
|
||||
INLINE_FUNCTION_H auto pFlow::VectorSingle<T, MemorySpace>::getSpan()
|
||||
{
|
||||
|
|
|
@ -284,10 +284,16 @@ public:
|
|||
/// The size of *this becomes the size of src.
|
||||
/// The capacity of *this becomes the capacity of src.
|
||||
INLINE_FUNCTION_H
|
||||
void assign(const VectorTypeHost& src);
|
||||
void assignFromHost(const VectorTypeHost& src);
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
void assign(const VectorType& src, bool srcCapacity = true);
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
void append(const std::vector<T>& appVec);
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
void append(const VectorType& appVec);
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
auto getSpan();
|
||||
|
|
|
@ -52,10 +52,8 @@ protected:
|
|||
static inline
|
||||
const message defaultMessage_ =
|
||||
(
|
||||
message::CAP_CHANGED+
|
||||
message::SIZE_CHANGED+
|
||||
message::ITEM_INSERT+
|
||||
message::ITEM_DELETE
|
||||
message::BNDR_RESET+
|
||||
message::BNDR_REARRANGE
|
||||
);
|
||||
|
||||
public:
|
||||
|
@ -95,8 +93,16 @@ public:
|
|||
const anyList& varList
|
||||
) override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
|
||||
if(msg.equivalentTo(message::BNDR_REARRANGE))
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
if(msg.equivalentTo(message::BNDR_RESET))
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
auto size()const
|
|
@ -70,8 +70,14 @@ public:
|
|||
const anyList& varList
|
||||
) override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
BoundaryFieldType::hearChanges(t,dt,iter, msg,varList);
|
||||
|
||||
if(msg.equivalentTo(message::BNDR_DELETE))
|
||||
{
|
||||
// do nothing;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
|
@ -98,6 +98,46 @@ typename pFlow::internalField<T, MemorySpace>::FieldTypeHost
|
|||
return aField;
|
||||
}
|
||||
|
||||
template <class T, class MemorySpace>
|
||||
bool pFlow::internalField<T, MemorySpace>:: hearChanges
|
||||
(
|
||||
real t,
|
||||
real dt,
|
||||
uint32 iter,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
)
|
||||
{
|
||||
if(msg.equivalentTo(message::CAP_CHANGED))
|
||||
{
|
||||
auto newCap = varList.getObject<uint32>(
|
||||
message::eventName(message::CAP_CHANGED));
|
||||
|
||||
field_.reserve(newCap);
|
||||
}
|
||||
if(msg.equivalentTo(message::SIZE_CHANGED))
|
||||
{
|
||||
auto newSize = varList.getObject<uint32>(
|
||||
message::eventName(message::SIZE_CHANGED));
|
||||
field_.resize(newSize);
|
||||
}
|
||||
if(msg.equivalentTo(message::ITEM_DELETE))
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
if(msg.equivalentTo(message::ITEM_REARRANGE))
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
}
|
||||
if(msg.equivalentTo(message::ITEM_INSERT))
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class MemorySpace>
|
||||
bool pFlow::internalField<T, MemorySpace>::write
|
||||
(
|
||||
|
|
|
@ -24,6 +24,7 @@ Licence:
|
|||
#include "Field.hpp"
|
||||
#include "observer.hpp"
|
||||
#include "dataIO.hpp"
|
||||
#include "anyList.hpp"
|
||||
|
||||
|
||||
namespace pFlow
|
||||
|
@ -59,6 +60,7 @@ protected:
|
|||
const message defaultMessage_ =
|
||||
(
|
||||
message::CAP_CHANGED+
|
||||
message::SIZE_CHANGED+
|
||||
message::ITEM_INSERT+
|
||||
message::ITEM_REARRANGE+
|
||||
message::ITEM_DELETE
|
||||
|
@ -75,6 +77,11 @@ public:
|
|||
const internalPoints& internal,
|
||||
const T& val);
|
||||
|
||||
inline
|
||||
const auto& deviceViewAll()const
|
||||
{
|
||||
return field_.deviceViewAll();
|
||||
}
|
||||
inline
|
||||
auto deviceView()const
|
||||
{
|
||||
|
@ -166,11 +173,8 @@ public:
|
|||
uint32 iter,
|
||||
const message& msg,
|
||||
const anyList& varList
|
||||
) override
|
||||
{
|
||||
notImplementedFunction;
|
||||
return false;
|
||||
}
|
||||
) override;
|
||||
|
||||
|
||||
//// - IO
|
||||
|
||||
|
|
|
@ -194,7 +194,58 @@ Pair<T,T> minMax(const internalField<T,MemorySpace>& iField)
|
|||
}
|
||||
}
|
||||
|
||||
template<class T, class MemorySpace>
|
||||
inline
|
||||
void fillSequence(internalField<T,MemorySpace>& iField, const T& startVal)
|
||||
{
|
||||
using exeSpace = typename internalField<T,MemorySpace>::execution_space;
|
||||
|
||||
using policy = Kokkos::RangePolicy<
|
||||
exeSpace,
|
||||
Kokkos::IndexType<uint32> >;
|
||||
|
||||
if constexpr(isDeviceAccessible<exeSpace>())
|
||||
{
|
||||
auto maskD = iField.activePointsMaskDevice();
|
||||
auto aRange = maskD.activeRange();
|
||||
auto field = iField.field().deviceViewAll();
|
||||
auto aPoints = maskD.getActivePoints();
|
||||
exclusiveScan(aPoints,0, aRange.end(), aPoints,0);
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"internalField::fillSequence",
|
||||
policy(aRange.start(), aRange.end() ),
|
||||
LAMBDA_HD(uint32 i)
|
||||
{
|
||||
if(maskD(i))
|
||||
{
|
||||
field[i] = aPoints[i]+startVal;
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
}
|
||||
else
|
||||
{
|
||||
// this is a host view
|
||||
auto maskH = iField.activePointsMaskHost();
|
||||
auto aRange = maskH.activeRange();
|
||||
auto field = iField.field().deviceViewAll();
|
||||
auto aPoints = maskH.getActivePoints();
|
||||
exclusiveScan(aPoints,0, aRange.end(), aPoints,0);
|
||||
|
||||
Kokkos::parallel_for(
|
||||
"internalField::fillSequence",
|
||||
policy(aRange.start(), aRange.end() ),
|
||||
LAMBDA_HD(uint32 i)
|
||||
{
|
||||
if(maskH(i))
|
||||
{
|
||||
field[i] = aPoints[i]+startVal;
|
||||
}
|
||||
});
|
||||
Kokkos::fence();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,7 @@ bool pFlow::pointField<T, MemorySpace>::readPointField
|
|||
return false;
|
||||
}
|
||||
|
||||
this->field_.assign(internal);
|
||||
this->field_.assignFromHost(internal);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,14 @@ template class pFlow::pointField<pFlow::uint32>;
|
|||
createBaseBoundary(pFlow::uint32, void);
|
||||
createAllBoundary(pFlow::uint32, void);
|
||||
|
||||
template class pFlow::pointField<pFlow::uint64, pFlow::HostSpace>;
|
||||
createBaseBoundary(pFlow::uint64, pFlow::HostSpace);
|
||||
createAllBoundary(pFlow::uint64, pFlow::HostSpace);
|
||||
|
||||
template class pFlow::pointField<pFlow::uint64>;
|
||||
createBaseBoundary(pFlow::uint64, void);
|
||||
createAllBoundary(pFlow::uint64, void);
|
||||
|
||||
template class pFlow::pointField<pFlow::real, pFlow::HostSpace>;
|
||||
createBaseBoundary(pFlow::real, pFlow::HostSpace);
|
||||
createAllBoundary(pFlow::real, pFlow::HostSpace);
|
||||
|
|
|
@ -23,22 +23,11 @@ Licence:
|
|||
|
||||
#include "KokkosTypes.hpp"
|
||||
|
||||
|
||||
#include "types.hpp"
|
||||
#include "typeInfo.hpp"
|
||||
#include "Vector.hpp"
|
||||
|
||||
|
||||
/*
|
||||
stores the elemnt of a symetric array in the following order in a 1D vector
|
||||
|
||||
0 1 2 3
|
||||
4 5 6
|
||||
7 8
|
||||
9
|
||||
|
||||
*/
|
||||
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
|
@ -52,6 +41,15 @@ void SWAP(Type &x, Type& y)
|
|||
x = temp;
|
||||
}
|
||||
|
||||
/*
|
||||
stores the elemnt of a symetric array in the following order in a 1D vector
|
||||
|
||||
0 1 2 3
|
||||
4 5 6
|
||||
7 8
|
||||
9
|
||||
|
||||
*/
|
||||
template<typename T, typename MemorySpace=void>
|
||||
class symArray
|
||||
{
|
||||
|
@ -82,14 +80,14 @@ class symArray
|
|||
using execution_space = typename ViewType::execution_space;
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
uint32 n_=0;
|
||||
uint32 n_= 0;
|
||||
|
||||
ViewType view_;
|
||||
|
||||
|
||||
constexpr static inline const char* memoerySpaceName()
|
||||
constexpr static const char* memoerySpaceName()
|
||||
{
|
||||
return memory_space::name();
|
||||
}
|
||||
|
@ -97,14 +95,14 @@ protected:
|
|||
public:
|
||||
|
||||
// - type info
|
||||
TypeInfoTemplateNV2("symArray", T, memoerySpaceName());
|
||||
TypeInfoTemplateNV111("symArray", T, memoerySpaceName());
|
||||
|
||||
//// constructors
|
||||
INLINE_FUNCTION_H
|
||||
symArray();
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
symArray(uint32 n)
|
||||
explicit symArray(uint32 n)
|
||||
:
|
||||
symArray("symArray",n)
|
||||
{}
|
||||
|
@ -125,7 +123,7 @@ public:
|
|||
}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
symArray(word name, Vector<T> src)
|
||||
symArray(word name, const Vector<T>& src)
|
||||
:
|
||||
view_(name)
|
||||
{
|
||||
|
@ -137,19 +135,19 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
INLINE_FUNCTION_HD
|
||||
symArray(const symArray&) = default;
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
INLINE_FUNCTION_HD
|
||||
symArray& operator=(const symArray&) = default;
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
symArray(symArray&&) = delete;
|
||||
INLINE_FUNCTION_HD
|
||||
symArray(symArray&&) = default;
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
symArray& operator=(symArray&&) = delete;
|
||||
INLINE_FUNCTION_HD
|
||||
symArray& operator=(symArray&&) = default;
|
||||
|
||||
INLINE_FUNCTION_H
|
||||
INLINE_FUNCTION_HD
|
||||
~symArray()=default;
|
||||
|
||||
|
||||
|
@ -219,10 +217,10 @@ public:
|
|||
bool write(iOstream& os)const
|
||||
{
|
||||
|
||||
int32 s = numElem(n_);
|
||||
Vector<T, noConstructAllocator<T>> vecToFile(s);
|
||||
uint32 s = numElem(n_);
|
||||
Vector<T> vecToFile(view_.label(),s);
|
||||
|
||||
const auto dVec = Kokkos::subview(view_, kPair<int32,int32>(0, s));
|
||||
const auto dVec = Kokkos::subview(view_, Pair<uint32,uint32>(0, s));
|
||||
hostViewType1D<T> mirror(vecToFile.data(), vecToFile.size());
|
||||
Kokkos::deep_copy(mirror,dVec);
|
||||
|
||||
|
|
|
@ -130,6 +130,41 @@ public:
|
|||
field_.assign(vals, surface_.capacity());
|
||||
}
|
||||
|
||||
inline
|
||||
const auto& deviceViewAll()const
|
||||
{
|
||||
return field_.deviceViewAll();
|
||||
}
|
||||
inline
|
||||
auto deviceView()const
|
||||
{
|
||||
return field_.deviceView();
|
||||
}
|
||||
|
||||
inline
|
||||
auto hostView()const
|
||||
{
|
||||
return field_.hostView();
|
||||
}
|
||||
|
||||
inline
|
||||
const FieldType& field()const
|
||||
{
|
||||
return field_;
|
||||
}
|
||||
|
||||
inline
|
||||
FieldType& field()
|
||||
{
|
||||
return field_;
|
||||
}
|
||||
|
||||
inline
|
||||
void fill(const T& val)
|
||||
{
|
||||
field_.fillField(val);
|
||||
}
|
||||
|
||||
bool hearChanges(
|
||||
real t,
|
||||
real dt,
|
||||
|
|
Loading…
Reference in New Issue