Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121972280
simulation.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 15, 03:40
Size
1 KB
Mime Type
text/x-c++
Expires
Thu, Jul 17, 03:40 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27419729
Attached To
rSCINTROPARALLEL Poisson code for introduction to parallelism
simulation.hh
View Options
#ifndef SIMULATION_HH
#define SIMULATION_HH
/* -------------------------------------------------------------------------- */
#include "double_buffer.hh"
#include "dumpers.hh"
#include "grid.hh"
/* -------------------------------------------------------------------------- */
#include <array>
#include <memory>
#include <tuple>
#if defined(_MPI)
#include <mpi.h>
#endif
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class Simulation {
public:
#if defined(_MPI)
Simulation(int m, int n, MPI_Comm communicator);
#else
Simulation(int m, int n);
#endif
/// set the initial conditions, Dirichlet and source term
virtual void set_initial_conditions();
/// perform the simulation
std::tuple<float, int> compute();
/// access the precision
void set_epsilon(float epsilon);
float epsilon() const;
std::size_t complexity() { return 8 * m_global_size[0] * m_global_size[1]; }
float min() const;
float max() const;
float dims(std::size_t i) const { return m_dims[i]; }
protected:
/// compute one step and return an error
virtual float compute_step();
/// compute one row
float compute_row(int i);
private:
/// Global problem size
std::array<int, 2> m_global_size;
/// Local problem size
std::array<int, 2> m_local_size;
/// local offset
std::array<int, 2> m_offset;
/// Cartesian dimensions
std::array<int, 2> m_dims;
/// Cartesian coordinates
std::array<int, 2> m_coords;
/// proc rank
int m_prank{0};
/// communicator size
int m_psize{1};
/// Precision to achieve
float m_epsilon;
/// grid spacing
std::array<float, 2> m_h;
float m_l2_shared;
/// Grids storage
DoubleBuffer m_grids;
/// source term
Grid m_f;
/// Dumper to use for outputs
std::unique_ptr<Dumper> m_dumper;
#if defined(_MPI)
/// communicator
MPI_Comm m_communicator;
#endif
};
#endif /* SIMULATION_HH */
Event Timeline
Log In to Comment