source: src/base/stencil.hpp@ e7e9a6

Last change on this file since e7e9a6 was dfed1c, checked in by Julian Iseringhausen <isering@…>, 14 years ago

Major vmg update.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1136 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 1.7 KB
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#ifndef STENCIL_HPP_
11#define STENCIL_HPP_
12
13#include <cstddef>
14#include <vector>
15
16#include "base/index.hpp"
17
18namespace VMG
19{
20
21class Grid;
22
23class Displacement
24{
25public:
26 Displacement() :
27 disp(0),
28 val(0.0)
29 {}
30
31 Displacement(const Index& disp_, const vmg_float& val_) :
32 disp(disp_),
33 val(val_)
34 {}
35
36 const Index& Disp() const {return disp;}
37 const vmg_float& Val() const {return val;}
38
39private:
40 Index disp;
41 vmg_float val;
42};
43
44class Stencil
45{
46public:
47 typedef std::vector<Displacement>::const_iterator iterator;
48
49 Stencil(const vmg_float& diag_) :
50 diag(diag_)
51 {}
52
53 Stencil(const Stencil& stencil_)
54 {
55 this->diag = stencil_.GetDiag();
56
57 for (Stencil::iterator iter=stencil_.begin(); iter!=stencil_.end(); iter++)
58 this->push_back(*iter);
59 }
60
61 const vmg_float& GetDiag() const {return diag;}
62 void SetDiag(const vmg_float& diag_) {diag = diag_;}
63
64 const Displacement& operator[](const int& index) const {return disp[index];}
65
66 void push_back(const int& x, const int& y, const int& z, const vmg_float& val)
67 {
68 disp.push_back(Displacement(Index(x,y,z), val));
69 }
70
71 void push_back(const Displacement& displacement)
72 {
73 disp.push_back(displacement);
74 }
75
76 iterator begin() const
77 {
78 return disp.begin();
79 }
80
81 iterator end() const
82 {
83 return disp.end();
84 }
85
86 size_t size() const
87 {
88 return disp.size();
89 }
90
91 void clear()
92 {
93 disp.clear();
94 }
95
96 vmg_float Apply(const Grid& grid, const Index& index) const;
97
98private:
99 std::vector<Displacement> disp;
100 vmg_float diag;
101};
102
103}
104
105#endif /* STENCIL_HPP_ */
Note: See TracBrowser for help on using the repository browser.