Ignore:
Timestamp:
Apr 10, 2012, 1:55:49 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
a40eea
Parents:
d24c2f
Message:

Merge recent changes of the vmg library into ScaFaCos.

Includes a fix for the communication problems on Jugene.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/base/linked_cell_list.cpp

    rd24c2f rac6d04  
    1818using namespace VMG;
    1919
    20 Particle::LinkedCellList::LinkedCellList(const std::list<Particle>& particles,
     20Particle::LinkedCellList::LinkedCellList(std::list<Particle>& particles,
    2121                                         const int& near_field_cells, const Grid& grid)
    2222{
    23   std::list<Particle>::const_iterator iter;
     23  std::list<Particle>::iterator iter;
    2424  Index index_global, index_local;
    2525  LocalIndices local = grid.Local();
    2626
    27   local.BoundaryBegin1() = local.BoundaryEnd1() = 0;
    28   local.BoundaryBegin2() = local.BoundaryEnd2() = 0;
     27  local.BoundaryBegin1() = 0;
     28  local.BoundaryEnd1() = 0;
     29  local.BoundarySize1() = 0;
     30
     31  local.BoundaryBegin2() = 0;
     32  local.BoundaryEnd2() = 0;
     33  local.BoundarySize2() = 0;
     34
     35  local.FinerBeginFoo() = 0;
     36  local.FinerEndFoo() = 0;
     37  local.FinerSizeFoo() = 0;
    2938
    3039  for (int i=0; i<3; ++i) {
    3140
    32     if (local.HasHalo1()[i]) {
     41    if (local.HaloSize1()[i] > 0) {
    3342      local.HaloBegin1()[i] = 0;
    3443      local.HaloEnd1()[i] = near_field_cells+1;
     44      local.HaloSize1()[i] = near_field_cells+1;
    3545      local.Begin()[i] = near_field_cells+1;
    3646      local.End()[i] = local.Begin()[i] + local.Size()[i];
     
    3848                             local.HaloEnd1()[i] - local.HaloBegin1()[i] +
    3949                             local.HaloEnd2()[i] - local.HaloBegin2()[i];
     50    }else {
     51      local.Begin()[i] = 0;
     52      local.End()[i] = local.Size()[i];
    4053    }
    4154
    42     if (local.HasHalo2()[i]) {
     55    if (local.HaloSize2()[i] > 0) {
    4356      local.HaloBegin2()[i] = local.End()[i];
    4457      local.HaloEnd2()[i] = local.HaloBegin2()[i] + near_field_cells+1;
     58      local.HaloSize2()[i] = near_field_cells+1;
    4559      local.SizeTotal()[i] = local.Size()[i] +
    4660                             local.HaloEnd1()[i] - local.HaloBegin1()[i] +
     
    5266
    5367  for (iter=particles.begin(); iter!=particles.end(); ++iter)
    54     AddParticle(*iter);
     68    AddParticle(&(*iter));
    5569}
    5670
    57 void Particle::LinkedCellList::AddParticle(const Particle& p)
     71Particle::LinkedCellList::~LinkedCellList()
    5872{
    59   const Index global_index = (p.Pos() - Extent().Begin()) / Extent().MeshWidth();
    60   const Index local_index = global_index - Global().BeginLocal() + Local().Begin();
    61 
    62   if (local_index.IsInBounds(Local().Begin(), Local().End()))
    63     (*this)(local_index).push_back(Particle(p.Pos(), p.Charge(), 0.0, 0.0, p.Rank(), p.Index()));
    64   else
    65     not_my_particles.push_back(Particle(p.Pos(), p.Charge(), 0.0, 0.0, p.Rank(), p.Index()));
     73  ClearHalo();
    6674}
    6775
    68 void Particle::LinkedCellList::AddParticleToComplete(const vmg_float* pos, const vmg_float& charge,
    69                                                      const vmg_float& pot, const vmg_float* force,
    70                                                      const int& rank, const int& index)
     76void Particle::LinkedCellList::AddParticle(Particle* p)
    7177{
    72   const Index global_index = (Vector(pos) - Extent().Begin()) / Extent().MeshWidth();
    73   const Index local_index = global_index - Global().BeginLocal() + Local().Begin();
     78  const Index global_index = (p->Pos() - Extent().Begin()) / Extent().MeshWidth();
     79  const Index local_index = global_index - Global().LocalBegin() + Local().Begin();
    7480
    75   if (local_index.IsInBounds(0, Local().SizeTotal()))
    76     (*this)(local_index).push_back(Particle(pos, charge, pot, force, rank, index));
    77   else
    78     not_my_particles.push_back(Particle(pos, charge, pot, force, rank, index));
     81  assert(local_index.IsInBounds(Local().Begin(), Local().End()));
     82  (*this)(local_index).push_back(p);
    7983}
    8084
    81 void Particle::LinkedCellList::AddParticleToComplete(const Vector& pos, const vmg_float& charge,
    82                                                      const vmg_float& pot, const Vector& force,
    83                                                      const int& rank, const int& index)
     85void Particle::LinkedCellList::AddParticleToHalo(const vmg_float* x, const vmg_float& q)
    8486{
    85   const Index global_index = (pos - Extent().Begin()) / Extent().MeshWidth();
    86   const Index local_index = global_index - Global().BeginLocal() + Local().Begin();
     87  const Index global_index = (Vector(x) - Extent().Begin()) / Extent().MeshWidth();
     88  const Index local_index = global_index - Global().LocalBegin() + Local().Begin();
    8789
    88   if (local_index.IsInBounds(0, Local().SizeTotal()))
    89     (*this)(local_index).push_back(Particle(pos, charge, pot, force, rank, index));
    90   else
    91     not_my_particles.push_back(Particle(pos, charge, pot, force, rank, index));
     90  assert(local_index.IsInBounds(0, Local().SizeTotal()));
     91  assert((local_index[0] >= Local().HaloBegin1()[0] && local_index[0] < Local().HaloEnd1()[0]) ||
     92         (local_index[1] >= Local().HaloBegin1()[1] && local_index[1] < Local().HaloEnd1()[1]) ||
     93         (local_index[2] >= Local().HaloBegin1()[2] && local_index[2] < Local().HaloEnd1()[2]) ||
     94         (local_index[0] >= Local().HaloBegin2()[0] && local_index[0] < Local().HaloEnd2()[0]) ||
     95         (local_index[1] >= Local().HaloBegin2()[1] && local_index[1] < Local().HaloEnd2()[1]) ||
     96         (local_index[2] >= Local().HaloBegin2()[2] && local_index[2] < Local().HaloEnd2()[2]));
     97
     98  (*this)(local_index).push_back(new Particle(x, q));
    9299}
    93100
    94 void Particle::LinkedCellList::AddParticleToComplete(const vmg_float* pos, const vmg_float& charge)
     101void Particle::LinkedCellList::ClearHalo()
    95102{
    96   const Index global_index = (Vector(pos) - Extent().Begin()) / Extent().MeshWidth();
    97   const Index local_index = global_index - Global().BeginLocal() + Local().Begin();
     103  Grid::iterator g_iter;
     104  std::list<Particle*>::iterator p_iter;
    98105
    99   if (local_index.IsInBounds(0, Local().SizeTotal()))
    100     (*this)(local_index).push_back(Particle(pos, charge));
    101   else
    102     not_my_particles.push_back(Particle(pos, charge));
     106  for (int i=0; i<3; ++i) {
     107
     108    for (g_iter = Iterators().Halo1()[i].Begin(); g_iter != Iterators().Halo1()[i].End(); ++g_iter)
     109      for (p_iter = (*this)(*g_iter).begin(); p_iter!=(*this)(*g_iter).end(); ++p_iter)
     110        delete *p_iter;
     111
     112    for (g_iter = Iterators().Halo2()[i].Begin(); g_iter != Iterators().Halo2()[i].End(); ++g_iter)
     113      for (p_iter = (*this)(*g_iter).begin(); p_iter!=(*this)(*g_iter).end(); ++p_iter)
     114        delete *p_iter;
     115
     116  }
    103117}
Note: See TracChangeset for help on using the changeset viewer.