1 |
|
#ifdef IS_MPI |
2 |
|
#include <iostream> |
3 |
< |
#include <cstdlib> |
4 |
< |
#include <cstring> |
5 |
< |
#include <cmath> |
3 |
> |
#include <stdlib.h> |
4 |
> |
#include <string.h> |
5 |
> |
#include <math.h> |
6 |
|
#include <mpi.h> |
7 |
|
|
8 |
|
#include "mpiSimulation.hpp" |
40 |
|
|
41 |
|
} |
42 |
|
|
43 |
< |
int* mpiSimulation::divideLabor( void ){ |
43 |
> |
void mpiSimulation::divideLabor( ){ |
44 |
|
|
45 |
– |
int* globalIndex; |
46 |
– |
|
45 |
|
int nComponents; |
46 |
|
MoleculeStamp** compStamps; |
47 |
|
randomSPRNG *myRandom; |
55 |
|
int old_atoms, add_atoms, new_atoms; |
56 |
|
|
57 |
|
int nTarget; |
58 |
< |
int molIndex, atomIndex, compIndex, compStart; |
58 |
> |
int molIndex, atomIndex; |
59 |
|
int done; |
62 |
– |
int nLocal, molLocal; |
60 |
|
int i, j, loops, which_proc, nmol_local, natoms_local; |
61 |
|
int nmol_global, natoms_global; |
62 |
< |
int local_index, index; |
66 |
< |
int smallDiff, bigDiff; |
62 |
> |
int local_index; |
63 |
|
int baseSeed = entryPlug->getSeed(); |
64 |
|
|
69 |
– |
int testSum; |
70 |
– |
|
65 |
|
nComponents = entryPlug->nComponents; |
66 |
|
compStamps = entryPlug->compStamps; |
67 |
|
componentsNmol = entryPlug->componentsNmol; |
74 |
|
mpiPlug->nSRIGlobal = entryPlug->n_SRI; |
75 |
|
mpiPlug->nMolGlobal = entryPlug->n_mol; |
76 |
|
|
83 |
– |
|
77 |
|
myRandom = new randomSPRNG( baseSeed ); |
78 |
|
|
79 |
|
a = 3.0 * (double)mpiPlug->nMolGlobal / (double)mpiPlug->nAtomsGlobal; |
271 |
|
mpiPlug->myNMol = nmol_local; |
272 |
|
mpiPlug->myNlocal = natoms_local; |
273 |
|
|
274 |
< |
globalIndex = new int[mpiPlug->myNlocal]; |
274 |
> |
globalAtomIndex.resize(mpiPlug->myNlocal); |
275 |
> |
globalToLocalAtom.resize(mpiPlug->nAtomsGlobal); |
276 |
|
local_index = 0; |
277 |
|
for (i = 0; i < mpiPlug->nAtomsGlobal; i++) { |
278 |
|
if (AtomToProcMap[i] == mpiPlug->myNode) { |
279 |
< |
globalIndex[local_index] = i; |
279 |
> |
globalAtomIndex[local_index] = i; |
280 |
> |
|
281 |
> |
globalToLocalAtom[i] = local_index; |
282 |
|
local_index++; |
283 |
+ |
|
284 |
|
} |
285 |
+ |
else |
286 |
+ |
globalToLocalAtom[i] = -1; |
287 |
|
} |
288 |
+ |
|
289 |
+ |
globalMolIndex.resize(mpiPlug->myNMol); |
290 |
+ |
globalToLocalMol.resize(mpiPlug->nMolGlobal); |
291 |
|
|
292 |
< |
return globalIndex; |
292 |
> |
local_index = 0; |
293 |
> |
for (i = 0; i < mpiPlug->nMolGlobal; i++) { |
294 |
> |
if (MolToProcMap[i] == mpiPlug->myNode) { |
295 |
> |
globalMolIndex[local_index] = i; |
296 |
> |
globalToLocalMol[i] = local_index; |
297 |
> |
local_index++; |
298 |
> |
} |
299 |
> |
else |
300 |
> |
globalToLocalMol[i] = -1; |
301 |
> |
} |
302 |
> |
|
303 |
|
} |
304 |
|
|
305 |
|
|