Skip to content

Commit

Permalink
remove set_pre_rhs_action
Browse files Browse the repository at this point in the history
  • Loading branch information
prkkumar committed Aug 28, 2024
1 parent f37ab64 commit 50b7f74
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions ExampleCodes/SUNDIALS/Reaction-Diffusion/Source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,11 @@ void main_main ()
WriteSingleLevelPlotfile(pltfile, phi, {"phi"}, geom, time, 0);
}

auto pre_rhs_function = [&](MultiFab& S_data, const Real /* time */) {
auto rhs_fast_function = [&](MultiFab& S_rhs, MultiFab& S_data,
const Real /* time */) {

// fill periodic ghost cells
S_data.FillBoundary(geom.periodicity());
};

auto rhs_function = [&](MultiFab& S_rhs, const MultiFab& S_data,
const Real /* time */) {

// loop over boxes
auto& phi_data = S_data;
Expand All @@ -195,16 +193,18 @@ void main_main ()
phi_rhs_array(i,j,k) = diffusion_coef*( (phi_array(i+1,j,k) - 2.*phi_array(i,j,k) + phi_array(i-1,j,k)) / (dx[0]*dx[0])
+(phi_array(i,j+1,k) - 2.*phi_array(i,j,k) + phi_array(i,j-1,k)) / (dx[1]*dx[1])
#if (AMREX_SPACEDIM == 3)
+(phi_array(i,j,k+1) - 2.*phi_array(i,j,k) + phi_array(i,j,k-1)) / (dx[2]*dx[2]) )
+(phi_array(i,j,k+1) - 2.*phi_array(i,j,k) + phi_array(i,j,k-1)) / (dx[2]*dx[2]) );
#endif
+ reaction_coef*phi_array(i,j,k);
});
}
};

auto rhs_fast_function = [&](MultiFab& S_rhs, const MultiFab& S_data,
auto rhs_function = [&](MultiFab& S_rhs, MultiFab& S_data,
const Real /* time */) {

// fill periodic ghost cells
S_data.FillBoundary(geom.periodicity());

// loop over boxes
auto& phi_data = S_data;
auto& phi_rhs = S_rhs;
Expand All @@ -226,17 +226,13 @@ void main_main ()
// fill the right-hand-side for phi
amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
{
phi_rhs_array(i,j,k) = diffusion_coef*( (phi_array(i+1,j,k) - 2.*phi_array(i,j,k) + phi_array(i-1,j,k)) / (dx[0]*dx[0])
+(phi_array(i,j+1,k) - 2.*phi_array(i,j,k) + phi_array(i,j-1,k)) / (dx[1]*dx[1])
#if (AMREX_SPACEDIM == 3)
+(phi_array(i,j,k+1) - 2.*phi_array(i,j,k) + phi_array(i,j,k-1)) / (dx[2]*dx[2]) );
#endif
phi_rhs_array(i,j,k) = -1.*reaction_coef*phi_array(i,j,k);
});
}
};


TimeIntegrator<MultiFab> integrator(phi, time);
integrator.set_pre_rhs_action(pre_rhs_function);
integrator.set_rhs(rhs_function);
integrator.set_fast_rhs(rhs_fast_function);
if (adapt_dt) {
Expand Down

0 comments on commit 50b7f74

Please sign in to comment.