Changeset b2154a3 for src/interface/interface_particles.cpp
- Timestamp:
- Apr 25, 2012, 7:31:43 PM (14 years ago)
- Children:
- 4571da
- Parents:
- 3bd250
- File:
-
- 1 edited
-
src/interface/interface_particles.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/interface/interface_particles.cpp
r3bd250 rb2154a3 151 151 152 152 /* 153 * Do potential back-interpolation 154 */ 155 std::list<Particle::Particle>::iterator p_iter; 156 for (p_iter=particles.begin(); p_iter!=particles.end(); ++p_iter) { 157 158 const Index global_index = (p_iter->Pos() - particle_grid.Extent().Begin()) / particle_grid.Extent().MeshWidth(); 159 const Index local_index = global_index - particle_grid.Global().LocalBegin() + particle_grid.Local().Begin(); 160 161 ip.ComputeCoefficients(particle_grid, local_index); 162 163 // Interpolate long range part of potential minus self-interaction 164 p_iter->Pot() = ip.Evaluate(p_iter->Pos()) - p_iter->Charge() * spl.GetAntiDerivativeAtZero(); 165 p_iter->Field() = ip.EvaluateGradient(p_iter->Pos()); 166 167 #ifdef DEBUG_OUTPUT 168 // TODO The scaling with 1/2 may not be correct. Check that. 169 e_long += 0.5 * p_iter->Charge() * Helper::InterpolateTrilinear(p_iter->Pos(), particle_grid); 170 e_self += 0.5 * p_iter->Charge() * p_iter->Charge() * spl.GetAntiDerivativeAtZero(); 171 #endif 172 173 } 174 175 /* 176 * Compute near field correction 153 * Compute potentials 177 154 */ 178 155 Particle::LinkedCellList lc(particles, near_field_cells, grid); … … 183 160 184 161 for (iter=lc.Iterators().Local().Begin(); iter!=lc.Iterators().Local().End(); ++iter) { 162 163 ip.ComputeCoefficients(particle_grid, *iter - lc.Local().Begin() + particle_grid.Local().Begin()); 164 185 165 std::list<Particle::Particle*>& lc_1 = lc(*iter); 186 for (p1=lc_1.begin(); p1!=lc_1.end(); ++p1) 166 167 for (p1=lc_1.begin(); p1!=lc_1.end(); ++p1) { 168 169 (*p1)->Pot() = ip.Evaluate((*p1)->Pos()) - (*p1)->Charge() * spl.GetAntiDerivativeAtZero(); 170 171 #ifdef DEBUG_OUTPUT 172 // TODO The scaling with 1/2 may not be correct. Check that. 173 e_long += 0.5 * (*p1)->Charge() * Helper::InterpolateTrilinear((*p1)->Pos(), particle_grid); 174 e_self += 0.5 * (*p1)->Charge() * (*p1)->Charge() * spl.GetAntiDerivativeAtZero(); 175 #endif 176 187 177 for (index.X()=-1*near_field_cells-1; index.X()<=near_field_cells+1; ++index.X()) 188 178 for (index.Y()=-1*near_field_cells-1; index.Y()<=near_field_cells+1; ++index.Y()) … … 207 197 } 208 198 } 199 } 209 200 } 210 201
Note:
See TracChangeset
for help on using the changeset viewer.
