- Timestamp:
- Apr 27, 2012, 11:34:57 PM (14 years ago)
- Children:
- 1a92cf
- Parents:
- b2154a3
- Location:
- src/grid
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/grid/grid.cpp
rb2154a3 r4571da 25 25 using namespace VMG; 26 26 27 vmg_float Grid::correction;28 29 27 void Grid::InitGrid() 30 28 { … … 112 110 avg += GetVal(*iter); 113 111 114 avg /= Local().Size().Product(); 112 avg = MG::GetComm()->GlobalSum(avg); 113 avg /= Global().GlobalSize().Product(); 114 115 #ifdef DEBUG_OUTPUT 116 MG::GetComm()->PrintStringOnce("Global constraint enforcement: %e", avg); 117 #endif 115 118 116 119 for (iter = Iterators().Local().Begin(); iter != Iterators().Local().End(); ++iter) … … 126 129 val += GetVal(*iter); 127 130 128 val = MG::GetComm()->GlobalSum(val) ;129 130 if ( fabs(val) > Global().GlobalSize().Product() *std::numeric_limits<vmg_float>::epsilon()) {131 val = MG::GetComm()->GlobalSum(val) / Global().GlobalSize().Product(); 132 133 if (std::abs(val) > std::numeric_limits<vmg_float>::epsilon()) { 131 134 132 135 #ifdef DEBUG_OUTPUT … … 134 137 #endif 135 138 136 val *= Helper::pow_2(this->Extent().MeshWidth().Max());137 139 for (iter = Iterators().Local().Begin(); iter != Iterators().Local().End(); ++iter) 138 140 (*this)(*iter) -= val; … … 155 157 #endif 156 158 157 for (Grid::iterator iter = Iterators().CompleteGrid().Begin(); iter != Iterators().CompleteGrid().End(); ++iter) 158 (*this)(*iter) = rhs.GetVal(*iter); 159 std::memcpy(grid, rhs.grid, local.SizeTotal().Product()*sizeof(vmg_float)); 159 160 } 160 161 -
src/grid/grid.hpp
rb2154a3 r4571da 81 81 const GridIteratorSuite& Iterators() const {return iterators;} 82 82 83 static vmg_float& Correction() {return Grid::correction;}84 85 83 void Clear(); ///< Overwrites all grid points on current level with zeros 86 84 void ClearInner(); … … 93 91 const vmg_float& GetVal(int x, int y, int z) const; ///< Returns the value of a requested gridpoint. 94 92 const vmg_float& GetVal(const Index& index) const; 95 96 vmg_float GetCorrectedVal(int x, int y, int z) const {return this->GetVal(x, y, z) - correction;} ///< Return grid97 vmg_float GetCorrectedVal(const Index& index) const {return this->GetVal(index) - correction;}98 93 99 94 void ForceDiscreteCompatibilityCondition(); … … 142 137 143 138 Multigrid* father; 144 145 static vmg_float correction;146 139 }; 147 140 -
src/grid/grid_iterator_suite.cpp
rb2154a3 r4571da 21 21 local.SetBounds(local_.Begin(), local_.End()); 22 22 complete_grid.SetBounds(0, local_.SizeTotal()); 23 inner_local_grid.SetBounds(local_.Begin()+ 1, local_.End()-1);23 inner_local_grid.SetBounds(local_.Begin()+local_.HaloSize1(), local_.End()-local_.HaloSize2()); 24 24 25 25 halo_1.X().SetBounds(Index(local_.HaloBegin1().X(), 0, 0), … … 61 61 62 62 near_boundary_1.X().SetBounds(Index(local_.Begin().X(), 0, 0), 63 Index(local_.Begin().X()+local_.Halo End1().X()-local_.HaloBegin1().X(),63 Index(local_.Begin().X()+local_.HaloSize1().X(), 64 64 local_.SizeTotal().Y(), 65 65 local_.SizeTotal().Z())); … … 67 67 near_boundary_1.Y().SetBounds(Index(local_.Begin().X(), local_.Begin().Y(), 0), 68 68 Index(local_.End().X(), 69 local_.Begin().Y()+local_.Halo End1().Y()-local_.HaloBegin1().Y(),69 local_.Begin().Y()+local_.HaloSize1().Y(), 70 70 local_.SizeTotal().Z())); 71 71 … … 73 73 Index(local_.End().X(), 74 74 local_.End().Y(), 75 local_.Begin().Z()+local_.Halo End1().Z()-local_.HaloBegin1().Z()));75 local_.Begin().Z()+local_.HaloSize1().Z())); 76 76 77 near_boundary_2.X().SetBounds(Index(local_.End().X()-local_.Halo End2().X()+local_.HaloBegin2().X(),77 near_boundary_2.X().SetBounds(Index(local_.End().X()-local_.HaloSize2().X(), 78 78 0, 79 79 0), … … 81 81 82 82 near_boundary_2.Y().SetBounds(Index(local_.Begin().X(), 83 local_.End().Y()-local_.Halo End2().Y()+local_.HaloBegin2().Y(),83 local_.End().Y()-local_.HaloSize2().Y(), 84 84 0), 85 85 Index(local_.End().X(), local_.End().Y(), local_.SizeTotal().Z())); … … 87 87 near_boundary_2.Z().SetBounds(Index(local_.Begin().X(), 88 88 local_.Begin().Y(), 89 local_.End().Z()-local_.Halo End2().Z()+local_.HaloBegin2().Z()),89 local_.End().Z()-local_.HaloSize2().Z()), 90 90 local_.End()); 91 91 }
Note:
See TracChangeset
for help on using the changeset viewer.
