Commit d05d54bd authored by Johannes Blaschke's avatar Johannes Blaschke
Browse files

comment main loop

parent 5fe16af2
......@@ -351,37 +351,64 @@ void run_support__print_status(int num_time_steps, int time_step){
}
void run_n_timesteps(int n, world_state* world, int ext_control)
{
int last=0;
void run_n_timesteps(int n, world_state* world, int ext_control) {
// **************************** HOUSE Keeping *************************************************************************
// flag used for garbadge collection at the end of the simulation
// TODO: Improve garbadge collection system
int last = 0;
// **************************** PRINT Status: START *******************************************************************
// inform user the the time loop has started (include details about the time loop)
if(cpu.rank==0) printf("Beginning time loop, begin timestep = %d end timestep = %d \n", world->timestep, n);
//all_cpus_print_active_and_inactive_squirmers(get_squirmers(world), get_nsquirmers(world), "Squirmers[beginning]");
// **************************** MAIN LOOP: ****************************************************************************
// number of time steps that the main loop has to ittrate over
int num_time_steps = n - world->timestep;
for(; world->timestep<=n; world->timestep++){
// ************* PRINT Status updates **************************************************************
run_support__print_status(num_time_steps, world->timestep);
if((world->timestep == n) && (ext_control == 0)){
// ************* determine IF LAST step ************************************************************
// TODO: again, use a more sane gabadge collection mechanism
if( (world->timestep == n) && (ext_control == 0) ){
last = 1;
if(cpu.rank == 0) printf("Last timestep \n");
}
// ************* MPCD Algorithm: START *************************************************************
// streaming operator acting on:
// (1) particles and obstacles [world]
// (2) gshift [cpu] ** GLOBAL **
run_support__timed_mpi_barrier(1);
stream(world->timestep, 0, world);
// collision operator acting on:
// (1) particles and obstalces [world]
// (2) grid [world]
if(!config.without_collision){
run_support__timed_mpi_barrier(2);
collision(world, last); // if taken out, undo gridshift has to be done in stream
}
// ************* MPCD Algorithm: END ***************************************************************
// ************* PRINT RESULTS TO FILE *************************************************************
// this includes end data (in order to allow simulations to be resumed)
// TODO: move squirmer end data printing here (it's currently in a really awkward place)
// system output house keeping
fflush(0);
if((cpu.rank == 0) && (config.trypanosome_on == 1) && (world->timestep % config.naverage == 0)){
// print trypanosome data
if((cpu.rank == 0) && (config.trypanosome_on == 1) && (world->timestep % config.naverage == 0)) {
tryp_FILE tryp_fp = tryp_support__access_fp("sim data");
print_trypanosome_to_file(world->trypanosome, tryp_fp, world->timestep); //TODO: implement averaging
print_trypanosome_to_file(world->trypanosome, tryp_fp, world->timestep);
}
// print system enddata to file
if(world->timestep>0){
if((world->timestep % 500000 == 0 ) || last){
if(cpu.rank == 0) printf("\n Printing world state to file \n");
......@@ -391,7 +418,7 @@ void run_n_timesteps(int n, world_state* world, int ext_control)
if(config.squirmeron == 1)
print_squirmer_enddata_to_file(get_squirmers(world), get_nsquirmers(world));
print_conserved_quantities_to_file(get_particles(world), get_nparticles(world),get_squirmers(world), get_nsquirmers(world), world->timestep);
print_conserved_quantities_to_file(get_particles(world), get_nparticles(world), get_squirmers(world), get_nsquirmers(world), world->timestep);
if((cpu.rank == 0) && (config.trypanosome_on == 1)){
tryp_FILE tryp_fp = tryp_support__access_fp("end data");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment