ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
LBWalberlaImpl.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-2026 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22/**
23 * @file
24 * @ref walberla::LBWalberlaImpl implements the interface of the LB
25 * waLBerla bridge using sweeps generated by lbmpy
26 * (see <tt>maintainer/walberla_kernels</tt>).
27 */
28
29#include <blockforest/Initialization.h>
30#include <blockforest/StructuredBlockForest.h>
31#include <domain_decomposition/BlockDataID.h>
32#include <domain_decomposition/IBlock.h>
33#include <field/AddToStorage.h>
34#include <field/vtk/FlagFieldCellFilter.h>
35#include <field/vtk/VTKWriter.h>
36#include <stencil/D3Q19.h>
37#include <stencil/D3Q27.h>
38#include <waLBerlaDefinitions.h>
39#if defined(__CUDACC__) and defined(WALBERLA_BUILD_WITH_CUDA)
40#include <gpu/AddGPUFieldToStorage.h>
41#endif
42
45#include "../utils/boundary.hpp"
48#include "ResetForce.hpp"
49#include "lb_fields.hpp"
50#include "lb_kernels.hpp"
51#if defined(__CUDACC__) and defined(WALBERLA_BUILD_WITH_CUDA)
52#include "lb_fields.cuh"
53#include "lb_kernels.cuh"
54#endif
55
63
64#include <utils/Vector.hpp>
65
66#include <array>
67#include <bitset>
68#include <cstddef>
69#include <cstdint>
70#include <functional>
71#include <initializer_list>
72#include <limits>
73#include <memory>
74#include <optional>
75#include <ranges>
76#include <stdexcept>
77#include <string>
78#include <type_traits>
79#include <utility>
80#include <variant>
81#include <vector>
82
83namespace walberla {
84
85/** @brief Class that runs and controls the LB on waLBerla. */
86template <typename FloatType, lbmpy::Arch Architecture>
88#if not defined(WALBERLA_BUILD_WITH_CUDA)
89 static_assert(Architecture != lbmpy::Arch::GPU,
90 "waLBerla was compiled without CUDA support");
91#endif
92protected:
93 // ---- Types & Constants ----
94
95 using Kernels = detail::KernelTrait<FloatType, Architecture>;
97 typename Kernels::DynamicUBB>;
99 std::variant<typename Kernels::StreamCollisionModelThermalized,
100 typename Kernels::StreamCollisionModelLeesEdwards>;
101
102public:
103 /** @brief Stencil for collision and streaming operations. */
104 using Stencil = stencil::D3Q19;
105 /** @brief Stencil for ghost communication (includes domain corners). */
106 using StencilFull = stencil::D3Q27;
107 /** @brief Lattice model (e.g. blockforest). */
109
110protected:
111 // "underlying" field types (`GPUField` has no f-size info at compile time)
114
115public:
119#if defined(__CUDACC__) and defined(WALBERLA_BUILD_WITH_CUDA)
120 using GPUField = gpu::GPUField<FloatType>;
121#endif
122
123 struct GhostComm {
124 /** @brief Ghost communication operations. */
125 enum GhostCommFlags : unsigned {
126 PDF, ///< PDFs communication
127 VEL, ///< velocities communication
128 LAF, ///< last applied forces communication
129 UBB, ///< boundaries communication
131 };
132 };
133
134protected:
135 /**
136 * @brief Full communicator.
137 * We use the D3Q27 directions to update cells along the diagonals during
138 * a full ghost communication. This is needed to properly update the corners
139 * of the ghost layer when setting cell velocities or populations.
140 */
142 FieldTrait<FloatType, Stencil,
143 Architecture>::template RegularCommScheme<stencil::D3Q27>;
145 FieldTrait<FloatType, Stencil,
146 Architecture>::template BoundaryCommScheme<stencil::D3Q27>;
147 /**
148 * @brief Regular communicator.
149 * We use the same directions as the stencil during integration.
150 */
152 FieldTrait<FloatType, Stencil,
153 Architecture>::template RegularCommScheme<Stencil>;
154 template <class Field>
155 using PackInfo =
157
158protected:
159 // ---- Member Variables ----
160
161 // Physical parameters
162 FloatType m_viscosity; /// kinematic viscosity
163 FloatType m_density;
164 FloatType m_kT;
165 unsigned int m_seed;
166 double m_zc_to_md; // zero-centered conversion factor to MD units
167 double m_zc_to_lb; // zero-centered conversion factor to LB units
168
169 // lattice
170 std::shared_ptr<LatticeWalberla> m_lattice;
171
172 // Block data access handles
173 BlockDataID m_pdf_field_id;
175 BlockDataID m_flag_field_id;
176
179
182
183 /** Flag for boundary cells. */
184 FlagUID const Boundary_flag{"boundary"};
185 bool m_has_boundaries{false};
186
187 // boundaries
188 std::shared_ptr<BoundaryModel> m_boundary;
189
190 // communicators
191 std::shared_ptr<BoundaryFullCommunicator> m_boundary_communicator;
192 std::shared_ptr<RegularFullCommunicator> m_full_communicator;
193 std::shared_ptr<RegularFullCommunicator> m_pdf_communicator;
194 std::shared_ptr<RegularFullCommunicator> m_vel_communicator;
195 std::shared_ptr<RegularFullCommunicator> m_laf_communicator;
196 std::shared_ptr<PDFStreamingCommunicator> m_pdf_streaming_communicator;
197 std::bitset<GhostComm::SIZE> m_pending_ghost_comm;
199
200 // collision sweep
201 std::shared_ptr<CollisionModel> m_collision_model;
202
203 // force reset sweep + external force handling
204 std::shared_ptr<ResetForce<PdfField, VectorField>> m_reset_force;
205
206 // velocity update sweep
207 std::shared_ptr<typename Kernels::UpdateVelFromPDF>
209
210 // Lees-Edwards boundary interpolation
211 std::shared_ptr<LeesEdwardsPack> m_lees_edwards_callbacks;
212 std::shared_ptr<InterpolateAndShiftAtBoundary<_PdfField, FloatType>>
214 std::shared_ptr<InterpolateAndShiftAtBoundary<_VectorField, FloatType>>
216 std::shared_ptr<InterpolateAndShiftAtBoundary<_VectorField, FloatType>>
218
219public:
220 template <typename T> FloatType FloatType_c(T t) const {
221 return numeric_cast<FloatType>(t);
222 }
223
224 [[nodiscard]] std::size_t stencil_size() const noexcept override {
225 return static_cast<std::size_t>(Stencil::Size);
226 }
227
228 [[nodiscard]] bool is_double_precision() const noexcept override {
229 return std::is_same_v<FloatType, double>;
230 }
231
232 [[nodiscard]] bool is_gpu() const noexcept override {
233 return Architecture == lbmpy::Arch::GPU;
234 }
235
236public:
237 LBWalberlaImpl(std::shared_ptr<LatticeWalberla> lattice, double viscosity,
238 double density)
240 m_kT(FloatType{0}), m_seed(0u), m_zc_to_md(density),
241 m_zc_to_lb(1. / density), m_lattice(std::move(lattice)),
243
244 auto const &blocks = m_lattice->get_blocks();
245 auto const n_ghost_layers = m_lattice->get_ghost_layers();
246 if (n_ghost_layers == 0u)
247 throw std::runtime_error("At least one ghost layer must be used");
248
249 // Initialize and register fields (must use the "underlying" types)
256
257 // Initialize and register pdf field with zero centered density
258 auto pdf_setter = typename Kernels::InitialPDFsSetter(
260 for (auto &block : *blocks) {
261 pdf_setter(&block);
262 }
263
264 // Initialize and register flag field (fluid/boundary)
265 m_flag_field_id = field::addFlagFieldToStorage<FlagField>(
266 blocks, "flag field", n_ghost_layers);
267 // Initialize boundary sweep
268 reset_boundary_handling(m_lattice->get_blocks());
269
270 // Set up the communication and register fields
273
275
276 // Instantiate the sweep responsible for force double buffering and
277 // external forces
278 m_reset_force = std::make_shared<ResetForce<PdfField, VectorField>>(
280
281 // Instantiate velocity update sweep
283 std::make_shared<typename Kernels::UpdateVelFromPDF>(
285 }
286
287 ~LBWalberlaImpl() override = default;
288
289 // ---- Integration (Core LB Algorithm) ----
290
291 void integrate() override {
292 integrate_pull_scheme();
294 }
295
296protected:
297 void integrate_vtk_writers() override {
298 for (auto const &vtk_handle : m_vtk_auto | std::views::values) {
299 if (vtk_handle->enabled) {
300 vtk::writeFiles(vtk_handle->ptr)();
301 vtk_handle->execution_count++;
302 }
303 }
304 }
305
306private:
307 /**
308 * @brief One LB time step using the pull scheme.
309 * Sequence: reset forces, stream-collide, communicate PDFs,
310 * apply Lees-Edwards interpolation (if active), handle boundaries,
311 * update velocity field from PDFs.
312 */
313 void integrate_pull_scheme() {
315 auto const &blocks = get_lattice().get_blocks();
316 // Reset force fields
317 integrate_reset_force(blocks);
318 // LB stream collide
319 integrate_stream_collide(blocks);
320 // Mark pending ghost layer updates
321 // As pdf and laf are communicated directly afterwards, they are not set
324 m_pdf_streaming_communicator->communicate();
325 if (has_lees_edwards_bc()) {
326 apply_lees_edwards_pdf_interpolation(blocks);
327 apply_lees_edwards_last_applied_force_interpolation(blocks);
328 }
329 // Handle boundaries
330 if (m_has_boundaries) {
331 integrate_boundaries(blocks);
332 }
333 // Update velocities from pdfs
334 integrate_update_velocities_from_pdf(blocks);
335
336 if (has_lees_edwards_bc()) {
337 apply_lees_edwards_vel_interpolation_and_shift(blocks);
338 }
339 }
340
341 void integrate_stream_collide(std::shared_ptr<BlockStorage> const &blocks) {
342 auto &cm_variant = *m_collision_model;
343 for (auto &block : *blocks) {
344 auto const block_variant = std::variant<IBlock *>(&block);
345 std::visit(m_run_stream_collide_sweep, cm_variant, block_variant);
346 }
347 if (auto *cm =
348 std::get_if<typename Kernels::StreamCollisionModelThermalized>(
349 &cm_variant)) {
350 cm->setTime_step(cm->getTime_step() + 1u);
351 }
352 }
353
354 void integrate_reset_force(std::shared_ptr<BlockStorage> const &blocks) {
355 for (auto &block : *blocks)
356 (*m_reset_force)(&block);
357 }
358
359 void integrate_boundaries(std::shared_ptr<BlockStorage> const &blocks) {
360 for (auto &block : *blocks)
361 (*m_boundary)(&block);
362 }
363
364 /**
365 * @brief Run the boundary sweep, but keep the PDFs of the local domain.
366 * The boundary sweep writes the PDFs that fluid cells pull from
367 * neighboring boundary cells. When the boundary cell is in the ghost
368 * layer, the ghost communication cannot provide these PDFs, because the
369 * boundary sweep never writes them into the periodic image of that cell.
370 * The PDFs of the local domain are restored afterwards, because they
371 * need not stem from an LB step: e.g. a checkpoint can contain PDFs that
372 * the user set on boundary nodes, which the boundary sweep would
373 * overwrite. This temporarily stores a copy of all local PDFs.
374 */
375 void integrate_boundaries_in_ghost_layer(
376 std::shared_ptr<BlockStorage> const &blocks) {
377 std::vector<std::vector<FloatType>> local_pdfs;
378 for (auto &block : *blocks) {
379 auto const *pdf_field = block.template getData<PdfField>(m_pdf_field_id);
380 local_pdfs.emplace_back(
381 lbm::accessor::Population::get(pdf_field, pdf_field->xyzSize()));
382 }
383 integrate_boundaries(blocks);
384 auto local_pdfs_it = local_pdfs.cbegin();
385 for (auto &block : *blocks) {
386 auto *pdf_field = block.template getData<PdfField>(m_pdf_field_id);
387 lbm::accessor::Population::set(pdf_field, *local_pdfs_it,
388 pdf_field->xyzSize());
389 ++local_pdfs_it;
390 }
391 }
392
393 void integrate_update_velocities_from_pdf(
394 std::shared_ptr<BlockStorage> const &blocks) {
395 for (auto &block : *blocks)
396 (*m_update_velocities_from_pdf)(&block);
397 }
398
399private:
400 // ---- Collision Model ----
401
402 /**
403 * @brief Visitor for dispatching stream-collide sweeps.
404 * Handles both thermalized and Lees-Edwards collision models
405 * via @c std::visit on the @ref CollisionModel variant.
406 */
407 class StreamCollideSweepVisitor {
408 public:
409 using StructuredBlockStorage = LatticeWalberla::Lattice_T;
410
411 void operator()(typename Kernels::StreamCollisionModelThermalized &cm,
412 IBlock *b) {
413 cm.configure(m_storage, b);
414 cm(b);
415 }
416
417 void operator()(typename Kernels::StreamCollisionModelLeesEdwards &cm,
418 IBlock *b) {
419 cm.setV_s(static_cast<decltype(cm.getV_s())>(
420 m_lees_edwards_callbacks->get_shear_velocity()));
421 cm(b);
422 }
423
424 StreamCollideSweepVisitor() = default;
425 StreamCollideSweepVisitor(std::shared_ptr<StructuredBlockStorage> storage) {
426 m_storage = std::move(storage);
427 }
428 StreamCollideSweepVisitor(std::shared_ptr<StructuredBlockStorage> storage,
429 std::shared_ptr<LeesEdwardsPack> callbacks) {
430 m_storage = std::move(storage);
431 m_lees_edwards_callbacks = std::move(callbacks);
432 }
433
434 private:
435 std::shared_ptr<StructuredBlockStorage> m_storage{};
436 std::shared_ptr<LeesEdwardsPack> m_lees_edwards_callbacks{};
437 };
438 StreamCollideSweepVisitor m_run_stream_collide_sweep{};
439
440 /** @brief Relaxation rate omega from kinematic viscosity: 2/(6*nu+1). */
441 FloatType shear_mode_relaxation_rate() const;
442 /**
443 * @brief Odd-mode relaxation rate for the magic parameter relation.
444 * Ensures optimal bounce-back wall location for the two-relaxation-time
445 * model. Default magic number is 3/16.
446 */
447 FloatType odd_mode_relaxation_rate(
448 FloatType shear_relaxation,
449 FloatType magic_number = FloatType{3} / FloatType{16}) const;
450
451public:
452 void set_collision_model(double kT, unsigned int seed) override;
454 std::unique_ptr<LeesEdwardsPack> &&lees_edwards_pack) override;
455 void check_lebc(unsigned int shear_direction,
456 unsigned int shear_plane_normal) const override;
457
458public:
459 // ---- Ghost Communication ----
460
461 /**
462 * @brief Perform all pending ghost layer updates.
463 * Uses a lazy scheme: ghost communications are only executed when
464 * they have been marked as pending by a preceding write operation.
465 */
475
476 void ghost_communication_pdf() override {
478 assert(m_mpi_cart_comm_observer.is_valid());
479 m_pdf_communicator->communicate();
480 if (has_lees_edwards_bc()) {
481 auto const &blocks = get_lattice().get_blocks();
482 apply_lees_edwards_pdf_interpolation(blocks);
483 }
485 }
486 }
487
488 void ghost_communication_vel() override {
490 assert(m_mpi_cart_comm_observer.is_valid());
491 m_vel_communicator->communicate();
492 if (has_lees_edwards_bc()) {
493 auto const &blocks = get_lattice().get_blocks();
494 apply_lees_edwards_vel_interpolation_and_shift(blocks);
495 }
497 }
498 }
499
500 void ghost_communication_laf() override {
502 assert(m_mpi_cart_comm_observer.is_valid());
503 m_laf_communicator->communicate();
504 if (has_lees_edwards_bc()) {
505 auto const &blocks = get_lattice().get_blocks();
506 apply_lees_edwards_last_applied_force_interpolation(blocks);
507 }
509 }
510 }
511
514 assert(m_mpi_cart_comm_observer.is_valid());
515 m_boundary_communicator->communicate();
517 }
518 }
519
520 /**
521 * @brief Recompute the fields that the LB step derives from the PDFs.
522 * Runs the boundary sweep and the velocity update sweep on the current
523 * PDFs, like the final stage of @c integrate_pull_scheme(), and
524 * communicates the ghost layers. The boundary sweep also restores the
525 * boundary forces.
526 */
527 void update_derived_fields() override {
528 assert(m_mpi_cart_comm_observer.is_valid());
529 auto const &blocks = get_lattice().get_blocks();
531 if (m_has_boundaries) {
532 integrate_boundaries_in_ghost_layer(blocks);
533 }
534 integrate_update_velocities_from_pdf(blocks);
537 }
538
539 /** @brief Communicate all fields at once using the D3Q27 stencil. */
541 assert(m_mpi_cart_comm_observer.is_valid());
542 m_full_communicator->communicate();
543 if (has_lees_edwards_bc()) {
545 }
549 }
550
551private:
552 // ---- Lees-Edwards Boundary Conditions ----
553
554 auto has_lees_edwards_bc() const {
555 return std::holds_alternative<
556 typename Kernels::StreamCollisionModelLeesEdwards>(*m_collision_model);
557 }
558
559 void apply_lees_edwards_pdf_interpolation(
560 std::shared_ptr<BlockStorage> const &blocks) {
561 for (auto &block : *blocks)
562 (*m_lees_edwards_pdf_interpol_sweep)(&block);
563 }
564
565 void apply_lees_edwards_vel_interpolation_and_shift(
566 std::shared_ptr<BlockStorage> const &blocks) {
567 for (auto &block : *blocks)
568 (*m_lees_edwards_vel_interpol_sweep)(&block);
569 }
570
571 void apply_lees_edwards_last_applied_force_interpolation(
572 std::shared_ptr<BlockStorage> const &blocks) {
573 for (auto &block : *blocks)
574 (*m_lees_edwards_last_applied_force_interpol_sweep)(&block);
575 }
576
577public:
579 auto const &blocks = get_lattice().get_blocks();
580 apply_lees_edwards_pdf_interpolation(blocks);
581 apply_lees_edwards_vel_interpolation_and_shift(blocks);
582 apply_lees_edwards_last_applied_force_interpolation(blocks);
583 }
584
585public:
586 // ---- Node & Slice Accessors (by quantity) ----
587
588 // Velocity
589 std::optional<Utils::Vector3d>
591 bool consider_ghosts = false) const override;
592 bool set_node_velocity(Utils::Vector3i const &node,
593 Utils::Vector3d const &v) override;
594 std::vector<double>
595 get_slice_velocity(Utils::Vector3i const &lower_corner,
596 Utils::Vector3i const &upper_corner) const override;
597 void set_slice_velocity(Utils::Vector3i const &lower_corner,
598 Utils::Vector3i const &upper_corner,
599 std::vector<double> const &velocity) override;
600
601 // Density
602 std::optional<double>
604 bool consider_ghosts = false) const override;
605 bool set_node_density(Utils::Vector3i const &node, double density) override;
606 std::vector<double>
607 get_slice_density(Utils::Vector3i const &lower_corner,
608 Utils::Vector3i const &upper_corner) const override;
609 void set_slice_density(Utils::Vector3i const &lower_corner,
610 Utils::Vector3i const &upper_corner,
611 std::vector<double> const &density) override;
612
613 // Population
614 std::optional<std::vector<double>>
616 bool consider_ghosts = false) const override;
617 bool set_node_population(Utils::Vector3i const &node,
618 std::vector<double> const &population) override;
619 std::vector<double>
620 get_slice_population(Utils::Vector3i const &lower_corner,
621 Utils::Vector3i const &upper_corner) const override;
622 void set_slice_population(Utils::Vector3i const &lower_corner,
623 Utils::Vector3i const &upper_corner,
624 std::vector<double> const &population) override;
625
626 // Force
627 std::optional<Utils::Vector3d>
628 get_node_force_to_be_applied(Utils::Vector3i const &node) const override;
629 std::optional<Utils::Vector3d>
631 bool consider_ghosts = false) const override;
633 Utils::Vector3d const &force) override;
634 std::vector<double> get_slice_last_applied_force(
635 Utils::Vector3i const &lower_corner,
636 Utils::Vector3i const &upper_corner) const override;
637 void set_slice_last_applied_force(Utils::Vector3i const &lower_corner,
638 Utils::Vector3i const &upper_corner,
639 std::vector<double> const &force) override;
640
641 // Pressure tensor
642 std::optional<Utils::VectorXd<9>>
643 get_node_pressure_tensor(Utils::Vector3i const &node) const override;
644 std::vector<double>
645 get_slice_pressure_tensor(Utils::Vector3i const &lower_corner,
646 Utils::Vector3i const &upper_corner) const override;
647
648private:
649 // ---- Interpolation (position-based access) ----
650
651 /** @brief Return a B-spline interpolation kernel for force distribution. */
652 auto make_force_interpolation_kernel() const;
653 /** @brief Return a B-spline interpolation kernel for velocity readout. */
654 auto make_velocity_interpolation_kernel() const;
655 /** @brief Return a B-spline interpolation kernel for density readout. */
656 auto make_density_interpolation_kernel() const;
657
658public:
659 std::function<bool(Utils::Vector3d const &)>
660 make_lattice_position_checker(bool consider_points_in_halo) const override;
661 bool add_force_at_pos(Utils::Vector3d const &pos,
662 Utils::Vector3d const &force) override;
663 void add_forces_at_pos(std::vector<Utils::Vector3d> const &pos,
664 std::vector<Utils::Vector3d> const &forces) override;
665 std::optional<Utils::Vector3d>
667 bool consider_points_in_halo = false) const override;
668 std::vector<Utils::Vector3d>
669 get_velocities_at_pos(std::vector<Utils::Vector3d> const &pos) override;
670 std::optional<double>
672 bool consider_points_in_halo = false) const override;
673 std::vector<double>
674 get_densities_at_pos(std::vector<Utils::Vector3d> const &pos) override;
675
676public:
677 // ---- Boundary Handling ----
678
679 void reset_boundary_handling(std::shared_ptr<BlockStorage> const &blocks) {
680 auto const [lc, uc] = m_lattice->get_local_grid_range(true);
681 m_boundary =
682 std::make_shared<BoundaryModel>(blocks, m_pdf_field_id, m_flag_field_id,
683 CellInterval{to_cell(lc), to_cell(uc)});
684 }
685
686 void on_boundary_add();
687 void clear_boundaries() override;
688 void reallocate_ubb_field() override;
689 void
690 update_boundary_from_shape(std::vector<int> const &raster_flat,
691 std::vector<double> const &data_flat) override;
692 std::optional<Utils::Vector3d>
694 bool consider_ghosts = false) const override;
696 Utils::Vector3d const &velocity) override;
697 std::vector<std::optional<Utils::Vector3d>> get_slice_velocity_at_boundary(
698 Utils::Vector3i const &lower_corner,
699 Utils::Vector3i const &upper_corner) const override;
701 Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner,
702 std::vector<std::optional<Utils::Vector3d>> const &velocity) override;
703 std::optional<Utils::Vector3d>
704 get_node_boundary_force(Utils::Vector3i const &node) const override;
705 bool remove_node_from_boundary(Utils::Vector3i const &node) override;
706 std::optional<bool>
708 bool consider_ghosts = false) const override;
709 std::vector<bool>
710 get_slice_is_boundary(Utils::Vector3i const &lower_corner,
711 Utils::Vector3i const &upper_corner) const override;
713 std::vector<int> const &raster_flat) const override;
714 [[nodiscard]] Utils::Vector3d get_boundary_force() const override;
715
716private:
717 [[nodiscard]] Utils::Vector3i flat_index_to_node(int index) const;
718 [[nodiscard]] Utils::Vector3i get_neighbor_node(Utils::Vector3i const &node,
719 int dir) const;
720
721public:
722 // ---- Global Reductions & Physical Parameters ----
723
724 // Global pressure tensor
725 [[nodiscard]] Utils::VectorXd<9> get_pressure_tensor() const override {
726 Matrix3<FloatType> tensor(FloatType{0});
727 for (auto const &block : *get_lattice().get_blocks()) {
728 auto pdf_field = block.template getData<PdfField>(m_pdf_field_id);
730 }
731 auto const &grid_size = get_lattice().get_grid_dimensions();
732 auto const number_of_nodes = Utils::product(grid_size);
734 return to_vector9d(tensor) * (1. / static_cast<double>(number_of_nodes));
735 }
736
737 // Global momentum
738 [[nodiscard]] Utils::Vector3d get_momentum() const override {
739 Vector3<FloatType> mom(FloatType{0});
740 for (auto const &block : *get_lattice().get_blocks()) {
741 auto pdf_field = block.template getData<PdfField>(m_pdf_field_id);
742 auto force_field =
743 block.template getData<VectorField>(m_last_applied_force_field_id);
744 mom += lbm::accessor::MomentumDensity::reduce(pdf_field, force_field,
745 m_density);
746 }
747 return to_vector3d(mom);
748 }
749
750 // Global external force
751 void set_external_force(Utils::Vector3d const &ext_force) override {
752 m_reset_force->set_ext_force(zero_centered_to_lb(ext_force));
753 }
754
755 [[nodiscard]] Utils::Vector3d get_external_force() const noexcept override {
756 return zero_centered_to_md(m_reset_force->get_ext_force());
757 }
758
759 void set_viscosity(double viscosity) override {
760 m_viscosity = FloatType_c(viscosity);
761 }
762
763 [[nodiscard]] double get_viscosity() const noexcept override {
764 return static_cast<double>(m_viscosity);
765 }
766
767 [[nodiscard]] double get_density() const noexcept override {
768 return static_cast<double>(m_density);
769 }
770
771 [[nodiscard]] double get_kT() const noexcept override {
772 return static_cast<double>(m_kT);
773 }
774
775 [[nodiscard]] unsigned int get_seed() const noexcept override {
776 return m_seed;
777 }
778
779 [[nodiscard]] std::optional<uint64_t> get_rng_state() const override {
780 auto const cm =
781 std::get_if<typename Kernels::StreamCollisionModelThermalized>(
783 if (!cm or m_kT == 0.) {
784 return std::nullopt;
785 }
786 return {static_cast<uint64_t>(cm->getTime_step())};
787 }
788
789 void set_rng_state(uint64_t counter) override {
790 auto const cm =
791 std::get_if<typename Kernels::StreamCollisionModelThermalized>(
793 if (!cm or m_kT == 0.) {
794 throw std::runtime_error("This LB instance is unthermalized");
795 }
796 assert(counter <=
797 static_cast<uint32_t>(std::numeric_limits<uint_t>::max()));
798 cm->setTime_step(static_cast<uint32_t>(counter));
799 }
800
801 [[nodiscard]] LatticeWalberla const &get_lattice() const noexcept override {
802 return *m_lattice;
803 }
804
805 [[nodiscard]] std::size_t get_velocity_field_id() const noexcept override {
806 return m_velocity_field_id;
807 }
808
809 [[nodiscard]] std::size_t get_force_field_id() const noexcept override {
811 }
812
813 /**
814 * @brief Correction factor for off-diagonal pressure tensor elements.
815 * Compensates for the viscosity-dependent error in the non-equilibrium
816 * stress: factor = nu / (nu + 1/6).
817 */
819 return m_viscosity / (m_viscosity + FloatType{1} / FloatType{6});
820 }
821
822 void pressure_tensor_correction(Matrix3<FloatType> &tensor) const {
823 auto const revert_factor = pressure_tensor_correction_factor();
824 for (auto const i : {1u, 2u, 3u, 5u, 6u, 7u}) {
825 tensor[i] *= revert_factor;
826 }
827 }
828
829 void pressure_tensor_correction(std::span<FloatType, 9ul> tensor) const {
830 auto const revert_factor = pressure_tensor_correction_factor();
831 for (auto const i : {1u, 2u, 3u, 5u, 6u, 7u}) {
832 tensor[i] *= revert_factor;
833 }
834 }
835
836protected:
837 /**
838 * @brief Scale data by a conversion factor (in-place).
839 * Used for zero-centered density representation: LB internally stores
840 * density fluctuations around zero, while the user interface uses
841 * absolute densities. The conversion factors @ref m_zc_to_md and
842 * @ref m_zc_to_lb translate between these representations.
843 */
844 template <typename T>
845 void zero_centered_transform_impl(T &data, auto const factor) const {
846 if constexpr (std::is_arithmetic_v<T>) {
847 static_assert(std::is_floating_point_v<T>);
848 data *= static_cast<T>(factor);
849 } else {
850 auto const coef = static_cast<typename T::value_type>(factor);
851 std::transform(std::begin(data), std::end(data), std::begin(data),
852 [coef](auto value) { return value * coef; });
853 }
854 }
855
856 void zero_centered_to_lb_in_place(auto &data) const {
858 }
859
860 void zero_centered_to_md_in_place(auto &data) const {
862 }
863
864 auto zero_centered_to_lb(auto const &data) const {
865 auto transformed_data = data;
866 zero_centered_to_lb_in_place(transformed_data);
867 return transformed_data;
868 }
869
870 auto zero_centered_to_md(auto const &data) const {
871 auto transformed_data = data;
872 zero_centered_to_md_in_place(transformed_data);
873 return transformed_data;
874 }
875
876public:
877 // ---- File I/O ----
878
879 void register_vtk_field_filters(walberla::vtk::VTKOutput &vtk_obj) override {
880 field::FlagFieldCellFilter<FlagField> fluid_filter(m_flag_field_id);
881 fluid_filter.addFlag(Boundary_flag);
882 vtk_obj.addCellExclusionFilter(fluid_filter);
883 }
884
885 void register_vtk_field_writers(walberla::vtk::VTKOutput &vtk_obj,
886 LatticeModel::units_map const &units,
887 int flag_observables) override;
888
889protected:
890 // ---- Private Infrastructure Helpers ----
891
892 /**
893 * @brief Convenience function to add a field with a custom allocator.
894 *
895 * When vectorization is off, let waLBerla decide which memory allocator
896 * to use. When vectorization is on, the aligned memory allocator is
897 * required, otherwise <tt>cpu_vectorize_info["assume_aligned"]</tt> will
898 * trigger assertions. That is because for single-precision kernels the
899 * waLBerla heuristic in <tt>src/field/allocation/FieldAllocator.h</tt>
900 * will fall back to @c StdFieldAlloc, yet @c AllocateAligned is needed
901 * for intrinsics to work.
902 */
903 template <typename Field> auto add_to_storage(std::string const tag) {
904 auto const &blocks = m_lattice->get_blocks();
905 auto const n_ghost_layers = m_lattice->get_ghost_layers();
906#if defined(__CUDACC__) and defined(WALBERLA_BUILD_WITH_CUDA)
907 if constexpr (Architecture == lbmpy::Arch::GPU) {
908 auto field_id = gpu::addGPUFieldToStorage<GPUField>(
909 blocks, tag, Field::F_SIZE, field::fzyx, n_ghost_layers);
910 if constexpr (std::is_same_v<Field, _VectorField>) {
911 for (auto &block : *blocks) {
912 auto field = block.template getData<GPUField>(field_id);
913 lbm::accessor::Vector::initialize(field, Vector3<FloatType>{0});
914 }
915 } else if constexpr (std::is_same_v<Field, _PdfField>) {
916 for (auto &block : *blocks) {
917 auto field = block.template getData<GPUField>(field_id);
919 field, std::array<FloatType, Stencil::Size>{});
920 }
921 }
922 return field_id;
923 }
924#endif
925 {
926#ifdef ESPRESSO_BUILD_WITH_AVX_KERNELS
927 constexpr auto alignment = field::SIMDAlignment();
928 using value_type = Field::value_type;
929 using Allocator = field::AllocateAligned<value_type, alignment>;
930 auto const allocator = std::make_shared<Allocator>();
931 auto const empty_set = Set<SUID>::emptySet();
932 return field::addToStorage<Field>(
933 blocks, tag, field::internal::defaultSize, FloatType{0}, field::fzyx,
934 n_ghost_layers, false, {}, empty_set, empty_set, allocator);
935#else // ESPRESSO_BUILD_WITH_AVX_KERNELS
936 return field::addToStorage<Field>(blocks, tag, FloatType{0}, field::fzyx,
937 n_ghost_layers);
938#endif // ESPRESSO_BUILD_WITH_AVX_KERNELS
939 }
940 }
941
942 /**
943 * @brief Set up D3Q27 communicators for full ghost layer updates.
944 * Creates per-field communicators (PDF, velocity, last-applied force)
945 * as well as a combined communicator and the boundary communicator.
946 */
948 auto const &blocks = m_lattice->get_blocks();
949
950 m_full_communicator = std::make_shared<RegularFullCommunicator>(blocks);
951 m_full_communicator->addPackInfo(
952 std::make_shared<PackInfo<PdfField>>(m_pdf_field_id));
953 m_full_communicator->addPackInfo(
955 m_full_communicator->addPackInfo(
956 std::make_shared<PackInfo<VectorField>>(m_velocity_field_id));
957
958 m_pdf_communicator = std::make_shared<RegularFullCommunicator>(blocks);
959 m_vel_communicator = std::make_shared<RegularFullCommunicator>(blocks);
960 m_laf_communicator = std::make_shared<RegularFullCommunicator>(blocks);
961 m_pdf_communicator->addPackInfo(
962 std::make_shared<PackInfo<PdfField>>(m_pdf_field_id));
963 m_vel_communicator->addPackInfo(
964 std::make_shared<PackInfo<VectorField>>(m_velocity_field_id));
965 m_laf_communicator->addPackInfo(
967
969 std::make_shared<BoundaryFullCommunicator>(blocks);
970 m_boundary_communicator->addPackInfo(
973 auto boundary_packinfo = std::make_shared<
976 boundary_packinfo->setup_boundary_handle(m_lattice, m_boundary);
977 m_boundary_communicator->addPackInfo(boundary_packinfo);
978 }
979
980 /**
981 * @brief Set up the communicator used during integration.
982 * Uses optimized streaming pack info when neither boundaries nor
983 * Lees-Edwards boundary conditions are active; falls back to the
984 * generic pack info otherwise.
985 */
987 auto const setup = [this]<typename PackInfoPdf, typename PackInfoVec>() {
988 auto const &blocks = m_lattice->get_blocks();
990 std::make_shared<PDFStreamingCommunicator>(blocks);
991 m_pdf_streaming_communicator->addPackInfo(
992 std::make_shared<PackInfoPdf>(m_pdf_field_id));
993 m_pdf_streaming_communicator->addPackInfo(
994 std::make_shared<PackInfoVec>(m_last_applied_force_field_id));
995 };
997 using PackInfoPdf = FieldTrait::PackInfoStreamingPdf;
998 using PackInfoVec = FieldTrait::PackInfoStreamingVec;
999 if (m_has_boundaries or (m_collision_model and has_lees_edwards_bc())) {
1000 setup.template operator()<PackInfo<PdfField>, PackInfoVec>();
1001 } else {
1002 setup.template operator()<PackInfoPdf, PackInfoVec>();
1003 }
1004 }
1005};
1006
1007} // namespace walberla
1008
1009// Out-of-class template method definitions
1012#include "LBInterpolation.impl.hpp"
1013#include "LBNodeAccess.impl.hpp"
1014#include "LBSliceAccess.impl.hpp"
1015#include "LBVTK.impl.hpp"
Out-of-class boundary access definitions for walberla::LBWalberlaImpl.
Out-of-class collision model setup definitions for walberla::LBWalberlaImpl.
Out-of-class position-based interpolation definitions for walberla::LBWalberlaImpl.
Out-of-class node access definitions for walberla::LBWalberlaImpl.
Out-of-class slice access definitions for walberla::LBWalberlaImpl.
Out-of-class VTK writer registration definition for walberla::LBWalberlaImpl.
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.
walberla::blockforest::StructuredBlockForest Lattice_T
Boundary class optimized for sparse data.
void add_forces_at_pos(std::vector< Utils::Vector3d > const &pos, std::vector< Utils::Vector3d > const &forces) override
Distribute forces to the lattice at given positions.
std::shared_ptr< typename Kernels::UpdateVelFromPDF > m_update_velocities_from_pdf
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
Scale data by a conversion factor (in-place).
void reset_boundary_handling(std::shared_ptr< BlockStorage > const &blocks)
FieldTrait< FloatType, Stencil, Architecture >::template RegularCommScheme< Stencil > PDFStreamingCommunicator
Regular communicator.
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
Perform all pending ghost layer updates.
void pressure_tensor_correction(Matrix3< FloatType > &tensor) const
std::optional< Utils::Vector3d > get_node_velocity(Utils::Vector3i const &node, bool consider_ghosts=false) const override
Utils::Vector3d get_boundary_force_from_shape(std::vector< int > const &raster_flat) const override
Total force exerted by the fluid on a subset of boundary nodes.
std::shared_ptr< RegularFullCommunicator > m_full_communicator
std::size_t get_force_field_id() const noexcept override
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
void pressure_tensor_correction(std::span< FloatType, 9ul > tensor) const
BoundaryModel::FlagField FlagField
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
FieldTrait< FloatType, Stencil >::VectorField _VectorField
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
std::function< bool(Utils::Vector3d const &)> make_lattice_position_checker(bool consider_points_in_halo) const override
FieldTrait< FloatType, Stencil >::PdfField _PdfField
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
FieldTrait< FloatType, Stencil, Architecture >::template PackInfo< Field > PackInfo
void update_boundary_from_shape(std::vector< int > const &raster_flat, std::vector< double > const &data_flat) override
Set boundary conditions from a rasterized shape.
std::shared_ptr< BoundaryModel > m_boundary
FieldTrait< FloatType, Stencil, Architecture >::PdfField PdfField
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
Set up the thermalized collision model.
std::vector< Utils::Vector3d > get_velocities_at_pos(std::vector< Utils::Vector3d > const &pos) override
Interpolate velocities at given positions (batch version).
void ghost_communication_laf() override
std::optional< bool > get_node_is_boundary(Utils::Vector3i const &node, bool consider_ghosts=false) const override
std::shared_ptr< ResetForce< PdfField, VectorField > > m_reset_force
void setup_streaming_communicator()
Set up the communicator used during integration.
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
void on_boundary_add()
Lazily enable boundary mode on first boundary addition.
std::shared_ptr< BoundaryFullCommunicator > m_boundary_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.
void ghost_communication_full()
Communicate all fields at once using the D3Q27 stencil.
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
std::optional< double > get_node_density(Utils::Vector3i const &node, bool consider_ghosts=false) const override
std::variant< typename Kernels::StreamCollisionModelThermalized, typename Kernels::StreamCollisionModelLeesEdwards > CollisionModel
void check_lebc(unsigned int shear_direction, unsigned int shear_plane_normal) const override
Verify that MD and LB Lees-Edwards parameters are consistent.
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
FloatType FloatType_c(T t) const
std::shared_ptr< RegularFullCommunicator > m_laf_communicator
std::size_t get_velocity_field_id() const noexcept override
Utils::VectorXd< 9 > get_pressure_tensor() const override
ResourceObserver m_mpi_cart_comm_observer
std::shared_ptr< InterpolateAndShiftAtBoundary< _PdfField, FloatType > > m_lees_edwards_pdf_interpol_sweep
FieldTrait< FloatType, Stencil, Architecture >::template BoundaryCommScheme< stencil::D3Q27 > BoundaryFullCommunicator
void set_external_force(Utils::Vector3d const &ext_force) override
void setup_full_communicator()
Set up D3Q27 communicators for full ghost layer updates.
std::optional< Utils::Vector3d > get_velocity_at_pos(Utils::Vector3d const &pos, bool consider_points_in_halo=false) const override
FieldTrait< FloatType, Stencil, Architecture >::VectorField VectorField
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< RegularFullCommunicator > m_vel_communicator
std::bitset< GhostComm::SIZE > m_pending_ghost_comm
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
double get_density() const noexcept override
void ghost_communication_pdf() override
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
FieldTrait< FloatType, Stencil, Architecture >::template RegularCommScheme< stencil::D3Q27 > RegularFullCommunicator
Full communicator.
bool set_node_population(Utils::Vector3i const &node, std::vector< double > const &population) override
BoundaryHandling< FloatType, Vector3< FloatType >, typename Kernels::DynamicUBB > BoundaryModel
bool is_gpu() const noexcept override
FloatType pressure_tensor_correction_factor() const
Correction factor for off-diagonal pressure tensor elements.
std::shared_ptr< PDFStreamingCommunicator > m_pdf_streaming_communicator
detail::KernelTrait< FloatType, Architecture > Kernels
BlockDataID m_last_applied_force_field_id
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 update_derived_fields() override
Recompute the fields that the LB step derives from the PDFs.
bool add_force_at_pos(Utils::Vector3d const &pos, Utils::Vector3d const &force) override
void setup_boundary_handle(std::shared_ptr< LatticeWalberla > lattice, std::shared_ptr< Boundary_T > boundary)
static double * block(double *p, std::size_t index, std::size_t size)
Definition elc.cpp:169
T product(Vector< T, N > const &v)
Definition Vector.hpp:379
VectorXd< 3 > Vector3d
Definition Vector.hpp:207
Vector< double, N > VectorXd
Definition Vector.hpp:205
VectorXi< 3 > Vector3i
Definition Vector.hpp:216
STL namespace.
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 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)
\file PackInfoPdfDoublePrecision.cpp \author pystencils
auto to_vector3d(Vector3< T > const &v) noexcept
Cell to_cell(signed_integral_vector auto const &xyz)
ResourceObserver get_mpi_cart_comm_observer()
Get an observer on waLBerla's MPI Cartesian communicator status.
auto to_vector9d(Matrix3< T > const &m) noexcept
static Utils::Vector3d velocity(Particle const &p_ref, Particle const &p_vs)
Velocity of the virtual site.
Definition relative.cpp:65
Observer to monitor the lifetime of a shared resource.
detail::KernelTrait< FT, AT >::PackInfoVec PackInfoStreamingVec
Definition lb_fields.hpp:37
field::GhostLayerField< FT, PdfStencil::Size > PdfField
Definition lb_fields.hpp:33
field::GhostLayerField< FT, uint_t{3u}> VectorField
Definition lb_fields.hpp:34
detail::KernelTrait< FT, AT >::PackInfoPdf PackInfoStreamingPdf
Definition lb_fields.hpp:36
GhostCommFlags
Ghost communication operations.
@ LAF
last applied forces communication