Skip to content

Commit c9b50ea

Browse files
committed
Particle Runtime Args: New Bindings
1 parent b41b83d commit c9b50ea

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Base/PODVector.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ void make_PODVector(py::module &m, std::string typestr, std::string allocstr)
6161
.def(py::init<>())
6262
.def(py::init<std::size_t>(), py::arg("size"))
6363
.def(py::init<PODVector_type&>(), py::arg("other"))
64+
.def("assign", [](PODVector_type & pv, T const & value){
65+
pv.assign(pv.size(), value);
66+
}, py::arg("value"), "assign the same value to every element")
6467
.def("push_back", py::overload_cast<const T&>(&PODVector_type::push_back))
6568
.def("pop_back", &PODVector_type::pop_back)
6669
.def("clear", &PODVector_type::clear)

src/Particle/ParticleContainer.H

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,23 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
201201
.def_property_readonly("num_runtime_int_comps", &ParticleContainerType::NumRuntimeIntComps,
202202
"The number of runtime Int components in SoA")
203203

204+
204205
.def_property_readonly("num_position_components", [](const py::object&){ return AMREX_SPACEDIM; })
205206
.def_property_readonly("byte_spread", &ParticleContainerType::ByteSpread)
206207

208+
// runtime components
209+
.def("add_real_comp", &ParticleContainerType::template AddRealComp<bool>,
210+
py::arg("communicate")=true, "add a new runtime component with type Real")
211+
.def("add_int_comp", &ParticleContainerType::template AddIntComp<bool>,
212+
py::arg("communicate")=true, "add a new runtime component with type Int")
213+
214+
.def("resize_runtime_real_comp", &ParticleContainerType::ResizeRuntimeRealComp,
215+
py::arg("new_size"), py::arg("communicate"),
216+
"Resize the Real runtime components (SoA)")
217+
.def("resize_runtime_int_comp", &ParticleContainerType::ResizeRuntimeIntComp,
218+
py::arg("new_size"), py::arg("communicate"),
219+
"Resize the Int runtime components (SoA)")
220+
207221
.def_property_readonly("finest_level", &ParticleContainerBase::finestLevel)
208222

209223
// ParticleContainer ( const ParticleContainer &) = delete;

0 commit comments

Comments
 (0)