Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
PackInfoVecDoublePrecision.cpp
Go to the documentation of this file.
1//======================================================================================================================
2//
3// This file is part of waLBerla. waLBerla is free software: you can
4// redistribute it and/or modify it under the terms of the GNU General Public
5// License as published by the Free Software Foundation, either version 3 of
6// the License, or (at your option) any later version.
7//
8// waLBerla is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11// for more details.
12//
13// You should have received a copy of the GNU General Public License along
14// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
15//
16//! \\file PackInfoVecDoublePrecision.cpp
17//! \\author pystencils
18//======================================================================================================================
19
20// kernel generated with pystencils v1.3.7, lbmpy v1.3.7, sympy v1.12.1, lbmpy_walberla/pystencils_walberla from waLBerla commit f36fa0a68bae59f0b516f6587ea8fa7c24a41141
21
23#include "core/DataTypes.h"
24#include "core/cell/CellInterval.h"
25#include "stencil/Directions.h"
26
27#if (defined WALBERLA_CXX_COMPILER_IS_GNU) || (defined WALBERLA_CXX_COMPILER_IS_CLANG)
28#pragma GCC diagnostic push
29#pragma GCC diagnostic ignored "-Wfloat-equal"
30#pragma GCC diagnostic ignored "-Wshadow"
31#pragma GCC diagnostic ignored "-Wconversion"
32#pragma GCC diagnostic ignored "-Wunused-variable"
33#endif
34
35namespace walberla {
36namespace pystencils {
37
38using walberla::cell::CellInterval;
39using walberla::stencil::Direction;
40
41namespace internal_05a1eb9a7382e5e7047cdb22e28b6556 {
42static FUNC_PREFIX void pack_SW_BW_W_TW_NW_BS_S_TS_B_C_T_BN_N_TN_SE_BE_E_TE_NE(double *RESTRICT _data_buffer, double *RESTRICT const _data_field, int64_t const _size_field_0, int64_t const _size_field_1, int64_t const _size_field_2, int64_t const _stride_field_0, int64_t const _stride_field_1, int64_t const _stride_field_2, int64_t const _stride_field_3) {
43 for (int64_t ctr_2 = 0; ctr_2 < _size_field_2; ctr_2 += 1) {
44 for (int64_t ctr_1 = 0; ctr_1 < _size_field_1; ctr_1 += 1) {
45 for (int64_t ctr_0 = 0; ctr_0 < _size_field_0; ctr_0 += 1) {
46 _data_buffer[3 * _size_field_0 * _size_field_1 * ctr_2 + 3 * _size_field_0 * ctr_1 + 3 * ctr_0] = _data_field[_stride_field_0 * ctr_0 + _stride_field_1 * ctr_1 + _stride_field_2 * ctr_2];
47 _data_buffer[3 * _size_field_0 * _size_field_1 * ctr_2 + 3 * _size_field_0 * ctr_1 + 3 * ctr_0 + 1] = _data_field[_stride_field_0 * ctr_0 + _stride_field_1 * ctr_1 + _stride_field_2 * ctr_2 + _stride_field_3];
48 _data_buffer[3 * _size_field_0 * _size_field_1 * ctr_2 + 3 * _size_field_0 * ctr_1 + 3 * ctr_0 + 2] = _data_field[_stride_field_0 * ctr_0 + _stride_field_1 * ctr_1 + _stride_field_2 * ctr_2 + 2 * _stride_field_3];
49 }
50 }
51 }
52}
53} // namespace internal_05a1eb9a7382e5e7047cdb22e28b6556
54
55namespace internal_1ccccad4ca561e07a0934cadb07d0fc1 {
56static FUNC_PREFIX void unpack_SW_BW_W_TW_NW_BS_S_TS_B_C_T_BN_N_TN_SE_BE_E_TE_NE(double *RESTRICT const _data_buffer, double *RESTRICT _data_field, int64_t const _size_field_0, int64_t const _size_field_1, int64_t const _size_field_2, int64_t const _stride_field_0, int64_t const _stride_field_1, int64_t const _stride_field_2, int64_t const _stride_field_3) {
57 for (int64_t ctr_2 = 0; ctr_2 < _size_field_2; ctr_2 += 1) {
58 for (int64_t ctr_1 = 0; ctr_1 < _size_field_1; ctr_1 += 1) {
59 for (int64_t ctr_0 = 0; ctr_0 < _size_field_0; ctr_0 += 1) {
60 _data_field[_stride_field_0 * ctr_0 + _stride_field_1 * ctr_1 + _stride_field_2 * ctr_2] = _data_buffer[3 * _size_field_0 * _size_field_1 * ctr_2 + 3 * _size_field_0 * ctr_1 + 3 * ctr_0];
61 _data_field[_stride_field_0 * ctr_0 + _stride_field_1 * ctr_1 + _stride_field_2 * ctr_2 + _stride_field_3] = _data_buffer[3 * _size_field_0 * _size_field_1 * ctr_2 + 3 * _size_field_0 * ctr_1 + 3 * ctr_0 + 1];
62 _data_field[_stride_field_0 * ctr_0 + _stride_field_1 * ctr_1 + _stride_field_2 * ctr_2 + 2 * _stride_field_3] = _data_buffer[3 * _size_field_0 * _size_field_1 * ctr_2 + 3 * _size_field_0 * ctr_1 + 3 * ctr_0 + 2];
63 }
64 }
65 }
66}
67} // namespace internal_1ccccad4ca561e07a0934cadb07d0fc1
68
69void PackInfoVecDoublePrecision::pack(Direction dir, unsigned char *byte_buffer, IBlock *block) const {
70 double *buffer = reinterpret_cast<double *>(byte_buffer);
71
72 auto field = block->getData<field::GhostLayerField<double, 3>>(fieldID);
73
74 CellInterval ci;
75 field->getSliceBeforeGhostLayer(dir, ci, 1, false);
76
77 switch (dir) {
78 case stencil::SW:
79 case stencil::BW:
80 case stencil::W:
81 case stencil::TW:
82 case stencil::NW:
83 case stencil::BS:
84 case stencil::S:
85 case stencil::TS:
86 case stencil::B:
87 case stencil::C:
88 case stencil::T:
89 case stencil::BN:
90 case stencil::N:
91 case stencil::TN:
92 case stencil::SE:
93 case stencil::BE:
94 case stencil::E:
95 case stencil::TE:
96 case stencil::NE: {
97 double *RESTRICT _data_buffer = buffer;
98 WALBERLA_ASSERT_GREATER_EQUAL(ci.xMin(), -int_c(field->nrOfGhostLayers()))
99 WALBERLA_ASSERT_GREATER_EQUAL(ci.yMin(), -int_c(field->nrOfGhostLayers()))
100 WALBERLA_ASSERT_GREATER_EQUAL(ci.zMin(), -int_c(field->nrOfGhostLayers()))
101 double *RESTRICT const _data_field = field->dataAt(ci.xMin(), ci.yMin(), ci.zMin(), 0);
102 WALBERLA_ASSERT_GREATER_EQUAL(field->xSizeWithGhostLayer(), int64_t(int64_c(ci.xSize()) + 0))
103 const int64_t _size_field_0 = int64_t(int64_c(ci.xSize()) + 0);
104 WALBERLA_ASSERT_GREATER_EQUAL(field->ySizeWithGhostLayer(), int64_t(int64_c(ci.ySize()) + 0))
105 const int64_t _size_field_1 = int64_t(int64_c(ci.ySize()) + 0);
106 WALBERLA_ASSERT_GREATER_EQUAL(field->zSizeWithGhostLayer(), int64_t(int64_c(ci.zSize()) + 0))
107 const int64_t _size_field_2 = int64_t(int64_c(ci.zSize()) + 0);
108 const int64_t _stride_field_0 = int64_t(field->xStride());
109 const int64_t _stride_field_1 = int64_t(field->yStride());
110 const int64_t _stride_field_2 = int64_t(field->zStride());
111 const int64_t _stride_field_3 = int64_t(1 * int64_t(field->fStride()));
112 internal_05a1eb9a7382e5e7047cdb22e28b6556::pack_SW_BW_W_TW_NW_BS_S_TS_B_C_T_BN_N_TN_SE_BE_E_TE_NE(_data_buffer, _data_field, _size_field_0, _size_field_1, _size_field_2, _stride_field_0, _stride_field_1, _stride_field_2, _stride_field_3);
113 break;
114 }
115
116 default:
117 WALBERLA_ASSERT(false);
118 }
119}
120
121void PackInfoVecDoublePrecision::unpack(Direction dir, unsigned char *byte_buffer, IBlock *block) const {
122 double *buffer = reinterpret_cast<double *>(byte_buffer);
123
124 auto field = block->getData<field::GhostLayerField<double, 3>>(fieldID);
125
126 CellInterval ci;
127 field->getGhostRegion(dir, ci, 1, false);
128 auto communciationDirection = stencil::inverseDir[dir];
129
130 switch (communciationDirection) {
131 case stencil::SW:
132 case stencil::BW:
133 case stencil::W:
134 case stencil::TW:
135 case stencil::NW:
136 case stencil::BS:
137 case stencil::S:
138 case stencil::TS:
139 case stencil::B:
140 case stencil::C:
141 case stencil::T:
142 case stencil::BN:
143 case stencil::N:
144 case stencil::TN:
145 case stencil::SE:
146 case stencil::BE:
147 case stencil::E:
148 case stencil::TE:
149 case stencil::NE: {
150 double *RESTRICT const _data_buffer = buffer;
151 WALBERLA_ASSERT_GREATER_EQUAL(ci.xMin(), -int_c(field->nrOfGhostLayers()))
152 WALBERLA_ASSERT_GREATER_EQUAL(ci.yMin(), -int_c(field->nrOfGhostLayers()))
153 WALBERLA_ASSERT_GREATER_EQUAL(ci.zMin(), -int_c(field->nrOfGhostLayers()))
154 double *RESTRICT _data_field = field->dataAt(ci.xMin(), ci.yMin(), ci.zMin(), 0);
155 WALBERLA_ASSERT_GREATER_EQUAL(field->xSizeWithGhostLayer(), int64_t(int64_c(ci.xSize()) + 0))
156 const int64_t _size_field_0 = int64_t(int64_c(ci.xSize()) + 0);
157 WALBERLA_ASSERT_GREATER_EQUAL(field->ySizeWithGhostLayer(), int64_t(int64_c(ci.ySize()) + 0))
158 const int64_t _size_field_1 = int64_t(int64_c(ci.ySize()) + 0);
159 WALBERLA_ASSERT_GREATER_EQUAL(field->zSizeWithGhostLayer(), int64_t(int64_c(ci.zSize()) + 0))
160 const int64_t _size_field_2 = int64_t(int64_c(ci.zSize()) + 0);
161 const int64_t _stride_field_0 = int64_t(field->xStride());
162 const int64_t _stride_field_1 = int64_t(field->yStride());
163 const int64_t _stride_field_2 = int64_t(field->zStride());
164 const int64_t _stride_field_3 = int64_t(1 * int64_t(field->fStride()));
165 internal_1ccccad4ca561e07a0934cadb07d0fc1::unpack_SW_BW_W_TW_NW_BS_S_TS_B_C_T_BN_N_TN_SE_BE_E_TE_NE(_data_buffer, _data_field, _size_field_0, _size_field_1, _size_field_2, _stride_field_0, _stride_field_1, _stride_field_2, _stride_field_3);
166 break;
167 }
168
169 default:
170 WALBERLA_ASSERT(false);
171 }
172}
173
174uint_t PackInfoVecDoublePrecision::size(stencil::Direction dir, const IBlock *block) const {
175 auto field = block->getData<field::GhostLayerField<double, 3>>(fieldID);
176
177 CellInterval ci;
178 field->getGhostRegion(dir, ci, 1, false);
179
180 uint_t elementsPerCell = uint_t{0u};
181
182 switch (dir) {
183 case stencil::SW:
184 case stencil::BW:
185 case stencil::W:
186 case stencil::TW:
187 case stencil::NW:
188 case stencil::BS:
189 case stencil::S:
190 case stencil::TS:
191 case stencil::B:
192 case stencil::C:
193 case stencil::T:
194 case stencil::BN:
195 case stencil::N:
196 case stencil::TN:
197 case stencil::SE:
198 case stencil::BE:
199 case stencil::E:
200 case stencil::TE:
201 case stencil::NE:
202 elementsPerCell = uint_t{3u};
203 break;
204
205 default:
206 elementsPerCell = uint_t{0u};
207 }
208 return ci.numCells() * elementsPerCell * sizeof(double);
209}
210
211} // namespace pystencils
212} // namespace walberla
#define FUNC_PREFIX
\file AdvectiveFluxKernel_double_precision.cpp \author pystencils
#define RESTRICT
\file AdvectiveFluxKernel_double_precision.h \author pystencils
void pack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const
uint_t size(stencil::Direction dir, const IBlock *block) const
void unpack(stencil::Direction dir, unsigned char *buffer, IBlock *block) const
static double * block(double *p, std::size_t index, std::size_t size)
Definition elc.cpp:172
static FUNC_PREFIX void pack_SW_BW_W_TW_NW_BS_S_TS_B_C_T_BN_N_TN_SE_BE_E_TE_NE(double *RESTRICT _data_buffer, double *RESTRICT const _data_field, int64_t const _size_field_0, int64_t const _size_field_1, int64_t const _size_field_2, int64_t const _stride_field_0, int64_t const _stride_field_1, int64_t const _stride_field_2, int64_t const _stride_field_3)
static FUNC_PREFIX void unpack_SW_BW_W_TW_NW_BS_S_TS_B_C_T_BN_N_TN_SE_BE_E_TE_NE(double *RESTRICT const _data_buffer, double *RESTRICT _data_field, int64_t const _size_field_0, int64_t const _size_field_1, int64_t const _size_field_2, int64_t const _stride_field_0, int64_t const _stride_field_1, int64_t const _stride_field_2, int64_t const _stride_field_3)
\file PackInfoPdfDoublePrecision.cpp \author pystencils