Changeset 716da7 for src/interface/interface_particles.cpp
- Timestamp:
- Apr 24, 2012, 2:26:14 PM (14 years ago)
- Children:
- b51c3b
- Parents:
- e3dbbf
- File:
-
- 1 edited
-
src/interface/interface_particles.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/interface/interface_particles.cpp
re3dbbf r716da7 25 25 #include "base/helper.hpp" 26 26 #include "base/index.hpp" 27 #include "base/interpolate_polynomial.hpp" 27 28 #include "base/linked_cell_list.hpp" 28 29 #include "base/math.hpp" … … 101 102 vmg_float length; 102 103 Vector dist_vec; 104 InterpolatePolynomial ip(8); 103 105 104 106 #ifdef DEBUG_OUTPUT … … 119 121 const int& near_field_cells = factory.GetObjectStorageVal<int>("PARTICLE_NEAR_FIELD_CELLS"); 120 122 vmg_float* p = factory.GetObjectStorageArray<vmg_float>("PARTICLE_POTENTIAL_ARRAY"); 121 vmg_float* f = factory.GetObjectStorageArray<vmg_float>("PARTICLE_F ORCE_ARRAY");123 vmg_float* f = factory.GetObjectStorageArray<vmg_float>("PARTICLE_FIELD_ARRAY"); 122 124 123 125 const vmg_float r_cut = (near_field_cells+0.5) * grid.Extent().MeshWidth().Max(); … … 152 154 for (p_iter=particles.begin(); p_iter!=particles.end(); ++p_iter) { 153 155 156 const Index global_index = (p_iter->Pos() - particle_grid.Extent().Begin()) / particle_grid.Extent().MeshWidth(); 157 const Index local_index = global_index - particle_grid.Global().LocalBegin() + particle_grid.Local().Begin(); 158 159 ip.ComputeCoefficients(particle_grid, local_index); 160 154 161 // Interpolate long range part of potential minus self-interaction 155 p_iter->Pot() = Helper::InterpolateTrilinear(p_iter->Pos(), particle_grid)156 - p_iter->Charge() * spl.GetAntiDerivativeAtZero();162 p_iter->Pot() = ip.Evaluate(p_iter->Pos()) - p_iter->Charge() * spl.GetAntiDerivativeAtZero(); 163 p_iter->Field() = ip.EvaluateGradient(p_iter->Pos()); 157 164 158 165 #ifdef DEBUG_OUTPUT … … 171 178 Grid::iterator iter; 172 179 173 comm.CommLCListToGhosts( grid,lc);180 comm.CommLCListToGhosts(lc); 174 181 175 182 for (iter=lc.Iterators().Local().Begin(); iter!=lc.Iterators().Local().End(); ++iter) { … … 179 186 for (index.Y()=-1*near_field_cells-1; index.Y()<=near_field_cells+1; ++index.Y()) 180 187 for (index.Z()=-1*near_field_cells-1; index.Z()<=near_field_cells+1; ++index.Z()) { 188 181 189 std::list<Particle::Particle*>& lc_2 = lc(*iter+index); 190 182 191 for (p2=lc_2.begin(); p2!=lc_2.end(); ++p2) 183 192 if (*p1 != *p2) { … … 187 196 //TODO Rewrite this equation more efficiently 188 197 if (length < r_cut) { 189 (*p1)->Pot() += (*p2)->Charge() / length * (1.0 -spl.EvaluatePotential(length));198 (*p1)->Pot() += (*p2)->Charge() / length * (1.0 + spl.EvaluatePotential(length)); 190 199 191 200 #ifdef DEBUG_OUTPUT … … 193 202 e_shortcorr -= 0.5 * (*p1)->Charge() * (*p2)->Charge() / length * spl.EvaluatePotential(length); 194 203 #endif 195 196 204 } 197 205 }
Note:
See TracChangeset
for help on using the changeset viewer.
