Skip to content

Commit

Permalink
Merge branch 'development' into fix_close_stars
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Apr 21, 2024
2 parents 161093b + 4ef6d25 commit 31c6057
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wdmerger_collision-compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ jobs:
- name: Check the extrema
run: |
cd Exec/science/wdmerger
../../../external/amrex/Tools/Plotfile/fextrema.gnu.ex plt00088 > fextrema.out
../../../external/amrex/Tools/Plotfile/fextrema.gnu.ex plt00086 > fextrema.out
diff fextrema.out ci-benchmarks/wdmerger_collision_2D.out
30 changes: 1 addition & 29 deletions Exec/science/wdmerger/ci-benchmarks/wdmerger_collision_2D.out
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
plotfile = plt00088
time = 1.25
variables minimum value maximum value
density 8.6729292612e-05 7845757.9641
xmom -4.0633354972e+14 1.551400564e+15
ymom -1.3597988369e+15 2.2475296277e+15
zmom 0 0
rho_E 9.2398321093e+11 5.3915021975e+24
rho_e 8.4936113732e+11 5.3523796964e+24
Temp 100000 3949829619.9
rho_He4 8.6729292612e-17 1288.8271801
rho_C12 3.4691717045e-05 2795592.1766
rho_O16 5.2037575567e-05 4714582.9885
rho_Ne20 8.6729292612e-17 550048.75584
rho_Mg24 8.6729292612e-17 996221.69275
rho_Si28 8.6729292612e-17 4108826.6962
rho_S32 8.6729292612e-17 2116229.6136
rho_Ar36 8.6729292612e-17 509049.28375
rho_Ca40 8.6729292612e-17 472504.19598
rho_Ti44 8.6729292612e-17 1071.9217721
rho_Cr48 8.6729292612e-17 5082.0773428
rho_Fe52 8.6729292612e-17 70257.464505
rho_Ni56 8.6729292612e-17 1284867.6299
phiGrav -4.8152316901e+17 -2.3376725137e+16
grav_x -526515781.34 -51483.706401
grav_y -565949608.7 391647841.27
grav_z 0 0
rho_enuc -2.7110182763e+22 5.5221803639e+26

slicing along x-direction and output to plt00086.slice
124 changes: 71 additions & 53 deletions Source/driver/Castro_advance_ctu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,18 @@ Castro::retry_advance_ctu(Real dt, const advance_status& status)

