-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ParticleID #452
base: develop
Are you sure you want to change the base?
ParticleID #452
Changes from 1 commit
1c2c215
8bbb63b
22b4f47
eae310a
ccdcd3e
d7b0e5e
b0c29fa
93a3d7e
3fd7769
84f216c
cc4a455
ea18537
866746b
9100ce8
fad56a9
5cd73a7
de479f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,29 @@ void readFileAttributes(InitSettings& settings, const std::string& settingsFile, | |
} | ||
} | ||
|
||
//! @brief generate particle IDs at the beginning of the simulation initialization | ||
template<class Dataset> | ||
void generateParticleIDs(Dataset& d, int rank, int numRanks) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function doesn't need the full dataset, only a |
||
{ | ||
std::vector<size_t> ranksLocalParticles(numRanks); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
size_t localNumRanks = d.x.size(); | ||
// fill ranksLocalParticles with the number of particles per rank | ||
MPI_Allgather(&localNumRanks, 1, MPI_UNSIGNED_LONG, ranksLocalParticles.data(), 1, MPI_UNSIGNED_LONG, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
MPI_COMM_WORLD); | ||
|
||
size_t offset = 0; | ||
|
||
for (int i = 0; i < rank; i++) | ||
{ | ||
offset += ranksLocalParticles[i]; | ||
} | ||
|
||
for (size_t i = 0; i < d.x.size(); i++) | ||
{ | ||
d.id[i] = offset + i; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These std::exclusive_scan(ranksLocalParticles.begin(), ranksLocalParticles.end(), ranksLocalParticles.begin(), uint64_t(0));
std::iota(id.begin(), id.end(), ranksLocalParticles[rank]); This will work also if |
||
} | ||
|
||
//! @brief Used to read the default values of dataset attributes | ||
class BuiltinReader | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generateParticleID
just initializes an additional field. It can be called ininitEvrardFields
where all the other fields are initialized as well. Same for the other test cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this requires passing rank and numRanks to the init*Fields functions. Should I pass these parameters as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're already using the MPI communicator in
generateParticleIDs
. Might as well use it to obtainrank
andnumRanks
as well. You can take the communicator as an argument togenerateParticleIDs
and passMPI_COMM_WORLD
at the call site. (One less function to removeMPI_COMM_WORLD
from later).