| kspaceFirstOrder3D-OMP 1.1 The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Friends Pages
DimensionSizes.h
Go to the documentation of this file.
1 /**
2 * @file DimensionSizes.h
3 * @author Jiri Jaros \n
4 * Faculty of Information Technology\n
5 * Brno University of Technology \n
6 * jarosjir@fit.vutbr.cz
7 *
8 * @brief The header file containing the structure with 3D dimension sizes
9 *
10 * @version kspaceFirstOrder3D 2.15
11 *
12 * @date 09 August 2011, 12:34 (created) \n
13 * 29 September 2014, 13:10 (revised)
14 *
15 * @section License
16 * This file is part of the C++ extension of the k-Wave Toolbox (http://www.k-wave.org).\n
17 * Copyright (C) 2014 Jiri Jaros and Bradley Treeby
18 *
19 * This file is part of k-Wave. k-Wave is free software: you can redistribute it
20 * and/or modify it under the terms of the GNU Lesser General Public License as
21 * published by the Free Software Foundation, either version 3 of the License,
22 * or (at your option) any later version.
23 *
24 * k-Wave is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 * See the GNU Lesser General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public License
30 * along with k-Wave. If not, see <http://www.gnu.org/licenses/>.
31 */
32
33
34 #ifndef DIMENSIONSIZES_H
35 #define DIMENSIONSIZES_H
36
37 #include <stdlib.h>
38 #include <stdio.h>
39
40 using namespace std;
41
42 #ifdef __AVX__
43 /**
44 * @var DATA_ALIGNMENT
45 * @brief memory alignment for AVX(32B)
46 */
47 const int DATA_ALIGNMENT = 32;
48 #else
49
50 /**
51 * @var DATA_ALIGNMENT
52 * @brief memory alignment for SSE, SSE2, SSE3, SSE4 (16B)
53 */const int DATA_ALIGNMENT = 16;
54 #endif
55
56 /**
57 * @struct TDimensionSizes
58 * @brief Structure with 4D dimension sizes (3 in space and 1 in time).
59 * @details Structure with 4D dimension sizes (3 in space and 1 in time).
60 * The structure can be used for 3D (the time is then set to 1). \n
61 * The structure contains only POD, so no C++ stuff is necessary.
62 */
63 struct TDimensionSizes
64 {
65 /// X dimension size.
66 size_t X;
67 /// Y dimension size.
68 size_t Y;
69 /// Z dimension size.
70 size_t Z;
71 /// Number of time steps (for time series datasets).
72 size_t T;
73
74 /// Default constructor.
75 TDimensionSizes() : X(0), Y(0), Z(0), T(0) {};
76
77 /**
78 * @brief Constructor.
79 * @param [in] x, y, z, t - Three spatial dimesnions and time.
80 */
81 TDimensionSizes(const size_t x,
82 const size_t y,
83 const size_t z,
84 const size_t t = 0)
85 : X(x), Y(y), Z(z), T(t)
86 { };
87
88 /**
89 * @brief Get element count, in 3D only spatial domain, in 4D with time.
90 * @details Get element count, in 3D only spatial domain, in 4D with time.
91 * @return spatial element count or number of elements over time.
92 */
93 size_t GetElementCount() const
94 {
95 if (Is3D()) return X * Y * Z;
96 else return X * Y * Z * T;
97 };
98
99 /// Is it a 3D object?
100 bool Is3D() const
101 {
102 return (T == 0);
103 }
104
105 /// Is it a 3D object with time?
106 bool Is4D() const
107 {
108 return (T > 0);
109 }
110
111 /**
112 * @brief Operator ==
113 * @param [in] other - the second operand to compare with
114 * @return true if ==
115 */
116 bool operator==(const TDimensionSizes &other) const
117 {
118 return ((X == other.X) && (Y == other.Y) && (Z == other.Z) && (T == other.T));
119 }
120
121 /**
122 * @brief Operator !=
123 * @param [in] other - the second operand to compare with
124 * @return true if !=
125 */
126 bool operator!=(const TDimensionSizes &other) const
127 {
128 return ((X != other.X) || (Y != other.Y) || (Z != other.Z) || (T != other.T));
129 }
130
131 /**
132 * @brief Operator -
133 * @details Get the size of the cube by subtracting two corners
134 * @param [in] op1 - usually bottom right corner
135 * @param [in] op2 - usually top left corner
136 * @return the size of the inner cuboid
137 */
138 inline friend TDimensionSizes operator-(const TDimensionSizes &op1,
139 const TDimensionSizes &op2)
140 {
141 // +1 because of planes (10.10.1 - 60.40.1)
142 if (op1.Is3D() && op2.Is3D())
143 {
144 return TDimensionSizes(op1.X - op2.X + 1,
145 op1.Y - op2.Y + 1,
146 op1.Z - op2.Z + 1);
147 }
148 else
149 {
150 return TDimensionSizes(op1.X - op2.X + 1,
151 op1.Y - op2.Y + 1,
152 op1.Z - op2.Z + 1,
153 op1.T - op2.T + 1);
154 }
155 }
156 }; // end of TDimensionSizes
157 //------------------------------------------------------------------------------
158 #endif /* DIMENSIONSIZES_H */
TDimensionSizes::Z
size_t Z
Z dimension size.
Definition: DimensionSizes.h:70
TDimensionSizes::operator!=
bool operator!=(const TDimensionSizes &other) const
Operator !=.
Definition: DimensionSizes.h:126
TDimensionSizes::operator-
friend TDimensionSizes operator-(const TDimensionSizes &op1, const TDimensionSizes &op2)
Operator -.
Definition: DimensionSizes.h:138
TDimensionSizes::X
size_t X
X dimension size.
Definition: DimensionSizes.h:66
TDimensionSizes::Is4D
bool Is4D() const
Is it a 3D object with time?
Definition: DimensionSizes.h:106
TDimensionSizes::GetElementCount
size_t GetElementCount() const
Get element count, in 3D only spatial domain, in 4D with time.
Definition: DimensionSizes.h:93
TDimensionSizes::operator==
bool operator==(const TDimensionSizes &other) const
Operator ==.
Definition: DimensionSizes.h:116
TDimensionSizes::Y
size_t Y
Y dimension size.
Definition: DimensionSizes.h:68
TDimensionSizes::T
size_t T
Number of time steps (for time series datasets).
Definition: DimensionSizes.h:72
TDimensionSizes::TDimensionSizes
TDimensionSizes()
Default constructor.
Definition: DimensionSizes.h:75
DATA_ALIGNMENT
const int DATA_ALIGNMENT
memory alignment for SSE, SSE2, SSE3, SSE4 (16B)
Definition: DimensionSizes.h:53
TDimensionSizes::TDimensionSizes
TDimensionSizes(const size_t x, const size_t y, const size_t z, const size_t t=0)
Constructor.
Definition: DimensionSizes.h:81
TDimensionSizes
Structure with 4D dimension sizes (3 in space and 1 in time).
Definition: DimensionSizes.h:63
TDimensionSizes::Is3D
bool Is3D() const
Is it a 3D object?
Definition: DimensionSizes.h:100