Beispiel #1
0
void MTDebugInit()
{
//	json_debug_init();
//	pthread_t thread = pthread_create(&thread, NULL, &json_debug_dump_thread, (void *)NULL);
//	pSendDebugMsg = SendDebugMsg;
	kdInit(0);
}
Beispiel #2
0
int main(int argc,char **argv)
{
	KD kd;
	SMX smx;
	int nBucket,nSmooth,i,j;
	FILE *fp;
	float fPeriod[3];
	float period;

   	nBucket = 16;
	nSmooth = 24;

	if ( argc < 4 || argc > 5 ) {
		fprintf(stderr,"USAGE: smooth PMcrd.DAT PMcrs.DAT [stars.dat] rho_smooth.den\n");
		exit(1);
	}

	kdInit(&kd,nBucket);

	/* read in here */
	if ( argc == 4 ) {
		kdReadART(kd,argv[1],argv[2],&period);
	} else {
		kdReadARTStars(kd,argv[1],argv[2],argv[3],&period);
	}

	fPeriod[0] = period;
	fPeriod[1] = period;
	fPeriod[2] = period;

	printf("bulding tree...\n");
	kdBuildTree(kd);
	printf("initializing density...\n");
	smInit(&smx,kd,nSmooth,fPeriod);
	printf("smoothing density...\n");
	smSmooth(smx,smDensitySym);
	printf("ordering tree...\n");
	kdOrder(kd);

	printf("writing output...\n");

	/* write density file */
	if ( argc == 4 ) {
		fp = fopen(argv[3], "w" );
	} else {
		fp = fopen(argv[4],"wb");	
	}
	assert(fp != NULL);
	smOutDensityBin(smx,fp);
	fclose(fp);

	smFinish(smx);
	kdFinish(kd);
	return 0;
	}
Beispiel #3
0
/*
* supInit
*
* Purpose:
*
* Initializes support subset related resources including kldbg subset.
*
* Must be called once during program startup
*
*/
VOID supInit(
	BOOL IsFullAdmin
	)
{
	RtlSecureZeroMemory(&g_enumParams, sizeof(g_enumParams));

	supQueryKnownDlls();
	kdInit(IsFullAdmin);

	if (IsFullAdmin != FALSE) {
		g_enumParams.scmSnapshot = supCreateSCMSnapshot(&g_enumParams.scmNumberOfEntries);
	}

	g_enumParams.sapiDB = sapiCreateSetupDBSnapshot();

	g_pObjectTypesInfo = supGetObjectTypesInfo();
}
Beispiel #4
0
/*==========================================================================*/
PyObject *kdinit(PyObject *self, PyObject *args)
{
    int nBucket;
    int i;

    PyObject *pos;  // Nx3 Numpy array of positions
    PyObject *mass; // Nx1 Numpy array of masses

    if (!PyArg_ParseTuple(args, "OOi", &pos, &mass, &nBucket))
        return NULL;

    int bitdepth = getBitDepth(pos);
    if(bitdepth==0) {
        PyErr_SetString(PyExc_ValueError, "Unsupported array dtype for kdtree");
        return NULL;
    }
    if(bitdepth!=getBitDepth(mass)) {
        PyErr_SetString(PyExc_ValueError, "pos and mass arrays must have matching dtypes for kdtree");
        return NULL;
    }

    if(bitdepth==64) {
        if(checkArray<double>(pos, "pos")) return NULL;
        if(checkArray<double>(mass, "mass")) return NULL;
    } else {
        if(checkArray<float>(pos, "pos")) return NULL;
        if(checkArray<float>(mass, "mass")) return NULL;
    }

    KD kd = (KD)malloc(sizeof(*kd));
    kdInit(&kd, nBucket);

    int nbodies = PyArray_DIM(pos, 0);

    kd->nParticles = nbodies;
    kd->nActive = nbodies;
    kd->nBitDepth = bitdepth;
    kd->pNumpyPos = pos;
    kd->pNumpyMass = mass;
    kd->pNumpySmooth = NULL;
    kd->pNumpyDen = NULL;
    kd->pNumpyQty = NULL;
    kd->pNumpyQtySmoothed = NULL;

    Py_INCREF(pos);
    Py_INCREF(mass);


    Py_BEGIN_ALLOW_THREADS


    // Allocate particles
    kd->p = (PARTICLE *)malloc(kd->nActive*sizeof(PARTICLE));
    assert(kd->p != NULL);

    for (i=0; i < nbodies; i++)
    {
        kd->p[i].iOrder = i;
        kd->p[i].iMark = 1;
    }

    if(bitdepth==64)
        kdBuildTree<double>(kd);
    else
        kdBuildTree<float>(kd);

    Py_END_ALLOW_THREADS

    return PyCapsule_New((void *)kd, NULL, NULL);
}
Beispiel #5
0
void
calc_dudt()
{
  struct gas_particle *gp ;
  KD kd;
  int n_smooth = 64;
  float period[MAXDIM];
  int i;
  double rsys, vsys;

  if (boxlist[0].ngas != header.nsph) {
    printf("<Warning, box 0 does not contain all particles, %s>\n", title);
    printf("<Reloading box 0, %s>\n", title);
    loadall();
  }
  if (!dkernel_loaded){
    dkernel_load() ;
  }
  if (!redshift_loaded){
    load_redshift() ;
  }
  if (!cool_loaded ){
    load_cool() ;
  }
  if (!visc_loaded) {
    load_visc();
  }
  if (!divv_loaded) {
    divv();
  }
  if (!meanmwt_loaded) {
    meanmwt_func() ;
  }

  rsys = kpcunit/1.e3 ;
  vsys = sqrt(msolunit/kpcunit*(GCGS*MSOLG/KPCCM))/1.e5 ;
  hsys = rsys*hubble_constant/vsys;


  if (dudt != NULL){
      free(dudt);
  }
  if (boxlist[0].ngas != 0) {
    dudt = (double *)malloc(boxlist[0].ngas *sizeof(*dudt));
    if (dudt == NULL) {
      printf("<sorry, no memory for hsmdivv, %s>\n",title) ;
      return ;
    }
  }
  else
    dudt = NULL;
    
  if (box0_smx) {
    kdFinish(box0_smx->kd);
    smFinish(box0_smx);
    box0_smx = NULL;
  }

  printf("<Building tree, %s>\n", title);
  kdInit(&kd);
  kdReadBox(kd, &boxlist[0], 0, 1, 0);
  kdBuildTree(kd);
  if (periodic)
    period[0] = period[1] = period[2] = period_size;
  else
    period[0] = period[1] = period[2] = 1e37;

  printf("<Calculating dudt, %s>\n", title);

  smInit(&box0_smx,kd,n_smooth,period);
  smSetBallh(box0_smx);
  smReSmooth(box0_smx,smDudtSym);

  kdOrder(kd);
  for(i = 0; i < boxlist[0].ngas; i++) {
    gp = boxlist[0].gp[i];
    dudt[i] = 0.5 * kd->p[i].fDensity;
  }
  dudt_loaded = YES ;
  starform_loaded = NO ;

}