Skip to content

Commit

Permalink
refacrabbit
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasaunai committed Oct 1, 2024
1 parent f5f2f05 commit e513179
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/core/numerics/ohm/ohm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,32 +369,29 @@ class Ohm : public LayoutHolder<GridLayout>
std::end(layout_->meshSize()), 0.,
[](double acc, double d) { return acc + d * d; })};

if constexpr (component == Component::X)
{
auto const BxOnE = GridLayout::project(B(Component::X), index, GridLayout::BxToEx());
auto const ByOnE = GridLayout::project(B(Component::Y), index, GridLayout::ByToEx());
auto const BzOnE = GridLayout::project(B(Component::Z), index, GridLayout::BzToEx());
auto const nOnE = GridLayout::project(n, index, GridLayout::momentsToEx());
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);
};

if constexpr (component == Component::X)
{
return computeHR(GridLayout::BxToEx(), GridLayout::ByToEx(), GridLayout::BzToEx(),
GridLayout::momentsToEx());
}
if constexpr (component == Component::Y)
{
auto const BxOnE = GridLayout::project(B(Component::X), index, GridLayout::BxToEy());
auto const ByOnE = GridLayout::project(B(Component::Y), index, GridLayout::ByToEy());
auto const BzOnE = GridLayout::project(B(Component::Z), index, GridLayout::BzToEy());
auto const nOnE = GridLayout::project(n, index, GridLayout::momentsToEy());
auto b = std::sqrt(BxOnE * BxOnE + ByOnE * ByOnE + BzOnE * BzOnE);
return -nu_ * b / nOnE * dl2 * layout_->laplacian(J(component), index);
return computeHR(GridLayout::BxToEy(), GridLayout::ByToEy(), GridLayout::BzToEy(),
GridLayout::momentsToEy());
}
if constexpr (component == Component::Z)
{
auto const BxOnE = GridLayout::project(B(Component::X), index, GridLayout::BxToEz());
auto const ByOnE = GridLayout::project(B(Component::Y), index, GridLayout::ByToEz());
auto const BzOnE = GridLayout::project(B(Component::Z), index, GridLayout::BzToEz());
auto const nOnE = GridLayout::project(n, index, GridLayout::momentsToEz());
auto b = std::sqrt(BxOnE * BxOnE + ByOnE * ByOnE + BzOnE * BzOnE);
return -nu_ * b / nOnE * dl2 * layout_->laplacian(J(component), index);
return computeHR(GridLayout::BxToEz(), GridLayout::ByToEz(), GridLayout::BzToEz(),
GridLayout::momentsToEz());
}
}
};
Expand Down

0 comments on commit e513179

Please sign in to comment.