ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
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.3, lbmpy v1.3.3, lbmpy_walberla/pystencils_walberla from waLBerla commit b0842e1a493ce19ef1bbb8d2cf382fc343970a7f
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 byte_buffer += sizeof(double) - (reinterpret_cast<std::size_t>(byte_buffer) - (reinterpret_cast<std::size_t>(byte_buffer) / sizeof(double)) * sizeof(double));
71 double *buffer = reinterpret_cast<double *>(byte_buffer);
72
73 auto field = block->getData<field::GhostLayerField<double, 3>>(fieldID);
74
75 CellInterval ci;
76 field->getSliceBeforeGhostLayer(dir, ci, 1, false);
77
78 switch (dir) {
79 case stencil::SW:
80 case stencil::BW:
81 case stencil::W:
82 case stencil::TW:
83 case stencil::NW:
84 case stencil::BS:
85 case stencil::S:
86 case stencil::TS:
87 case stencil::B:
88 case stencil::C:
89 case stencil::T:
90 case stencil::BN:
91 case stencil::N:
92 case stencil::TN:
93 case stencil::SE:
94 case stencil::BE:
95 case stencil::E:
96 case stencil::TE:
97 case stencil::NE: {
98 double *RESTRICT _data_buffer = buffer;
99 WALBERLA_ASSERT_GREATER_EQUAL(ci.xMin(), -int_c(field->nrOfGhostLayers()))
100 WALBERLA_ASSERT_GREATER_EQUAL(ci.yMin(), -int_c(field->nrOfGhostLayers()))
101 WALBERLA_ASSERT_GREATER_EQUAL(ci.zMin(), -int_c(field->nrOfGhostLayers()))
102 double *RESTRICT const _data_field = field->dataAt(ci.xMin(), ci.yMin(), ci.zMin(), 0);
103 WALBERLA_ASSERT_GREATER_EQUAL(field->xSizeWithGhostLayer(), int64_t(int64_c(ci.xSize()) + 0))
104 const int64_t _size_field_0 = int64_t(int64_c(ci.xSize()) + 0);
105 WALBERLA_ASSERT_GREATER_EQUAL(field->ySizeWithGhostLayer(), int64_t(int64_c(ci.ySize()) + 0))
106 const int64_t _size_field_1 = int64_t(int64_c(ci.ySize()) + 0);
107 WALBERLA_ASSERT_GREATER_EQUAL(field->zSizeWithGhostLayer(), int64_t(int64_c(ci.zSize()) + 0))
108 const int64_t _size_field_2 = int64_t(int64_c(ci.zSize()) + 0);
109 const int64_t _stride_field_0 = int64_t(field->xStride());
110 const int64_t _stride_field_1 = int64_t(field->yStride());
111 const int64_t _stride_field_2 = int64_t(field->zStride());
112 const int64_t _stride_field_3 = int64_t(1 * int64_t(field->fStride()));
113 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);
114 break;
115 }
116
117 default:
118 WALBERLA_ASSERT(false);
119 }
120}
121
122void PackInfoVecDoublePrecision::unpack(Direction dir, unsigned char *byte_buffer, IBlock *block) const {
123 byte_buffer += sizeof(double) - (reinterpret_cast<std::size_t>(byte_buffer) - (reinterpret_cast<std::size_t>(byte_buffer) / sizeof(double)) * sizeof(double));
124 double *buffer = reinterpret_cast<double *>(byte_buffer);
125
126 auto field = block->getData<field::GhostLayerField<double, 3>>(fieldID);
127
128 CellInterval ci;
129 field->getGhostRegion(dir, ci, 1, false);
130 auto communciationDirection = stencil::inverseDir[dir];
131
132 switch (communciationDirection) {
133 case stencil::SW:
134 case stencil::BW:
135 case stencil::W:
136 case stencil::TW:
137 case stencil::NW:
138 case stencil::BS:
139 case stencil::S:
140 case stencil::TS:
141 case stencil::B:
142 case stencil::C:
143 case stencil::T:
144 case stencil::BN:
145 case stencil::N:
146 case stencil::TN:
147 case stencil::SE:
148 case stencil::BE:
149 case stencil::E:
150 case stencil::TE:
151 case stencil::NE: {
152 double *RESTRICT const _data_buffer = buffer;
153 WALBERLA_ASSERT_GREATER_EQUAL(ci.xMin(), -int_c(field->nrOfGhostLayers()))
154 WALBERLA_ASSERT_GREATER_EQUAL(ci.yMin(), -int_c(field->nrOfGhostLayers()))
155 WALBERLA_ASSERT_GREATER_EQUAL(ci.zMin(), -int_c(field->nrOfGhostLayers()))
156 double *RESTRICT _data_field = field->dataAt(ci.xMin(), ci.yMin(), ci.zMin(), 0);
157 WALBERLA_ASSERT_GREATER_EQUAL(field->xSizeWithGhostLayer(), int64_t(int64_c(ci.xSize()) + 0))
158 const int64_t _size_field_0 = int64_t(int64_c(ci.xSize()) + 0);
159 WALBERLA_ASSERT_GREATER_EQUAL(field->ySizeWithGhostLayer(), int64_t(int64_c(ci.ySize()) + 0))
160 const int64_t _size_field_1 = int64_t(int64_c(ci.ySize()) + 0);
161 WALBERLA_ASSERT_GREATER_EQUAL(field->zSizeWithGhostLayer(), int64_t(int64_c(ci.zSize()) + 0))
162 const int64_t _size_field_2 = int64_t(int64_c(ci.zSize()) + 0);
163 const int64_t _stride_field_0 = int64_t(field->xStride());
164 const int64_t _stride_field_1 = int64_t(field->yStride());
165 const int64_t _stride_field_2 = int64_t(field->zStride());
166 const int64_t _stride_field_3 = int64_t(1 * int64_t(field->fStride()));
167 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);
168 break;
169 }
170
171 default:
172 WALBERLA_ASSERT(false);
173 }
174}
175
176uint_t PackInfoVecDoublePrecision::size(stencil::Direction dir, const IBlock *block) const {
177 auto field = block->getData<field::GhostLayerField<double, 3>>(fieldID);
178
179 CellInterval ci;
180 field->getGhostRegion(dir, ci, 1, false);
181
182 uint_t elementsPerCell = 0;
183
184 switch (dir) {
185 case stencil::SW:
186 case stencil::BW:
187 case stencil::W:
188 case stencil::TW:
189 case stencil::NW:
190 case stencil::BS:
191 case stencil::S:
192 case stencil::TS:
193 case stencil::B:
194 case stencil::C:
195 case stencil::T:
196 case stencil::BN:
197 case stencil::N:
198 case stencil::TN:
199 case stencil::SE:
200 case stencil::BE:
201 case stencil::E:
202 case stencil::TE:
203 case stencil::NE:
204 elementsPerCell = 3;
205 break;
206
207 default:
208 elementsPerCell = 0;
209 }
210 return ci.numCells() * elementsPerCell * sizeof(double);
211}
212
213} // namespace pystencils
214} // 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