Changeset b303d0
- Timestamp:
- Sep 6, 2015, 10:25:02 PM (10 years ago)
- Children:
- 3f6604
- Parents:
- ebc866
- git-author:
- Frederik Heber <heber@…> (03/13/15 15:02:44)
- git-committer:
- Frederik Heber <heber@…> (09/06/15 22:25:02)
- File:
-
- 1 edited
-
src/units/particle/bspline.hpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/units/particle/bspline.hpp
rebc866 rb303d0 210 210 const vmg_float& h_z = grid.Extent().MeshWidth().Z(); 211 211 212 int int_val = 0.;212 vmg_float int_val = 0.; 213 213 vmg_float dir_x = pos_beg_x; 214 214 for (int i=-1*near_field_cells; i<=near_field_cells; ++i) { … … 218 218 for (int k=-1*near_field_cells; k<=near_field_cells; ++k) { 219 219 220 // Compute distance from grid point to particle 221 int_val += EvaluateSpline(std::sqrt(dir_x*dir_x+dir_y*dir_y+dir_z*dir_z)); 220 const double length_sq = dir_x*dir_x+dir_y*dir_y+dir_z*dir_z; 221 if (fabs(length_sq) > std::numeric_limits<double>::epsilon()) { 222 // Compute distance from grid point to particle 223 int_val += EvaluateSpline(std::sqrt(length_sq)); 224 } 222 225 223 226 dir_z += h_z; … … 229 232 // Reciprocal value of the numerically integrated spline 230 233 if (fabs(int_val) > std::numeric_limits<double>::epsilon()) 231 int_val = 1. 0/ (int_val * h_x * h_y * h_z);234 int_val = 1. / (int_val * h_x * h_y * h_z); 232 235 else 233 int_val = 1. 0;236 int_val = 1. / (h_x * h_y * h_z); 234 237 235 238 // Iterate over all grid points which lie in the support of the interpolating B-Spline 239 vmg_float test_int_val = 0.; 236 240 dir_x = pos_beg_x; 237 241 for (int i=-1*near_field_cells; i<=near_field_cells; ++i) { … … 245 249 if (fabs(length_sq) > std::numeric_limits<double>::epsilon()) { 246 250 const double length = std::sqrt(length_sq); 247 // temp_val = EvaluateField(length); 248 // p.Field()[0] -= p.Charge() * dir_x * temp_val; 249 // p.Field()[1] -= p.Charge() * dir_y * temp_val; 250 // p.Field()[2] -= p.Charge() * dir_z * temp_val; 251 temp_val = int_val * EvaluateSpline(length); 252 p.Field()[0] -= p.Charge()*p.Charge() * temp_val * temp_val * dir_x / (length_sq*length); 253 p.Field()[1] -= p.Charge()*p.Charge() * temp_val * temp_val * dir_y / (length_sq*length); 254 p.Field()[2] -= p.Charge()*p.Charge() * temp_val * temp_val * dir_z / (length_sq*length); 251 252 temp_val = h_x * h_y * h_z * int_val * EvaluateSpline(length); 253 test_int_val += temp_val; 254 p.Field()[0] -= p.Charge()* temp_val * dir_x / (length_sq*length); 255 p.Field()[1] -= p.Charge()* temp_val * dir_y / (length_sq*length); 256 p.Field()[2] -= p.Charge()* temp_val * dir_z / (length_sq*length); 255 257 } else { 256 258 std::cerr << "Value very small " << length_sq << "=(" … … 267 269 dir_x += h_x; 268 270 } 271 if ( fabs(test_int_val -1.) > std::numeric_limits<double>::epsilon()*1e4 ) { 272 std::cerr << "Integrated spline value should be 1 but is " << test_int_val << std::endl; 273 assert(0); 274 } 269 275 } 270 276
Note:
See TracChangeset
for help on using the changeset viewer.
