# PhasicFlow: src/Interaction/contactSearch/methods/cellBased/NBS/mapperNBS.hpp 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.

mapperNBS.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 __mapperNBS_hpp__
#define __mapperNBS_hpp__
#include "phasicFlowKokkos.hpp"
#include "pointFlag.hpp"
#include "cells.hpp"
//#include "contactSearchFunctions.hpp"
namespace pFlow
{
class mapperNBS
{
public:
using HeadType = deviceViewType3D<uint32>;
using NextType = deviceViewType1D<uint32>;
static constexpr uint32 NoPos = 0xFFFFFFFF;
class CellIterator
{
private:
HeadType head_;
NextType next_;
public:
CellIterator(const HeadType& head, const NextType& next)
:
head_(head),
next_(next)
{}
static constexpr uint32 NoPos = 0xFFFFFFFF;
INLINE_FUNCTION_HD
int32x3 numCells()const {
return int32x3(head_.extent(0), head_.extent(1), head_.extent(2));}
INLINE_FUNCTION_HD
uint32 start(int32 i, int32 j, int32 k)const {
return head_(i,j,k); }
INLINE_FUNCTION_HD
uint32 getNext(uint32 n)const {
if(n == NoPos ) return NoPos;
return next_(n); }
INLINE_FUNCTION_HD
uint32 next(uint32 n)const{
return next_(n);}
};
private:
cells domainCells_;
cells searchCells_;
HeadType head_{"NBS::head",1,1,1};
NextType next_{"NBS::next", 1};
uint32 nextCapacity_ = 0;
uint32 lastCheckForBox_ = 0;
uint32 buildCount_ = 0;
bool adjustableBox_ = false;
bool nextOwner_ = true;
static uint32 checkInterval_;
static real enlargementFactor_;
bool setSearchBox(
const deviceViewType1D<realx3>& pointPos,
const pFlagTypeDevice& flags,
real cellSize
);
void allocateArrays(rangeU32 nextRng);
void checkAllocateNext(rangeU32 nextRng);
void nullifyHead();
void nullifyNext(rangeU32 nextRng);
public:
TypeInfoNV("mapperNBS");
INLINE_FUNCTION_HD
mapperNBS() = default;
mapperNBS(
const box& domain,
real cellSize,
const deviceViewType1D<realx3>& pointPos,
const pFlagTypeDevice& flags,
bool adjustableBox,
bool nextOwner = true);
INLINE_FUNCTION_HD
mapperNBS(const mapperNBS&) = default;
INLINE_FUNCTION_HD
mapperNBS(mapperNBS&&) = default;
INLINE_FUNCTION_HD
mapperNBS& operator = (const mapperNBS&) = default;
INLINE_FUNCTION_HD
mapperNBS& operator = (mapperNBS&&) = default;
INLINE_FUNCTION_HD
~mapperNBS()=default;
auto getCellIterator()const
{
return CellIterator(head_, next_);
}
const auto& getDomainCells()const
{
return domainCells_;
}
const auto& getSearchCells()const
{
return searchCells_;
}
bool build(
const deviceViewType1D<realx3>& pointPos,
const pFlagTypeDevice& flags,
bool& searchBoxChanged);
};
} // pFlow
#endif // __mapperNBS_hpp__
/*
INLINE_FUNCTION_HD
auto& head()
{
return head_;
}
INLINE_FUNCTION_HD
auto& next()
{
return next_;
}
INLINE_FUNCTION_HD
const auto& head()const
{
return head_;
}
INLINE_FUNCTION_HD
const auto& next()const
{
return next_;
}
INLINE_FUNCTION_HD
auto& pointPosition()
{
return pointPosition_;
}
*/
pFlow::mapperNBS::CellIterator::next
INLINE_FUNCTION_HD uint32 next(uint32 n) const
Definition: mapperNBS.hpp:76
pFlow::mapperNBS::mapperNBS
INLINE_FUNCTION_HD mapperNBS()=default
pFlow::mapperNBS::domainCells_
cells domainCells_
Definition: mapperNBS.hpp:82
pFlow::mapperNBS::allocateArrays
void allocateArrays(rangeU32 nextRng)
Definition: mapperNBS.cpp:74
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::mapperNBS::CellIterator::numCells
INLINE_FUNCTION_HD int32x3 numCells() const
Definition: mapperNBS.hpp:63
pFlow::mapperNBS::buildCount_
uint32 buildCount_
Definition: mapperNBS.hpp:94
pFlow::mapperNBS::nextOwner_
bool nextOwner_
Definition: mapperNBS.hpp:98
pFlow::mapperNBS::CellIterator::head_
HeadType head_
Definition: mapperNBS.hpp:48
pFlow::mapperNBS::build
bool build(const deviceViewType1D< realx3 > &pointPos, const pFlagTypeDevice &flags, bool &searchBoxChanged)
Definition: mapperNBS.cpp:125
pFlow::mapperNBS::~mapperNBS
INLINE_FUNCTION_HD ~mapperNBS()=default
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::mapperNBS::setSearchBox
bool setSearchBox(const deviceViewType1D< realx3 > &pointPos, const pFlagTypeDevice &flags, real cellSize)
Definition: mapperNBS.cpp:29
pFlow::mapperNBS::nullifyHead
void nullifyHead()
Definition: mapperNBS.cpp:94
pFlow::mapperNBS::CellIterator
Definition: mapperNBS.hpp:45
pFlow::mapperNBS::NoPos
static constexpr uint32 NoPos
Definition: mapperNBS.hpp:43
pFlow::deviceViewType1D
Kokkos::View< T * > deviceViewType1D
1D array (vector) with default device (memory space and execution space)
Definition: KokkosTypes.hpp:121
pFlow::mapperNBS
Definition: mapperNBS.hpp:34
pFlow::mapperNBS::nullifyNext
void nullifyNext(rangeU32 nextRng)
Definition: mapperNBS.cpp:99
pFlow
Definition: demGeometry.hpp:27
pFlow::mapperNBS::TypeInfoNV
TypeInfoNV("mapperNBS")
pFlow::mapperNBS::enlargementFactor_
static real enlargementFactor_
Definition: mapperNBS.hpp:102
phasicFlowKokkos.hpp
pFlow::mapperNBS::searchCells_
cells searchCells_
Definition: mapperNBS.hpp:84
pFlow::mapperNBS::getSearchCells
const auto & getSearchCells() const
Definition: mapperNBS.hpp:160
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::mapperNBS::lastCheckForBox_
uint32 lastCheckForBox_
Definition: mapperNBS.hpp:92
pFlow::deviceViewType3D
Kokkos::View< T ***, Layout, void > deviceViewType3D
3D view on device as an array on device
Definition: KokkosTypes.hpp:129
pFlow::int32x3
triple< int32 > int32x3
Definition: types.hpp:38
pFlow::mapperNBS::CellIterator::start
INLINE_FUNCTION_HD uint32 start(int32 i, int32 j, int32 k) const
Definition: mapperNBS.hpp:67
pFlow::mapperNBS::getDomainCells
const auto & getDomainCells() const
Definition: mapperNBS.hpp:155
pFlow::mapperNBS::adjustableBox_
bool adjustableBox_
Definition: mapperNBS.hpp:96
pFlow::mapperNBS::CellIterator::next_
NextType next_
Definition: mapperNBS.hpp:50
pFlow::mapperNBS::CellIterator::CellIterator
CellIterator(const HeadType &head, const NextType &next)
Definition: mapperNBS.hpp:54
pFlow::Range< uint32 >
pFlow::mapperNBS::checkInterval_
static uint32 checkInterval_
Definition: mapperNBS.hpp:100
n
uint32 n
Definition: NBSLoop.hpp:24
pFlow::mapperNBS::HeadType
deviceViewType3D< uint32 > HeadType
Definition: mapperNBS.hpp:38
pFlow::mapperNBS::CellIterator::NoPos
static constexpr uint32 NoPos
Definition: mapperNBS.hpp:60
pFlow::box
Definition: box.hpp:32
pFlow::mapperNBS::head_
HeadType head_
Definition: mapperNBS.hpp:86
pFlow::mapperNBS::checkAllocateNext
void checkAllocateNext(rangeU32 nextRng)
Definition: mapperNBS.cpp:81
pFlow::mapperNBS::operator=
INLINE_FUNCTION_HD mapperNBS & operator=(const mapperNBS &)=default
pFlow::mapperNBS::getCellIterator
auto getCellIterator() const
Definition: mapperNBS.hpp:150
pFlow::domain
Definition: domain.hpp:31
pFlow::cells
Definition: cells.hpp:31
pFlow::mapperNBS::NextType
deviceViewType1D< uint32 > NextType
Definition: mapperNBS.hpp:40
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::triple< int32 >
pFlow::mapperNBS::nextCapacity_
uint32 nextCapacity_
Definition: mapperNBS.hpp:90
pFlow::mapperNBS::CellIterator::getNext
INLINE_FUNCTION_HD uint32 getNext(uint32 n) const
Definition: mapperNBS.hpp:71
pFlow::mapperNBS::next_
NextType next_
Definition: mapperNBS.hpp:88
pFlow::pointFlag< DefaultExecutionSpace >
pointFlag.hpp