ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
src
data
aslBlocks.h
Go to the documentation of this file.
1
/*
2
* Advanced Simulation Library <http://asl.org.il>
3
*
4
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5
*
6
*
7
* This file is part of Advanced Simulation Library (ASL).
8
*
9
* ASL is free software: you can redistribute it and/or modify it
10
* under the terms of the GNU Affero General Public License as
11
* published by the Free Software Foundation, version 3 of the License.
12
*
13
* ASL is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
17
*
18
* You should have received a copy of the GNU Affero General Public License
19
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
20
*
21
*/
22
23
24
#ifndef ASLBLOCKS_H
25
#define ASLBLOCKS_H
26
27
#include <iostream>
28
#include <fstream>
29
#include "
../math/aslVectors.h
"
30
31
namespace
acl
32
{
33
class
VectorOfElements
;
34
}
35
36
namespace
asl
37
{
38
40
class
Box
41
{
42
public
:
43
typedef
AVec<>
V
;
44
V
size
;
45
V
position
;
46
48
inline
explicit
Box
(
unsigned
int
nd);
49
};
50
51
56
class
Block
57
{
58
public
:
59
typedef
AVec<int>
DV
;
60
private
:
61
DV
size;
62
public
:
63
typedef
AVec<>
V
;
64
65
V
position
;
66
double
dx
;
67
DV
c2iTransformVector
;
68
70
inline
Block
();
71
inline
explicit
Block
(
unsigned
int
nd);
72
inline
Block
(
const
DV
& s,
double
dx
,
const
V
& p);
73
inline
explicit
Block
(
const
DV
& s,
double
dx
= 1);
74
inline
Block
(
const
Block
& b);
75
inline
const
Block
&
operator=
(
const
Block
& b);
77
int
c2i
(
const
Block::DV
& c)
const
;
78
inline
void
setSize
(
const
DV
& s);
79
inline
const
DV
&
getSize
()
const
;
82
inline
const
V
getBPosition
()
const
;
83
acl::VectorOfElements
initACLPositionDiscrete
();
84
acl::VectorOfElements
initACLPosition
();
85
86
acl::VectorOfElements
getACLPositionDiscrete
();
87
acl::VectorOfElements
getACLPosition
();
88
};
89
90
93
const
Block
offset
(
const
Block
& bl,
int
a = 1);
94
95
98
inline
const
unsigned
int
nD
(
const
Block
& b);
99
102
inline
const
bool
in
(
const
Block
& b,
AVec<>
a);
103
106
inline
const
bool
in
(
const
Block
& b,
AVec<int>
a);
107
108
109
inline
const
AVec<int>
continiousToDiscret
(
const
Block
& b,
AVec<>
a);
110
111
//--------------- Implementation----------------
112
113
inline
Box::Box
(
unsigned
int
nd):
size
(nd),
position
(nd)
114
{
115
}
116
117
118
inline
AVec<int>
castTransformVector
(
AVec<int>
s)
119
{
120
unsigned
int
n(s.
getSize
());
121
AVec<int>
r(n, 1);
122
int
a(1);
123
for
(
unsigned
int
i = 0; i < n - 1; ++i)
124
{
125
a *= s[n - 1 - i];
126
r[n - 2 - i] = a;
127
}
128
return
r;
129
}
130
131
132
inline
Block::Block
(
unsigned
int
nd):
133
size(nd),
134
position
(nd),
135
dx
(1),
136
c2iTransformVector
(
castTransformVector
(size))
137
{
138
}
139
140
141
inline
Block::Block
():
142
size(1),
143
position
(1,0.),
144
dx
(1),
145
c2iTransformVector
(
castTransformVector
(size))
146
{
147
}
148
149
150
inline
Block::Block
(
const
Block::DV
& s,
double
d):
151
size(s),
152
position
(
V
(s.
getSize
())),
153
dx
(d),
154
c2iTransformVector
(
castTransformVector
(s))
155
{
156
}
157
158
159
inline
Block::Block
(
const
Block::DV
& s,
double
d,
const
Block::V
& p):
160
size(s),
161
position
(p),
162
dx
(d),
163
c2iTransformVector
(
castTransformVector
(s))
164
{
165
if
(p.
getSize
() != s.
getSize
())
166
errorMessage
(
"Block::Block() Size and Position dimensionalities are different"
);
167
}
168
169
170
inline
Block::Block
(
const
Block
& b):
171
size(b.size),
172
position
(b.
position
),
173
dx
(b.
dx
),
174
c2iTransformVector
(b.
c2iTransformVector
)
175
{
176
}
177
178
179
inline
const
Block
&
Block::operator=
(
const
Block
& b)
180
{
181
position
=b.
position
;
182
size = b.size;
183
dx
= b.
dx
;
184
c2iTransformVector
= b.
c2iTransformVector
;
185
return
*
this
;
186
}
187
188
189
inline
int
Block::c2i
(
const
DV
& c)
const
190
{
191
unsigned
int
n(
c2iTransformVector
.getSize());
192
if
(c.
getSize
() != n)
193
errorMessage
(
"Block::c2i() - The input vector size does not correspond to the block dimensionality"
);
194
195
return
c *
c2iTransformVector
;
196
}
197
198
199
inline
void
Block::setSize
(
const
DV
& s)
200
{
201
size = s;
202
if
(
position
.getSize()!= s.
getSize
())
203
position
=
V
(s.
getSize
());
204
c2iTransformVector
=
castTransformVector
(s);
205
}
206
207
208
inline
const
Block::DV
&
Block::getSize
()
const
209
{
210
return
size;
211
}
212
213
214
inline
const
Block::V
Block::getBPosition
()
const
215
{
216
return
position
+ (
V
(size -
DV
(size.getSize(), 1.)) ) *
dx
;
217
}
218
219
220
inline
const
unsigned
int
nD
(
const
Block
& b)
221
{
222
return
b.
position
.
getSize
();
223
}
224
225
226
inline
const
bool
in
(
const
Block
& b,
AVec<>
a)
227
{
228
return
positive
(a-b.
position
) &&
positive
(b.
getBPosition
() - a);
229
}
230
231
232
inline
const
bool
in
(
const
Block
& b,
AVec<int>
a)
233
{
234
return
positive
(a) &&
positive
(b.
getSize
() - a);
235
}
236
237
}
//asl
238
239
#endif
//ASLBLOCKS_H
240
aslVectors.h
definition of class АVec<T>
acl::VectorOfElements
The class represents several Element.
Definition
aclVectorOfElementsDef.h:92
asl::AVec
Definition
aslVectorsDynamicLength.h:40
asl::AVec::getSize
const unsigned int & getSize() const
Definition
aslVectorsDynamicLength.h:171
asl::Block
Definition
aslBlocks.h:57
asl::Block::getACLPositionDiscrete
acl::VectorOfElements getACLPositionDiscrete()
asl::Block::dx
double dx
Definition
aslBlocks.h:66
asl::Block::DV
AVec< int > DV
Discrete Vector.
Definition
aslBlocks.h:59
asl::Block::getBPosition
const V getBPosition() const
Definition
aslBlocks.h:214
asl::Block::getSize
const DV & getSize() const
Definition
aslBlocks.h:208
asl::Block::initACLPosition
acl::VectorOfElements initACLPosition()
asl::Block::setSize
void setSize(const DV &s)
Definition
aslBlocks.h:199
asl::Block::Block
Block()
the size is taken 1, the position is taken to be 0
Definition
aslBlocks.h:141
asl::Block::c2i
int c2i(const Block::DV &c) const
defines convertion rule of 1D/2D/3D index i into container one
Definition
aslBlocks.h:189
asl::Block::position
V position
Definition
aslBlocks.h:65
asl::Block::operator=
const Block & operator=(const Block &b)
Definition
aslBlocks.h:179
asl::Block::getACLPosition
acl::VectorOfElements getACLPosition()
asl::Block::initACLPositionDiscrete
acl::VectorOfElements initACLPositionDiscrete()
asl::Block::V
AVec V
Type of the position.
Definition
aslBlocks.h:63
asl::Block::c2iTransformVector
DV c2iTransformVector
Definition
aslBlocks.h:67
asl::Box::V
AVec V
Type of a vector.
Definition
aslBlocks.h:43
asl::Box::Box
Box(unsigned int nd)
the size and position are taken 0
Definition
aslBlocks.h:113
asl::Box::position
V position
Definition
aslBlocks.h:45
asl::Box::size
V size
Definition
aslBlocks.h:44
asl::nD
const unsigned int nD(const Block &b)
Definition
aslBlocks.h:220
asl::offset
const Block offset(const Block &bl, int a=1)
asl::errorMessage
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
acl
Advanced Computational Language.
Definition
acl.h:41
asl
Advanced Simulation Library.
Definition
aslDataInc.h:31
asl::in
bool in(const T &xx, const T &x1, const T &x2)
Checks the belonging to a closed interval [x1,x2], .
Definition
aslUtilities.h:84
asl::castTransformVector
AVec< int > castTransformVector(AVec< int > s)
Definition
aslBlocks.h:118
asl::continiousToDiscret
const AVec< int > continiousToDiscret(const Block &b, AVec<> a)
asl::positive
const bool positive(const AVec< T > &a)
Definition
aslVectorsDynamicLengthOperations.h:345
Generated by
1.17.0