Changeset 4571da for src/grid


Ignore:
Timestamp:
Apr 27, 2012, 11:34:57 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
1a92cf
Parents:
b2154a3
Message:

vmg: Implement fourth-order discretization of the Poisson equation.

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

Location:
src/grid
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/grid/grid.cpp

    rb2154a3 r4571da  
    2525using namespace VMG;
    2626
    27 vmg_float Grid::correction;
    28 
    2927void Grid::InitGrid()
    3028{
     
    112110    avg += GetVal(*iter);
    113111
    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
    115118
    116119  for (iter = Iterators().Local().Begin(); iter != Iterators().Local().End(); ++iter)
     
    126129    val += GetVal(*iter);
    127130
    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()) {
    131134
    132135#ifdef DEBUG_OUTPUT
     
    134137#endif
    135138
    136     val *= Helper::pow_2(this->Extent().MeshWidth().Max());
    137139    for (iter = Iterators().Local().Begin(); iter != Iterators().Local().End(); ++iter)
    138140      (*this)(*iter) -= val;
     
    155157#endif
    156158
    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));
    159160}
    160161
  • src/grid/grid.hpp

    rb2154a3 r4571da  
    8181  const GridIteratorSuite& Iterators() const {return iterators;}
    8282
    83   static vmg_float& Correction() {return Grid::correction;}
    84 
    8583  void Clear();         ///< Overwrites all grid points on current level with zeros
    8684  void ClearInner();
     
    9391  const vmg_float& GetVal(int x, int y, int z) const; ///< Returns the value of a requested gridpoint.
    9492  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 grid
    97   vmg_float GetCorrectedVal(const Index& index) const {return this->GetVal(index) - correction;}
    9893
    9994  void ForceDiscreteCompatibilityCondition();
     
    142137
    143138  Multigrid* father;
    144 
    145   static vmg_float correction;
    146139};
    147140
  • src/grid/grid_iterator_suite.cpp

    rb2154a3 r4571da  
    2121  local.SetBounds(local_.Begin(), local_.End());
    2222  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());
    2424
    2525  halo_1.X().SetBounds(Index(local_.HaloBegin1().X(), 0, 0),
     
    6161
    6262  near_boundary_1.X().SetBounds(Index(local_.Begin().X(), 0, 0),
    63                                 Index(local_.Begin().X()+local_.HaloEnd1().X()-local_.HaloBegin1().X(),
     63                                Index(local_.Begin().X()+local_.HaloSize1().X(),
    6464                                      local_.SizeTotal().Y(),
    6565                                      local_.SizeTotal().Z()));
     
    6767  near_boundary_1.Y().SetBounds(Index(local_.Begin().X(), local_.Begin().Y(), 0),
    6868                                Index(local_.End().X(),
    69                                       local_.Begin().Y()+local_.HaloEnd1().Y()-local_.HaloBegin1().Y(),
     69                                      local_.Begin().Y()+local_.HaloSize1().Y(),
    7070                                      local_.SizeTotal().Z()));
    7171
     
    7373                                Index(local_.End().X(),
    7474                                      local_.End().Y(),
    75                                       local_.Begin().Z()+local_.HaloEnd1().Z()-local_.HaloBegin1().Z()));
     75                                      local_.Begin().Z()+local_.HaloSize1().Z()));
    7676
    77   near_boundary_2.X().SetBounds(Index(local_.End().X()-local_.HaloEnd2().X()+local_.HaloBegin2().X(),
     77  near_boundary_2.X().SetBounds(Index(local_.End().X()-local_.HaloSize2().X(),
    7878                                      0,
    7979                                      0),
     
    8181
    8282  near_boundary_2.Y().SetBounds(Index(local_.Begin().X(),
    83                                       local_.End().Y()-local_.HaloEnd2().Y()+local_.HaloBegin2().Y(),
     83                                      local_.End().Y()-local_.HaloSize2().Y(),
    8484                                      0),
    8585                                Index(local_.End().X(), local_.End().Y(), local_.SizeTotal().Z()));
     
    8787  near_boundary_2.Z().SetBounds(Index(local_.Begin().X(),
    8888                                      local_.Begin().Y(),
    89                                       local_.End().Z()-local_.HaloEnd2().Z()+local_.HaloBegin2().Z()),
     89                                      local_.End().Z()-local_.HaloSize2().Z()),
    9090                                local_.End());
    9191}
Note: See TracChangeset for help on using the changeset viewer.