Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor refactoring of refined injection for AddPlasmaFlux #5274

Merged
merged 5 commits into from
Sep 17, 2024

Conversation

RemiLehe
Copy link
Member

In AddPlasmaFlux, the code associated with the refined injection can be simplified a bit in a few places.

const auto index = overlap_box.index(iv);

Real scale_fac = compute_scale_fac_area(dx, num_ppc_real, flux_normal_axis);

auto lo = getCellCoords(overlap_corner, dx, {0._rt, 0._rt, 0._rt}, iv);
auto hi = getCellCoords(overlap_corner, dx, {1._rt, 1._rt, 1._rt}, iv);

if (flux_pos->overlapsWith(lo, hi))
Copy link
Member Author

Choose a reason for hiding this comment

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

This if condition is not key here, since the pcounts[index] is 0 anyway for cells that do not overlap.

@ax3l ax3l requested a review from dpgrote September 16, 2024 23:19
@ax3l ax3l added cleaning Clean code, improve readability component: initialization Changes related to the initialization of the simulation labels Sep 16, 2024
auto lo = getCellCoords(overlap_corner, dx, {0._rt, 0._rt, 0._rt}, iv);
auto hi = getCellCoords(overlap_corner, dx, {1._rt, 1._rt, 1._rt}, iv);

if (flux_pos->overlapsWith(lo, hi))
{
auto index = overlap_box.index(iv);
int r;
int r = 1;
if (fine_overlap_box.ok() && fine_overlap_box.contains(iv)) {
r = compute_area_weights(lrrfac, flux_normal_axis);
Copy link
Member

@dpgrote dpgrote Sep 16, 2024

Choose a reason for hiding this comment

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

There is another small clean up that can be done. The lrrfac is not necessary since rrfac is already locally declared within the routine. Similarly for AddPlasma.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, thanks. I added this in my latest commit.

@RemiLehe RemiLehe enabled auto-merge (squash) September 17, 2024 13:27
@RemiLehe RemiLehe merged commit 55e86de into ECP-WarpX:development Sep 17, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleaning Clean code, improve readability component: initialization Changes related to the initialization of the simulation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants