Conversation
…sures that resume does not load particle types multiple times. Also only adds unique particle types to particle_types_. Not clanged. Not tested.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #115 +/- ##
==========================================
- Coverage 95.76% 95.71% -0.05%
==========================================
Files 244 245 +1
Lines 51467 51730 +263
==========================================
+ Hits 49284 49509 +225
- Misses 2183 2221 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bodhinandach
left a comment
There was a problem hiding this comment.
@cgeudeker Thanks for finding and fixing this. Perhaps it is good to make some tests, if it is not too difficult?
Yes will work on a couple. |
| for (const auto ptype : particle_types_) { | ||
| std::string attribute = mpm::ParticlePODTypeName.at(ptype); | ||
| std::string extension = ".h5"; | ||
|
|
||
| auto particles_file = | ||
| io_->output_file(attribute, extension, uuid_, step_, this->nsteps_) | ||
| .string(); | ||
|
|
||
| // Load particle information from file | ||
| mesh_->read_particles_hdf5(particles_file, attribute, ptype); | ||
| } | ||
|
|
There was a problem hiding this comment.
Any specific reasons why this is moved to read_hdf5() function? Just to tidy it up?
There was a problem hiding this comment.
Yes its mainly a tidy up, better follows the write approach as well. Just makes it a little more readable in my opinion, can switch it back if we want.
…ultiple particle types
|
@cgeudeker Would you be able to confirm if you have fixed the latest reported problem of seg fault in MPI resume? |
bodhinandach
left a comment
There was a problem hiding this comment.
@cgeudeker Thanks for the effort. Overall, looks good to me. But I have some questions that I would like to understand.
| auto pod = std::static_pointer_cast<mpm::PODParticle>((*pitr)->pod()); | ||
| particle_data.emplace_back(*pod); | ||
| if (particle_type == (*pitr)->type()) { | ||
| auto pod = std::static_pointer_cast<mpm::PODParticle>((*pitr)->pod()); |
There was a problem hiding this comment.
This casting to mpm::PODParticle means that the different particle types should have the same POD t,ype right? That means single-phase particles cannot be output together with two-phase particles since they have different POD types. Is that the intention? I guess, we are not going to run a scenario of both multi-phase particles and single-phase particles simulated at the same time, right?
There was a problem hiding this comment.
Maybe not true, since if there are different particle types, they're gonna call different functions from mpm_base.tcc.
There was a problem hiding this comment.
The purpose of this check is just to confirm that only particles of the same particle type are output to the file that is being written in a given instance of the function call. I would assume all particles of a given type would have the same POD.
| particle_data.emplace_back(*pod); | ||
| if (particle_type == (*pitr)->type()) { | ||
| auto pod = | ||
| std::static_pointer_cast<mpm::PODParticleTwoPhase>((*pitr)->pod()); |
| //! Read HDF5 files | ||
| template <unsigned Tdim> | ||
| void mpm::MPMBase<Tdim>::read_hdf5() { | ||
| // Read hdf5 file for single phase particle |
| // Load particle information from file | ||
| mesh_->read_particles_hdf5(particles_file, attribute, ptype); | ||
| } | ||
| this->read_hdf5(); |
There was a problem hiding this comment.
I am not too sure what the necessity is to bundle them into a single function. Is this just to improve readability? Or is there any specific efficiency reason?
There was a problem hiding this comment.
Only to improve readability and match the same naming conventions that the write pathway has. Can change back if desired.
Yes this has been fixed. Simple 1D bar compression with two particle types, successfully ran in the four aforementioned cases (serial or mpi with and without resume) and yielded the same results. |


Describe the PR
When resuming a simulation with multiple particle_types, a full set of particles would be generated for each particle type. Additionally, it seems that each instance of the same particle type would be loaded in full, though subsequent generation would likely replace the previous. As such the following modifications have been made:
ParticlePODTypeName, each distinct particle type has been assigned a specific POD type name, though these all lead to the eventual use of the "particles" POD type for file reading and writing.initialise_particle_types, a modification has been made to only add distinct particle types.Related Issues/PRs
N/A
Additional context
N/A