diff --git a/src/simpmesh.c b/src/simpmesh.c index 68e204d7..29928cf0 100644 --- a/src/simpmesh.c +++ b/src/simpmesh.c @@ -336,8 +336,10 @@ void mesh_srcdetelem(tetmesh *mesh,mcconfig *cfg){ mesh->srcelemlen=0; mesh->detelemlen=0; for(i=0;ine;i++){ - if(mesh->type[i]==-1) /*number of elements in the initial candidate list*/ + if(mesh->type[i]==-1){ /*number of elements in the initial candidate list*/ mesh->srcelemlen++; + cfg->e0=(cfg->e0==0) ? i+1 : cfg->e0; + } if(mesh->type[i]==-2){ /*number of elements in the initial candidate list*/ mesh->detelemlen++; cfg->isextdet=1; @@ -598,7 +600,7 @@ void tracer_prep(raytracer *tracer,mcconfig *cfg){ tracer_build(tracer); else MESH_ERROR("tracer is not associated with a mesh"); - }else if(cfg->srctype==stPencil && cfg->e0>0){ + }else if( (cfg->srctype==stPencil || cfg->srctype==stIsotropic || cfg->srctype==stCone || cfg->srctype==stArcSin) && cfg->e0>0){ int eid=cfg->e0-1; float3 vecS={0.f}, *nodes=tracer->mesh->node, vecAB, vecAC, vecN; int ea,eb,ec; diff --git a/src/tettracing.c b/src/tettracing.c index 8607f534..6f39b21a 100644 --- a/src/tettracing.c +++ b/src/tettracing.c @@ -1540,9 +1540,8 @@ void launchphoton(mcconfig *cfg, ray *r, tetmesh *mesh, RandType *ran, RandType r->vec.y=stheta*sphi; r->vec.z=ctheta; canfocus=0; - if(cfg->srctype==stIsotropic) - if(r->eid>0) - return; + if(r->eid>0) + return; }else if(cfg->srctype==stZGaussian){ float ang,stheta,ctheta,sphi,cphi; ang=TWO_PI*rand_uniform01(ran); //next arimuth angle @@ -1598,7 +1597,7 @@ void launchphoton(mcconfig *cfg, ray *r, tetmesh *mesh, RandType *ran, RandType vec_mult_add(&(r->p0),&(r->vec),1.f,EPS,&(r->p0)); - /*Caluclate intial element id and bary-centric coordinates*/ + /*Caluclate intial element id and bary-centric coordinates for area sources - position changes everytime*/ float3 vecS={0.f}, *nodes=mesh->node, vecAB, vecAC, vecN; int is,i,ea,eb,ec; float bary[4]={0.f};