Skip to content

Commit

Permalink
Now passes in MultiFabs for state_old and state_new. This provides ac…
Browse files Browse the repository at this point in the history
…cess to state_old.Factory() etc.
  • Loading branch information
dmontgomeryNREL committed Oct 21, 2024
1 parent 3e32ab3 commit 19279b1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
7 changes: 4 additions & 3 deletions Exec/RegTests/EB_ODEQty/PeleLMeX_ProblemSpecificFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ problem_modify_ext_sources(
Real /*time*/,
Real /*dt*/,
int lev,
MultiArray4<const Real> const& state_old_arr,
MultiArray4<const Real> const& /*state_new_arr*/,
const MultiFab& state_old,
const MultiFab& /*state_new*/,
Vector<std::unique_ptr<MultiFab>>& a_extSource,
const GeometryData& /*geomdata*/,
ProbParm const& prob_parm)
const ProbParm& prob_parm)
{
/*
Notes:
Expand All @@ -42,6 +42,7 @@ problem_modify_ext_sources(
*/

auto ext_source_arr = a_extSource[lev]->arrays();
auto const& state_old_arr = state_old.const_arrays();

ParallelFor(
*a_extSource[lev],
Expand Down
8 changes: 4 additions & 4 deletions Source/PeleLMeX_Forces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ PeleLM::getExternalSources(
// User defined external sources
if (m_user_defined_ext_sources) {
for (int lev = 0; lev <= finest_level; lev++) {
auto* ldata_p_old = getLevelDataPtr(lev, a_timestamp_old);
auto* ldata_p_new = getLevelDataPtr(lev, a_timestamp_new);
problem_modify_ext_sources(
getTime(lev, a_timestamp_new), m_dt, lev,
getLevelDataPtr(lev, a_timestamp_old)->state.const_arrays(),
getLevelDataPtr(lev, a_timestamp_new)->state.const_arrays(),
m_extSource, geom[lev].data(), *prob_parm_d);
getTime(lev, a_timestamp_new), m_dt, lev, ldata_p_old->state,
ldata_p_new->state, m_extSource, geom[lev].data(), *prob_parm_d);
}
}
}
6 changes: 3 additions & 3 deletions Source/PeleLMeX_ProblemSpecificFunctions.H
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ void problem_modify_ext_sources(
Real time,
Real dt,
int lev,
MultiArray4<const Real> const& state_old,
MultiArray4<const Real> const& state_new,
const MultiFab& state_old,
const MultiFab& state_new,
Vector<std::unique_ptr<MultiFab>>& a_extSource,
const GeometryData& geomdata,
ProbParm const& prob_parm);
const ProbParm& prob_parm);
#endif
12 changes: 7 additions & 5 deletions Source/PeleLMeX_ProblemSpecificFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ problem_modify_ext_sources(
Real /*time*/,
Real /*dt*/,
int /*lev*/,
MultiArray4<const Real> const& /*state_old_arr*/,
MultiArray4<const Real> const& /*state_new_arr*/,
const MultiFab& /*state_old*/,
const MultiFab& /*state_new*/,
Vector<std::unique_ptr<MultiFab>>& /*a_extSource*/,
const GeometryData& /*geomdata*/,
ProbParm const& /*prob_parm*/)
const ProbParm& /*prob_parm*/)
{
/*
Notes:
Expand All @@ -42,13 +42,15 @@ problem_modify_ext_sources(
// Example: Exponential decay ode quantity
auto ext_source_arr = a_extSource[lev]->arrays();
auto const& state_old_arr = state_old.const_arrays();
ParallelFor(
*a_extSource[lev],
[=] AMREX_GPU_DEVICE(int box_no, int i, int j, int k) noexcept {
for (int n = 0; n < NUM_ODE; n++){
for (int n = 0; n < NUM_ODE; n++) {
Real B_n = state_old_arr[box_no](i, j, k, FIRSTODE + n);
Real src_strength = -1.0 * pow(10.0,n+1);
ext_source_arr[box_no](i, j, k, FIRSTODE + n) += src_strength * B_n;
ext_source_arr[box_no](i, j, k, FIRSTODE + n) += src;
}
});
Gpu::streamSynchronize();
Expand Down

0 comments on commit 19279b1

Please sign in to comment.