Page MenuHomec4science

simulation.h
No OneTemporary

File Metadata

Created
Mon, May 27, 00:16

simulation.h

//
// Created by Arnaud Pannatier on 06.05.18.
// Based on the code of :
// - Nicolas Richart <nicolas.richart@epfl.ch>
// - Vincent Keller <vincent.keller@epfl.ch>
// - Vittoria Rezzonico <vittoria.rezzonico@epfl.ch>
// See the files AUTHORS and COPYRIGHT for the concerning information
//
#ifndef PHPCTSUNAMIPROJECT_SIMULATION_H
#define PHPCTSUNAMIPROJECT_SIMULATION_H
#include <tuple>
#include <string>
#include <mpi.h>
#include "double_buffer.h"
#include "grid.h"
class Simulation {
public:
Simulation(int NX_,double G_, int SIZE_,double TEND_, double DX_, std::string dir_, std::string output_, MPI_Comm communicator_);
/// Simulation I/O
void readInitialConditionsFromFile();
void writeResultsToFile();
/// perform the simulation
std::tuple<double, int> compute();
inline int x(){ return NX; };
inline int y(){ return NY; };
protected:
/// compute one step, fetch ghost cells and call compute row
void compute_step();
// Sequential computation that compute the next value for the i-est row
void compute_row (int i);
// Compute the next time step
void compute_mu_and_set_dt ();
// Usefull for creating grids of the proper local size
void resizeGrids(int nx, int ny);
private:
/// Global problem size
int NX,NY;
/// Directory of the files where to read the grids and write the results
std::string dir;
/// Output filename
std::string outputFilename;
/// Constant, timesteps and scalar variables useful for the simulation
double G, TEND, DX, dt, T, C;
/// Size of the Grid
int SIZE;
/// Grid that stores the actual data for the height and the velocity of the water
DoubleBuffer H, HV,HU;
/// Topology of the map
Grid Zdx,Zdy;
/// Local problem size
int local_x, local_y;
/// Local problem size without ghost cells
int write_x, write_y;
/// variables for iteration without the ghost cells
int x_start_mu, x_end_mu;
/// local offset
int offset_x, offset_y;
/// local neighbors
int north_prank, south_prank;
/// proc rank
int prank;
/// communicator size
int psize;
/// communicator
MPI_Comm communicator;
};
#endif //PHPCTSUNAMIPROJECT_SIMULATION_H

Event Timeline