Changeset b2154a3 for src


Ignore:
Timestamp:
Apr 25, 2012, 7:31:43 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
4571da
Parents:
3bd250
Message:

vmg: Improved performance of potential interpolation.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/interface/interface_particles.cpp

    r3bd250 rb2154a3  
    151151
    152152  /*
    153    * Do potential back-interpolation
    154    */
    155   std::list<Particle::Particle>::iterator p_iter;
    156   for (p_iter=particles.begin(); p_iter!=particles.end(); ++p_iter) {
    157 
    158     const Index global_index = (p_iter->Pos() - particle_grid.Extent().Begin()) / particle_grid.Extent().MeshWidth();
    159     const Index local_index = global_index - particle_grid.Global().LocalBegin() + particle_grid.Local().Begin();
    160 
    161     ip.ComputeCoefficients(particle_grid, local_index);
    162 
    163     // Interpolate long range part of potential minus self-interaction
    164     p_iter->Pot() = ip.Evaluate(p_iter->Pos()) - p_iter->Charge() * spl.GetAntiDerivativeAtZero();
    165     p_iter->Field() = ip.EvaluateGradient(p_iter->Pos());
    166 
    167 #ifdef DEBUG_OUTPUT
    168     // TODO The scaling with 1/2 may not be correct. Check that.
    169     e_long += 0.5 * p_iter->Charge() * Helper::InterpolateTrilinear(p_iter->Pos(), particle_grid);
    170     e_self += 0.5 * p_iter->Charge() * p_iter->Charge() * spl.GetAntiDerivativeAtZero();
    171 #endif
    172 
    173   }
    174 
    175   /*
    176    * Compute near field correction
     153   * Compute potentials
    177154   */
    178155  Particle::LinkedCellList lc(particles, near_field_cells, grid);
     
    183160
    184161  for (iter=lc.Iterators().Local().Begin(); iter!=lc.Iterators().Local().End(); ++iter) {
     162
     163    ip.ComputeCoefficients(particle_grid, *iter - lc.Local().Begin() + particle_grid.Local().Begin());
     164
    185165    std::list<Particle::Particle*>& lc_1 = lc(*iter);
    186     for (p1=lc_1.begin(); p1!=lc_1.end(); ++p1)
     166
     167    for (p1=lc_1.begin(); p1!=lc_1.end(); ++p1) {
     168
     169      (*p1)->Pot() = ip.Evaluate((*p1)->Pos()) - (*p1)->Charge() * spl.GetAntiDerivativeAtZero();
     170
     171#ifdef DEBUG_OUTPUT
     172    // TODO The scaling with 1/2 may not be correct. Check that.
     173      e_long += 0.5 * (*p1)->Charge() * Helper::InterpolateTrilinear((*p1)->Pos(), particle_grid);
     174      e_self += 0.5 * (*p1)->Charge() * (*p1)->Charge() * spl.GetAntiDerivativeAtZero();
     175#endif
     176
    187177      for (index.X()=-1*near_field_cells-1; index.X()<=near_field_cells+1; ++index.X())
    188178        for (index.Y()=-1*near_field_cells-1; index.Y()<=near_field_cells+1; ++index.Y())
     
    207197              }
    208198          }
     199    }
    209200  }
    210201
Note: See TracChangeset for help on using the changeset viewer.