Added C interface
This commit is contained in:
parent
b59b6716a6
commit
69e1a7ad9d
3 changed files with 63 additions and 1 deletions
30
gravity.cpp
Normal file
30
gravity.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include <span>
|
||||
#include "../grapite/etics_interface.h"
|
||||
#include "../grapite/particle_manager.h"
|
||||
|
||||
static grapite::Active_particles* particles_i;
|
||||
static grapite::Etics_interface* etics_interface;
|
||||
|
||||
extern "C"
|
||||
void etics_external_init(const int n_total)
|
||||
{
|
||||
particles_i = new grapite::Active_particles{n_total};
|
||||
etics_interface = new grapite::Etics_interface{n_total};
|
||||
}
|
||||
|
||||
extern "C"
|
||||
void etics_external_grav(const double* const A, const int n_act, double x_act[][3], double pot_act[], double a_act[][3])
|
||||
{
|
||||
// Load coefficients
|
||||
std::span A_complex{reinterpret_cast<const Complex*>(A), 1024};
|
||||
std::copy(begin(A_complex), end(A_complex), etics_interface->A_h);
|
||||
etics_interface->GetGpuLock();
|
||||
etics_interface->SendCoeffsToGPU();
|
||||
etics_interface->ReleaseGpuLock();
|
||||
|
||||
// Calculate potentials and forces
|
||||
particles_i->ni_core = 0;
|
||||
particles_i->ni_total = n_act;
|
||||
particles_i->flush_memory();
|
||||
etics_interface->calculate_gravity(particles_i, grapite::Selector::halo, 0, pot_act, reinterpret_cast<vec3*>(a_act));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue