Ignore:
Timestamp:
Apr 5, 2013, 12:39:30 PM (13 years ago)
Author:
Julian Iseringhausen <julian.iseringhausen@…>
Children:
4a709e
Parents:
f57182
Message:

Merge stashed open boundary stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/level/level_operator_cs.cpp

    rf57182 r8180d8  
    3232#include "base/index.hpp"
    3333#include "comm/comm.hpp"
     34#include "grid/grid_index_translations.hpp"
    3435#include "grid/grid_iterator.hpp"
    3536#include "grid/multigrid.hpp"
     
    5354  const Stencil& op = OperatorRestrict();
    5455
    55   const Index begin_f_global = rhs_f.Global().LocalSize().Product() > 0
    56     ? rhs_f.Global().LocalBegin() + rhs_f.Global().LocalBegin() % 2
    57     : rhs_f.Global().LocalBegin();
    58   const Index end_f_global = rhs_f.Global().LocalSize().Product() > 0
    59     ? rhs_f.Global().LocalEnd() - (rhs_f.Global().LocalEnd() - 1) % 2
    60     : rhs_f.Global().LocalBegin();
    61 
    62   Index begin_f = begin_f_global - rhs_f.Global().LocalBegin() + rhs_f.Local().Begin();
    63   Index end_f = end_f_global - rhs_f.Global().LocalBegin() + rhs_f.Local().Begin();
    64 
    65   /* Modify fine begin/end to align the points on both levels correctly */
    66   if (rhs_c_undist.Global().BoundaryType() == GlobalCoarsened) {
    67     begin_f += rhs_f.Local().BoundarySize1();
    68     end_f -= rhs_f.Local().BoundarySize2();
    69   }
    70 
    71   const Index begin_c = rhs_c_undist.Local().Begin() + begin_f_global / 2 - rhs_c_undist.Global().LocalBegin();
    72   const Index end_c = rhs_c_undist.Local().Begin() + end_f_global / 2 - rhs_c_undist.Global().LocalBegin() + 1;
    73 
    74   const GridIteratorSet bounds_f(begin_f, end_f);
    75   const GridIteratorSet bounds_c(begin_c, end_c);
     56  GridIteratorSet bounds_c, bounds_f;
     57  GridIndexTranslations::GetGridAlignment(rhs_c_undist, bounds_c, rhs_f, bounds_f);
    7658
    7759  assert(bounds_c.Begin().GetEnd()-bounds_c.Begin().GetBegin() == ((bounds_f.Begin().GetEnd()-bounds_f.Begin().GetBegin())-1)/2+1);
     
    10688  Grid& sol_f_dist = sol(sol.Level()+1);
    10789  Grid& sol_f_undist = comm.GetFinerGrid(sol);
    108   Grid& rhs_f_undist = comm.GetFinerGrid(rhs);
    10990
    11091  const Stencil& op = OperatorProlongate();
    11192
    112   Index begin_f = sol_f_undist.Local().Begin() + 2*sol_c.Global().LocalBegin() - sol_f_undist.Global().LocalBegin();
    113   Index end_f = sol_f_undist.Local().End();
    114 
    115   if (sol_c.Global().BoundaryType() == GlobalCoarsened) {
    116     begin_f += rhs_f_undist.Local().BoundarySize1();
    117     end_f -= rhs_f_undist.Local().BoundarySize2();
    118   }
    119 
    120   const GridIteratorSet bounds_f(begin_f, end_f);
    121   const GridIteratorSet bounds_c(sol_c.Local().FinerBegin(), sol_c.Local().FinerEnd());
     93  GridIteratorSet bounds_c, bounds_f;
     94  GridIndexTranslations::GetGridAlignment(sol_c, bounds_c, sol_f_undist, bounds_f);
    12295
    12396  assert(bounds_c.Begin().GetEnd()-bounds_c.Begin().GetBegin() == ((bounds_f.Begin().GetEnd()-bounds_f.Begin().GetBegin())-1)/2+1);
     
    132105    for (stencil_iter = op.begin(); stencil_iter != op.end(); ++stencil_iter)
    133106      sol_f_undist(iter_f->X() + stencil_iter->Disp().X(),
    134                    iter_f->Y() + stencil_iter->Disp().Y(),
    135                    iter_f->Z() + stencil_iter->Disp().Z()) += stencil_iter->Val() * val;
     107                   iter_f->Y() + stencil_iter->Disp().Y(),
     108                   iter_f->Z() + stencil_iter->Disp().Z()) += stencil_iter->Val() * val;
    136109  }
    137110
Note: See TracChangeset for help on using the changeset viewer.