Skip to content

Commit

Permalink
Add option to pout() GRAMRLevel::advance only to rank 0
Browse files Browse the repository at this point in the history
  • Loading branch information
TaigoFr committed Mar 17, 2021
1 parent 956bcdb commit bcf138a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 20 deletions.
1 change: 1 addition & 0 deletions Examples/BinaryBH/params_very_cheap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ data_subpath = "data"

# change the name of output files
#pout_prefix = "pout"
print_progress_only_to_rank_0 = 1
#################################################

# Set up grid spacings and regrid params
Expand Down
5 changes: 3 additions & 2 deletions Examples/KerrBH/params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verbosity = 0
chk_prefix = KerrBH_
plot_prefix = KerrBHp_
#restart_file = KerrBH_000060.3d.hdf5
print_progress_only_to_rank_0 = 1

# 'N' is the number of subdivisions in each direction of a cubic box
# 'L' is the length of the longest side of the box, dx_coarsest = L/N
Expand All @@ -12,7 +13,7 @@ plot_prefix = KerrBHp_
# NB - if you have a non-cubic grid, you can specify 'N1' or 'N1_full',
# 'N2' or 'N2_full' and 'N3' or 'N3_full' ( then dx_coarsest = L/N(max) )
# NB - the N values need to be multiples of the block_factor
N_full = 64
N_full = 128
L_full = 128

# Spatial derivative order (only affects CCZ4 RHS)
Expand All @@ -36,7 +37,7 @@ max_level = 6 # There are (max_level+1) grids, so min is zero
# Generally you do not need to regrid frequently on every level
# Level Regridding: 0 1 2 3 4 5
regrid_interval = 50 25 5 5 5 5
regrid_thresholds = 0.3 0.3 0.3 0.3 0.3 0.3
regrid_thresholds = 0.1 0.1 0.1 0.1 0.1 0.1

# Max box sizes
max_grid_size = 16
Expand Down
3 changes: 2 additions & 1 deletion Examples/KerrBH/params_cheap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ verbosity = 0
chk_prefix = KerrBH_
plot_prefix = KerrBHp_
#restart_file = KerrBH_000060.3d.hdf5
print_progress_only_to_rank_0 = 1

# 'N' is the number of subdivisions in each direction of a cubic box
# 'L' is the length of the longest side of the box, dx_coarsest = L/N
Expand Down Expand Up @@ -81,7 +82,7 @@ plot_interval = 0
num_plot_vars = 0
dt_multiplier = 0.25
stop_time = 10.0
max_steps = 2
max_steps = 4

#Lapse evolution
lapse_power = 1.0
Expand Down
12 changes: 9 additions & 3 deletions Source/GRChomboCore/ChomboParameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class ChomboParameters

if (pp.contains("check_params"))
just_check_params = true;

pp.load("print_progress_only_to_rank_0", print_progress_only_to_rank_0,
false);
}

void read_filesystem_params(GRParmParse &pp)
Expand Down Expand Up @@ -290,6 +293,7 @@ class ChomboParameters
L = (L_full * max_N) / max_N_full;

coarsest_dx = L / max_N;
coarsest_dt = coarsest_dx * dt_multiplier;

// grid spacing params
dx.fill(coarsest_dx);
Expand Down Expand Up @@ -445,9 +449,10 @@ class ChomboParameters
int verbosity;
double L; // Physical sidelength of the grid
std::array<double, CH_SPACEDIM> center; // grid center
IntVect ivN; // The number of grid cells in each dimension
double coarsest_dx; // The coarsest resolution
int max_level; // the max number of regriddings to do
IntVect ivN; // The number of grid cells in each dimension
double coarsest_dx,
coarsest_dt; // The coarsest resolution in space and time
int max_level; // the max number of regriddings to do
int max_spatial_derivative_order; // The maximum order of the spatial
// derivatives - does nothing
// in Chombo but can be used in examples
Expand Down Expand Up @@ -488,6 +493,7 @@ class ChomboParameters
// For checking parameters and then exiting rather before instantiating
// GRAMR (or child) object
bool just_check_params = false;
bool print_progress_only_to_rank_0;

