25#include <blockforest/Initialization.h>
26#include <blockforest/StructuredBlockForest.h>
27#include <core/DataTypes.h>
28#include <core/cell/Cell.h>
29#include <domain_decomposition/IBlock.h>
34#include <initializer_list>
47 using walberla::real_t;
48 using walberla::uint_c;
50 for (
auto const i : {0
u, 1u, 2u}) {
51 if (m_grid_dimensions[i] % node_grid[i] != 0) {
52 throw std::runtime_error(
53 "Lattice grid dimensions and MPI node grid are not compatible.");
55 if (m_grid_dimensions[i] %
block_grid[i] != 0) {
56 throw std::runtime_error(
57 "Lattice grid dimensions and block grid are not compatible.");
65 m_blocks = walberla::blockforest::createUniformBlockGrid(
77 for (IBlock &
block : *m_blocks) {
78 m_cached_blocks.push_back(&
block);
82[[
nodiscard]] std::pair<Utils::Vector3d, Utils::Vector3d>
88 auto aa = to_vector3d(m_blocks->begin()->getAABB().min());
89 auto bb = to_vector3d(m_blocks->begin()->getAABB().max());
90 for (
auto const &
block : *m_blocks) {
92 for (
auto const i : {0
u, 1u, 2u}) {
93 aa[i] = std::min(
aa[i],
cc.min()[i]);
94 bb[i] = std::max(
bb[i],
cc.max()[i]);
100[[
nodiscard]] std::pair<Utils::Vector3i, Utils::Vector3i>
103 auto const gl =
with_halo ?
static_cast<int>(m_n_ghost_layers) : 0;
120 return ::walberla::get_block_and_cell(*
this, node,
false) != std::nullopt;
124 return ::walberla::get_block_and_cell(*
this, node,
true) != std::nullopt;
128 return ::walberla::get_block(*
this, pos,
false) !=
nullptr;
132 return ::walberla::get_block(*
this, pos,
true) !=
nullptr;
142 for (
auto const i : {0
u, 1u, 2u}) {
144 std::numeric_limits<double>::epsilon()) {
145 throw std::runtime_error(
146 "Box length not commensurate with agrid in direction " +
147 std::to_string(i) +
" length " + std::to_string(
box_size[i]) +
148 " agrid " + std::to_string(
agrid));
Vector implementation and trait types for boost qvm interoperability.
bool pos_in_local_halo(Utils::Vector3d const &pos) const
static Utils::Vector3i calc_grid_dimensions(Utils::Vector3d const &box_size, double agrid)
bool node_in_local_halo(Utils::Vector3i const &node) const
std::pair< Utils::Vector3d, Utils::Vector3d > get_local_domain() const
bool node_in_local_domain(Utils::Vector3i const &node) const
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
LatticeWalberla(Utils::Vector3i const &grid_dimensions, Utils::Vector3i const &node_grid, Utils::Vector3i const &block_grid, unsigned int n_ghost_layers)
bool pos_in_local_domain(Utils::Vector3d const &pos) const
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value) noexcept
Create a vector that has all entries set to the same value.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
static double * block(double *p, std::size_t index, std::size_t size)
auto hadamard_division(Vector< T, N > const &a, Vector< U, N > const &b)
auto to_vector3d(Vector3< T > const &v) noexcept
auto convert_cell_corner_to_coord(real_vector auto const &corner)
Get the block-local coordinates of a block corner.
auto get_min_corner(IBlock const &block)
Get the block-local coordinates of the lower corner of a block.
auto get_max_corner(IBlock const &block)
Get the block-local coordinates of the upper corner of a block.