Changeset dfed1c for src/grid/grid.hpp
- Timestamp:
- Nov 22, 2011, 9:22:10 PM (14 years ago)
- Children:
- facba0
- Parents:
- 66f24d
- File:
-
- 1 edited
-
src/grid/grid.hpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/grid/grid.hpp
r66f24d rdfed1c 12 12 13 13 #include "base/object.hpp" 14 #include "grid/grid_indexing.hpp" 14 #include "grid/grid_index_translations.hpp" 15 #include "grid/grid_iterator.hpp" 16 #include "grid/grid_iterator_suite.hpp" 17 #include "grid/grid_properties.hpp" 15 18 16 19 namespace VMG … … 18 21 19 22 class Comm; 23 class Multigrid; 24 class Stencil; 20 25 21 26 class Grid : public Object 22 27 { 23 28 public: 24 Grid() 29 typedef GridIterator iterator; 30 31 Grid(int level_ = 0, Multigrid* father_ = NULL) : 32 index_translations(this), 33 level(level_), 34 father(father_) 25 35 { 26 36 grid = NULL; 27 37 } 28 38 29 Grid(const GlobalIndices& global_, const LocalIndices& local_, const SpatialExtent& extent_) : 39 Grid(const GlobalIndices& global_, const LocalIndices& local_, const SpatialExtent& extent_, 40 int level_ = 0, Multigrid* father_ = NULL) : 41 index_translations(this), 42 level(level_), 30 43 global(global_), 31 44 local(local_), 32 extent(extent_) 33 {InitGrid();} 45 extent(extent_), 46 iterators(local_), 47 father(father_) 48 { 49 InitGrid(); 50 } 51 52 Grid(const Grid& rhs) : 53 index_translations(rhs.Indexing()), 54 level(rhs.Level()), 55 global(rhs.Global()), 56 local(rhs.Local()), 57 extent(rhs.Extent()), 58 iterators(rhs.Iterators()), 59 father(rhs.Father()) 60 { 61 InitGrid(); 62 SetGrid(rhs); 63 } 34 64 35 65 virtual ~Grid(); 36 66 37 Grid (const Comm* comm, const Index& size, const vmg_float& width);67 Grid& operator=(const Grid& rhs); 38 68 39 69 const GlobalIndices& Global() const {return global;} … … 44 74 LocalIndices& Local() {return local;} 45 75 SpatialExtent& Extent() {return extent;} 76 77 GridIteratorSuite& Iterators() {return iterators;} 78 const GridIteratorSuite& Iterators() const {return iterators;} 46 79 47 80 const vmg_float& MeshWidth() const {return Extent().MeshWidth().X();} ///< Mesh width of current level … … 77 110 int GlobalLinearIndex(const Index& index) const; 78 111 79 Index GlobalToLocalIndex(const Index& index) const;80 81 112 bool IsCompatible(const Grid& rhs) const; ///< Check if two grids share compatible settings 82 113 bool IsConsistent() const; ///< Check grid for nan and inf 114 115 Multigrid* Father() const {return father;} 83 116 84 117 virtual vmg_float DebugKnownSolution(Vector x) const {return 0.0;} 85 118 vmg_float DebugKnownSolution(Index i) const {return DebugKnownSolution(extent.Begin() + i * extent.MeshWidth());} 86 119 120 const GridIndexTranslations& Indexing() const {return index_translations;} 121 122 const int& Level() const {return level;} 123 124 bool IsActive() const {return Local().Size().Product() > 0;} 125 87 126 private: 88 127 void InitGrid(); 89 128 129 GridIndexTranslations index_translations; 130 90 131 protected: 132 int level; 133 91 134 GlobalIndices global; 92 135 LocalIndices local; 93 136 SpatialExtent extent; 94 137 138 GridIteratorSuite iterators; 139 95 140 vmg_float *grid; 141 142 Multigrid* father; 96 143 97 144 static vmg_float correction; … … 120 167 inline int Grid::GlobalLinearIndex(int x, int y, int z) const 121 168 { 122 return z + global.Size ().Z() * (y + global.Size().Y() * x);169 return z + global.SizeGlobal().Z() * (y + global.SizeGlobal().Y() * x); 123 170 } 124 171 … … 128 175 } 129 176 130 inline Index Grid::GlobalToLocalIndex(const Index& index) const131 {132 return index - Global().Begin() + Local().Begin();133 }134 135 177 } 136 178
Note:
See TracChangeset
for help on using the changeset viewer.
