# PhasicFlow: src/phasicFlow/structuredData/pointStructure/internalPoints/internalPoints.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.

internalPoints.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 __internalPoints_hpp__
#define __internalPoints_hpp__
#include "subscriber.hpp"
#include "Vectors.hpp"
#include "VectorSingles.hpp"
#include "Fields.hpp"
#include "pointFlag.hpp"
namespace pFlow
{
class domain;
class boundaryBase;
class Time;
class internalPoints
:
public subscriber
{
public:
inline static const uint32 initialCapacity_ = 10000;
using PointsType = realx3Field_D;
using PointsTypeHost = typename PointsType::FieldTypeHost;
using device_type = typename PointsType::device_type;
using memory_space = typename PointsType::memory_space;
using execution_space = typename PointsType::execution_space;
private:
friend boundaryBase;
PointsType pointPosition_;
mutable pFlagTypeDevice pFlagsD_;
mutable pFlagTypeHost pFlagsH_;
mutable bool pFlagSync_ = false;
bool deletePoints(const uint32Vector_D& delPoints);
bool changePointsFlagPosition(
const uint32Vector_D& changePoints,
realx3 transferVector,
uint32 fromBoundaryIndex,
uint32 toBoundaryIndex);
protected:
void syncPFlag()const;
inline
void unSyncFlag()
{
pFlagSync_ = false;
}
inline
void createDeviceFlag(uint32 cap, uint32 start, uint32 end)
{
unSyncFlag();
pFlagsD_ = pFlagTypeDevice(cap, start, end);
}
bool sortPoints(const uint32IndexContainer& sortedIndices);
public:
//friend class dynamicinternalPoints;
// - type info
TypeInfo("internalPoints");
// - an empty internalPoints, good for reading from file
internalPoints();
explicit internalPoints(const realx3Vector& posVec);
internalPoints(const internalPoints&) = delete;
internalPoints(internalPoints&&) = default;
internalPoints& operator=(const internalPoints&) = delete;
internalPoints& operator=(internalPoints&&) = default;
~internalPoints()override = default;
const pFlagTypeDevice& activePointsMaskDevice()const;
const pFlagTypeHost& activePointsMaskHost()const;
// - Const access pointPosition
const PointsType& pointPosition()const;
PointsType& pointPosition();
inline
auto pointPositionHost()const
{
return pointPosition_.hostView();
}
inline
auto pointPositionDevice()const
{
return pointPosition_.deviceView();
}
PointsTypeHost activePointsHost()const;
// - size of data structure
inline
uint32 size()const
{
return pFlagsD_.activeRange_.end();
}
// - maximum capacity of data structure
inline
uint32 capacity()const
{
return pFlagsD_.capacity();
}
inline
bool empty()const
{
return size()==0u;
}
// - number of active points
inline
uint32 numActive() const
{
return pFlagsD_.numActive();
}
// - if all points are active
inline
bool isAllActive()const
{
return pFlagsD_.isAllActive();
}
inline
auto activeRange()const
{
return pFlagsD_.activeRange();
}
virtual
Time& time() = 0;
virtual
const Time& time() const = 0;
virtual
boundaryBase& boundary(size_t boundaryIndex ) = 0;
virtual
const boundaryBase& boundary(size_t boundaryIndex ) const = 0;
bool deletePoints(
scatteredFieldAccess<uint32, memory_space> delPoints);
uint32 updateFlag(
const domain& dm,
const std::array<real,6>& dist);
void fillNeighborsLists(
ViewType1D<uint32, memory_space> leftList,
ViewType1D<uint32, memory_space> rightList,
ViewType1D<uint32, memory_space> bottomList,
ViewType1D<uint32, memory_space> topList,
ViewType1D<uint32, memory_space> rearList,
ViewType1D<uint32, memory_space> frontList);
bool insertPoints(const realx3Vector& points, anyList& varList);
bool insertPointsOnly(const realx3Vector_D& points, message& msg, anyList& varList);
bool read(iIstream& is);
bool write(iOstream& os)const;
bool read(iIstream& is, const IOPattern& iop);
bool write(iOstream& os, const IOPattern& iop)const;
};
inline
iOstream& operator<<(iOstream& os, const internalPoints& ip)
{
if( !ip.write(os) )
{
ioErrorInFile(os.name(), os.lineNumber());
fatalExit;
}
return os;
}
} // pFlow
#endif //__internalPoints_hpp__
pFlow::internalPoints::isAllActive
bool isAllActive() const
Definition: internalPoints.hpp:195
pFlow::internalPoints::activePointsHost
PointsTypeHost activePointsHost() const
Definition: internalPoints.cpp:222
subscriber.hpp
pFlow::internalPoints::pFlagsD_
pFlagTypeDevice pFlagsD_
flag of points on device
Definition: internalPoints.hpp:68
pFlow::pointFlag::capacity
INLINE_FUNCTION_HD uint32 capacity() const
Definition: pointFlag.hpp:185
pFlow::internalPoints
Definition: internalPoints.hpp:38
pFlow::scatteredFieldAccess
Definition: scatteredFieldAccess.hpp:32
pFlow::message
Definition: message.hpp:33
pFlow::internalPoints::execution_space
typename PointsType::execution_space execution_space
Definition: internalPoints.hpp:54
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::internalPoints::TypeInfo
TypeInfo("internalPoints")
pFlow::pointFlag::activeRange_
rangeU32 activeRange_
Definition: pointFlag.hpp:66
pFlow::realx3Field_D
Field< realx3 > realx3Field_D
Definition: Fields.hpp:65
pFlow::internalPoints::unSyncFlag
void unSyncFlag()
Definition: internalPoints.hpp:92
pFlow::Range::end
INLINE_FUNCTION_HD T & end()
End.
Definition: Range.hpp:101
pFlow::internalPoints::pointPosition
const PointsType & pointPosition() const
Definition: internalPoints.cpp:209
pFlow::internalPoints::pointPositionHost
auto pointPositionHost() const
Definition: internalPoints.hpp:153
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::internalPoints::deletePoints
bool deletePoints(const uint32Vector_D &delPoints)
Definition: internalPoints.cpp:37
pFlow::pointFlag::numActive
INLINE_FUNCTION_HD auto numActive() const
Definition: pointFlag.hpp:191
pFlow::internalPoints::pointPosition_
PointsType pointPosition_
Position of points on device.
Definition: internalPoints.hpp:65
pFlow::internalPoints::fillNeighborsLists
void fillNeighborsLists(ViewType1D< uint32, memory_space > leftList, ViewType1D< uint32, memory_space > rightList, ViewType1D< uint32, memory_space > bottomList, ViewType1D< uint32, memory_space > topList, ViewType1D< uint32, memory_space > rearList, ViewType1D< uint32, memory_space > frontList)
Definition: internalPoints.cpp:291
Vectors.hpp
pFlow::internalPoints::pFlagSync_
bool pFlagSync_
if both host and device flags sync
Definition: internalPoints.hpp:74
pFlow::internalPoints::pointPositionDevice
auto pointPositionDevice() const
Definition: internalPoints.hpp:159
pFlow::Field< realx3 >
pFlow::subscriber
Definition: subscriber.hpp:37
pFlow
Definition: demGeometry.hpp:27
VectorSingles.hpp
pFlow::VectorSingle::deviceView
INLINE_FUNCTION_H auto deviceView() const
Device view range [0, size)
Definition: VectorSingle.cpp:263
pFlow::internalPoints::boundary
virtual boundaryBase & boundary(size_t boundaryIndex)=0
pFlow::internalPoints::activeRange
auto activeRange() const
Definition: internalPoints.hpp:201
pFlow::anyList
Definition: anyList.hpp:35
pFlow::VectorSingle< realx3, void >::device_type
typename viewType::device_type device_type
Definition: VectorSingle.hpp:72
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::internalPoints::numActive
uint32 numActive() const
Definition: internalPoints.hpp:188
pFlow::internalPoints::activePointsMaskDevice
const pFlagTypeDevice & activePointsMaskDevice() const
Definition: internalPoints.cpp:194
pFlow::VectorSingle::hostView
INLINE_FUNCTION_H auto hostView() const
Return a view accessible on Host in range [0,size)
Definition: VectorSingle.cpp:281
Fields.hpp
pFlow::internalPoints::changePointsFlagPosition
bool changePointsFlagPosition(const uint32Vector_D &changePoints, realx3 transferVector, uint32 fromBoundaryIndex, uint32 toBoundaryIndex)
Definition: internalPoints.cpp:92
pFlow::internalPoints::operator=
internalPoints & operator=(const internalPoints &)=delete
No Copy assignment.
pFlow::internalPoints::empty
bool empty() const
Definition: internalPoints.hpp:181
pFlow::internalPoints::PointsTypeHost
typename PointsType::FieldTypeHost PointsTypeHost
Definition: internalPoints.hpp:48
pFlow::internalPoints::sortPoints
bool sortPoints(const uint32IndexContainer &sortedIndices)
Definition: internalPoints.cpp:145
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::pointFlag::isAllActive
INLINE_FUNCTION_HD bool isAllActive() const
Definition: pointFlag.hpp:173
pFlow::internalPoints::time
virtual Time & time()=0
pFlow::boundaryBase
Definition: boundaryBase.hpp:42
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::internalPoints::boundaryBase
friend boundaryBase
Definition: internalPoints.hpp:60
pFlow::pointFlag::activeRange
const INLINE_FUNCTION_HD auto & activeRange() const
Definition: pointFlag.hpp:179
pFlow::internalPoints::pFlagsH_
pFlagTypeHost pFlagsH_
flag of points on host
Definition: internalPoints.hpp:71
pFlow::VectorSingle< uint32 >
pFlow::internalPoints::updateFlag
uint32 updateFlag(const domain &dm, const std::array< real, 6 > &dist)
Definition: internalPoints.cpp:271
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::internalPoints::insertPoints
bool insertPoints(const realx3Vector &points, anyList &varList)
Definition: internalPoints.cpp:311
pFlow::internalPoints::device_type
typename PointsType::device_type device_type
Definition: internalPoints.hpp:50
pFlow::ViewType1D
Kokkos::View< T *, properties... > ViewType1D
1D veiw as a vector
Definition: KokkosTypes.hpp:93
pFlow::internalPoints::size
uint32 size() const
Definition: internalPoints.hpp:168
pFlow::internalPoints::syncPFlag
void syncPFlag() const
Definition: internalPoints.cpp:28
pFlow::internalPoints::memory_space
typename PointsType::memory_space memory_space
Definition: internalPoints.hpp:52
pFlow::internalPoints::PointsType
realx3Field_D PointsType
Definition: internalPoints.hpp:46
pFlow::internalPoints::read
bool read(iIstream &is)
Read.
Definition: internalPoints.cpp:530
pFlow::internalPoints::~internalPoints
~internalPoints() override=default
Destructor.
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::internalPoints::createDeviceFlag
void createDeviceFlag(uint32 cap, uint32 start, uint32 end)
Definition: internalPoints.hpp:98
pFlow::internalPoints::write
bool write(iOstream &os) const
Write.
Definition: internalPoints.cpp:556
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
pFlow::domain
Definition: domain.hpp:31
pFlow::internalPoints::insertPointsOnly
bool insertPointsOnly(const realx3Vector_D &points, message &msg, anyList &varList)
Definition: internalPoints.cpp:427
pFlow::internalPoints::initialCapacity_
static const uint32 initialCapacity_
Definition: internalPoints.hpp:44
pFlow::internalPoints::activePointsMaskHost
const pFlagTypeHost & activePointsMaskHost() const
Definition: internalPoints.cpp:201
pFlow::triple< real >
pFlow::Field< realx3 >::memory_space
typename VectorType::memory_space memory_space
Definition: Field.hpp:48
pFlow::Vector< realx3 >
pFlow::pFlagTypeDevice
pointFlag< DefaultExecutionSpace > pFlagTypeDevice
Definition: pointFlag.hpp:387
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::Field< realx3 >::FieldTypeHost
Field< realx3, HostSpace > FieldTypeHost
Definition: Field.hpp:46
pFlow::internalPoints::internalPoints
internalPoints()
Definition: internalPoints.cpp:159
pFlow::Field< realx3 >::execution_space
typename VectorType::execution_space execution_space
Definition: Field.hpp:50
pFlow::pointFlag< DefaultExecutionSpace >
pFlow::indexContainer
It holds two vectors of indecis on Host and Device.
Definition: indexContainer.hpp:39
pFlow::internalPoints::capacity
uint32 capacity() const
Definition: internalPoints.hpp:175
pointFlag.hpp
pFlow::Time
Definition: Time.hpp:37