- Timestamp:
- Jul 4, 2012, 6:10:39 PM (13 years ago)
- Children:
- 0260d3
- Parents:
- 290aa3
- Location:
- src
- Files:
-
- 10 edited
-
base/vector.hpp (modified) (1 diff)
-
comm/comm.hpp (modified) (2 diffs)
-
comm/comm_mpi.cpp (modified) (6 diffs)
-
comm/comm_mpi.hpp (modified) (2 diffs)
-
grid/grid.cpp (modified) (1 diff)
-
units/particle/comm_mpi_particle.cpp (modified) (1 diff)
-
units/particle/interface_fcs.cpp (modified) (1 diff)
-
units/particle/interface_particles.cpp (modified) (1 diff)
-
units/particle/interpolation.cpp (modified) (4 diffs)
-
units/particle/particle.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/base/vector.hpp
r290aa3 ref94e7 106 106 } 107 107 108 bool IsInBounds(const Vector& begin, const Vector& end) const 109 { 110 return this->IsComponentwiseGreaterOrEqual(begin) && 111 this->IsComponentwiseLessOrEqual(end); 112 } 108 113 109 114 Vector MaxComponentwise(const Vector& rhs) const -
src/comm/comm.hpp
r290aa3 ref94e7 73 73 virtual void Barrier() {} 74 74 75 virtual vmg_float GlobalSum( const vmg_float&value) {return value;}76 virtual vmg_float GlobalSumRoot( const vmg_float&value) {return value;}75 virtual vmg_float GlobalSum(vmg_float value) {return value;} 76 virtual vmg_float GlobalSumRoot(vmg_float value) {return value;} 77 77 virtual void GlobalSumArray(vmg_float* array, const vmg_int& size) {} 78 virtual vmg_float GlobalMax( const vmg_float&value) {return value;}79 virtual vmg_float GlobalMaxRoot( const vmg_float&value) {return value;}78 virtual vmg_float GlobalMax(vmg_float value) {return value;} 79 virtual vmg_float GlobalMaxRoot(vmg_float value) {return value;} 80 80 virtual void GlobalMaxArray(vmg_float* array, const vmg_int& size) {} 81 81 virtual void GlobalBroadcast(vmg_float& value) {} 82 82 virtual void GlobalGather(vmg_float& value, vmg_float* array) {array[0] = value;} 83 83 84 virtual vmg_int GlobalSum( const vmg_int&value) {return value;}85 virtual vmg_int GlobalSumRoot( const vmg_int&value) {return value;}84 virtual vmg_int GlobalSum(vmg_int value) {return value;} 85 virtual vmg_int GlobalSumRoot(vmg_int value) {return value;} 86 86 virtual void GlobalSumArray(vmg_int* array, const vmg_int& size) {} 87 virtual vmg_int GlobalMax( const vmg_int&value) {return value;}88 virtual vmg_int GlobalMaxRoot( const vmg_int&value) {return value;}87 virtual vmg_int GlobalMax(vmg_int value) {return value;} 88 virtual vmg_int GlobalMaxRoot(vmg_int value) {return value;} 89 89 virtual void GlobalMaxArray(vmg_int* array, const vmg_int& size) {} 90 90 virtual void GlobalBroadcast(vmg_int& value) {} … … 93 93 virtual void GlobalBroadcast(char* str) {} 94 94 95 virtual vmg_float LevelSum(const Grid& grid, const vmg_float&value) {return value;}96 virtual vmg_float LevelSumRoot(const Grid& grid, const vmg_float&value) {return value;}95 virtual vmg_float LevelSum(const Grid& grid, vmg_float value) {return value;} 96 virtual vmg_float LevelSumRoot(const Grid& grid, vmg_float value) {return value;} 97 97 virtual void LevelSumArray(const Grid& grid, vmg_float* array, const vmg_int& size) {} 98 98 99 virtual vmg_int LevelSum(const Grid& grid, const vmg_int&value) {return value;}100 virtual vmg_int LevelSumRoot(const Grid& grid, const vmg_int&value) {return value;}99 virtual vmg_int LevelSum(const Grid& grid, vmg_int value) {return value;} 100 virtual vmg_int LevelSumRoot(const Grid& grid, vmg_int value) {return value;} 101 101 virtual void LevelSumArray(const Grid& grid, vmg_int* array, const vmg_int& size) {} 102 102 -
src/comm/comm_mpi.cpp
r290aa3 ref94e7 191 191 } 192 192 193 vmg_float CommMPI::GlobalSum(const vmg_float& value) 194 { 195 vmg_float result = value; 196 MPI_Allreduce(MPI_IN_PLACE, &result, 1, MPI_DOUBLE, MPI_SUM, comm_global); 197 return result; 198 } 199 200 vmg_float CommMPI::GlobalSumRoot(const vmg_float& value) 201 { 202 vmg_float recv_buffer = value; 203 vmg_float send_buffer = value; 204 MPI_Reduce(&send_buffer, &recv_buffer, 1, MPI_DOUBLE, MPI_SUM, 0, comm_global); 205 return recv_buffer; 193 vmg_float CommMPI::GlobalSum(vmg_float value) 194 { 195 vmg_float result = 0; 196 MPI_Allreduce(&value, &result, 1, MPI_DOUBLE, MPI_SUM, comm_global); 197 return result; 198 } 199 200 vmg_float CommMPI::GlobalSumRoot(vmg_float value) 201 { 202 vmg_float result = 0; 203 MPI_Reduce(&value, &result, 1, MPI_DOUBLE, MPI_SUM, 0, comm_global); 204 return result; 206 205 } 207 206 … … 221 220 } 222 221 223 vmg_int CommMPI::GlobalSum(const vmg_int& value) 224 { 225 vmg_int result = value; 226 MPI_Allreduce(MPI_IN_PLACE, &result, 1, MPI_INT, MPI_SUM, comm_global); 227 return result; 228 } 229 230 vmg_int CommMPI::GlobalSumRoot(const vmg_int& value) 231 { 232 vmg_int recv_buffer = value; 233 vmg_int send_buffer = value; 234 MPI_Reduce(&send_buffer, &recv_buffer, 1, MPI_INT, MPI_SUM, 0, comm_global); 235 return recv_buffer; 222 vmg_int CommMPI::GlobalSum(vmg_int value) 223 { 224 vmg_int result = 0; 225 MPI_Allreduce(&value, &result, 1, MPI_INT, MPI_SUM, comm_global); 226 return result; 227 } 228 229 vmg_int CommMPI::GlobalSumRoot(vmg_int value) 230 { 231 vmg_int result = 0; 232 MPI_Reduce(&value, &result, 1, MPI_INT, MPI_SUM, 0, comm_global); 233 return result; 236 234 } 237 235 … … 241 239 } 242 240 243 vmg_float CommMPI::GlobalMax(const vmg_float& value) 244 { 245 vmg_float result = value; 246 MPI_Allreduce(MPI_IN_PLACE, &result, 1, MPI_DOUBLE, MPI_MAX, comm_global); 247 return result; 248 } 249 250 vmg_float CommMPI::GlobalMaxRoot(const vmg_float& value) 251 { 252 vmg_float recv_buffer = value; 253 vmg_float send_buffer = value; 254 MPI_Reduce(&send_buffer, &recv_buffer, 1, MPI_DOUBLE, MPI_MAX, 0, comm_global); 255 return recv_buffer; 241 vmg_float CommMPI::GlobalMax(vmg_float value) 242 { 243 vmg_float result = 0.0; 244 MPI_Allreduce(&value, &result, 1, MPI_DOUBLE, MPI_MAX, comm_global); 245 return result; 246 } 247 248 vmg_float CommMPI::GlobalMaxRoot(vmg_float value) 249 { 250 vmg_float result = 0.0; 251 MPI_Reduce(&value, &result, 1, MPI_DOUBLE, MPI_MAX, 0, comm_global); 252 return result; 256 253 } 257 254 … … 261 258 } 262 259 263 vmg_int CommMPI::GlobalMax(const vmg_int& value) 264 { 265 vmg_int result = value; 266 MPI_Allreduce(MPI_IN_PLACE, &result, 1, MPI_INT, MPI_MAX, comm_global); 267 return result; 268 } 269 270 vmg_int CommMPI::GlobalMaxRoot(const vmg_int& value) 271 { 272 vmg_int recv_buffer = value; 273 vmg_int send_buffer = value; 274 MPI_Reduce(&send_buffer, &recv_buffer, 1, MPI_INT, MPI_MAX, 0, comm_global); 275 return recv_buffer; 260 vmg_int CommMPI::GlobalMax(vmg_int value) 261 { 262 vmg_int result = 0; 263 MPI_Allreduce(&value, &result, 1, MPI_INT, MPI_MAX, comm_global); 264 return result; 265 } 266 267 vmg_int CommMPI::GlobalMaxRoot(vmg_int value) 268 { 269 vmg_int result = 0; 270 MPI_Reduce(&value, &result, 1, MPI_INT, MPI_MAX, 0, comm_global); 271 return result; 276 272 } 277 273 … … 298 294 } 299 295 300 vmg_float CommMPI::LevelSum(const Grid& grid, const vmg_float&value)301 { 302 vmg_float result = value;296 vmg_float CommMPI::LevelSum(const Grid& grid, vmg_float value) 297 { 298 vmg_float result = 0.0; 303 299 MPI_Comm comm = settings.CommunicatorLocal(grid); 304 300 assert(comm != MPI_COMM_NULL); 305 MPI_Allreduce(MPI_IN_PLACE, &result, 1, MPI_DOUBLE, MPI_SUM, comm); 306 return result; 307 } 308 309 vmg_float CommMPI::LevelSumRoot(const Grid& grid, const vmg_float& value) 310 { 311 vmg_float recv_buffer = value; 312 vmg_float send_buffer = value; 301 MPI_Allreduce(&value, &result, 1, MPI_DOUBLE, MPI_SUM, comm); 302 return result; 303 } 304 305 vmg_float CommMPI::LevelSumRoot(const Grid& grid, vmg_float value) 306 { 307 vmg_float result = 0.0; 313 308 MPI_Comm comm = settings.CommunicatorLocal(grid); 314 309 assert(comm != MPI_COMM_NULL); 315 MPI_Reduce(& send_buffer, &recv_buffer, 1, MPI_DOUBLE, MPI_SUM, 0, comm);316 return re cv_buffer;310 MPI_Reduce(&value, &result, 1, MPI_DOUBLE, MPI_SUM, 0, comm); 311 return result; 317 312 } 318 313 … … 324 319 } 325 320 326 vmg_int CommMPI::LevelSum(const Grid& grid, const vmg_int&value)327 { 328 vmg_int result = value;321 vmg_int CommMPI::LevelSum(const Grid& grid, vmg_int value) 322 { 323 vmg_int result = 0; 329 324 MPI_Comm comm = settings.CommunicatorLocal(grid); 330 325 assert(comm != MPI_COMM_NULL); 331 MPI_Allreduce(MPI_IN_PLACE, &result, 1, MPI_INT, MPI_SUM, comm); 332 return result; 333 } 334 335 vmg_int CommMPI::LevelSumRoot(const Grid& grid, const vmg_int& value) 336 { 337 vmg_int recv_buffer = value; 338 vmg_int send_buffer = value; 326 MPI_Allreduce(&value, &result, 1, MPI_INT, MPI_SUM, comm); 327 return result; 328 } 329 330 vmg_int CommMPI::LevelSumRoot(const Grid& grid, vmg_int value) 331 { 332 vmg_int result = 0; 339 333 MPI_Comm comm = settings.CommunicatorLocal(grid); 340 334 assert(comm != MPI_COMM_NULL); 341 MPI_Reduce(& send_buffer, &recv_buffer, 1, MPI_INT, MPI_SUM, 0, comm);342 return re cv_buffer;335 MPI_Reduce(&value, &result, 1, MPI_INT, MPI_SUM, 0, comm); 336 return result; 343 337 } 344 338 -
src/comm/comm_mpi.hpp
r290aa3 ref94e7 89 89 void Barrier(); 90 90 91 vmg_float GlobalSum( const vmg_float&value);92 vmg_float GlobalSumRoot( const vmg_float&value);91 vmg_float GlobalSum(vmg_float value); 92 vmg_float GlobalSumRoot(vmg_float value); 93 93 void GlobalSumArray(vmg_float* array, const vmg_int& size); 94 vmg_float GlobalMax( const vmg_float&value);95 vmg_float GlobalMaxRoot( const vmg_float&value);94 vmg_float GlobalMax(vmg_float value); 95 vmg_float GlobalMaxRoot(vmg_float value); 96 96 void GlobalMaxArray(vmg_float* array, const vmg_int& size); 97 97 void GlobalBroadcast(vmg_float& value); 98 98 void GlobalGather(vmg_float& value, vmg_float* array); 99 99 100 vmg_int GlobalSum( const vmg_int&value);101 vmg_int GlobalSumRoot( const vmg_int&value);100 vmg_int GlobalSum(vmg_int value); 101 vmg_int GlobalSumRoot(vmg_int value); 102 102 void GlobalSumArray(vmg_int* array, const vmg_int& size); 103 vmg_int GlobalMax( const vmg_int&value);104 vmg_int GlobalMaxRoot( const vmg_int&value);103 vmg_int GlobalMax(vmg_int value); 104 vmg_int GlobalMaxRoot(vmg_int value); 105 105 void GlobalMaxArray(vmg_int* array, const vmg_int& size); 106 106 void GlobalBroadcast(vmg_int& value); … … 109 109 void GlobalBroadcast(char* str); 110 110 111 vmg_float LevelSum(const Grid& grid, const vmg_float&value);112 vmg_float LevelSumRoot(const Grid& grid, const vmg_float&value);111 vmg_float LevelSum(const Grid& grid, vmg_float value); 112 vmg_float LevelSumRoot(const Grid& grid, vmg_float value); 113 113 void LevelSumArray(const Grid& grid, vmg_float* array, const vmg_int& size); 114 114 115 vmg_int LevelSum(const Grid& grid, const vmg_int&value);116 vmg_int LevelSumRoot(const Grid& grid, const vmg_int&value);115 vmg_int LevelSum(const Grid& grid, vmg_int value); 116 vmg_int LevelSumRoot(const Grid& grid, vmg_int value); 117 117 void LevelSumArray(const Grid& grid, vmg_int* array, const vmg_int& size); 118 118 -
src/grid/grid.cpp
r290aa3 ref94e7 269 269 bool consistent = true; 270 270 271 for (Grid::iterator iter=Iterators(). CompleteGrid().Begin(); iter!=Iterators().CompleteGrid().End(); ++iter)271 for (Grid::iterator iter=Iterators().Local().Begin(); iter!=Iterators().Local().End(); ++iter) 272 272 consistent &= Helper::CheckNumber(GetVal(*iter)); 273 273 -
src/units/particle/comm_mpi_particle.cpp
r290aa3 ref94e7 218 218 for (vmg_int j=0; j<size_receive[i]; ++j) { 219 219 p[recv_buffer_index[i][j]] = recv_buffer_float[i][4*j]; 220 std::memcpy(&f[ recv_buffer_index[i][j]], &recv_buffer_float[i][4*j+1], 3*sizeof(vmg_float));220 std::memcpy(&f[3*recv_buffer_index[i][j]], &recv_buffer_float[i][4*j+1], 3*sizeof(vmg_float)); 221 221 } 222 222 #endif -
src/units/particle/interface_fcs.cpp
r290aa3 ref94e7 221 221 const Grid& grid = multigrid(multigrid.MaxLevel()); 222 222 223 int error_code ;223 int error_code = 0; 224 224 225 225 if (!grid.Global().LocalSize().IsComponentwiseGreater(near_field_cells)) 226 226 error_code = 1; 227 else 228 error_code = 0; 229 230 error_code = MG::GetComm()->GlobalMax(error_code); 231 232 return error_code; 227 228 return MG::GetComm()->GlobalMax(error_code); 233 229 } 234 230 -
src/units/particle/interface_particles.cpp
r290aa3 ref94e7 179 179 for (p1=lc(i,j,k).begin(); p1!=lc(i,j,k).end(); ++p1) { 180 180 181 // Interpolate long-range part of potential and electric field 181 182 ip.Evaluate(**p1); 183 184 // Subtract self-induced potential 182 185 (*p1)->Pot() -= (*p1)->Charge() * spl.GetAntiDerivativeAtZero(); 183 (*p1)->Field() *= 0.5;184 186 185 187 #ifdef DEBUG_OUTPUT -
src/units/particle/interpolation.cpp
r290aa3 ref94e7 30 30 #include "units/particle/particle.hpp" 31 31 32 #include "mg.hpp" 33 #include "comm/comm.hpp" 34 32 35 using namespace VMG; 33 36 … … 54 57 Index i; 55 58 56 const Index begin = index - deg/2 - 1;59 const Index begin = index - deg/2; 57 60 58 61 h = grid.Extent().MeshWidth(); … … 105 108 void Particle::Interpolation::Evaluate(Particle& p) 106 109 { 107 Vector offset; 110 const Vector& pos = p.Pos(); 111 vmg_float& pot = p.Pot(); 112 Vector& field = p.Field(); 108 113 109 const Vector& pos = p.Pos(); 110 vmg_float& pot = p.Pot(); 111 Vector& field = p.Field(); 114 pot = 0.0; 115 field = 0.0; 112 116 113 pot = 0.0; 114 field = 0.0; 115 117 Vector offset = pos - pos_begin; 116 118 buffer[0] = 1.0; 117 offset = pos - pos_begin;118 for (int i=1; i<deg_1; ++i) {119 buffer[i] = buffer[i-1] * offset;120 offset -= h;121 }122 123 offset = pos - pos_begin;124 119 for (int i=0; i<deg; ++i) { 120 buffer[i+1] = buffer[i] * offset; 125 121 for (int j=0; j<i; ++j) 126 122 buffer_diff[i][j] = buffer_diff[i-1][j] * offset; … … 145 141 field[2] -= _access_coeff(i, j, k+1) * buffer[i][0] * buffer[j][1] * buffer_diff[k][0][2]; 146 142 } 147 148 143 } 149 144 -
src/units/particle/particle.hpp
r290aa3 ref94e7 40 40 { 41 41 public: 42 Particle() : 43 x_(0.0), 44 f_(0.0), 45 q_(0.0), 46 p_(0.0), 47 rank_(-1), 48 index_(-1) 49 {} 50 42 51 Particle(const vmg_float* x, const vmg_float& q) : 43 52 x_(x),
Note:
See TracChangeset
for help on using the changeset viewer.
