173 lines
3.6 KiB
C++
173 lines
3.6 KiB
C++
#include <algorithm>
|
|
#include <cassert>
|
|
|
|
#include "yebisu_g6.h"
|
|
#include "g6util.h"
|
|
|
|
#define NIMAX 1048576
|
|
#define MAXDEV 4
|
|
|
|
#ifndef NB_FLAG
|
|
#define NB_FLAG 0
|
|
#endif
|
|
|
|
extern "C"
|
|
{
|
|
static int sort_mode = 0;
|
|
static double eps2_buf[MAXDEV][NIMAX];
|
|
static int nnb_buf[MAXDEV][NIMAX];
|
|
|
|
void g6_open(int clusterid){
|
|
assert(clusterid < MAXDEV);
|
|
assert(NIMAX >= g6_npipes());
|
|
yebisu_g6_open(clusterid);
|
|
}
|
|
void g6_close(int clusterid){
|
|
yebisu_g6_close(clusterid);
|
|
}
|
|
void g6_set_tunit(int newtunit){}
|
|
void g6_set_xunit(int newxunit){}
|
|
int g6_set_j_particle(
|
|
int clusterid,
|
|
int address,
|
|
int index,
|
|
double tj,
|
|
double dtj,
|
|
double mass,
|
|
double a2by18[3],
|
|
double a1by6[3],
|
|
double aby2[3],
|
|
double v[3],
|
|
double x[3])
|
|
{
|
|
yebisu_g6_push_jp(clusterid, x, v, aby2, a1by6, mass, tj, index, address);
|
|
return 0;
|
|
}
|
|
void g6_set_ti(int clusterid, double ti){
|
|
yebisu_g6_set_ti(clusterid, ti);
|
|
}
|
|
void g6calc_firsthalf0(
|
|
int clusterid,
|
|
int nj,
|
|
int ni,
|
|
int index[],
|
|
double xi[][3],
|
|
double vi[][3],
|
|
double fold[][3],
|
|
double jold[][3],
|
|
double phiold[],
|
|
double *eps2,
|
|
double h2[],
|
|
int mode)
|
|
{
|
|
double *eps2_ptr = eps2;
|
|
if(mode){ // constand eps2
|
|
eps2_ptr = eps2_buf[clusterid];
|
|
for(int i=0; i<ni; i++){
|
|
eps2_ptr[i] = *eps2;
|
|
}
|
|
}
|
|
|
|
yebisu_g6_set_ip(clusterid, ni, xi, vi, eps2_ptr, h2, index);
|
|
yebisu_g6_launch_gravity(clusterid, ni, nj, NB_FLAG);
|
|
}
|
|
void g6calc_firsthalf(
|
|
int clusterid,
|
|
int nj,
|
|
int ni,
|
|
int index[],
|
|
double xi[][3],
|
|
double vi[][3],
|
|
double fold[][3],
|
|
double jold[][3],
|
|
double phiold[],
|
|
double eps2,
|
|
double h2[])
|
|
{
|
|
g6calc_firsthalf0(clusterid, nj, ni, index, xi, vi, fold, jold, phiold, &eps2, h2, 1);
|
|
}
|
|
int g6calc_lasthalf(
|
|
int clusterid,
|
|
int nj,
|
|
int ni,
|
|
int index[],
|
|
double xi[][3],
|
|
double vi[][3],
|
|
double eps2,
|
|
double h2[],
|
|
double acc[][3],
|
|
double jerk[][3],
|
|
double pot[])
|
|
{
|
|
yebisu_g6_get_force(clusterid, ni, acc, jerk, pot, nnb_buf[clusterid]);
|
|
return 0;
|
|
}
|
|
int g6calc_lasthalf0(
|
|
int clusterid,
|
|
int nj,
|
|
int ni,
|
|
int index[],
|
|
double xi[][3],
|
|
double vi[][3],
|
|
double *eps2,
|
|
double h2[],
|
|
double acc[][3],
|
|
double jerk[][3],
|
|
double pot[],
|
|
int mode)
|
|
{
|
|
yebisu_g6_get_force(clusterid, ni, acc, jerk, pot, nnb_buf[clusterid]);
|
|
return 0;
|
|
}
|
|
int g6calc_lasthalf2(
|
|
int clusterid,
|
|
int nj,
|
|
int ni,
|
|
int index[],
|
|
double xi[][3],
|
|
double vi[][3],
|
|
double eps2,
|
|
double h2[],
|
|
double acc[][3],
|
|
double jerk[][3],
|
|
double pot[],
|
|
int nnbindex[])
|
|
{
|
|
assert(NB_FLAG);
|
|
yebisu_g6_get_force(clusterid, ni, acc, jerk, pot, nnbindex);
|
|
return 0;
|
|
}
|
|
int g6_read_neighbour_list(int clusterid){
|
|
assert(NB_FLAG);
|
|
yebisu_g6_receive_neighbor_list(clusterid);
|
|
return 0;
|
|
}
|
|
int g6_get_neighbour_list(
|
|
int clusterid,
|
|
int ipipe,
|
|
int maxlength,
|
|
int *nblen,
|
|
int nbl[])
|
|
{
|
|
assert(NB_FLAG);
|
|
yebisu_g6_get_neighbor_list(clusterid, ipipe, maxlength, nblen, nbl);
|
|
const int nnb = *nblen;
|
|
if(nnb < 0) return -1;
|
|
if(sort_mode){
|
|
std::sort(nbl, nbl+nnb);
|
|
}
|
|
return 0;
|
|
}
|
|
void g6_set_neighbour_list_sort_mode(int mode){
|
|
sort_mode = mode;
|
|
}
|
|
int g6_get_neighbour_list_sort_mode(void){
|
|
return sort_mode;
|
|
}
|
|
int g6_npipes(void){
|
|
return yebisu_g6_get_nimax();
|
|
}
|
|
int g6_getnjmax(int clusterid){
|
|
return yebisu_g6_get_njmax();
|
|
}
|
|
}
|