Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 8 additions & 24 deletions src/core/data/grid/gridlayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <array>
#include <tuple>
#include <cstddef>
#include <optional>
#include <functional>
#include <type_traits>

Expand Down Expand Up @@ -99,7 +100,7 @@ namespace core
static constexpr std::size_t interp_order = GridLayoutImpl::interp_order;
using This = GridLayout<GridLayoutImpl>;
using implT = GridLayoutImpl;

using AMRBox_t = Box<int, dimension>;

/**
* @brief Constructor of a GridLayout
Expand All @@ -110,37 +111,20 @@ namespace core
GridLayout(std::array<double, dimension> const& meshSize,
std::array<std::uint32_t, dimension> const& nbrCells,
Point<double, dimension> const& origin,
Box<int, dimension> AMRBox = Box<int, dimension>{}, int level_number = 0)
std::optional<AMRBox_t> const AMRBox = std::nullopt, int level_number = 0)
: meshSize_{meshSize}
, origin_{origin}
, nbrPhysicalCells_{nbrCells}
, physicalStartIndexTable_{initPhysicalStart_()}
, physicalEndIndexTable_{initPhysicalEnd_()}
, ghostEndIndexTable_{initGhostEnd_()}
, AMRBox_{AMRBox}
, AMRBox_{AMRBox ? *AMRBox : boxFromNbrCells(nbrCells)}
, levelNumber_{level_number}
{
if (AMRBox_.isEmpty())
{
AMRBox_ = boxFromNbrCells(nbrCells);
}
else
{
if (AMRBox.size() != boxFromNbrCells(nbrCells).size())
{
throw std::runtime_error("Error - invalid AMR box, incorrect number of cells");
}
}
if (AMRBox_.size() != boxFromNbrCells(nbrCells).size())
throw std::runtime_error("Error - invalid AMR box, incorrect number of cells");

inverseMeshSize_[0] = 1. / meshSize_[0];
if constexpr (dimension > 1)
{
inverseMeshSize_[1] = 1. / meshSize_[1];
if constexpr (dimension > 2)
{
inverseMeshSize_[2] = 1. / meshSize_[2];
}
}
inverseMeshSize_ = generate([](auto const e) { return 1. / e; }, meshSize_);
}


Expand Down Expand Up @@ -1548,7 +1532,7 @@ namespace core
std::array<std::array<std::uint32_t, dimension>, 2> physicalStartIndexTable_;
std::array<std::array<std::uint32_t, dimension>, 2> physicalEndIndexTable_;
std::array<std::array<std::uint32_t, dimension>, 2> ghostEndIndexTable_;
Box<int, dimension> AMRBox_;
AMRBox_t AMRBox_;

// this constexpr initialization only works if primal==0 and dual==1
// this is defined in gridlayoutdefs.hpp don't change it because these
Expand Down
5 changes: 2 additions & 3 deletions src/core/data/particles/particle_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,9 @@ class ParticleArray
{
auto oldCell = particles_[particleIndex].iCell;
particles_[particleIndex].iCell = newCell;
if (!box_.isEmpty())
{
auto const box_is_valid = box_.size() > 1;
if (box_is_valid)
Comment on lines +187 to +188
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now it's an implementation detail rather than a function/interface that is somewhat nonsensical

cellMap_.update(particles_, particleIndex, oldCell);
}
}


Expand Down
7 changes: 1 addition & 6 deletions src/core/utilities/box/box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ struct Box
return Box{lower - that.lower, upper - that.upper};
}

NO_DISCARD bool isEmpty() const { return (*this) == Box{}; }

void grow(Type const& size)
{
Expand Down Expand Up @@ -341,11 +340,7 @@ NO_DISCARD Box<Type, dim> shift(Box<Type, dim> const& box, Shifter const& offset
return copy;
}

template<typename Type, std::size_t dim>
NO_DISCARD Box<Type, dim> emptyBox()
{
return Box<Type, dim>{};
}


template<typename Type, std::size_t dim>
auto& operator<<(std::ostream& os, Box<Type, dim> const& box)
Expand Down
4 changes: 2 additions & 2 deletions src/core/utilities/cellmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <vector>
#include <algorithm>
#include <numeric>
#include <optional>


#include "core/data/ndarray/ndarray_vector.hpp"
#include "core/utilities/box/box.hpp"
Expand Down Expand Up @@ -225,7 +225,7 @@ template<std::size_t dim, typename cell_index_t>
template<typename CellIndex>
inline void CellMap<dim, cell_index_t>::addToCell(CellIndex const& cell, std::size_t itemIndex)
{
if (!box_.isEmpty() and isIn(Point{cell}, box_))
if (isIn(Point{cell}, box_))
cellIndexes_(local_(cell)).add(itemIndex);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/core/numerics/pusher/test_pusher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ class DummySelector
};


template<std::size_t dimension_>
template<std::size_t dim>
struct DummyLayout
{
static constexpr std::size_t dimension = dimension_;
static constexpr std::size_t dimension = dim;
std::array<unsigned int, dimension> nbrCells_;
auto nbrCells() const { return nbrCells_; }
auto AMRBox() const { return PHARE::core::emptyBox<int, dimension>(); }
auto AMRBox() const { return PHARE::core::Box<int, dimension>{}; }
auto levelNumber() const { return 0; }
};

Expand Down