www.cemf.ir
selectorStridedRange.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include "selectorStridedRange.hpp"
22 #include "dictionary.hpp"
23 
24 void
26 {
27  // to reduct allocations
28  uint32 maxNum = (end_ - begin_) / stride_ + 2;
29 
30  selectedPoints_.reserve(maxNum);
31 
32  selectedPoints_.clear();
33 
34  for (uint32 i = begin_; i < end_; i += stride_)
35  {
36  selectedPoints_.push_back(i);
37  }
38 }
39 
41  const pointStructure& pStruct,
42  const dictionary& dict
43 )
45  "stridedRange",
46  pStruct,
47  dict.subDict("stridedRangeInfo")
48  )
49 {
50 }
51 
53  const word& type,
54  const pointStructure& pStruct,
55  const dictionary& dict
56 )
57  : pStructSelector(type, pStruct, dict),
58  begin_(dict.getVal<uint32>("begin")),
59  end_(dict.getValOrSet<uint32>("end", pStruct.size())),
60  stride_(dict.getValOrSet<uint32>("stride", 1u))
61 {
62  begin_ = max(begin_, 1u);
63  end_ = min(end_, static_cast<uint32>(pStruct.size()));
64  stride_ = max(stride_, 1u);
65 
67 }
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