Skip to content

Commit

Permalink
level coef in hypermode
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasaunai committed Sep 27, 2024
1 parent 3159471 commit d8c1d2b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/amr/resources_manager/amr_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ namespace amr
nbrCell[iDim] = static_cast<std::uint32_t>(domain.numberCells(iDim));
}

return GridLayoutT{dl, nbrCell, origin, amr::Box<int, dimension>{domain}};
auto lvlNbr = patch.getPatchLevelNumber();
return GridLayoutT{dl, nbrCell, origin, amr::Box<int, dimension>{domain}, lvlNbr};
}

inline auto to_string(SAMRAI::hier::GlobalId const& id)
Expand Down
6 changes: 5 additions & 1 deletion src/core/data/grid/gridlayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,15 @@ 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>{})
Box<int, dimension> AMRBox = Box<int, dimension>{}, int level_number = 0)
: meshSize_{meshSize}
, origin_{origin}
, nbrPhysicalCells_{nbrCells}
, physicalStartIndexTable_{initPhysicalStart_()}
, physicalEndIndexTable_{initPhysicalEnd_()}
, ghostEndIndexTable_{initGhostEnd_()}
, AMRBox_{AMRBox}
, levelNumber_{level_number}
{
if (AMRBox_.isEmpty())
{
Expand Down Expand Up @@ -1170,6 +1171,7 @@ namespace core
evalOnBox_(field, fn, indices);
}

auto levelNumber() const { return levelNumber_; }

private:
template<typename Field, typename IndicesFn, typename Fn>
Expand Down Expand Up @@ -1513,6 +1515,8 @@ namespace core
// arrays will be accessed with [primal] and [dual] indexes.
constexpr static std::array<int, 2> nextIndexTable_{{nextPrimal_(), nextDual_()}};
constexpr static std::array<int, 2> prevIndexTable_{{prevPrimal_(), prevDual_()}};

int levelNumber_ = 0;
};


Expand Down
6 changes: 2 additions & 4 deletions src/core/numerics/ohm/ohm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,15 @@ class Ohm : public LayoutHolder<GridLayout>
auto spatial_hyperresistive_(VecField const& J, VecField const& B, Field const& n,
MeshIndex<VecField::dimension> index) const
{ // TODO : https://github.com/PHAREHUB/PHARE/issues/3
double const dl2{std::accumulate(std::begin(layout_->meshSize()),
std::end(layout_->meshSize()), 0.,
[](double acc, double d) { return acc + d * d; })};
auto const lvlCoeff = std::pow(4, layout_->levelNumber());

auto computeHR = [&](auto BxProj, auto ByProj, auto BzProj, auto nProj) {
auto const BxOnE = GridLayout::project(B(Component::X), index, BxProj);
auto const ByOnE = GridLayout::project(B(Component::Y), index, ByProj);
auto const BzOnE = GridLayout::project(B(Component::Z), index, BzProj);
auto const nOnE = GridLayout::project(n, index, nProj);
auto b = std::sqrt(BxOnE * BxOnE + ByOnE * ByOnE + BzOnE * BzOnE);
return -nu_ * b / nOnE * dl2 * layout_->laplacian(J(component), index);
return -nu_ * b / nOnE * lvlCoeff * layout_->laplacian(J(component), index);
};

if constexpr (component == Component::X)
Expand Down

0 comments on commit d8c1d2b

Please sign in to comment.