Changeset 8180d8 for src/comm/mpi


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.

Location:
src/comm/mpi
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/comm/mpi/datatype.cpp

    rf57182 r8180d8  
    7272    for (i.X()=_starts.X(); i.X()<end.X();  ++i.X())
    7373      for (i.Y()=_starts.Y(); i.Y()<end.Y(); ++i.Y()) {
    74         std::memcpy(&_buffer[c], &grid.GetVal(i.X(), i.Y(), _starts.Z()), memcpy_size);
    75         c += _subsizes.Z();
     74        std::memcpy(&_buffer[c], &grid.GetVal(i.X(), i.Y(), _starts.Z()), memcpy_size);
     75        c += _subsizes.Z();
    7676      }
    7777
     
    9191    for (i.X()=_starts.X(); i.X()<end.X();  ++i.X())
    9292      for (i.Y()=_starts.Y(); i.Y()<end.Y(); ++i.Y()) {
    93         std::memcpy(&_buffer[c], &grid.GetVal(i.X(), i.Y(), _starts.Z()), memcpy_size);
    94         c += _subsizes.Z();
     93        std::memcpy(&_buffer[c], &grid.GetVal(i.X(), i.Y(), _starts.Z()), memcpy_size);
     94        c += _subsizes.Z();
    9595      }
    9696
     
    124124    for (i.X()=_starts.X(); i.X()<end.X(); ++i.X())
    125125      for (i.Y()=_starts.Y(); i.Y()<end.Y(); ++i.Y()) {
    126         std::memcpy(&grid(i.X(), i.Y(), _starts.Z()), &_buffer[c], memcpy_size);
    127         c += _subsizes.Z();
     126        std::memcpy(&grid(i.X(), i.Y(), _starts.Z()), &_buffer[c], memcpy_size);
     127        c += _subsizes.Z();
    128128      }
    129129
     
    142142    for (i.X()=_starts.X(); i.X()<end.X(); ++i.X())
    143143      for (i.Y()=_starts.Y(); i.Y()<end.Y(); ++i.Y())
    144         for (i.Z()=_starts.Z(); i.Z()<end.Z(); ++i.Z())
    145           grid(i) += *iter++;
     144        for (i.Z()=_starts.Z(); i.Z()<end.Z(); ++i.Z())
     145          grid(i) += *iter++;
    146146
    147147    assert(iter == _buffer.end());
     
    150150
    151151void VMG::MPI::Datatype::Set(const GridIteratorSet& bounds, const Grid& grid, const int& rank,
    152                              const int& tag_send, const int& tag_receive)
     152    const int& tag_send, const int& tag_receive)
    153153{
    154154  _sizes = grid.Local().SizeTotal();
     
    166166
    167167void VMG::MPI::Datatype::Set(const Index& sizes, const Index& subsizes, const Index& starts, const int& rank,
    168                              const int& tag_send, const int& tag_receive)
     168    const int& tag_send, const int& tag_receive)
    169169{
    170170  _sizes = sizes;
  • src/comm/mpi/datatypes_local.hpp

    rf57182 r8180d8  
    3737  DatatypesLocal(const T& grid, const MPI_Comm& comm, const bool& alloc)
    3838  {
    39     InitDatatypesLocal(grid, comm, alloc);
     39  InitDatatypesLocal(grid, comm, alloc);
    4040  }
    4141
     
    6969{
    7070  return (periods[0] || (coord[0] >= 0 && coord[0] < dims[0])) &&
    71          (periods[1] || (coord[1] >= 0 && coord[1] < dims[1])) &&
    72          (periods[2] || (coord[2] >= 0 && coord[2] < dims[2]));
     71      (periods[1] || (coord[1] >= 0 && coord[1] < dims[1])) &&
     72      (periods[2] || (coord[2] >= 0 && coord[2] < dims[2]));
    7373}
    7474
     
    9090    for (i.X()=-1; i.X()<=1; ++i.X())
    9191      for (i.Y()=-1; i.Y()<=1; ++i.Y())
    92         for (i.Z()=-1; i.Z()<=1; ++i.Z())
    93           if (_is_valid(coords + i, dims, periods))
    94             MPI_Cart_rank(comm, (coords + i).vec(), &ranks[to_1d(i+1)]);
     92        for (i.Z()=-1; i.Z()<=1; ++i.Z())
     93          if (_is_valid(coords + i, dims, periods))
     94            MPI_Cart_rank(comm, (coords + i).vec(), &ranks[to_1d(i+1)]);
    9595
    9696    sizes = l.SizeTotal();
     
    266266    /* 0 -1 -1 */
    267267    offset = Index(0,-1,-1);
    268      if (_is_valid(coords + offset, dims, periods)) {
    269        index = to_1d(offset+1);
    270        subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize1().Z());
    271        starts = Index(l.Begin().X(), 0, 0);
    272        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer));
    273        starts = l.Begin();
    274        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer));
    275        _offset.push_back(offset);
    276      }
     268    if (_is_valid(coords + offset, dims, periods)) {
     269      index = to_1d(offset+1);
     270      subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize1().Z());
     271      starts = Index(l.Begin().X(), 0, 0);
     272      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer));
     273      starts = l.Begin();
     274      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 14, 15, alloc_buffer));
     275      _offset.push_back(offset);
     276    }
    277277
    278278    /* 0 -1 1 */
    279      offset = Index(0,-1,1);
    280      if (_is_valid(coords + offset, dims, periods)) {
    281        index = to_1d(offset+1);
    282        subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize2().Z());
    283        starts = Index(l.Begin().X(), 0, l.End().Z());
    284        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer));
    285        starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());
    286        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer));
    287        _offset.push_back(offset);
    288      }
     279    offset = Index(0,-1,1);
     280    if (_is_valid(coords + offset, dims, periods)) {
     281      index = to_1d(offset+1);
     282      subsizes = Index(l.Size().X(), l.HaloSize1().Y(), l.HaloSize2().Z());
     283      starts = Index(l.Begin().X(), 0, l.End().Z());
     284      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer));
     285      starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());
     286      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 16, 17, alloc_buffer));
     287      _offset.push_back(offset);
     288    }
    289289
    290290    /* 0 1 -1 */
    291      offset = Index(0,1,-1);
    292      if (_is_valid(coords + offset, dims, periods)) {
    293        index = to_1d(offset+1);
    294        subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize1().Z());
    295        starts = Index(l.Begin().X(), l.End().Y(), 0);
    296        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer));
    297        starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());
    298        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer));
    299        _offset.push_back(offset);
    300      }
     291    offset = Index(0,1,-1);
     292    if (_is_valid(coords + offset, dims, periods)) {
     293      index = to_1d(offset+1);
     294      subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize1().Z());
     295      starts = Index(l.Begin().X(), l.End().Y(), 0);
     296      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer));
     297      starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());
     298      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 17, 16, alloc_buffer));
     299      _offset.push_back(offset);
     300    }
    301301
    302302    /* 0 1 1 */
    303      offset = Index(0,1,1);
    304      if (_is_valid(coords + offset, dims, periods)) {
    305        index = to_1d(offset+1);
    306        subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize2().Z());
    307        starts = Index(l.Begin().X(), l.End().Y(), l.End().Z());
    308        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer));
    309        starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z());
    310        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer));
    311        _offset.push_back(offset);
    312      }
     303    offset = Index(0,1,1);
     304    if (_is_valid(coords + offset, dims, periods)) {
     305      index = to_1d(offset+1);
     306      subsizes = Index(l.Size().X(), l.HaloSize2().Y(), l.HaloSize2().Z());
     307      starts = Index(l.Begin().X(), l.End().Y(), l.End().Z());
     308      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer));
     309      starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z());
     310      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 15, 14, alloc_buffer));
     311      _offset.push_back(offset);
     312    }
    313313
    314314    /* -1 -1 -1 */
    315      offset = Index(-1,-1,-1);
    316      if (_is_valid(coords + offset, dims, periods)) {
    317        index = to_1d(offset+1);
    318        subsizes = l.HaloSize1();
    319        starts = 0;
    320        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer));
    321        starts = l.Begin();
    322        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer));
    323        _offset.push_back(offset);
    324      }
     315    offset = Index(-1,-1,-1);
     316    if (_is_valid(coords + offset, dims, periods)) {
     317      index = to_1d(offset+1);
     318      subsizes = l.HaloSize1();
     319      starts = 0;
     320      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer));
     321      starts = l.Begin();
     322      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 18, 19, alloc_buffer));
     323      _offset.push_back(offset);
     324    }
    325325
    326326    /* -1 -1 1 */
    327      offset = Index(-1,-1,1);
    328      if (_is_valid(coords + offset, dims, periods)) {
    329        index = to_1d(offset+1);
    330        subsizes = Index(l.HaloSize1().X(), l.HaloSize1().Y(), l.HaloSize2().Z());
    331        starts = Index(0, 0, l.End().Z());;
    332        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer));
    333        starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());
    334        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer));
    335        _offset.push_back(offset);
    336      }
     327    offset = Index(-1,-1,1);
     328    if (_is_valid(coords + offset, dims, periods)) {
     329      index = to_1d(offset+1);
     330      subsizes = Index(l.HaloSize1().X(), l.HaloSize1().Y(), l.HaloSize2().Z());
     331      starts = Index(0, 0, l.End().Z());;
     332      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer));
     333      starts = Index(l.Begin().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());
     334      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 20, 21, alloc_buffer));
     335      _offset.push_back(offset);
     336    }
    337337
    338338    /* -1 1 -1 */
    339      offset = Index(-1,1,-1);
    340      if (_is_valid(coords + offset, dims, periods)) {
    341        index = to_1d(offset+1);
    342        subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize1().Z());
    343        starts = Index(0, l.End().Y(), 0);
    344        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer));
    345        starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());
    346        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer));
    347        _offset.push_back(offset);
    348      }
     339    offset = Index(-1,1,-1);
     340    if (_is_valid(coords + offset, dims, periods)) {
     341      index = to_1d(offset+1);
     342      subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize1().Z());
     343      starts = Index(0, l.End().Y(), 0);
     344      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer));
     345      starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());
     346      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 22, 23, alloc_buffer));
     347      _offset.push_back(offset);
     348    }
    349349
    350350    /* 1 -1 -1 */
    351      offset = Index(1,-1,-1);
    352      if (_is_valid(coords + offset, dims, periods)) {
    353        index = to_1d(offset+1);
    354        subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize1().Z());
    355        starts = Index(l.End().X(), 0, 0);
    356        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer));
    357        starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.Begin().Z());
    358        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer));
    359        _offset.push_back(offset);
    360      }
     351    offset = Index(1,-1,-1);
     352    if (_is_valid(coords + offset, dims, periods)) {
     353      index = to_1d(offset+1);
     354      subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize1().Z());
     355      starts = Index(l.End().X(), 0, 0);
     356      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer));
     357      starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.Begin().Z());
     358      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 24, 25, alloc_buffer));
     359      _offset.push_back(offset);
     360    }
    361361
    362362    /* -1 1 1 */
    363      offset = Index(-1,1,1);
    364      if (_is_valid(coords + offset, dims, periods)) {
    365        index = to_1d(offset+1);
    366        subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize2().Z());
    367        starts = Index(0, l.End().Y(), l.End().Z());
    368        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer));
    369        starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z());
    370        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer));
    371        _offset.push_back(offset);
    372      }
     363    offset = Index(-1,1,1);
     364    if (_is_valid(coords + offset, dims, periods)) {
     365      index = to_1d(offset+1);
     366      subsizes = Index(l.HaloSize1().X(), l.HaloSize2().Y(), l.HaloSize2().Z());
     367      starts = Index(0, l.End().Y(), l.End().Z());
     368      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer));
     369      starts = Index(l.Begin().X(), l.End().Y()-l.HaloSize2().Y(), l.End().Z()-l.HaloSize2().Z());
     370      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 25, 24, alloc_buffer));
     371      _offset.push_back(offset);
     372    }
    373373
    374374    /* 1 -1 1 */
    375      offset = Index(1,-1,1);
    376      if (_is_valid(coords + offset, dims, periods)) {
    377        index = to_1d(offset+1);
    378        subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize2().Z());
    379        starts = Index(l.End().X(), 0, l.End().Z());
    380        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer));
    381        starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());
    382        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer));
    383        _offset.push_back(offset);
    384      }
     375    offset = Index(1,-1,1);
     376    if (_is_valid(coords + offset, dims, periods)) {
     377      index = to_1d(offset+1);
     378      subsizes = Index(l.HaloSize2().X(), l.HaloSize1().Y(), l.HaloSize2().Z());
     379      starts = Index(l.End().X(), 0, l.End().Z());
     380      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer));
     381      starts = Index(l.End().X()-l.HaloSize2().X(), l.Begin().Y(), l.End().Z()-l.HaloSize2().Z());
     382      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 23, 22, alloc_buffer));
     383      _offset.push_back(offset);
     384    }
    385385
    386386    /* 1 1 -1 */
    387      offset = Index(1,1,-1);
    388      if (_is_valid(coords + offset, dims, periods)) {
    389        index = to_1d(offset+1);
    390        subsizes = Index(l.HaloSize2().X(), l.HaloSize2().Y(), l.HaloSize1().Z());
    391        starts = Index(l.End().X(), l.End().Y(), 0);
    392        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer));
    393        starts = Index(l.End().X()-l.HaloSize2().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());
    394        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer));
    395        _offset.push_back(offset);
    396      }
     387    offset = Index(1,1,-1);
     388    if (_is_valid(coords + offset, dims, periods)) {
     389      index = to_1d(offset+1);
     390      subsizes = Index(l.HaloSize2().X(), l.HaloSize2().Y(), l.HaloSize1().Z());
     391      starts = Index(l.End().X(), l.End().Y(), 0);
     392      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer));
     393      starts = Index(l.End().X()-l.HaloSize2().X(), l.End().Y()-l.HaloSize2().Y(), l.Begin().Z());
     394      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 21, 20, alloc_buffer));
     395      _offset.push_back(offset);
     396    }
    397397
    398398    /* 1 1 1 */
    399      offset = Index(1,1,1);
    400      if (_is_valid(coords + offset, dims, periods)) {
    401        index = to_1d(offset+1);
    402        subsizes = l.HaloSize2();
    403        starts = l.End();
    404        _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer));
    405        starts = l.End()-l.HaloSize2();
    406        _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer));
    407        _offset.push_back(offset);
    408      }
     399    offset = Index(1,1,1);
     400    if (_is_valid(coords + offset, dims, periods)) {
     401      index = to_1d(offset+1);
     402      subsizes = l.HaloSize2();
     403      starts = l.End();
     404      _halo.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer));
     405      starts = l.End()-l.HaloSize2();
     406      _nb.push_back(VMG::MPI::Datatype(sizes, subsizes, starts, ranks[index], 19, 18, alloc_buffer));
     407      _offset.push_back(offset);
     408    }
    409409
    410410  }
  • src/comm/mpi/key.hpp

    rf57182 r8180d8  
    5454    end(grid.Global().LocalEnd()),
    5555    size_local(grid.Local().SizeTotal()),
    56     size_global(grid.Global().GlobalSize()),
     56    size_global(grid.Global().GlobalSizeFinest()),
    5757    level(grid.Level())
    5858  {}
  • src/comm/mpi/settings.cpp

    rf57182 r8180d8  
    9696
    9797    if (temp_grid->Global().LocalBegin().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) &&
    98         temp_grid->Global().LocalBegin().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd()) &&
    99         temp_grid->Global().LocalEnd().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) &&
    100         temp_grid->Global().LocalEnd().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd())) {
     98        temp_grid->Global().LocalBegin().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd()) &&
     99        temp_grid->Global().LocalEnd().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) &&
     100        temp_grid->Global().LocalEnd().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd())) {
    101101      delete temp_grid;
    102102      coarser_grids.insert(std::make_pair(&sol(i), &sol(i-1)));
     
    113113
    114114    if (temp_grid->Global().LocalBegin().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) &&
    115         temp_grid->Global().LocalBegin().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd()) &&
    116         temp_grid->Global().LocalEnd().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) &&
    117         temp_grid->Global().LocalEnd().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd())) {
     115        temp_grid->Global().LocalBegin().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd()) &&
     116        temp_grid->Global().LocalEnd().IsComponentwiseGreaterOrEqual(sol(i-1).Global().LocalBegin()) &&
     117        temp_grid->Global().LocalEnd().IsComponentwiseLessOrEqual(sol(i-1).Global().LocalEnd())) {
    118118      delete temp_grid;
    119119      coarser_grids.insert(std::make_pair(&rhs(i), &rhs(i-1)));
     
    133133
    134134    if (temp_grid->Global().LocalBegin() == sol(i+1).Global().LocalBegin() &&
    135         temp_grid->Global().LocalEnd() == sol(i+1).Global().LocalEnd()) {
     135        temp_grid->Global().LocalEnd() == sol(i+1).Global().LocalEnd()) {
    136136      delete temp_grid;
    137137      finer_grids.insert(std::make_pair(&sol(i), &sol(i+1)));
     
    148148
    149149    if (temp_grid->Global().LocalBegin() == rhs(i+1).Global().LocalBegin() &&
    150         temp_grid->Global().LocalEnd() == rhs(i+1).Global().LocalEnd()) {
     150        temp_grid->Global().LocalEnd() == rhs(i+1).Global().LocalEnd()) {
    151151      delete temp_grid;
    152152      finer_grids.insert(std::make_pair(&rhs(i), &rhs(i+1)));
     
    220220
    221221  const bool in_communicator = (grid_1->Global().LocalSize().Product() > 0) ||
    222                                (grid_2 && grid_2->Global().LocalSize().Product() > 0) ||
    223                                (grid_3 && grid_3->Global().LocalSize().Product() > 0);
     222      (grid_2 && grid_2->Global().LocalSize().Product() > 0) ||
     223      (grid_3 && grid_3->Global().LocalSize().Product() > 0);
    224224
    225225  MPI_Comm_rank(comm_global, &rank);
     
    263263    for (iter=communicators_local_unique.begin(); iter!=communicators_local_unique.end(); ++iter) {
    264264      if (*iter != MPI_COMM_NULL) {
    265         MPI_Comm_compare(comm_new, *iter, &comm_equal);
    266         assert(comm_equal != MPI_SIMILAR);
    267         if (comm_equal == MPI_IDENT || comm_equal == MPI_CONGRUENT) {
    268           MPI_Comm_free(&comm_new);
    269           comm_new = *iter;
    270           break;
    271         }
     265        MPI_Comm_compare(comm_new, *iter, &comm_equal);
     266        assert(comm_equal != MPI_SIMILAR);
     267        if (comm_equal == MPI_IDENT || comm_equal == MPI_CONGRUENT) {
     268          MPI_Comm_free(&comm_new);
     269          comm_new = *iter;
     270          break;
     271        }
    272272      }
    273273    }
     
    283283  bool dt_is_new = true;
    284284
    285     // Insert into map
     285  // Insert into map
    286286  std::pair< std::map<VMG::MPI::KeyUnsorted, VMG::MPI::DatatypesGlobal>::iterator, bool > insert_result =
    287     datatypes_global.insert(std::make_pair(VMG::MPI::KeyUnsorted(grid_old, grid_new, direction), VMG::MPI::DatatypesGlobal()));
     287      datatypes_global.insert(std::make_pair(VMG::MPI::KeyUnsorted(grid_old, grid_new, direction), VMG::MPI::DatatypesGlobal()));
    288288  VMG::MPI::DatatypesGlobal& dt_global = insert_result.first->second;
    289289  dt_is_new = insert_result.second;
     
    310310    if (&grid_old == &grid_new) {
    311311      for (int i=0; i<6; ++i)
    312         buffer[6*rank+i] = 0;
     312        buffer[6*rank+i] = 0;
    313313    }else {
    314314      for (int i=0; i<3; ++i) {
    315         buffer[6*rank+i] = grid_old.Global().LocalBegin()[i];
    316         buffer[6*rank+i+3] = grid_old.Global().LocalEnd()[i];
     315        buffer[6*rank+i] = grid_old.Global().LocalBegin()[i];
     316        buffer[6*rank+i+3] = grid_old.Global().LocalEnd()[i];
    317317      }
    318318    }
     
    324324      // Decide who offers a useful grid part
    325325      for (int i=0; i<size; ++i) {
    326         for (int j=0; j<3; ++j) {
    327           begin[j] = buffer[6*i+j];
    328           end[j] = buffer[6*i+j+3];
    329         }
    330 
    331         begin = begin.Clamp(grid_new.Global().LocalBegin(), grid_new.Global().LocalEnd());
    332         end = end.Clamp(grid_new.Global().LocalBegin(), grid_new.Global().LocalEnd());
    333 
    334         if ((end-begin).Product() > 0) {
    335           // This process has a useful part
    336           dt_global.Receive().push_back(VMG::MPI::Datatype(grid_new.Local().SizeTotal(),
    337                                                            end - begin,
    338                                                            begin - grid_new.Global().LocalBegin() + offset_new,
    339                                                            i, 0, 0, true));
    340         }
     326        for (int j=0; j<3; ++j) {
     327          begin[j] = buffer[6*i+j];
     328          end[j] = buffer[6*i+j+3];
     329        }
     330
     331        begin = begin.Clamp(grid_new.Global().LocalBegin(), grid_new.Global().LocalEnd());
     332        end = end.Clamp(grid_new.Global().LocalBegin(), grid_new.Global().LocalEnd());
     333
     334        if ((end-begin).Product() > 0) {
     335          // This process has a useful part
     336          dt_global.Receive().push_back(VMG::MPI::Datatype(grid_new.Local().SizeTotal(),
     337              end - begin,
     338              begin - grid_new.Global().LocalBegin() + grid_new.Global().GlobalBegin() + offset_new,
     339              i, 0, 0, true));
     340        }
    341341      }
    342342    }
     
    355355      for (int i=0; i<size; ++i) {
    356356
    357         if ((i == rank) && (&grid_old == &grid_new))
    358           continue;
    359 
    360         for (int j=0; j<3; ++j) {
    361           begin[j] = buffer[6*i+j];
    362           end[j] = buffer[6*i+j+3];
    363         }
    364 
    365         begin = begin.Clamp(grid_old.Global().LocalBegin(), grid_old.Global().LocalEnd());
    366         end = end.Clamp(grid_old.Global().LocalBegin(), grid_old.Global().LocalEnd());
    367 
    368         if ((end-begin).Product() > 0) {
    369           // This process needs one of my parts
    370           dt_global.Send().push_back(VMG::MPI::Datatype(grid_old.Local().SizeTotal(),
    371                                                         end - begin,
    372                                                         begin - grid_old.Global().LocalBegin() + offset_old,
    373                                                         i, 0, 0, true));
    374         }
     357        if ((i == rank) && (&grid_old == &grid_new))
     358          continue;
     359
     360        for (int j=0; j<3; ++j) {
     361          begin[j] = buffer[6*i+j];
     362          end[j] = buffer[6*i+j+3];
     363        }
     364
     365        begin = begin.Clamp(grid_old.Global().LocalBegin(), grid_old.Global().LocalEnd());
     366        end = end.Clamp(grid_old.Global().LocalBegin(), grid_old.Global().LocalEnd());
     367
     368        if ((end-begin).Product() > 0) {
     369          // This process needs one of my parts
     370          dt_global.Send().push_back(VMG::MPI::Datatype(grid_old.Local().SizeTotal(),
     371              end - begin,
     372              begin - grid_old.Global().LocalBegin() + grid_old.Global().GlobalBegin() + offset_old,
     373              i, 0, 0, true));
     374        }
    375375      }
    376376    }
     
    379379
    380380MPI_Datatype& VMG::MPI::Settings::Datatype(const Index& begin, const Index& end,
    381                                            const Index& size_local, const Index& size_global,
    382                                            const int& level)
     381    const Index& size_local, const Index& size_global,
     382    const int& level)
    383383{
    384384  KeyUnsorted k(begin, end, size_local, size_global, level, 0);
Note: See TracChangeset for help on using the changeset viewer.