30#if defined(__CUDACC__)
37#include <blockforest/communication/UniformBufferedScheme.h>
38#include <domain_decomposition/BlockDataID.h>
39#include <field/AddToStorage.h>
40#include <field/GhostLayerField.h>
41#include <field/vtk/VTKWriter.h>
42#include <stencil/D3Q27.h>
43#include <waLBerlaDefinitions.h>
44#if defined(__CUDACC__)
45#include <gpu/AddGPUFieldToStorage.h>
46#include <gpu/FieldAccessor.h>
47#include <gpu/FieldIndexing.h>
48#include <gpu/GPUField.h>
49#include <gpu/HostFieldAllocator.h>
50#include <gpu/Kernel.h>
51#include <gpu/communication/UniformGPUScheme.h>
55#pragma clang diagnostic push
56#pragma clang diagnostic ignored "-Wfloat-conversion"
57#pragma clang diagnostic ignored "-Wimplicit-float-conversion"
58#elif defined(__GNUC__) or defined(__GNUG__)
59#pragma GCC diagnostic push
60#pragma GCC diagnostic ignored "-Wfloat-conversion"
64#pragma clang diagnostic pop
65#elif defined(__GNUC__) or defined(__GNUG__)
66#pragma GCC diagnostic pop
82template <
typename FloatType, lbmpy::Arch Architecture>
85 template <
typename T> FloatType FloatType_c(T t) {
86 return numeric_cast<FloatType>(t);
90 template <
typename FT, lbmpy::Arch AT = lbmpy::Arch::CPU>
struct FieldTrait {
94#if defined(__CUDACC__)
104 BlockDataID m_potential_field_id;
111#if defined(__CUDACC__)
112 m_potential_field_id = gpu::addGPUFieldToStorage<PotentialField>(
113 blocks,
"potential field", 1u, field::fzyx,
116 m_potential_field_id = field::addToStorage<PotentialField>(
117 blocks,
"potential field", 0., field::fzyx,
124 [[nodiscard]]
bool is_gpu() const noexcept
override {
129 return std::is_same_v<FloatType, double>;
133 return static_cast<std::size_t
>(m_potential_field_id);
136 [[nodiscard]] std::optional<double>
138 bool consider_ghosts =
false)
override {
144 auto const potential_field =
145 bc->block->template getData<PotentialField>(m_potential_field_id);
156 auto potential_field =
157 bc->block->template getData<PotentialField>(m_potential_field_id);
163 [[nodiscard]] std::vector<double>
166 std::vector<double> out;
168 uint_t values_size{0u};
171 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
172 out = std::vector<double>(ci->numCells());
173 for (
auto &
block : *lattice.get_blocks()) {
174 auto const block_offset = lattice.get_block_corner(
block,
true);
176 lattice, lower_corner, upper_corner, block_offset,
block)) {
177 auto const potential_field =
178 block.template getData<PotentialField>(m_potential_field_id);
180 assert(values.size() == bci->numCells());
182 values_size += bci->numCells();
184 auto kernel = [&values, &out](
unsigned const block_index,
185 unsigned const local_index,
187 out[local_index] = double_c(values[block_index]);
193 assert(values_size == ci->numCells());
200 std::vector<double>
const &
potential)
override {
202 if (
auto const ci =
get_interval(lattice, lower_corner, upper_corner)) {
203 assert(
potential.size() == ci->numCells());
204 for (
auto &
block : *lattice.get_blocks()) {
205 auto const block_offset = lattice.get_block_corner(
block,
true);
207 lattice, lower_corner, upper_corner, block_offset,
block)) {
208 auto potential_field =
209 block.template getData<PotentialField>(m_potential_field_id);
210 std::vector<FloatType> values(bci->numCells());
212 auto kernel = [&values, &
potential](
unsigned const block_index,
213 unsigned const local_index,
215 values[block_index] =
216 numeric_cast<FloatType>(
potential[local_index]);
Vector implementation and trait types for boost qvm interoperability.
void setup_fft(bool use_gpu_aware) override
bool is_double_precision() const noexcept override
~PoissonSolverNone() override=default
bool is_gpu() const noexcept override
std::size_t get_potential_field_id() const noexcept override
void set_slice_potential(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< double > const &potential) override
std::vector< double > get_slice_potential(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const override
PoissonSolverNone(std::shared_ptr< LatticeWalberla > lattice)
void reset_charge_field() override
void add_charge_to_field(std::size_t id, double valency) override
FieldTrait< FloatType, Architecture >::PotentialField PotentialField
bool set_node_potential(Utils::Vector3i const &node, double potential) override
std::optional< double > get_node_potential(Utils::Vector3i const &node, bool consider_ghosts=false) override
void ghost_communication() override
LatticeWalberla const & get_lattice() const noexcept override
static double * block(double *p, std::size_t index, std::size_t size)
void set(GhostLayerField< double, 1u > *scalar_field, double const &value, Cell const &cell)
auto get(GhostLayerField< double, 1u > const *scalar_field, Cell const &cell)
\file PackInfoPdfDoublePrecision.cpp \author pystencils
void copy_block_buffer(CellInterval const &bci, CellInterval const &ci, Utils::Vector3i const &block_offset, Utils::Vector3i const &lower_corner, auto &&kernel)
Synchronize data between a sliced block and a container.
std::optional< BlockAndCell > get_block_and_cell(::LatticeWalberla const &lattice, signed_integral_vector auto const &node, bool consider_ghost_layers)
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)
std::optional< walberla::cell::CellInterval > get_interval(::LatticeWalberla const &lattice, Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner)
field::GhostLayerField< FT, 1u > PotentialField