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

selectorStridedRange.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 "selectorStridedRange.hpp"
#include "dictionary.hpp"
void
pFlow::selectorStridedRange::selectAllPointsInRange()
{
// to reduct allocations
uint32 maxNum = (end_ - begin_) / stride_ + 2;
selectedPoints_.reserve(maxNum);
selectedPoints_.clear();
for (uint32 i = begin_; i < end_; i += stride_)
{
selectedPoints_.push_back(i);
}
}
pFlow::selectorStridedRange::selectorStridedRange(
const pointStructure& pStruct,
const dictionary& dict
)
: selectorStridedRange(
"stridedRange",
pStruct,
dict.subDict("stridedRangeInfo")
)
{
}
pFlow::selectorStridedRange::selectorStridedRange(
const word& type,
const pointStructure& pStruct,
const dictionary& dict
)
: pStructSelector(type, pStruct, dict),
begin_(dict.getVal<uint32>("begin")),
end_(dict.getValOrSet<uint32>("end", pStruct.size())),
stride_(dict.getValOrSet<uint32>("stride", 1u))
{
begin_ = max(begin_, 1u);
end_ = min(end_, static_cast< uint32 >(pStruct.size()));
stride_ = max(stride_, 1u);
selectAllPointsInRange();
}
pFlow::selectorStridedRange::end_
uint32 end_
Definition: selectorStridedRange.hpp:46
selectorStridedRange.hpp
pFlow::selectorStridedRange::selectAllPointsInRange
void selectAllPointsInRange()
Definition: selectorStridedRange.cpp:25
pFlow::Vector::reserve
void reserve(size_t cap)
Reserve capacity for vector Preserve the content.
Definition: Vector.hpp:284
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::max
T max(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:79
pFlow::selectorStridedRange::stride_
uint32 stride_
Definition: selectorStridedRange.hpp:49
pFlow::pointStructure
Definition: pointStructure.hpp:34
dictionary.hpp
pFlow::pStructSelector::pStruct
const pointStructure & pStruct() const
Definition: pStructSelector.cpp:45
pFlow::min
T min(const internalField< T, MemorySpace > &iField)
Definition: internalFieldAlgorithms.hpp:28
pFlow::selectorStridedRange::begin_
uint32 begin_
Definition: selectorStridedRange.hpp:43
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::internalPoints::size
uint32 size() const
Definition: internalPoints.hpp:168
pFlow::pStructSelector
Definition: pStructSelector.hpp:36
pFlow::selectorStridedRange::selectorStridedRange
selectorStridedRange(const pointStructure &pStruct, const dictionary &dict)
Definition: selectorStridedRange.cpp:40
pFlow::selectorStridedRange::selectedPoints_
uint32Vector selectedPoints_
Definition: selectorStridedRange.hpp:40
pFlow::selectorStridedRange
Definition: selectorStridedRange.hpp:34
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67