Skip to content

Commit 4b45893

Browse files
committed
more optimization of normalize_species
this eliminates some Array4 loads
1 parent a126e15 commit 4b45893

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Source/driver/Castro.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,7 +3162,7 @@ Castro::normalize_species (MultiFab& S_new, int ng)
31623162
reduce_op.eval(bx, reduce_data,
31633163
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept -> ReduceTuple
31643164
{
3165-
Real rhoX_sum = 0.0_rt;
3165+
Real sum = 0.0_rt;
31663166
Real rho = u(i,j,k,URHO);
31673167
Real rhoInv = 1.0_rt / rho;
31683168

@@ -3187,15 +3187,15 @@ Castro::normalize_species (MultiFab& S_new, int ng)
31873187
}
31883188
}
31893189

3190-
u(i,j,k,UFS+n) = amrex::Clamp(u(i,j,k,UFS+n), lsmall_x * rho, rho);
3191-
rhoX_sum += u(i,j,k,UFS+n);
3190+
X = amrex::Clamp(X, lsmall_x, 1.0_rt);
3191+
sum += X;
31923192
}
31933193

3194-
Real fac = u(i,j,k,URHO) / rhoX_sum;
3194+
Real fac = 1.0_rt / sum;
31953195

3196-
for (int n = 0; n < NumSpec; ++n) {
3196+
amrex::constexpr_for<0, NumSpec>([&] (auto n) {
31973197
u(i,j,k,UFS+n) *= fac;
3198-
}
3198+
});
31993199

32003200
return {failed};
32013201
});

0 commit comments

Comments
 (0)