aboutsummaryrefslogtreecommitdiff
path: root/Source/Python/WarpXWrappers.cpp
diff options
context:
space:
mode:
authorGravatar Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> 2021-08-02 12:52:13 -0700
committerGravatar GitHub <noreply@github.com> 2021-08-02 12:52:13 -0700
commit8836f4a4dc38898c6b628729424aba6924151333 (patch)
tree726fd5e8579db3faa12ed39b7757c22d1f077994 /Source/Python/WarpXWrappers.cpp
parentcd8cb0bf917d8a92d03c87e943fbf0866e277dcb (diff)
downloadWarpX-8836f4a4dc38898c6b628729424aba6924151333.tar.gz
WarpX-8836f4a4dc38898c6b628729424aba6924151333.tar.zst
WarpX-8836f4a4dc38898c6b628729424aba6924151333.zip
Allow extra particle attributes (besides ux, uy, uz and w) to be set at particle creation in AddNParticles() (#2115)
* exposes AddRealComp to Python to allow extra particle attributes to be added at runtime; also includes a new function to grab a particle data array from the name of the component rather than the index * added functionality to AddNParticles() to allow extra particle attributes to also be set during particle creation * added function to get index of a particle component given the PID name * changed new get component index and get_particle_arrays_from_comp_name functions to take species name as argument rather than species id * changed warpx_addRealComp to accept a species name as input and only add the new component for that species * added a test of the pywarpx bridge to get particle data and add new particle attributes at runtime * changed all particle interacting functions in libwarpx to use the species name rather than id, also changed the functions to get particle array data to use the component name rather than index * updated test according to PR #2119 changes * removed unneeded BL_ASSERT(nattr == 1) statement * fixed bug in add_particles to correctly determine the number of extra attributes * fixed bug in AddNParticles if fewer attribute values are passed than the number of extra arrays for the species * use isinstance(attr, ndarray) rather than type(attr) is np.ndarray * generalize_runtime_comps_io * fix OpenPMD * fix OpenPMD * fix plot flags in WritePlotFile * fix offset and comment * changed extra pid test to not use an underscore in the pid name * switched _libwarpx.py::add_particles to use kwargs to accept the weight and extra attribute arrays * License update in test file Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> * fix typo * added a test with unique_particles=False * Apply suggestions from code review Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> * updated docstring and comments Co-authored-by: atmyers <atmyers2@gmail.com> Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Python/WarpXWrappers.cpp')
-rw-r--r--Source/Python/WarpXWrappers.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/Python/WarpXWrappers.cpp b/Source/Python/WarpXWrappers.cpp
index 16005ed43..24ee25dcf 100644
--- a/Source/Python/WarpXWrappers.cpp
+++ b/Source/Python/WarpXWrappers.cpp
@@ -132,6 +132,14 @@ extern "C"
return PIdx::nattribs;
}
+ int warpx_nCompsSpecies(const char* char_species_name)
+ {
+ auto & mypc = WarpX::GetInstance().GetPartContainer();
+ const std::string species_name(char_species_name);
+ auto & myspc = mypc.GetParticleContainerFromName(species_name);
+ return myspc.NumRealComps();
+ }
+
int warpx_SpaceDim()
{
return AMREX_SPACEDIM;