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; }
/*==========================================================================*/ PyObject *nn_stop(PyObject *self, PyObject *args) { KD kd; SMX smx; PyObject *kdobj, *smxobj; PyArg_ParseTuple(args, "OO", &kdobj, &smxobj); kd = (KD)PyCapsule_GetPointer(kdobj,NULL); smx = (SMX)PyCapsule_GetPointer(smxobj,NULL); smFinish(smx); return Py_None; }
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 ; }