# PhasicFlow: utilities/postprocessPhasicFlow/cellMapper.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.

cellMapper.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.
-----------------------------------------------------------------------------*/
#include "cellMapper.hpp"
//#include "cellMapperKernels.hpp"
#include "streams.hpp"
void pFlow::cellMapper::allocateArrays(rangeU32 nextRng)
{
checkAllocateNext(nextRng);
nullifyNext(nextRng);
reallocFill(head_, domainCells_.nx(), domainCells_.ny(), domainCells_.nz(), NoPos);
}
void pFlow::cellMapper::checkAllocateNext(rangeU32 nextRng)
{
auto newCap = nextRng.end();
if( nextCapacity_ < newCap)
{
nextCapacity_ = newCap;
reallocNoInit(next_, nextCapacity_);
}
}
void pFlow::cellMapper::nullifyHead()
{
fill(head_, NoPos);
}
void pFlow::cellMapper::nullifyNext(rangeU32 nextRng)
{
fill(next_, nextRng, NoPos);
}
pFlow::cellMapper::cellMapper(
const rectangleMesh& rectMesh,
const hostViewType1D<realx3>& pointPos,
const pFlagTypeHost& flags
)
:
domainCells_(rectMesh)
{
allocateArrays(flags.activeRange());
}
bool pFlow::cellMapper::build
(
const hostViewType1D<realx3>& pointPos,
const pFlagTypeHost & flags
)
{
auto aRange = flags.activeRange();
checkAllocateNext(aRange);
nullifyHead();
nullifyNext(aRange);
int32x3 ind;
for(uint32 i=aRange.start(); i<aRange.end(); i++)
{
if( domainCells_.isInsideIndex(pointPos[i], ind) )
{
next_[i] = head_(ind.x(), ind.y(), ind.z());
head_(ind.x(), ind.y(), ind.z()) = i;
}
}
return true;
}
pFlow::cellMapper::nullifyNext
void nullifyNext(rangeU32 nextRng)
Definition: cellMapper.cpp:50
pFlow::reallocFill
INLINE_FUNCTION_H void reallocFill(ViewType1D< Type, Properties... > &view, uint32 len, Type val)
Definition: KokkosUtilities.hpp:71
pFlow::rectangleMesh::ny
int32 ny() const
Definition: rectangleMesh.hpp:82
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
pFlow::cellMapper::head_
HeadType head_
Definition: cellMapper.hpp:83
pFlow::Range::end
INLINE_FUNCTION_HD T & end()
End.
Definition: Range.hpp:101
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::reallocNoInit
INLINE_FUNCTION_H void reallocNoInit(ViewType1D< Type, Properties... > &view, uint32 len)
Definition: KokkosUtilities.hpp:64
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:34
pFlow::triple::y
INLINE_FUNCTION_HD T & y()
access component
Definition: triple.hpp:144
pFlow::cellMapper::checkAllocateNext
void checkAllocateNext(rangeU32 nextRng)
Definition: cellMapper.cpp:33
cellMapper.hpp
pFlow::cellMapper::domainCells_
const rectangleMesh & domainCells_
Definition: cellMapper.hpp:81
pFlow::rectangleMesh::nz
int32 nz() const
Definition: rectangleMesh.hpp:87
pFlow::cellMapper::allocateArrays
void allocateArrays(rangeU32 nextRng)
Definition: cellMapper.cpp:26
pFlow::pointFlag::activeRange
const INLINE_FUNCTION_HD auto & activeRange() const
Definition: pointFlag.hpp:179
pFlow::Range< uint32 >
pFlow::triple::z
INLINE_FUNCTION_HD T & z()
access component
Definition: triple.hpp:156
streams.hpp
pFlow::hostViewType1D
Kokkos::View< T *, Kokkos::HostSpace > hostViewType1D
1D array (vector with host memeory space)
Definition: KokkosTypes.hpp:136
pFlow::cellMapper::build
bool build(const hostViewType1D< realx3 > &pointPos, const pFlagTypeHost &flags)
Definition: cellMapper.cpp:68
pFlow::cellMapper::NoPos
static constexpr uint32 NoPos
Definition: cellMapper.hpp:42
pFlow::triple::x
INLINE_FUNCTION_HD T & x()
access component
Definition: triple.hpp:132
pFlow::triple< int32 >
pFlow::cellMapper::nullifyHead
void nullifyHead()
Definition: cellMapper.cpp:45
pFlow::pointFlag< DefaultHostExecutionSpace >
pFlow::cellMapper::cellMapper
cellMapper(const rectangleMesh &rectMesh, const hostViewType1D< realx3 > &pointPos, const pFlagTypeHost &flags)
Definition: cellMapper.cpp:55
pFlow::rectangleMesh::nx
int32 nx() const
Definition: rectangleMesh.hpp:77