Ignore:
Timestamp:
Apr 29, 2012, 11:37:31 AM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
51e793
Parents:
1a92cf
Message:

vmg: Improved serial performance.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/samples/bspline.hpp

    r1a92cf r39a6d9  
    4040    assert(p.Pos().Z() >= grid.Extent().Begin().Z() && p.Pos().Z() < grid.Extent().End().Z());
    4141
    42     Index i, index_global, index_local;
    43     vmg_float temp_val, length;
    44     std::vector<vmg_float> vals;
    45     std::vector<vmg_float>::const_iterator iter;
     42    vmg_float vals[Helper::intpow(2*near_field_cells+1,3)];
     43    vmg_float temp_val;
     44    vmg_float int_val = 0.0;
     45    int c = 0;
    4646
    47     vmg_float int_val = 0.0;
     47    Index i;
     48    Vector dir;
    4849
    49     index_global = static_cast<Index>((p.Pos() - grid.Extent().Begin()) / grid.Extent().MeshWidth());
     50    const Index index_global = static_cast<Index>((p.Pos() - grid.Extent().Begin()) / grid.Extent().MeshWidth());
    5051    assert(index_global.X() >= grid.Global().LocalBegin().X() && index_global.X() < grid.Global().LocalEnd().X());
    5152    assert(index_global.Y() >= grid.Global().LocalBegin().Y() && index_global.Y() < grid.Global().LocalEnd().Y());
    5253    assert(index_global.Z() >= grid.Global().LocalBegin().Z() && index_global.Z() < grid.Global().LocalEnd().Z());
    5354
    54     index_local = index_global - grid.Global().LocalBegin() + grid.Local().Begin();
     55    const Index index_local = index_global - grid.Global().LocalBegin() + grid.Local().Begin();
    5556    assert(index_local.X() >= grid.Local().Begin().X() && index_local.X() < grid.Local().End().X());
    5657    assert(index_local.Y() >= grid.Local().Begin().Y() && index_local.Y() < grid.Local().End().Y());
    5758    assert(index_local.Z() >= grid.Local().Begin().Z() && index_local.Z() < grid.Local().End().Z());
    5859
     60    const Vector pos_beg = p.Pos() - grid.Extent().Begin() - grid.Extent().MeshWidth() * (index_global - near_field_cells);
     61    const Vector& h = grid.Extent().MeshWidth();
     62
    5963    // Iterate over all grid points which lie in the support of the interpolating B-Spline
    60     for (i.X()=-1*near_field_cells; i.X()<=near_field_cells; ++i.X())
    61       for (i.Y()=-1*near_field_cells; i.Y()<=near_field_cells; ++i.Y())
     64    dir[0] = pos_beg[0];
     65    for (i.X()=-1*near_field_cells; i.X()<=near_field_cells; ++i.X()) {
     66      dir[1] = pos_beg[1];
     67      for (i.Y()=-1*near_field_cells; i.Y()<=near_field_cells; ++i.Y()) {
     68        dir[2] = pos_beg[2];
    6269        for (i.Z()=-1*near_field_cells; i.Z()<=near_field_cells; ++i.Z()) {
    6370
    6471          // Compute distance from grid point to particle
    65           length = ( p.Pos() - grid.Extent().Begin() - grid.Extent().MeshWidth() * (index_global+i) ).Length();
    66 
    67           temp_val = EvaluateSpline(length);
    68           vals.push_back(temp_val * p.Charge());
     72          temp_val = EvaluateSpline(dir.Length());
     73          vals[c++] = temp_val * p.Charge();
    6974          int_val += temp_val;
    7075
     76          dir[2] -= h[2];
    7177        }
     78        dir[1] -= h[1];
     79      }
     80      dir[0] -= h[0];
     81    }
    7282
    7383    // Reciprocal value of the numerically integrated spline
    7484    int_val = 1.0 / (int_val * grid.Extent().MeshWidth().Product());
    7585
    76     iter = vals.begin();
     86    c = 0;
    7787    for (i.X()=-1*near_field_cells; i.X()<=near_field_cells; ++i.X())
    7888      for (i.Y()=-1*near_field_cells; i.Y()<=near_field_cells; ++i.Y())
    7989        for (i.Z()=-1*near_field_cells; i.Z()<=near_field_cells; ++i.Z())
    80           grid(index_local+i) += *iter++ * int_val;
     90          grid(index_local+i) += vals[c++] * int_val;
    8191
    82     assert(iter == vals.end());
    8392  }
    8493
Note: See TracChangeset for help on using the changeset viewer.