Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91103870
grid.h
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
Thu, Nov 7, 22:49
Size
2 KB
Mime Type
text/x-c++
Expires
Sat, Nov 9, 22:49 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22197297
Attached To
rTSUNAMIPROJECT PHPC-TSUNAMI-PROJECT
grid.h
View Options
//
// 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_GRID_H
#define PHPCTSUNAMIPROJECT_GRID_H
#include <vector>
#include <iostream>
class Grid {
public:
Grid(std::size_t m, std::size_t n);
inline double & get(std::size_t i, std::size_t j){ return m_grid[i * m_x + j]; };
inline const double & get(std::size_t i, std::size_t j) const { return m_grid[i * m_x + j]; };
/// access the value [i][j] of the grid
inline double & operator()(std::size_t i, std::size_t j) { return get(i,j); }
inline const double & operator()(std::size_t i, std::size_t j) const {
return get(i,j);
}
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();
void applyBoundaryConditions();
void imposeTolerances(double tol, double value, const Grid&);
std::size_t m() const;
std::size_t n() const;
friend std::ostream& operator<<(std::ostream& os, const Grid&);
private:
std::size_t m_x, m_y;
std::vector<double> m_grid;
};
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
Event Timeline
Log In to Comment