10#ifndef PECLET_AMR_LEAF_FIELD_HPP
11#define PECLET_AMR_LEAF_FIELD_HPP
19#include "peclet/core/common/types.hpp"
28 for (
int d = 0; d < Dim; ++d)
63 for (
int d = 1; d < Dim; ++d)
64 m =
h0[d] < m ?
h0[d] : m;
69 for (
int d = 1; d < Dim; ++d)
70 m =
h0[d] > m ?
h0[d] : m;
74 for (
int d = 1; d < Dim; ++d)
82 for (
int d = 1; d < Dim; ++d)
89 return h0[d] *
static_cast<Real
>(Index(1) << level);
94 const Real f =
static_cast<Real
>(Index(1) << level);
95 for (
int d = 0; d < Dim; ++d)
101 template <
class Coord>
104 for (
int d = 0; d < Dim; ++d)
105 p[d] =
origin[d] +
static_cast<Real
>(lo[d]) *
h0[d];
110 template <
class Coord>
111 Vec<Dim>
center(
const std::array<std::array<Coord, Dim>, 2>& b)
const {
113 for (
int d = 0; d < Dim; ++d)
116 (
static_cast<Real
>(b[0][d]) + 0.5 * (
static_cast<Real
>(b[1][d] - b[0][d]) + 1.0)) *
h0[d];
127 explicit LeafField(Index n, T init = T{}) :
values(static_cast<std::size_t>(n), init) {}
129 template <
int Dim,
unsigned Bits>
131 :
values(static_cast<std::size_t>(t.numLeaves()), init) {}
133 Index
size()
const {
return static_cast<Index
>(
values.size()); }
Per-block adaptive octree over block-local Morton codes.
Vec< Dim > filledVec(Real v)
Vec<Dim> with every component set to v (C++ has no aggregate-fill initializer).
World-space placement of a block-local octree: fine coordinate (0,..,0) sits at origin,...
void setIsotropic(Real h)
Set all axes to one spacing (the cubic case), in place.
Real cellVolume() const
World volume of a level-0 fine cell.
Vec< Dim > lowerCorner(const std::array< Coord, Dim > &lo) const
World coordinate of a leaf's lower corner, given its integer lower bound (fine units).
Vec< Dim > center(const std::array< std::array< Coord, Dim >, 2 > &b) const
World coordinate of a leaf centre, from its integer bounds [lo,hi] (inclusive, fine units).
static AmrGeometry isotropicAt(const Vec< Dim > &o, Real h)
Cubic-cell convenience: the pre-Phase-3 {origin, h} construction.
Real leafSize(unsigned level, int d) const
World width of a leaf at level on axis d (it covers 2^level fine cells).
Vec< Dim > leafSize(unsigned level) const
World widths of a leaf at level, per axis.
LeafField(Index n, T init=T{})
const T & operator[](Index i) const
LeafField(const BlockOctree< Dim, Bits > &t, T init=T{})