Changeset ab63b6 for src/samples/bspline.hpp
- Timestamp:
- Dec 8, 2011, 12:53:48 PM (14 years ago)
- Children:
- 138f86
- Parents:
- facba0
- File:
-
- 1 edited
-
src/samples/bspline.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/samples/bspline.hpp
rfacba0 rab63b6 12 12 13 13 #include "base/helper.hpp" 14 #include "base/index.hpp" 15 #include "base/particle.hpp" 14 16 #include "base/polynomial.hpp" 15 17 #include "base/vector.hpp" 18 #include "grid/grid.hpp" 16 19 17 20 namespace VMG … … 29 32 return spline_nom[i](val) / spline_denom[i](val); 30 33 return 0.0; 34 } 35 36 void SetSpline(Grid& grid, const Particle::Particle p, const int& near_field_cells) 37 { 38 Index i, index_global, index_local; 39 vmg_float temp_val, length; 40 std::vector<vmg_float> vals; 41 std::vector<vmg_float>::const_iterator iter; 42 43 vmg_float int_val = 0.0; 44 45 index_global = static_cast<Index>((p.Pos() - grid.Extent().Begin()) / grid.Extent().MeshWidth()); 46 index_local = index_global - grid.Global().BeginLocal() + grid.Local().Begin(); 47 48 // Iterate over all grid points which lie in the support of the interpolating B-Spline 49 for (i.X()=-1*near_field_cells-1; i.X()<=near_field_cells+1; ++i.X()) 50 for (i.Y()=-1*near_field_cells-1; i.Y()<=near_field_cells+1; ++i.Y()) 51 for (i.Z()=-1*near_field_cells-1; i.Z()<=near_field_cells+1; ++i.Z()) { 52 53 // Compute distance from grid point to particle 54 length = ( p.Pos() - grid.Extent().Begin() - grid.Extent().MeshWidth() * (index_global+i) ).Length(); 55 56 temp_val = EvaluateSpline(length); 57 vals.push_back(temp_val * p.Charge()); 58 int_val += temp_val; 59 60 } 61 62 int_val = 1.0 / (Helper::pow(grid.MeshWidth(), 3) * int_val); 63 64 iter = vals.begin(); 65 66 for (i.X()=-1*near_field_cells-1; i.X()<=near_field_cells+1; ++i.X()) 67 for (i.Y()=-1*near_field_cells-1; i.Y()<=near_field_cells+1; ++i.Y()) 68 for (i.Z()=-1*near_field_cells-1; i.Z()<=near_field_cells+1; ++i.Z()) 69 grid(index_local+i) += *iter++ * int_val; 70 31 71 } 32 72
Note:
See TracChangeset
for help on using the changeset viewer.