protected:
// the low and high corners of the domain taking into account reflective BCs
Expand Down
54 changes: 40 additions & 14 deletions Source/GRChomboCore/GRAMRLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,25 @@ Real GRAMRLevel::advance()
{
CH_TIME("GRAMRLevel::advance");

// Work out roughly how fast the evolution is going since restart
double speed = (m_time - m_restart_time) / m_gr_amr.get_walltime();

// Get information on number of boxes on this level (helps with better load
// balancing)
const DisjointBoxLayout &level_domain = m_state_new.disjointBoxLayout();
int nbox = level_domain.dataIterator().size();
int total_nbox = level_domain.size();
pout() << "GRAMRLevel::advance level " << m_level << " at time " << m_time
<< " (" << speed << " M/hr)"
<< ". Boxes on this rank: " << nbox << " / " << total_nbox << endl;
// if 'print_progress_only_to_rank_0', still print if it's level 0 or
// t=restart_time
if (!m_p.print_progress_only_to_rank_0 || (procID() == 0) ||
m_time == m_restart_time)
{
// Work out roughly how fast the evolution is going since restart
double speed = (m_time - m_restart_time) / m_gr_amr.get_walltime();

// Get information on number of boxes on this level (helps with better
// load balancing)
const DisjointBoxLayout &level_domain = m_state_new.disjointBoxLayout();
int nbox = level_domain.dataIterator().size();
int total_nbox = level_domain.size();

pout() << "GRAMRLevel::advance level " << m_level << " at time "
<< m_time << " (" << speed << " M/hr)"
<< ". Boxes on this rank: " << nbox << " / " << total_nbox
<< endl;
}

// copy soln to old state to save it
m_state_new.copyTo(m_state_new.interval(), m_state_old,
Expand Down Expand Up @@ -350,6 +358,25 @@ void GRAMRLevel::regrid(const Vector<Box> &a_new_grids)
/// things to do after regridding
void GRAMRLevel::postRegrid(int a_base_level)
{
// if 'print_progress_only_to_rank_0', print progress only on regrids
// (except for rank 0, which kept doing prints)
if (m_p.print_progress_only_to_rank_0 && (procID() != 0))
{
// Work out roughly how fast the evolution is going since restart
double speed = (m_time - m_restart_time) / m_gr_amr.get_walltime();

// Get information on number of boxes on this level (helps with better
// load balancing)
const DisjointBoxLayout &level_domain = m_state_new.disjointBoxLayout();
int nbox = level_domain.dataIterator().size();
int total_nbox = level_domain.size();

pout() << "GRAMRLevel::postRegrid level " << m_level << " at time "
<< m_time << " (" << speed << " M/hr)"
<< ". Boxes on this rank: " << nbox << " / " << total_nbox
<< endl;
}

// set m_restart_time to same as the coarser level
if (m_level > a_base_level && m_coarser_level_ptr != nullptr)
{
Expand Down Expand Up @@ -989,15 +1016,14 @@ double GRAMRLevel::get_dx() const { return m_dx; }

bool GRAMRLevel::at_level_timestep_multiple(int a_level) const
{
const double coarsest_dt = m_p.coarsest_dx * m_p.dt_multiplier;
double target_dt = coarsest_dt;
double target_dt = m_p.coarsest_dt;
for (int ilevel = 0; ilevel < a_level; ++ilevel)
{
target_dt /= m_p.ref_ratios[ilevel];
}
// get difference to nearest multiple of target_dt
const double time_remainder = remainder(m_time, target_dt);
return (abs(time_remainder) < m_gr_amr.timeEps() * coarsest_dt);
return (abs(time_remainder) < m_gr_amr.timeEps() * m_p.coarsest_dt);
}

void GRAMRLevel::fillAllGhosts(const VariableType var_type,
Expand Down

0 comments on commit bcf138a

Please sign in to comment.