22#include <blockforest/communication/UniformBufferedScheme.h>
23#include <field/AddToStorage.h>
24#include <field/FlagField.h>
25#include <field/FlagUID.h>
26#include <field/GhostLayerField.h>
27#include <field/communication/PackInfo.h>
28#include <field/vtk/FlagFieldCellFilter.h>
29#include <field/vtk/VTKWriter.h>
30#include <stencil/D3Q27.h>
31#if defined(__CUDACC__)
32#include <gpu/AddGPUFieldToStorage.h>
33#include <gpu/HostFieldAllocator.h>
34#include <gpu/communication/MemcpyPackInfo.h>
35#include <gpu/communication/UniformGPUScheme.h>
38#include "../BoundaryHandling.hpp"
39#include "../BoundaryPackInfo.hpp"
40#include "../utils/boundary.hpp"
41#include "../utils/types_conversion.hpp"
43#if defined(__CUDACC__)
69template <std::size_t FluxCount = 13,
typename FloatType = double,
72 using ContinuityKernel =
74 using DiffusiveFluxKernelUnthermalized =
75 typename detail::KernelTrait<FloatType,
76 Architecture>::DiffusiveFluxKernel;
77 using DiffusiveFluxKernelThermalized =
typename detail::KernelTrait<
78 FloatType, Architecture>::DiffusiveFluxKernelThermalized;
79 using AdvectiveFluxKernel =
80 typename detail::KernelTrait<FloatType,
81 Architecture>::AdvectiveFluxKernel;
82 using FrictionCouplingKernel =
83 typename detail::KernelTrait<FloatType,
84 Architecture>::FrictionCouplingKernel;
85 using DiffusiveFluxKernelElectrostaticUnthermalized =
86 typename detail::KernelTrait<
87 FloatType, Architecture>::DiffusiveFluxKernelElectrostatic;
88 using DiffusiveFluxKernelElectrostaticThermalized =
89 typename detail::KernelTrait<
90 FloatType, Architecture>::DiffusiveFluxKernelElectrostaticThermalized;
92 using DiffusiveFluxKernel = std::variant<DiffusiveFluxKernelUnthermalized,
93 DiffusiveFluxKernelThermalized>;
94 using DiffusiveFluxKernelElectrostatic =
95 std::variant<DiffusiveFluxKernelElectrostaticUnthermalized,
96 DiffusiveFluxKernelElectrostaticThermalized>;
115 template <
typename FT, lbmpy::Arch AT = lbmpy::Arch::CPU>
struct FieldTrait {
119 template <
class Field>
120 using PackInfo = field::communication::PackInfo<Field>;
121 template <
class Stencil>
123 blockforest::communication::UniformBufferedScheme<Stencil>;
124 template <
class Stencil>
126 blockforest::communication::UniformBufferedScheme<Stencil>;
128 using FlagField = walberla::FlagField<walberla::uint8_t>;
129#if defined(__CUDACC__)
133 template <
class Field>
134 using MemcpyPackInfo = gpu::communication::MemcpyPackInfo<Field>;
137 template <
typename Stencil>
138 class UniformGPUScheme
139 :
public gpu::communication::UniformGPUScheme<Stencil> {
141 explicit UniformGPUScheme(
auto const &bf)
142 : gpu::communication::UniformGPUScheme<Stencil>(
148 template <
class Field>
using PackInfo = MemcpyPackInfo<Field>;
149 template <
class Stencil>
151 template <
class Stencil>
153 blockforest::communication::UniformBufferedScheme<Stencil>;
155 using GPUField = gpu::GPUField<FloatType>;
176#if defined(__CUDACC__)
182 return numeric_cast<FloatType>(t);
190 return std::is_same_v<FloatType, double>;
194 FloatType m_diffusion;
199 bool m_friction_coupling;
211#if defined(__CUDACC__)
212 std::optional<BlockDataID> m_density_cpu_field_id;
213 std::optional<BlockDataID> m_flux_cpu_field_id;
228 std::unique_ptr<DiffusiveFluxKernelElectrostatic>
232#if defined(__CUDACC__)
233 std::shared_ptr<gpu::HostFieldAllocator<FloatType>> m_host_field_allocator;
251 template <
typename Field>
253 auto const &blocks =
m_lattice->get_blocks();
254 auto const n_ghost_layers =
m_lattice->get_ghost_layers();
256 return field::addToStorage<Field>(blocks, tag, FloatType{value},
257 field::fzyx, n_ghost_layers);
259#if defined(__CUDACC__)
261 auto field_id = gpu::addGPUFieldToStorage<GPUField>(
262 blocks, tag, Field::F_SIZE, field::fzyx, n_ghost_layers);
263 if constexpr (std::is_same_v<Field, _DensityField>) {
265 auto field =
block->template getData<GPUField>(field_id);
268 }
else if constexpr (std::is_same_v<Field, _FluxField>) {
270 auto field =
block->template getData<GPUField>(field_id);
272 std::array<FloatType, FluxCount>{});
282 auto const [lc, uc] =
m_lattice->get_local_grid_range(
true);
290 auto const [lc, uc] =
m_lattice->get_local_grid_range(
true);
298 typename stencil::D3Q27>;
301 typename stencil::D3Q27>;
306 template <
class Field>
313 double density,
bool advection,
bool friction_coupling,
314 bool thermalized,
unsigned int seed)
316 m_valency(
FloatType_c(valency)), m_ext_efield(ext_efield),
317 m_advection(advection), m_friction_coupling(friction_coupling),
321 auto const &blocks =
m_lattice->get_blocks();
322 auto const n_ghost_layers =
m_lattice->get_ghost_layers();
327 add_to_storage<_FluxField>(
"flux field",
FloatType_c(0.0));
332#if defined(__CUDACC__)
333 m_host_field_allocator =
334 std::make_shared<gpu::HostFieldAllocator<FloatType>>();
340 set_diffusion_kernels();
345 blocks,
"flag field density", n_ghost_layers);
349 blocks,
"flag field flux", n_ghost_layers);
356 std::make_shared<BoundaryFullCommunicator>(blocks);
360 auto flux_boundary_packinfo = std::make_shared<
373 [[nodiscard]]
double get_kT() const noexcept
override {
return m_kT; }
381 return m_friction_coupling;
387 return static_cast<bool>(
390 [[nodiscard]]
unsigned int get_seed() const noexcept
override {
399 return {
static_cast<uint64_t
>(kernel->getTime_step())};
404 auto visitor = [m_diffusion = m_diffusion](
auto &kernel) {
405 kernel.setD(m_diffusion);
413 std::visit([m_kT = m_kT](
auto &kernel) { kernel.setKt(m_kT); },
420 [m_valency = m_valency](
auto &kernel) { kernel.setZ(m_valency); },
427 m_friction_coupling = friction_coupling;
433 auto const kernel_electrostatic =
434 std::get_if<DiffusiveFluxKernelElectrostaticThermalized>(
437 if (!kernel or !kernel_electrostatic) {
438 throw std::runtime_error(
"This EK instance is unthermalized");
441 static_cast<uint32_t
>(std::numeric_limits<uint_t>::max()));
442 kernel->setTime_step(
static_cast<uint32_t
>(counter));
443 kernel_electrostatic->setTime_step(
static_cast<uint32_t
>(counter));
447 m_ext_efield = field;
450 [
this](
auto &kernel) {
461 (*m_full_communication)();
476 void set_diffusion_kernels() {
477 auto kernel = DiffusiveFluxKernelUnthermalized(
479 m_diffusive_flux = std::make_unique<DiffusiveFluxKernel>(std::move(kernel));
481 auto kernel_electrostatic = DiffusiveFluxKernelElectrostaticUnthermalized(
488 std::make_unique<DiffusiveFluxKernelElectrostatic>(
489 std::move(kernel_electrostatic));
496 auto kernel = DiffusiveFluxKernelThermalized(
498 grid_dim[0], grid_dim[1], grid_dim[2], seed, 0);
500 auto kernel_electrostatic = DiffusiveFluxKernelElectrostaticThermalized(
509 for (
auto &
block : *blocks) {
510 kernel.configure(blocks, &
block);
511 kernel_electrostatic.configure(blocks, &
block);
514 m_diffusive_flux = std::make_unique<DiffusiveFluxKernel>(std::move(kernel));
516 std::make_unique<DiffusiveFluxKernelElectrostatic>(
517 std::move(kernel_electrostatic));
520 void kernel_boundary_density() {
522 (*m_boundary_density)(&
block);
526 void kernel_boundary_flux() {
528 (*m_boundary_flux)(&
block);
532 void kernel_continuity() {
534 (*m_continuity).run(&
block);
538 void kernel_diffusion() {
540 std::visit([&
block](
auto &kernel) { kernel.run(&
block); },
546 kernel->setTime_step(kernel->getTime_step() + 1u);
548 auto *kernel_electrostatic =
549 std::get_if<DiffusiveFluxKernelElectrostaticThermalized>(
551 kernel_electrostatic->setTime_step(kernel_electrostatic->getTime_step() +
556 void kernel_advection(std::size_t
const velocity_id) {
558 BlockDataID(velocity_id));
564 void kernel_friction_coupling(std::size_t
const force_id,
565 double const lb_density) {
566 auto kernel = FrictionCouplingKernel(
574 void kernel_diffusion_electrostatic(std::size_t
const potential_id) {
575 auto const phiID = BlockDataID(potential_id);
576 std::visit([phiID](
auto &kernel) { kernel.setPhiID(phiID); },
580 std::visit([&
block](
auto &kernel) { kernel.run(&
block); },
584 if (
auto *kernel_electrostatic =
585 std::get_if<DiffusiveFluxKernelElectrostaticThermalized>(
587 kernel_electrostatic->setTime_step(kernel_electrostatic->getTime_step() +
592 kernel->setTime_step(kernel->getTime_step() + 1u);
596 void kernel_migration() {}
598 void update_boundary_fields() {
606 auto &vtk_handle = it.second;
607 if (vtk_handle->enabled) {
608 vtk::writeFiles(vtk_handle->ptr)();
609 vtk_handle->execution_count++;
615 void integrate(std::size_t potential_id, std::size_t velocity_id,
616 std::size_t force_id,
double lb_density)
override {
619 update_boundary_fields();
625 if (potential_id == walberla::BlockDataID{}) {
626 throw std::runtime_error(
"Walberla EK: electrostatic potential enabled "
627 "but no field accessible. potential id is " +
628 std::to_string(potential_id));
630 kernel_diffusion_electrostatic(potential_id);
636 kernel_boundary_flux();
639 if (force_id == walberla::BlockDataID{}) {
640 throw std::runtime_error(
"Walberla EK: friction coupling enabled but "
641 "no force field accessible. force_id is " +
642 std::to_string(force_id) +
643 ". Hint: LB may be inactive.");
645 kernel_friction_coupling(force_id, lb_density);
649 if (velocity_id == walberla::BlockDataID{}) {
650 throw std::runtime_error(
"Walberla EK: advection enabled but no "
651 "velocity field accessible. velocity_id is " +
652 std::to_string(velocity_id) +
653 ". Hint: LB may be inactive.");
655 kernel_advection(velocity_id);
656 kernel_boundary_flux();
661 kernel_boundary_density();
669 static_assert(std::is_same_v<std::size_t, walberla::uint_t>);
685 [[nodiscard]] std::optional<double>
687 bool consider_ghosts =
false)
const override {
693 auto const density_field =
698 [[nodiscard]] std::vector<double>
701 std::vector<double> out;
702 uint_t values_size = 0;
704 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
705 out = std::vector<double>(ci->numCells());
709 lattice, lower_corner, upper_corner, block_offset,
block)) {
710 auto const density_field =
713 assert(values.size() == bci->numCells());
714 values_size += bci->numCells();
715 auto kernel = [&values, &out](
unsigned const block_index,
716 unsigned const local_index,
718 out[local_index] = double_c(values[block_index]);
724 assert(values_size == ci->numCells());
731 std::vector<double>
const &
density)
override {
734 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
735 assert(
density.size() == ci->numCells());
739 lattice, lower_corner, upper_corner, block_offset,
block)) {
740 auto const density_field =
742 std::vector<FloatType> values(bci->numCells());
744 auto kernel = [&values, &
density](
unsigned const block_index,
745 unsigned const local_index,
747 values[block_index] = numeric_cast<FloatType>(
density[local_index]);
757 [[nodiscard]] std::optional<Utils::Vector3d>
759 bool consider_ghosts =
false)
const override {
765 auto const flux_field =
773 std::vector<double> out;
774 uint_t values_size = 0;
776 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
777 out = std::vector<double>(3u * ci->numCells());
781 lattice, lower_corner, upper_corner, block_offset,
block)) {
782 auto const flux_field =
785 assert(values.size() == 3u * bci->numCells());
786 values_size += 3u * bci->numCells();
788 auto kernel = [&values, &out,
this](
unsigned const block_index,
789 unsigned const local_index,
794 for (uint_t f = 0u; f < 3u; ++f) {
795 out[3u * local_index + f] = double_c(vec[f]);
798 for (uint_t f = 0u; f < 3u; ++f) {
799 out[3u * local_index + f] =
800 double_c(values[3u * block_index + f]);
808 assert(values_size == 3u * ci->numCells());
830 node, to_vector3<FloatType>(
flux), *bc);
834 [[nodiscard]] std::optional<Utils::Vector3d>
836 bool consider_ghosts =
false)
const override {
867 [[nodiscard]] std::optional<double>
869 bool consider_ghosts =
false)
const override {
879 std::vector<std::optional<double>>
const &
density)
override {
881 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
883 auto const lower_cell = ci->min();
884 auto const upper_cell = ci->max();
886 assert(
density.size() == ci->numCells());
887 for (
auto x = lower_cell.x(); x <= upper_cell.x(); ++x) {
888 for (
auto y = lower_cell.y(); y <= upper_cell.y(); ++y) {
889 for (
auto z = lower_cell.z(); z <= upper_cell.z(); ++z) {
892 auto const &opt = *it;
906 [[nodiscard]] std::vector<std::optional<double>>
910 std::vector<std::optional<double>> out;
912 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
914 auto const lower_cell = ci->min();
915 auto const upper_cell = ci->max();
916 auto const n_values = ci->numCells();
917 out.reserve(n_values);
918 for (
auto x = lower_cell.x(); x <= upper_cell.x(); ++x) {
919 for (
auto y = lower_cell.y(); y <= upper_cell.y(); ++y) {
920 for (
auto z = lower_cell.z(); z <= upper_cell.z(); ++z) {
923 out.emplace_back(double_c(
926 out.emplace_back(std::nullopt);
931 assert(out.size() == n_values);
938 std::vector<std::optional<Utils::Vector3d>>
const &
flux)
override {
941 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
943 auto const lower_cell = ci->min();
944 auto const upper_cell = ci->max();
945 auto it =
flux.begin();
946 assert(
flux.size() == ci->numCells());
947 for (
auto x = lower_cell.x(); x <= upper_cell.x(); ++x) {
948 for (
auto y = lower_cell.y(); y <= upper_cell.y(); ++y) {
949 for (
auto z = lower_cell.z(); z <= upper_cell.z(); ++z) {
952 auto const &opt = *it;
955 node, to_vector3<FloatType>(*opt), *bc);
966 [[nodiscard]] std::vector<std::optional<Utils::Vector3d>>
970 std::vector<std::optional<Utils::Vector3d>> out;
972 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
974 auto const lower_cell = ci->min();
975 auto const upper_cell = ci->max();
976 auto const n_values = ci->numCells();
977 out.reserve(n_values);
978 for (
auto x = lower_cell.x(); x <= upper_cell.x(); ++x) {
979 for (
auto y = lower_cell.y(); y <= upper_cell.y(); ++y) {
980 for (
auto z = lower_cell.z(); z <= upper_cell.z(); ++z) {
986 out.emplace_back(std::nullopt);
991 assert(out.size() == n_values);
996 [[nodiscard]] std::vector<bool>
999 std::vector<bool> out;
1001 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
1003 auto const lower_cell = ci->min();
1004 auto const upper_cell = ci->max();
1005 auto const n_values = ci->numCells();
1006 out.reserve(n_values);
1007 for (
auto x = lower_cell.x(); x <= upper_cell.x(); ++x) {
1008 for (
auto y = lower_cell.y(); y <= upper_cell.y(); ++y) {
1009 for (
auto z = lower_cell.z(); z <= upper_cell.z(); ++z) {
1016 assert(out.size() == n_values);
1031 [[nodiscard]] std::optional<bool>
1033 bool consider_ghosts)
const override {
1037 return std::nullopt;
1042 [[nodiscard]] std::optional<bool>
1044 bool consider_ghosts)
const override {
1047 return std::nullopt;
1052 [[nodiscard]] std::optional<bool>
1054 bool consider_ghosts =
false)
const override {
1057 return std::nullopt;
1064 const std::vector<int> &raster_flat,
1065 const std::vector<double> &data_flat)
override {
1074 const std::vector<int> &raster_flat,
1075 const std::vector<double> &data_flat)
override {
1093 [[nodiscard]]
bool is_gpu() const noexcept
override {
1100 vtk_obj.addCellExclusionFilter(fluid_filter);
1104 template <
typename Field_T, u
int_t F_SIZE_ARG,
typename OutputType>
1105 class VTKWriter :
public vtk::BlockCellDataWriter<OutputType, F_SIZE_ARG> {
1107 VTKWriter(ConstBlockDataID
const &block_id, std::string
const &
id,
1108 FloatType unit_conversion)
1109 : vtk::BlockCellDataWriter<OutputType, F_SIZE_ARG>(id),
1115 WALBERLA_ASSERT_NOT_NULLPTR(this->block_);
1124#if defined(__CUDACC__)
1125 template <
typename OutputType =
float>
1130 using Base::evaluate;
1133 OutputType
evaluate(cell_idx_t
const x, cell_idx_t
const y,
1134 cell_idx_t
const z, cell_idx_t
const)
override {
1135 WALBERLA_ASSERT_NOT_NULLPTR(this->
m_field);
1141 template <
typename OutputType =
float>
1146 using Base::evaluate;
1149 OutputType
evaluate(cell_idx_t
const x, cell_idx_t
const y,
1150 cell_idx_t
const z, cell_idx_t
const)
override {
1151 WALBERLA_ASSERT_NOT_NULLPTR(this->
m_field);
1158#if defined(__CUDACC__)
1159 template <
typename OutputType =
float>
1160 class FluxVTKWriter :
public VTKWriter<FluxFieldCpu, 3u, OutputType> {
1162 using Base = VTKWriter<FluxFieldCpu, 3u, OutputType>;
1164 using Base::evaluate;
1167 OutputType
evaluate(cell_idx_t
const x, cell_idx_t
const y,
1168 cell_idx_t
const z, cell_idx_t
const f)
override {
1169 WALBERLA_ASSERT_NOT_NULLPTR(this->
m_field);
1176 template <
typename OutputType =
float>
1181 using Base::evaluate;
1184 OutputType
evaluate(cell_idx_t
const x, cell_idx_t
const y,
1185 cell_idx_t
const z, cell_idx_t
const f)
override {
1186 WALBERLA_ASSERT_NOT_NULLPTR(this->
m_field);
1197 int flag_observables)
override {
1198#if defined(__CUDACC__)
1199 auto const allocate_cpu_field_if_empty =
1200 [&]<
typename Field>(
auto const &blocks, std::string name,
1201 std::optional<BlockDataID> &cpu_field) {
1202 if (not cpu_field) {
1203 cpu_field = field::addToStorage<Field>(
1204 blocks, name, FloatType{0}, field::fzyx,
1205 m_lattice->get_ghost_layers(), m_host_field_allocator);
1210 auto const unit_conversion =
FloatType_c(units.at(
"density"));
1211#if defined(__CUDACC__)
1213 auto const &blocks =
m_lattice->get_blocks();
1214 allocate_cpu_field_if_empty.template operator()<DensityFieldCpu>(
1215 blocks,
"density_cpu", m_density_cpu_field_id);
1216 vtk_obj.addBeforeFunction(
1217 gpu::fieldCpyFunctor<DensityFieldCpu, DensityField>(
1220 *m_density_cpu_field_id,
"density", unit_conversion));
1225#if defined(__CUDACC__)
1230 auto const unit_conversion =
FloatType_c(units.at(
"flux"));
1231#if defined(__CUDACC__)
1233 auto const &blocks =
m_lattice->get_blocks();
1234 allocate_cpu_field_if_empty.template operator()<FluxFieldCpu>(
1235 blocks,
"flux_cpu", m_flux_cpu_field_id);
1236 vtk_obj.addBeforeFunction(gpu::fieldCpyFunctor<FluxFieldCpu, FluxField>(
1239 *m_flux_cpu_field_id,
"flux", unit_conversion));
1244#if defined(__CUDACC__)
Vector implementation and trait types for boost qvm interoperability.
Interface of a lattice-based electrokinetic 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
std::pair< Utils::Vector3i, Utils::Vector3i > get_local_grid_range(bool with_halo=false) const
Utils::Vector3i get_block_corner(IBlock const &block, bool lower) const
Boundary class optimized for sparse data.
VTKWriter< DensityField, 1u, OutputType > Base
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
VTKWriter< FluxField, 3u, OutputType > Base
VTKWriter(ConstBlockDataID const &block_id, std::string const &id, FloatType unit_conversion)
ConstBlockDataID const m_block_id
void configure() override
FloatType const m_conversion
Class that runs and controls the EK on waLBerla.
~EKinWalberlaImpl() override=default
void set_slice_flux_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< std::optional< Utils::Vector3d > > const &flux) override
void set_kT(double kT) override
std::optional< double > get_node_density_at_boundary(Utils::Vector3i const &node, bool consider_ghosts=false) const override
double get_kT() const noexcept override
std::unique_ptr< DiffusiveFluxKernelElectrostatic > m_diffusive_flux_electrostatic
walberla::FlagField< walberla::uint8_t > FlagField
void set_friction_coupling(bool friction_coupling) override
void set_rng_state(uint64_t counter) override
void integrate(std::size_t potential_id, std::size_t velocity_id, std::size_t force_id, double lb_density) override
bool set_node_density_boundary(Utils::Vector3i const &node, double density) override
void set_slice_density(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< double > const &density) override
BlockDataID m_density_field_id
std::shared_ptr< FullCommunicator > m_full_communication
std::bitset< GhostComm::SIZE > m_pending_ghost_comm
std::vector< double > get_slice_density(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
void update_density_boundary_from_shape(const std::vector< int > &raster_flat, const std::vector< double > &data_flat) override
void update_flux_boundary_from_shape(const std::vector< int > &raster_flat, const std::vector< double > &data_flat) override
std::vector< bool > get_slice_is_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
void set_ext_efield(Utils::Vector3d const &field) override
bool set_node_density(Utils::Vector3i const &node, double density) override
double get_diffusion() const noexcept override
void set_valency(double valency) override
bool is_thermalized() const noexcept override
auto add_to_storage(std::string const tag, FloatType value)
Convenience function to add a field with a custom allocator.
std::optional< double > get_node_density(Utils::Vector3i const &node, bool consider_ghosts=false) const override
std::size_t get_density_id() const noexcept override
unsigned int get_seed() const noexcept override
BlockDataID m_flag_field_flux_id
std::unique_ptr< ContinuityKernel > m_continuity
double get_valency() const noexcept override
typename FieldTrait< FloatType, Architecture >::FluxField FluxField
void clear_flux_boundaries() override
std::shared_ptr< BoundaryModelFlux > m_boundary_flux
void set_slice_density_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< std::optional< double > > const &density) override
void reset_flux_boundary_handling(std::shared_ptr< BlockStorage > const &blocks)
bool get_advection() const noexcept override
std::optional< Utils::Vector3d > get_node_flux_vector(Utils::Vector3i const &node, bool consider_ghosts=false) const override
typename FieldTrait< FloatType, Architecture >::template BoundaryCommScheme< typename stencil::D3Q27 > BoundaryFullCommunicator
typename FieldTrait< FloatType, Architecture >::template RegularCommScheme< typename stencil::D3Q27 > FullCommunicator
void reallocate_density_boundary_field()
std::optional< uint64_t > get_rng_state() const override
void set_advection(bool advection) override
BlockDataID m_flag_field_density_id
bool remove_node_from_density_boundary(Utils::Vector3i const &node) override
typename FieldTrait< FloatType, Architecture >::template PackInfo< Field > PackInfo
bool get_friction_coupling() const noexcept override
Utils::Vector3d get_ext_efield() const noexcept override
stencil::D3Q27 Stencil
Stencil for collision and streaming operations.
LatticeWalberla const & get_lattice() const noexcept override
bool remove_node_from_flux_boundary(Utils::Vector3i const &node) override
bool is_double_precision() const noexcept override
void integrate_vtk_writers() override
typename FieldTrait< FloatType, Architecture >::DensityField DensityField
FloatType FloatType_c(T t)
bool is_gpu() const noexcept override
void clear_density_boundaries() override
std::optional< bool > get_node_is_flux_boundary(Utils::Vector3i const &node, bool consider_ghosts) const override
void ghost_communication() override
LatticeWalberla::Lattice_T BlockStorage
Lattice model (e.g.
void ghost_communication_boundary()
void reset_density_boundary_handling(std::shared_ptr< BlockStorage > const &blocks)
std::vector< std::optional< Utils::Vector3d > > get_slice_flux_at_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
ResourceObserver m_mpi_cart_comm_observer
std::vector< std::optional< double > > get_slice_density_at_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
BlockDataID m_flux_field_id
void register_vtk_field_writers(walberla::vtk::VTKOutput &vtk_obj, LatticeModel::units_map const &units, int flag_observables) override
std::optional< Utils::Vector3d > get_node_flux_at_boundary(Utils::Vector3i const &node, bool consider_ghosts=false) const override
std::vector< double > get_slice_flux_vector(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
typename FieldTrait< FloatType >::DensityField _DensityField
std::shared_ptr< BoundaryFullCommunicator > m_boundary_communicator
std::optional< bool > get_node_is_density_boundary(Utils::Vector3i const &node, bool consider_ghosts) const override
std::unique_ptr< DiffusiveFluxKernel > m_diffusive_flux
void set_diffusion(double diffusion) override
std::size_t stencil_size() const noexcept override
FlagUID const Boundary_flag
Flag for boundary cells.
bool set_node_flux_boundary(Utils::Vector3i const &node, Utils::Vector3d const &flux) override
void reallocate_flux_boundary_field()
typename FieldTrait< FloatType >::FluxField _FluxField
std::optional< bool > get_node_is_boundary(Utils::Vector3i const &node, bool consider_ghosts=false) const override
std::unique_ptr< BoundaryModelDensity > m_boundary_density
EKinWalberlaImpl(std::shared_ptr< LatticeWalberla > lattice, double diffusion, double kT, double valency, Utils::Vector3d const &ext_efield, double density, bool advection, bool friction_coupling, bool thermalized, unsigned int seed)
std::shared_ptr< LatticeWalberla > m_lattice
Block forest.
FlagUID const Domain_flag
Flag for domain cells, i.e.
void register_vtk_field_filters(walberla::vtk::VTKOutput &vtk_obj) 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)
auto get_vector(GhostLayerField< double, uint_t{13u}> const *flux_field, Cell const &cell)
void initialize(GhostLayerField< double, uint_t{13u}> *flux_field, std::array< double, 13 > const &values)
void initialize(GhostLayerField< double, 1u > *scalar_field, double const &value)
void set(GhostLayerField< double, 1u > *scalar_field, double const &value, Cell const &cell)
auto get(GhostLayerField< double, 1u > const *scalar_field, Cell const &cell)
static FUNC_PREFIX double *RESTRICT const double *RESTRICT const int64_t const int64_t const int64_t const int64_t const int64_t const int64_t const int64_t const int64_t const int64_t const int64_t const uint32_t uint32_t uint32_t uint32_t uint32_t uint32_t uint32_t seed
\file PackInfoPdfDoublePrecision.cpp \author pystencils
auto to_vector3d(Vector3< T > const &v) noexcept
std::vector< double > fill_3D_scalar_array(std::vector< double > const &vec_flat, Utils::Vector3i const &grid_size)
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)
ResourceObserver get_mpi_cart_comm_observer()
Get an observer on waLBerla's MPI Cartesian communicator status.
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.
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)
Observer to monitor the lifetime of a shared resource.
blockforest::communication::UniformBufferedScheme< Stencil > RegularCommScheme
GhostLayerField< FT, FluxCount > FluxField
field::communication::PackInfo< Field > PackInfo
GhostLayerField< FT, 1 > DensityField
blockforest::communication::UniformBufferedScheme< Stencil > BoundaryCommScheme
GhostCommFlags
Ghost communication operations.
@ DENS
density communication
@ FLB
flux boundary communication