diff --git a/double_buffer.cpp b/double_buffer.cpp index f705667..3f4be1e 100644 --- a/double_buffer.cpp +++ b/double_buffer.cpp @@ -1,23 +1,18 @@ // // Created by Arnaud Pannatier on 06.05.18. // #include "double_buffer.h" #include "grid.h" DoubleBuffer::DoubleBuffer(int m, int n) : m_current(new Grid(m, n)), m_old(new Grid(m, n)) {} Grid & DoubleBuffer::current() { return *m_current; } Grid & DoubleBuffer::old() { return *m_old; } void DoubleBuffer::swap() { m_current.swap(m_old); } -void DoubleBuffer::resize (int nx, int ny) { - //std::cout << "NX : " << nx << std::endl; - current().resize(nx,ny); - old().resize(nx,ny); -} diff --git a/grid.h b/grid.h index 3572d0a..ffda56e 100644 --- a/grid.h +++ b/grid.h @@ -1,93 +1,90 @@ // // Created by Arnaud Pannatier on 06.05.18. // Based on the code of : // - Nicolas Richart // - Vincent Keller // - Vittoria Rezzonico // See the files AUTHORS and COPYRIGHT for the concerning information // #ifndef PHPCTSUNAMIPROJECT_GRID_H #define PHPCTSUNAMIPROJECT_GRID_H #include #include class Grid { public: Grid() = default; Grid(int m, int n); /// Getter and Const Getter inline double & get(int i, int j){ return m_grid[i * m_y + j]; }; inline const double & get(int i, int j) const { return m_grid[i * m_y + j]; }; /// access the value [i][j] of the grid inline double & operator()(int i, int j) { return m_grid[i * m_y + j]; } inline const double & operator()(int i, int j) const { return m_grid[i * m_y + j]; } /// Sequential matrix multiplication operators, never used. Grid& operator*= (const double a); Grid& operator*= (Grid const& b); Grid& operator+= (const double a); Grid& operator+= (Grid const& b); Grid operator-() const; Grid inv() const; /// set the grid to 0 void clear(); - - /// Change the shape of the grid - void resize(int nx, int ny); - + /// Remove ghosts cells and return vector double std::vector RemoveGhostCellsAndPrepareToWrite(int psize, int prank, int local_x, int local_y); /// Apply the mirror boundary conditions void applyBoundaryConditions(); /// Impose the tolerances to avoid numerical issues void imposeTolerances(double tol, double value, const Grid&); /// Get the size of the grid int x() const; int y() const; /// print the grid friend std::ostream& operator<<(std::ostream& os, const Grid&); private: /// size int m_x, m_y; /// data std::vector m_grid; }; /// Overloaded Matrix operation, but are not really good for perfomance so never used. Grid operator*(double a, Grid const& g); inline Grid operator*(Grid const& g, double a) { return a*g; } Grid operator*(Grid const& a, Grid const& b); Grid operator+(double a, Grid const& g); inline Grid operator+(Grid const& g,double a){ return a+g; }; Grid operator+(Grid const& a, Grid const& b); inline Grid operator-(double a, Grid const& g){ return a+(-g);}; inline Grid operator-(Grid const& g,double a){ return a-g; }; inline Grid operator-(Grid const& a, Grid const& b){ return a+(-b); }; inline Grid operator/(double a, Grid const& g){ return a*g.inv(); }; inline Grid operator/(Grid const& g,double a){ return a/g; }; inline Grid operator/(Grid const& a, Grid const& b){ return a * b.inv(); }; Grid sqrt(Grid const& a); Grid pow(Grid const& a, double p); double max(Grid const& a); Grid maxAbs(Grid const&, Grid const&); #endif //PHPCTSUNAMIPROJECT_GRID_H