Changeset 39a6d9 for src/samples/bspline.hpp
- Timestamp:
- Apr 29, 2012, 11:37:31 AM (14 years ago)
- Children:
- 51e793
- Parents:
- 1a92cf
- File:
-
- 1 edited
-
src/samples/bspline.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/samples/bspline.hpp
r1a92cf r39a6d9 40 40 assert(p.Pos().Z() >= grid.Extent().Begin().Z() && p.Pos().Z() < grid.Extent().End().Z()); 41 41 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; 46 46 47 vmg_float int_val = 0.0; 47 Index i; 48 Vector dir; 48 49 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()); 50 51 assert(index_global.X() >= grid.Global().LocalBegin().X() && index_global.X() < grid.Global().LocalEnd().X()); 51 52 assert(index_global.Y() >= grid.Global().LocalBegin().Y() && index_global.Y() < grid.Global().LocalEnd().Y()); 52 53 assert(index_global.Z() >= grid.Global().LocalBegin().Z() && index_global.Z() < grid.Global().LocalEnd().Z()); 53 54 54 index_local = index_global - grid.Global().LocalBegin() + grid.Local().Begin();55 const Index index_local = index_global - grid.Global().LocalBegin() + grid.Local().Begin(); 55 56 assert(index_local.X() >= grid.Local().Begin().X() && index_local.X() < grid.Local().End().X()); 56 57 assert(index_local.Y() >= grid.Local().Begin().Y() && index_local.Y() < grid.Local().End().Y()); 57 58 assert(index_local.Z() >= grid.Local().Begin().Z() && index_local.Z() < grid.Local().End().Z()); 58 59 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 59 63 // 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]; 62 69 for (i.Z()=-1*near_field_cells; i.Z()<=near_field_cells; ++i.Z()) { 63 70 64 71 // 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(); 69 74 int_val += temp_val; 70 75 76 dir[2] -= h[2]; 71 77 } 78 dir[1] -= h[1]; 79 } 80 dir[0] -= h[0]; 81 } 72 82 73 83 // Reciprocal value of the numerically integrated spline 74 84 int_val = 1.0 / (int_val * grid.Extent().MeshWidth().Product()); 75 85 76 iter = vals.begin();86 c = 0; 77 87 for (i.X()=-1*near_field_cells; i.X()<=near_field_cells; ++i.X()) 78 88 for (i.Y()=-1*near_field_cells; i.Y()<=near_field_cells; ++i.Y()) 79 89 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; 81 91 82 assert(iter == vals.end());83 92 } 84 93
Note:
See TracChangeset
for help on using the changeset viewer.
