Skip to content

Commit

Permalink
safer nu (PHAREHUB#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasaunai authored and UCaromel committed Nov 13, 2024
1 parent 0f80000 commit 94dee9f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/numerics/ohm/ohm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,17 @@ 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
auto const lvlCoeff = 1. / std::pow(4, layout_->levelNumber());
auto const lvlCoeff = 1. / std::pow(4, layout_->levelNumber());
auto constexpr min_density = 0.1;

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 * lvlCoeff * layout_->laplacian(J(component), index);
return -nu_ * (b / (nOnE + min_density) + 1) * lvlCoeff
* layout_->laplacian(J(component), index);
};

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

0 comments on commit 94dee9f

Please sign in to comment.