Skip to content

Commit

Permalink
Wrap functions getNprocs / getMyProc
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Jul 12, 2023
1 parent c198175 commit bebd3ff
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Examples/Tests/particle_data_python/PICMI_inputs_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def add_particles():
w=w, newPid=newPid, unique_particles=args.unique
)

callbacks.installbeforestep(add_particles)
sim.extension.libwarpx_so.add_python_callback( "installbeforestep", add_particles )

##########################
# simulation run
Expand Down
4 changes: 2 additions & 2 deletions Python/pywarpx/_libwarpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ def getNProcs(self):
Get the number of processors
'''
return self.libwarpx_so.warpx_getNProcs()
return self.libwarpx_so.getNProcs()

def getMyProc(self):
'''
Get the number of the processor
'''
return self.libwarpx_so.warpx_getMyProc()
return self.libwarpx_so.getMyProc()

def get_nattr(self):
'''
Expand Down
3 changes: 0 additions & 3 deletions Source/Python/WarpXWrappers.H
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ extern "C" {

int warpx_finestLevel ();

int warpx_getMyProc ();
int warpx_getNProcs ();

void warpx_setPotentialEB (const char * char_potential);

void mypc_Redistribute ();
Expand Down
8 changes: 0 additions & 8 deletions Source/Python/WarpXWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,6 @@
return warpx.finestLevel();
}

int warpx_getMyProc () {
return amrex::ParallelDescriptor::MyProc();
}

int warpx_getNProcs () {
return amrex::ParallelDescriptor::NProcs();
}

void warpx_setPotentialEB (const char * char_potential) {
WarpX& warpx = WarpX::GetInstance();
const std::string potential(char_potential);
Expand Down
4 changes: 4 additions & 0 deletions Source/Python/pyWarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ PYBIND11_MODULE(PYWARPX_MODULE_NAME, m) {
py::return_value_policy::reference,
"Return a reference to the WarpX object.");

// Expose functions to get the processor number
m.def("getNProcs", [](){amrex::ParallelDescriptor::NProcs();} );
m.def("getMyProc", [](){amrex::ParallelDescriptor::MyProc();} );

// Expose the python callback function installation and removal functions
m.def("add_python_callback", &InstallPythonCallback);
m.def("remove_python_callback", &ClearPythonCallback);
Expand Down

0 comments on commit bebd3ff

Please sign in to comment.