www.cemf.ir
baseShapeNames.hpp
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
#ifndef __baseShapeNames_hpp__
21
#define __baseShapeNames_hpp__
22
23
#include "
fileDictionary.hpp
"
24
#include "
Vectors.hpp
"
25
#include "
hashMap.hpp
"
26
27
28
namespace
pFlow
29
{
30
31
class
repository;
32
33
class
baseShapeNames
34
:
35
public
fileDictionary
36
{
37
private
:
38
39
size_t
numShapes_
= 0;
40
41
// - hashed list of spheres names
42
wordHashMap<uint32>
hashNames_
;
43
45
wordVector
shapeNames_
{
"shapeNames"
};
46
48
Vector<size_t>
hashes_
{
"hashes"
};
49
50
bool
createHashNames
();
51
52
bool
readFromDictionary1
();
53
54
using
hasher
=
typename
wordHashMap<uint32>::hasher
;
55
56
protected
:
57
58
virtual
59
bool
writeToDict
(
dictionary
&
dict
)
const
;
60
61
public
:
62
63
TypeInfo
(
"baseShapeNames"
);
64
65
baseShapeNames
(
66
const
word
& fileName,
67
repository
*
owner
);
68
69
~baseShapeNames
()
override
=
default
;
70
71
72
inline
73
const
wordVector
&
shapeNames
()
const
74
{
75
return
shapeNames_
;
76
}
77
78
inline
79
wordList
shapeNameList
()
const
80
{
81
wordList
wl;
82
wl.insert(wl.begin(),
shapeNames_
.begin(),
shapeNames_
.end());
83
return
wl;
84
}
85
86
inline
87
const
auto
&
hashes
()
const
88
{
89
return
hashes_
;
90
}
91
92
inline
93
size_t
numShapes
()
const
94
{
95
return
numShapes_
;
96
}
97
98
// name to index
99
inline
100
bool
shapeNameToIndex
(
const
word
&
name
,
uint32
& index)
const
101
{
102
if
(
auto
[iter, found] =
hashNames_
.findIf(
name
); found )
103
{
104
index = iter->second;
105
return
true
;
106
}
107
else
108
{
109
index = 0;
110
return
false
;
111
}
112
}
113
114
inline
115
bool
indexToShapeName
(
uint32
i,
word
&
name
)
const
116
{
117
if
( i <
numShapes_
)
118
{
119
name
=
shapeNames_
[i];
120
return
true
;
121
}
122
return
false
;
123
}
124
125
inline
bool
hashToIndex
(
const
size_t
& hs,
uint32
& idx)
126
{
127
for
(
auto
i=0; i<
hashes_
.
size
(); i++)
128
{
129
if
(
hashes_
[i]==hs)
130
{
131
idx = i;
132
return
true
;
133
}
134
}
135
idx =
static_cast<
uint32
>
(-1);
136
return
false
;
137
}
138
139
inline
140
bool
indexValid
(
uint32
index)
const
141
{
142
return
index <
numShapes_
;
143
}
144
145
// - IO
146
147
using
fileDictionary::write
;
148
149
bool
write
(
iOstream
& os)
const override
;
150
151
};
152
153
}
154
155
#endif //__shapeNames_hpp__
pFlow::baseShapeNames::numShapes_
size_t numShapes_
Definition:
baseShapeNames.hpp:39
pFlow::List< word >
pFlow::baseShapeNames::hashToIndex
bool hashToIndex(const size_t &hs, uint32 &idx)
Definition:
baseShapeNames.hpp:125
pFlow::baseShapeNames::hashes
const auto & hashes() const
Definition:
baseShapeNames.hpp:87
pFlow::baseShapeNames::hashNames_
wordHashMap< uint32 > hashNames_
Definition:
baseShapeNames.hpp:42
hashMap.hpp
pFlow::baseShapeNames::baseShapeNames
baseShapeNames(const word &fileName, repository *owner)
Definition:
baseShapeNames.cpp:59
pFlow::baseShapeNames::shapeNames
const wordVector & shapeNames() const
Definition:
baseShapeNames.hpp:73
pFlow::hashMap
Definition:
hashMap.hpp:36
pFlow::baseShapeNames
Definition:
baseShapeNames.hpp:33
pFlow::uint32
unsigned int uint32
Definition:
builtinTypes.hpp:56
pFlow::baseShapeNames::indexValid
bool indexValid(uint32 index) const
Definition:
baseShapeNames.hpp:140
pFlow::baseShapeNames::hashes_
Vector< size_t > hashes_
hash for names
Definition:
baseShapeNames.hpp:48
pFlow::word
std::string word
Definition:
builtinTypes.hpp:64
pFlow::baseShapeNames::shapeNameList
wordList shapeNameList() const
Definition:
baseShapeNames.hpp:79
pFlow::hashMap::hasher
typename hashmapType::hasher hasher
Definition:
hashMap.hpp:46
pFlow::Vector::size
auto size() const
Size of the vector.
Definition:
Vector.hpp:265
Vectors.hpp
pFlow::baseShapeNames::numShapes
size_t numShapes() const
Definition:
baseShapeNames.hpp:93
pFlow::baseShapeNames::~baseShapeNames
~baseShapeNames() override=default
pFlow::baseShapeNames::hasher
typename wordHashMap< uint32 >::hasher hasher
Definition:
baseShapeNames.hpp:54
pFlow
Definition:
demGeometry.hpp:27
pFlow::baseShapeNames::indexToShapeName
bool indexToShapeName(uint32 i, word &name) const
Definition:
baseShapeNames.hpp:115
pFlow::dictionary::dict
virtual dictionary & dict()
ref to this dictionary, if it is a dictionary
Definition:
dictionary.cpp:369
pFlow::baseShapeNames::readFromDictionary1
bool readFromDictionary1()
Definition:
baseShapeNames.cpp:48
pFlow::baseShapeNames::shapeNameToIndex
bool shapeNameToIndex(const word &name, uint32 &index) const
Definition:
baseShapeNames.hpp:100
pFlow::IOobject::owner
const repository * owner() const override
Definition:
IOobject.hpp:76
pFlow::baseShapeNames::createHashNames
bool createHashNames()
Definition:
baseShapeNames.cpp:23
pFlow::iEntry::name
virtual word name() const
name/keyword of entry
Definition:
iEntry.hpp:100
fileDictionary.hpp
pFlow::fileDictionary
Definition:
fileDictionary.hpp:29
pFlow::repository
Definition:
repository.hpp:34
pFlow::fileDictionary::write
bool write(iOstream &os, const IOPattern &iop) const override
write to stream
Definition:
fileDictionary.cpp:75
pFlow::baseShapeNames::shapeNames_
wordVector shapeNames_
list of shape names
Definition:
baseShapeNames.hpp:45
pFlow::baseShapeNames::write
bool write(iOstream &os) const override
write to stream
Definition:
baseShapeNames.cpp:105
pFlow::Vector< word >
pFlow::iOstream
Interface class for any output stream.
Definition:
iOstream.hpp:59
pFlow::baseShapeNames::writeToDict
virtual bool writeToDict(dictionary &dict) const
Definition:
baseShapeNames.cpp:92
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
pFlow::baseShapeNames::TypeInfo
TypeInfo("baseShapeNames")
src
Particles
particles
shape
baseShapeNames.hpp
Generated by
1.8.17