# PhasicFlow: src/phasicFlow/structuredData/pointStructure/selectors/selectRange/selectRange.cpp Source File

selectRange.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 "selectRange.hpp"
#include "dictionary.hpp"
void pFlow::selectRange::selectAllPointsInRange()
{
// to reduct allocations
int32 maxNum = (end_ - begin_)/stride_+2;
selectedPoints_.reserve (maxNum);
selectedPoints_.clear();
for(int32 i = begin_; i<end_; i+= stride_)
{
selectedPoints_.push_back(i);
}
}
pFlow::selectRange::selectRange
(
const pointStructure& pStruct,
const dictionary& dict
)
:
pStructSelector
(
pStruct, dict
),
begin_
(
dict.subDict("selectRangeInfo").getVal<int32>("begin")
),
end_
(
dict.subDict("selectRangeInfo").getValOrSet("end", pStruct.size())
),
stride_
(
dict.subDict("selectRangeInfo").getValOrSet("stride", 1)
)
{
begin_ = max(begin_,1);
end_ = min(end_, static_cast< int32 >(pStruct.size()));
stride_ = max(stride_,1);
selectAllPointsInRange();
}
pFlow::selectRange::selectAllPointsInRange
void selectAllPointsInRange()
Definition: selectRange.cpp:25
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
Definition: dictionary.hpp:325
pFlow::selectRange::selectRange
selectRange(const pointStructure &pStruct, const dictionary &dict)
Definition: selectRange.cpp:41
pFlow::pointStructure
Definition: pointStructure.hpp:44
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::selectRange::begin_
int32 begin_
Definition: selectRange.hpp:43
pFlow::selectRange::end_
int32 end_
Definition: selectRange.hpp:46
dictionary.hpp
pFlow::Vector::reserve
auto reserve(label len)
Definition: Vector.hpp:309
pFlow::dictionary::subDict
dictionary & subDict(const word &keyword)
Definition: dictionary.cpp:547
pFlow::max
T max(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:164
pStruct
auto & pStruct
Definition: setPointStructure.hpp:24
pFlow::dictionary::getVal
T getVal(const word &keyword) const
Definition: dictionary.hpp:309
pFlow::Vector::clear
auto clear()
Definition: Vector.hpp:248
pFlow::pStructSelector
Definition: pStructSelector.hpp:36
pFlow::selectRange::selectedPoints_
int32Vector selectedPoints_
Definition: selectRange.hpp:40
selectRange.hpp
pFlow::selectRange::stride_
int32 stride_
Definition: selectRange.hpp:49
pFlow::min
T min(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:138
pFlow::dictionary
Definition: dictionary.hpp:38