ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
FieldAccessorsDoublePrecisionCUDA.cuh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023-2025 The ESPResSo project
3 * Copyright (C) 2020 The waLBerla project
4 *
5 * This file is part of ESPResSo.
6 *
7 * ESPResSo is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * ESPResSo is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21// kernel generated with pystencils v1.3.7, lbmpy v1.3.7+4.gc7d65a7, sympy
22// v1.12.1, lbmpy_walberla/pystencils_walberla from waLBerla commit
23// 0aab9c0af2335b1f6fec75deae06e514ccb233ab
24
25/**
26 * @file
27 * Lattice field accessors.
28 * Adapted from the waLBerla source file
29 * https://i10git.cs.fau.de/walberla/walberla/-/blob/a16141524c58ab88386e2a0f8fdd7c63c5edd704/python/lbmpy_walberla/templates/LatticeModel.tmpl.h
30 */
31
32#pragma once
33
34#include <core/DataTypes.h>
35#include <core/cell/Cell.h>
36#include <core/cell/CellInterval.h>
37#include <core/math/Matrix3.h>
38#include <core/math/Vector3.h>
39
40#include <gpu/GPUField.h>
41
42#include <thrust/device_vector.h>
43
44#include <array>
45#include <tuple>
46#include <vector>
47
48namespace walberla {
49namespace lbm {
50namespace accessor {
51
52namespace Population {
53/** @brief Get populations from a single cell. */
54std::array<double, 19u> get(gpu::GPUField<double> const *pdf_field,
55 Cell const &cell);
56/** @brief Set populations on a single cell. */
57void set(gpu::GPUField<double> *pdf_field, std::array<double, 19u> const &pop,
58 Cell const &cell);
59/** @brief Set populations and recalculate velocities on a single cell. */
60void set(gpu::GPUField<double> *pdf_field,
61 gpu::GPUField<double> *velocity_field,
62 gpu::GPUField<double> const *force_field,
63 std::array<double, 19u> const &pop, Cell const &cell);
64/** @brief Initialize all cells with the same value. */
65void initialize(gpu::GPUField<double> *pdf_field,
66 std::array<double, 19u> const &pop);
67/** @brief Get populations from a cell interval. */
68std::vector<double> get(gpu::GPUField<double> const *pdf_field,
69 CellInterval const &ci);
70/** @brief Set populations on a cell interval. */
71void set(gpu::GPUField<double> *pdf_field, std::vector<double> const &values,
72 CellInterval const &ci);
73/** @brief Set populations and recalculate velocities on a cell interval. */
74void set(gpu::GPUField<double> *pdf_field,
75 gpu::GPUField<double> *velocity_field,
76 gpu::GPUField<double> const *force_field,
77 std::vector<double> const &values, CellInterval const &ci);
78} // namespace Population
79
80namespace Vector {
81/** @brief Get value from a single cell. */
82Vector3<double> get(gpu::GPUField<double> const *field, Cell const &cell);
83/** @brief Set value on a single cell. */
84void set(gpu::GPUField<double> *field, Vector3<double> const &vec,
85 Cell const &cell);
86/** @brief Add value to a single cell. */
87void add(gpu::GPUField<double> *field, Vector3<double> const &vec,
88 Cell const &cell);
89/** @brief Initialize all cells with the same value. */
90void initialize(gpu::GPUField<double> *field, Vector3<double> const &vec);
91/** @brief Add value to all cells. */
92void add_to_all(gpu::GPUField<double> *field, Vector3<double> const &vec);
93/** @brief Get values from a cell interval. */
94std::vector<double> get(gpu::GPUField<double> const *vec_field,
95 CellInterval const &ci);
96/** @brief Set values on a cell interval. */
97void set(gpu::GPUField<double> *vec_field, std::vector<double> const &values,
98 CellInterval const &ci);
99void set_from_list(gpu::GPUField<double> const *field,
100 thrust::device_vector<int> const &indices,
101 thrust::device_vector<double> const &values, uint gl);
102} // namespace Vector
103
104namespace Interpolation {
105std::vector<double> get_rho(gpu::GPUField<double> const *field,
106 std::vector<double> const &pos, double density,
107 uint gl);
108std::vector<double> get_vel(gpu::GPUField<double> const *field,
109 std::vector<double> const &pos, uint gl);
110void add_force(gpu::GPUField<double> const *field,
111 std::vector<double> const &pos,
112 std::vector<double> const &forces, uint gl);
113} // namespace Interpolation
114
115namespace Density {
116double get(gpu::GPUField<double> const *pdf_field, double density,
117 Cell const &cell);
118void set(gpu::GPUField<double> *pdf_field, double rho, double density,
119 Cell const &cell);
120std::vector<double> get(gpu::GPUField<double> const *pdf_field, double density,
121 CellInterval const &ci);
122void set(gpu::GPUField<double> *pdf_field, std::vector<double> const &values,
123 double density, CellInterval const &ci);
124} // namespace Density
125
126namespace Velocity {
127Vector3<double> get(gpu::GPUField<double> const *pdf_field,
128 gpu::GPUField<double> const *force_field, Cell const &cell);
129std::vector<double> get(gpu::GPUField<double> const *pdf_field,
130 gpu::GPUField<double> const *force_field,
131 CellInterval const &ci);
132void set(gpu::GPUField<double> *pdf_field,
133 gpu::GPUField<double> *velocity_field,
134 gpu::GPUField<double> const *force_field, Vector3<double> const &u,
135 Cell const &cell);
136void set(gpu::GPUField<double> *pdf_field,
137 gpu::GPUField<double> *velocity_field,
138 gpu::GPUField<double> const *force_field,
139 std::vector<double> const &values, CellInterval const &ci);
140} // namespace Velocity
141
142namespace Force {
143void set(gpu::GPUField<double> const *pdf_field,
144 gpu::GPUField<double> *velocity_field,
145 gpu::GPUField<double> *force_field, Vector3<double> const &u,
146 double density, Cell const &cell);
147void set(gpu::GPUField<double> const *pdf_field,
148 gpu::GPUField<double> *velocity_field,
149 gpu::GPUField<double> *force_field, std::vector<double> const &values,
150 double density, CellInterval const &ci);
151} // namespace Force
152
153namespace DensityAndVelocity {
154std::tuple<double, Vector3<double>>
155get(gpu::GPUField<double> const *pdf_field,
156 gpu::GPUField<double> const *force_field, Cell const &cell);
157void set(gpu::GPUField<double> *pdf_field, gpu::GPUField<double> *force_field,
158 Vector3<double> const &u, double rho, Cell const &cell);
159} // namespace DensityAndVelocity
160
161namespace DensityAndMomentumDensity {
162std::tuple<double, Vector3<double>>
163get(gpu::GPUField<double> const *pdf_field,
164 gpu::GPUField<double> const *force_field, Cell const &cell);
165} // namespace DensityAndMomentumDensity
166
167namespace MomentumDensity {
168Vector3<double> reduce(gpu::GPUField<double> const *pdf_field,
169 gpu::GPUField<double> const *force_field,
170 double density);
171} // namespace MomentumDensity
172
173namespace PressureTensor {
174Matrix3<double> get(gpu::GPUField<double> const *pdf_field, double density,
175 Cell const &cell);
176std::vector<double> get(gpu::GPUField<double> const *pdf_field, double density,
177 CellInterval const &ci);
178Matrix3<double> reduce(gpu::GPUField<double> const *pdf_field, double density);
179} // namespace PressureTensor
180
181} // namespace accessor
182} // namespace lbm
183} // namespace walberla
Definition Cell.hpp:96
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
std::tuple< double, Vector3< double > > get(gpu::GPUField< double > const *pdf_field, gpu::GPUField< double > const *force_field, Cell const &cell)
std::tuple< double, Vector3< double > > get(gpu::GPUField< double > const *pdf_field, gpu::GPUField< double > const *force_field, Cell const &cell)
void set(gpu::GPUField< double > *pdf_field, gpu::GPUField< double > *force_field, Vector3< double > const &u, double rho, Cell const &cell)
void set(GhostLayerField< double, uint_t{19u}> *pdf_field, double const rho_in, double const density, Cell const &cell)
double get(GhostLayerField< double, uint_t{19u}> const *pdf_field, double const density, Cell const &cell)
void set(GhostLayerField< double, uint_t{19u}> const *pdf_field, GhostLayerField< double, uint_t{3u}> *velocity_field, GhostLayerField< double, uint_t{3u}> *force_field, Vector3< double > const &force, double const density, Cell const &cell)
void add_force(gpu::GPUField< double > const *field, std::vector< double > const &pos, std::vector< double > const &forces, uint gl)
std::vector< double > get_rho(gpu::GPUField< double > const *field, std::vector< double > const &pos, double const density, uint gl)
std::vector< double > get_vel(gpu::GPUField< double > const *field, std::vector< double > const &pos, uint gl)
auto reduce(GhostLayerField< double, uint_t{19u}> const *pdf_field, GhostLayerField< double, uint_t{3u}> const *force_field, double const density)
void set(GhostLayerField< double, uint_t{19u}> *pdf_field, std::array< double, 19u > const &pop, Cell const &cell)
auto get(GhostLayerField< double, uint_t{19u}> const *pdf_field, Cell const &cell)
void initialize(GhostLayerField< double, uint_t{19u}> *pdf_field, std::array< double, 19u > const &pop)
auto get(GhostLayerField< double, uint_t{19u}> const *pdf_field, double const density, Cell const &cell)
auto reduce(GhostLayerField< double, uint_t{19u}> const *pdf_field, double const density)
void initialize(GhostLayerField< double, uint_t{3u}> *vec_field, Vector3< double > const &vec)
void set_from_list(gpu::GPUField< double > const *field, thrust::device_vector< int > const &indices, thrust::device_vector< double > const &values, uint gl)
void add(GhostLayerField< double, uint_t{3u}> *vec_field, Vector3< double > const &vec, Cell const &cell)
void set(GhostLayerField< double, uint_t{3u}> *vec_field, Vector3< double > const &vec, Cell const &cell)
auto get(GhostLayerField< double, uint_t{3u}> const *vec_field, Cell const &cell)
void add_to_all(GhostLayerField< double, uint_t{3u}> *vec_field, Vector3< double > const &vec)
void set(GhostLayerField< double, uint_t{19u}> *pdf_field, GhostLayerField< double, uint_t{3u}> *velocity_field, GhostLayerField< double, uint_t{3u}> const *force_field, Vector3< double > const &u, Cell const &cell)
auto get(GhostLayerField< double, uint_t{19u}> const *pdf_field, GhostLayerField< double, uint_t{3u}> const *force_field, Cell const &cell)
\file PackInfoPdfDoublePrecision.cpp \author pystencils