if (do_retry) {

if (status.suggested_dt > 0.0_rt && status.suggested_dt < dt) {
dt_subcycle = status.suggested_dt;
int max_level_to_advance = level;

if (parent->subcyclingMode() == "None" && level == 0) {
max_level_to_advance = parent->finestLevel();
}
else {
dt_subcycle = std::min(dt, dt_subcycle) * retry_subcycle_factor;

for (int lev = level; lev <= max_level_to_advance; ++lev) {
if (status.suggested_dt > 0.0_rt && status.suggested_dt < dt) {
getLevel(lev).dt_subcycle = status.suggested_dt;
} else {
getLevel(lev).dt_subcycle = std::min(dt, getLevel(lev).dt_subcycle) * retry_subcycle_factor;
}
}

if (verbose && ParallelDescriptor::IOProcessor()) {
Expand All @@ -178,53 +185,56 @@ Castro::retry_advance_ctu(Real dt, const advance_status& status)
// be useful to us at the end of the timestep when we need
// to restore the original old data.

save_data_for_retry();
for (int lev = level; lev <= max_level_to_advance; ++lev) {
getLevel(lev).save_data_for_retry();

// Clear the contribution to the fluxes from this step.
// Clear the contribution to the fluxes from this step.

for (int dir = 0; dir < 3; ++dir) {
fluxes[dir]->setVal(0.0);
}
for (int dir = 0; dir < 3; ++dir) {
getLevel(lev).fluxes[dir]->setVal(0.0);
}

for (int dir = 0; dir < 3; ++dir) {
mass_fluxes[dir]->setVal(0.0);
}
for (int dir = 0; dir < 3; ++dir) {
getLevel(lev).mass_fluxes[dir]->setVal(0.0);
}

#if (AMREX_SPACEDIM <= 2)
if (!Geom().IsCartesian()) {
P_radial.setVal(0.0);
}
if (!Geom().IsCartesian()) {
getLevel(lev).P_radial.setVal(0.0);
}
#endif

#ifdef RADIATION
if (Radiation::rad_hydro_combined) {
for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
rad_fluxes[dir]->setVal(0.0);
}
}
if (Radiation::rad_hydro_combined) {
for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
getLevel(lev).rad_fluxes[dir]->setVal(0.0);
}
}
#endif

#ifdef REACTIONS
if (castro::store_burn_weights) {
burn_weights.setVal(0.0);
}
if (castro::store_burn_weights) {
getLevel(lev).burn_weights.setVal(0.0);
}
#endif

// For simplified SDC, we'll have garbage data if we
// attempt to use the lagged source terms (both reacting
// and non-reacting) from the last timestep, since that
// advance failed and we don't know if we can trust it.
// So we zero out both source term correctors.
// For simplified SDC, we'll have garbage data if we
// attempt to use the lagged source terms (both reacting
// and non-reacting) from the last timestep, since that
// advance failed and we don't know if we can trust it.
// So we zero out both source term correctors.

if (time_integration_method == SimplifiedSpectralDeferredCorrections) {
source_corrector.setVal(0.0, source_corrector.nGrow());
if (time_integration_method == SimplifiedSpectralDeferredCorrections) {
getLevel(lev).source_corrector.setVal(0.0, getLevel(lev).source_corrector.nGrow());

#ifdef SIMPLIFIED_SDC
#ifdef REACTIONS
MultiFab& SDC_react_new = get_new_data(Simplified_SDC_React_Type);
SDC_react_new.setVal(0.0, SDC_react_new.nGrow());
MultiFab& SDC_react_new = getLevel(lev).get_new_data(Simplified_SDC_React_Type);
SDC_react_new.setVal(0.0, SDC_react_new.nGrow());
#endif
#endif
}

}

}
Expand Down Expand Up @@ -311,7 +321,9 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration,

if (num_subcycles_remaining > max_subcycles) {
amrex::Print() << std::endl
<< " The subcycle mechanism requested " << num_subcycles_remaining << " subcycled timesteps, which is larger than the maximum of " << max_subcycles << "." << std::endl
<< " The subcycle mechanism requested " << num_subcycles_remaining
<< " subcycled timesteps, which is larger than the maximum of "
<< max_subcycles << "." << std::endl
<< " If you would like to override this, increase the parameter castro.max_subcycles." << std::endl;
amrex::Abort("Error: too many subcycles.");
}
Expand All @@ -320,9 +332,12 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration,

if (verbose && ParallelDescriptor::IOProcessor()) {
std::cout << std::endl;
std::cout << Font::Bold << FGColor::Green << " Beginning subcycle " << sub_iteration + 1 << " starting at time " << subcycle_time
std::cout << Font::Bold << FGColor::Green
<< " Beginning subcycle " << sub_iteration + 1
<< " starting at time " << subcycle_time
<< " with dt = " << dt_subcycle << ResetDisplay << std::endl;
std::cout << " Estimated number of subcycles remaining: " << num_subcycles_remaining << std::endl << std::endl;
std::cout << " Estimated number of subcycles remaining: "
<< num_subcycles_remaining << std::endl << std::endl;
}

// Swap the time levels. Only do this after the first iteration;
Expand All @@ -331,19 +346,18 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration,

if (do_swap) {

swap_state_time_levels(0.0);
for (int lev = level; lev <= max_level_to_advance; ++lev) {
getLevel(lev).swap_state_time_levels(0.0);

#ifdef GRAVITY
if (do_grav) {
gravity->swapTimeLevels(level);
}
if (do_grav) {
getLevel(lev).gravity->swapTimeLevels(lev);
}
#endif
}

}
else {

} else {
do_swap = true;

}

// Set the relevant time levels.
Expand Down Expand Up @@ -462,7 +476,9 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration,

// Record the number of subcycles we took for diagnostic purposes.

num_subcycles_taken = sub_iteration;
for (int lev = level; lev <= max_level_to_advance; ++lev) {
getLevel(lev).num_subcycles_taken = sub_iteration;
}

if (sub_iteration > 1) {

Expand All @@ -472,14 +488,14 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration,
// we still have the last iteration's old data if we need
// it later.

for (int k = 0; k < num_state_type; k++) {

if (prev_state[k]->hasOldData()) {
state[k].replaceOldData(*prev_state[k]);
for (int lev = level; lev <= max_level_to_advance; ++lev) {
for (int k = 0; k < num_state_type; k++) {
if (getLevel(lev).prev_state[k]->hasOldData()) {
getLevel(lev).state[k].replaceOldData(*getLevel(lev).prev_state[k]);
}
getLevel(lev).state[k].setTimeLevel(time + dt, dt, 0.0);
getLevel(lev).prev_state[k]->setTimeLevel(time + dt, dt_subcycle, 0.0);
}
state[k].setTimeLevel(time + dt, dt, 0.0);
prev_state[k]->setTimeLevel(time + dt, dt_subcycle, 0.0);

}

// If we took more than one step and are going to do a reflux,
Expand All @@ -491,8 +507,10 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration,
// reflux immediately following this, skip this if we're on the
// finest level and this is not the last iteration.

if (!(amr_iteration < amr_ncycle && level == parent->finestLevel())) {
keep_prev_state = true;
for (int lev = level; lev <= max_level_to_advance; ++lev) {
if (!(amr_iteration < amr_ncycle && lev == parent->finestLevel())) {
getLevel(lev).keep_prev_state = true;
}
}

}
Expand Down

0 comments on commit 31c6057

Please sign in to comment.