| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * @file stencil.hpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Mon Apr 18 12:25:05 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief VMG::Stencil
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | #ifndef STENCIL_HPP_
|
|---|
| 12 | #define STENCIL_HPP_
|
|---|
| 13 |
|
|---|
| 14 | #include <cstddef>
|
|---|
| 15 | #include <vector>
|
|---|
| 16 |
|
|---|
| 17 | #include "base/defs.hpp"
|
|---|
| 18 |
|
|---|
| 19 | namespace VMG
|
|---|
| 20 | {
|
|---|
| 21 |
|
|---|
| 22 | class Grid;
|
|---|
| 23 | class Index;
|
|---|
| 24 |
|
|---|
| 25 | struct Displacement
|
|---|
| 26 | {
|
|---|
| 27 | int m, n, o;
|
|---|
| 28 | vmg_float val;
|
|---|
| 29 |
|
|---|
| 30 | Displacement(int m_, int n_, int o_, vmg_float val_)
|
|---|
| 31 | {
|
|---|
| 32 | m = m_;
|
|---|
| 33 | n = n_;
|
|---|
| 34 | o = o_;
|
|---|
| 35 | val = val_;
|
|---|
| 36 | }
|
|---|
| 37 | };
|
|---|
| 38 |
|
|---|
| 39 | class Stencil
|
|---|
| 40 | {
|
|---|
| 41 | public:
|
|---|
| 42 | Stencil(vmg_float diag_) :
|
|---|
| 43 | diag(diag_)
|
|---|
| 44 | {}
|
|---|
| 45 |
|
|---|
| 46 | Stencil(const Stencil& stencil_)
|
|---|
| 47 | {
|
|---|
| 48 | this->diag = stencil_.GetDiag();
|
|---|
| 49 |
|
|---|
| 50 | for (Stencil::iterator iter=stencil_.begin(); iter!=stencil_.end(); iter++)
|
|---|
| 51 | this->push_back(*iter);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | typedef std::vector<Displacement>::const_iterator iterator;
|
|---|
| 55 |
|
|---|
| 56 | void push_back(const Displacement& val)
|
|---|
| 57 | {
|
|---|
| 58 | disp.push_back(val);
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | iterator begin() const
|
|---|
| 62 | {
|
|---|
| 63 | return disp.begin();
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | iterator end() const
|
|---|
| 67 | {
|
|---|
| 68 | return disp.end();
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | size_t size() const
|
|---|
| 72 | {
|
|---|
| 73 | return disp.size();
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | vmg_float GetDiag() const {return diag;}
|
|---|
| 77 | void SetDiag(vmg_float diag_) {diag = diag_;}
|
|---|
| 78 |
|
|---|
| 79 | void Clear()
|
|---|
| 80 | {
|
|---|
| 81 | disp.clear();
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | vmg_float Apply(const Grid& grid, const Index& index) const;
|
|---|
| 85 |
|
|---|
| 86 | private:
|
|---|
| 87 | std::vector<Displacement> disp;
|
|---|
| 88 | vmg_float diag;
|
|---|
| 89 | };
|
|---|
| 90 |
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | #endif /* STENCIL_HPP_ */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.