From d03d643dcd536947bed77aaf257415d93000d870 Mon Sep 17 00:00:00 2001 From: Nicolas Aunai Date: Fri, 27 Sep 2024 15:42:37 +0200 Subject: [PATCH] level coef in hypermode --- src/amr/resources_manager/amr_utils.hpp | 3 ++- src/core/data/grid/gridlayout.hpp | 6 +++++- src/core/numerics/ohm/ohm.hpp | 6 ++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/amr/resources_manager/amr_utils.hpp b/src/amr/resources_manager/amr_utils.hpp index 4faf3bb39..0efd3f795 100644 --- a/src/amr/resources_manager/amr_utils.hpp +++ b/src/amr/resources_manager/amr_utils.hpp @@ -182,7 +182,8 @@ namespace amr nbrCell[iDim] = static_cast(domain.numberCells(iDim)); } - return GridLayoutT{dl, nbrCell, origin, amr::Box{domain}}; + auto lvlNbr = patch.getPatchLevelNumber(); + return GridLayoutT{dl, nbrCell, origin, amr::Box{domain}, lvlNbr}; } inline auto to_string(SAMRAI::hier::GlobalId const& id) diff --git a/src/core/data/grid/gridlayout.hpp b/src/core/data/grid/gridlayout.hpp index 9ab41c674..74297a864 100644 --- a/src/core/data/grid/gridlayout.hpp +++ b/src/core/data/grid/gridlayout.hpp @@ -112,7 +112,7 @@ namespace core GridLayout(std::array const& meshSize, std::array const& nbrCells, Point const& origin, - Box AMRBox = Box{}) + Box AMRBox = Box{}, int level_number = 0) : meshSize_{meshSize} , origin_{origin} , nbrPhysicalCells_{nbrCells} @@ -120,6 +120,7 @@ namespace core , physicalEndIndexTable_{initPhysicalEnd_()} , ghostEndIndexTable_{initGhostEnd_()} , AMRBox_{AMRBox} + , levelNumber_{level_number} { if (AMRBox_.isEmpty()) { @@ -1170,6 +1171,7 @@ namespace core evalOnBox_(field, fn, indices); } + auto levelNumber() const { return levelNumber_; } private: template @@ -1513,6 +1515,8 @@ namespace core // arrays will be accessed with [primal] and [dual] indexes. constexpr static std::array nextIndexTable_{{nextPrimal_(), nextDual_()}}; constexpr static std::array prevIndexTable_{{prevPrimal_(), prevDual_()}}; + + int levelNumber_ = 0; }; diff --git a/src/core/numerics/ohm/ohm.hpp b/src/core/numerics/ohm/ohm.hpp index 8d3c60927..39a27172e 100644 --- a/src/core/numerics/ohm/ohm.hpp +++ b/src/core/numerics/ohm/ohm.hpp @@ -365,9 +365,7 @@ class Ohm : public LayoutHolder auto spatial_hyperresistive_(VecField const& J, VecField const& B, Field const& n, MeshIndex 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); @@ -375,7 +373,7 @@ class Ohm : public LayoutHolder 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)