Skip to content

Commit

Permalink
Applied bruno's final comments
Browse files Browse the repository at this point in the history
  • Loading branch information
OGaboriault committed Oct 28, 2024
1 parent abe92b5 commit e50d30d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
17 changes: 9 additions & 8 deletions include/core/checkpoint_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#ifndef lethe_checkpoint_control_h
#define lethe_checkpoint_control_h

#include <core/parameters.h>

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>

Expand All @@ -17,20 +19,19 @@ class CheckpointControl
* @param checkpoint_freq Checkpoint frequency.
* @param restart_filename Filename used for the prefix during checkpointing.
*/
CheckpointControl(const unsigned int checkpoint_freq,
const std::string &restart_filename)
CheckpointControl(Parameters::Restart &restart)
: max_checkpoint_id(2)
, next_checkpoint_id(max_checkpoint_id)
, checkpointing_frequency(checkpoint_freq)
, filename(restart_filename)
, checkpointing_frequency(restart.frequency)
, filename(restart.filename)
{}

/**
* @brief Return true if a checkpoint should be made at the current time step.
* @param time_step_number Current time step.
*/
bool
is_checkpoint_time_step(const unsigned int time_step_number)
is_checkpoint_time_step(const unsigned int time_step_number) const
{
return (time_step_number % checkpointing_frequency) == 0;
}
Expand All @@ -54,7 +55,7 @@ class CheckpointControl
}

/**
* @brief Return de prefix for the restart files.
* @brief Return the prefix for the restart files.
*/
std::string
get_filename() const
Expand All @@ -69,7 +70,7 @@ class CheckpointControl
void
serialize(boost::archive::text_oarchive &ar, const unsigned int) const
{
ar &next_checkpoint_id;
ar << next_checkpoint_id;
}

/**
Expand All @@ -79,7 +80,7 @@ class CheckpointControl
void
deserialize(boost::archive::text_iarchive &ar, const unsigned int)
{
ar &next_checkpoint_id;
ar >> next_checkpoint_id;
}

private:
Expand Down
3 changes: 1 addition & 2 deletions source/dem/dem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ DEMSolver<dim>::DEMSolver(DEMSolverParameters<dim> dem_parameters)
, this_mpi_process(Utilities::MPI::this_mpi_process(mpi_communicator))
, pcout(std::cout, Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
, parameters(dem_parameters)
, checkpoint_controller(CheckpointControl(parameters.restart.frequency,
parameters.restart.filename))
, checkpoint_controller(parameters.restart)
, triangulation(this->mpi_communicator)
, mapping(1)
, particle_handler(triangulation, mapping, DEM::get_number_properties())
Expand Down
2 changes: 1 addition & 1 deletion source/dem/write_checkpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ write_checkpoint(
// Prepare the checkpoint controller for checkpointing
// We don't use the same prefix, since this file needs to have the same name
// regardless of the checkpoint id being used. This file is giving the
// information of which checkpoint id to use when restarting
// information of which checkpoint id to use when restarting.
std::string checkpoint_controller_object_filename =
checkpoint_controller.get_filename() + ".checkpoint_controller";
std::ofstream oss_checkpoint_controller_obj(
Expand Down

0 comments on commit e50d30d

Please sign in to comment.