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/units/particle/bspline.hpp

    rf57182 r8180d8  
    5151    for (unsigned int i=0; i<intervals.size(); ++i)
    5252      if (val < intervals[i])
    53         return spline_nom[i](val) / spline_denom[i](val);
     53        return spline_nom[i](val) / spline_denom[i](val);
    5454    return 0.0;
    5555  }
     
    6767    int c = 0;
    6868
    69     const int index_global_x = (p.Pos().X() - grid.Extent().Begin().X()) / grid.Extent().MeshWidth().X();
    70     const int index_global_y = (p.Pos().Y() - grid.Extent().Begin().Y()) / grid.Extent().MeshWidth().Y();
    71     const int index_global_z = (p.Pos().Z() - grid.Extent().Begin().Z()) / grid.Extent().MeshWidth().Z();
     69    const int index_global_x = grid.Global().GlobalBegin().X() + (p.Pos().X() - grid.Extent().Begin().X()) / grid.Extent().MeshWidth().X();
     70    const int index_global_y = grid.Global().GlobalBegin().Y() + (p.Pos().Y() - grid.Extent().Begin().Y()) / grid.Extent().MeshWidth().Y();
     71    const int index_global_z = grid.Global().GlobalBegin().Z() + (p.Pos().Z() - grid.Extent().Begin().Z()) / grid.Extent().MeshWidth().Z();
    7272
    7373    assert(index_global_x >= grid.Global().LocalBegin().X() && index_global_x < grid.Global().LocalEnd().X());
     
    8383    assert(index_local_z >= grid.Local().Begin().Z() && index_local_z < grid.Local().End().Z());
    8484
    85     const vmg_float pos_beg_x = p.Pos().X() - grid.Extent().Begin().X() - grid.Extent().MeshWidth().X() * (index_global_x - near_field_cells);
    86     const vmg_float pos_beg_y = p.Pos().Y() - grid.Extent().Begin().Y() - grid.Extent().MeshWidth().Y() * (index_global_y - near_field_cells);
    87     const vmg_float pos_beg_z = p.Pos().Z() - grid.Extent().Begin().Z() - grid.Extent().MeshWidth().Z() * (index_global_z - near_field_cells);
     85    const vmg_float pos_beg_x = p.Pos().X() - grid.Extent().Begin().X() - grid.Extent().MeshWidth().X() * (index_global_x - grid.Global().GlobalBegin().X() - near_field_cells);
     86    const vmg_float pos_beg_y = p.Pos().Y() - grid.Extent().Begin().Y() - grid.Extent().MeshWidth().Y() * (index_global_y - grid.Global().GlobalBegin().Y() - near_field_cells);
     87    const vmg_float pos_beg_z = p.Pos().Z() - grid.Extent().Begin().Z() - grid.Extent().MeshWidth().Z() * (index_global_z - grid.Global().GlobalBegin().Z() - near_field_cells);
    8888
    8989    const vmg_float& h_x = grid.Extent().MeshWidth().X();
     
    9696      vmg_float dir_y = pos_beg_y;
    9797      for (int j=-1*near_field_cells; j<=near_field_cells; ++j) {
    98         vmg_float dir_z = pos_beg_z;
    99         for (int k=-1*near_field_cells; k<=near_field_cells; ++k) {
     98        vmg_float dir_z = pos_beg_z;
     99        for (int k=-1*near_field_cells; k<=near_field_cells; ++k) {
    100100
    101           // Compute distance from grid point to particle
    102           temp_val = EvaluateSpline(std::sqrt(dir_x*dir_x+dir_y*dir_y+dir_z*dir_z));
    103           vals[c++] = temp_val * p.Charge();
    104           int_val += temp_val;
     101          // Compute distance from grid point to particle
     102          temp_val = EvaluateSpline(std::sqrt(dir_x*dir_x+dir_y*dir_y+dir_z*dir_z));
     103          vals[c++] = temp_val * p.Charge();
     104          int_val += temp_val;
    105105
    106           dir_z -= h_z;
    107         }
    108         dir_y -= h_y;
     106          dir_z -= h_z;
     107        }
     108        dir_y -= h_y;
    109109      }
    110110      dir_x -= h_x;
     
    117117    for (int i=-1*near_field_cells; i<=near_field_cells; ++i)
    118118      for (int j=-1*near_field_cells; j<=near_field_cells; ++j)
    119         for (int k=-1*near_field_cells; k<=near_field_cells; ++k)
    120           grid(index_local_x + i,
    121                index_local_y + j,
    122                index_local_z + k) += vals[c++] * int_val;
     119        for (int k=-1*near_field_cells; k<=near_field_cells; ++k)
     120          grid(index_local_x + i,
     121              index_local_y + j,
     122              index_local_z + k) += vals[c++] * int_val;
    123123
    124124    delete [] vals;
     
    129129    for (unsigned int i=0; i<intervals.size(); ++i)
    130130      if (val < intervals[i])
    131         return potential_nom[i](val) / potential_denom[i](val);
     131        return potential_nom[i](val) / potential_denom[i](val);
    132132    return potential_nom.back()(val) / potential_denom.back()(val);
    133133  }
     
    137137    for (unsigned int i=0; i<intervals.size(); ++i)
    138138      if (val < intervals[i])
    139         return field_nom[i](val) / field_denom[i](val);
     139        return field_nom[i](val) / field_denom[i](val);
    140140    return 0.0;
    141141  }
Note: See TracChangeset for help on using the changeset viewer.