Skip to content

Commit

Permalink
Add version of PC::Checkpoint that allows toggling off certain compon…
Browse files Browse the repository at this point in the history
…ents. (#4264)

This is useful in the case that some components can be re-initialized
rather than read from the checkpoint file.

## Summary

## Additional background

## Checklist

The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
atmyers authored Dec 16, 2024
1 parent 9643da4 commit 3fcfcce
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Src/Particle/AMReX_ParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,24 @@ public:
const Vector<std::string>& real_comp_names = Vector<std::string>(),
const Vector<std::string>& int_comp_names = Vector<std::string>()) const;

/**
* \brief Writes a particle checkpoint to file, suitable for restarting.
* This version allows some components to be toggled off, if they
* don't need to be stored in the chk file.
*
* \param dir The base directory into which to write (i.e. "plt00000")
* \param name The name of the sub-directory for this particle type (i.e. "Tracer")
* \param write_real_comp for each real component, whether or not we include that component in the file
* \param write_int_comp for each integer component, whether or not we include that component in the file
* \param real_comp_names vector of real component names
* \param int_comp_names vector of int component names
*/
void Checkpoint (const std::string& dir, const std::string& name,
const Vector<int>& write_real_comp,
const Vector<int>& write_int_comp,
const Vector<std::string>& real_comp_names,
const Vector<std::string>& int_comp_names) const;

/**
* \brief Writes particle data to disk in the AMReX native format.
*
Expand Down
15 changes: 15 additions & 0 deletions Src/Particle/AMReX_ParticleIO.H
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
FilterPositiveID{}, true);
}

template <typename ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator, class CellAssignor>
void
ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>
::Checkpoint (const std::string& dir, const std::string& name,
const Vector<int>& write_real_comp,
const Vector<int>& write_int_comp,
const Vector<std::string>& real_comp_names,
const Vector<std::string>& int_comp_names) const
{
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
real_comp_names, int_comp_names,
FilterPositiveID{}, true);
}

template <typename ParticleType, int NArrayReal, int NArrayInt,
template<class> class Allocator, class CellAssignor>
void
Expand Down

0 comments on commit 3fcfcce

Please sign in to comment.