Skip to content

Commit

Permalink
add access to particle id
Browse files Browse the repository at this point in the history
  • Loading branch information
jcurtis2 committed Sep 29, 2023
1 parent 0de7795 commit 85aa967
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/aero_particle.F90
Original file line number Diff line number Diff line change
Expand Up @@ -479,4 +479,19 @@ subroutine f_aero_particle_n_orig_part( &

end subroutine

subroutine f_aero_particle_id( &
aero_particle_ptr_c, &
id &
) bind(C)

type(aero_particle_t), pointer :: aero_particle_ptr_f => null()
type(c_ptr), intent(in) :: aero_particle_ptr_c
integer(c_int), intent(out) :: id

call c_f_pointer(aero_particle_ptr_c, aero_particle_ptr_f)

id = aero_particle_ptr_f%id

end subroutine

end module
10 changes: 10 additions & 0 deletions src/aero_particle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern "C" void f_aero_particle_asymmetry(const void *aero_particle_ptr, double
extern "C" void f_aero_particle_greatest_create_time(const void *aero_particle_ptr, double *val) noexcept;
extern "C" void f_aero_particle_least_create_time(const void *aero_particle_ptr, double *val) noexcept;
extern "C" void f_aero_particle_n_orig_part(const void *aero_particle_ptr, void *arr_data, const int *arr_size) noexcept;
extern "C" void f_aero_particle_id(const void *aero_particle_ptr, int *val) noexcept;

namespace py = pybind11;
struct AeroParticle {
Expand Down Expand Up @@ -335,4 +336,13 @@ struct AeroParticle {
return val;
}

static auto id(const AeroParticle &self) {
int val;
f_aero_particle_id(
self.ptr.f_arg(),
&val
);
return val;
}

};
1 change: 1 addition & 0 deletions src/pypartmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ PYBIND11_MODULE(_PyPartMC, m) {
"First time a constituent was created (s).")
.def_property_readonly("greatest_create_time", AeroParticle::greatest_create_time,
"Last time a constituent was created (s).")
.def_property_readonly("id", AeroParticle::id, "Unique ID number.")
.def("mobility_diameter", AeroParticle::mobility_diameter,
"Mobility diameter of the particle (m).")
.def_property_readonly("density", AeroParticle::density,
Expand Down

0 comments on commit 85aa967

Please sign in to comment.