Changeset ac6d04 for src/samples/bspline.hpp
- Timestamp:
- Apr 10, 2012, 1:55:49 PM (14 years ago)
- Children:
- a40eea
- Parents:
- d24c2f
- File:
-
- 1 edited
-
src/samples/bspline.hpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/samples/bspline.hpp
rd24c2f rac6d04 36 36 void SetSpline(Grid& grid, const Particle::Particle p, const int& near_field_cells) 37 37 { 38 assert(p.Pos().X() >= grid.Extent().Begin().X() && p.Pos().X() < grid.Extent().End().X()); 39 assert(p.Pos().Y() >= grid.Extent().Begin().Y() && p.Pos().Y() < grid.Extent().End().Y()); 40 assert(p.Pos().Z() >= grid.Extent().Begin().Z() && p.Pos().Z() < grid.Extent().End().Z()); 41 38 42 Index i, index_global, index_local; 39 43 vmg_float temp_val, length; … … 44 48 45 49 index_global = static_cast<Index>((p.Pos() - grid.Extent().Begin()) / grid.Extent().MeshWidth()); 46 index_local = index_global - grid.Global().BeginLocal() + grid.Local().Begin(); 50 assert(index_global.X() >= grid.Global().LocalBegin().X() && index_global.X() < grid.Global().LocalEnd().X()); 51 assert(index_global.Y() >= grid.Global().LocalBegin().Y() && index_global.Y() < grid.Global().LocalEnd().Y()); 52 assert(index_global.Z() >= grid.Global().LocalBegin().Z() && index_global.Z() < grid.Global().LocalEnd().Z()); 53 54 index_local = index_global - grid.Global().LocalBegin() + grid.Local().Begin(); 55 assert(index_local.X() >= grid.Local().Begin().X() && index_local.X() < grid.Local().End().X()); 56 assert(index_local.Y() >= grid.Local().Begin().Y() && index_local.Y() < grid.Local().End().Y()); 57 assert(index_local.Z() >= grid.Local().Begin().Z() && index_local.Z() < grid.Local().End().Z()); 47 58 48 59 // 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()) {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()) 62 for (i.Z()=-1*near_field_cells; i.Z()<=near_field_cells; ++i.Z()) { 52 63 53 64 // Compute distance from grid point to particle … … 58 69 int_val += temp_val; 59 70 71 assert(temp_val >= 0.0); 72 60 73 } 61 74 62 int_val = 1.0 / (Helper::pow(grid.MeshWidth(), 3) * int_val); 75 // Reciprocal value of the numerically integrated spline 76 int_val = 1.0 / (int_val * grid.Extent().MeshWidth().Product()); 63 77 64 78 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()) 79 for (i.X()=-1*near_field_cells; i.X()<=near_field_cells; ++i.X()) 80 for (i.Y()=-1*near_field_cells; i.Y()<=near_field_cells; ++i.Y()) 81 for (i.Z()=-1*near_field_cells; i.Z()<=near_field_cells; ++i.Z()) 69 82 grid(index_local+i) += *iter++ * int_val; 70 83 84 assert(iter == vals.end()); 71 85 } 72 86 … … 79 93 } 80 94 81 vmg_float EvaluateDerivative(const Vector& v, const int& dv); 82 83 const vmg_float& GetAntiDerivativeZero() const 95 const vmg_float& GetAntiDerivativeAtZero() const 84 96 { 85 97 return antid;
Note:
See TracChangeset
for help on using the changeset viewer.
