Skip to content

Commit

Permalink
use char array for boundary condition input
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 24, 2018
1 parent 817609e commit a31b5cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/mcx_core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1744,9 +1744,8 @@ void mcx_run_simulation(Config *cfg,GPUInfo *gpu){
param.idx1dorig=(int(floorf(p0.z))*dimlen.y+int(floorf(p0.y))*dimlen.x+int(floorf(p0.x)));
param.mediaidorig=(cfg->vol[param.idx1dorig] & MED_MASK);
}
memcpy(&(param.bc),&(cfg->bc),sizeof(uint2));
memcpy(&(param.bc),cfg->bc,8);
Vvox=cfg->steps.x*cfg->steps.y*cfg->steps.z; /*Vvox: voxel volume in mm^3*/

if(cfg->seed>0)
srand(cfg->seed+threadid);
else
Expand Down
10 changes: 5 additions & 5 deletions src/mcx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void mcx_initcfg(Config *cfg){
cfg->isspecular=0;
cfg->dx=cfg->dy=cfg->dz=NULL;
cfg->gscatter=1e9; /** by default, honor anisotropy for all scattering, use --gscatter to reduce it */
memset(&(cfg->bc),0,sizeof(uint2));
memset(cfg->bc,0,8);
memset(&(cfg->srcparam1),0,sizeof(float4));
memset(&(cfg->srcparam2),0,sizeof(float4));
memset(cfg->deviceid,0,MAX_DEVICE);
Expand Down Expand Up @@ -712,7 +712,7 @@ void mcx_prepdomain(char *filename, Config *cfg){
if(cfg->deviceid[i]=='0')
cfg->deviceid[i]='\0';

bc=(char*)(&cfg->bc);
bc=cfg->bc;
for(int i=0;i<6;i++)
if(bc[i]>='A' && mcx_lookupindex(bc+i,boundarycond))
MCX_ERROR(-4,"unknown boundary condition specifier");
Expand Down Expand Up @@ -1734,7 +1734,7 @@ void mcx_parsecmd(int argc, char* argv[], Config *cfg){
}
}
if(argv[i][1]<='z' && argv[i][1]>='A')
flagset[(int)(argv[i][1])]=1;
flagset[(int)(argv[i][1])]=1;
switch(argv[i][1]){
case 'h':
mcx_usage(cfg,argv[0]);
Expand Down Expand Up @@ -1779,9 +1779,9 @@ void mcx_parsecmd(int argc, char* argv[], Config *cfg){
i=mcx_readarg(argc,argv,i,&(cfg->isreflect),"char");
cfg->isref3=cfg->isreflect;
if(cfg->isreflect)
memset(&(cfg->bc),bcReflect,sizeof(uint2));
memset(cfg->bc,bcReflect,6);
else
memset(&(cfg->bc),bcAbsorb,sizeof(uint2));
memset(cfg->bc,bcAbsorb,6);
break;
case 'B':
i=mcx_readarg(argc,argv,i,&(cfg->bc),"string");
Expand Down
2 changes: 1 addition & 1 deletion src/mcx_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ typedef struct MCXConfig{
float *exportdebugdata; /**<pointer to the buffer where the photon trajectory data are stored*/
uint mediabyte; /**< how many bytes per media index, mcx supports 1, 2 and 4, 4 is the default*/
float *dx, *dy, *dz; /**< anisotropic voxel spacing for x,y,z axis */
uint2 bc; /**<boundary condition flag*/
char bc[8]; /**<boundary condition flag for [-x,+x,-y,+y,-z,+z,unused,unused] */
} Config;

#ifdef __cplusplus
Expand Down

0 comments on commit a31b5cd

Please sign in to comment.