29#include <blockforest/Initialization.h>
30#include <blockforest/StructuredBlockForest.h>
31#include <blockforest/communication/UniformBufferedScheme.h>
32#include <domain_decomposition/BlockDataID.h>
33#include <domain_decomposition/IBlock.h>
34#include <field/AddToStorage.h>
35#include <field/GhostLayerField.h>
36#include <field/communication/PackInfo.h>
37#include <field/vtk/FlagFieldCellFilter.h>
38#include <field/vtk/VTKWriter.h>
39#include <stencil/D3Q19.h>
40#include <stencil/D3Q27.h>
41#if defined(__CUDACC__)
42#include <gpu/AddGPUFieldToStorage.h>
43#include <gpu/HostFieldAllocator.h>
44#include <gpu/communication/MemcpyPackInfo.h>
45#include <gpu/communication/UniformGPUScheme.h>
48#include "../BoundaryHandling.hpp"
49#include "../BoundaryPackInfo.hpp"
50#include "../utils/boundary.hpp"
51#include "../utils/types_conversion.hpp"
55#if defined(__CUDACC__)
75#include <initializer_list>
90template <
typename FloatType, lbmpy::Arch Architecture>
94 detail::KernelTrait<FloatType,
97 detail::KernelTrait<FloatType,
119 template <
typename FT, lbmpy::Arch AT = lbmpy::Arch::CPU>
struct FieldTrait {
120 using PdfField = field::GhostLayerField<FT, Stencil::Size>;
122 template <
class Field>
123 using PackInfo = field::communication::PackInfo<Field>;
126 template <
class Stencil>
128 blockforest::communication::UniformBufferedScheme<Stencil>;
129 template <
class Stencil>
131 blockforest::communication::UniformBufferedScheme<Stencil>;
134#if defined(__CUDACC__)
138 template <
class Field>
139 using MemcpyPackInfo = gpu::communication::MemcpyPackInfo<Field>;
142 template <
typename Stencil>
143 class UniformGPUScheme
144 :
public gpu::communication::UniformGPUScheme<Stencil> {
146 explicit UniformGPUScheme(
auto const &bf)
147 : gpu::communication::UniformGPUScheme<Stencil>(
153 template <
class Field>
using PackInfo = MemcpyPackInfo<Field>;
156 template <
class Stencil>
158 template <
class Stencil>
160 blockforest::communication::UniformBufferedScheme<Stencil>;
172#if defined(__CUDACC__)
173 using GPUField = gpu::GPUField<FloatType>;
191 return numeric_cast<FloatType>(t);
195 return static_cast<std::size_t
>(Stencil::Size);
199 return std::is_same_v<FloatType, double>;
203 class StreamCollideSweepVisitor {
208 cm.configure(m_storage, b);
213 cm.setV_s(
static_cast<decltype(cm.getV_s())
>(
214 m_lees_edwards_callbacks->get_shear_velocity()));
218 StreamCollideSweepVisitor() =
default;
219 StreamCollideSweepVisitor(std::shared_ptr<StructuredBlockStorage> storage) {
220 m_storage = std::move(storage);
222 StreamCollideSweepVisitor(std::shared_ptr<StructuredBlockStorage> storage,
223 std::shared_ptr<LeesEdwardsPack> callbacks) {
224 m_storage = std::move(storage);
225 m_lees_edwards_callbacks = std::move(callbacks);
229 std::shared_ptr<StructuredBlockStorage> m_storage{};
230 std::shared_ptr<LeesEdwardsPack> m_lees_edwards_callbacks{};
232 StreamCollideSweepVisitor m_run_stream_collide_sweep{};
234 FloatType shear_mode_relaxation_rate()
const {
235 return FloatType{2} / (FloatType{6} *
m_viscosity + FloatType{1});
238 FloatType odd_mode_relaxation_rate(
239 FloatType shear_relaxation,
240 FloatType magic_number = FloatType{3} / FloatType{16})
const {
241 return (FloatType{4} - FloatType{2} * shear_relaxation) /
242 (FloatType{4} * magic_number * shear_relaxation + FloatType{2} -
246 void reset_boundary_handling(std::shared_ptr<BlockStorage>
const &blocks) {
247 auto const [lc, uc] =
m_lattice->get_local_grid_range(
true);
253 FloatType pressure_tensor_correction_factor()
const {
257 void pressure_tensor_correction(Matrix3<FloatType> &tensor)
const {
258 auto const revert_factor = pressure_tensor_correction_factor();
259 for (
auto const i : {1u, 2u, 3u, 5u, 6u, 7u}) {
260 tensor[i] *= revert_factor;
264 void pressure_tensor_correction(std::span<FloatType, 9ul> tensor)
const {
265 auto const revert_factor = pressure_tensor_correction_factor();
266 for (
auto const i : {1u, 2u, 3u, 5u, 6u, 7u}) {
267 tensor[i] *= revert_factor;
271 class interpolation_illegal_access :
public std::runtime_error {
273 interpolation_illegal_access(std::string
const &field,
275 std::array<int, 3>
const &node,
double weight)
276 :
std::runtime_error(
"Access to LB " + field +
" field failed") {
278 <<
"], weight " <<
weight <<
"\n";
285 :
std::runtime_error(
"VTKOutput object '" + vtk_uid +
"' " + reason) {}
308#if defined(__CUDACC__)
309 std::optional<BlockDataID> m_pdf_cpu_field_id;
310 std::optional<BlockDataID> m_vel_cpu_field_id;
325 Architecture>::template RegularCommScheme<stencil::D3Q27>;
328 Architecture>::template BoundaryCommScheme<stencil::D3Q27>;
335 template <
class Field>
353 std::shared_ptr<InterpolateAndShiftAtBoundary<_PdfField, FloatType>>
355 std::shared_ptr<InterpolateAndShiftAtBoundary<_VectorField, FloatType>>
357 std::shared_ptr<InterpolateAndShiftAtBoundary<_VectorField, FloatType>>
372#if defined(__CUDACC__)
373 std::shared_ptr<gpu::HostFieldAllocator<FloatType>> m_host_field_allocator;
388 auto const &blocks =
m_lattice->get_blocks();
389 auto const n_ghost_layers =
m_lattice->get_ghost_layers();
391#ifdef ESPRESSO_BUILD_WITH_AVX_KERNELS
392 constexpr auto alignment = field::SIMDAlignment();
393 using value_type = Field::value_type;
394 using Allocator = field::AllocateAligned<value_type, alignment>;
395 auto const allocator = std::make_shared<Allocator>();
396 auto const empty_set = Set<SUID>::emptySet();
397 return field::addToStorage<Field>(
398 blocks, tag, field::internal::defaultSize, FloatType{0}, field::fzyx,
399 n_ghost_layers,
false, {}, empty_set, empty_set, allocator);
401 return field::addToStorage<Field>(blocks, tag, FloatType{0}, field::fzyx,
405#if defined(__CUDACC__)
407 auto field_id = gpu::addGPUFieldToStorage<GPUField>(
408 blocks, tag, Field::F_SIZE, field::fzyx, n_ghost_layers);
409 if constexpr (std::is_same_v<Field, _VectorField>) {
411 auto field =
block->template getData<GPUField>(field_id);
414 }
else if constexpr (std::is_same_v<Field, _PdfField>) {
416 auto field =
block->template getData<GPUField>(field_id);
418 field, std::array<FloatType, Stencil::Size>{});
427 auto const setup = [
this]<
typename PackInfoPdf,
typename PackInfoVec>() {
428 auto const &blocks =
m_lattice->get_blocks();
430 std::make_shared<PDFStreamingCommunicator>(blocks);
442 setup.template operator()<PackInfoPdf, PackInfoVec>();
453 auto const &blocks =
m_lattice->get_blocks();
454 auto const n_ghost_layers =
m_lattice->get_ghost_layers();
455 if (n_ghost_layers == 0u)
456 throw std::runtime_error(
"At least one ghost layer must be used");
465#if defined(__CUDACC__)
466 m_host_field_allocator =
467 std::make_shared<gpu::HostFieldAllocator<FloatType>>();
473 for (
auto &
block : *blocks) {
479 blocks,
"flag field", n_ghost_layers);
481 reset_boundary_handling(
m_lattice->get_blocks());
505 std::make_shared<BoundaryFullCommunicator>(blocks);
509 auto boundary_packinfo = std::make_shared<
519 m_reset_force = std::make_shared<ResetForce<PdfField, VectorField>>(
528 void integrate_stream_collide(std::shared_ptr<BlockStorage>
const &blocks) {
530 for (
auto &
block : *blocks) {
531 auto const block_variant = std::variant<IBlock *>(&
block);
532 std::visit(m_run_stream_collide_sweep, cm_variant, block_variant);
534 if (
auto *cm = std::get_if<StreamCollisionModelThermalized>(&cm_variant)) {
535 cm->setTime_step(cm->getTime_step() + 1u);
539 auto has_lees_edwards_bc()
const {
540 return std::holds_alternative<StreamCollisionModelLeesEdwards>(
544 void apply_lees_edwards_pdf_interpolation(
545 std::shared_ptr<BlockStorage>
const &blocks) {
546 for (
auto &
block : *blocks)
550 void apply_lees_edwards_vel_interpolation_and_shift(
551 std::shared_ptr<BlockStorage>
const &blocks) {
552 for (
auto &
block : *blocks)
556 void apply_lees_edwards_last_applied_force_interpolation(
557 std::shared_ptr<BlockStorage>
const &blocks) {
558 for (
auto &
block : *blocks)
562 void integrate_reset_force(std::shared_ptr<BlockStorage>
const &blocks) {
563 for (
auto &
block : *blocks)
567 void integrate_boundaries(std::shared_ptr<BlockStorage>
const &blocks) {
568 for (
auto &
block : *blocks)
572 void integrate_update_velocities_from_pdf(
573 std::shared_ptr<BlockStorage>
const &blocks) {
574 for (
auto b = blocks->begin(); b != blocks->end(); ++b)
578 void integrate_pull_scheme() {
581 integrate_reset_force(blocks);
583 integrate_stream_collide(blocks);
589 if (has_lees_edwards_bc()) {
590 apply_lees_edwards_pdf_interpolation(blocks);
591 apply_lees_edwards_last_applied_force_interpolation(blocks);
595 integrate_boundaries(blocks);
598 integrate_update_velocities_from_pdf(blocks);
600 if (has_lees_edwards_bc()) {
601 apply_lees_edwards_vel_interpolation_and_shift(blocks);
608 auto &vtk_handle = it.second;
609 if (vtk_handle->enabled) {
610 vtk::writeFiles(vtk_handle->ptr)();
611 vtk_handle->execution_count++;
618 integrate_pull_scheme();
634 if (has_lees_edwards_bc()) {
636 apply_lees_edwards_pdf_interpolation(blocks);
645 if (has_lees_edwards_bc()) {
647 apply_lees_edwards_vel_interpolation_and_shift(blocks);
656 if (has_lees_edwards_bc()) {
658 apply_lees_edwards_last_applied_force_interpolation(blocks);
673 if (has_lees_edwards_bc()) {
683 apply_lees_edwards_pdf_interpolation(blocks);
684 apply_lees_edwards_vel_interpolation_and_shift(blocks);
685 apply_lees_edwards_last_applied_force_interpolation(blocks);
689 auto const omega = shear_mode_relaxation_rate();
690 auto const omega_odd = odd_mode_relaxation_rate(omega);
699 m_run_stream_collide_sweep = StreamCollideSweepVisitor(blocks);
704 std::unique_ptr<LeesEdwardsPack> &&lees_edwards_pack)
override {
706#if defined(__CUDACC__)
708 throw std::runtime_error(
"Lees-Edwards LB doesn't support GPU yet");
711 auto const shear_direction = lees_edwards_pack->shear_direction;
712 auto const shear_plane_normal = lees_edwards_pack->shear_plane_normal;
713 auto const shear_vel =
FloatType_c(lees_edwards_pack->get_shear_velocity());
714 auto const omega = shear_mode_relaxation_rate();
715 if (shear_plane_normal != 1u) {
716 throw std::domain_error(
717 "Lees-Edwards LB only supports shear_plane_normal=\"y\"");
720 auto const n_ghost_layers = lattice.get_ghost_layers();
721 auto const blocks = lattice.get_blocks();
722 if (lattice.get_node_grid()[shear_direction] != 1 or
723 lattice.get_node_grid()[shear_plane_normal] != 1 or
724 blocks->getSize(shear_direction) != 1ul or
725 blocks->getSize(shear_plane_normal) != 1ul) {
726 throw std::domain_error(
"LB LEbc doesn't support domain decomposition "
727 "along the shear and normal directions.");
729 auto const &grid_dimensions = lattice.get_grid_dimensions();
730 auto const grid_size =
FloatType_c(grid_dimensions[shear_plane_normal]);
736 m_run_stream_collide_sweep =
739 std::make_shared<InterpolateAndShiftAtBoundary<_PdfField, FloatType>>(
741 shear_direction, shear_plane_normal,
746 shear_direction, shear_plane_normal,
752 n_ghost_layers, shear_direction, shear_plane_normal,
758 unsigned int shear_plane_normal)
const override {
762 throw std::runtime_error(
763 "MD and LB Lees-Edwards boundary conditions disagree");
780 template <
typename T>
782 if constexpr (std::is_arithmetic_v<T>) {
783 static_assert(std::is_floating_point_v<T>);
784 data *=
static_cast<T
>(factor);
786 auto const coef =
static_cast<typename T::value_type
>(factor);
787 std::transform(std::begin(data), std::end(data), std::begin(data),
788 [coef](
auto value) {
return value * coef; });
801 auto transformed_data = data;
803 return transformed_data;
807 auto transformed_data = data;
809 return transformed_data;
813 std::optional<Utils::Vector3d>
815 bool consider_ghosts =
false)
const override {
820 if (is_boundary and *is_boundary) {
828 auto field = bc->block->template uncheckedFastGetData<VectorField>(
843 auto pdf_field = bc->block->template getData<PdfField>(
m_pdf_field_id);
848 auto vel = to_vector3<FloatType>(v);
858 std::vector<double> out;
859 uint_t values_size = 0;
861 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
862 out = std::vector<double>(3u * ci->numCells());
863 for (
auto &
block : *lattice.get_blocks()) {
864 auto const block_offset = lattice.get_block_corner(
block,
true);
866 lattice, lower_corner, upper_corner, block_offset,
block)) {
870 assert(values.size() == 3u * bci->numCells());
871 values_size += 3u * bci->numCells();
873 auto kernel = [&values, &out,
this](
unsigned const block_index,
874 unsigned const local_index,
877 auto const &vec =
m_boundary->get_node_value_at_boundary(node);
878 for (uint_t f = 0u; f < 3u; ++f) {
879 out[3u * local_index + f] = vec[f];
882 for (uint_t f = 0u; f < 3u; ++f) {
883 out[3u * local_index + f] =
884 double_c(values[3u * block_index + f]);
892 assert(values_size == 3u * ci->numCells());
899 std::vector<double>
const &
velocity)
override {
903 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
905 for (
auto &
block : *lattice.get_blocks()) {
906 auto const block_offset = lattice.get_block_corner(
block,
true);
908 lattice, lower_corner, upper_corner, block_offset,
block)) {
910 auto force_field =
block.template getData<VectorField>(
914 std::vector<FloatType> values(3u * bci->numCells());
916 auto kernel = [&values, &
velocity](
unsigned const block_index,
917 unsigned const local_index,
919 for (uint_t f = 0u; f < 3u; ++f) {
920 values[3u * block_index + f] =
921 numeric_cast<FloatType>(
velocity[3u * local_index + f]);
933 [[nodiscard]]
bool is_gpu() const noexcept
override {
940 if (consider_points_in_halo) {
941 return [&](
Utils::Vector3d const &p) {
return lat.pos_in_local_halo(p); };
943 return [&](
Utils::Vector3d const &p) {
return lat.pos_in_local_domain(p); };
947 std::vector<Utils::Vector3d>
const &forces)
override {
948 assert(pos.size() == forces.size());
954 for (std::size_t i = 0ul; i < pos.size(); ++i) {
955 kernel(pos[i], forces[i]);
958#if defined(__CUDACC__)
961 auto const &
block = *(lattice.get_blocks()->begin());
962 auto const origin =
block.getAABB().min();
963 std::vector<FloatType> host_pos;
964 std::vector<FloatType> host_force;
965 host_pos.reserve(3ul * pos.size());
966 host_force.reserve(3ul * forces.size());
967 assert(lattice.get_blocks()->getNumberOfBlocks() == 1u);
968 for (
auto const &vec : pos) {
970 for (std::size_t i : {0ul, 1ul, 2ul}) {
971 host_pos.emplace_back(
static_cast<FloatType
>(vec[i] - origin[i]));
974 for (
auto const &vec : forces) {
976 for (std::size_t i : {0ul, 1ul, 2ul}) {
977 host_force.emplace_back(
static_cast<FloatType
>(vec[i]));
981 auto const gl = lattice.get_ghost_layers();
982 auto field =
block.template uncheckedFastGetData<VectorField>(
991 auto const &blocks = *lattice.get_blocks();
992 assert(lattice.get_ghost_layers() == 1u);
999 std::array<int, 3>
const node,
double weight) {
1005 blocks.transformGlobalToBlockLocalCell(cell, *
block);
1007 auto const weighted_force = to_vector3<FloatType>(
weight * force);
1009 block->template uncheckedFastGetData<VectorField>(field_id);
1018 auto const &blocks = *lattice.get_blocks();
1019 assert(lattice.get_ghost_layers() == 1u);
1023 std::array<int, 3>
const node,
1030 throw interpolation_illegal_access(
"velocity", pos, node,
weight);
1031 Vector3<FloatType> vel;
1033 vel =
m_boundary->get_node_value_at_boundary(node);
1036 blocks.transformGlobalToBlockLocalCell(cell, *
block);
1038 block->template uncheckedFastGetData<VectorField>(field_id);
1050 auto const &blocks = *lattice.get_blocks();
1051 assert(lattice.get_ghost_layers() == 1u);
1056 std::array<int, 3>
const node,
1063 throw interpolation_illegal_access(
"density", pos, node,
weight);
1065 blocks.transformGlobalToBlockLocalCell(cell, *
block);
1066 auto field =
block->template uncheckedFastGetData<PdfField>(field_id);
1075 std::vector<Utils::Vector3d>
1080 std::vector<Utils::Vector3d> vel{};
1081 vel.reserve(pos.size());
1084 std::ranges::transform(pos, std::back_inserter(vel), kernel);
1086#if defined(__CUDACC__)
1089 auto const &
block = *(lattice.get_blocks()->begin());
1090 auto const origin =
block.getAABB().min();
1091 std::vector<FloatType> host_pos;
1092 host_pos.reserve(3ul * pos.size());
1093 assert(lattice.get_blocks()->getNumberOfBlocks() == 1u);
1094 for (
auto const &vec : pos) {
1096 for (std::size_t i : {0ul, 1ul, 2ul}) {
1097 host_pos.emplace_back(
static_cast<FloatType
>(vec[i] - origin[i]));
1100 auto const gl = lattice.get_ghost_layers();
1105 auto const [dev_idx, dev_vel] =
m_boundary->get_flattened_map_device();
1106 if (not dev_idx->empty()) {
1111 for (
auto it = res.begin(); it != res.end(); it += 3) {
1113 static_cast<double>(*(it + 1)),
1114 static_cast<double>(*(it + 2))});
1126 std::vector<double> rho{};
1127 rho.reserve(pos.size());
1130 std::ranges::transform(pos, std::back_inserter(rho), kernel);
1132#if defined(__CUDACC__)
1135 auto const &
block = *(lattice.get_blocks()->begin());
1136 auto const origin =
block.getAABB().min();
1137 std::vector<FloatType> host_pos;
1138 host_pos.reserve(3ul * pos.size());
1139 assert(lattice.get_blocks()->getNumberOfBlocks() == 1u);
1140 for (
auto const &vec : pos) {
1142 for (std::size_t i : {0ul, 1ul, 2ul}) {
1143 host_pos.emplace_back(
static_cast<FloatType
>(vec[i] - origin[i]));
1146 auto const gl = lattice.get_ghost_layers();
1151 if constexpr (std::is_same_v<FloatType, double>) {
1152 std::swap(rho, res);
1154 for (
auto const &v : res) {
1155 rho.emplace_back(
static_cast<double>(v));
1163 std::optional<Utils::Vector3d>
1165 bool consider_points_in_halo =
false)
const override {
1168 if (!consider_points_in_halo and !
m_lattice->pos_in_local_domain(pos))
1169 return std::nullopt;
1170 if (consider_points_in_halo and !
m_lattice->pos_in_local_halo(pos))
1171 return std::nullopt;
1173 return {kernel(pos)};
1176 std::optional<double>
1178 bool consider_points_in_halo =
false)
const override {
1180 if (!consider_points_in_halo and !
m_lattice->pos_in_local_domain(pos))
1181 return std::nullopt;
1182 if (consider_points_in_halo and !
m_lattice->pos_in_local_halo(pos))
1183 return std::nullopt;
1185 return {kernel(pos)};
1197 std::optional<Utils::Vector3d>
1201 return std::nullopt;
1209 std::optional<Utils::Vector3d>
1211 bool consider_ghosts =
false)
const override {
1215 return std::nullopt;
1231 auto pdf_field = bc->block->template getData<PdfField>(
m_pdf_field_id);
1236 auto const vec = to_vector3<FloatType>(force);
1246 std::vector<double> out;
1248 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1249 out = std::vector<double>(3u * ci->numCells());
1250 for (
auto const &
block : *lattice.get_blocks()) {
1251 auto const block_offset = lattice.get_block_corner(
block,
true);
1253 lattice, lower_corner, upper_corner, block_offset,
block)) {
1254 auto const field =
block.template getData<VectorField>(
1257 assert(values.size() == 3u * bci->numCells());
1259 auto kernel = [&values, &out](
unsigned const block_index,
1260 unsigned const local_index,
1262 for (uint_t f = 0u; f < 3u; ++f) {
1263 out[3u * local_index + f] = values[3u * block_index + f];
1277 std::vector<double>
const &force)
override {
1281 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1282 assert(force.size() == 3u * ci->numCells());
1283 for (
auto &
block : *lattice.get_blocks()) {
1284 auto const block_offset = lattice.get_block_corner(
block,
true);
1286 lattice, lower_corner, upper_corner, block_offset,
block)) {
1288 auto force_field =
block.template getData<VectorField>(
1292 std::vector<FloatType> values(3u * bci->numCells());
1294 auto kernel = [&values, &force](
unsigned const block_index,
1295 unsigned const local_index,
1297 for (uint_t f = 0u; f < 3u; ++f) {
1298 values[3u * block_index + f] =
1299 numeric_cast<FloatType>(force[3u * local_index + f]);
1312 std::optional<std::vector<double>>
1314 bool consider_ghosts =
false)
const override {
1318 return std::nullopt;
1320 auto pdf_field = bc->block->template getData<PdfField>(
m_pdf_field_id);
1322 std::vector<double> population(Stencil::Size);
1323 for (uint_t f = 0u; f < Stencil::Size; ++f) {
1324 population[f] = double_c(pop[f]);
1327 return {std::move(population)};
1331 std::vector<double>
const &population)
override {
1338 auto pdf_field = bc->block->template getData<PdfField>(
m_pdf_field_id);
1343 std::array<FloatType, Stencil::Size> pop;
1344 for (uint_t f = 0u; f < Stencil::Size; ++f) {
1356 std::vector<double> out;
1358 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1359 out = std::vector<double>(
stencil_size() * ci->numCells());
1360 for (
auto const &
block : *lattice.get_blocks()) {
1361 auto const block_offset = lattice.get_block_corner(
block,
true);
1363 lattice, lower_corner, upper_corner, block_offset,
block)) {
1364 auto const pdf_field =
1367 assert(values.size() ==
stencil_size() * bci->numCells());
1369 auto kernel = [&values, &out,
this](
unsigned const block_index,
1370 unsigned const local_index,
1387 std::vector<double>
const &population)
override {
1389 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1390 assert(population.size() ==
stencil_size() * ci->numCells());
1391 for (
auto &
block : *lattice.get_blocks()) {
1392 auto const block_offset = lattice.get_block_corner(
block,
true);
1394 lattice, lower_corner, upper_corner, block_offset,
block)) {
1396 auto force_field =
block.template getData<VectorField>(
1400 std::vector<FloatType> values(
stencil_size() * bci->numCells());
1402 auto kernel = [&values, &population,
this](
unsigned const block_index,
1403 unsigned const local_index,
1407 numeric_cast<FloatType>(
1421 std::optional<double>
1423 bool consider_ghosts =
false)
const override {
1427 return std::nullopt;
1430 bc->block->template uncheckedFastGetData<PdfField>(
m_pdf_field_id);
1442 auto pdf_field = bc->block->template getData<PdfField>(
m_pdf_field_id);
1452 std::vector<double> out;
1454 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1455 out = std::vector<double>(ci->numCells());
1456 for (
auto const &
block : *lattice.get_blocks()) {
1457 auto const block_offset = lattice.get_block_corner(
block,
true);
1459 lattice, lower_corner, upper_corner, block_offset,
block)) {
1460 auto const pdf_field =
1464 assert(values.size() == bci->numCells());
1466 auto kernel = [&values, &out](
unsigned const block_index,
1467 unsigned const local_index,
1469 out[local_index] = values[block_index];
1481 std::vector<double>
const &
density)
override {
1484 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1485 assert(
density.size() == ci->numCells());
1486 for (
auto &
block : *lattice.get_blocks()) {
1487 auto const block_offset = lattice.get_block_corner(
block,
true);
1489 lattice, lower_corner, upper_corner, block_offset,
block)) {
1491 std::vector<FloatType> values(bci->numCells());
1493 auto kernel = [&values, &
density](
unsigned const block_index,
1494 unsigned const local_index,
1496 values[block_index] = numeric_cast<FloatType>(
density[local_index]);
1506 std::optional<Utils::Vector3d>
1508 bool consider_ghosts =
false)
const override {
1511 if (!bc or !
m_boundary->node_is_boundary(node))
1512 return std::nullopt;
1527 node, to_vector3<FloatType>(
velocity), *bc);
1529 return bc.has_value();
1535 std::vector<std::optional<Utils::Vector3d>> out;
1537 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1538 out = std::vector<std::optional<Utils::Vector3d>>(ci->numCells());
1539 for (
auto const &
block : *lattice.get_blocks()) {
1540 auto const block_offset = lattice.get_block_corner(
block,
true);
1542 lattice, lower_corner, upper_corner, block_offset,
block)) {
1544 auto kernel = [&out,
this](
unsigned const,
unsigned const local_index,
1550 out[local_index] = std::nullopt;
1557 assert(out.size() == ci->numCells());
1564 std::vector<std::optional<Utils::Vector3d>>
const &
velocity)
override {
1568 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1570 for (
auto &
block : *lattice.get_blocks()) {
1571 auto const block_offset = lattice.get_block_corner(
block,
true);
1573 lattice, lower_corner, upper_corner, block_offset,
block)) {
1575 auto kernel = [&,
this](
unsigned const,
unsigned const local_index,
1578 assert(bc->block->getAABB() ==
block.getAABB());
1579 auto const &opt =
velocity[local_index];
1582 node, to_vector3<FloatType>(*opt), *bc);
1584 m_boundary->remove_node_from_boundary(node, *bc);
1594 std::optional<Utils::Vector3d>
1597 if (!bc or !
m_boundary->node_is_boundary(node))
1598 return std::nullopt;
1609 m_boundary->remove_node_from_boundary(node, *bc);
1611 return bc.has_value();
1616 bool consider_ghosts =
false)
const override {
1620 return std::nullopt;
1628 std::vector<bool> out;
1630 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1631 out = std::vector<bool>(ci->numCells());
1632 for (
auto const &
block : *lattice.get_blocks()) {
1633 auto const block_offset = lattice.get_block_corner(
block,
true);
1635 lattice, lower_corner, upper_corner, block_offset,
block)) {
1637 auto kernel = [&out,
this](
unsigned const,
unsigned const local_index,
1639 out[local_index] =
m_boundary->node_is_boundary(node);
1645 assert(out.size() == ci->numCells());
1661 reset_boundary_handling(
get_lattice().get_blocks());
1670 std::vector<double>
const &data_flat)
override {
1681 std::optional<Utils::VectorXd<9>>
1685 return std::nullopt;
1687 auto pdf_field = bc->block->template getData<PdfField>(
m_pdf_field_id);
1690 pressure_tensor_correction(tensor);
1697 std::vector<double> out;
1699 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1700 out = std::vector<double>(9u * ci->numCells());
1701 for (
auto const &
block : *lattice.get_blocks()) {
1702 auto const block_offset = lattice.get_block_corner(
block,
true);
1704 lattice, lower_corner, upper_corner, block_offset,
block)) {
1705 auto const pdf_field =
1709 assert(values.size() == 9u * bci->numCells());
1711 auto kernel = [&values, &out,
this](
unsigned const block_index,
1712 unsigned const local_index,
1714 pressure_tensor_correction(
1715 std::span<FloatType, 9ul>(&values[9u * block_index], 9ul));
1716 for (uint_t f = 0u; f < 9u; ++f) {
1717 out[9u * local_index + f] = values[9u * block_index + f];
1731 node[2] = index % grid_size[2];
1732 int tmp = index / grid_size[2];
1733 node[1] = tmp % grid_size[1];
1734 node[0] = tmp / grid_size[1];
1743 for (
int i = 0; i < neighbor.size(); i++) {
1745 (node[i] - neighbor_offset[i][dir] + grid_size[i]) % grid_size[i];
1751 std::vector<int>
const &raster_flat)
const override {
1758 for (
int i = 0; i < raster_flat.size(); i++) {
1759 if (raster_flat[i] != 0) {
1763 node = (node - offset + grid_size) % grid_size;
1764 for (
int j = 0; j < index_field.size(); j++) {
1766 if (index_field[j].x == neighbor_node[0] &&
1767 index_field[j].y == neighbor_node[1] &&
1768 index_field[j].z == neighbor_node[2]) {
1769 force[0] += force_field[j].F_0;
1770 force[1] += force_field[j].F_1;
1771 force[2] += force_field[j].F_2;
1782 Vector3<double> force(0.);
1790 Matrix3<FloatType> tensor(FloatType{0});
1797 pressure_tensor_correction(tensor);
1798 return to_vector9d(tensor) * (1. /
static_cast<double>(number_of_nodes));
1803 Vector3<FloatType> mom(FloatType{0});
1823 [[nodiscard]]
double get_kT() const noexcept
override {
1824 return static_cast<double>(
m_kT);
1827 [[nodiscard]]
unsigned int get_seed() const noexcept
override {
1834 if (!cm or
m_kT == 0.) {
1835 return std::nullopt;
1837 return {
static_cast<uint64_t
>(cm->getTime_step())};
1843 if (!cm or
m_kT == 0.) {
1844 throw std::runtime_error(
"This LB instance is unthermalized");
1847 static_cast<uint32_t
>(std::numeric_limits<uint_t>::max()));
1848 cm->setTime_step(
static_cast<uint32_t
>(counter));
1866 vtk_obj.addCellExclusionFilter(fluid_filter);
1870 template <
typename Field_T, u
int_t F_SIZE_ARG,
typename OutputType>
1871 class VTKWriter :
public vtk::BlockCellDataWriter<OutputType, F_SIZE_ARG> {
1873 VTKWriter(ConstBlockDataID
const &block_id, std::string
const &
id,
1874 FloatType unit_conversion)
1875 : vtk::BlockCellDataWriter<OutputType, F_SIZE_ARG>(id),
1881 WALBERLA_ASSERT_NOT_NULLPTR(this->block_);
1890 template <
typename OutputType =
float>
1895 using Base::evaluate;
1898 OutputType
evaluate(cell_idx_t
const x, cell_idx_t
const y,
1899 cell_idx_t
const z, cell_idx_t
const)
override {
1900 WALBERLA_ASSERT_NOT_NULLPTR(this->
m_field);
1907 template <
typename OutputType =
float>
1912 using Base::evaluate;
1915 OutputType
evaluate(cell_idx_t
const x, cell_idx_t
const y,
1916 cell_idx_t
const z, cell_idx_t
const f)
override {
1917 WALBERLA_ASSERT_NOT_NULLPTR(this->
m_field);
1924 template <
typename OutputType =
float>
1929 using Base::evaluate;
1932 std::string
const &
id, FloatType unit_conversion,
1933 FloatType off_diag_factor)
1934 :
Base(block_id, id, unit_conversion),
1938 OutputType
evaluate(cell_idx_t
const x, cell_idx_t
const y,
1939 cell_idx_t
const z, cell_idx_t
const f)
override {
1940 WALBERLA_ASSERT_NOT_NULLPTR(this->
m_field);
1941 auto const pressure =
1943 auto const revert_factor =
1945 return numeric_cast<OutputType>(this->
m_conversion * revert_factor *
1946 pressure[uint_c(f)]);
1954 int flag_observables)
override {
1955#if defined(__CUDACC__)
1956 auto const allocate_cpu_field_if_empty =
1957 [&]<
typename Field>(
auto const &blocks, std::string name,
1958 std::optional<BlockDataID> &cpu_field) {
1959 if (not cpu_field) {
1960 cpu_field = field::addToStorage<Field>(
1961 blocks, name, FloatType{0}, field::fzyx,
1962 m_lattice->get_ghost_layers(), m_host_field_allocator);
1967 auto const unit_conversion =
1969#if defined(__CUDACC__)
1971 auto const &blocks =
m_lattice->get_blocks();
1972 allocate_cpu_field_if_empty.template operator()<PdfFieldCpu>(
1973 blocks,
"pdfs_cpu", m_pdf_cpu_field_id);
1974 vtk_obj.addBeforeFunction(gpu::fieldCpyFunctor<PdfFieldCpu, PdfField>(
1982 auto const unit_conversion =
FloatType_c(units.at(
"velocity"));
1983#if defined(__CUDACC__)
1985 auto const &blocks =
m_lattice->get_blocks();
1986 allocate_cpu_field_if_empty.template operator()<VectorFieldCpu>(
1987 blocks,
"vel_cpu", m_vel_cpu_field_id);
1988 vtk_obj.addBeforeFunction(
1989 gpu::fieldCpyFunctor<VectorFieldCpu, VectorField>(
1997 auto const unit_conversion =
1999#if defined(__CUDACC__)
2001 auto const &blocks =
m_lattice->get_blocks();
2002 allocate_cpu_field_if_empty.template operator()<PdfFieldCpu>(
2003 blocks,
"pdfs_cpu", m_pdf_cpu_field_id);
2004 vtk_obj.addBeforeFunction(gpu::fieldCpyFunctor<PdfFieldCpu, PdfField>(
2008 vtk_obj.addCellDataWriter(
2011 pressure_tensor_correction_factor()));
LBWalberlaBase provides the public interface of the LB waLBerla bridge.
Vector implementation and trait types for boost qvm interoperability.
Interface of a lattice-based fluid model.
std::map< std::string, std::shared_ptr< VTKHandle > > m_vtk_auto
VTK writers that are executed automatically.
std::unordered_map< std::string, double > units_map
Class that runs and controls the BlockForest in waLBerla.
auto const & get_grid_dimensions() const
walberla::blockforest::StructuredBlockForest Lattice_T
Utils::Vector3i get_block_corner(IBlock const &block, bool lower) const
DEVICE_QUALIFIER constexpr size_type size() const noexcept
Boundary class optimized for sparse data.
field::FlagField< uint8_t > FlagField
OutputType evaluate(cell_idx_t const x, cell_idx_t const y, cell_idx_t const z, cell_idx_t const) override
OutputType evaluate(cell_idx_t const x, cell_idx_t const y, cell_idx_t const z, cell_idx_t const f) override
FloatType const m_off_diag_factor
PressureTensorVTKWriter(ConstBlockDataID const &block_id, std::string const &id, FloatType unit_conversion, FloatType off_diag_factor)
void configure() override
VTKWriter(ConstBlockDataID const &block_id, std::string const &id, FloatType unit_conversion)
FloatType const m_conversion
ConstBlockDataID const m_block_id
OutputType evaluate(cell_idx_t const x, cell_idx_t const y, cell_idx_t const z, cell_idx_t const f) override
Class that runs and controls the LB on waLBerla.
void add_forces_at_pos(std::vector< Utils::Vector3d > const &pos, std::vector< Utils::Vector3d > const &forces) override
std::vector< double > get_slice_last_applied_force(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
void zero_centered_transform_impl(T &data, auto const factor) const
std::shared_ptr< RegularFullCommunicator > m_pdf_communicator
std::vector< std::optional< Utils::Vector3d > > get_slice_velocity_at_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
std::optional< Utils::Vector3d > get_node_last_applied_force(Utils::Vector3i const &node, bool consider_ghosts=false) const override
stencil::D3Q19 Stencil
Stencil for collision and streaming operations.
std::optional< Utils::Vector3d > get_node_velocity_at_boundary(Utils::Vector3i const &node, bool consider_ghosts=false) const override
void ghost_communication() override
FieldTrait< FloatType, Architecture >::VectorField VectorField
std::optional< Utils::Vector3d > get_node_velocity(Utils::Vector3i const &node, bool consider_ghosts=false) const override
void reallocate_ubb_field() override
Utils::Vector3d get_boundary_force_from_shape(std::vector< int > const &raster_flat) const override
std::shared_ptr< RegularFullCommunicator > m_full_communicator
BlockDataID m_pdf_tmp_field_id
std::size_t get_force_field_id() const noexcept override
BlockDataID m_pdf_field_id
std::shared_ptr< CollisionModel > m_collision_model
void set_slice_velocity(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< double > const &velocity) override
unsigned int get_seed() const noexcept override
void integrate_vtk_writers() override
BoundaryModel::FlagField FlagField
FieldTrait< FloatType, Architecture >::template PackInfo< Field > PackInfo
bool remove_node_from_boundary(Utils::Vector3i const &node) override
std::optional< Utils::Vector3d > get_node_boundary_force(Utils::Vector3i const &node) const override
std::optional< double > get_density_at_pos(Utils::Vector3d const &pos, bool consider_points_in_halo=false) const override
void zero_centered_to_md_in_place(auto &data) const
BlockDataID m_vel_tmp_field_id
void set_slice_velocity_at_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< std::optional< Utils::Vector3d > > const &velocity) override
std::vector< double > get_slice_population(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
void set_rng_state(uint64_t counter) override
std::vector< double > get_slice_velocity(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
Utils::Vector3d get_boundary_force() const override
std::shared_ptr< LatticeWalberla > m_lattice
std::shared_ptr< LeesEdwardsPack > m_lees_edwards_callbacks
LBWalberlaImpl(std::shared_ptr< LatticeWalberla > lattice, double viscosity, double density)
bool set_node_last_applied_force(Utils::Vector3i const &node, Utils::Vector3d const &force) override
FieldTrait< FloatType >::PdfField _PdfField
std::function< bool(Utils::Vector3d const &)> make_lattice_position_checker(bool consider_points_in_halo) const override
std::shared_ptr< InterpolateAndShiftAtBoundary< _VectorField, FloatType > > m_lees_edwards_vel_interpol_sweep
std::vector< bool > get_slice_is_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
std::vector< double > get_slice_density(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
bool is_double_precision() const noexcept override
void update_boundary_from_shape(std::vector< int > const &raster_flat, std::vector< double > const &data_flat) override
std::shared_ptr< BoundaryModel > m_boundary
std::vector< double > get_slice_pressure_tensor(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
bool set_node_density(Utils::Vector3i const &node, double density) override
void set_collision_model(double kT, unsigned int seed) override
Utils::Vector3i get_neighbor_node(Utils::Vector3i const &node, int dir) const
std::vector< Utils::Vector3d > get_velocities_at_pos(std::vector< Utils::Vector3d > const &pos) override
void ghost_communication_laf() override
std::optional< bool > get_node_is_boundary(Utils::Vector3i const &node, bool consider_ghosts=false) const override
BlockDataID m_velocity_field_id
FieldTrait< FloatType, Architecture >::template RegularCommScheme< Stencil > PDFStreamingCommunicator
Regular communicator.
std::shared_ptr< ResetForce< PdfField, VectorField > > m_reset_force
void setup_streaming_communicator()
BlockDataID m_flag_field_id
FlagUID const Boundary_flag
Flag for boundary cells.
~LBWalberlaImpl() override=default
std::optional< uint64_t > get_rng_state() const override
std::optional< std::vector< double > > get_node_population(Utils::Vector3i const &node, bool consider_ghosts=false) const override
FloatType m_density
kinematic viscosity
double get_viscosity() const noexcept override
double get_kT() const noexcept override
Utils::Vector3d get_momentum() const override
void set_viscosity(double viscosity) override
std::shared_ptr< BoundaryFullCommunicator > m_boundary_communicator
FieldTrait< FloatType, Architecture >::template RegularCommScheme< stencil::D3Q27 > RegularFullCommunicator
Full communicator.
std::size_t stencil_size() const noexcept override
auto add_to_storage(std::string const tag)
Convenience function to add a field with a custom allocator.
FieldTrait< FloatType, Architecture >::PdfField PdfField
void ghost_communication_full()
detail::KernelTrait< FloatType, Architecture >::InitialPDFsSetter InitialPDFsSetter
auto zero_centered_to_lb(auto const &data) const
bool set_node_velocity_at_boundary(Utils::Vector3i const &node, Utils::Vector3d const &velocity) override
stencil::D3Q27 StencilFull
Stencil for ghost communication (includes domain corners).
void register_vtk_field_writers(walberla::vtk::VTKOutput &vtk_obj, LatticeModel::units_map const &units, int flag_observables) override
auto make_density_interpolation_kernel() const
auto make_force_interpolation_kernel() const
std::optional< double > get_node_density(Utils::Vector3i const &node, bool consider_ghosts=false) const override
void check_lebc(unsigned int shear_direction, unsigned int shear_plane_normal) const override
void set_slice_density(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< double > const &density) override
void ghost_communication_vel() override
Utils::Vector3d get_external_force() const noexcept override
BlockDataID m_force_to_be_applied_id
FloatType FloatType_c(T t) const
std::shared_ptr< RegularFullCommunicator > m_laf_communicator
void apply_lees_edwards_interpolation()
detail::KernelTrait< FloatType, Architecture >::StreamCollisionModelLeesEdwards StreamCollisionModelLeesEdwards
std::size_t get_velocity_field_id() const noexcept override
Utils::VectorXd< 9 > get_pressure_tensor() const override
std::shared_ptr< InterpolateAndShiftAtBoundary< _PdfField, FloatType > > m_lees_edwards_pdf_interpol_sweep
Utils::Vector3i flat_index_to_node(int index) const
void set_external_force(Utils::Vector3d const &ext_force) override
std::optional< Utils::Vector3d > get_velocity_at_pos(Utils::Vector3d const &pos, bool consider_points_in_halo=false) const override
void set_slice_last_applied_force(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< double > const &force) override
LatticeWalberla::Lattice_T BlockStorage
Lattice model (e.g.
std::shared_ptr< UpdateVelFromPDF > m_update_velocities_from_pdf
void set_collision_model(std::unique_ptr< LeesEdwardsPack > &&lees_edwards_pack) override
std::shared_ptr< RegularFullCommunicator > m_vel_communicator
std::bitset< GhostComm::SIZE > m_pending_ghost_comm
detail::KernelTrait< FloatType, Architecture >::StreamCollisionModelThermalized StreamCollisionModelThermalized
LatticeWalberla const & get_lattice() const noexcept override
auto zero_centered_to_md(auto const &data) const
void set_slice_population(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< double > const &population) override
FieldTrait< FloatType, Architecture >::template BoundaryCommScheme< stencil::D3Q27 > BoundaryFullCommunicator
double get_density() const noexcept override
void ghost_communication_pdf() override
auto make_velocity_interpolation_kernel() const
void register_vtk_field_filters(walberla::vtk::VTKOutput &vtk_obj) override
std::optional< Utils::Vector3d > get_node_force_to_be_applied(Utils::Vector3i const &node) const override
std::vector< double > get_densities_at_pos(std::vector< Utils::Vector3d > const &pos) override
void zero_centered_to_lb_in_place(auto &data) const
bool set_node_velocity(Utils::Vector3i const &node, Utils::Vector3d const &v) override
void clear_boundaries() override
bool set_node_population(Utils::Vector3i const &node, std::vector< double > const &population) override
bool is_gpu() const noexcept override
std::shared_ptr< PDFStreamingCommunicator > m_pdf_streaming_communicator
FieldTrait< FloatType >::VectorField _VectorField
BlockDataID m_last_applied_force_field_id
void integrate() override
std::optional< Utils::VectorXd< 9 > > get_node_pressure_tensor(Utils::Vector3i const &node) const override
std::shared_ptr< InterpolateAndShiftAtBoundary< _VectorField, FloatType > > m_lees_edwards_last_applied_force_interpol_sweep
void ghost_communication_boundary()
bool add_force_at_pos(Utils::Vector3d const &pos, Utils::Vector3d const &force) override
std::variant< StreamCollisionModelThermalized, StreamCollisionModelLeesEdwards > CollisionModel
void setup_boundary_handle(std::shared_ptr< LatticeWalberla > lattice, std::shared_ptr< Boundary_T > boundary)
static constexpr std::array< std::array< int, 19u >, 3u > neighborOffset
static double weight(int type, double r_cut, double k, double r)
static double * block(double *p, std::size_t index, std::size_t size)
T product(Vector< T, N > const &v)
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)
auto get(GhostLayerField< double, uint_t{3u}> const *vec_field, Cell const &cell)
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)
\file PackInfoPdfDoublePrecision.cpp \author pystencils
IBlock * get_block_extended(LatticeWalberla const &lattice, auto const &pos, unsigned int n_ghost_layers)
auto to_vector3d(Vector3< T > const &v) noexcept
void interpolate_bspline_at_pos(Utils::Vector3d const &pos, Function const &f)
void set_boundary_from_grid(BoundaryModel &boundary, LatticeWalberla const &lattice, std::vector< int > const &raster_flat, std::vector< DataType > const &data_flat)
std::optional< BlockAndCell > get_block_and_cell(::LatticeWalberla const &lattice, signed_integral_vector auto const &node, bool consider_ghost_layers)
Cell to_cell(signed_integral_vector auto const &xyz)
std::optional< walberla::cell::CellInterval > get_block_interval(::LatticeWalberla const &lattice, Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, Utils::Vector3i const &block_offset, IBlock const &block)
void copy_block_buffer(CellInterval const &bci, CellInterval const &ci, Utils::Vector3i const &block_offset, Utils::Vector3i const &lower_corner, Kernel &&kernel)
Synchronize data between a sliced block and a container.
auto to_vector9d(Matrix3< T > const &m) noexcept
std::optional< walberla::cell::CellInterval > get_interval(::LatticeWalberla const &lattice, Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner)
std::vector< Utils::Vector3d > fill_3D_vector_array(std::vector< double > const &vec_flat, Utils::Vector3i const &grid_size)
static Utils::Vector3d velocity(Particle const &p_ref, Particle const &p_vs)
Velocity of the virtual site.
detail::KernelTrait< FT, AT >::PackInfoVec PackInfoStreamingVec
field::GhostLayerField< FT, uint_t{3u}> VectorField
detail::KernelTrait< FT, AT >::PackInfoPdf PackInfoStreamingPdf
field::communication::PackInfo< Field > PackInfo
field::GhostLayerField< FT, Stencil::Size > PdfField
blockforest::communication::UniformBufferedScheme< Stencil > RegularCommScheme
blockforest::communication::UniformBufferedScheme< Stencil > BoundaryCommScheme
GhostCommFlags
Ghost communication operations.
@ VEL
velocities communication
@ LAF
last applied forces communication
@ UBB
boundaries communication