Fix splash2 benchmark
During the last commit of splash2 benchmark it seems before committing when we ran "make clean", it effectively undid what the patch at below link did http://www.capsl.udel.edu/splash/Download.html Fix this since without this it is not possible to build the arcane splash2 benchmark.
This commit is contained in:
parent
2fcc51c2c1
commit
0f4b39775c
135 changed files with 9862 additions and 8916 deletions
|
@ -6,7 +6,7 @@ CFLAGS := $(CFLAGS) -Wpadded -Winline -Wpointer-arith -Wsign-compare -Wendif-lab
|
||||||
LDFLAGS := -lm libpthread.a m5op_x86.o
|
LDFLAGS := -lm libpthread.a m5op_x86.o
|
||||||
|
|
||||||
BASEDIR := $(HOME)/GitSource/gem5/splash2/codes
|
BASEDIR := $(HOME)/GitSource/gem5/splash2/codes
|
||||||
MACROS := $(BASEDIR)/null_macros/c.m4.null.POSIX_BARRIER
|
MACROS := $(BASEDIR)/null_macros/c.m4.null.POSIX
|
||||||
M4 := m4 -s -Ulen -Uindex
|
M4 := m4 -s -Ulen -Uindex
|
||||||
|
|
||||||
x = *
|
x = *
|
||||||
|
|
|
@ -3,7 +3,7 @@ OBJS = code.o code_io.o load.o grav.o getparam.o util.o
|
||||||
|
|
||||||
include ../../Makefile.config
|
include ../../Makefile.config
|
||||||
|
|
||||||
stdinc.h: code.h defs.h util.h vectmath.h load.h code_io.h grav.h getparam.h stdinc.H
|
stdinc.h: code.h defs.h util.h vectmath.h load.h code_io.h grav.h getparam.h stdinc.H
|
||||||
code.o: code.C stdinc.h
|
code.o: code.C stdinc.h
|
||||||
code_io.o: code_io.C stdinc.h
|
code_io.o: code_io.C stdinc.h
|
||||||
getparam.o: getparam.C stdinc.h
|
getparam.o: getparam.C stdinc.h
|
||||||
|
|
|
@ -131,7 +131,7 @@ string defv[] = { /* DEFAULT PARAMETER VALUES */
|
||||||
|
|
||||||
static long Child_Sequence[NUM_DIRECTIONS][NSUB] =
|
static long Child_Sequence[NUM_DIRECTIONS][NSUB] =
|
||||||
{
|
{
|
||||||
{ 2, 5, 6, 1, 0, 3, 4, 7}, /* BRC_FUC */
|
{ 2, 5, 6, 1, 0, 3, 4, 7}, /* BRC_FUC */
|
||||||
{ 2, 5, 6, 1, 0, 7, 4, 3}, /* BRC_FRA */
|
{ 2, 5, 6, 1, 0, 7, 4, 3}, /* BRC_FRA */
|
||||||
{ 1, 6, 5, 2, 3, 0, 7, 4}, /* BRA_FDA */
|
{ 1, 6, 5, 2, 3, 0, 7, 4}, /* BRA_FDA */
|
||||||
{ 1, 6, 5, 2, 3, 4, 7, 0}, /* BRA_FRC */
|
{ 1, 6, 5, 2, 3, 4, 7, 0}, /* BRA_FRC */
|
||||||
|
@ -168,7 +168,7 @@ static long Child_Sequence[NUM_DIRECTIONS][NSUB] =
|
||||||
|
|
||||||
static long Direction_Sequence[NUM_DIRECTIONS][NSUB] =
|
static long Direction_Sequence[NUM_DIRECTIONS][NSUB] =
|
||||||
{
|
{
|
||||||
{ FRC_BUC, BRA_FRC, FDA_BDC, BLA_FUA, BUC_FLC, FUA_BUC, BRA_FRC, FDA_BLA },
|
{ FRC_BUC, BRA_FRC, FDA_BDC, BLA_FUA, BUC_FLC, FUA_BUC, BRA_FRC, FDA_BLA },
|
||||||
/* BRC_FUC */
|
/* BRC_FUC */
|
||||||
{ FRC_BUC, BRA_FRC, FDA_BDC, BLA_FUA, BRA_FDA, FRC_BRA, BUC_FUA, FLC_BDC },
|
{ FRC_BUC, BRA_FRC, FDA_BDC, BLA_FUA, BRA_FDA, FRC_BRA, BUC_FUA, FLC_BDC },
|
||||||
/* BRC_FRA */
|
/* BRC_FRA */
|
||||||
|
@ -242,13 +242,13 @@ int main (int argc, string argv[])
|
||||||
while ((c = getopt(argc, argv, "h")) != -1) {
|
while ((c = getopt(argc, argv, "h")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
Help();
|
Help();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Only valid option is \"-h\".\n");
|
fprintf(stderr, "Only valid option is \"-h\".\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,17 +278,17 @@ int main (int argc, string argv[])
|
||||||
printf("COMPUTETIME = %12lu\n",Global->computeend - Global->computestart);
|
printf("COMPUTETIME = %12lu\n",Global->computeend - Global->computestart);
|
||||||
printf("TRACKTIME = %12lu\n",Global->tracktime);
|
printf("TRACKTIME = %12lu\n",Global->tracktime);
|
||||||
printf("PARTITIONTIME = %12lu\t%5.2f\n",Global->partitiontime,
|
printf("PARTITIONTIME = %12lu\t%5.2f\n",Global->partitiontime,
|
||||||
((float)Global->partitiontime)/Global->tracktime);
|
((float)Global->partitiontime)/Global->tracktime);
|
||||||
printf("TREEBUILDTIME = %12lu\t%5.2f\n",Global->treebuildtime,
|
printf("TREEBUILDTIME = %12lu\t%5.2f\n",Global->treebuildtime,
|
||||||
((float)Global->treebuildtime)/Global->tracktime);
|
((float)Global->treebuildtime)/Global->tracktime);
|
||||||
printf("FORCECALCTIME = %12lu\t%5.2f\n",Global->forcecalctime,
|
printf("FORCECALCTIME = %12lu\t%5.2f\n",Global->forcecalctime,
|
||||||
((float)Global->forcecalctime)/Global->tracktime);
|
((float)Global->forcecalctime)/Global->tracktime);
|
||||||
printf("RESTTIME = %12lu\t%5.2f\n",
|
printf("RESTTIME = %12lu\t%5.2f\n",
|
||||||
Global->tracktime - Global->partitiontime -
|
Global->tracktime - Global->partitiontime -
|
||||||
Global->treebuildtime - Global->forcecalctime,
|
Global->treebuildtime - Global->forcecalctime,
|
||||||
((float)(Global->tracktime-Global->partitiontime-
|
((float)(Global->tracktime-Global->partitiontime-
|
||||||
Global->treebuildtime-Global->forcecalctime))/
|
Global->treebuildtime-Global->forcecalctime))/
|
||||||
Global->tracktime);
|
Global->tracktime);
|
||||||
MAIN_END;
|
MAIN_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,7 +462,7 @@ void startrun()
|
||||||
else {
|
else {
|
||||||
nbody = getiparam("nbody");
|
nbody = getiparam("nbody");
|
||||||
if (nbody < 1) {
|
if (nbody < 1) {
|
||||||
error("startrun: absurd nbody\n");
|
error("startrun: absurd nbody\n");
|
||||||
}
|
}
|
||||||
seed = getiparam("seed");
|
seed = getiparam("seed");
|
||||||
}
|
}
|
||||||
|
@ -527,14 +527,14 @@ void testdata()
|
||||||
r = 1 / sqrt(pow(xrand(0.0, MFRAC), -2.0/3.0) - 1);
|
r = 1 / sqrt(pow(xrand(0.0, MFRAC), -2.0/3.0) - 1);
|
||||||
/* reject radii greater than 10 */
|
/* reject radii greater than 10 */
|
||||||
while (r > 9.0) {
|
while (r > 9.0) {
|
||||||
rejects++;
|
rejects++;
|
||||||
r = 1 / sqrt(pow(xrand(0.0, MFRAC), -2.0/3.0) - 1);
|
r = 1 / sqrt(pow(xrand(0.0, MFRAC), -2.0/3.0) - 1);
|
||||||
}
|
}
|
||||||
pickshell(Pos(p), rsc * r);
|
pickshell(Pos(p), rsc * r);
|
||||||
ADDV(cmr, cmr, Pos(p));
|
ADDV(cmr, cmr, Pos(p));
|
||||||
do {
|
do {
|
||||||
x = xrand(0.0, 1.0);
|
x = xrand(0.0, 1.0);
|
||||||
y = xrand(0.0, 0.1);
|
y = xrand(0.0, 0.1);
|
||||||
|
|
||||||
} while (y > x*x * pow(1 - x*x, 3.5));
|
} while (y > x*x * pow(1 - x*x, 3.5));
|
||||||
|
|
||||||
|
@ -552,8 +552,8 @@ void testdata()
|
||||||
|
|
||||||
cp = p - halfnbody;
|
cp = p - halfnbody;
|
||||||
for (i = 0; i < NDIM; i++){
|
for (i = 0; i < NDIM; i++){
|
||||||
Pos(p)[i] = Pos(cp)[i] + offset;
|
Pos(p)[i] = Pos(cp)[i] + offset;
|
||||||
Vel(p)[i] = Vel(cp)[i];
|
Vel(p)[i] = Vel(cp)[i];
|
||||||
}
|
}
|
||||||
ADDV(cmr, cmr, Pos(p));
|
ADDV(cmr, cmr, Pos(p));
|
||||||
ADDV(cmv, cmv, Vel(p));
|
ADDV(cmv, cmv, Vel(p));
|
||||||
|
@ -579,7 +579,7 @@ void pickshell(real vec[], real rad)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
for (k = 0; k < NDIM; k++) {
|
for (k = 0; k < NDIM; k++) {
|
||||||
vec[k] = xrand(-1.0, 1.0);
|
vec[k] = xrand(-1.0, 1.0);
|
||||||
}
|
}
|
||||||
DOTVP(rsq, vec, vec);
|
DOTVP(rsq, vec, vec);
|
||||||
} while (rsq > 1.0);
|
} while (rsq > 1.0);
|
||||||
|
@ -653,7 +653,7 @@ void stepsystem(long ProcessId)
|
||||||
Cavg = (real) Cost(Global->G_root) / (real)NPROC ;
|
Cavg = (real) Cost(Global->G_root) / (real)NPROC ;
|
||||||
Local[ProcessId].workMin = (long) (Cavg * ProcessId);
|
Local[ProcessId].workMin = (long) (Cavg * ProcessId);
|
||||||
Local[ProcessId].workMax = (long) (Cavg * (ProcessId + 1)
|
Local[ProcessId].workMax = (long) (Cavg * (ProcessId + 1)
|
||||||
+ (ProcessId == (NPROC - 1)));
|
+ (ProcessId == (NPROC - 1)));
|
||||||
|
|
||||||
if ((ProcessId == 0) && (Local[ProcessId].nstep >= 2)) {
|
if ((ProcessId == 0) && (Local[ProcessId].nstep >= 2)) {
|
||||||
CLOCK(partitionstart);
|
CLOCK(partitionstart);
|
||||||
|
@ -681,7 +681,7 @@ void stepsystem(long ProcessId)
|
||||||
|
|
||||||
/* advance my bodies */
|
/* advance my bodies */
|
||||||
for (pp = Local[ProcessId].mybodytab;
|
for (pp = Local[ProcessId].mybodytab;
|
||||||
pp < Local[ProcessId].mybodytab+Local[ProcessId].mynbody; pp++) {
|
pp < Local[ProcessId].mybodytab+Local[ProcessId].mynbody; pp++) {
|
||||||
p = *pp;
|
p = *pp;
|
||||||
MULVS(dvel, Acc(p), dthf);
|
MULVS(dvel, Acc(p), dthf);
|
||||||
ADDV(vel1, Vel(p), dvel);
|
ADDV(vel1, Vel(p), dvel);
|
||||||
|
@ -691,20 +691,20 @@ void stepsystem(long ProcessId)
|
||||||
|
|
||||||
for (i = 0; i < NDIM; i++) {
|
for (i = 0; i < NDIM; i++) {
|
||||||
if (Pos(p)[i]<Local[ProcessId].min[i]) {
|
if (Pos(p)[i]<Local[ProcessId].min[i]) {
|
||||||
Local[ProcessId].min[i]=Pos(p)[i];
|
Local[ProcessId].min[i]=Pos(p)[i];
|
||||||
}
|
}
|
||||||
if (Pos(p)[i]>Local[ProcessId].max[i]) {
|
if (Pos(p)[i]>Local[ProcessId].max[i]) {
|
||||||
Local[ProcessId].max[i]=Pos(p)[i] ;
|
Local[ProcessId].max[i]=Pos(p)[i] ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOCK(Global->CountLock);
|
LOCK(Global->CountLock);
|
||||||
for (i = 0; i < NDIM; i++) {
|
for (i = 0; i < NDIM; i++) {
|
||||||
if (Global->min[i] > Local[ProcessId].min[i]) {
|
if (Global->min[i] > Local[ProcessId].min[i]) {
|
||||||
Global->min[i] = Local[ProcessId].min[i];
|
Global->min[i] = Local[ProcessId].min[i];
|
||||||
}
|
}
|
||||||
if (Global->max[i] < Local[ProcessId].max[i]) {
|
if (Global->max[i] < Local[ProcessId].max[i]) {
|
||||||
Global->max[i] = Local[ProcessId].max[i];
|
Global->max[i] = Local[ProcessId].max[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UNLOCK(Global->CountLock);
|
UNLOCK(Global->CountLock);
|
||||||
|
@ -722,9 +722,9 @@ void stepsystem(long ProcessId)
|
||||||
Global->rsize=0;
|
Global->rsize=0;
|
||||||
SUBV(Global->max,Global->max,Global->min);
|
SUBV(Global->max,Global->max,Global->min);
|
||||||
for (i = 0; i < NDIM; i++) {
|
for (i = 0; i < NDIM; i++) {
|
||||||
if (Global->rsize < Global->max[i]) {
|
if (Global->rsize < Global->max[i]) {
|
||||||
Global->rsize = Global->max[i];
|
Global->rsize = Global->max[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ADDVS(Global->rmin,Global->min,-Global->rsize/100000.0);
|
ADDVS(Global->rmin,Global->min,-Global->rsize/100000.0);
|
||||||
Global->rsize = 1.00002*Global->rsize;
|
Global->rsize = 1.00002*Global->rsize;
|
||||||
|
@ -743,7 +743,7 @@ void ComputeForces(long ProcessId)
|
||||||
vector acc1, dacc, dvel;
|
vector acc1, dacc, dvel;
|
||||||
|
|
||||||
for (pp = Local[ProcessId].mybodytab;
|
for (pp = Local[ProcessId].mybodytab;
|
||||||
pp < Local[ProcessId].mybodytab+Local[ProcessId].mynbody;pp++) {
|
pp < Local[ProcessId].mybodytab+Local[ProcessId].mynbody;pp++) {
|
||||||
p = *pp;
|
p = *pp;
|
||||||
SETV(acc1, Acc(p));
|
SETV(acc1, Acc(p));
|
||||||
Cost(p)=0;
|
Cost(p)=0;
|
||||||
|
@ -751,13 +751,13 @@ void ComputeForces(long ProcessId)
|
||||||
Local[ProcessId].myn2bcalc += Local[ProcessId].myn2bterm;
|
Local[ProcessId].myn2bcalc += Local[ProcessId].myn2bterm;
|
||||||
Local[ProcessId].mynbccalc += Local[ProcessId].mynbcterm;
|
Local[ProcessId].mynbccalc += Local[ProcessId].mynbcterm;
|
||||||
if (!Local[ProcessId].skipself) { /* did we miss self-int? */
|
if (!Local[ProcessId].skipself) { /* did we miss self-int? */
|
||||||
Local[ProcessId].myselfint++; /* count another goofup */
|
Local[ProcessId].myselfint++; /* count another goofup */
|
||||||
}
|
}
|
||||||
if (Local[ProcessId].nstep > 0) {
|
if (Local[ProcessId].nstep > 0) {
|
||||||
/* use change in accel to make 2nd order correction to vel */
|
/* use change in accel to make 2nd order correction to vel */
|
||||||
SUBV(dacc, Acc(p), acc1);
|
SUBV(dacc, Acc(p), acc1);
|
||||||
MULVS(dvel, dacc, dthf);
|
MULVS(dvel, dacc, dthf);
|
||||||
ADDV(Vel(p), Vel(p), dvel);
|
ADDV(Vel(p), Vel(p), dvel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -797,29 +797,29 @@ void find_my_bodies(nodeptr mycell, long work, long direction, long ProcessId)
|
||||||
if (Type(mycell) == LEAF) {
|
if (Type(mycell) == LEAF) {
|
||||||
l = (leafptr) mycell;
|
l = (leafptr) mycell;
|
||||||
for (i = 0; i < l->num_bodies; i++) {
|
for (i = 0; i < l->num_bodies; i++) {
|
||||||
if (work >= Local[ProcessId].workMin - .1) {
|
if (work >= Local[ProcessId].workMin - .1) {
|
||||||
if ((Local[ProcessId].mynbody+2) > maxmybody) {
|
if((Local[ProcessId].mynbody+2) > maxmybody) {
|
||||||
error("find_my_bodies: Processor %ld needs more than %ld bodies; increase fleaves\n", ProcessId, maxmybody);
|
error("find_my_bodies: Processor %ld needs more than %ld bodies; increase fleaves\n", ProcessId, maxmybody);
|
||||||
}
|
}
|
||||||
Local[ProcessId].mybodytab[Local[ProcessId].mynbody++] =
|
Local[ProcessId].mybodytab[Local[ProcessId].mynbody++] =
|
||||||
Bodyp(l)[i];
|
Bodyp(l)[i];
|
||||||
}
|
}
|
||||||
work += Cost(Bodyp(l)[i]);
|
work += Cost(Bodyp(l)[i]);
|
||||||
if (work >= Local[ProcessId].workMax-.1) {
|
if (work >= Local[ProcessId].workMax-.1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (i = 0; (i < NSUB) && (work < (Local[ProcessId].workMax - .1)); i++){
|
for(i = 0; (i < NSUB) && (work < (Local[ProcessId].workMax - .1)); i++){
|
||||||
qptr = Subp(mycell)[Child_Sequence[direction][i]];
|
qptr = Subp(mycell)[Child_Sequence[direction][i]];
|
||||||
if (qptr!=NULL) {
|
if (qptr!=NULL) {
|
||||||
if ((work+Cost(qptr)) >= (Local[ProcessId].workMin -.1)) {
|
if ((work+Cost(qptr)) >= (Local[ProcessId].workMin -.1)) {
|
||||||
find_my_bodies(qptr,work, Direction_Sequence[direction][i],
|
find_my_bodies(qptr,work, Direction_Sequence[direction][i],
|
||||||
ProcessId);
|
ProcessId);
|
||||||
}
|
}
|
||||||
work += Cost(qptr);
|
work += Cost(qptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -853,8 +853,8 @@ void setbound()
|
||||||
|
|
||||||
for (p = bodytab; p < bodytab+nbody; p++) {
|
for (p = bodytab; p < bodytab+nbody; p++) {
|
||||||
for (i=0; i<NDIM;i++) {
|
for (i=0; i<NDIM;i++) {
|
||||||
if (Pos(p)[i]<Local[0].min[i]) Local[0].min[i]=Pos(p)[i] ;
|
if (Pos(p)[i]<Local[0].min[i]) Local[0].min[i]=Pos(p)[i] ;
|
||||||
if (Pos(p)[i]>Local[0].max[i]) Local[0].max[i]=Pos(p)[i] ;
|
if (Pos(p)[i]>Local[0].max[i]) Local[0].max[i]=Pos(p)[i] ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,9 @@ void initoutput()
|
||||||
{
|
{
|
||||||
printf("\n\t\t%s\n\n", headline);
|
printf("\n\t\t%s\n\n", headline);
|
||||||
printf("%10s%10s%10s%10s%10s%10s%10s%10s\n",
|
printf("%10s%10s%10s%10s%10s%10s%10s%10s\n",
|
||||||
"nbody", "dtime", "eps", "tol", "dtout", "tstop","fcells","NPROC");
|
"nbody", "dtime", "eps", "tol", "dtout", "tstop","fcells","NPROC");
|
||||||
printf("%10ld%10.5f%10.4f%10.2f%10.3f%10.3f%10.2f%10ld\n\n",
|
printf("%10ld%10.5f%10.4f%10.2f%10.3f%10.3f%10.2f%10ld\n\n",
|
||||||
nbody, dtime, eps, tol, dtout, tstop, fcells, NPROC);
|
nbody, dtime, eps, tol, dtout, tstop, fcells, NPROC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -157,7 +157,7 @@ void diagnostics(long ProcessId)
|
||||||
CLRV(Local[ProcessId].mycmphase[1]);
|
CLRV(Local[ProcessId].mycmphase[1]);
|
||||||
CLRV(Local[ProcessId].myamvec);
|
CLRV(Local[ProcessId].myamvec);
|
||||||
for (pp = Local[ProcessId].mybodytab+Local[ProcessId].mynbody -1;
|
for (pp = Local[ProcessId].mybodytab+Local[ProcessId].mynbody -1;
|
||||||
pp >= Local[ProcessId].mybodytab; pp--) {
|
pp >= Local[ProcessId].mybodytab; pp--) {
|
||||||
p= *pp;
|
p= *pp;
|
||||||
Local[ProcessId].mymtot += Mass(p);
|
Local[ProcessId].mymtot += Mass(p);
|
||||||
DOTVP(velsq, Vel(p), Vel(p));
|
DOTVP(velsq, Vel(p), Vel(p));
|
||||||
|
@ -181,9 +181,9 @@ void diagnostics(long ProcessId)
|
||||||
+ Local[ProcessId].myetot[2];
|
+ Local[ProcessId].myetot[2];
|
||||||
if (Local[ProcessId].mymtot!=0){
|
if (Local[ProcessId].mymtot!=0){
|
||||||
DIVVS(Local[ProcessId].mycmphase[0], Local[ProcessId].mycmphase[0],
|
DIVVS(Local[ProcessId].mycmphase[0], Local[ProcessId].mycmphase[0],
|
||||||
Local[ProcessId].mymtot);
|
Local[ProcessId].mymtot);
|
||||||
DIVVS(Local[ProcessId].mycmphase[1], Local[ProcessId].mycmphase[1],
|
DIVVS(Local[ProcessId].mycmphase[1], Local[ProcessId].mycmphase[1],
|
||||||
Local[ProcessId].mymtot);
|
Local[ProcessId].mymtot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ typedef struct _node {
|
||||||
long level;
|
long level;
|
||||||
struct _node *parent; /* ptr to parent of this node in tree */
|
struct _node *parent; /* ptr to parent of this node in tree */
|
||||||
long child_num; /* Index that this node should be put
|
long child_num; /* Index that this node should be put
|
||||||
at in parent cell */
|
at in parent cell */
|
||||||
} node;
|
} node;
|
||||||
|
|
||||||
typedef node* nodeptr;
|
typedef node* nodeptr;
|
||||||
|
|
|
@ -119,7 +119,7 @@ long scanbind(string bvec[], string name)
|
||||||
|
|
||||||
for (i = 0; bvec[i] != NULL; i++)
|
for (i = 0; bvec[i] != NULL; i++)
|
||||||
if (matchname(bvec[i], name))
|
if (matchname(bvec[i], name))
|
||||||
return (i);
|
return (i);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ string extrvalue(string arg)
|
||||||
ap = (char *) arg;
|
ap = (char *) arg;
|
||||||
while (*ap != '\0')
|
while (*ap != '\0')
|
||||||
if (*ap++ == '=')
|
if (*ap++ == '=')
|
||||||
return ((string) ap);
|
return ((string) ap);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ void gravsub(register nodeptr p, long ProcessId)
|
||||||
mor3 = phii / Local[ProcessId].drsq;
|
mor3 = phii / Local[ProcessId].drsq;
|
||||||
MULVS(ai, Local[ProcessId].dr, mor3);
|
MULVS(ai, Local[ProcessId].dr, mor3);
|
||||||
ADDV(Local[ProcessId].acc0, Local[ProcessId].acc0, ai);
|
ADDV(Local[ProcessId].acc0, Local[ProcessId].acc0, ai);
|
||||||
if (Type(p) != BODY) { /* a body-cell/leaf interaction? */
|
if(Type(p) != BODY) { /* a body-cell/leaf interaction? */
|
||||||
Local[ProcessId].mynbcterm++;
|
Local[ProcessId].mynbcterm++;
|
||||||
#ifdef QUADPOLE
|
#ifdef QUADPOLE
|
||||||
dr5inv = 1.0/(Local[ProcessId].drsq * Local[ProcessId].drsq * drabs);
|
dr5inv = 1.0/(Local[ProcessId].drsq * Local[ProcessId].drsq * drabs);
|
||||||
|
@ -111,23 +111,23 @@ void walksub(nodeptr n, real dsq, long ProcessId)
|
||||||
|
|
||||||
if (subdivp(n, dsq, ProcessId)) {
|
if (subdivp(n, dsq, ProcessId)) {
|
||||||
if (Type(n) == CELL) {
|
if (Type(n) == CELL) {
|
||||||
for (nn = Subp(n); nn < Subp(n) + NSUB; nn++) {
|
for (nn = Subp(n); nn < Subp(n) + NSUB; nn++) {
|
||||||
if (*nn != NULL) {
|
if (*nn != NULL) {
|
||||||
walksub(*nn, dsq / 4.0, ProcessId);
|
walksub(*nn, dsq / 4.0, ProcessId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
l = (leafptr) n;
|
l = (leafptr) n;
|
||||||
for (i = 0; i < l->num_bodies; i++) {
|
for (i = 0; i < l->num_bodies; i++) {
|
||||||
p = Bodyp(l)[i];
|
p = Bodyp(l)[i];
|
||||||
if (p != Local[ProcessId].pskip) {
|
if (p != Local[ProcessId].pskip) {
|
||||||
gravsub(p, ProcessId);
|
gravsub(p, ProcessId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Local[ProcessId].skipself = TRUE;
|
Local[ProcessId].skipself = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -34,18 +34,18 @@ void maketree(long ProcessId)
|
||||||
}
|
}
|
||||||
Local[ProcessId].Current_Root = (nodeptr) Global->G_root;
|
Local[ProcessId].Current_Root = (nodeptr) Global->G_root;
|
||||||
for (pp = Local[ProcessId].mybodytab;
|
for (pp = Local[ProcessId].mybodytab;
|
||||||
pp < Local[ProcessId].mybodytab+Local[ProcessId].mynbody; pp++) {
|
pp < Local[ProcessId].mybodytab+Local[ProcessId].mynbody; pp++) {
|
||||||
p = *pp;
|
p = *pp;
|
||||||
if (Mass(p) != 0.0) {
|
if (Mass(p) != 0.0) {
|
||||||
Local[ProcessId].Current_Root
|
Local[ProcessId].Current_Root
|
||||||
= (nodeptr) loadtree(p, (cellptr) Local[ProcessId].Current_Root,
|
= (nodeptr) loadtree(p, (cellptr) Local[ProcessId].Current_Root,
|
||||||
ProcessId);
|
ProcessId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOCK(Global->io_lock);
|
LOCK(Global->io_lock);
|
||||||
fprintf(stderr, "Process %ld found body %ld to have zero mass\n",
|
fprintf(stderr, "Process %ld found body %ld to have zero mass\n",
|
||||||
ProcessId, (long) p);
|
ProcessId, (long) p);
|
||||||
UNLOCK(Global->io_lock);
|
UNLOCK(Global->io_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BARRIER(Global->Barrier,NPROC);
|
BARRIER(Global->Barrier,NPROC);
|
||||||
|
@ -104,29 +104,29 @@ void printtree(nodeptr n)
|
||||||
PRTV("Pos", Pos(n));
|
PRTV("Pos", Pos(n));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for (k = 0; k < NSUB; k++) {
|
for (k = 0; k < NSUB; k++) {
|
||||||
printf("Child #%ld: ", k);
|
printf("Child #%ld: ", k);
|
||||||
if (Subp(c)[k] == NULL) {
|
if (Subp(c)[k] == NULL) {
|
||||||
printf("NONE");
|
printf("NONE");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Type(Subp(c)[k]) == CELL) {
|
if (Type(Subp(c)[k]) == CELL) {
|
||||||
nseq = ((cellptr) Subp(c)[k])->seqnum;
|
nseq = ((cellptr) Subp(c)[k])->seqnum;
|
||||||
printf("C: Cost = %ld, ", Cost(Subp(c)[k]));
|
printf("C: Cost = %ld, ", Cost(Subp(c)[k]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nseq = ((leafptr) Subp(c)[k])->seqnum;
|
nseq = ((leafptr) Subp(c)[k])->seqnum;
|
||||||
printf("L: # Bodies = %2ld, Cost = %ld, ",
|
printf("L: # Bodies = %2ld, Cost = %ld, ",
|
||||||
((leafptr) Subp(c)[k])->num_bodies, Cost(Subp(c)[k]));
|
((leafptr) Subp(c)[k])->num_bodies, Cost(Subp(c)[k]));
|
||||||
}
|
}
|
||||||
tmp = Subp(c)[k];
|
tmp = Subp(c)[k];
|
||||||
PRTV("Pos", Pos(tmp));
|
PRTV("Pos", Pos(tmp));
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
for (k=0;k<NSUB;k++) {
|
for (k=0;k<NSUB;k++) {
|
||||||
if (Subp(c)[k] != NULL) {
|
if (Subp(c)[k] != NULL) {
|
||||||
printtree(Subp(c)[k]);
|
printtree(Subp(c)[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LEAF:
|
case LEAF:
|
||||||
|
@ -136,11 +136,11 @@ void printtree(nodeptr n)
|
||||||
PRTV("Pos", Pos(n));
|
PRTV("Pos", Pos(n));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for (k = 0; k < l->num_bodies; k++) {
|
for (k = 0; k < l->num_bodies; k++) {
|
||||||
p = Bodyp(l)[k];
|
p = Bodyp(l)[k];
|
||||||
printf("Body #%2ld: Num = %2ld, Level = %ld, ",
|
printf("Body #%2ld: Num = %2ld, Level = %ld, ",
|
||||||
p - bodytab, k, Level(p));
|
p - bodytab, k, Level(p));
|
||||||
PRTV("Pos",Pos(p));
|
PRTV("Pos",Pos(p));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -171,34 +171,34 @@ nodeptr loadtree(bodyptr p, cellptr root, long ProcessId)
|
||||||
}
|
}
|
||||||
for (i = IMAX >> 1; i > Level(root); i >>= 1) {
|
for (i = IMAX >> 1; i > Level(root); i >>= 1) {
|
||||||
for (j = 0; j < NDIM; j++) {
|
for (j = 0; j < NDIM; j++) {
|
||||||
if (xor[j] & i) {
|
if (xor[j] & i) {
|
||||||
valid_root = FALSE;
|
valid_root = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!valid_root) {
|
if (!valid_root) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!valid_root) {
|
if (!valid_root) {
|
||||||
if (root != Global->G_root) {
|
if (root != Global->G_root) {
|
||||||
root_level = Level(root);
|
root_level = Level(root);
|
||||||
for (j = i; j > root_level; j >>= 1) {
|
for (j = i; j > root_level; j >>= 1) {
|
||||||
root = (cellptr) Parent(root);
|
root = (cellptr) Parent(root);
|
||||||
}
|
}
|
||||||
valid_root = TRUE;
|
valid_root = TRUE;
|
||||||
for (i = IMAX >> 1; i > Level(root); i >>= 1) {
|
for (i = IMAX >> 1; i > Level(root); i >>= 1) {
|
||||||
for (j = 0; j < NDIM; j++) {
|
for (j = 0; j < NDIM; j++) {
|
||||||
if (xor[j] & i) {
|
if (xor[j] & i) {
|
||||||
valid_root = FALSE;
|
valid_root = FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!valid_root) {
|
if (!valid_root) {
|
||||||
printf("P%ld body %ld\n", ProcessId, p - bodytab);
|
printf("P%ld body %ld\n", ProcessId, p - bodytab);
|
||||||
root = Global->G_root;
|
root = Global->G_root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
root = Global->G_root;
|
root = Global->G_root;
|
||||||
|
@ -210,50 +210,50 @@ nodeptr loadtree(bodyptr p, cellptr root, long ProcessId)
|
||||||
flag = TRUE;
|
flag = TRUE;
|
||||||
while (flag) { /* loop descending tree */
|
while (flag) { /* loop descending tree */
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
error("not enough levels in tree\n");
|
error("not enough levels in tree\n");
|
||||||
}
|
}
|
||||||
if (*qptr == NULL) {
|
if (*qptr == NULL) {
|
||||||
/* lock the parent cell */
|
/* lock the parent cell */
|
||||||
ALOCK(CellLock->CL, ((cellptr) mynode)->seqnum % MAXLOCK);
|
ALOCK(CellLock->CL, ((cellptr) mynode)->seqnum % MAXLOCK);
|
||||||
if (*qptr == NULL) {
|
if (*qptr == NULL) {
|
||||||
le = InitLeaf((cellptr) mynode, ProcessId);
|
le = InitLeaf((cellptr) mynode, ProcessId);
|
||||||
Parent(p) = (nodeptr) le;
|
Parent(p) = (nodeptr) le;
|
||||||
Level(p) = l;
|
Level(p) = l;
|
||||||
ChildNum(p) = le->num_bodies;
|
ChildNum(p) = le->num_bodies;
|
||||||
ChildNum(le) = kidIndex;
|
ChildNum(le) = kidIndex;
|
||||||
Bodyp(le)[le->num_bodies++] = p;
|
Bodyp(le)[le->num_bodies++] = p;
|
||||||
*qptr = (nodeptr) le;
|
*qptr = (nodeptr) le;
|
||||||
flag = FALSE;
|
flag = FALSE;
|
||||||
}
|
}
|
||||||
AULOCK(CellLock->CL, ((cellptr) mynode)->seqnum % MAXLOCK);
|
AULOCK(CellLock->CL, ((cellptr) mynode)->seqnum % MAXLOCK);
|
||||||
/* unlock the parent cell */
|
/* unlock the parent cell */
|
||||||
}
|
}
|
||||||
if (flag && *qptr && (Type(*qptr) == LEAF)) {
|
if (flag && *qptr && (Type(*qptr) == LEAF)) {
|
||||||
/* reached a "leaf"? */
|
/* reached a "leaf"? */
|
||||||
ALOCK(CellLock->CL, ((cellptr) mynode)->seqnum % MAXLOCK);
|
ALOCK(CellLock->CL, ((cellptr) mynode)->seqnum % MAXLOCK);
|
||||||
/* lock the parent cell */
|
/* lock the parent cell */
|
||||||
if (Type(*qptr) == LEAF) { /* still a "leaf"? */
|
if (Type(*qptr) == LEAF) { /* still a "leaf"? */
|
||||||
le = (leafptr) *qptr;
|
le = (leafptr) *qptr;
|
||||||
if (le->num_bodies == MAX_BODIES_PER_LEAF) {
|
if (le->num_bodies == MAX_BODIES_PER_LEAF) {
|
||||||
*qptr = (nodeptr) SubdivideLeaf(le, (cellptr) mynode, l,
|
*qptr = (nodeptr) SubdivideLeaf(le, (cellptr) mynode, l,
|
||||||
ProcessId);
|
ProcessId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Parent(p) = (nodeptr) le;
|
Parent(p) = (nodeptr) le;
|
||||||
Level(p) = l;
|
Level(p) = l;
|
||||||
ChildNum(p) = le->num_bodies;
|
ChildNum(p) = le->num_bodies;
|
||||||
Bodyp(le)[le->num_bodies++] = p;
|
Bodyp(le)[le->num_bodies++] = p;
|
||||||
flag = FALSE;
|
flag = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AULOCK(CellLock->CL, ((cellptr) mynode)->seqnum % MAXLOCK);
|
AULOCK(CellLock->CL, ((cellptr) mynode)->seqnum % MAXLOCK);
|
||||||
/* unlock the node */
|
/* unlock the node */
|
||||||
}
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
mynode = *qptr;
|
mynode = *qptr;
|
||||||
kidIndex = subindex(xp, l);
|
kidIndex = subindex(xp, l);
|
||||||
qptr = &Subp(*qptr)[kidIndex]; /* move down one level */
|
qptr = &Subp(*qptr)[kidIndex]; /* move down one level */
|
||||||
l = l >> 1; /* and test next bit */
|
l = l >> 1; /* and test next bit */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SETV(Local[ProcessId].Root_Coords, xp);
|
SETV(Local[ProcessId].Root_Coords, xp);
|
||||||
|
@ -276,10 +276,10 @@ bool intcoord(long xp[NDIM], vector rp)
|
||||||
for (k = 0; k < NDIM; k++) {
|
for (k = 0; k < NDIM; k++) {
|
||||||
xsc = (rp[k] - Global->rmin[k]) / Global->rsize;
|
xsc = (rp[k] - Global->rmin[k]) / Global->rsize;
|
||||||
if (0.0 <= xsc && xsc < 1.0) {
|
if (0.0 <= xsc && xsc < 1.0) {
|
||||||
xp[k] = floor(IMAX * xsc);
|
xp[k] = floor(IMAX * xsc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
inb = FALSE;
|
inb = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (inb);
|
return (inb);
|
||||||
|
@ -304,8 +304,8 @@ long subindex(long x[NDIM], long l)
|
||||||
}
|
}
|
||||||
for (k = 1; k < NDIM; k++) {
|
for (k = 1; k < NDIM; k++) {
|
||||||
if (((x[k] & l) && !yes) || (!(x[k] & l) && yes)) {
|
if (((x[k] & l) && !yes) || (!(x[k] & l) && yes)) {
|
||||||
i += NSUB >> (k + 1);
|
i += NSUB >> (k + 1);
|
||||||
yes = TRUE;
|
yes = TRUE;
|
||||||
}
|
}
|
||||||
else yes = FALSE;
|
else yes = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -335,72 +335,72 @@ void hackcofm(long ProcessId)
|
||||||
/* this way, we look at child cells before parents */
|
/* this way, we look at child cells before parents */
|
||||||
|
|
||||||
for (ll = Local[ProcessId].myleaftab + Local[ProcessId].mynleaf - 1;
|
for (ll = Local[ProcessId].myleaftab + Local[ProcessId].mynleaf - 1;
|
||||||
ll >= Local[ProcessId].myleaftab; ll--) {
|
ll >= Local[ProcessId].myleaftab; ll--) {
|
||||||
l = *ll;
|
l = *ll;
|
||||||
Mass(l) = 0.0;
|
Mass(l) = 0.0;
|
||||||
Cost(l) = 0;
|
Cost(l) = 0;
|
||||||
CLRV(Pos(l));
|
CLRV(Pos(l));
|
||||||
for (i = 0; i < l->num_bodies; i++) {
|
for (i = 0; i < l->num_bodies; i++) {
|
||||||
p = Bodyp(l)[i];
|
p = Bodyp(l)[i];
|
||||||
Mass(l) += Mass(p);
|
Mass(l) += Mass(p);
|
||||||
Cost(l) += Cost(p);
|
Cost(l) += Cost(p);
|
||||||
MULVS(tmpv, Pos(p), Mass(p));
|
MULVS(tmpv, Pos(p), Mass(p));
|
||||||
ADDV(Pos(l), Pos(l), tmpv);
|
ADDV(Pos(l), Pos(l), tmpv);
|
||||||
}
|
}
|
||||||
DIVVS(Pos(l), Pos(l), Mass(l));
|
DIVVS(Pos(l), Pos(l), Mass(l));
|
||||||
#ifdef QUADPOLE
|
#ifdef QUADPOLE
|
||||||
CLRM(Quad(l));
|
CLRM(Quad(l));
|
||||||
for (i = 0; i < l->num_bodies; i++) {
|
for (i = 0; i < l->num_bodies; i++) {
|
||||||
p = Bodyp(l)[i];
|
p = Bodyp(l)[i];
|
||||||
SUBV(dr, Pos(p), Pos(l));
|
SUBV(dr, Pos(p), Pos(l));
|
||||||
OUTVP(drdr, dr, dr);
|
OUTVP(drdr, dr, dr);
|
||||||
DOTVP(drsq, dr, dr);
|
DOTVP(drsq, dr, dr);
|
||||||
SETMI(Idrsq);
|
SETMI(Idrsq);
|
||||||
MULMS(Idrsq, Idrsq, drsq);
|
MULMS(Idrsq, Idrsq, drsq);
|
||||||
MULMS(tmpm, drdr, 3.0);
|
MULMS(tmpm, drdr, 3.0);
|
||||||
SUBM(tmpm, tmpm, Idrsq);
|
SUBM(tmpm, tmpm, Idrsq);
|
||||||
MULMS(tmpm, tmpm, Mass(p));
|
MULMS(tmpm, tmpm, Mass(p));
|
||||||
ADDM(Quad(l), Quad(l), tmpm);
|
ADDM(Quad(l), Quad(l), tmpm);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Done(l)=TRUE;
|
Done(l)=TRUE;
|
||||||
}
|
}
|
||||||
for (cc = Local[ProcessId].mycelltab+Local[ProcessId].myncell-1;
|
for (cc = Local[ProcessId].mycelltab+Local[ProcessId].myncell-1;
|
||||||
cc >= Local[ProcessId].mycelltab; cc--) {
|
cc >= Local[ProcessId].mycelltab; cc--) {
|
||||||
q = *cc;
|
q = *cc;
|
||||||
Mass(q) = 0.0;
|
Mass(q) = 0.0;
|
||||||
Cost(q) = 0;
|
Cost(q) = 0;
|
||||||
CLRV(Pos(q));
|
CLRV(Pos(q));
|
||||||
for (i = 0; i < NSUB; i++) {
|
for (i = 0; i < NSUB; i++) {
|
||||||
r = Subp(q)[i];
|
r = Subp(q)[i];
|
||||||
if (r != NULL) {
|
if (r != NULL) {
|
||||||
while (!Done(r)) {
|
while(!Done(r)) {
|
||||||
/* wait */
|
/* wait */
|
||||||
}
|
}
|
||||||
Mass(q) += Mass(r);
|
Mass(q) += Mass(r);
|
||||||
Cost(q) += Cost(r);
|
Cost(q) += Cost(r);
|
||||||
MULVS(tmpv, Pos(r), Mass(r));
|
MULVS(tmpv, Pos(r), Mass(r));
|
||||||
ADDV(Pos(q), Pos(q), tmpv);
|
ADDV(Pos(q), Pos(q), tmpv);
|
||||||
Done(r) = FALSE;
|
Done(r) = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DIVVS(Pos(q), Pos(q), Mass(q));
|
DIVVS(Pos(q), Pos(q), Mass(q));
|
||||||
#ifdef QUADPOLE
|
#ifdef QUADPOLE
|
||||||
CLRM(Quad(q));
|
CLRM(Quad(q));
|
||||||
for (i = 0; i < NSUB; i++) {
|
for (i = 0; i < NSUB; i++) {
|
||||||
r = Subp(q)[i];
|
r = Subp(q)[i];
|
||||||
if (r != NULL) {
|
if (r != NULL) {
|
||||||
SUBV(dr, Pos(r), Pos(q));
|
SUBV(dr, Pos(r), Pos(q));
|
||||||
OUTVP(drdr, dr, dr);
|
OUTVP(drdr, dr, dr);
|
||||||
DOTVP(drsq, dr, dr);
|
DOTVP(drsq, dr, dr);
|
||||||
SETMI(Idrsq);
|
SETMI(Idrsq);
|
||||||
MULMS(Idrsq, Idrsq, drsq);
|
MULMS(Idrsq, Idrsq, drsq);
|
||||||
MULMS(tmpm, drdr, 3.0);
|
MULMS(tmpm, drdr, 3.0);
|
||||||
SUBM(tmpm, tmpm, Idrsq);
|
SUBM(tmpm, tmpm, Idrsq);
|
||||||
MULMS(tmpm, tmpm, Mass(r));
|
MULMS(tmpm, tmpm, Mass(r));
|
||||||
ADDM(tmpm, tmpm, Quad(r));
|
ADDM(tmpm, tmpm, Quad(r));
|
||||||
ADDM(Quad(q), Quad(q), tmpm);
|
ADDM(Quad(q), Quad(q), tmpm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Done(q)=TRUE;
|
Done(q)=TRUE;
|
||||||
|
@ -446,12 +446,12 @@ cellptr SubdivideLeaf(leafptr le, cellptr parent, long l, long ProcessId)
|
||||||
intcoord(xp, Pos(p));
|
intcoord(xp, Pos(p));
|
||||||
index = subindex(xp, l);
|
index = subindex(xp, l);
|
||||||
if (!Subp(c)[index]) {
|
if (!Subp(c)[index]) {
|
||||||
le = InitLeaf(c, ProcessId);
|
le = InitLeaf(c, ProcessId);
|
||||||
ChildNum(le) = index;
|
ChildNum(le) = index;
|
||||||
Subp(c)[index] = (nodeptr) le;
|
Subp(c)[index] = (nodeptr) le;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
le = (leafptr) Subp(c)[index];
|
le = (leafptr) Subp(c)[index];
|
||||||
}
|
}
|
||||||
Parent(p) = (nodeptr) le;
|
Parent(p) = (nodeptr) le;
|
||||||
ChildNum(p) = le->num_bodies;
|
ChildNum(p) = le->num_bodies;
|
||||||
|
@ -472,7 +472,7 @@ cellptr makecell(long ProcessId)
|
||||||
|
|
||||||
if (Local[ProcessId].mynumcell == maxmycell) {
|
if (Local[ProcessId].mynumcell == maxmycell) {
|
||||||
error("makecell: Proc %ld needs more than %ld cells; increase fcells\n",
|
error("makecell: Proc %ld needs more than %ld cells; increase fcells\n",
|
||||||
ProcessId,maxmycell);
|
ProcessId,maxmycell);
|
||||||
}
|
}
|
||||||
Mycell = Local[ProcessId].mynumcell++;
|
Mycell = Local[ProcessId].mynumcell++;
|
||||||
c = Local[ProcessId].ctab + Mycell;
|
c = Local[ProcessId].ctab + Mycell;
|
||||||
|
@ -498,7 +498,7 @@ leafptr makeleaf(long ProcessId)
|
||||||
|
|
||||||
if (Local[ProcessId].mynumleaf == maxmyleaf) {
|
if (Local[ProcessId].mynumleaf == maxmyleaf) {
|
||||||
error("makeleaf: Proc %ld needs more than %ld leaves; increase fleaves\n",
|
error("makeleaf: Proc %ld needs more than %ld leaves; increase fleaves\n",
|
||||||
ProcessId,maxmyleaf);
|
ProcessId,maxmyleaf);
|
||||||
}
|
}
|
||||||
Myleaf = Local[ProcessId].mynumleaf++;
|
Myleaf = Local[ProcessId].mynumleaf++;
|
||||||
le = Local[ProcessId].ltab + Myleaf;
|
le = Local[ProcessId].ltab + Myleaf;
|
||||||
|
|
|
@ -21,14 +21,13 @@
|
||||||
#ifndef _STDINC_H_
|
#ifndef _STDINC_H_
|
||||||
#define _STDINC_H_
|
#define _STDINC_H_
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
#define error(msg, ...) printf(msg, ##__VA_ARGS__);
|
#define error(msg, ...) printf(msg, ##__VA_ARGS__);
|
||||||
/*
|
/*
|
||||||
* STREAM: a replacement for FILE *.
|
* STREAM: a replacement for FILE *.
|
||||||
|
@ -60,9 +59,9 @@ typedef char byte;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef char *string;
|
typedef char *string;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* REAL: default type is double;
|
* REAL: default type is double;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef double real, *realptr;
|
typedef double real, *realptr;
|
||||||
|
@ -99,7 +98,7 @@ typedef real (*rproc)();
|
||||||
#define FOUR_PI 12.56637061435917295385
|
#define FOUR_PI 12.56637061435917295385
|
||||||
#define HALF_PI 1.57079632679489661923
|
#define HALF_PI 1.57079632679489661923
|
||||||
#define FRTHRD_PI 4.18879020478639098462
|
#define FRTHRD_PI 4.18879020478639098462
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ABS: returns the absolute value of its argument
|
* ABS: returns the absolute value of its argument
|
||||||
* MAX: returns the argument with the highest value
|
* MAX: returns the argument with the highest value
|
||||||
|
@ -108,13 +107,13 @@ typedef real (*rproc)();
|
||||||
|
|
||||||
#define ABS(x) (((x) < 0) ? -(x) : (x))
|
#define ABS(x) (((x) < 0) ? -(x) : (x))
|
||||||
|
|
||||||
#include "code.h"
|
|
||||||
#include "code_io.h"
|
|
||||||
#include "defs.h"
|
|
||||||
#include "getparam.h"
|
|
||||||
#include "grav.h"
|
|
||||||
#include "load.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "vectmath.h"
|
#include "vectmath.h"
|
||||||
|
#include "defs.h"
|
||||||
|
#include "code.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "load.h"
|
||||||
|
#include "code_io.h"
|
||||||
|
#include "grav.h"
|
||||||
|
#include "getparam.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -50,7 +50,7 @@ void pranset(long seed)
|
||||||
|
|
||||||
double prand()
|
double prand()
|
||||||
/*
|
/*
|
||||||
Return a random double in [0, 1.0)
|
Return a random double in [0, 1.0)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
lastrand = randx;
|
lastrand = randx;
|
||||||
|
|
|
@ -14,13 +14,12 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
#include "box.h"
|
||||||
|
|
||||||
/* How many boxes can fit on one line */
|
/* How many boxes can fit on one line */
|
||||||
#define BOXES_PER_LINE 4
|
#define BOXES_PER_LINE 4
|
||||||
|
@ -48,7 +47,7 @@ CreateBoxes (long my_id, long num_boxes)
|
||||||
|
|
||||||
starting_address = (char *) Local[my_id].B_Heap;
|
starting_address = (char *) Local[my_id].B_Heap;
|
||||||
ending_address = (((char *) Local[my_id].B_Heap)
|
ending_address = (((char *) Local[my_id].B_Heap)
|
||||||
+ (num_boxes * sizeof(particle *)) - 1);
|
+ (num_boxes * sizeof(particle *)) - 1);
|
||||||
|
|
||||||
Place all addresses x such that (starting_address <= x < ending_address)
|
Place all addresses x such that (starting_address <= x < ending_address)
|
||||||
on node my_id
|
on node my_id
|
||||||
|
@ -167,19 +166,19 @@ PrintBox (box *b)
|
||||||
printf(" Type = %d\n", b->type);
|
printf(" Type = %d\n", b->type);
|
||||||
printf(" Child Num = %ld\n", b->child_num);
|
printf(" Child Num = %ld\n", b->child_num);
|
||||||
if (b->parent == NULL)
|
if (b->parent == NULL)
|
||||||
printf(" Parent = NONE\n");
|
printf(" Parent = NONE\n");
|
||||||
else
|
else
|
||||||
printf(" Parent = B%f\n", b->parent->id);
|
printf(" Parent = B%f\n", b->parent->id);
|
||||||
printf(" Children's IDs : ");
|
printf(" Children's IDs : ");
|
||||||
if (b->num_children != 0)
|
if (b->num_children != 0)
|
||||||
PrintBoxArrayIds(b->children, b->num_children);
|
PrintBoxArrayIds(b->children, b->num_children);
|
||||||
else
|
else
|
||||||
printf("NONE\n");
|
printf("NONE\n");
|
||||||
printf(" Sibling's IDs : ");
|
printf(" Sibling's IDs : ");
|
||||||
if (b->num_siblings != 0)
|
if (b->num_siblings != 0)
|
||||||
PrintBoxArrayIds(b->siblings, b->num_siblings);
|
PrintBoxArrayIds(b->siblings, b->num_siblings);
|
||||||
else
|
else
|
||||||
printf("NONE\n");
|
printf("NONE\n");
|
||||||
printf(" Colleagues' IDs : ");
|
printf(" Colleagues' IDs : ");
|
||||||
PrintBoxArrayIds(b->colleagues, b->num_colleagues);
|
PrintBoxArrayIds(b->colleagues, b->num_colleagues);
|
||||||
printf(" U List IDs : ");
|
printf(" U List IDs : ");
|
||||||
|
@ -222,11 +221,11 @@ PrintBoxArrayIds (box *b_array[], long array_length)
|
||||||
tab_count = 0;
|
tab_count = 0;
|
||||||
for (i = 0; i < array_length; i++) {
|
for (i = 0; i < array_length; i++) {
|
||||||
if (tab_count == 0) {
|
if (tab_count == 0) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
tab_count = BOXES_PER_LINE;
|
tab_count = BOXES_PER_LINE;
|
||||||
}
|
}
|
||||||
if (b_array[i] != NULL)
|
if (b_array[i] != NULL)
|
||||||
printf("\tB%f", b_array[i]->id);
|
printf("\tB%f", b_array[i]->id);
|
||||||
tab_count -= 1;
|
tab_count -= 1;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -251,13 +250,13 @@ PrintExpansionTerms (complex expansion[])
|
||||||
|
|
||||||
for (i = 0; i < Expansion_Terms; i++) {
|
for (i = 0; i < Expansion_Terms; i++) {
|
||||||
if (tab_count == 0) {
|
if (tab_count == 0) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
tab_count = TERMS_PER_LINE;
|
tab_count = TERMS_PER_LINE;
|
||||||
}
|
}
|
||||||
if (expansion[i].i >= (real) 0.0)
|
if (expansion[i].i >= (real) 0.0)
|
||||||
printf("\ta%ld = %.3e + %.3ei", i, expansion[i].r, expansion[i].i);
|
printf("\ta%ld = %.3e + %.3ei", i, expansion[i].r, expansion[i].i);
|
||||||
else
|
else
|
||||||
printf("\ta%ld = %.3e - %.3ei", i, expansion[i].r, -expansion[i].i);
|
printf("\ta%ld = %.3e - %.3ei", i, expansion[i].r, -expansion[i].i);
|
||||||
tab_count -= 1;
|
tab_count -= 1;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -271,8 +270,8 @@ ListIterate (long my_id, box *b, box **list, long length, list_function function
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
if (list[i] == NULL) {
|
if (list[i] == NULL) {
|
||||||
LockedPrint("ERROR (P%d) : NULL list entry\n", my_id);
|
LockedPrint("ERROR (P%d) : NULL list entry\n", my_id);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
(*function)(my_id, list[i], b);
|
(*function)(my_id, list[i], b);
|
||||||
}
|
}
|
||||||
|
@ -312,10 +311,10 @@ AdjacentBoxes (box *b1, box *b2)
|
||||||
ret_val = TRUE;
|
ret_val = TRUE;
|
||||||
else
|
else
|
||||||
if ((y_separation == exact_separation) &&
|
if ((y_separation == exact_separation) &&
|
||||||
(x_separation <= exact_separation))
|
(x_separation <= exact_separation))
|
||||||
ret_val = TRUE;
|
ret_val = TRUE;
|
||||||
else
|
else
|
||||||
ret_val = FALSE;
|
ret_val = FALSE;
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,14 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <cfloat>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <float.h>
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "construct_grid.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
#include "box.h"
|
||||||
#include "partition_grid.h"
|
#include "partition_grid.h"
|
||||||
|
#include "construct_grid.h"
|
||||||
|
|
||||||
#define MY_PARTICLES (Local[my_id].Particles)
|
#define MY_PARTICLES (Local[my_id].Particles)
|
||||||
#define MY_NUM_PARTICLES (Local[my_id].Num_Particles)
|
#define MY_NUM_PARTICLES (Local[my_id].Num_Particles)
|
||||||
|
@ -74,10 +73,10 @@ ConstructGrid (long my_id, time_info *local_time, long time_all)
|
||||||
CLOCK(start);
|
CLOCK(start);
|
||||||
if (MY_NUM_PARTICLES > 0) {
|
if (MY_NUM_PARTICLES > 0) {
|
||||||
ConstructLocalGrid(my_id); /* Each processor constructs their own tree
|
ConstructLocalGrid(my_id); /* Each processor constructs their own tree
|
||||||
based on only their particles */
|
based on only their particles */
|
||||||
MergeLocalGrid(my_id); /* The processors combine their trees into one
|
MergeLocalGrid(my_id); /* The processors combine their trees into one
|
||||||
global tree. This step contains
|
global tree. This step contains
|
||||||
communication between processors. */
|
communication between processors. */
|
||||||
}
|
}
|
||||||
BARRIER(G_Memory->synch, Number_Of_Processors);
|
BARRIER(G_Memory->synch, Number_Of_Processors);
|
||||||
CleanupGrid(my_id);
|
CleanupGrid(my_id);
|
||||||
|
@ -128,13 +127,13 @@ DestroyGrid (long my_id, time_info *local_time, long time_all)
|
||||||
b_scan = b_scan->next;
|
b_scan = b_scan->next;
|
||||||
particle_cost = tb->cost / tb->num_particles;
|
particle_cost = tb->cost / tb->num_particles;
|
||||||
for (i = 0; i < tb->num_particles; i++) {
|
for (i = 0; i < tb->num_particles; i++) {
|
||||||
if (MY_MAX_PARTICLES <= MY_NUM_PARTICLES) {
|
if (MY_MAX_PARTICLES <= MY_NUM_PARTICLES) {
|
||||||
LockedPrint("ERROR (P%d) : Too many particles in local array\n", my_id);
|
LockedPrint("ERROR (P%d) : Too many particles in local array\n", my_id);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
p = tb->particles[i];
|
p = tb->particles[i];
|
||||||
p->cost = particle_cost;
|
p->cost = particle_cost;
|
||||||
MY_PARTICLES[MY_NUM_PARTICLES++] = p;
|
MY_PARTICLES[MY_NUM_PARTICLES++] = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (my_id == 0)
|
if (my_id == 0)
|
||||||
|
@ -161,15 +160,15 @@ PrintGrid (long my_id)
|
||||||
{
|
{
|
||||||
if (Grid != NULL) {
|
if (Grid != NULL) {
|
||||||
if (my_id == 0) {
|
if (my_id == 0) {
|
||||||
printf("Info for Adaptive Grid :\n");
|
printf("Info for Adaptive Grid :\n");
|
||||||
printf("Boxes :\n\n");
|
printf("Boxes :\n\n");
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
BARRIER(G_Memory->synch, Number_Of_Processors);
|
BARRIER(G_Memory->synch, Number_Of_Processors);
|
||||||
PartitionIterate(my_id, PrintBox, TOP);
|
PartitionIterate(my_id, PrintBox, TOP);
|
||||||
BARRIER(G_Memory->synch, Number_Of_Processors);
|
BARRIER(G_Memory->synch, Number_Of_Processors);
|
||||||
if (my_id == 0) {
|
if (my_id == 0) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
BARRIER(G_Memory->synch, Number_Of_Processors);
|
BARRIER(G_Memory->synch, Number_Of_Processors);
|
||||||
|
@ -183,9 +182,9 @@ void
|
||||||
DetermineGridSize (long my_id)
|
DetermineGridSize (long my_id)
|
||||||
{
|
{
|
||||||
DetermineLocalGridSize(my_id); /* Processor looks at its own particles and
|
DetermineLocalGridSize(my_id); /* Processor looks at its own particles and
|
||||||
finds the x and y max and min */
|
finds the x and y max and min */
|
||||||
MergeLocalGridSize(my_id); /* Processors shares info with others and each
|
MergeLocalGridSize(my_id); /* Processors shares info with others and each
|
||||||
one computes the global max and min */
|
one computes the global max and min */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,29 +210,29 @@ DetermineLocalGridSize (long my_id)
|
||||||
x_pos2 = MY_PARTICLES[i + 1]->pos.x;
|
x_pos2 = MY_PARTICLES[i + 1]->pos.x;
|
||||||
y_pos2 = MY_PARTICLES[i + 1]->pos.y;
|
y_pos2 = MY_PARTICLES[i + 1]->pos.y;
|
||||||
if (x_pos1 > x_pos2) {
|
if (x_pos1 > x_pos2) {
|
||||||
x_max_challenger = x_pos1;
|
x_max_challenger = x_pos1;
|
||||||
x_min_challenger = x_pos2;
|
x_min_challenger = x_pos2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
x_max_challenger = x_pos2;
|
x_max_challenger = x_pos2;
|
||||||
x_min_challenger = x_pos1;
|
x_min_challenger = x_pos1;
|
||||||
}
|
}
|
||||||
if (y_pos1 > y_pos2) {
|
if (y_pos1 > y_pos2) {
|
||||||
y_max_challenger = y_pos1;
|
y_max_challenger = y_pos1;
|
||||||
y_min_challenger = y_pos2;
|
y_min_challenger = y_pos2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
y_max_challenger = y_pos2;
|
y_max_challenger = y_pos2;
|
||||||
y_min_challenger = y_pos1;
|
y_min_challenger = y_pos1;
|
||||||
}
|
}
|
||||||
if (x_max_challenger > Local[my_id].Local_X_Max)
|
if (x_max_challenger > Local[my_id].Local_X_Max)
|
||||||
Local[my_id].Local_X_Max = x_max_challenger;
|
Local[my_id].Local_X_Max = x_max_challenger;
|
||||||
if (x_min_challenger < Local[my_id].Local_X_Min)
|
if (x_min_challenger < Local[my_id].Local_X_Min)
|
||||||
Local[my_id].Local_X_Min = x_min_challenger;
|
Local[my_id].Local_X_Min = x_min_challenger;
|
||||||
if (y_max_challenger > Local[my_id].Local_Y_Max)
|
if (y_max_challenger > Local[my_id].Local_Y_Max)
|
||||||
Local[my_id].Local_Y_Max = y_max_challenger;
|
Local[my_id].Local_Y_Max = y_max_challenger;
|
||||||
if (y_min_challenger < Local[my_id].Local_Y_Min)
|
if (y_min_challenger < Local[my_id].Local_Y_Min)
|
||||||
Local[my_id].Local_Y_Min = y_min_challenger;
|
Local[my_id].Local_Y_Min = y_min_challenger;
|
||||||
}
|
}
|
||||||
if (i == (MY_NUM_PARTICLES - 1)) {
|
if (i == (MY_NUM_PARTICLES - 1)) {
|
||||||
x_max_challenger = MY_PARTICLES[i]->pos.x;
|
x_max_challenger = MY_PARTICLES[i]->pos.x;
|
||||||
|
@ -241,13 +240,13 @@ DetermineLocalGridSize (long my_id)
|
||||||
y_max_challenger = MY_PARTICLES[i]->pos.y;
|
y_max_challenger = MY_PARTICLES[i]->pos.y;
|
||||||
y_min_challenger = MY_PARTICLES[i]->pos.y;
|
y_min_challenger = MY_PARTICLES[i]->pos.y;
|
||||||
if (x_max_challenger > Local[my_id].Local_X_Max)
|
if (x_max_challenger > Local[my_id].Local_X_Max)
|
||||||
Local[my_id].Local_X_Max = x_max_challenger;
|
Local[my_id].Local_X_Max = x_max_challenger;
|
||||||
if (x_min_challenger < Local[my_id].Local_X_Min)
|
if (x_min_challenger < Local[my_id].Local_X_Min)
|
||||||
Local[my_id].Local_X_Min = x_min_challenger;
|
Local[my_id].Local_X_Min = x_min_challenger;
|
||||||
if (y_max_challenger > Local[my_id].Local_Y_Max)
|
if (y_max_challenger > Local[my_id].Local_Y_Max)
|
||||||
Local[my_id].Local_Y_Max = y_max_challenger;
|
Local[my_id].Local_Y_Max = y_max_challenger;
|
||||||
if (y_min_challenger < Local[my_id].Local_Y_Min)
|
if (y_min_challenger < Local[my_id].Local_Y_Min)
|
||||||
Local[my_id].Local_Y_Min = y_min_challenger;
|
Local[my_id].Local_Y_Min = y_min_challenger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,13 +274,13 @@ MergeLocalGridSize (long my_id)
|
||||||
y_max_challenger = their_f_array[2];
|
y_max_challenger = their_f_array[2];
|
||||||
y_min_challenger = their_f_array[3];
|
y_min_challenger = their_f_array[3];
|
||||||
if (x_max_challenger > Local[my_id].Local_X_Max)
|
if (x_max_challenger > Local[my_id].Local_X_Max)
|
||||||
Local[my_id].Local_X_Max = x_max_challenger;
|
Local[my_id].Local_X_Max = x_max_challenger;
|
||||||
if (x_min_challenger < Local[my_id].Local_X_Min)
|
if (x_min_challenger < Local[my_id].Local_X_Min)
|
||||||
Local[my_id].Local_X_Min = x_min_challenger;
|
Local[my_id].Local_X_Min = x_min_challenger;
|
||||||
if (y_max_challenger > Local[my_id].Local_Y_Max)
|
if (y_max_challenger > Local[my_id].Local_Y_Max)
|
||||||
Local[my_id].Local_Y_Max = y_max_challenger;
|
Local[my_id].Local_Y_Max = y_max_challenger;
|
||||||
if (y_min_challenger < Local[my_id].Local_Y_Min)
|
if (y_min_challenger < Local[my_id].Local_Y_Min)
|
||||||
Local[my_id].Local_Y_Min = y_min_challenger;
|
Local[my_id].Local_Y_Min = y_min_challenger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +290,7 @@ ConstructLocalGrid (long my_id)
|
||||||
{
|
{
|
||||||
Local[my_id].Local_Grid = InitGrid(my_id); /* Create the root box */
|
Local[my_id].Local_Grid = InitGrid(my_id); /* Create the root box */
|
||||||
InsertParticlesInTree(my_id, MY_PARTICLES, MY_NUM_PARTICLES,
|
InsertParticlesInTree(my_id, MY_PARTICLES, MY_NUM_PARTICLES,
|
||||||
Local[my_id].Local_Grid);
|
Local[my_id].Local_Grid);
|
||||||
/* Put all of your particles into your local tree */
|
/* Put all of your particles into your local tree */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,28 +308,28 @@ InitGrid (long my_id)
|
||||||
Local[my_id].Local_X_Max = ldexp(1.0, exp);
|
Local[my_id].Local_X_Max = ldexp(1.0, exp);
|
||||||
else {
|
else {
|
||||||
if (Local[my_id].Local_X_Max < 0)
|
if (Local[my_id].Local_X_Max < 0)
|
||||||
Local[my_id].Local_X_Max = -ldexp(1.0, exp - 1);
|
Local[my_id].Local_X_Max = -ldexp(1.0, exp - 1);
|
||||||
}
|
}
|
||||||
frexp(Local[my_id].Local_X_Min, &exp);
|
frexp(Local[my_id].Local_X_Min, &exp);
|
||||||
if (Local[my_id].Local_X_Min < 0)
|
if (Local[my_id].Local_X_Min < 0)
|
||||||
Local[my_id].Local_X_Min = -ldexp(1.0, exp);
|
Local[my_id].Local_X_Min = -ldexp(1.0, exp);
|
||||||
else {
|
else {
|
||||||
if (Local[my_id].Local_X_Min > 0)
|
if (Local[my_id].Local_X_Min > 0)
|
||||||
Local[my_id].Local_X_Min = ldexp(1.0, exp - 1);
|
Local[my_id].Local_X_Min = ldexp(1.0, exp - 1);
|
||||||
}
|
}
|
||||||
frexp(Local[my_id].Local_Y_Max, &exp);
|
frexp(Local[my_id].Local_Y_Max, &exp);
|
||||||
if (Local[my_id].Local_Y_Max > 0)
|
if (Local[my_id].Local_Y_Max > 0)
|
||||||
Local[my_id].Local_Y_Max = ldexp(1.0, exp);
|
Local[my_id].Local_Y_Max = ldexp(1.0, exp);
|
||||||
else {
|
else {
|
||||||
if (Local[my_id].Local_Y_Max < 0)
|
if (Local[my_id].Local_Y_Max < 0)
|
||||||
Local[my_id].Local_Y_Max = -ldexp(1.0, exp - 1);
|
Local[my_id].Local_Y_Max = -ldexp(1.0, exp - 1);
|
||||||
}
|
}
|
||||||
frexp(Local[my_id].Local_Y_Min, &exp);
|
frexp(Local[my_id].Local_Y_Min, &exp);
|
||||||
if (Local[my_id].Local_Y_Min < 0)
|
if (Local[my_id].Local_Y_Min < 0)
|
||||||
Local[my_id].Local_Y_Min = -ldexp(1.0, exp);
|
Local[my_id].Local_Y_Min = -ldexp(1.0, exp);
|
||||||
else {
|
else {
|
||||||
if (Local[my_id].Local_Y_Min > 0)
|
if (Local[my_id].Local_Y_Min > 0)
|
||||||
Local[my_id].Local_Y_Min = ldexp(1.0, exp - 1);
|
Local[my_id].Local_Y_Min = ldexp(1.0, exp - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
x_length = Local[my_id].Local_X_Max - Local[my_id].Local_X_Min;
|
x_length = Local[my_id].Local_X_Max - Local[my_id].Local_X_Min;
|
||||||
|
@ -369,12 +368,12 @@ InsertParticlesInTree (long my_id, particle **p_list, long num_of_particles, box
|
||||||
dest_box = FindHome(my_id, p, dest_box);
|
dest_box = FindHome(my_id, p, dest_box);
|
||||||
dest_box->particles[dest_box->num_particles++] = p;
|
dest_box->particles[dest_box->num_particles++] = p;
|
||||||
while (dest_box->num_particles > MAX_PARTICLES_PER_BOX) {
|
while (dest_box->num_particles > MAX_PARTICLES_PER_BOX) {
|
||||||
SubdivideBox(my_id, dest_box);
|
SubdivideBox(my_id, dest_box);
|
||||||
if (dest_box->num_children == 1) {
|
if (dest_box->num_children == 1) {
|
||||||
for (j = 0; dest_box->children[j] == NULL; j++)
|
for (j = 0; dest_box->children[j] == NULL; j++)
|
||||||
;
|
;
|
||||||
dest_box = dest_box->children[j];
|
dest_box = dest_box->children[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,28 +392,28 @@ FindHome (long my_id, particle *p, box *current_home)
|
||||||
pb = FindInitialRoot(p, current_home);
|
pb = FindInitialRoot(p, current_home);
|
||||||
while (pb->type == PARENT) {
|
while (pb->type == PARENT) {
|
||||||
if (p->pos.y > pb->y_center) {
|
if (p->pos.y > pb->y_center) {
|
||||||
if (p->pos.x > pb->x_center) {
|
if (p->pos.x > pb->x_center) {
|
||||||
if (pb->children[0] == NULL)
|
if (pb->children[0] == NULL)
|
||||||
CreateChild(my_id, pb, 0);
|
CreateChild(my_id, pb, 0);
|
||||||
pb = pb->children[0];
|
pb = pb->children[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (pb->children[1] == NULL)
|
if (pb->children[1] == NULL)
|
||||||
CreateChild(my_id, pb, 1);
|
CreateChild(my_id, pb, 1);
|
||||||
pb = pb->children[1];
|
pb = pb->children[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (p->pos.x > pb->x_center) {
|
if (p->pos.x > pb->x_center) {
|
||||||
if (pb->children[3] == NULL)
|
if (pb->children[3] == NULL)
|
||||||
CreateChild(my_id, pb, 3);
|
CreateChild(my_id, pb, 3);
|
||||||
pb = pb->children[3];
|
pb = pb->children[3];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (pb->children[2] == NULL)
|
if (pb->children[2] == NULL)
|
||||||
CreateChild(my_id, pb, 2);
|
CreateChild(my_id, pb, 2);
|
||||||
pb = pb->children[2];
|
pb = pb->children[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pb;
|
return pb;
|
||||||
|
@ -432,14 +431,14 @@ FindInitialRoot (particle *p, box *current_home)
|
||||||
x_center_distance = p->pos.x - current_home->x_center;
|
x_center_distance = p->pos.x - current_home->x_center;
|
||||||
y_center_distance = p->pos.y - current_home->y_center;
|
y_center_distance = p->pos.y - current_home->y_center;
|
||||||
if (x_center_distance < 0)
|
if (x_center_distance < 0)
|
||||||
x_center_distance = -x_center_distance;
|
x_center_distance = -x_center_distance;
|
||||||
if (y_center_distance < 0)
|
if (y_center_distance < 0)
|
||||||
y_center_distance = -y_center_distance;
|
y_center_distance = -y_center_distance;
|
||||||
if ((x_center_distance > (current_home->length / 2.0)) ||
|
if ((x_center_distance > (current_home->length / 2.0)) ||
|
||||||
(y_center_distance > (current_home->length / 2.0)))
|
(y_center_distance > (current_home->length / 2.0)))
|
||||||
current_home = current_home->parent;
|
current_home = current_home->parent;
|
||||||
else
|
else
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
}
|
}
|
||||||
return current_home;
|
return current_home;
|
||||||
}
|
}
|
||||||
|
@ -461,26 +460,26 @@ CreateChild (long my_id, box *pb, long new_child_num)
|
||||||
child_offset = pb->length / (real) NUM_OFFSPRING;
|
child_offset = pb->length / (real) NUM_OFFSPRING;
|
||||||
if (new_child_num == 0) {
|
if (new_child_num == 0) {
|
||||||
pb->children[0] = InitBox(my_id, (pb->x_center + child_offset),
|
pb->children[0] = InitBox(my_id, (pb->x_center + child_offset),
|
||||||
(pb->y_center + child_offset), child_length,
|
(pb->y_center + child_offset), child_length,
|
||||||
pb);
|
pb);
|
||||||
pb->shadow[0] = pb->children[0];
|
pb->shadow[0] = pb->children[0];
|
||||||
}
|
}
|
||||||
if (new_child_num == 1) {
|
if (new_child_num == 1) {
|
||||||
pb->children[1] = InitBox(my_id, (pb->x_center - child_offset),
|
pb->children[1] = InitBox(my_id, (pb->x_center - child_offset),
|
||||||
(pb->y_center + child_offset), child_length,
|
(pb->y_center + child_offset), child_length,
|
||||||
pb);
|
pb);
|
||||||
pb->shadow[1] = pb->children[1];
|
pb->shadow[1] = pb->children[1];
|
||||||
}
|
}
|
||||||
if (new_child_num == 2) {
|
if (new_child_num == 2) {
|
||||||
pb->children[2] = InitBox(my_id, (pb->x_center - child_offset),
|
pb->children[2] = InitBox(my_id, (pb->x_center - child_offset),
|
||||||
(pb->y_center - child_offset), child_length,
|
(pb->y_center - child_offset), child_length,
|
||||||
pb);
|
pb);
|
||||||
pb->shadow[2] = pb->children[2];
|
pb->shadow[2] = pb->children[2];
|
||||||
}
|
}
|
||||||
if (new_child_num == 3) {
|
if (new_child_num == 3) {
|
||||||
pb->children[3] = InitBox(my_id, (pb->x_center + child_offset),
|
pb->children[3] = InitBox(my_id, (pb->x_center + child_offset),
|
||||||
(pb->y_center - child_offset), child_length,
|
(pb->y_center - child_offset), child_length,
|
||||||
pb);
|
pb);
|
||||||
pb->shadow[3] = pb->children[3];
|
pb->shadow[3] = pb->children[3];
|
||||||
}
|
}
|
||||||
pb->children[new_child_num]->child_num = new_child_num;
|
pb->children[new_child_num]->child_num = new_child_num;
|
||||||
|
@ -502,28 +501,28 @@ SubdivideBox (long my_id, box *b)
|
||||||
for (i = 0; i < b->num_particles; i++) {
|
for (i = 0; i < b->num_particles; i++) {
|
||||||
p = b->particles[i];
|
p = b->particles[i];
|
||||||
if (p->pos.y > b->y_center) {
|
if (p->pos.y > b->y_center) {
|
||||||
if (p->pos.x > b->x_center) {
|
if (p->pos.x > b->x_center) {
|
||||||
child = b->children[0];
|
child = b->children[0];
|
||||||
if (child == NULL)
|
if (child == NULL)
|
||||||
child = CreateChild(my_id, b, 0);
|
child = CreateChild(my_id, b, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
child = b->children[1];
|
child = b->children[1];
|
||||||
if (child == NULL)
|
if (child == NULL)
|
||||||
child = CreateChild(my_id, b, 1);
|
child = CreateChild(my_id, b, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (p->pos.x > b->x_center) {
|
if (p->pos.x > b->x_center) {
|
||||||
child = b->children[3];
|
child = b->children[3];
|
||||||
if (child == NULL)
|
if (child == NULL)
|
||||||
child = CreateChild(my_id, b, 3);
|
child = CreateChild(my_id, b, 3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
child = b->children[2];
|
child = b->children[2];
|
||||||
if (child == NULL)
|
if (child == NULL)
|
||||||
child = CreateChild(my_id, b, 2);
|
child = CreateChild(my_id, b, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child->particles[child->num_particles++] = p;
|
child->particles[child->num_particles++] = p;
|
||||||
b->particles[i] = NULL;
|
b->particles[i] = NULL;
|
||||||
|
@ -554,53 +553,53 @@ MLGHelper (long my_id, box *local_box, box *global_box, box *global_parent)
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
while (success == FALSE) {
|
while (success == FALSE) {
|
||||||
if (local_box->type == PARENT) {
|
if (local_box->type == PARENT) {
|
||||||
if (global_box == NULL) {
|
if (global_box == NULL) {
|
||||||
success = InsertBoxInGrid(my_id, local_box, global_parent);
|
success = InsertBoxInGrid(my_id, local_box, global_parent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (global_box->type == PARENT) {
|
if (global_box->type == PARENT) {
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
for (i = 0; i < NUM_OFFSPRING; i++) {
|
for (i = 0; i < NUM_OFFSPRING; i++) {
|
||||||
if (local_box->children[i] != NULL)
|
if (local_box->children[i] != NULL)
|
||||||
MLGHelper(my_id, local_box->children[i],
|
MLGHelper(my_id, local_box->children[i],
|
||||||
global_box->children[i], global_box);
|
global_box->children[i], global_box);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
success = RemoveBoxFromGrid(global_box, global_parent);
|
success = RemoveBoxFromGrid(global_box, global_parent);
|
||||||
if (success == TRUE) {
|
if (success == TRUE) {
|
||||||
InsertParticlesInTree(my_id, global_box->particles,
|
InsertParticlesInTree(my_id, global_box->particles,
|
||||||
global_box->num_particles, local_box);
|
global_box->num_particles, local_box);
|
||||||
success = InsertBoxInGrid(my_id, local_box, global_parent);
|
success = InsertBoxInGrid(my_id, local_box, global_parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (global_box == NULL) {
|
if (global_box == NULL) {
|
||||||
success = InsertBoxInGrid(my_id, local_box, global_parent);
|
success = InsertBoxInGrid(my_id, local_box, global_parent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (global_box->type == PARENT) {
|
if (global_box->type == PARENT) {
|
||||||
MergeLocalParticles(my_id, local_box->particles,
|
MergeLocalParticles(my_id, local_box->particles,
|
||||||
local_box->num_particles, global_box);
|
local_box->num_particles, global_box);
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
success = RemoveBoxFromGrid(global_box, global_parent);
|
success = RemoveBoxFromGrid(global_box, global_parent);
|
||||||
if (success == TRUE) {
|
if (success == TRUE) {
|
||||||
InsertParticlesInLeaf(my_id, global_box->particles,
|
InsertParticlesInLeaf(my_id, global_box->particles,
|
||||||
global_box->num_particles, local_box);
|
global_box->num_particles, local_box);
|
||||||
success = InsertBoxInGrid(my_id, local_box, global_parent);
|
success = InsertBoxInGrid(my_id, local_box, global_parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success == FALSE) {
|
if (success == FALSE) {
|
||||||
if (global_parent == NULL)
|
if (global_parent == NULL)
|
||||||
global_box = Grid;
|
global_box = Grid;
|
||||||
else
|
else
|
||||||
global_box = global_parent->children[local_box->child_num];
|
global_box = global_parent->children[local_box->child_num];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,32 +615,32 @@ MergeLocalParticles (long my_id, particle **p_array, long num_of_particles, box
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
SplitParticles(p_array, num_of_particles,
|
SplitParticles(p_array, num_of_particles,
|
||||||
(particle **) p_dist, num_p_dist, pb);
|
(particle **) p_dist, num_p_dist, pb);
|
||||||
for (i= 0; i < NUM_OFFSPRING; i++) {
|
for (i= 0; i < NUM_OFFSPRING; i++) {
|
||||||
if (num_p_dist[i] > 0) {
|
if (num_p_dist[i] > 0) {
|
||||||
child = pb->children[i];
|
child = pb->children[i];
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
child = CreateLeaf(my_id, pb, i, p_dist[i], num_p_dist[i]);
|
child = CreateLeaf(my_id, pb, i, p_dist[i], num_p_dist[i]);
|
||||||
success = InsertBoxInGrid(my_id, child, pb);
|
success = InsertBoxInGrid(my_id, child, pb);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (child->type == PARENT) {
|
if (child->type == PARENT) {
|
||||||
MergeLocalParticles(my_id, p_dist[i], num_p_dist[i], child);
|
MergeLocalParticles(my_id, p_dist[i], num_p_dist[i], child);
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
success = RemoveBoxFromGrid(child, pb);
|
success = RemoveBoxFromGrid(child, pb);
|
||||||
if (success == TRUE) {
|
if (success == TRUE) {
|
||||||
InsertParticlesInLeaf(my_id, p_dist[i], num_p_dist[i], child);
|
InsertParticlesInLeaf(my_id, p_dist[i], num_p_dist[i], child);
|
||||||
success = InsertBoxInGrid(my_id, child, pb);
|
success = InsertBoxInGrid(my_id, child, pb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
child = CreateLeaf(my_id, pb, i, p_dist[i], num_p_dist[i]);
|
child = CreateLeaf(my_id, pb, i, p_dist[i], num_p_dist[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success == FALSE) {
|
if (success == FALSE) {
|
||||||
MLGHelper(my_id, child, pb->children[child->child_num], pb);
|
MLGHelper(my_id, child, pb->children[child->child_num], pb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -649,7 +648,7 @@ MergeLocalParticles (long my_id, particle **p_array, long num_of_particles, box
|
||||||
|
|
||||||
void
|
void
|
||||||
SplitParticles (particle **p_array, long length, particle **p_dist,
|
SplitParticles (particle **p_array, long length, particle **p_dist,
|
||||||
long num_p_dist[NUM_OFFSPRING], box *pb)
|
long num_p_dist[NUM_OFFSPRING], box *pb)
|
||||||
{
|
{
|
||||||
particle *p;
|
particle *p;
|
||||||
long i;
|
long i;
|
||||||
|
@ -659,16 +658,16 @@ SplitParticles (particle **p_array, long length, particle **p_dist,
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
p = p_array[i];
|
p = p_array[i];
|
||||||
if (p->pos.y > pb->y_center) {
|
if (p->pos.y > pb->y_center) {
|
||||||
if (p->pos.x > pb->x_center)
|
if (p->pos.x > pb->x_center)
|
||||||
*(p_dist + num_p_dist[0]++) = p;
|
*(p_dist + num_p_dist[0]++) = p;
|
||||||
else
|
else
|
||||||
*(p_dist + MAX_PARTICLES_PER_BOX + num_p_dist[1]++) = p;
|
*(p_dist + MAX_PARTICLES_PER_BOX + num_p_dist[1]++) = p;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (p->pos.x > pb->x_center)
|
if (p->pos.x > pb->x_center)
|
||||||
*(p_dist + (3 * MAX_PARTICLES_PER_BOX) + num_p_dist[3]++) = p;
|
*(p_dist + (3 * MAX_PARTICLES_PER_BOX) + num_p_dist[3]++) = p;
|
||||||
else
|
else
|
||||||
*(p_dist + (2 * MAX_PARTICLES_PER_BOX) + num_p_dist[2]++) = p;
|
*(p_dist + (2 * MAX_PARTICLES_PER_BOX) + num_p_dist[2]++) = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -685,23 +684,23 @@ CreateLeaf (long my_id, box *pb, long new_child_num, particle **p_array, long le
|
||||||
child_offset = pb->length / (real) NUM_OFFSPRING;
|
child_offset = pb->length / (real) NUM_OFFSPRING;
|
||||||
if (new_child_num == 0) {
|
if (new_child_num == 0) {
|
||||||
ret_box = InitBox(my_id, (pb->x_center + child_offset),
|
ret_box = InitBox(my_id, (pb->x_center + child_offset),
|
||||||
(pb->y_center + child_offset), child_length,
|
(pb->y_center + child_offset), child_length,
|
||||||
pb);
|
pb);
|
||||||
}
|
}
|
||||||
if (new_child_num == 1) {
|
if (new_child_num == 1) {
|
||||||
ret_box = InitBox(my_id, (pb->x_center - child_offset),
|
ret_box = InitBox(my_id, (pb->x_center - child_offset),
|
||||||
(pb->y_center + child_offset), child_length,
|
(pb->y_center + child_offset), child_length,
|
||||||
pb);
|
pb);
|
||||||
}
|
}
|
||||||
if (new_child_num == 2) {
|
if (new_child_num == 2) {
|
||||||
ret_box = InitBox(my_id, (pb->x_center - child_offset),
|
ret_box = InitBox(my_id, (pb->x_center - child_offset),
|
||||||
(pb->y_center - child_offset), child_length,
|
(pb->y_center - child_offset), child_length,
|
||||||
pb);
|
pb);
|
||||||
}
|
}
|
||||||
if (new_child_num == 3) {
|
if (new_child_num == 3) {
|
||||||
ret_box = InitBox(my_id, (pb->x_center + child_offset),
|
ret_box = InitBox(my_id, (pb->x_center + child_offset),
|
||||||
(pb->y_center - child_offset), child_length,
|
(pb->y_center - child_offset), child_length,
|
||||||
pb);
|
pb);
|
||||||
}
|
}
|
||||||
ret_box->child_num = new_child_num;
|
ret_box->child_num = new_child_num;
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
|
@ -720,8 +719,8 @@ InsertParticlesInLeaf (long my_id, particle **p_array, long length, box *b)
|
||||||
|
|
||||||
if ((length + b->num_particles) > MAX_PARTICLES_PER_BOX) {
|
if ((length + b->num_particles) > MAX_PARTICLES_PER_BOX) {
|
||||||
for (i = b->num_particles, j = length - 1; i < MAX_PARTICLES_PER_BOX;
|
for (i = b->num_particles, j = length - 1; i < MAX_PARTICLES_PER_BOX;
|
||||||
i++, j--)
|
i++, j--)
|
||||||
b->particles[i] = p_array[j];
|
b->particles[i] = p_array[j];
|
||||||
b->num_particles = MAX_PARTICLES_PER_BOX;
|
b->num_particles = MAX_PARTICLES_PER_BOX;
|
||||||
length = j + 1;
|
length = j + 1;
|
||||||
InsertParticlesInTree(my_id, p_array, length, b);
|
InsertParticlesInTree(my_id, p_array, length, b);
|
||||||
|
@ -729,7 +728,7 @@ InsertParticlesInLeaf (long my_id, particle **p_array, long length, box *b)
|
||||||
else {
|
else {
|
||||||
offset = b->num_particles;
|
offset = b->num_particles;
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
b->particles[i + offset] = p_array[i];
|
b->particles[i + offset] = p_array[i];
|
||||||
b->num_particles += length;
|
b->num_particles += length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -743,23 +742,23 @@ InsertBoxInGrid (long my_id, box *b, box *pb)
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
LOCK(G_Memory->single_lock);
|
LOCK(G_Memory->single_lock);
|
||||||
if (Grid == NULL) {
|
if (Grid == NULL) {
|
||||||
Grid = b;
|
Grid = b;
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
UNLOCK(G_Memory->single_lock);
|
UNLOCK(G_Memory->single_lock);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ALOCK(G_Memory->lock_array, pb->particle_lock_index);
|
ALOCK(G_Memory->lock_array, pb->particle_lock_index);
|
||||||
if (pb->children[b->child_num] == NULL) {
|
if (pb->children[b->child_num] == NULL) {
|
||||||
pb->children[b->child_num] = b;
|
pb->children[b->child_num] = b;
|
||||||
pb->num_children += 1;
|
pb->num_children += 1;
|
||||||
b->parent = pb;
|
b->parent = pb;
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
AULOCK(G_Memory->lock_array, pb->particle_lock_index);
|
AULOCK(G_Memory->lock_array, pb->particle_lock_index);
|
||||||
}
|
}
|
||||||
if (success == TRUE)
|
if (success == TRUE)
|
||||||
|
@ -776,23 +775,23 @@ RemoveBoxFromGrid (box *b, box *pb)
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
LOCK(G_Memory->single_lock);
|
LOCK(G_Memory->single_lock);
|
||||||
if (Grid == b) {
|
if (Grid == b) {
|
||||||
Grid = NULL;
|
Grid = NULL;
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
UNLOCK(G_Memory->single_lock);
|
UNLOCK(G_Memory->single_lock);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ALOCK(G_Memory->lock_array, pb->particle_lock_index);
|
ALOCK(G_Memory->lock_array, pb->particle_lock_index);
|
||||||
if (pb->children[b->child_num] == b) {
|
if (pb->children[b->child_num] == b) {
|
||||||
pb->children[b->child_num] = NULL;
|
pb->children[b->child_num] = NULL;
|
||||||
b->parent = NULL;
|
b->parent = NULL;
|
||||||
pb->num_children -= 1;
|
pb->num_children -= 1;
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
AULOCK(G_Memory->lock_array, pb->particle_lock_index);
|
AULOCK(G_Memory->lock_array, pb->particle_lock_index);
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
|
@ -810,11 +809,11 @@ InsertSubtreeInPartition (long my_id, box *b)
|
||||||
}
|
}
|
||||||
if (b->type == PARENT) {
|
if (b->type == PARENT) {
|
||||||
for (i = 0; i < NUM_OFFSPRING; i++) {
|
for (i = 0; i < NUM_OFFSPRING; i++) {
|
||||||
child = b->children[i];
|
child = b->children[i];
|
||||||
if (child == NULL)
|
if (child == NULL)
|
||||||
child = b->shadow[i];
|
child = b->shadow[i];
|
||||||
if (child != NULL)
|
if (child != NULL)
|
||||||
InsertSubtreeInPartition(my_id, child);
|
InsertSubtreeInPartition(my_id, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -828,21 +827,21 @@ CleanupGrid (long my_id)
|
||||||
b_scan = Local[my_id].Childless_Partition;
|
b_scan = Local[my_id].Childless_Partition;
|
||||||
while (b_scan != NULL) {
|
while (b_scan != NULL) {
|
||||||
if (((b_scan->parent != NULL) || (b_scan == Grid))
|
if (((b_scan->parent != NULL) || (b_scan == Grid))
|
||||||
&& (b_scan->type == CHILDLESS))
|
&& (b_scan->type == CHILDLESS))
|
||||||
b_scan = b_scan->next;
|
b_scan = b_scan->next;
|
||||||
else {
|
else {
|
||||||
tb = b_scan;
|
tb = b_scan;
|
||||||
b_scan = b_scan->next;
|
b_scan = b_scan->next;
|
||||||
if (tb->type == PARENT) {
|
if (tb->type == PARENT) {
|
||||||
tb->type = CHILDLESS;
|
tb->type = CHILDLESS;
|
||||||
RemoveBoxFromPartition(my_id, tb);
|
RemoveBoxFromPartition(my_id, tb);
|
||||||
tb->type = PARENT;
|
tb->type = PARENT;
|
||||||
if ((tb->parent != NULL) || (tb == Grid)) {
|
if ((tb->parent != NULL) || (tb == Grid)) {
|
||||||
InsertBoxInPartition(my_id, tb);
|
InsertBoxInPartition(my_id, tb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RemoveBoxFromPartition(my_id, tb);
|
RemoveBoxFromPartition(my_id, tb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,9 +865,9 @@ SetSiblings (box *b)
|
||||||
pb = b->parent;
|
pb = b->parent;
|
||||||
if (pb != NULL) {
|
if (pb != NULL) {
|
||||||
for (i = 0; i < NUM_OFFSPRING; i++) {
|
for (i = 0; i < NUM_OFFSPRING; i++) {
|
||||||
sb = pb->children[i];
|
sb = pb->children[i];
|
||||||
if ((sb != NULL) && (sb != b))
|
if ((sb != NULL) && (sb != b))
|
||||||
b->siblings[b->num_siblings++] = sb;
|
b->siblings[b->num_siblings++] = sb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -884,27 +883,27 @@ SetColleagues (long my_id, box *b)
|
||||||
pb = b->parent;
|
pb = b->parent;
|
||||||
if (pb != NULL) {
|
if (pb != NULL) {
|
||||||
for (i = 0; i < b->num_siblings; i++)
|
for (i = 0; i < b->num_siblings; i++)
|
||||||
b->colleagues[b->num_colleagues++] = b->siblings[i];
|
b->colleagues[b->num_colleagues++] = b->siblings[i];
|
||||||
while (b->construct_synch == 0) {
|
while (b->construct_synch == 0) {
|
||||||
/* wait */;
|
/* wait */;
|
||||||
}
|
}
|
||||||
b->construct_synch = 0;
|
b->construct_synch = 0;
|
||||||
for (i = 0; i < pb->num_colleagues; i++) {
|
for (i = 0; i < pb->num_colleagues; i++) {
|
||||||
cb = pb->colleagues[i];
|
cb = pb->colleagues[i];
|
||||||
for (j = 0; j < NUM_OFFSPRING; j++) {
|
for (j = 0; j < NUM_OFFSPRING; j++) {
|
||||||
cousin = cb->children[j];
|
cousin = cb->children[j];
|
||||||
if (cousin != NULL) {
|
if (cousin != NULL) {
|
||||||
if (AdjacentBoxes(b, cousin) == TRUE)
|
if (AdjacentBoxes(b, cousin) == TRUE)
|
||||||
b->colleagues[b->num_colleagues++] = cousin;
|
b->colleagues[b->num_colleagues++] = cousin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (b->type == PARENT) {
|
if (b->type == PARENT) {
|
||||||
for (i = 0; i < NUM_OFFSPRING; i++) {
|
for (i = 0; i < NUM_OFFSPRING; i++) {
|
||||||
if (b->children[i] != NULL) {
|
if (b->children[i] != NULL) {
|
||||||
b->children[i]->construct_synch = 1;
|
b->children[i]->construct_synch = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -944,14 +943,14 @@ SetVList (long my_id, box *b)
|
||||||
pb = b->parent;
|
pb = b->parent;
|
||||||
if (pb != NULL) {
|
if (pb != NULL) {
|
||||||
for (i = 0; i < pb->num_colleagues; i++) {
|
for (i = 0; i < pb->num_colleagues; i++) {
|
||||||
cb = pb->colleagues[i];
|
cb = pb->colleagues[i];
|
||||||
for (j = 0; j < NUM_OFFSPRING; j++) {
|
for (j = 0; j < NUM_OFFSPRING; j++) {
|
||||||
cousin = cb->children[j];
|
cousin = cb->children[j];
|
||||||
if (cousin != NULL) {
|
if (cousin != NULL) {
|
||||||
if (WellSeparatedBoxes(b, cousin) == TRUE)
|
if (WellSeparatedBoxes(b, cousin) == TRUE)
|
||||||
b->v_list[b->num_v_list++] = cousin;
|
b->v_list[b->num_v_list++] = cousin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -999,16 +998,16 @@ SetUListHelper (long my_id, box *b, box *pb)
|
||||||
for (i = 0; i < NUM_OFFSPRING; i++) {
|
for (i = 0; i < NUM_OFFSPRING; i++) {
|
||||||
child = pb->children[i];
|
child = pb->children[i];
|
||||||
if (child != NULL) {
|
if (child != NULL) {
|
||||||
if (AdjacentBoxes(b, child) == TRUE) {
|
if (AdjacentBoxes(b, child) == TRUE) {
|
||||||
if (child->type == CHILDLESS)
|
if (child->type == CHILDLESS)
|
||||||
b->u_list[b->num_u_list++] = child;
|
b->u_list[b->num_u_list++] = child;
|
||||||
else
|
else
|
||||||
SetUListHelper(my_id, b, child);
|
SetUListHelper(my_id, b, child);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (AncestorBox(b, child) == TRUE)
|
if (AncestorBox(b, child) == TRUE)
|
||||||
SetUListHelper(my_id, b, child);
|
SetUListHelper(my_id, b, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,8 +1041,8 @@ AncestorBox (box *b, box *ancestor_box)
|
||||||
x_center_distance = fabs((double)(b->x_center - ancestor_box->x_center));
|
x_center_distance = fabs((double)(b->x_center - ancestor_box->x_center));
|
||||||
y_center_distance = fabs((double)(b->y_center - ancestor_box->y_center));
|
y_center_distance = fabs((double)(b->y_center - ancestor_box->y_center));
|
||||||
if ((x_center_distance > (ancestor_box->length / 2.0)) ||
|
if ((x_center_distance > (ancestor_box->length / 2.0)) ||
|
||||||
(y_center_distance > (ancestor_box->length / 2.0)))
|
(y_center_distance > (ancestor_box->length / 2.0)))
|
||||||
ret_val = FALSE;
|
ret_val = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret_val = FALSE;
|
ret_val = FALSE;
|
||||||
|
@ -1077,7 +1076,7 @@ SetWList (long my_id, box *b)
|
||||||
for (i = 0; i < b->num_colleagues; i++) {
|
for (i = 0; i < b->num_colleagues; i++) {
|
||||||
co_search = b->colleagues[i];
|
co_search = b->colleagues[i];
|
||||||
if (co_search->type == PARENT)
|
if (co_search->type == PARENT)
|
||||||
InsertNonAdjChildren(my_id, b, co_search);
|
InsertNonAdjChildren(my_id, b, co_search);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1106,12 +1105,12 @@ InsertNonAdjChildren (long my_id, box *b, box *pb)
|
||||||
for (i = 0; i < pb->num_children; i++) {
|
for (i = 0; i < pb->num_children; i++) {
|
||||||
child = pb->children[i];
|
child = pb->children[i];
|
||||||
if (child != NULL) {
|
if (child != NULL) {
|
||||||
if (AdjacentBoxes(b, child) == TRUE) {
|
if (AdjacentBoxes(b, child) == TRUE) {
|
||||||
if (child->type == PARENT)
|
if (child->type == PARENT)
|
||||||
InsertNonAdjChildren(my_id, b, child);
|
InsertNonAdjChildren(my_id, b, child);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
b->w_list[b->num_w_list++] = child;
|
b->w_list[b->num_w_list++] = child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "cost_zones.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "box.h"
|
||||||
#include "partition_grid.h"
|
#include "partition_grid.h"
|
||||||
|
#include "cost_zones.h"
|
||||||
|
|
||||||
#define NUM_DIRECTIONS 4
|
#define NUM_DIRECTIONS 4
|
||||||
|
|
||||||
|
@ -50,13 +50,13 @@ CostZones (long my_id)
|
||||||
BARRIER(G_Memory->synch, Number_Of_Processors);
|
BARRIER(G_Memory->synch, Number_Of_Processors);
|
||||||
Local[my_id].Total_Work = Grid->subtree_cost;
|
Local[my_id].Total_Work = Grid->subtree_cost;
|
||||||
Local[my_id].Min_Work = ((Local[my_id].Total_Work / Number_Of_Processors)
|
Local[my_id].Min_Work = ((Local[my_id].Total_Work / Number_Of_Processors)
|
||||||
* my_id);
|
* my_id);
|
||||||
if (my_id == (Number_Of_Processors - 1))
|
if (my_id == (Number_Of_Processors - 1))
|
||||||
Local[my_id].Max_Work = Local[my_id].Total_Work;
|
Local[my_id].Max_Work = Local[my_id].Total_Work;
|
||||||
else
|
else
|
||||||
Local[my_id].Max_Work = (Local[my_id].Min_Work
|
Local[my_id].Max_Work = (Local[my_id].Min_Work
|
||||||
+ (Local[my_id].Total_Work
|
+ (Local[my_id].Total_Work
|
||||||
/ Number_Of_Processors));
|
/ Number_Of_Processors));
|
||||||
InitPartition(my_id);
|
InitPartition(my_id);
|
||||||
CostZonesHelper(my_id, Grid, 0, RIGHT);
|
CostZonesHelper(my_id, Grid, 0, RIGHT);
|
||||||
BARRIER(G_Memory->synch, Number_Of_Processors);
|
BARRIER(G_Memory->synch, Number_Of_Processors);
|
||||||
|
@ -95,25 +95,25 @@ CostZonesHelper (long my_id, box *b, long work, direction dir)
|
||||||
|
|
||||||
if (b->type == CHILDLESS) {
|
if (b->type == CHILDLESS) {
|
||||||
if (work >= Local[my_id].Min_Work)
|
if (work >= Local[my_id].Min_Work)
|
||||||
InsertBoxInPartition(my_id, b);
|
InsertBoxInPartition(my_id, b);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
next_child = Child_Sequence[dir];
|
next_child = Child_Sequence[dir];
|
||||||
child_dir = Direction_Sequence[dir];
|
child_dir = Direction_Sequence[dir];
|
||||||
for (i = 0; (i < NUM_OFFSPRING) && (work < Local[my_id].Max_Work);
|
for (i = 0; (i < NUM_OFFSPRING) && (work < Local[my_id].Max_Work);
|
||||||
i++) {
|
i++) {
|
||||||
cb = b->children[next_child[i]];
|
cb = b->children[next_child[i]];
|
||||||
if (cb != NULL) {
|
if (cb != NULL) {
|
||||||
if ((work + cb->subtree_cost) >= Local[my_id].Min_Work)
|
if ((work + cb->subtree_cost) >= Local[my_id].Min_Work)
|
||||||
CostZonesHelper(my_id, cb, work, child_dir[i]);
|
CostZonesHelper(my_id, cb, work, child_dir[i]);
|
||||||
work += cb->subtree_cost;
|
work += cb->subtree_cost;
|
||||||
}
|
}
|
||||||
if (i == 2) {
|
if (i == 2) {
|
||||||
if ((work >= Local[my_id].Min_Work)
|
if ((work >= Local[my_id].Min_Work)
|
||||||
&& (work < Local[my_id].Max_Work))
|
&& (work < Local[my_id].Max_Work))
|
||||||
InsertBoxInPartition(my_id, b);
|
InsertBoxInPartition(my_id, b);
|
||||||
work += b->cost;
|
work += b->cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,9 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdarg>
|
#include <stdarg.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
#ifndef _Defs_H
|
#ifndef _Defs_H
|
||||||
#define _Defs_H 1
|
#define _Defs_H 1
|
||||||
|
|
||||||
#include <cassert>
|
#include <stdio.h>
|
||||||
#include <climits>
|
#include <stdlib.h>
|
||||||
#include <cmath>
|
#include <assert.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <limits.h>
|
||||||
|
|
||||||
/* Define booleans */
|
/* Define booleans */
|
||||||
#ifdef TRUE
|
#ifdef TRUE
|
||||||
|
|
|
@ -66,20 +66,19 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cerrno>
|
#include <stdio.h>
|
||||||
#include <cmath>
|
#include <math.h>
|
||||||
#include <cstdio>
|
#include <errno.h>
|
||||||
#include <cstdlib>
|
#include <stdlib.h>
|
||||||
#include <cstring>
|
#include <string.h>
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "construct_grid.h"
|
|
||||||
#include "cost_zones.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "interactions.h"
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
#include "box.h"
|
||||||
#include "partition_grid.h"
|
#include "partition_grid.h"
|
||||||
|
#include "cost_zones.h"
|
||||||
|
#include "construct_grid.h"
|
||||||
|
#include "interactions.h"
|
||||||
|
|
||||||
#define BASE ((((double) 4) - sqrt((double) 2)) / sqrt((double) 2))
|
#define BASE ((((double) 4) - sqrt((double) 2)) / sqrt((double) 2))
|
||||||
#define MAX_LINE_SIZE 100
|
#define MAX_LINE_SIZE 100
|
||||||
|
@ -189,7 +188,7 @@ ParallelExecute ()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CreateParticleList(my_id, ((Total_Particles * PDF)
|
CreateParticleList(my_id, ((Total_Particles * PDF)
|
||||||
/ Number_Of_Processors));
|
/ Number_Of_Processors));
|
||||||
InitParticleList(my_id, 0, 0);
|
InitParticleList(my_id, 0, 0);
|
||||||
}
|
}
|
||||||
num_boxes = 1.333 * (Total_Particles / (OCCUPANCY * MAX_PARTICLES_PER_BOX));
|
num_boxes = 1.333 * (Total_Particles / (OCCUPANCY * MAX_PARTICLES_PER_BOX));
|
||||||
|
@ -200,7 +199,7 @@ ParallelExecute ()
|
||||||
|
|
||||||
if (my_id == 0) {
|
if (my_id == 0) {
|
||||||
LockedPrint("Starting FMM with %d processor%s\n", Number_Of_Processors,
|
LockedPrint("Starting FMM with %d processor%s\n", Number_Of_Processors,
|
||||||
(Number_Of_Processors == 1) ? "" : "s");
|
(Number_Of_Processors == 1) ? "" : "s");
|
||||||
}
|
}
|
||||||
BARRIER(G_Memory->synch, Number_Of_Processors);
|
BARRIER(G_Memory->synch, Number_Of_Processors);
|
||||||
Local[my_id].Time = 0.0;
|
Local[my_id].Time = 0.0;
|
||||||
|
@ -218,10 +217,10 @@ ParallelExecute ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MY_TIME_STEP == 0) {
|
if (MY_TIME_STEP == 0) {
|
||||||
CLOCK(start);
|
CLOCK(start);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
start = finish;
|
start = finish;
|
||||||
ConstructGrid(my_id,local_time,time_all);
|
ConstructGrid(my_id,local_time,time_all);
|
||||||
ConstructLists(my_id,local_time,time_all);
|
ConstructLists(my_id,local_time,time_all);
|
||||||
PartitionGrid(my_id,local_time,time_all);
|
PartitionGrid(my_id,local_time,time_all);
|
||||||
|
@ -316,12 +315,12 @@ GetArguments ()
|
||||||
Cluster = ONE_CLUSTER;
|
Cluster = ONE_CLUSTER;
|
||||||
else {
|
else {
|
||||||
if ((*input == '\0') || (strcmp(input, "two cluster") == 0))
|
if ((*input == '\0') || (strcmp(input, "two cluster") == 0))
|
||||||
Cluster = TWO_CLUSTER;
|
Cluster = TWO_CLUSTER;
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "ERROR: The only cluster types available are ");
|
fprintf(stderr, "ERROR: The only cluster types available are ");
|
||||||
fprintf(stderr, "\"one cluster\" or \"two cluster\".\n");
|
fprintf(stderr, "\"one cluster\" or \"two cluster\".\n");
|
||||||
fprintf(stderr, "If you need help, type \"nbody -help\".\n");
|
fprintf(stderr, "If you need help, type \"nbody -help\".\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,12 +329,12 @@ GetArguments ()
|
||||||
Model = UNIFORM;
|
Model = UNIFORM;
|
||||||
else {
|
else {
|
||||||
if ((*input == '\0') || (strcmp(input, "plummer") == 0))
|
if ((*input == '\0') || (strcmp(input, "plummer") == 0))
|
||||||
Model = PLUMMER;
|
Model = PLUMMER;
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "ERROR: The only distributions available are ");
|
fprintf(stderr, "ERROR: The only distributions available are ");
|
||||||
fprintf(stderr, "\"uniform\" or \"plummer\".\n");
|
fprintf(stderr, "\"uniform\" or \"plummer\".\n");
|
||||||
fprintf(stderr, "If you need help, type \"nbody -help\".\n");
|
fprintf(stderr, "If you need help, type \"nbody -help\".\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,12 +415,12 @@ GetArguments ()
|
||||||
Partition_Flag = COST_ZONES;
|
Partition_Flag = COST_ZONES;
|
||||||
else {
|
else {
|
||||||
if (strcmp(input, "orb") == 0)
|
if (strcmp(input, "orb") == 0)
|
||||||
Partition_Flag = ORB;
|
Partition_Flag = ORB;
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "ERROR: The only partitioning schemes available ");
|
fprintf(stderr, "ERROR: The only partitioning schemes available ");
|
||||||
fprintf(stderr, "are \"cost zones\" \n\t or \"orb\".\n");
|
fprintf(stderr, "are \"cost zones\" \n\t or \"orb\".\n");
|
||||||
fprintf(stderr, "If you need help, type \"nbody -help\".\n");
|
fprintf(stderr, "If you need help, type \"nbody -help\".\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,21 +464,21 @@ PrintTimes ()
|
||||||
for (i = 0; i < Time_Steps; i++) {
|
for (i = 0; i < Time_Steps; i++) {
|
||||||
fprintf(fp, "Time Step %ld\n", i);
|
fprintf(fp, "Time Step %ld\n", i);
|
||||||
for (j = 0; j < Number_Of_Processors; j++) {
|
for (j = 0; j < Number_Of_Processors; j++) {
|
||||||
timing = &(Local[j].Timing[i]);
|
timing = &(Local[j].Timing[i]);
|
||||||
fprintf(fp, "Processor %ld\n", j);
|
fprintf(fp, "Processor %ld\n", j);
|
||||||
fprintf(fp, "\tTotal Time = %lu\n", timing->total_time);
|
fprintf(fp, "\tTotal Time = %lu\n", timing->total_time);
|
||||||
if (do_stats) {
|
if (do_stats) {
|
||||||
fprintf(fp, "\tTree Construction Time = %lu\n",
|
fprintf(fp, "\tTree Construction Time = %lu\n",
|
||||||
timing->construct_time);
|
timing->construct_time);
|
||||||
fprintf(fp, "\tList Construction Time = %lu\n", timing->list_time);
|
fprintf(fp, "\tList Construction Time = %lu\n", timing->list_time);
|
||||||
fprintf(fp, "\tPartition Time = %lu\n", timing->partition_time);
|
fprintf(fp, "\tPartition Time = %lu\n", timing->partition_time);
|
||||||
fprintf(fp, "\tTree Pass Time = %lu\n", timing->pass_time);
|
fprintf(fp, "\tTree Pass Time = %lu\n", timing->pass_time);
|
||||||
fprintf(fp, "\tInter Particle Time = %lu\n", timing->inter_time);
|
fprintf(fp, "\tInter Particle Time = %lu\n", timing->inter_time);
|
||||||
fprintf(fp, "\tBarrier Time = %lu\n", timing->barrier_time);
|
fprintf(fp, "\tBarrier Time = %lu\n", timing->barrier_time);
|
||||||
fprintf(fp, "\tIntra Particle Time = %lu\n", timing->intra_time);
|
fprintf(fp, "\tIntra Particle Time = %lu\n", timing->intra_time);
|
||||||
fprintf(fp, "\tOther Time = %lu\n", timing->other_time);
|
fprintf(fp, "\tOther Time = %lu\n", timing->other_time);
|
||||||
}
|
}
|
||||||
fflush(fp);
|
fflush(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(fp, "END\n");
|
fprintf(fp, "END\n");
|
||||||
|
@ -554,8 +553,8 @@ PrintTimes ()
|
||||||
P = Number_Of_Processors;
|
P = Number_Of_Processors;
|
||||||
printf(" Avg %12.0f%12.0f%12.0f%12.0f%12.0f%12.0f%12.0f%12.0f%12.0f\n",
|
printf(" Avg %12.0f%12.0f%12.0f%12.0f%12.0f%12.0f%12.0f%12.0f%12.0f\n",
|
||||||
t_total_time/P,t_tree_time/P,t_list_time/P,t_part_time/P,
|
t_total_time/P,t_tree_time/P,t_list_time/P,t_part_time/P,
|
||||||
t_pass_time/P,t_inter_time/P,t_bar_time/P,t_intra_time/P,
|
t_pass_time/P,t_inter_time/P,t_bar_time/P,t_intra_time/P,
|
||||||
t_other_time/P);
|
t_other_time/P);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if (Time_Steps > 2) {
|
if (Time_Steps > 2) {
|
||||||
|
|
|
@ -14,15 +14,14 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "interactions.h"
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
#include "box.h"
|
||||||
#include "partition_grid.h"
|
#include "partition_grid.h"
|
||||||
|
#include "interactions.h"
|
||||||
|
|
||||||
static real Inv[MAX_EXPANSION_TERMS + 1];
|
static real Inv[MAX_EXPANSION_TERMS + 1];
|
||||||
static real OverInc[MAX_EXPANSION_TERMS + 1];
|
static real OverInc[MAX_EXPANSION_TERMS + 1];
|
||||||
|
@ -59,7 +58,7 @@ InitExpTables ()
|
||||||
C[i][1] = (real) i;
|
C[i][1] = (real) i;
|
||||||
C[i - 1][i] = (real) 0.0;
|
C[i - 1][i] = (real) 0.0;
|
||||||
for (j = 2; j <= i; j++)
|
for (j = 2; j <= i; j++)
|
||||||
C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
|
C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
One.r = (real) 1.0;
|
One.r = (real) 1.0;
|
||||||
|
@ -83,7 +82,7 @@ PrintExpTables ()
|
||||||
printf("i\tj\th(i,j)\n");
|
printf("i\tj\th(i,j)\n");
|
||||||
for (i = 0; i < (2 * MAX_EXPANSION_TERMS); i++) {
|
for (i = 0; i < (2 * MAX_EXPANSION_TERMS); i++) {
|
||||||
for (j = 0; j <= i; j++)
|
for (j = 0; j <= i; j++)
|
||||||
printf("%ld\t%ld\t%g\n", i, j, C[i][j]);
|
printf("%ld\t%ld\t%g\n", i, j, C[i][j]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +100,7 @@ UpwardPass (long my_id, box *b)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (b->interaction_synch != b->num_children) {
|
while (b->interaction_synch != b->num_children) {
|
||||||
/* wait */;
|
/* wait */;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (b->parent != NULL) {
|
if (b->parent != NULL) {
|
||||||
|
@ -131,7 +130,7 @@ DownwardPass (long my_id, box *b)
|
||||||
{
|
{
|
||||||
if (b->parent != NULL) {
|
if (b->parent != NULL) {
|
||||||
while (b->parent->interaction_synch != 0) {
|
while (b->parent->interaction_synch != 0) {
|
||||||
/* wait */;
|
/* wait */;
|
||||||
}
|
}
|
||||||
ShiftLocalExp(b->parent, b);
|
ShiftLocalExp(b->parent, b);
|
||||||
}
|
}
|
||||||
|
@ -165,9 +164,9 @@ ComputeParticlePositions (long my_id, box *b)
|
||||||
force.y = p->field.i * p->charge;
|
force.y = p->field.i * p->charge;
|
||||||
VECTOR_DIV(new_acc, force, p->mass);
|
VECTOR_DIV(new_acc, force, p->mass);
|
||||||
if (Local[my_id].Time_Step != 0) {
|
if (Local[my_id].Time_Step != 0) {
|
||||||
VECTOR_SUB(delta_acc, new_acc, (p->acc));
|
VECTOR_SUB(delta_acc, new_acc, (p->acc));
|
||||||
VECTOR_MUL(delta_vel, delta_acc, ((real) Timestep_Dur) / (real) 2.0);
|
VECTOR_MUL(delta_vel, delta_acc, ((real) Timestep_Dur) / (real) 2.0);
|
||||||
VECTOR_ADD((p->vel), (p->vel), delta_vel);
|
VECTOR_ADD((p->vel), (p->vel), delta_vel);
|
||||||
}
|
}
|
||||||
p->acc.x = new_acc.x;
|
p->acc.x = new_acc.x;
|
||||||
p->acc.y = new_acc.y;
|
p->acc.y = new_acc.y;
|
||||||
|
@ -242,9 +241,9 @@ ComputeMPExp (box *b)
|
||||||
z0_pow_n.r = One.r;
|
z0_pow_n.r = One.r;
|
||||||
z0_pow_n.i = One.i;
|
z0_pow_n.i = One.i;
|
||||||
for (j = 1; j < Expansion_Terms; j++) {
|
for (j = 1; j < Expansion_Terms; j++) {
|
||||||
COMPLEX_MUL(temp, z0_pow_n, charge);
|
COMPLEX_MUL(temp, z0_pow_n, charge);
|
||||||
COMPLEX_ADD(result_exp[j], result_exp[j], temp);
|
COMPLEX_ADD(result_exp[j], result_exp[j], temp);
|
||||||
COMPLEX_MUL(z0_pow_n, z0_pow_n, z0);
|
COMPLEX_MUL(z0_pow_n, z0_pow_n, z0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ALOCK(G_Memory->lock_array, b->exp_lock_index);
|
ALOCK(G_Memory->lock_array, b->exp_lock_index);
|
||||||
|
@ -289,10 +288,10 @@ ShiftMPExp (box *cb, box *pb)
|
||||||
COMPLEX_MUL(z0_pow_minus_n, z0_pow_minus_n, z0_inv);
|
COMPLEX_MUL(z0_pow_minus_n, z0_pow_minus_n, z0_inv);
|
||||||
COMPLEX_MUL(temp_exp[i], z0_pow_minus_n, cb->mp_expansion[i]);
|
COMPLEX_MUL(temp_exp[i], z0_pow_minus_n, cb->mp_expansion[i]);
|
||||||
for (j = 1; j <= i; j++) {
|
for (j = 1; j <= i; j++) {
|
||||||
temp.r = C[i - 1][j - 1];
|
temp.r = C[i - 1][j - 1];
|
||||||
temp.i = (real) 0.0;
|
temp.i = (real) 0.0;
|
||||||
COMPLEX_MUL(temp, temp, temp_exp[j]);
|
COMPLEX_MUL(temp, temp, temp_exp[j]);
|
||||||
COMPLEX_ADD(result_exp[i], result_exp[i], temp);
|
COMPLEX_ADD(result_exp[i], result_exp[i], temp);
|
||||||
}
|
}
|
||||||
temp.r = Inv[i];
|
temp.r = Inv[i];
|
||||||
temp.i = (real) 0.0;
|
temp.i = (real) 0.0;
|
||||||
|
@ -330,23 +329,23 @@ UListInteraction (long my_id, box *source_box, box *dest_box)
|
||||||
dest_x = dest_box->particles[i]->pos.x;
|
dest_x = dest_box->particles[i]->pos.x;
|
||||||
dest_y = dest_box->particles[i]->pos.y;
|
dest_y = dest_box->particles[i]->pos.y;
|
||||||
for (j = 0; j < source_box->num_particles; j++) {
|
for (j = 0; j < source_box->num_particles; j++) {
|
||||||
x_sep = source_box->particles[j]->pos.x - dest_x;
|
x_sep = source_box->particles[j]->pos.x - dest_x;
|
||||||
y_sep = source_box->particles[j]->pos.y - dest_y;
|
y_sep = source_box->particles[j]->pos.y - dest_y;
|
||||||
denom = ((real) 1.0) / ((x_sep * x_sep) + (y_sep * y_sep));
|
denom = ((real) 1.0) / ((x_sep * x_sep) + (y_sep * y_sep));
|
||||||
temp_vector.r = x_sep * denom;
|
temp_vector.r = x_sep * denom;
|
||||||
temp_vector.i = y_sep * denom;
|
temp_vector.i = y_sep * denom;
|
||||||
temp_charge.r = source_box->particles[j]->charge;
|
temp_charge.r = source_box->particles[j]->charge;
|
||||||
temp_charge.i = (real) 0.0;
|
temp_charge.i = (real) 0.0;
|
||||||
COMPLEX_MUL(temp_result, temp_vector, temp_charge);
|
COMPLEX_MUL(temp_result, temp_vector, temp_charge);
|
||||||
COMPLEX_SUB(result, result, temp_result);
|
COMPLEX_SUB(result, result, temp_result);
|
||||||
}
|
}
|
||||||
result.i = -result.i;
|
result.i = -result.i;
|
||||||
COMPLEX_ADD((dest_box->particles[i]->field),
|
COMPLEX_ADD((dest_box->particles[i]->field),
|
||||||
(dest_box->particles[i]->field), result);
|
(dest_box->particles[i]->field), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
dest_box->cost += U_LIST_COST(source_box->num_particles,
|
dest_box->cost += U_LIST_COST(source_box->num_particles,
|
||||||
dest_box->num_particles);
|
dest_box->num_particles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,12 +365,12 @@ VListInteraction (long my_id, box *source_box, box *dest_box)
|
||||||
|
|
||||||
if (source_box->type == CHILDLESS) {
|
if (source_box->type == CHILDLESS) {
|
||||||
while (source_box->interaction_synch != 1) {
|
while (source_box->interaction_synch != 1) {
|
||||||
/* wait */;
|
/* wait */;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (source_box->interaction_synch != source_box->num_children) {
|
while (source_box->interaction_synch != source_box->num_children) {
|
||||||
/* wait */;
|
/* wait */;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,32 +392,32 @@ VListInteraction (long my_id, box *source_box, box *dest_box)
|
||||||
result_exp.r = (real) 0.0;
|
result_exp.r = (real) 0.0;
|
||||||
result_exp.i = (real) 0.0;
|
result_exp.i = (real) 0.0;
|
||||||
for (j = 1; j < Expansion_Terms; j++) {
|
for (j = 1; j < Expansion_Terms; j++) {
|
||||||
temp.r = C[i + j - 1][j - 1];
|
temp.r = C[i + j - 1][j - 1];
|
||||||
temp.i = (real) 0.0;
|
temp.i = (real) 0.0;
|
||||||
COMPLEX_MUL(temp, temp, temp_exp[j]);
|
COMPLEX_MUL(temp, temp, temp_exp[j]);
|
||||||
if ((j & 0x1) == 0x0) {
|
if ((j & 0x1) == 0x0) {
|
||||||
COMPLEX_ADD(result_exp, result_exp, temp);
|
COMPLEX_ADD(result_exp, result_exp, temp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
COMPLEX_SUB(result_exp, result_exp, temp);
|
COMPLEX_SUB(result_exp, result_exp, temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
COMPLEX_MUL(result_exp, result_exp, z0_pow_minus_n[i]);
|
COMPLEX_MUL(result_exp, result_exp, z0_pow_minus_n[i]);
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
temp.r = log(COMPLEX_ABS(z0));
|
temp.r = log(COMPLEX_ABS(z0));
|
||||||
temp.i = (real) 0.0;
|
temp.i = (real) 0.0;
|
||||||
COMPLEX_MUL(temp, temp, source_box->mp_expansion[0]);
|
COMPLEX_MUL(temp, temp, source_box->mp_expansion[0]);
|
||||||
COMPLEX_ADD(result_exp, result_exp, temp);
|
COMPLEX_ADD(result_exp, result_exp, temp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
temp.r = Inv[i];
|
temp.r = Inv[i];
|
||||||
temp.i = (real) 0.0;
|
temp.i = (real) 0.0;
|
||||||
COMPLEX_MUL(temp, temp, z0_pow_minus_n[i]);
|
COMPLEX_MUL(temp, temp, z0_pow_minus_n[i]);
|
||||||
COMPLEX_MUL(temp, temp, source_box->mp_expansion[0]);
|
COMPLEX_MUL(temp, temp, source_box->mp_expansion[0]);
|
||||||
COMPLEX_SUB(result_exp, result_exp, temp);
|
COMPLEX_SUB(result_exp, result_exp, temp);
|
||||||
}
|
}
|
||||||
COMPLEX_ADD((dest_box->local_expansion[i]),
|
COMPLEX_ADD((dest_box->local_expansion[i]),
|
||||||
(dest_box->local_expansion[i]), result_exp);
|
(dest_box->local_expansion[i]), result_exp);
|
||||||
}
|
}
|
||||||
dest_box->cost += V_LIST_COST(Expansion_Terms);
|
dest_box->cost += V_LIST_COST(Expansion_Terms);
|
||||||
}
|
}
|
||||||
|
@ -445,12 +444,12 @@ WListInteraction (box *source_box, box *dest_box)
|
||||||
|
|
||||||
if (source_box->type == CHILDLESS) {
|
if (source_box->type == CHILDLESS) {
|
||||||
while (source_box->interaction_synch != 1) {
|
while (source_box->interaction_synch != 1) {
|
||||||
/* wait */;
|
/* wait */;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (source_box->interaction_synch != source_box->num_children) {
|
while (source_box->interaction_synch != source_box->num_children) {
|
||||||
/* wait */;
|
/* wait */;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,11 +463,11 @@ WListInteraction (box *source_box, box *dest_box)
|
||||||
COMPLEX_SUB(z0, particle_pos, source_pos);
|
COMPLEX_SUB(z0, particle_pos, source_pos);
|
||||||
COMPLEX_DIV(z0_inv, One, z0);
|
COMPLEX_DIV(z0_inv, One, z0);
|
||||||
for (j = Expansion_Terms - 1; j > 0; j--) {
|
for (j = Expansion_Terms - 1; j > 0; j--) {
|
||||||
COMPLEX_ADD(result, result, (source_box->mp_expansion[j]));
|
COMPLEX_ADD(result, result, (source_box->mp_expansion[j]));
|
||||||
COMPLEX_MUL(result, result, z0_inv);
|
COMPLEX_MUL(result, result, z0_inv);
|
||||||
}
|
}
|
||||||
COMPLEX_ADD((dest_box->particles[i]->field),
|
COMPLEX_ADD((dest_box->particles[i]->field),
|
||||||
(dest_box->particles[i]->field), result);
|
(dest_box->particles[i]->field), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
dest_box->cost += W_LIST_COST(dest_box->num_particles, Expansion_Terms);
|
dest_box->cost += W_LIST_COST(dest_box->num_particles, Expansion_Terms);
|
||||||
|
@ -505,15 +504,15 @@ XListInteraction (box *source_box, box *dest_box)
|
||||||
z0_pow_minus_n.r = z0_inv.r;
|
z0_pow_minus_n.r = z0_inv.r;
|
||||||
z0_pow_minus_n.i = z0_inv.i;
|
z0_pow_minus_n.i = z0_inv.i;
|
||||||
for (j = 1; j < Expansion_Terms; j++) {
|
for (j = 1; j < Expansion_Terms; j++) {
|
||||||
COMPLEX_MUL(z0_pow_minus_n, z0_pow_minus_n, z0_inv);
|
COMPLEX_MUL(z0_pow_minus_n, z0_pow_minus_n, z0_inv);
|
||||||
COMPLEX_MUL(temp, charge, z0_pow_minus_n);
|
COMPLEX_MUL(temp, charge, z0_pow_minus_n);
|
||||||
COMPLEX_ADD(result_exp[j], result_exp[j], temp);
|
COMPLEX_ADD(result_exp[j], result_exp[j], temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ALOCK(G_Memory->lock_array, dest_box->exp_lock_index);
|
ALOCK(G_Memory->lock_array, dest_box->exp_lock_index);
|
||||||
for (i = 0; i < Expansion_Terms; i++) {
|
for (i = 0; i < Expansion_Terms; i++) {
|
||||||
COMPLEX_SUB((dest_box->x_expansion[i]),
|
COMPLEX_SUB((dest_box->x_expansion[i]),
|
||||||
(dest_box->x_expansion[i]), result_exp[i]);
|
(dest_box->x_expansion[i]), result_exp[i]);
|
||||||
}
|
}
|
||||||
AULOCK(G_Memory->lock_array, dest_box->exp_lock_index);
|
AULOCK(G_Memory->lock_array, dest_box->exp_lock_index);
|
||||||
source_box->cost += X_LIST_COST(source_box->num_particles, Expansion_Terms);
|
source_box->cost += X_LIST_COST(source_box->num_particles, Expansion_Terms);
|
||||||
|
@ -540,37 +539,37 @@ ComputeSelfInteraction (box *b)
|
||||||
|
|
||||||
for (i = 0; i < b->num_particles; i++) {
|
for (i = 0; i < b->num_particles; i++) {
|
||||||
for (j = i + 1; j < b->num_particles; j++) {
|
for (j = i + 1; j < b->num_particles; j++) {
|
||||||
x_sep = b->particles[i]->pos.x - b->particles[j]->pos.x;
|
x_sep = b->particles[i]->pos.x - b->particles[j]->pos.x;
|
||||||
y_sep = b->particles[i]->pos.y - b->particles[j]->pos.y;
|
y_sep = b->particles[i]->pos.y - b->particles[j]->pos.y;
|
||||||
|
|
||||||
if ((fabs(x_sep) < Softening_Param)
|
if ((fabs(x_sep) < Softening_Param)
|
||||||
&& (fabs(y_sep) < Softening_Param)) {
|
&& (fabs(y_sep) < Softening_Param)) {
|
||||||
if (x_sep >= 0.0)
|
if (x_sep >= 0.0)
|
||||||
x_sep = Softening_Param;
|
x_sep = Softening_Param;
|
||||||
else
|
else
|
||||||
x_sep = -Softening_Param;
|
x_sep = -Softening_Param;
|
||||||
if (y_sep >= 0.0)
|
if (y_sep >= 0.0)
|
||||||
y_sep = Softening_Param;
|
y_sep = Softening_Param;
|
||||||
else
|
else
|
||||||
y_sep = -Softening_Param;
|
y_sep = -Softening_Param;
|
||||||
}
|
}
|
||||||
denom = ((real) 1.0) / ((x_sep * x_sep) + (y_sep * y_sep));
|
denom = ((real) 1.0) / ((x_sep * x_sep) + (y_sep * y_sep));
|
||||||
temp_vector.r = x_sep * denom;
|
temp_vector.r = x_sep * denom;
|
||||||
temp_vector.i = y_sep * denom;
|
temp_vector.i = y_sep * denom;
|
||||||
|
|
||||||
temp_charge.r = b->particles[j]->charge;
|
temp_charge.r = b->particles[j]->charge;
|
||||||
temp_charge.i = (real) 0.0;
|
temp_charge.i = (real) 0.0;
|
||||||
COMPLEX_MUL(temp_result, temp_vector, temp_charge);
|
COMPLEX_MUL(temp_result, temp_vector, temp_charge);
|
||||||
COMPLEX_ADD(results[i], results[i], temp_result);
|
COMPLEX_ADD(results[i], results[i], temp_result);
|
||||||
|
|
||||||
temp_charge.r = b->particles[i]->charge;
|
temp_charge.r = b->particles[i]->charge;
|
||||||
temp_charge.i = (real) 0.0;
|
temp_charge.i = (real) 0.0;
|
||||||
COMPLEX_MUL(temp_result, temp_vector, temp_charge);
|
COMPLEX_MUL(temp_result, temp_vector, temp_charge);
|
||||||
COMPLEX_SUB(results[j], results[j], temp_result);
|
COMPLEX_SUB(results[j], results[j], temp_result);
|
||||||
}
|
}
|
||||||
results[i].i = -results[i].i;
|
results[i].i = -results[i].i;
|
||||||
COMPLEX_ADD((b->particles[i]->field),
|
COMPLEX_ADD((b->particles[i]->field),
|
||||||
(b->particles[i]->field), results[i]);
|
(b->particles[i]->field), results[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
b->cost += SELF_COST(b->num_particles);
|
b->cost += SELF_COST(b->num_particles);
|
||||||
|
@ -604,7 +603,7 @@ ShiftLocalExp (box *pb, box *cb)
|
||||||
z0_pow_minus_n.i = One.i;
|
z0_pow_minus_n.i = One.i;
|
||||||
for (i = 0; i < Expansion_Terms; i++) {
|
for (i = 0; i < Expansion_Terms; i++) {
|
||||||
COMPLEX_ADD(pb->local_expansion[i], pb->local_expansion[i],
|
COMPLEX_ADD(pb->local_expansion[i], pb->local_expansion[i],
|
||||||
pb->x_expansion[i]);
|
pb->x_expansion[i]);
|
||||||
COMPLEX_MUL(temp_exp[i], z0_pow_n, pb->local_expansion[i]);
|
COMPLEX_MUL(temp_exp[i], z0_pow_n, pb->local_expansion[i]);
|
||||||
COMPLEX_MUL(z0_pow_n, z0_pow_n, z0);
|
COMPLEX_MUL(z0_pow_n, z0_pow_n, z0);
|
||||||
}
|
}
|
||||||
|
@ -612,10 +611,10 @@ ShiftLocalExp (box *pb, box *cb)
|
||||||
result_exp[i].r = (real) 0.0;
|
result_exp[i].r = (real) 0.0;
|
||||||
result_exp[i].i = (real) 0.0;
|
result_exp[i].i = (real) 0.0;
|
||||||
for (j = i; j < Expansion_Terms ; j++) {
|
for (j = i; j < Expansion_Terms ; j++) {
|
||||||
temp.r = C[j][i];
|
temp.r = C[j][i];
|
||||||
temp.i = (real) 0.0;
|
temp.i = (real) 0.0;
|
||||||
COMPLEX_MUL(temp, temp, temp_exp[j]);
|
COMPLEX_MUL(temp, temp, temp_exp[j]);
|
||||||
COMPLEX_ADD(result_exp[i], result_exp[i], temp);
|
COMPLEX_ADD(result_exp[i], result_exp[i], temp);
|
||||||
}
|
}
|
||||||
COMPLEX_MUL(result_exp[i], temp, z0_pow_minus_n);
|
COMPLEX_MUL(result_exp[i], temp, z0_pow_minus_n);
|
||||||
COMPLEX_MUL(z0_pow_minus_n, z0_pow_minus_n, z0_inv);
|
COMPLEX_MUL(z0_pow_minus_n, z0_pow_minus_n, z0_inv);
|
||||||
|
@ -623,7 +622,7 @@ ShiftLocalExp (box *pb, box *cb)
|
||||||
ALOCK(G_Memory->lock_array, cb->exp_lock_index);
|
ALOCK(G_Memory->lock_array, cb->exp_lock_index);
|
||||||
for (i = 0; i < Expansion_Terms; i++) {
|
for (i = 0; i < Expansion_Terms; i++) {
|
||||||
COMPLEX_ADD((cb->local_expansion[i]), (cb->local_expansion[i]),
|
COMPLEX_ADD((cb->local_expansion[i]), (cb->local_expansion[i]),
|
||||||
result_exp[i]);
|
result_exp[i]);
|
||||||
}
|
}
|
||||||
AULOCK(G_Memory->lock_array, cb->exp_lock_index);
|
AULOCK(G_Memory->lock_array, cb->exp_lock_index);
|
||||||
}
|
}
|
||||||
|
@ -649,11 +648,11 @@ EvaluateLocalExp (box *b)
|
||||||
particle_pos.i = b->particles[i]->pos.y;
|
particle_pos.i = b->particles[i]->pos.y;
|
||||||
COMPLEX_SUB(z0, particle_pos, source_pos);
|
COMPLEX_SUB(z0, particle_pos, source_pos);
|
||||||
for (j = Expansion_Terms - 1; j > 0; j--) {
|
for (j = Expansion_Terms - 1; j > 0; j--) {
|
||||||
temp.r = (real) j;
|
temp.r = (real) j;
|
||||||
temp.i = (real) 0.0;
|
temp.i = (real) 0.0;
|
||||||
COMPLEX_MUL(result, result, z0);
|
COMPLEX_MUL(result, result, z0);
|
||||||
COMPLEX_MUL(temp, temp, (b->local_expansion[j]));
|
COMPLEX_MUL(temp, temp, (b->local_expansion[j]));
|
||||||
COMPLEX_ADD(result, result, temp);
|
COMPLEX_ADD(result, result, temp);
|
||||||
}
|
}
|
||||||
COMPLEX_ADD((b->particles[i]->field), (b->particles[i]->field), result);
|
COMPLEX_ADD((b->particles[i]->field), (b->particles[i]->field), result);
|
||||||
b->particles[i]->field.r = -(b->particles[i]->field.r);
|
b->particles[i]->field.r = -(b->particles[i]->field.r);
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <cfloat>
|
#include <float.h>
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
#ifndef _Memory_H
|
#ifndef _Memory_H
|
||||||
#define _Memory_H 1
|
#define _Memory_H 1
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
#include "box.h"
|
||||||
|
|
||||||
#define MAX_LOCKS 2048
|
#define MAX_LOCKS 2048
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,9 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
@ -85,26 +83,26 @@ CreateDistribution (cluster_type cluster, model_type model)
|
||||||
end_limit = Total_Particles;
|
end_limit = Total_Particles;
|
||||||
switch (model) {
|
switch (model) {
|
||||||
case UNIFORM:
|
case UNIFORM:
|
||||||
printf("Creating a one cluster, uniform distribution for %ld ", Total_Particles);
|
printf("Creating a one cluster, uniform distribution for %ld ", Total_Particles);
|
||||||
printf("particles\n");
|
printf("particles\n");
|
||||||
break;
|
break;
|
||||||
case PLUMMER:
|
case PLUMMER:
|
||||||
printf("Creating a one cluster, non uniform distribution for %ld ", Total_Particles);
|
printf("Creating a one cluster, non uniform distribution for %ld ", Total_Particles);
|
||||||
printf("particles\n");
|
printf("particles\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TWO_CLUSTER:
|
case TWO_CLUSTER:
|
||||||
end_limit = (Total_Particles / 2) + (Total_Particles & 0x1);
|
end_limit = (Total_Particles / 2) + (Total_Particles & 0x1);
|
||||||
switch (model) {
|
switch (model) {
|
||||||
case UNIFORM:
|
case UNIFORM:
|
||||||
printf("Creating a two cluster, uniform distribution for %ld ", Total_Particles);
|
printf("Creating a two cluster, uniform distribution for %ld ", Total_Particles);
|
||||||
printf("particles\n");
|
printf("particles\n");
|
||||||
break;
|
break;
|
||||||
case PLUMMER:
|
case PLUMMER:
|
||||||
printf("Creating a two cluster, non uniform distribution for %ld ", Total_Particles);
|
printf("Creating a two cluster, non uniform distribution for %ld ", Total_Particles);
|
||||||
printf("particles\n");
|
printf("particles\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -116,27 +114,27 @@ CreateDistribution (cluster_type cluster, model_type model)
|
||||||
new_particle = InitParticle(charge, charge);
|
new_particle = InitParticle(charge, charge);
|
||||||
switch (model) {
|
switch (model) {
|
||||||
case UNIFORM:
|
case UNIFORM:
|
||||||
do {
|
do {
|
||||||
new_particle->pos.x = XRand(-1.0, 1.0);
|
new_particle->pos.x = XRand(-1.0, 1.0);
|
||||||
new_particle->pos.y = XRand(-1.0, 1.0);
|
new_particle->pos.y = XRand(-1.0, 1.0);
|
||||||
temp_r = DOT_PRODUCT((new_particle->pos), (new_particle->pos));
|
temp_r = DOT_PRODUCT((new_particle->pos), (new_particle->pos));
|
||||||
}
|
}
|
||||||
while (temp_r > (real) 1.0);
|
while (temp_r > (real) 1.0);
|
||||||
radius = sqrt(temp_r);
|
radius = sqrt(temp_r);
|
||||||
break;
|
break;
|
||||||
case PLUMMER:
|
case PLUMMER:
|
||||||
do
|
do
|
||||||
radius = (real) 1.0 / (real) sqrt(pow(XRand(0.0, MAX_FRAC),
|
radius = (real) 1.0 / (real) sqrt(pow(XRand(0.0, MAX_FRAC),
|
||||||
-2.0/3.0) - 1);
|
-2.0/3.0) - 1);
|
||||||
while (radius > 9.0);
|
while (radius > 9.0);
|
||||||
PickShell(&(new_particle->pos), r_scale * radius);
|
PickShell(&(new_particle->pos), r_scale * radius);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
VECTOR_ADD(r_sum, r_sum, (new_particle->pos));
|
VECTOR_ADD(r_sum, r_sum, (new_particle->pos));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
x_vel = XRand(0.0, 1.0);
|
x_vel = XRand(0.0, 1.0);
|
||||||
y_vel = XRand(0.0, 0.1);
|
y_vel = XRand(0.0, 0.1);
|
||||||
}
|
}
|
||||||
while (y_vel > x_vel * x_vel * (real) pow(1.0 - (x_vel * x_vel), 3.5));
|
while (y_vel > x_vel * x_vel * (real) pow(1.0 - (x_vel * x_vel), 3.5));
|
||||||
vel = (real) sqrt(2.0) * x_vel / pow(1.0 + (radius * radius), 0.25);
|
vel = (real) sqrt(2.0) * x_vel / pow(1.0 + (radius * radius), 0.25);
|
||||||
|
@ -147,21 +145,21 @@ CreateDistribution (cluster_type cluster, model_type model)
|
||||||
if (cluster == TWO_CLUSTER) {
|
if (cluster == TWO_CLUSTER) {
|
||||||
switch (model) {
|
switch (model) {
|
||||||
case UNIFORM:
|
case UNIFORM:
|
||||||
offset = 1.5;
|
offset = 1.5;
|
||||||
break;
|
break;
|
||||||
case PLUMMER:
|
case PLUMMER:
|
||||||
offset = 2.0;
|
offset = 2.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = end_limit; i < Total_Particles; i++) {
|
for (i = end_limit; i < Total_Particles; i++) {
|
||||||
new_particle = InitParticle(charge, charge);
|
new_particle = InitParticle(charge, charge);
|
||||||
twin_particle = Particle_List[i - end_limit];
|
twin_particle = Particle_List[i - end_limit];
|
||||||
new_particle->pos.x = twin_particle->pos.x + offset;
|
new_particle->pos.x = twin_particle->pos.x + offset;
|
||||||
new_particle->pos.y = twin_particle->pos.y + offset;
|
new_particle->pos.y = twin_particle->pos.y + offset;
|
||||||
VECTOR_ADD(r_sum, r_sum, (new_particle->pos));
|
VECTOR_ADD(r_sum, r_sum, (new_particle->pos));
|
||||||
new_particle->vel.x = twin_particle->vel.x;
|
new_particle->vel.x = twin_particle->vel.x;
|
||||||
new_particle->vel.y = twin_particle->vel.y;
|
new_particle->vel.y = twin_particle->vel.y;
|
||||||
VECTOR_ADD(v_sum, v_sum, (new_particle->vel));
|
VECTOR_ADD(v_sum, v_sum, (new_particle->vel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +178,7 @@ CreateParticleList (long my_id, long length)
|
||||||
{
|
{
|
||||||
LOCK(G_Memory->mal_lock);
|
LOCK(G_Memory->mal_lock);
|
||||||
Local[my_id].Particles = (particle **) G_MALLOC(length
|
Local[my_id].Particles = (particle **) G_MALLOC(length
|
||||||
* sizeof(particle *));
|
* sizeof(particle *));
|
||||||
|
|
||||||
/* POSSIBLE ENHANCEMENT: Here is where one might distribute the
|
/* POSSIBLE ENHANCEMENT: Here is where one might distribute the
|
||||||
Particles data across physically distributed memories as desired.
|
Particles data across physically distributed memories as desired.
|
||||||
|
@ -192,7 +190,7 @@ CreateParticleList (long my_id, long length)
|
||||||
|
|
||||||
starting_address = (char *) Local[my_id].Particles;
|
starting_address = (char *) Local[my_id].Particles;
|
||||||
ending_address = (((char *) Local[my_id].Particles)
|
ending_address = (((char *) Local[my_id].Particles)
|
||||||
+ (length * sizeof(particle *)) - 1);
|
+ (length * sizeof(particle *)) - 1);
|
||||||
|
|
||||||
Place all addresses x such that (starting_address <= x < ending_address)
|
Place all addresses x such that (starting_address <= x < ending_address)
|
||||||
on node my_id
|
on node my_id
|
||||||
|
@ -263,12 +261,12 @@ PrintParticleArrayIds (particle **p_array, long num_particles)
|
||||||
printf("NONE\n");
|
printf("NONE\n");
|
||||||
else {
|
else {
|
||||||
for (i = 0; i < num_particles; i++) {
|
for (i = 0; i < num_particles; i++) {
|
||||||
if (tab_count == 0) {
|
if (tab_count == 0) {
|
||||||
tab_count = PARTICLES_PER_LINE;
|
tab_count = PARTICLES_PER_LINE;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
printf("\tP%ld", p_array[i]->id);
|
printf("\tP%ld", p_array[i]->id);
|
||||||
tab_count -= 1;
|
tab_count -= 1;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,12 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <climits>
|
#include <math.h>
|
||||||
#include <cmath>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "particle.h"
|
#include "particle.h"
|
||||||
|
#include "box.h"
|
||||||
#include "partition_grid.h"
|
#include "partition_grid.h"
|
||||||
|
|
||||||
#define DIVISOR(x) ((x <= 20) ? 1 : ((x - 20) * 50))
|
#define DIVISOR(x) ((x <= 20) ? 1 : ((x - 20) * 50))
|
||||||
|
@ -56,7 +55,7 @@ InitPartition (long my_id)
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionIterate (long my_id, partition_function function,
|
PartitionIterate (long my_id, partition_function function,
|
||||||
partition_start position)
|
partition_start position)
|
||||||
{
|
{
|
||||||
box *b;
|
box *b;
|
||||||
long i;
|
long i;
|
||||||
|
@ -64,38 +63,38 @@ PartitionIterate (long my_id, partition_function function,
|
||||||
if (position == CHILDREN) {
|
if (position == CHILDREN) {
|
||||||
b = Local[my_id].Childless_Partition;
|
b = Local[my_id].Childless_Partition;
|
||||||
while (b != NULL) {
|
while (b != NULL) {
|
||||||
(*function)(my_id, b);
|
(*function)(my_id, b);
|
||||||
b = b->next;
|
b = b->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (position == TOP) {
|
if (position == TOP) {
|
||||||
for (i = 0; i <= Local[my_id].Max_Parent_Level; i++) {
|
for (i = 0; i <= Local[my_id].Max_Parent_Level; i++) {
|
||||||
b = Local[my_id].Parent_Partition[i];
|
b = Local[my_id].Parent_Partition[i];
|
||||||
while (b != NULL) {
|
while (b != NULL) {
|
||||||
(*function)(my_id, b);
|
(*function)(my_id, b);
|
||||||
b = b->next;
|
b = b->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b = Local[my_id].Childless_Partition;
|
b = Local[my_id].Childless_Partition;
|
||||||
while (b != NULL) {
|
while (b != NULL) {
|
||||||
(*function)(my_id, b);
|
(*function)(my_id, b);
|
||||||
b = b->next;
|
b = b->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
b = Local[my_id].Childless_Partition;
|
b = Local[my_id].Childless_Partition;
|
||||||
while (b != NULL) {
|
while (b != NULL) {
|
||||||
(*function)(my_id, b);
|
(*function)(my_id, b);
|
||||||
b = b->next;
|
b = b->next;
|
||||||
}
|
}
|
||||||
for (i = Local[my_id].Max_Parent_Level; i >= 0; i--) {
|
for (i = Local[my_id].Max_Parent_Level; i >= 0; i--) {
|
||||||
b = Local[my_id].Parent_Partition[i];
|
b = Local[my_id].Parent_Partition[i];
|
||||||
while (b != NULL) {
|
while (b != NULL) {
|
||||||
(*function)(my_id, b);
|
(*function)(my_id, b);
|
||||||
b = b->next;
|
b = b->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +108,7 @@ InsertBoxInPartition (long my_id, box *b)
|
||||||
if (b->type == CHILDLESS) {
|
if (b->type == CHILDLESS) {
|
||||||
b->prev = NULL;
|
b->prev = NULL;
|
||||||
if (Local[my_id].Childless_Partition != NULL)
|
if (Local[my_id].Childless_Partition != NULL)
|
||||||
Local[my_id].Childless_Partition->prev = b;
|
Local[my_id].Childless_Partition->prev = b;
|
||||||
b->next = Local[my_id].Childless_Partition;
|
b->next = Local[my_id].Childless_Partition;
|
||||||
Local[my_id].Childless_Partition = b;
|
Local[my_id].Childless_Partition = b;
|
||||||
}
|
}
|
||||||
|
@ -117,11 +116,11 @@ InsertBoxInPartition (long my_id, box *b)
|
||||||
level_list = Local[my_id].Parent_Partition[b->level];
|
level_list = Local[my_id].Parent_Partition[b->level];
|
||||||
b->prev = NULL;
|
b->prev = NULL;
|
||||||
if (level_list != NULL)
|
if (level_list != NULL)
|
||||||
level_list->prev = b;
|
level_list->prev = b;
|
||||||
b->next = level_list;
|
b->next = level_list;
|
||||||
Local[my_id].Parent_Partition[b->level] = b;
|
Local[my_id].Parent_Partition[b->level] = b;
|
||||||
if (b->level > Local[my_id].Max_Parent_Level) {
|
if (b->level > Local[my_id].Max_Parent_Level) {
|
||||||
Local[my_id].Max_Parent_Level = b->level;
|
Local[my_id].Max_Parent_Level = b->level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,24 +131,24 @@ RemoveBoxFromPartition (long my_id, box *b)
|
||||||
{
|
{
|
||||||
if (b->type == CHILDLESS) {
|
if (b->type == CHILDLESS) {
|
||||||
if (b->prev != NULL)
|
if (b->prev != NULL)
|
||||||
b->prev->next = b->next;
|
b->prev->next = b->next;
|
||||||
else
|
else
|
||||||
Local[my_id].Childless_Partition = b->next;
|
Local[my_id].Childless_Partition = b->next;
|
||||||
if (b->next != NULL)
|
if (b->next != NULL)
|
||||||
b->next->prev = b->prev;
|
b->next->prev = b->prev;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (b->prev != NULL)
|
if (b->prev != NULL)
|
||||||
b->prev->next = b->next;
|
b->prev->next = b->next;
|
||||||
else
|
else
|
||||||
Local[my_id].Parent_Partition[b->level] = b->next;
|
Local[my_id].Parent_Partition[b->level] = b->next;
|
||||||
if (b->next != NULL)
|
if (b->next != NULL)
|
||||||
b->next->prev = b->prev;
|
b->next->prev = b->prev;
|
||||||
if ((b->level == Local[my_id].Max_Parent_Level) &&
|
if ((b->level == Local[my_id].Max_Parent_Level) &&
|
||||||
(Local[my_id].Parent_Partition[b->level] == NULL)) {
|
(Local[my_id].Parent_Partition[b->level] == NULL)) {
|
||||||
while (Local[my_id].Parent_Partition[Local[my_id].Max_Parent_Level]
|
while (Local[my_id].Parent_Partition[Local[my_id].Max_Parent_Level]
|
||||||
== NULL)
|
== NULL)
|
||||||
Local[my_id].Max_Parent_Level -= 1;
|
Local[my_id].Max_Parent_Level -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,22 +168,22 @@ ComputeCostOfBox (box *b)
|
||||||
|
|
||||||
if (b->type == PARENT)
|
if (b->type == PARENT)
|
||||||
b->cost = ((b->num_v_list * V_LIST_COST(Expansion_Terms))
|
b->cost = ((b->num_v_list * V_LIST_COST(Expansion_Terms))
|
||||||
/ DIVISOR(Expansion_Terms)) + 1;
|
/ DIVISOR(Expansion_Terms)) + 1;
|
||||||
else {
|
else {
|
||||||
different_costs = 0;
|
different_costs = 0;
|
||||||
for (i = 0; i < b->num_particles; i++) {
|
for (i = 0; i < b->num_particles; i++) {
|
||||||
new_cost = b->particles[i]->cost;
|
new_cost = b->particles[i]->cost;
|
||||||
for (j = 0; j < different_costs; j++) {
|
for (j = 0; j < different_costs; j++) {
|
||||||
if (new_cost == cost_list[j].cost)
|
if (new_cost == cost_list[j].cost)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j == different_costs) {
|
if (j == different_costs) {
|
||||||
cost_list[different_costs].cost = new_cost;
|
cost_list[different_costs].cost = new_cost;
|
||||||
cost_list[different_costs].num = 1;
|
cost_list[different_costs].num = 1;
|
||||||
different_costs += 1;
|
different_costs += 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cost_list[j].num += 1;
|
cost_list[j].num += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
winner.cost = cost_list[0].cost;
|
winner.cost = cost_list[0].cost;
|
||||||
|
@ -192,27 +191,27 @@ ComputeCostOfBox (box *b)
|
||||||
winner_index = 0;
|
winner_index = 0;
|
||||||
cost_index[0] = 0;
|
cost_index[0] = 0;
|
||||||
for (i = 1; i < different_costs; i++) {
|
for (i = 1; i < different_costs; i++) {
|
||||||
if (cost_list[i].num > cost_list[winner_index].num) {
|
if (cost_list[i].num > cost_list[winner_index].num) {
|
||||||
winner.cost = cost_list[i].cost;
|
winner.cost = cost_list[i].cost;
|
||||||
winner.num = 1;
|
winner.num = 1;
|
||||||
winner_index = i;
|
winner_index = i;
|
||||||
cost_index[0] = i;
|
cost_index[0] = i;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (cost_list[i].num == cost_list[winner_index].num) {
|
if (cost_list[i].num == cost_list[winner_index].num) {
|
||||||
cost_index[winner.num] = i;
|
cost_index[winner.num] = i;
|
||||||
winner.num += 1;
|
winner.num += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (winner.num != 1) {
|
if (winner.num != 1) {
|
||||||
for (i = 1; i < winner.num; i++)
|
for (i = 1; i < winner.num; i++)
|
||||||
winner.cost += cost_list[cost_index[i]].cost;
|
winner.cost += cost_list[cost_index[i]].cost;
|
||||||
winner.cost /= winner.num;
|
winner.cost /= winner.num;
|
||||||
}
|
}
|
||||||
b->cost = (winner.cost * b->num_particles) / DIVISOR(Expansion_Terms);
|
b->cost = (winner.cost * b->num_particles) / DIVISOR(Expansion_Terms);
|
||||||
if (b->cost == 0)
|
if (b->cost == 0)
|
||||||
b->cost = 1;
|
b->cost = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,30 +230,30 @@ CheckPartition (long my_id)
|
||||||
for (i = 0; i <= Local[my_id].Max_Parent_Level; i++) {
|
for (i = 0; i <= Local[my_id].Max_Parent_Level; i++) {
|
||||||
b = Local[my_id].Parent_Partition[i];
|
b = Local[my_id].Parent_Partition[i];
|
||||||
while (b != NULL) {
|
while (b != NULL) {
|
||||||
NE += CheckBox(my_id, b, i);
|
NE += CheckBox(my_id, b, i);
|
||||||
PB += 1;
|
PB += 1;
|
||||||
PC += b->cost;
|
PC += b->cost;
|
||||||
b = b->next;
|
b = b->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b = Local[my_id].Childless_Partition;
|
b = Local[my_id].Childless_Partition;
|
||||||
while (b != NULL) {
|
while (b != NULL) {
|
||||||
NE += CheckBox(my_id, b, -1);
|
NE += CheckBox(my_id, b, -1);
|
||||||
for (i = 0; i < b->num_particles; i++) {
|
for (i = 0; i < b->num_particles; i++) {
|
||||||
xpos = b->particles[i]->pos.x;
|
xpos = b->particles[i]->pos.x;
|
||||||
ypos = b->particles[i]->pos.y;
|
ypos = b->particles[i]->pos.y;
|
||||||
if (xpos > Grid->x_center) {
|
if (xpos > Grid->x_center) {
|
||||||
if (ypos > Grid->y_center)
|
if (ypos > Grid->y_center)
|
||||||
Q1 += 1;
|
Q1 += 1;
|
||||||
else
|
else
|
||||||
Q4 += 1;
|
Q4 += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (ypos > Grid->y_center)
|
if (ypos > Grid->y_center)
|
||||||
Q2 += 1;
|
Q2 += 1;
|
||||||
else
|
else
|
||||||
Q3 += 1;
|
Q3 += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NoP += b->num_particles;
|
NoP += b->num_particles;
|
||||||
CB += 1;
|
CB += 1;
|
||||||
|
@ -272,99 +271,99 @@ CheckBox (long my_id, box *b, long partition_level)
|
||||||
num_errors = 0;
|
num_errors = 0;
|
||||||
if (b->type == CHILDLESS) {
|
if (b->type == CHILDLESS) {
|
||||||
if (partition_level != -1) {
|
if (partition_level != -1) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : CHILDLESS box in parent partition (B%f P%ld %ld)\n", b->id, my_id, b->proc);
|
printf("ERROR : CHILDLESS box in parent partition (B%f P%ld %ld)\n", b->id, my_id, b->proc);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
if (b->num_children != 0) {
|
if (b->num_children != 0) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : CHILDLESS box has children (B%f P%ld)\n", b->id, my_id);
|
printf("ERROR : CHILDLESS box has children (B%f P%ld)\n", b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
if (b->num_particles == 0) {
|
if (b->num_particles == 0) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : CHILDLESS box has no particles (B%f P%ld)\n", b->id, my_id);
|
printf("ERROR : CHILDLESS box has no particles (B%f P%ld)\n", b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
if (b->particles[b->num_particles - 1] == NULL) {
|
if (b->particles[b->num_particles - 1] == NULL) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : CHILDLESS box has fewer particles than expected ");
|
printf("ERROR : CHILDLESS box has fewer particles than expected ");
|
||||||
printf("(B%f P%ld)\n", b->id, my_id);
|
printf("(B%f P%ld)\n", b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
if (b->particles[b->num_particles] != NULL) {
|
if (b->particles[b->num_particles] != NULL) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : CHILDLESS box has more particles than expected ");
|
printf("ERROR : CHILDLESS box has more particles than expected ");
|
||||||
printf("(B%f P%ld)\n", b->id, my_id);
|
printf("(B%f P%ld)\n", b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (partition_level == -1) {
|
if (partition_level == -1) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : PARENT box in childless partition (B%f P%ld %ld)\n",
|
printf("ERROR : PARENT box in childless partition (B%f P%ld %ld)\n",
|
||||||
b->id, my_id, b->proc);
|
b->id, my_id, b->proc);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (partition_level != b->level) {
|
if (partition_level != b->level) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : PARENT box in wrong partition level ");
|
printf("ERROR : PARENT box in wrong partition level ");
|
||||||
printf("(%ld vs %ld) (B%f P%ld)\n", b->level, partition_level, b->id, my_id);
|
printf("(%ld vs %ld) (B%f P%ld)\n", b->level, partition_level, b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (b->num_children == 0) {
|
if (b->num_children == 0) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : PARENT box has no children (B%f P%ld)\n", b->id, my_id);
|
printf("ERROR : PARENT box has no children (B%f P%ld)\n", b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
if (b->num_particles != 0) {
|
if (b->num_particles != 0) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
printf("ERROR : PARENT box has particles (B%f P%ld)\n", b->id, my_id);
|
printf("ERROR : PARENT box has particles (B%f P%ld)\n", b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (b->parent == NULL) {
|
if (b->parent == NULL) {
|
||||||
if (b != Grid) {
|
if (b != Grid) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
if (b->type == CHILDLESS)
|
if (b->type == CHILDLESS)
|
||||||
printf("ERROR : Extra CHILDLESS box in partition (B%f P%ld)\n", b->id, my_id);
|
printf("ERROR : Extra CHILDLESS box in partition (B%f P%ld)\n", b->id, my_id);
|
||||||
else
|
else
|
||||||
printf("ERROR : Extra PARENT box in partition (B%f P%ld)\n", b->id, my_id);
|
printf("ERROR : Extra PARENT box in partition (B%f P%ld)\n", b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (b->parent->children[b->child_num] != b) {
|
if (b->parent->children[b->child_num] != b) {
|
||||||
LOCK(G_Memory->io_lock);
|
LOCK(G_Memory->io_lock);
|
||||||
if (b->type == CHILDLESS)
|
if (b->type == CHILDLESS)
|
||||||
printf("ERROR : Extra CHILDLESS box in partition (B%f P%ld)\n", b->id, my_id);
|
printf("ERROR : Extra CHILDLESS box in partition (B%f P%ld)\n", b->id, my_id);
|
||||||
else
|
else
|
||||||
printf("ERROR : Extra PARENT box in partition (B%f P%ld)\n", b->id, my_id);
|
printf("ERROR : Extra PARENT box in partition (B%f P%ld)\n", b->id, my_id);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
UNLOCK(G_Memory->io_lock);
|
UNLOCK(G_Memory->io_lock);
|
||||||
num_errors += 1;
|
num_errors += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return num_errors;
|
return num_errors;
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
#ifndef _Partition_H
|
#ifndef _Partition_H
|
||||||
#define _Partition_H 1
|
#define _Partition_H 1
|
||||||
|
|
||||||
#include "box.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
#include "box.h"
|
||||||
|
|
||||||
/* Void function type */
|
/* Void function type */
|
||||||
typedef void (*partition_function)(long my_id, box *b);
|
typedef void (*partition_function)(long my_id, box *b);
|
||||||
|
@ -28,7 +28,7 @@ typedef enum { ORB, COST_ZONES } partition_alg;
|
||||||
|
|
||||||
extern void InitPartition(long my_id);
|
extern void InitPartition(long my_id);
|
||||||
extern void PartitionIterate(long my_id, partition_function function,
|
extern void PartitionIterate(long my_id, partition_function function,
|
||||||
partition_start position);
|
partition_start position);
|
||||||
extern void InsertBoxInPartition(long my_id, box *b);
|
extern void InsertBoxInPartition(long my_id, box *b);
|
||||||
extern void RemoveBoxFromPartition(long my_id, box *b);
|
extern void RemoveBoxFromPartition(long my_id, box *b);
|
||||||
extern void ComputeCostOfBox(box *b);
|
extern void ComputeCostOfBox(box *b);
|
||||||
|
|
|
@ -19,10 +19,9 @@
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <ctime>
|
#include <time.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void jacobcalc(double ***x, double ***y, double ***z, long pid, long firstrow, long lastrow, long firstcol, long lastcol)
|
void jacobcalc(double ***x, double ***y, double ***z, long pid, long firstrow, long lastrow, long firstcol, long lastcol)
|
||||||
|
|
|
@ -19,10 +19,9 @@
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <ctime>
|
#include <time.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void jacobcalc2(double ****x, double ****y, double ****z, long psiindex, long pid, long firstrow, long lastrow, long firstcol, long lastcol)
|
void jacobcalc2(double ****x, double ****y, double ****z, long psiindex, long pid, long firstrow, long lastrow, long firstcol, long lastcol)
|
||||||
|
|
|
@ -18,10 +18,9 @@
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <ctime>
|
#include <time.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void laplacalc(long procid, double ****x, double ****z, long psiindex, long firstrow, long lastrow, long firstcol, long lastcol)
|
void laplacalc(long procid, double ****x, double ****z, long psiindex, long firstrow, long lastrow, long firstcol, long lastcol)
|
||||||
|
@ -85,7 +84,7 @@ void laplacalc(long procid, double ****x, double ****z, long psiindex, long firs
|
||||||
indexp1 = iindex+1;
|
indexp1 = iindex+1;
|
||||||
indexm1 = iindex-1;
|
indexm1 = iindex-1;
|
||||||
t1b[iindex] = factlap*(t1c[iindex]+
|
t1b[iindex] = factlap*(t1c[iindex]+
|
||||||
t1d[iindex]+t1a[indexp1]+
|
t1d[iindex]+t1a[indexp1]+
|
||||||
t1a[indexm1]-4.*t1a[iindex]);
|
t1a[indexm1]-4.*t1a[iindex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,10 @@ MAIN_ENV
|
||||||
#define DOWNRIGHT 7
|
#define DOWNRIGHT 7
|
||||||
#define PAGE_SIZE 4096
|
#define PAGE_SIZE 4096
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <time.h>
|
||||||
#include <ctime>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
struct multi_struct *multi;
|
struct multi_struct *multi;
|
||||||
|
|
|
@ -21,11 +21,10 @@
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <time.h>
|
||||||
#include <ctime>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
/* perform multigrid (w cycles) */
|
/* perform multigrid (w cycles) */
|
||||||
|
@ -124,12 +123,12 @@ void multig(long my_id)
|
||||||
if (wu > wmax) {
|
if (wu > wmax) {
|
||||||
/* max work exceeded */
|
/* max work exceeded */
|
||||||
flag1 = 1;
|
flag1 = 1;
|
||||||
fprintf(stderr,"ERROR: Maximum work limit %0.5f exceeded\n",wmax);
|
fprintf(stderr,"ERROR: Maximum work limit %0.5f exceeded\n",wmax);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
} else {
|
} else {
|
||||||
/* if we have not converged */
|
/* if we have not converged */
|
||||||
if ((k != 0) && (g_error/errp >= 0.6) &&
|
if ((k != 0) && (g_error/errp >= 0.6) &&
|
||||||
(k > minlevel)) {
|
(k > minlevel)) {
|
||||||
/* if need to go to coarser grid */
|
/* if need to go to coarser grid */
|
||||||
|
|
||||||
copy_borders(k,my_num);
|
copy_borders(k,my_num);
|
||||||
|
@ -141,9 +140,9 @@ void multig(long my_id)
|
||||||
rescal values */
|
rescal values */
|
||||||
|
|
||||||
#if defined(MULTIPLE_BARRIERS)
|
#if defined(MULTIPLE_BARRIERS)
|
||||||
BARRIER(bars->error_barrier,nprocs)
|
BARRIER(bars->error_barrier,nprocs)
|
||||||
#else
|
#else
|
||||||
BARRIER(bars->barrier,nprocs)
|
BARRIER(bars->barrier,nprocs)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rescal(k,my_num);
|
rescal(k,my_num);
|
||||||
|
@ -235,8 +234,8 @@ void relax(long k, double *err, long color, long my_num)
|
||||||
t1d = (double *) t2a[i+1];
|
t1d = (double *) t2a[i+1];
|
||||||
for (j=evenjstart;j<jend;j+=2) {
|
for (j=evenjstart;j<jend;j+=2) {
|
||||||
a = t1a[j+1] + t1a[j-1] +
|
a = t1a[j+1] + t1a[j-1] +
|
||||||
t1c[j] + t1d[j] -
|
t1c[j] + t1d[j] -
|
||||||
t1b[j] ;
|
t1b[j] ;
|
||||||
oldval = t1a[j];
|
oldval = t1a[j];
|
||||||
newval = a / factor;
|
newval = a / factor;
|
||||||
newerr = oldval - newval;
|
newerr = oldval - newval;
|
||||||
|
@ -253,8 +252,8 @@ void relax(long k, double *err, long color, long my_num)
|
||||||
t1d = (double *) t2a[i+1];
|
t1d = (double *) t2a[i+1];
|
||||||
for (j=oddjstart;j<jend;j+=2) {
|
for (j=oddjstart;j<jend;j+=2) {
|
||||||
a = t1a[j+1] + t1a[j-1] +
|
a = t1a[j+1] + t1a[j-1] +
|
||||||
t1c[j] + t1d[j] -
|
t1c[j] + t1d[j] -
|
||||||
t1b[j] ;
|
t1b[j] ;
|
||||||
oldval = t1a[j];
|
oldval = t1a[j];
|
||||||
newval = a / factor;
|
newval = a / factor;
|
||||||
newerr = oldval - newval;
|
newerr = oldval - newval;
|
||||||
|
@ -272,8 +271,8 @@ void relax(long k, double *err, long color, long my_num)
|
||||||
t1d = (double *) t2a[i+1];
|
t1d = (double *) t2a[i+1];
|
||||||
for (j=oddjstart;j<jend;j+=2) {
|
for (j=oddjstart;j<jend;j+=2) {
|
||||||
a = t1a[j+1] + t1a[j-1] +
|
a = t1a[j+1] + t1a[j-1] +
|
||||||
t1c[j] + t1d[j] -
|
t1c[j] + t1d[j] -
|
||||||
t1b[j] ;
|
t1b[j] ;
|
||||||
oldval = t1a[j];
|
oldval = t1a[j];
|
||||||
newval = a / factor;
|
newval = a / factor;
|
||||||
newerr = oldval - newval;
|
newerr = oldval - newval;
|
||||||
|
@ -290,8 +289,8 @@ void relax(long k, double *err, long color, long my_num)
|
||||||
t1d = (double *) t2a[i+1];
|
t1d = (double *) t2a[i+1];
|
||||||
for (j=evenjstart;j<jend;j+=2) {
|
for (j=evenjstart;j<jend;j+=2) {
|
||||||
a = t1a[j+1] + t1a[j-1] +
|
a = t1a[j+1] + t1a[j-1] +
|
||||||
t1c[j] + t1d[j] -
|
t1c[j] + t1d[j] -
|
||||||
t1b[j] ;
|
t1b[j] ;
|
||||||
oldval = t1a[j];
|
oldval = t1a[j];
|
||||||
newval = a / factor;
|
newval = a / factor;
|
||||||
newerr = oldval - newval;
|
newerr = oldval - newval;
|
||||||
|
@ -371,7 +370,7 @@ void rescal(long kf, long my_num)
|
||||||
t2b = (double **) rhs_multi[my_num][kf];
|
t2b = (double **) rhs_multi[my_num][kf];
|
||||||
t2c = (double **) rhs_multi[my_num][krc];
|
t2c = (double **) rhs_multi[my_num][krc];
|
||||||
if17=2*(istart-1);
|
if17=2*(istart-1);
|
||||||
for (ic=istart;ic<=iend;ic++) {
|
for(ic=istart;ic<=iend;ic++) {
|
||||||
if17+=2;
|
if17+=2;
|
||||||
i_int_factor = (ic+i_off) * i_int_coeff[krc] * 0.5;
|
i_int_factor = (ic+i_off) * i_int_coeff[krc] * 0.5;
|
||||||
jf = 2 * (jstart - 1);
|
jf = 2 * (jstart - 1);
|
||||||
|
@ -383,7 +382,7 @@ void rescal(long kf, long my_num)
|
||||||
t1f = (double *) t2a[if17-2];
|
t1f = (double *) t2a[if17-2];
|
||||||
t1g = (double *) t2a[if17-3];
|
t1g = (double *) t2a[if17-3];
|
||||||
t1h = (double *) t2b[if17-2];
|
t1h = (double *) t2b[if17-2];
|
||||||
for (jc=jstart;jc<=jend;jc++) {
|
for(jc=jstart;jc<=jend;jc++) {
|
||||||
jf+=2;
|
jf+=2;
|
||||||
j_int_factor = (jc+j_off)*j_int_coeff[krc] * 0.5;
|
j_int_factor = (jc+j_off)*j_int_coeff[krc] * 0.5;
|
||||||
|
|
||||||
|
@ -393,32 +392,32 @@ void rescal(long kf, long my_num)
|
||||||
s = t1a[jf+1] + t1a[jf-1] + t1d[jf] + t1e[jf];
|
s = t1a[jf+1] + t1a[jf-1] + t1d[jf] + t1e[jf];
|
||||||
s1 = 2.0 * (t1b[jf] - s + factor * t1a[jf]);
|
s1 = 2.0 * (t1b[jf] - s + factor * t1a[jf]);
|
||||||
if (((if17 == 2) && (gp[my_num].neighbors[UP] == -1)) ||
|
if (((if17 == 2) && (gp[my_num].neighbors[UP] == -1)) ||
|
||||||
((jf == 2) && (gp[my_num].neighbors[LEFT] == -1))) {
|
((jf == 2) && (gp[my_num].neighbors[LEFT] == -1))) {
|
||||||
s2 = 0;
|
s2 = 0;
|
||||||
s3 = 0;
|
s3 = 0;
|
||||||
s4 = 0;
|
s4 = 0;
|
||||||
} else if ((if17 == 2) || (jf == 2)) {
|
} else if ((if17 == 2) || (jf == 2)) {
|
||||||
if (jf == 2) {
|
if (jf == 2) {
|
||||||
temp = q_multi[left_proc][kf][if17][jm-1];
|
temp = q_multi[left_proc][kf][if17][jm-1];
|
||||||
} else {
|
} else {
|
||||||
temp = t1a[jf-3];
|
temp = t1a[jf-3];
|
||||||
}
|
}
|
||||||
s = t1a[jf-1] + temp + t1d[jf-2] + t1e[jf-2];
|
s = t1a[jf-1] + temp + t1d[jf-2] + t1e[jf-2];
|
||||||
s2 = 2.0 * (t1b[jf-2] - s + factor * t1a[jf-2]);
|
s2 = 2.0 * (t1b[jf-2] - s + factor * t1a[jf-2]);
|
||||||
if (if17 == 2) {
|
if (if17 == 2) {
|
||||||
temp = q_multi[up_proc][kf][im-1][jf];
|
temp = q_multi[up_proc][kf][im-1][jf];
|
||||||
} else {
|
} else {
|
||||||
temp = t1g[jf];
|
temp = t1g[jf];
|
||||||
}
|
}
|
||||||
s = t1f[jf+1]+ t1f[jf-1]+ temp + t1d[jf];
|
s = t1f[jf+1]+ t1f[jf-1]+ temp + t1d[jf];
|
||||||
s3 = 2.0 * (t1h[jf] - s + factor * t1f[jf]);
|
s3 = 2.0 * (t1h[jf] - s + factor * t1f[jf]);
|
||||||
if (jf == 2) {
|
if (jf == 2) {
|
||||||
temp = q_multi[left_proc][kf][if17-2][jm-1];
|
temp = q_multi[left_proc][kf][if17-2][jm-1];
|
||||||
} else {
|
} else {
|
||||||
temp = t1f[jf-3];
|
temp = t1f[jf-3];
|
||||||
}
|
}
|
||||||
if (if17 == 2) {
|
if (if17 == 2) {
|
||||||
temp2 = q_multi[up_proc][kf][im-1][jf-2];
|
temp2 = q_multi[up_proc][kf][im-1][jf-2];
|
||||||
} else {
|
} else {
|
||||||
temp2 = t1g[jf-2];
|
temp2 = t1g[jf-2];
|
||||||
}
|
}
|
||||||
|
@ -484,7 +483,7 @@ void intadd(long kc, long my_num)
|
||||||
t2a = (double **) q_multi[my_num][kc];
|
t2a = (double **) q_multi[my_num][kc];
|
||||||
t2b = (double **) q_multi[my_num][kf];
|
t2b = (double **) q_multi[my_num][kf];
|
||||||
if17 = 2*(istart-1);
|
if17 = 2*(istart-1);
|
||||||
for (ic=istart;ic<=iend;ic++) {
|
for(ic=istart;ic<=iend;ic++) {
|
||||||
if17+=2;
|
if17+=2;
|
||||||
i_int_factor1= ((imx[kc]-2)-(ic+i_off-1)) * (i_int_coeff[kf]);
|
i_int_factor1= ((imx[kc]-2)-(ic+i_off-1)) * (i_int_coeff[kf]);
|
||||||
i_int_factor2= (ic+i_off) * i_int_coeff[kf];
|
i_int_factor2= (ic+i_off) * i_int_coeff[kf];
|
||||||
|
@ -495,7 +494,7 @@ void intadd(long kc, long my_num)
|
||||||
t1c = (double *) t2a[ic+1];
|
t1c = (double *) t2a[ic+1];
|
||||||
t1d = (double *) t2b[if17];
|
t1d = (double *) t2b[if17];
|
||||||
t1e = (double *) t2b[if17-1];
|
t1e = (double *) t2b[if17-1];
|
||||||
for (jc=jstart;jc<=jend;jc++) {
|
for(jc=jstart;jc<=jend;jc++) {
|
||||||
jf+=2;
|
jf+=2;
|
||||||
j_int_factor1= ((jmx[kc]-2)-(jc+j_off-1)) * (j_int_coeff[kf]);
|
j_int_factor1= ((jmx[kc]-2)-(jc+j_off-1)) * (j_int_coeff[kf]);
|
||||||
j_int_factor2= (jc+j_off) * j_int_coeff[kf];
|
j_int_factor2= (jc+j_off) * j_int_coeff[kf];
|
||||||
|
|
|
@ -20,11 +20,10 @@
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <time.h>
|
||||||
#include <ctime>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void slave()
|
void slave()
|
||||||
|
@ -223,30 +222,30 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = 0.0;
|
t2a[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = 0.0;
|
t2a[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = 0.0;
|
t1a[iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,29 +264,29 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = 0.0;
|
t2a[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = 0.0;
|
t2a[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = 0.0;
|
t1a[iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,29 +306,29 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 1.0;
|
t1a[j] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 1.0;
|
t1a[j] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = 1.0;
|
t2a[j][0] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = 1.0;
|
t2a[j][jm-1] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = 0.0;
|
t1a[iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,10 +365,10 @@ eof(double) +
|
||||||
|
|
||||||
t2a = (double **) rhs_multi[procid][numlev-1];
|
t2a = (double **) rhs_multi[procid][numlev-1];
|
||||||
t2b = (double **) psib[procid];
|
t2b = (double **) psib[procid];
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1a[j] = t1b[j] * ressqr;
|
t1a[j] = t1b[j] * ressqr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,24 +376,24 @@ eof(double) +
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1a[j] = t1b[j];
|
t1a[j] = t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1a[j] = t1b[j];
|
t1a[j] = t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t2a[i][0] = t2b[i][0];
|
t2a[i][0] = t2b[i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t2a[i][jm-1] = t2b[i][jm-1];
|
t2a[i][jm-1] = t2b[i][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,12 +437,12 @@ eof(double) +
|
||||||
t2a = (double **) q_multi[procid][numlev-1];
|
t2a = (double **) q_multi[procid][numlev-1];
|
||||||
t2b = (double **) psib[procid];
|
t2b = (double **) psib[procid];
|
||||||
fac = 1.0 / (4.0 - ressqr*eig2);
|
fac = 1.0 / (4.0 - ressqr*eig2);
|
||||||
for (i=ist;i<=ien;i++) {
|
for(i=ist;i<=ien;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
t1c = (double *) t2b[i-1];
|
t1c = (double *) t2b[i-1];
|
||||||
t1d = (double *) t2b[i+1];
|
t1d = (double *) t2b[i+1];
|
||||||
for (j=jst;j<=jen;j++) {
|
for(j=jst;j<=jen;j++) {
|
||||||
t1a[j] = fac * (t1d[j]+t1c[j]+t1b[j+1]+t1b[j-1] -
|
t1a[j] = fac * (t1d[j]+t1c[j]+t1b[j+1]+t1b[j-1] -
|
||||||
ressqr*t1b[j]);
|
ressqr*t1b[j]);
|
||||||
}
|
}
|
||||||
|
@ -451,10 +450,10 @@ eof(double) +
|
||||||
|
|
||||||
multig(procid);
|
multig(procid);
|
||||||
|
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1b[j] = t1a[j];
|
t1b[j] = t1a[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,29 +481,29 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
psibipriv = psibipriv + 0.5*t1a[j];
|
psibipriv = psibipriv + 0.5*t1a[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
psibipriv = psibipriv + 0.5*t1a[j];
|
psibipriv = psibipriv + 0.5*t1a[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
psibipriv = psibipriv + 0.5*t2a[j][0];
|
psibipriv = psibipriv + 0.5*t2a[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
psibipriv = psibipriv + 0.5*t2a[j][jm-1];
|
psibipriv = psibipriv + 0.5*t2a[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
psibipriv = psibipriv + t1a[iindex];
|
psibipriv = psibipriv + t1a[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +523,7 @@ eof(double) +
|
||||||
between the two psim matrices; otherwise, let the single process
|
between the two psim matrices; otherwise, let the single process
|
||||||
work on one first and then the other */
|
work on one first and then the other */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
t2a = (double **) psim[procid][psiindex];
|
t2a = (double **) psim[procid][psiindex];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[0][0] = 0.0;
|
t2a[0][0] = 0.0;
|
||||||
|
@ -540,29 +539,29 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = 0.0;
|
t2a[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = 0.0;
|
t2a[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = 0.0;
|
t1a[iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,7 +569,7 @@ eof(double) +
|
||||||
|
|
||||||
/* initialize psi matrices the same way */
|
/* initialize psi matrices the same way */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
t2a = (double **) psi[procid][psiindex];
|
t2a = (double **) psi[procid][psiindex];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[0][0] = 0.0;
|
t2a[0][0] = 0.0;
|
||||||
|
@ -586,29 +585,29 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = 0.0;
|
t2a[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = 0.0;
|
t2a[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = 0.0;
|
t1a[iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,7 +636,7 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
sintemp = pi*((double) j+j_off)*res/ysca1;
|
sintemp = pi*((double) j+j_off)*res/ysca1;
|
||||||
sintemp = sin(sintemp);
|
sintemp = sin(sintemp);
|
||||||
curlt = factor*sintemp;
|
curlt = factor*sintemp;
|
||||||
|
@ -646,7 +645,7 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
sintemp = pi*((double) j+j_off)*res/ysca1;
|
sintemp = pi*((double) j+j_off)*res/ysca1;
|
||||||
sintemp = sin(sintemp);
|
sintemp = sin(sintemp);
|
||||||
curlt = factor*sintemp;
|
curlt = factor*sintemp;
|
||||||
|
@ -654,7 +653,7 @@ eof(double) +
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = 0.0;
|
t2a[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -662,13 +661,13 @@ eof(double) +
|
||||||
sintemp = pi*((double) jm-1+j_off)*res/ysca1;
|
sintemp = pi*((double) jm-1+j_off)*res/ysca1;
|
||||||
sintemp = sin(sintemp);
|
sintemp = sin(sintemp);
|
||||||
curlt = factor*sintemp;
|
curlt = factor*sintemp;
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = curlt;
|
t2a[j][jm-1] = curlt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
sintemp = pi*((double) iindex+j_off)*res/ysca1;
|
sintemp = pi*((double) iindex+j_off)*res/ysca1;
|
||||||
sintemp = sin(sintemp);
|
sintemp = sin(sintemp);
|
||||||
curlt = factor*sintemp;
|
curlt = factor*sintemp;
|
||||||
|
@ -693,11 +692,11 @@ eof(double) +
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
CLOCK(global->trackstart)
|
CLOCK(global->trackstart)
|
||||||
}
|
}
|
||||||
if ((procid == MASTER) || (do_stats)) {
|
if ((procid == MASTER) || (do_stats)) {
|
||||||
CLOCK(t1);
|
CLOCK(t1);
|
||||||
gp[procid].total_time = t1;
|
gp[procid].total_time = t1;
|
||||||
gp[procid].multi_time = 0;
|
gp[procid].multi_time = 0;
|
||||||
}
|
}
|
||||||
/* POSSIBLE ENHANCEMENT: Here is where one might reset the
|
/* POSSIBLE ENHANCEMENT: Here is where one might reset the
|
||||||
statistics that one is measuring about the parallel execution */
|
statistics that one is measuring about the parallel execution */
|
||||||
}
|
}
|
||||||
|
@ -717,7 +716,7 @@ eof(double) +
|
||||||
iday = (long) day;
|
iday = (long) day;
|
||||||
dhour = dhour+dtau;
|
dhour = dhour+dtau;
|
||||||
if (dhour >= 86400.0) {
|
if (dhour >= 86400.0) {
|
||||||
dhourflag = 1;
|
dhourflag = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -736,37 +735,37 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
||||||
t2b[im-1][jm-1];
|
t2b[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j]+t1b[j];
|
t1a[j] = t1a[j]+t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j] + t1b[j];
|
t1a[j] = t1a[j] + t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2a[j][0]+t2b[j][0];
|
t2a[j][0] = t2a[j][0]+t2b[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2a[j][jm-1] +
|
t2a[j][jm-1] = t2a[j][jm-1] +
|
||||||
t2b[j][jm-1];
|
t2b[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1a[iindex] + t1b[iindex];
|
t1a[iindex] = t1a[iindex] + t1b[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,36 +785,36 @@ eof(double) +
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
||||||
t2b[im-1][jm-1];
|
t2b[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j]+t1b[j];
|
t1a[j] = t1a[j]+t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j]+t1b[j];
|
t1a[j] = t1a[j]+t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2a[j][0]+t2b[j][0];
|
t2a[j][0] = t2a[j][0]+t2b[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2a[j][jm-1] + t2b[j][jm-1];
|
t2a[j][jm-1] = t2a[j][jm-1] + t2b[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1a[iindex] + t1b[iindex];
|
t1a[iindex] = t1a[iindex] + t1b[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,10 @@
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <time.h>
|
||||||
#include <ctime>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void slave2(long procid, long firstrow, long lastrow, long numrows, long firstcol, long lastcol, long numcols)
|
void slave2(long procid, long firstrow, long lastrow, long numrows, long firstcol, long lastcol, long numcols)
|
||||||
|
@ -96,29 +95,29 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = 0.0;
|
t2a[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = 0.0;
|
t2a[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = 0.0;
|
t1a[iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,29 +137,29 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = 0.0;
|
t1a[j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = 0.0;
|
t2a[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = 0.0;
|
t2a[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = 0.0;
|
t1a[iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +168,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
note that psi(i,j,2) represents the psi3 array in
|
note that psi(i,j,2) represents the psi3 array in
|
||||||
the original equations */
|
the original equations */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
t2a = (double **) work1[procid][psiindex];
|
t2a = (double **) work1[procid][psiindex];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[0][0] = 0;
|
t2a[0][0] = 0;
|
||||||
|
@ -184,7 +183,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t2a[im-1][jm-1] = 0;
|
t2a[im-1][jm-1] = 0;
|
||||||
}
|
}
|
||||||
laplacalc(procid,psi,work1,psiindex,
|
laplacalc(procid,psi,work1,psiindex,
|
||||||
firstrow,lastrow,firstcol,lastcol);
|
firstrow,lastrow,firstcol,lastcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set values of work2 array to psi1 - psi3 */
|
/* set values of work2 array to psi1 - psi3 */
|
||||||
|
@ -203,13 +202,13 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[im-1][jm-1] = t2b[im-1][jm-1] -
|
t2a[im-1][jm-1] = t2b[im-1][jm-1] -
|
||||||
t2c[im-1][jm-1];
|
t2c[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
t1c = (double *) t2c[0];
|
t1c = (double *) t2c[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1b[j]-t1c[j];
|
t1a[j] = t1b[j]-t1c[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,25 +216,25 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
t1c = (double *) t2c[im-1];
|
t1c = (double *) t2c[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1b[j]-t1c[j];
|
t1a[j] = t1b[j]-t1c[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2b[j][0]-t2c[j][0];
|
t2a[j][0] = t2b[j][0]-t2c[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2b[j][jm-1]-t2c[j][jm-1];
|
t2a[j][jm-1] = t2b[j][jm-1]-t2c[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
t1c = (double *) t2c[i];
|
t1c = (double *) t2c[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1b[iindex] - t1c[iindex];
|
t1a[iindex] = t1b[iindex] - t1c[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,49 +249,49 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[im-1][0] = hh3*t2a[im-1][0] +
|
t2a[im-1][0] = hh3*t2a[im-1][0] +
|
||||||
hh1*t2c[im-1][0];
|
hh1*t2c[im-1][0];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[0][jm-1] = hh3*t2a[0][jm-1] +
|
t2a[0][jm-1] = hh3*t2a[0][jm-1] +
|
||||||
hh1*t2c[0][jm-1];
|
hh1*t2c[0][jm-1];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[im-1][jm-1] = hh3*t2a[im-1][jm-1] +
|
t2a[im-1][jm-1] = hh3*t2a[im-1][jm-1] +
|
||||||
hh1*t2c[im-1][jm-1];
|
hh1*t2c[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t2a[0][j] = hh3*t2a[0][j]+hh1*t2c[0][j];
|
t2a[0][j] = hh3*t2a[0][j]+hh1*t2c[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t2a[im-1][j] = hh3*t2a[im-1][j] +
|
t2a[im-1][j] = hh3*t2a[im-1][j] +
|
||||||
hh1*t2c[im-1][j];
|
hh1*t2c[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = hh3*t2a[j][0]+hh1*t2c[j][0];
|
t2a[j][0] = hh3*t2a[j][0]+hh1*t2c[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = hh3*t2a[j][jm-1] +
|
t2a[j][jm-1] = hh3*t2a[j][jm-1] +
|
||||||
hh1*t2c[j][jm-1];
|
hh1*t2c[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1c = (double *) t2c[i];
|
t1c = (double *) t2c[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = hh3*t1a[iindex] + hh1*t1c[iindex];
|
t1a[iindex] = hh3*t1a[iindex] + hh1*t1c[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set values of temparray{1,3} to psim{1,3} */
|
/* set values of temparray{1,3} to psim{1,3} */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
t2a = (double **) temparray[procid][psiindex];
|
t2a = (double **) temparray[procid][psiindex];
|
||||||
t2b = (double **) psi[procid][psiindex];
|
t2b = (double **) psi[procid][psiindex];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
|
@ -308,30 +307,30 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t2a[im-1][jm-1] = t2b[im-1][jm-1];
|
t2a[im-1][jm-1] = t2b[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t2a[0][j] = t2b[0][j];
|
t2a[0][j] = t2b[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t2a[im-1][j] = t2b[im-1][j];
|
t2a[im-1][j] = t2b[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2b[j][0];
|
t2a[j][0] = t2b[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2b[j][jm-1];
|
t2a[j][jm-1] = t2b[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1b[iindex];
|
t1a[iindex] = t1b[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,7 +348,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
|
|
||||||
set values of psi{1,3} to psim{1,3} */
|
set values of psi{1,3} to psim{1,3} */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
t2a = (double **) psi[procid][psiindex];
|
t2a = (double **) psi[procid][psiindex];
|
||||||
t2b = (double **) psim[procid][psiindex];
|
t2b = (double **) psim[procid][psiindex];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
|
@ -365,30 +364,30 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t2a[im-1][jm-1] = t2b[im-1][jm-1];
|
t2a[im-1][jm-1] = t2b[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t2a[0][j] = t2b[0][j];
|
t2a[0][j] = t2b[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t2a[im-1][j] = t2b[im-1][j];
|
t2a[im-1][j] = t2b[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2b[j][0];
|
t2a[j][0] = t2b[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2b[j][jm-1];
|
t2a[j][jm-1] = t2b[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1b[iindex];
|
t1a[iindex] = t1b[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,7 +397,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
into the work7 array; first part of a three-laplacian
|
into the work7 array; first part of a three-laplacian
|
||||||
calculation to compute the friction terms */
|
calculation to compute the friction terms */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
t2a = (double **) work7[procid][psiindex];
|
t2a = (double **) work7[procid][psiindex];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[0][0] = 0;
|
t2a[0][0] = 0;
|
||||||
|
@ -413,7 +412,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t2a[im-1][jm-1] = 0;
|
t2a[im-1][jm-1] = 0;
|
||||||
}
|
}
|
||||||
laplacalc(procid,psim,work7,psiindex,
|
laplacalc(procid,psim,work7,psiindex,
|
||||||
firstrow,lastrow,firstcol,lastcol);
|
firstrow,lastrow,firstcol,lastcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* to the values of the work1{1,2} arrays obtained from the
|
/* to the values of the work1{1,2} arrays obtained from the
|
||||||
|
@ -421,7 +420,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
elements of every column the corresponding value in the
|
elements of every column the corresponding value in the
|
||||||
one-dimenional f array */
|
one-dimenional f array */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
t2a = (double **) work1[procid][psiindex];
|
t2a = (double **) work1[procid][psiindex];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[0][0] = t2a[0][0] + f[0];
|
t2a[0][0] = t2a[0][0] + f[0];
|
||||||
|
@ -436,28 +435,28 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t2a[im-1][jm-1]=t2a[im-1][jm-1] + f[jmx[numlev-1]-1];
|
t2a[im-1][jm-1]=t2a[im-1][jm-1] + f[jmx[numlev-1]-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t2a[0][j] = t2a[0][j] + f[j+j_off];
|
t2a[0][j] = t2a[0][j] + f[j+j_off];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t2a[im-1][j] = t2a[im-1][j] + f[j+j_off];
|
t2a[im-1][j] = t2a[im-1][j] + f[j+j_off];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2a[j][0] + f[j+i_off];
|
t2a[j][0] = t2a[j][0] + f[j+i_off];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2a[j][jm-1] + f[j+i_off];
|
t2a[j][jm-1] = t2a[j][jm-1] + f[j+i_off];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex]=t1a[iindex] + f[iindex+j_off];
|
t1a[iindex]=t1a[iindex] + f[iindex+j_off];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,19 +470,19 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
|
|
||||||
t h i r d p h a s e
|
t h i r d p h a s e
|
||||||
|
|
||||||
*******************************************************
|
*******************************************************
|
||||||
|
|
||||||
put the jacobian of the work1{1,2} and psi{1,3} arrays
|
put the jacobian of the work1{1,2} and psi{1,3} arrays
|
||||||
(the latter currently in temparray) in the work5{1,2} arrays */
|
(the latter currently in temparray) in the work5{1,2} arrays */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
jacobcalc2(work1,temparray,work5,psiindex,procid,firstrow,lastrow,
|
jacobcalc2(work1,temparray,work5,psiindex,procid,firstrow,lastrow,
|
||||||
firstcol,lastcol);
|
firstcol,lastcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set values of psim{1,3} to temparray{1,3} */
|
/* set values of psim{1,3} to temparray{1,3} */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
t2a = (double **) psim[procid][psiindex];
|
t2a = (double **) psim[procid][psiindex];
|
||||||
t2b = (double **) temparray[procid][psiindex];
|
t2b = (double **) temparray[procid][psiindex];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
|
@ -501,31 +500,31 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1b[j];
|
t1a[j] = t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1b[j];
|
t1a[j] = t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2b[j][0];
|
t2a[j][0] = t2b[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2b[j][jm-1];
|
t2a[j][jm-1] = t2b[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1b[iindex];
|
t1a[iindex] = t1b[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,9 +533,9 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
/* put the laplacian of the work7{1,2} arrays in the work4{1,2}
|
/* put the laplacian of the work7{1,2} arrays in the work4{1,2}
|
||||||
arrays; second step in the three-laplacian friction calculation */
|
arrays; second step in the three-laplacian friction calculation */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
laplacalc(procid,work7,work4,psiindex,
|
laplacalc(procid,work7,work4,psiindex,
|
||||||
firstrow,lastrow,firstcol,lastcol);
|
firstrow,lastrow,firstcol,lastcol);
|
||||||
}
|
}
|
||||||
#if defined(MULTIPLE_BARRIERS)
|
#if defined(MULTIPLE_BARRIERS)
|
||||||
BARRIER(bars->sl_phase_3,nprocs)
|
BARRIER(bars->sl_phase_3,nprocs)
|
||||||
|
@ -557,9 +556,9 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
/* put the laplacian of the work4{1,2} arrays in the work7{1,2}
|
/* put the laplacian of the work4{1,2} arrays in the work7{1,2}
|
||||||
arrays; third step in the three-laplacian friction calculation */
|
arrays; third step in the three-laplacian friction calculation */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
laplacalc(procid,work4,work7,psiindex,
|
laplacalc(procid,work4,work7,psiindex,
|
||||||
firstrow,lastrow,firstcol,lastcol);
|
firstrow,lastrow,firstcol,lastcol);
|
||||||
}
|
}
|
||||||
#if defined(MULTIPLE_BARRIERS)
|
#if defined(MULTIPLE_BARRIERS)
|
||||||
BARRIER(bars->sl_phase_4,nprocs)
|
BARRIER(bars->sl_phase_4,nprocs)
|
||||||
|
@ -589,37 +588,37 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t2h = (double **) tauz[procid];
|
t2h = (double **) tauz[procid];
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[0][0] = t2c[0][0]-t2d[0][0] +
|
t2a[0][0] = t2c[0][0]-t2d[0][0] +
|
||||||
eig2*t2g[0][0]+h1inv*t2h[0][0] +
|
eig2*t2g[0][0]+h1inv*t2h[0][0] +
|
||||||
lf*t2e[0][0]-lf*t2f[0][0];
|
lf*t2e[0][0]-lf*t2f[0][0];
|
||||||
t2b[0][0] = hh1*t2c[0][0]+hh3*t2d[0][0] +
|
t2b[0][0] = hh1*t2c[0][0]+hh3*t2d[0][0] +
|
||||||
hinv*t2h[0][0]+lf*hh1*t2e[0][0] +
|
hinv*t2h[0][0]+lf*hh1*t2e[0][0] +
|
||||||
lf*hh3*t2f[0][0];
|
lf*hh3*t2f[0][0];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[im-1][0] = t2c[im-1][0]-t2d[im-1][0] +
|
t2a[im-1][0] = t2c[im-1][0]-t2d[im-1][0] +
|
||||||
eig2*t2g[im-1][0] + h1inv*t2h[im-1][0] +
|
eig2*t2g[im-1][0] + h1inv*t2h[im-1][0] +
|
||||||
lf*t2e[im-1][0] - lf*t2f[im-1][0];
|
lf*t2e[im-1][0] - lf*t2f[im-1][0];
|
||||||
t2b[im-1][0] = hh1*t2c[im-1][0] +
|
t2b[im-1][0] = hh1*t2c[im-1][0] +
|
||||||
hh3*t2d[im-1][0] + hinv*t2h[im-1][0] +
|
hh3*t2d[im-1][0] + hinv*t2h[im-1][0] +
|
||||||
lf*hh1*t2e[im-1][0] + lf*hh3*t2f[im-1][0];
|
lf*hh1*t2e[im-1][0] + lf*hh3*t2f[im-1][0];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[0][jm-1] = t2c[0][jm-1]-t2d[0][jm-1]+
|
t2a[0][jm-1] = t2c[0][jm-1]-t2d[0][jm-1]+
|
||||||
eig2*t2g[0][jm-1]+h1inv*t2h[0][jm-1] +
|
eig2*t2g[0][jm-1]+h1inv*t2h[0][jm-1] +
|
||||||
lf*t2e[0][jm-1]-lf*t2f[0][jm-1];
|
lf*t2e[0][jm-1]-lf*t2f[0][jm-1];
|
||||||
t2b[0][jm-1] = hh1*t2c[0][jm-1] +
|
t2b[0][jm-1] = hh1*t2c[0][jm-1] +
|
||||||
hh3*t2d[0][jm-1]+hinv*t2h[0][jm-1] +
|
hh3*t2d[0][jm-1]+hinv*t2h[0][jm-1] +
|
||||||
lf*hh1*t2e[0][jm-1]+lf*hh3*t2f[0][jm-1];
|
lf*hh1*t2e[0][jm-1]+lf*hh3*t2f[0][jm-1];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[im-1][jm-1] = t2c[im-1][jm-1] -
|
t2a[im-1][jm-1] = t2c[im-1][jm-1] -
|
||||||
t2d[im-1][jm-1]+eig2*t2g[im-1][jm-1] +
|
t2d[im-1][jm-1]+eig2*t2g[im-1][jm-1] +
|
||||||
h1inv*t2h[im-1][jm-1]+lf*t2e[im-1][jm-1] -
|
h1inv*t2h[im-1][jm-1]+lf*t2e[im-1][jm-1] -
|
||||||
lf*t2f[im-1][jm-1];
|
lf*t2f[im-1][jm-1];
|
||||||
t2b[im-1][jm-1] = hh1*t2c[im-1][jm-1] +
|
t2b[im-1][jm-1] = hh1*t2c[im-1][jm-1] +
|
||||||
hh3*t2d[im-1][jm-1]+hinv*t2h[im-1][jm-1] +
|
hh3*t2d[im-1][jm-1]+hinv*t2h[im-1][jm-1] +
|
||||||
lf*hh1*t2e[im-1][jm-1] +
|
lf*hh1*t2e[im-1][jm-1] +
|
||||||
lf*hh3*t2f[im-1][jm-1];
|
lf*hh3*t2f[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
|
@ -630,13 +629,13 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t1f = (double *) t2f[0];
|
t1f = (double *) t2f[0];
|
||||||
t1g = (double *) t2g[0];
|
t1g = (double *) t2g[0];
|
||||||
t1h = (double *) t2h[0];
|
t1h = (double *) t2h[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1c[j]-t1d[j] +
|
t1a[j] = t1c[j]-t1d[j] +
|
||||||
eig2*t1g[j]+h1inv*t1h[j] +
|
eig2*t1g[j]+h1inv*t1h[j] +
|
||||||
lf*t1e[j]-lf*t1f[j];
|
lf*t1e[j]-lf*t1f[j];
|
||||||
t1b[j] = hh1*t1c[j] +
|
t1b[j] = hh1*t1c[j] +
|
||||||
hh3*t1d[j]+hinv*t1h[j] +
|
hh3*t1d[j]+hinv*t1h[j] +
|
||||||
lf*hh1*t1e[j]+lf*hh3*t1f[j];
|
lf*hh1*t1e[j]+lf*hh3*t1f[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
|
@ -648,39 +647,39 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t1f = (double *) t2f[im-1];
|
t1f = (double *) t2f[im-1];
|
||||||
t1g = (double *) t2g[im-1];
|
t1g = (double *) t2g[im-1];
|
||||||
t1h = (double *) t2h[im-1];
|
t1h = (double *) t2h[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1c[j] -
|
t1a[j] = t1c[j] -
|
||||||
t1d[j]+eig2*t1g[j] +
|
t1d[j]+eig2*t1g[j] +
|
||||||
h1inv*t1h[j]+lf*t1e[j] -
|
h1inv*t1h[j]+lf*t1e[j] -
|
||||||
lf*t1f[j];
|
lf*t1f[j];
|
||||||
t1b[j] = hh1*t1c[j] +
|
t1b[j] = hh1*t1c[j] +
|
||||||
hh3*t1d[j]+hinv*t1h[j] +
|
hh3*t1d[j]+hinv*t1h[j] +
|
||||||
lf*hh1*t1e[j]+lf*hh3*t1f[j];
|
lf*hh1*t1e[j]+lf*hh3*t1f[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2c[j][0]-t2d[j][0] +
|
t2a[j][0] = t2c[j][0]-t2d[j][0] +
|
||||||
eig2*t2g[j][0]+h1inv*t2h[j][0] +
|
eig2*t2g[j][0]+h1inv*t2h[j][0] +
|
||||||
lf*t2e[j][0]-lf*t2f[j][0];
|
lf*t2e[j][0]-lf*t2f[j][0];
|
||||||
t2b[j][0] = hh1*t2c[j][0] +
|
t2b[j][0] = hh1*t2c[j][0] +
|
||||||
hh3*t2d[j][0]+hinv*t2h[j][0] +
|
hh3*t2d[j][0]+hinv*t2h[j][0] +
|
||||||
lf*hh1*t2e[j][0]+lf*hh3*t2f[j][0];
|
lf*hh1*t2e[j][0]+lf*hh3*t2f[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2c[j][jm-1] -
|
t2a[j][jm-1] = t2c[j][jm-1] -
|
||||||
t2d[j][jm-1]+eig2*t2g[j][jm-1] +
|
t2d[j][jm-1]+eig2*t2g[j][jm-1] +
|
||||||
h1inv*t2h[j][jm-1]+lf*t2e[j][jm-1] -
|
h1inv*t2h[j][jm-1]+lf*t2e[j][jm-1] -
|
||||||
lf*t2f[j][jm-1];
|
lf*t2f[j][jm-1];
|
||||||
t2b[j][jm-1] = hh1*t2c[j][jm-1] +
|
t2b[j][jm-1] = hh1*t2c[j][jm-1] +
|
||||||
hh3*t2d[j][jm-1]+hinv*t2h[j][jm-1] +
|
hh3*t2d[j][jm-1]+hinv*t2h[j][jm-1] +
|
||||||
lf*hh1*t2e[j][jm-1]+lf*hh3*t2f[j][jm-1];
|
lf*hh1*t2e[j][jm-1]+lf*hh3*t2f[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
t1c = (double *) t2c[i];
|
t1c = (double *) t2c[i];
|
||||||
|
@ -689,15 +688,15 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t1f = (double *) t2f[i];
|
t1f = (double *) t2f[i];
|
||||||
t1g = (double *) t2g[i];
|
t1g = (double *) t2g[i];
|
||||||
t1h = (double *) t2h[i];
|
t1h = (double *) t2h[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1c[iindex] -
|
t1a[iindex] = t1c[iindex] -
|
||||||
t1d[iindex]+eig2*t1g[iindex] +
|
t1d[iindex]+eig2*t1g[iindex] +
|
||||||
h1inv*t1h[iindex]+lf*t1e[iindex] -
|
h1inv*t1h[iindex]+lf*t1e[iindex] -
|
||||||
lf*t1f[iindex];
|
lf*t1f[iindex];
|
||||||
t1b[iindex] = hh1*t1c[iindex] +
|
t1b[iindex] = hh1*t1c[iindex] +
|
||||||
hh3*t1d[iindex]+hinv*t1h[iindex] +
|
hh3*t1d[iindex]+hinv*t1h[iindex] +
|
||||||
lf*hh1*t1e[iindex] +
|
lf*hh1*t1e[iindex] +
|
||||||
lf*hh3*t1f[iindex];
|
lf*hh3*t1f[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(MULTIPLE_BARRIERS)
|
#if defined(MULTIPLE_BARRIERS)
|
||||||
|
@ -736,10 +735,10 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t2b = (double **) ga[procid];
|
t2b = (double **) ga[procid];
|
||||||
t2c = (double **) oldga[procid];
|
t2c = (double **) oldga[procid];
|
||||||
t2d = (double **) q_multi[procid][numlev-1];
|
t2d = (double **) q_multi[procid][numlev-1];
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1a[j] = t1b[j] * ressqr;
|
t1a[j] = t1b[j] * ressqr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -747,33 +746,33 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1d = (double *) t2d[0];
|
t1d = (double *) t2d[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1d[j] = t1b[j];
|
t1d[j] = t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1d = (double *) t2d[im-1];
|
t1d = (double *) t2d[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1d[j] = t1b[j];
|
t1d[j] = t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t2d[i][0] = t2b[i][0];
|
t2d[i][0] = t2b[i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t2d[i][jm-1] = t2b[i][jm-1];
|
t2d[i][jm-1] = t2b[i][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fac = 1.0 / (4.0 - ressqr*eig2);
|
fac = 1.0 / (4.0 - ressqr*eig2);
|
||||||
for (i=ist;i<=ien;i++) {
|
for(i=ist;i<=ien;i++) {
|
||||||
t1d = (double *) t2d[i];
|
t1d = (double *) t2d[i];
|
||||||
t1c = (double *) t2c[i];
|
t1c = (double *) t2c[i];
|
||||||
for (j=jst;j<=jen;j++) {
|
for(j=jst;j<=jen;j++) {
|
||||||
t1d[j] = t1c[j];
|
t1d[j] = t1c[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -798,11 +797,11 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
|
|
||||||
/* copy the solution for use as initial guess in next time-step */
|
/* copy the solution for use as initial guess in next time-step */
|
||||||
|
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
t1c = (double *) t2c[i];
|
t1c = (double *) t2c[i];
|
||||||
t1d = (double *) t2d[i];
|
t1d = (double *) t2d[i];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1b[j] = t1d[j];
|
t1b[j] = t1d[j];
|
||||||
t1c[j] = t1d[j];
|
t1c[j] = t1d[j];
|
||||||
}
|
}
|
||||||
|
@ -837,29 +836,29 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
psiaipriv = psiaipriv + 0.5*t1a[j];
|
psiaipriv = psiaipriv + 0.5*t1a[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
psiaipriv = psiaipriv + 0.5*t1a[j];
|
psiaipriv = psiaipriv + 0.5*t1a[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
psiaipriv = psiaipriv + 0.5*t2a[j][0];
|
psiaipriv = psiaipriv + 0.5*t2a[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
psiaipriv = psiaipriv + 0.5*t2a[j][jm-1];
|
psiaipriv = psiaipriv + 0.5*t2a[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
psiaipriv = psiaipriv + t1a[iindex];
|
psiaipriv = psiaipriv + t1a[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -898,36 +897,36 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
||||||
f4*t2b[im-1][jm-1];
|
f4*t2b[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j]+f4*t1b[j];
|
t1a[j] = t1a[j]+f4*t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j]+f4*t1b[j];
|
t1a[j] = t1a[j]+f4*t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2a[j][0]+f4*t2b[j][0];
|
t2a[j][0] = t2a[j][0]+f4*t2b[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2a[j][jm-1]+f4*t2b[j][jm-1];
|
t2a[j][jm-1] = t2a[j][jm-1]+f4*t2b[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1a[iindex]+f4*t1b[iindex];
|
t1a[iindex] = t1a[iindex]+f4*t1b[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -936,43 +935,43 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t2b = (double **) gb[procid];
|
t2b = (double **) gb[procid];
|
||||||
t2c = (double **) oldgb[procid];
|
t2c = (double **) oldgb[procid];
|
||||||
t2d = (double **) q_multi[procid][numlev-1];
|
t2d = (double **) q_multi[procid][numlev-1];
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1a[j] = t1b[j] * ressqr;
|
t1a[j] = t1b[j] * ressqr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1d = (double *) t2d[0];
|
t1d = (double *) t2d[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1d[j] = t1b[j];
|
t1d[j] = t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1d = (double *) t2d[im-1];
|
t1d = (double *) t2d[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1d[j] = t1b[j];
|
t1d[j] = t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t2d[i][0] = t2b[i][0];
|
t2d[i][0] = t2b[i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t2d[i][jm-1] = t2b[i][jm-1];
|
t2d[i][jm-1] = t2b[i][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fac = 1.0 / (4.0 - ressqr*eig2);
|
fac = 1.0 / (4.0 - ressqr*eig2);
|
||||||
for (i=ist;i<=ien;i++) {
|
for(i=ist;i<=ien;i++) {
|
||||||
t1d = (double *) t2d[i];
|
t1d = (double *) t2d[i];
|
||||||
t1c = (double *) t2c[i];
|
t1c = (double *) t2c[i];
|
||||||
for (j=jst;j<=jen;j++) {
|
for(j=jst;j<=jen;j++) {
|
||||||
t1d[j] = t1c[j];
|
t1d[j] = t1c[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,11 +987,11 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
gp[procid].multi_time += (multi_end - multi_start);
|
gp[procid].multi_time += (multi_end - multi_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
t1c = (double *) t2c[i];
|
t1c = (double *) t2c[i];
|
||||||
t1d = (double *) t2d[i];
|
t1d = (double *) t2d[i];
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
t1b[j] = t1d[j];
|
t1b[j] = t1d[j];
|
||||||
t1c[j] = t1d[j];
|
t1c[j] = t1d[j];
|
||||||
}
|
}
|
||||||
|
@ -1035,16 +1034,16 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2c[im-1][jm-1] = t2b[im-1][jm-1] -
|
t2c[im-1][jm-1] = t2b[im-1][jm-1] -
|
||||||
hh1*t2a[im-1][jm-1];
|
hh1*t2a[im-1][jm-1];
|
||||||
t2d[im-1][jm-1] = t2b[im-1][jm-1] +
|
t2d[im-1][jm-1] = t2b[im-1][jm-1] +
|
||||||
hh3*t2a[im-1][jm-1];
|
hh3*t2a[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
t1c = (double *) t2c[0];
|
t1c = (double *) t2c[0];
|
||||||
t1d = (double *) t2d[0];
|
t1d = (double *) t2d[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1d[j] = t1b[j]+hh3*t1a[j];
|
t1d[j] = t1b[j]+hh3*t1a[j];
|
||||||
t1c[j] = t1b[j]-hh1*t1a[j];
|
t1c[j] = t1b[j]-hh1*t1a[j];
|
||||||
}
|
}
|
||||||
|
@ -1054,30 +1053,30 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
t1c = (double *) t2c[im-1];
|
t1c = (double *) t2c[im-1];
|
||||||
t1d = (double *) t2d[im-1];
|
t1d = (double *) t2d[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1d[j] = t1b[j]+hh3*t1a[j];
|
t1d[j] = t1b[j]+hh3*t1a[j];
|
||||||
t1c[j] = t1b[j]-hh1*t1a[j];
|
t1c[j] = t1b[j]-hh1*t1a[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2d[j][0] = t2b[j][0]+hh3*t2a[j][0];
|
t2d[j][0] = t2b[j][0]+hh3*t2a[j][0];
|
||||||
t2c[j][0] = t2b[j][0]-hh1*t2a[j][0];
|
t2c[j][0] = t2b[j][0]-hh1*t2a[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2d[j][jm-1] = t2b[j][jm-1]+hh3*t2a[j][jm-1];
|
t2d[j][jm-1] = t2b[j][jm-1]+hh3*t2a[j][jm-1];
|
||||||
t2c[j][jm-1] = t2b[j][jm-1]-hh1*t2a[j][jm-1];
|
t2c[j][jm-1] = t2b[j][jm-1]-hh1*t2a[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
t1c = (double *) t2c[i];
|
t1c = (double *) t2c[i];
|
||||||
t1d = (double *) t2d[i];
|
t1d = (double *) t2d[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1d[iindex] = t1b[iindex] + hh3*t1a[iindex];
|
t1d[iindex] = t1b[iindex] + hh3*t1a[iindex];
|
||||||
t1c[iindex] = t1b[iindex] - hh1*t1a[iindex];
|
t1c[iindex] = t1b[iindex] - hh1*t1a[iindex];
|
||||||
}
|
}
|
||||||
|
@ -1105,45 +1104,45 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[im-1][0] = t2a[im-1][0] +
|
t2a[im-1][0] = t2a[im-1][0] +
|
||||||
timst*t2b[im-1][0];
|
timst*t2b[im-1][0];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[0][jm-1] = t2a[0][jm-1] +
|
t2a[0][jm-1] = t2a[0][jm-1] +
|
||||||
timst*t2b[0][jm-1];
|
timst*t2b[0][jm-1];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
||||||
timst*t2b[im-1][jm-1];
|
timst*t2b[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j] + timst*t1b[j];
|
t1a[j] = t1a[j] + timst*t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j] + timst*t1b[j];
|
t1a[j] = t1a[j] + timst*t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2a[j][0] + timst*t2b[j][0];
|
t2a[j][0] = t2a[j][0] + timst*t2b[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2a[j][jm-1] +
|
t2a[j][jm-1] = t2a[j][jm-1] +
|
||||||
timst*t2b[j][jm-1];
|
timst*t2b[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1a[iindex] + timst*t1b[iindex];
|
t1a[iindex] = t1a[iindex] + timst*t1b[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1155,46 +1154,46 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[LEFT] == -1)) {
|
||||||
t2a[im-1][0] = t2a[im-1][0] +
|
t2a[im-1][0] = t2a[im-1][0] +
|
||||||
timst*t2b[im-1][0];
|
timst*t2b[im-1][0];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[UP] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[0][jm-1] = t2a[0][jm-1] +
|
t2a[0][jm-1] = t2a[0][jm-1] +
|
||||||
timst*t2b[0][jm-1];
|
timst*t2b[0][jm-1];
|
||||||
}
|
}
|
||||||
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
if ((gp[procid].neighbors[DOWN] == -1) && (gp[procid].neighbors[RIGHT] == -1)) {
|
||||||
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
t2a[im-1][jm-1] = t2a[im-1][jm-1] +
|
||||||
timst*t2b[im-1][jm-1];
|
timst*t2b[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[UP] == -1) {
|
if (gp[procid].neighbors[UP] == -1) {
|
||||||
t1a = (double *) t2a[0];
|
t1a = (double *) t2a[0];
|
||||||
t1b = (double *) t2b[0];
|
t1b = (double *) t2b[0];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j] + timst*t1b[j];
|
t1a[j] = t1a[j] + timst*t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[DOWN] == -1) {
|
if (gp[procid].neighbors[DOWN] == -1) {
|
||||||
t1a = (double *) t2a[im-1];
|
t1a = (double *) t2a[im-1];
|
||||||
t1b = (double *) t2b[im-1];
|
t1b = (double *) t2b[im-1];
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
t1a[j] = t1a[j] + timst*t1b[j];
|
t1a[j] = t1a[j] + timst*t1b[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[LEFT] == -1) {
|
if (gp[procid].neighbors[LEFT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][0] = t2a[j][0] + timst*t2b[j][0];
|
t2a[j][0] = t2a[j][0] + timst*t2b[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gp[procid].neighbors[RIGHT] == -1) {
|
if (gp[procid].neighbors[RIGHT] == -1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
t2a[j][jm-1] = t2a[j][jm-1] +
|
t2a[j][jm-1] = t2a[j][jm-1] +
|
||||||
timst*t2b[j][jm-1];
|
timst*t2b[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
t1a = (double *) t2a[i];
|
t1a = (double *) t2a[i];
|
||||||
t1b = (double *) t2b[i];
|
t1b = (double *) t2b[i];
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
t1a[iindex] = t1a[iindex] + timst*t1b[iindex];
|
t1a[iindex] = t1a[iindex] + timst*t1b[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,8 @@
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void subblock()
|
void subblock()
|
||||||
|
|
|
@ -17,10 +17,9 @@
|
||||||
/* does the arakawa jacobian calculation (of the x and y matrices,
|
/* does the arakawa jacobian calculation (of the x and y matrices,
|
||||||
putting the results in the z matrix) for a subblock. */
|
putting the results in the z matrix) for a subblock. */
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <ctime>
|
#include <time.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void jacobcalc(double x[IMAX][JMAX], double y[IMAX][JMAX], double z[IMAX][JMAX], long pid, long firstrow, long lastrow, long firstcol, long lastcol, long numrows, long numcols)
|
void jacobcalc(double x[IMAX][JMAX], double y[IMAX][JMAX], double z[IMAX][JMAX], long pid, long firstrow, long lastrow, long firstcol, long lastcol, long numrows, long numcols)
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
|
|
||||||
performs the laplacian calculation for a subblock. */
|
performs the laplacian calculation for a subblock. */
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <ctime>
|
#include <time.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void laplacalc(double x[IMAX][JMAX], double z[IMAX][JMAX], long firstrow, long lastrow, long firstcol, long lastcol, long numrows, long numcols)
|
void laplacalc(double x[IMAX][JMAX], double z[IMAX][JMAX], long firstrow, long lastrow, long firstcol, long lastcol, long numrows, long numcols)
|
||||||
|
|
|
@ -23,11 +23,10 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <time.h>
|
||||||
#include <ctime>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
MAIN_ENV
|
MAIN_ENV
|
||||||
|
|
|
@ -19,11 +19,10 @@
|
||||||
iterations, w cycles, and the method of half-injection for
|
iterations, w cycles, and the method of half-injection for
|
||||||
residual computation */
|
residual computation */
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <time.h>
|
||||||
#include <ctime>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
/* perform multigrid (w cycles) */
|
/* perform multigrid (w cycles) */
|
||||||
|
@ -208,8 +207,8 @@ void relax(long k, double *err, long color, long my_num)
|
||||||
for (i=evenistart;i<iend;i+=2) {
|
for (i=evenistart;i<iend;i+=2) {
|
||||||
for (j=evenjstart;j<jend;j+=2) {
|
for (j=evenjstart;j<jend;j+=2) {
|
||||||
a = multi->q_multi[k][i][j+1] + multi->q_multi[k][i][j-1] +
|
a = multi->q_multi[k][i][j+1] + multi->q_multi[k][i][j-1] +
|
||||||
multi->q_multi[k][i-1][j] + multi->q_multi[k][i+1][j] -
|
multi->q_multi[k][i-1][j] + multi->q_multi[k][i+1][j] -
|
||||||
multi->rhs_multi[k][i][j] ;
|
multi->rhs_multi[k][i][j] ;
|
||||||
oldval = multi->q_multi[k][i][j];
|
oldval = multi->q_multi[k][i][j];
|
||||||
newval = a / factor;
|
newval = a / factor;
|
||||||
newerr = oldval - newval;
|
newerr = oldval - newval;
|
||||||
|
@ -222,8 +221,8 @@ void relax(long k, double *err, long color, long my_num)
|
||||||
for (i=oddistart;i<iend;i+=2) {
|
for (i=oddistart;i<iend;i+=2) {
|
||||||
for (j=oddjstart;j<jend;j+=2) {
|
for (j=oddjstart;j<jend;j+=2) {
|
||||||
a = multi->q_multi[k][i][j+1] + multi->q_multi[k][i][j-1] +
|
a = multi->q_multi[k][i][j+1] + multi->q_multi[k][i][j-1] +
|
||||||
multi->q_multi[k][i-1][j] + multi->q_multi[k][i+1][j] -
|
multi->q_multi[k][i-1][j] + multi->q_multi[k][i+1][j] -
|
||||||
multi->rhs_multi[k][i][j] ;
|
multi->rhs_multi[k][i][j] ;
|
||||||
oldval = multi->q_multi[k][i][j];
|
oldval = multi->q_multi[k][i][j];
|
||||||
newval = a / factor;
|
newval = a / factor;
|
||||||
newerr = oldval - newval;
|
newerr = oldval - newval;
|
||||||
|
@ -237,8 +236,8 @@ void relax(long k, double *err, long color, long my_num)
|
||||||
for (i=evenistart;i<iend;i+=2) {
|
for (i=evenistart;i<iend;i+=2) {
|
||||||
for (j=oddjstart;j<jend;j+=2) {
|
for (j=oddjstart;j<jend;j+=2) {
|
||||||
a = multi->q_multi[k][i][j+1] + multi->q_multi[k][i][j-1] +
|
a = multi->q_multi[k][i][j+1] + multi->q_multi[k][i][j-1] +
|
||||||
multi->q_multi[k][i-1][j] + multi->q_multi[k][i+1][j] -
|
multi->q_multi[k][i-1][j] + multi->q_multi[k][i+1][j] -
|
||||||
multi->rhs_multi[k][i][j] ;
|
multi->rhs_multi[k][i][j] ;
|
||||||
oldval = multi->q_multi[k][i][j];
|
oldval = multi->q_multi[k][i][j];
|
||||||
newval = a / factor;
|
newval = a / factor;
|
||||||
newerr = oldval - newval;
|
newerr = oldval - newval;
|
||||||
|
@ -251,8 +250,8 @@ void relax(long k, double *err, long color, long my_num)
|
||||||
for (i=oddistart;i<iend;i+=2) {
|
for (i=oddistart;i<iend;i+=2) {
|
||||||
for (j=evenjstart;j<jend;j+=2) {
|
for (j=evenjstart;j<jend;j+=2) {
|
||||||
a = multi->q_multi[k][i][j+1] + multi->q_multi[k][i][j-1] +
|
a = multi->q_multi[k][i][j+1] + multi->q_multi[k][i][j-1] +
|
||||||
multi->q_multi[k][i-1][j] + multi->q_multi[k][i+1][j] -
|
multi->q_multi[k][i-1][j] + multi->q_multi[k][i+1][j] -
|
||||||
multi->rhs_multi[k][i][j] ;
|
multi->rhs_multi[k][i][j] ;
|
||||||
oldval = multi->q_multi[k][i][j];
|
oldval = multi->q_multi[k][i][j];
|
||||||
newval = a / factor;
|
newval = a / factor;
|
||||||
newerr = oldval - newval;
|
newerr = oldval - newval;
|
||||||
|
@ -306,25 +305,25 @@ void rescal(long kf, long my_num)
|
||||||
factor = 4.0 - eig2 * hf * hf;
|
factor = 4.0 - eig2 * hf * hf;
|
||||||
|
|
||||||
if17=2*(istart-1);
|
if17=2*(istart-1);
|
||||||
for (ic=istart;ic<=iend;ic++) {
|
for(ic=istart;ic<=iend;ic++) {
|
||||||
if17+=2;
|
if17+=2;
|
||||||
i_int_factor = ic * i_int_coeff[krc] * 0.5;
|
i_int_factor = ic * i_int_coeff[krc] * 0.5;
|
||||||
jf = 2 * (jstart - 1);
|
jf = 2 * (jstart - 1);
|
||||||
for (jc=jstart;jc<=jend;jc++) {
|
for(jc=jstart;jc<=jend;jc++) {
|
||||||
jf+=2;
|
jf+=2;
|
||||||
j_int_factor = jc*j_int_coeff[krc] * 0.5;
|
j_int_factor = jc*j_int_coeff[krc] * 0.5;
|
||||||
/* method of half-injection uses 2.0 instead of 4.0 */
|
/* method of half-injection uses 2.0 instead of 4.0 */
|
||||||
s = multi->q_multi[kf][if17][jf+1] + multi->q_multi[kf][if17][jf-1] +
|
s = multi->q_multi[kf][if17][jf+1] + multi->q_multi[kf][if17][jf-1] +
|
||||||
multi->q_multi[kf][if17-1][jf] + multi->q_multi[kf][if17+1][jf];
|
multi->q_multi[kf][if17-1][jf] + multi->q_multi[kf][if17+1][jf];
|
||||||
s1 = 2.0 * (multi->rhs_multi[kf][if17][jf] - s +
|
s1 = 2.0 * (multi->rhs_multi[kf][if17][jf] - s +
|
||||||
factor * multi->q_multi[kf][if17][jf]);
|
factor * multi->q_multi[kf][if17][jf]);
|
||||||
if ((if17 == 2) || (jf ==2)) {
|
if ((if17 == 2) || (jf ==2)) {
|
||||||
s2 = 0;
|
s2 = 0;
|
||||||
} else {
|
} else {
|
||||||
s = multi->q_multi[kf][if17][jf-1] + multi->q_multi[kf][if17][jf-3] +
|
s = multi->q_multi[kf][if17][jf-1] + multi->q_multi[kf][if17][jf-3] +
|
||||||
multi->q_multi[kf][if17-1][jf-2] + multi->q_multi[kf][if17+1][jf-2];
|
multi->q_multi[kf][if17-1][jf-2] + multi->q_multi[kf][if17+1][jf-2];
|
||||||
s2 = 2.0 * (multi->rhs_multi[kf][if17][jf-2] - s +
|
s2 = 2.0 * (multi->rhs_multi[kf][if17][jf-2] - s +
|
||||||
factor * multi->q_multi[kf][if17][jf-2]);
|
factor * multi->q_multi[kf][if17][jf-2]);
|
||||||
}
|
}
|
||||||
if ((if17 == 2) || (jf ==2)) {
|
if ((if17 == 2) || (jf ==2)) {
|
||||||
s3 = 0;
|
s3 = 0;
|
||||||
|
@ -332,7 +331,7 @@ void rescal(long kf, long my_num)
|
||||||
s = multi->q_multi[kf][if17-2][jf+1] + multi->q_multi[kf][if17-2][jf-1] +
|
s = multi->q_multi[kf][if17-2][jf+1] + multi->q_multi[kf][if17-2][jf-1] +
|
||||||
multi->q_multi[kf][if17-3][jf] + multi->q_multi[kf][if17-1][jf];
|
multi->q_multi[kf][if17-3][jf] + multi->q_multi[kf][if17-1][jf];
|
||||||
s3 = 2.0 * (multi->rhs_multi[kf][if17-2][jf] - s +
|
s3 = 2.0 * (multi->rhs_multi[kf][if17-2][jf] - s +
|
||||||
factor * multi->q_multi[kf][if17-2][jf]);
|
factor * multi->q_multi[kf][if17-2][jf]);
|
||||||
}
|
}
|
||||||
if ((if17 == 2) || (jf ==2)) {
|
if ((if17 == 2) || (jf ==2)) {
|
||||||
s4 = 0;
|
s4 = 0;
|
||||||
|
@ -340,7 +339,7 @@ void rescal(long kf, long my_num)
|
||||||
s = multi->q_multi[kf][if17-2][jf-1] + multi->q_multi[kf][if17-2][jf-3] +
|
s = multi->q_multi[kf][if17-2][jf-1] + multi->q_multi[kf][if17-2][jf-3] +
|
||||||
multi->q_multi[kf][if17-3][jf-2] + multi->q_multi[kf][if17-1][jf-2];
|
multi->q_multi[kf][if17-3][jf-2] + multi->q_multi[kf][if17-1][jf-2];
|
||||||
s4 = 2.0 * (multi->rhs_multi[kf][if17-2][jf-2] - s +
|
s4 = 2.0 * (multi->rhs_multi[kf][if17-2][jf-2] - s +
|
||||||
factor * multi->q_multi[kf][if17-2][jf-2]);
|
factor * multi->q_multi[kf][if17-2][jf-2]);
|
||||||
}
|
}
|
||||||
int1 = j_int_factor*s4 + (1.0-j_int_factor)*s3;
|
int1 = j_int_factor*s4 + (1.0-j_int_factor)*s3;
|
||||||
int2 = j_int_factor*s2 + (1.0-j_int_factor)*s1;
|
int2 = j_int_factor*s2 + (1.0-j_int_factor)*s1;
|
||||||
|
@ -389,7 +388,7 @@ void intadd(long kc, long my_num)
|
||||||
iend = gp[my_num].rel_start_y[kc] + gp[my_num].rel_num_y[kc] - 1;
|
iend = gp[my_num].rel_start_y[kc] + gp[my_num].rel_num_y[kc] - 1;
|
||||||
jend = gp[my_num].rel_start_x[kc] + gp[my_num].rel_num_x[kc] - 1;
|
jend = gp[my_num].rel_start_x[kc] + gp[my_num].rel_num_x[kc] - 1;
|
||||||
if17 = 2*(istart-1);
|
if17 = 2*(istart-1);
|
||||||
for (ic=istart;ic<=iend;ic++) {
|
for(ic=istart;ic<=iend;ic++) {
|
||||||
|
|
||||||
if17+=2;
|
if17+=2;
|
||||||
ifine1 = if17-1;
|
ifine1 = if17-1;
|
||||||
|
@ -399,7 +398,7 @@ void intadd(long kc, long my_num)
|
||||||
|
|
||||||
jf = 2*(jstart-1);
|
jf = 2*(jstart-1);
|
||||||
|
|
||||||
for (jc=jstart;jc<=jend;jc++) {
|
for(jc=jstart;jc<=jend;jc++) {
|
||||||
jf+=2;
|
jf+=2;
|
||||||
jfine1 = jf-1;
|
jfine1 = jf-1;
|
||||||
jfine2 = jf;
|
jfine2 = jf;
|
||||||
|
@ -407,25 +406,25 @@ void intadd(long kc, long my_num)
|
||||||
j_int_factor2= jc * j_int_coeff[kf];
|
j_int_factor2= jc * j_int_coeff[kf];
|
||||||
|
|
||||||
int1 = j_int_factor1*multi->q_multi[kc][ic][jc-1] +
|
int1 = j_int_factor1*multi->q_multi[kc][ic][jc-1] +
|
||||||
(1.0-j_int_factor1)*multi->q_multi[kc][ic][jc];
|
(1.0-j_int_factor1)*multi->q_multi[kc][ic][jc];
|
||||||
int2 = j_int_factor1*multi->q_multi[kc][ic-1][jc-1] +
|
int2 = j_int_factor1*multi->q_multi[kc][ic-1][jc-1] +
|
||||||
(1.0-j_int_factor1)*multi->q_multi[kc][ic-1][jc];
|
(1.0-j_int_factor1)*multi->q_multi[kc][ic-1][jc];
|
||||||
multi->q_multi[kf][if17-1][jf-1] += i_int_factor1*int2 +
|
multi->q_multi[kf][if17-1][jf-1] += i_int_factor1*int2 +
|
||||||
(1.0-i_int_factor1)*int1;
|
(1.0-i_int_factor1)*int1;
|
||||||
int2 = j_int_factor1*multi->q_multi[kc][ic+1][jc-1] +
|
int2 = j_int_factor1*multi->q_multi[kc][ic+1][jc-1] +
|
||||||
(1.0-j_int_factor1)*multi->q_multi[kc][ic+1][jc];
|
(1.0-j_int_factor1)*multi->q_multi[kc][ic+1][jc];
|
||||||
multi->q_multi[kf][if17][jf-1] += i_int_factor2*int2 +
|
multi->q_multi[kf][if17][jf-1] += i_int_factor2*int2 +
|
||||||
(1.0-i_int_factor2)*int1;
|
(1.0-i_int_factor2)*int1;
|
||||||
int1 = j_int_factor2*multi->q_multi[kc][ic][jc+1] +
|
int1 = j_int_factor2*multi->q_multi[kc][ic][jc+1] +
|
||||||
(1.0-j_int_factor2)*multi->q_multi[kc][ic][jc];
|
(1.0-j_int_factor2)*multi->q_multi[kc][ic][jc];
|
||||||
int2 = j_int_factor2*multi->q_multi[kc][ic-1][jc+1] +
|
int2 = j_int_factor2*multi->q_multi[kc][ic-1][jc+1] +
|
||||||
(1.0-j_int_factor2)*multi->q_multi[kc][ic-1][jc];
|
(1.0-j_int_factor2)*multi->q_multi[kc][ic-1][jc];
|
||||||
multi->q_multi[kf][if17-1][jf] += i_int_factor1*int2 +
|
multi->q_multi[kf][if17-1][jf] += i_int_factor1*int2 +
|
||||||
(1.0-i_int_factor1)*int1;
|
(1.0-i_int_factor1)*int1;
|
||||||
int2 = j_int_factor2*multi->q_multi[kc][ic+1][jc+1] +
|
int2 = j_int_factor2*multi->q_multi[kc][ic+1][jc+1] +
|
||||||
(1.0-j_int_factor2)*multi->q_multi[kc][ic+1][jc];
|
(1.0-j_int_factor2)*multi->q_multi[kc][ic+1][jc];
|
||||||
multi->q_multi[kf][if17][jf] += i_int_factor2*int2 +
|
multi->q_multi[kf][if17][jf] += i_int_factor2*int2 +
|
||||||
(1.0-i_int_factor2)*int1;
|
(1.0-i_int_factor2)*int1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,10 @@
|
||||||
subroutine slave
|
subroutine slave
|
||||||
**************** */
|
**************** */
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <time.h>
|
||||||
#include <ctime>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ void slave()
|
||||||
|
|
||||||
ysca1 = 0.5*ysca;
|
ysca1 = 0.5*ysca;
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
for (iindex = 0;iindex<=jm-1;iindex++) {
|
for(iindex = 0;iindex<=jm-1;iindex++) {
|
||||||
y = ((double) iindex)*res;
|
y = ((double) iindex)*res;
|
||||||
wrk2->f[iindex] = f0+beta*(y-ysca1);
|
wrk2->f[iindex] = f0+beta*(y-ysca1);
|
||||||
}
|
}
|
||||||
|
@ -122,28 +122,28 @@ void slave()
|
||||||
fields2->psium[im-1][jm-1]=0.0;
|
fields2->psium[im-1][jm-1]=0.0;
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields2->psium[0][j] = 0.0;
|
fields2->psium[0][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields2->psium[im-1][j] = 0.0;
|
fields2->psium[im-1][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields2->psium[j][0] = 0.0;
|
fields2->psium[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields2->psium[j][jm-1] = 0.0;
|
fields2->psium[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields2->psium[i][iindex] = 0.0;
|
fields2->psium[i][iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,27 +160,27 @@ void slave()
|
||||||
fields2->psilm[im-1][jm-1]=0.0;
|
fields2->psilm[im-1][jm-1]=0.0;
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields2->psilm[0][j] = 0.0;
|
fields2->psilm[0][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields2->psilm[im-1][j] = 0.0;
|
fields2->psilm[im-1][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields2->psilm[j][0] = 0.0;
|
fields2->psilm[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields2->psilm[j][jm-1] = 0.0;
|
fields2->psilm[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields2->psilm[i][iindex] = 0.0;
|
fields2->psilm[i][iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,27 +198,27 @@ void slave()
|
||||||
wrk1->psib[im-1][jm-1]=1.0;
|
wrk1->psib[im-1][jm-1]=1.0;
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->psib[0][j] = 1.0;
|
wrk1->psib[0][j] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->psib[im-1][j] = 1.0;
|
wrk1->psib[im-1][j] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->psib[j][0] = 1.0;
|
wrk1->psib[j][0] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->psib[j][jm-1] = 1.0;
|
wrk1->psib[j][jm-1] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk1->psib[i][iindex] = 0.0;
|
wrk1->psib[i][iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,35 +249,35 @@ BARRIER(bars->barrier,nprocs)
|
||||||
if (jend == jm-2) {
|
if (jend == jm-2) {
|
||||||
jend = jm-1;
|
jend = jm-1;
|
||||||
}
|
}
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->rhs_multi[numlev-1][i][j] = wrk1->psib[i][j] * ressqr;
|
multi->rhs_multi[numlev-1][i][j] = wrk1->psib[i][j] * ressqr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (istart == 0) {
|
if (istart == 0) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->q_multi[numlev-1][0][j] = wrk1->psib[0][j];
|
multi->q_multi[numlev-1][0][j] = wrk1->psib[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iend == im-1) {
|
if (iend == im-1) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->q_multi[numlev-1][im-1][j] = wrk1->psib[im-1][j];
|
multi->q_multi[numlev-1][im-1][j] = wrk1->psib[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jstart == 0) {
|
if (jstart == 0) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
multi->q_multi[numlev-1][i][0] = wrk1->psib[i][0];
|
multi->q_multi[numlev-1][i][0] = wrk1->psib[i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jend == jm-1) {
|
if (jend == jm-1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
multi->q_multi[numlev-1][i][jm-1] = wrk1->psib[i][jm-1];
|
multi->q_multi[numlev-1][i][jm-1] = wrk1->psib[i][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fac = 1.0 / (4.0 - ressqr*eig2);
|
fac = 1.0 / (4.0 - ressqr*eig2);
|
||||||
for (i=ist;i<=ien;i++) {
|
for(i=ist;i<=ien;i++) {
|
||||||
for (j=jst;j<=jen;j++) {
|
for(j=jst;j<=jen;j++) {
|
||||||
multi->q_multi[numlev-1][i][j] = fac * (wrk1->psib[i+1][j] +
|
multi->q_multi[numlev-1][i][j] = fac * (wrk1->psib[i+1][j] +
|
||||||
wrk1->psib[i-1][j] + wrk1->psib[i][j+1] + wrk1->psib[i][j-1] -
|
wrk1->psib[i-1][j] + wrk1->psib[i][j+1] + wrk1->psib[i][j-1] -
|
||||||
ressqr*wrk1->psib[i][j]);
|
ressqr*wrk1->psib[i][j]);
|
||||||
|
@ -290,8 +290,8 @@ BARRIER(bars->barrier,nprocs)
|
||||||
#endif
|
#endif
|
||||||
multig(procid);
|
multig(procid);
|
||||||
|
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
wrk1->psib[i][j] = multi->q_multi[numlev-1][i][j];
|
wrk1->psib[i][j] = multi->q_multi[numlev-1][i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,27 +317,27 @@ BARRIER(bars->barrier,nprocs)
|
||||||
psibipriv=psibipriv+0.25*(wrk1->psib[im-1][jm-1]);
|
psibipriv=psibipriv+0.25*(wrk1->psib[im-1][jm-1]);
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
psibipriv = psibipriv + 0.5*wrk1->psib[0][j];
|
psibipriv = psibipriv + 0.5*wrk1->psib[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
psibipriv = psibipriv + 0.5*wrk1->psib[im-1][j];
|
psibipriv = psibipriv + 0.5*wrk1->psib[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
psibipriv = psibipriv + 0.5*wrk1->psib[j][0];
|
psibipriv = psibipriv + 0.5*wrk1->psib[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
psibipriv = psibipriv + 0.5*wrk1->psib[j][jm-1];
|
psibipriv = psibipriv + 0.5*wrk1->psib[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
psibipriv = psibipriv + wrk1->psib[i][iindex];
|
psibipriv = psibipriv + wrk1->psib[i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ BARRIER(bars->barrier,nprocs)
|
||||||
global->psibi = global->psibi + psibipriv;
|
global->psibi = global->psibi + psibipriv;
|
||||||
UNLOCK(locks->psibilock)
|
UNLOCK(locks->psibilock)
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
fields->psim[psiindex][0][0] = 0.0;
|
fields->psim[psiindex][0][0] = 0.0;
|
||||||
}
|
}
|
||||||
|
@ -365,27 +365,27 @@ BARRIER(bars->barrier,nprocs)
|
||||||
fields->psim[psiindex][im-1][jm-1] = 0.0;
|
fields->psim[psiindex][im-1][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psim[psiindex][0][j] = 0.0;
|
fields->psim[psiindex][0][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psim[psiindex][im-1][j] = 0.0;
|
fields->psim[psiindex][im-1][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psim[psiindex][j][0] = 0.0;
|
fields->psim[psiindex][j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psim[psiindex][j][jm-1] = 0.0;
|
fields->psim[psiindex][j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields->psim[psiindex][i][iindex] = 0.0;
|
fields->psim[psiindex][i][iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ BARRIER(bars->barrier,nprocs)
|
||||||
|
|
||||||
/* initialize psi matrices the same way */
|
/* initialize psi matrices the same way */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
fields->psi[psiindex][0][0] = 0.0;
|
fields->psi[psiindex][0][0] = 0.0;
|
||||||
}
|
}
|
||||||
|
@ -407,27 +407,27 @@ BARRIER(bars->barrier,nprocs)
|
||||||
fields->psi[psiindex][im-1][jm-1] = 0.0;
|
fields->psi[psiindex][im-1][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psi[psiindex][0][j] = 0.0;
|
fields->psi[psiindex][0][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psi[psiindex][im-1][j] = 0.0;
|
fields->psi[psiindex][im-1][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psi[psiindex][j][0] = 0.0;
|
fields->psi[psiindex][j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psi[psiindex][j][jm-1] = 0.0;
|
fields->psi[psiindex][j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields->psi[psiindex][i][iindex] = 0.0;
|
fields->psi[psiindex][i][iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,7 +454,7 @@ BARRIER(bars->barrier,nprocs)
|
||||||
frcng->tauz[im-1][jm-1] = frcng->tauz[0][jm-1];
|
frcng->tauz[im-1][jm-1] = frcng->tauz[0][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
sintemp = pi*((double) j)*res/ysca1;
|
sintemp = pi*((double) j)*res/ysca1;
|
||||||
sintemp = sin(sintemp);
|
sintemp = sin(sintemp);
|
||||||
curlt = factor*sintemp;
|
curlt = factor*sintemp;
|
||||||
|
@ -462,7 +462,7 @@ BARRIER(bars->barrier,nprocs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
sintemp = pi*((double) j)*res/ysca1;
|
sintemp = pi*((double) j)*res/ysca1;
|
||||||
sintemp = sin(sintemp);
|
sintemp = sin(sintemp);
|
||||||
curlt = factor*sintemp;
|
curlt = factor*sintemp;
|
||||||
|
@ -470,7 +470,7 @@ BARRIER(bars->barrier,nprocs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
frcng->tauz[j][0] = 0.0;
|
frcng->tauz[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -478,15 +478,15 @@ BARRIER(bars->barrier,nprocs)
|
||||||
sintemp = pi*((double) jmm1)*res/ysca1;
|
sintemp = pi*((double) jmm1)*res/ysca1;
|
||||||
sintemp = sin(sintemp);
|
sintemp = sin(sintemp);
|
||||||
curlt = factor*sintemp;
|
curlt = factor*sintemp;
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
frcng->tauz[j][jm-1] = curlt;
|
frcng->tauz[j][jm-1] = curlt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
sintemp = pi*((double) iindex)*res/ysca1;
|
sintemp = pi*((double) iindex)*res/ysca1;
|
||||||
sintemp = sin(sintemp);
|
sintemp = sin(sintemp);
|
||||||
curlt = factor*sintemp;
|
curlt = factor*sintemp;
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
frcng->tauz[i][iindex] = curlt;
|
frcng->tauz[i][iindex] = curlt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ BARRIER(bars->barrier,nprocs)
|
||||||
iday = (long) day;
|
iday = (long) day;
|
||||||
dhour = dhour+dtau;
|
dhour = dhour+dtau;
|
||||||
if (dhour >= 86400.0) {
|
if (dhour >= 86400.0) {
|
||||||
dhourflag = 1;
|
dhourflag = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,27 +552,27 @@ BARRIER(bars->barrier,nprocs)
|
||||||
fields2->psium[im-1][jm-1] = fields2->psium[im-1][jm-1]+fields->psim[0][im-1][jm-1];
|
fields2->psium[im-1][jm-1] = fields2->psium[im-1][jm-1]+fields->psim[0][im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields2->psium[0][j] = fields2->psium[0][j]+fields->psim[0][0][j];
|
fields2->psium[0][j] = fields2->psium[0][j]+fields->psim[0][0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields2->psium[im-1][j] = fields2->psium[im-1][j]+fields->psim[0][im-1][j];
|
fields2->psium[im-1][j] = fields2->psium[im-1][j]+fields->psim[0][im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields2->psium[j][0] = fields2->psium[j][0]+fields->psim[0][j][0];
|
fields2->psium[j][0] = fields2->psium[j][0]+fields->psim[0][j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields2->psium[j][jm-1] = fields2->psium[j][jm-1]+fields->psim[0][j][jm-1];
|
fields2->psium[j][jm-1] = fields2->psium[j][jm-1]+fields->psim[0][j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields2->psium[i][iindex] = fields2->psium[i][iindex]+fields->psim[0][i][iindex];
|
fields2->psium[i][iindex] = fields2->psium[i][iindex]+fields->psim[0][i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -592,27 +592,27 @@ BARRIER(bars->barrier,nprocs)
|
||||||
fields2->psilm[im-1][jm-1] = fields2->psilm[im-1][jm-1]+fields->psim[1][im-1][jm-1];
|
fields2->psilm[im-1][jm-1] = fields2->psilm[im-1][jm-1]+fields->psim[1][im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields2->psilm[0][j] = fields2->psilm[0][j]+fields->psim[1][0][j];
|
fields2->psilm[0][j] = fields2->psilm[0][j]+fields->psim[1][0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields2->psilm[im-1][j] = fields2->psilm[im-1][j]+fields->psim[1][im-1][j];
|
fields2->psilm[im-1][j] = fields2->psilm[im-1][j]+fields->psim[1][im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields2->psilm[j][0] = fields2->psilm[j][0]+fields->psim[1][j][0];
|
fields2->psilm[j][0] = fields2->psilm[j][0]+fields->psim[1][j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields2->psilm[j][jm-1] = fields2->psilm[j][jm-1]+fields->psim[1][j][jm-1];
|
fields2->psilm[j][jm-1] = fields2->psilm[j][jm-1]+fields->psim[1][j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields2->psilm[i][iindex] = fields2->psilm[i][iindex]+fields->psim[1][i][iindex];
|
fields2->psilm[i][iindex] = fields2->psilm[i][iindex]+fields->psim[1][i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
subroutine slave2
|
subroutine slave2
|
||||||
**************** */
|
**************** */
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
#include <cstdlib>
|
#include <time.h>
|
||||||
#include <ctime>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "decs.h"
|
#include "decs.h"
|
||||||
|
|
||||||
void slave2(long procid, long firstrow, long lastrow, long numrows, long firstcol, long lastcol, long numcols)
|
void slave2(long procid, long firstrow, long lastrow, long numrows, long firstcol, long lastcol, long numcols)
|
||||||
|
@ -72,27 +71,27 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk1->ga[im-1][jm-1]=0.0;
|
wrk1->ga[im-1][jm-1]=0.0;
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->ga[0][j] = 0.0;
|
wrk1->ga[0][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->ga[im-1][j] = 0.0;
|
wrk1->ga[im-1][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->ga[j][0] = 0.0;
|
wrk1->ga[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->ga[j][jm-1] = 0.0;
|
wrk1->ga[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk1->ga[i][iindex] = 0.0;
|
wrk1->ga[i][iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,27 +109,27 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk1->gb[im-1][jm-1]=0.0;
|
wrk1->gb[im-1][jm-1]=0.0;
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->gb[0][j] = 0.0;
|
wrk1->gb[0][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->gb[im-1][j] = 0.0;
|
wrk1->gb[im-1][j] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->gb[j][0] = 0.0;
|
wrk1->gb[j][0] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->gb[j][jm-1] = 0.0;
|
wrk1->gb[j][jm-1] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk1->gb[i][iindex] = 0.0;
|
wrk1->gb[i][iindex] = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +138,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
note that psi(i,j,2) represents the psi3 array in
|
note that psi(i,j,2) represents the psi3 array in
|
||||||
the original equations */
|
the original equations */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
wrk3->work1[psiindex][0][0] = 0;
|
wrk3->work1[psiindex][0][0] = 0;
|
||||||
}
|
}
|
||||||
|
@ -153,8 +152,8 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk3->work1[psiindex][im-1][jm-1] = 0;
|
wrk3->work1[psiindex][im-1][jm-1] = 0;
|
||||||
}
|
}
|
||||||
laplacalc(fields->psi[psiindex],
|
laplacalc(fields->psi[psiindex],
|
||||||
wrk3->work1[psiindex],
|
wrk3->work1[psiindex],
|
||||||
firstrow,lastrow,firstcol,lastcol,numrows,numcols);
|
firstrow,lastrow,firstcol,lastcol,numrows,numcols);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,27 +171,27 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk3->work2[im-1][jm-1] = fields->psi[0][im-1][jm-1]-fields->psi[1][im-1][jm-1];
|
wrk3->work2[im-1][jm-1] = fields->psi[0][im-1][jm-1]-fields->psi[1][im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk3->work2[0][j] = fields->psi[0][0][j]-fields->psi[1][0][j];
|
wrk3->work2[0][j] = fields->psi[0][0][j]-fields->psi[1][0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk3->work2[im-1][j] = fields->psi[0][im-1][j]-fields->psi[1][im-1][j];
|
wrk3->work2[im-1][j] = fields->psi[0][im-1][j]-fields->psi[1][im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk3->work2[j][0] = fields->psi[0][j][0]-fields->psi[1][j][0];
|
wrk3->work2[j][0] = fields->psi[0][j][0]-fields->psi[1][j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk3->work2[j][jm-1] = fields->psi[0][j][jm-1]-fields->psi[1][j][jm-1];
|
wrk3->work2[j][jm-1] = fields->psi[0][j][jm-1]-fields->psi[1][j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk3->work2[i][iindex] = fields->psi[0][i][iindex]-fields->psi[1][i][iindex];
|
wrk3->work2[i][iindex] = fields->psi[0][i][iindex]-fields->psi[1][i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,34 +213,34 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk2->work3[im-1][jm-1] = hh3*fields->psi[0][im-1][jm-1]+hh1*fields->psi[1][im-1][jm-1];
|
wrk2->work3[im-1][jm-1] = hh3*fields->psi[0][im-1][jm-1]+hh1*fields->psi[1][im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk2->work3[0][j] = hh3*fields->psi[0][0][j]+hh1*fields->psi[1][0][j];
|
wrk2->work3[0][j] = hh3*fields->psi[0][0][j]+hh1*fields->psi[1][0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk2->work3[im-1][j] = hh3*fields->psi[0][im-1][j]+hh1*fields->psi[1][im-1][j];
|
wrk2->work3[im-1][j] = hh3*fields->psi[0][im-1][j]+hh1*fields->psi[1][im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk2->work3[j][0] = hh3*fields->psi[0][j][0]+hh1*fields->psi[1][j][0];
|
wrk2->work3[j][0] = hh3*fields->psi[0][j][0]+hh1*fields->psi[1][j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk2->work3[j][jm-1] = hh3*fields->psi[0][j][jm-1]+hh1*fields->psi[1][j][jm-1];
|
wrk2->work3[j][jm-1] = hh3*fields->psi[0][j][jm-1]+hh1*fields->psi[1][j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk2->work3[i][iindex] = hh3*fields->psi[0][i][iindex]+hh1*fields->psi[1][i][iindex];
|
wrk2->work3[i][iindex] = hh3*fields->psi[0][i][iindex]+hh1*fields->psi[1][i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set values of temparray{1,3} to psim{1,3} */
|
/* set values of temparray{1,3} to psim{1,3} */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
wrk5->temparray[psiindex][0][0] = fields->psi[psiindex][0][0];
|
wrk5->temparray[psiindex][0][0] = fields->psi[psiindex][0][0];
|
||||||
}
|
}
|
||||||
|
@ -255,28 +254,28 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk5->temparray[psiindex][im-1][jm-1] = fields->psi[psiindex][im-1][jm-1];
|
wrk5->temparray[psiindex][im-1][jm-1] = fields->psi[psiindex][im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk5->temparray[psiindex][0][j] = fields->psi[psiindex][0][j];
|
wrk5->temparray[psiindex][0][j] = fields->psi[psiindex][0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk5->temparray[psiindex][im-1][j] = fields->psi[psiindex][im-1][j];
|
wrk5->temparray[psiindex][im-1][j] = fields->psi[psiindex][im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk5->temparray[psiindex][j][0] = fields->psi[psiindex][j][0];
|
wrk5->temparray[psiindex][j][0] = fields->psi[psiindex][j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk5->temparray[psiindex][j][jm-1] = fields->psi[psiindex][j][jm-1];
|
wrk5->temparray[psiindex][j][jm-1] = fields->psi[psiindex][j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk5->temparray[psiindex][i][iindex] = fields->psi[psiindex][i][iindex];
|
wrk5->temparray[psiindex][i][iindex] = fields->psi[psiindex][i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +293,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
|
|
||||||
set values of psi{1,3} to psim{1,3} */
|
set values of psi{1,3} to psim{1,3} */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
fields->psi[psiindex][0][0] = fields->psim[psiindex][0][0];
|
fields->psi[psiindex][0][0] = fields->psim[psiindex][0][0];
|
||||||
}
|
}
|
||||||
|
@ -308,28 +307,28 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
fields->psi[psiindex][im-1][jm-1] = fields->psim[psiindex][im-1][jm-1];
|
fields->psi[psiindex][im-1][jm-1] = fields->psim[psiindex][im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psi[psiindex][0][j] = fields->psim[psiindex][0][j];
|
fields->psi[psiindex][0][j] = fields->psim[psiindex][0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psi[psiindex][im-1][j] = fields->psim[psiindex][im-1][j];
|
fields->psi[psiindex][im-1][j] = fields->psim[psiindex][im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psi[psiindex][j][0] = fields->psim[psiindex][j][0];
|
fields->psi[psiindex][j][0] = fields->psim[psiindex][j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psi[psiindex][j][jm-1] = fields->psim[psiindex][j][jm-1];
|
fields->psi[psiindex][j][jm-1] = fields->psim[psiindex][j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields->psi[psiindex][i][iindex] = fields->psim[psiindex][i][iindex];
|
fields->psi[psiindex][i][iindex] = fields->psim[psiindex][i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,7 +338,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
into the work7 array; first part of a three-laplacian
|
into the work7 array; first part of a three-laplacian
|
||||||
calculation to compute the friction terms */
|
calculation to compute the friction terms */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
wrk5->work7[psiindex][0][0] = 0;
|
wrk5->work7[psiindex][0][0] = 0;
|
||||||
}
|
}
|
||||||
|
@ -360,7 +359,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
elements of every column the corresponding value in the
|
elements of every column the corresponding value in the
|
||||||
one-dimenional f array */
|
one-dimenional f array */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
wrk3->work1[psiindex][0][0] = wrk3->work1[psiindex][0][0] + wrk2->f[0];
|
wrk3->work1[psiindex][0][0] = wrk3->work1[psiindex][0][0] + wrk2->f[0];
|
||||||
}
|
}
|
||||||
|
@ -374,29 +373,29 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk3->work1[psiindex][im-1][jm-1] = wrk3->work1[psiindex][im-1][jm-1] + wrk2->f[jm-1];
|
wrk3->work1[psiindex][im-1][jm-1] = wrk3->work1[psiindex][im-1][jm-1] + wrk2->f[jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk3->work1[psiindex][0][j] = wrk3->work1[psiindex][0][j] + wrk2->f[j];
|
wrk3->work1[psiindex][0][j] = wrk3->work1[psiindex][0][j] + wrk2->f[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk3->work1[psiindex][im-1][j] = wrk3->work1[psiindex][im-1][j] + wrk2->f[j];
|
wrk3->work1[psiindex][im-1][j] = wrk3->work1[psiindex][im-1][j] + wrk2->f[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk3->work1[psiindex][j][0] = wrk3->work1[psiindex][j][0] + wrk2->f[j];
|
wrk3->work1[psiindex][j][0] = wrk3->work1[psiindex][j][0] + wrk2->f[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk3->work1[psiindex][j][jm-1] = wrk3->work1[psiindex][j][jm-1] + wrk2->f[j];
|
wrk3->work1[psiindex][j][jm-1] = wrk3->work1[psiindex][j][jm-1] + wrk2->f[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk3->work1[psiindex][i][iindex] = wrk3->work1[psiindex][i][iindex] +
|
wrk3->work1[psiindex][i][iindex] = wrk3->work1[psiindex][i][iindex] +
|
||||||
wrk2->f[iindex];
|
wrk2->f[iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,12 +408,12 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
|
|
||||||
t h i r d p h a s e
|
t h i r d p h a s e
|
||||||
|
|
||||||
*******************************************************
|
*******************************************************
|
||||||
|
|
||||||
put the jacobian of the work1{1,2} and psi{1,3} arrays
|
put the jacobian of the work1{1,2} and psi{1,3} arrays
|
||||||
(the latter currently in temparray) in the work5{1,2} arrays */
|
(the latter currently in temparray) in the work5{1,2} arrays */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
jacobcalc(wrk3->work1[psiindex],wrk5->temparray[psiindex],
|
jacobcalc(wrk3->work1[psiindex],wrk5->temparray[psiindex],
|
||||||
wrk4->work5[psiindex],procid,firstrow,lastrow,firstcol,lastcol,numrows,numcols);
|
wrk4->work5[psiindex],procid,firstrow,lastrow,firstcol,lastcol,numrows,numcols);
|
||||||
}
|
}
|
||||||
|
@ -422,7 +421,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
|
|
||||||
/* set values of psim{1,3} to temparray{1,3} */
|
/* set values of psim{1,3} to temparray{1,3} */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
if (procid == MASTER) {
|
if (procid == MASTER) {
|
||||||
fields->psim[psiindex][0][0] = wrk5->temparray[psiindex][0][0];
|
fields->psim[psiindex][0][0] = wrk5->temparray[psiindex][0][0];
|
||||||
}
|
}
|
||||||
|
@ -436,27 +435,27 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
fields->psim[psiindex][im-1][jm-1] = wrk5->temparray[psiindex][im-1][jm-1];
|
fields->psim[psiindex][im-1][jm-1] = wrk5->temparray[psiindex][im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psim[psiindex][0][j] = wrk5->temparray[psiindex][0][j];
|
fields->psim[psiindex][0][j] = wrk5->temparray[psiindex][0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psim[psiindex][im-1][j] = wrk5->temparray[psiindex][im-1][j];
|
fields->psim[psiindex][im-1][j] = wrk5->temparray[psiindex][im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psim[psiindex][j][0] = wrk5->temparray[psiindex][j][0];
|
fields->psim[psiindex][j][0] = wrk5->temparray[psiindex][j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psim[psiindex][j][jm-1] = wrk5->temparray[psiindex][j][jm-1];
|
fields->psim[psiindex][j][jm-1] = wrk5->temparray[psiindex][j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields->psim[psiindex][i][iindex] = wrk5->temparray[psiindex][i][iindex];
|
fields->psim[psiindex][i][iindex] = wrk5->temparray[psiindex][i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,9 +464,9 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
/* put the laplacian of the work7{1,2} arrays in the work4{1,2}
|
/* put the laplacian of the work7{1,2} arrays in the work4{1,2}
|
||||||
arrays; second step in the three-laplacian friction calculation */
|
arrays; second step in the three-laplacian friction calculation */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
laplacalc(wrk5->work7[psiindex],
|
laplacalc(wrk5->work7[psiindex],
|
||||||
wrk4->work4[psiindex],
|
wrk4->work4[psiindex],
|
||||||
firstrow,lastrow,firstcol,lastcol,numrows,numcols);
|
firstrow,lastrow,firstcol,lastcol,numrows,numcols);
|
||||||
}
|
}
|
||||||
#if defined(MULTIPLE_BARRIERS)
|
#if defined(MULTIPLE_BARRIERS)
|
||||||
|
@ -490,7 +489,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
/* put the laplacian of the work4{1,2} arrays in the work7{1,2}
|
/* put the laplacian of the work4{1,2} arrays in the work7{1,2}
|
||||||
arrays; third step in the three-laplacian friction calculation */
|
arrays; third step in the three-laplacian friction calculation */
|
||||||
|
|
||||||
for (psiindex=0;psiindex<=1;psiindex++) {
|
for(psiindex=0;psiindex<=1;psiindex++) {
|
||||||
laplacalc(wrk4->work4[psiindex],
|
laplacalc(wrk4->work4[psiindex],
|
||||||
wrk5->work7[psiindex],
|
wrk5->work7[psiindex],
|
||||||
firstrow,lastrow,firstcol,lastcol,numrows,numcols);
|
firstrow,lastrow,firstcol,lastcol,numrows,numcols);
|
||||||
|
@ -535,10 +534,10 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk1->ga[im-1][jm-1] = wrk4->work5[0][im-1][jm-1]-wrk4->work5[1][im-1][jm-1]+eig2*wrk6->work6[im-1][jm-1]+
|
wrk1->ga[im-1][jm-1] = wrk4->work5[0][im-1][jm-1]-wrk4->work5[1][im-1][jm-1]+eig2*wrk6->work6[im-1][jm-1]+
|
||||||
h1inv*frcng->tauz[im-1][jm-1]+lf*wrk5->work7[0][im-1][jm-1]-lf*wrk5->work7[1][im-1][jm-1];
|
h1inv*frcng->tauz[im-1][jm-1]+lf*wrk5->work7[0][im-1][jm-1]-lf*wrk5->work7[1][im-1][jm-1];
|
||||||
wrk1->gb[im-1][jm-1] = hh1*wrk4->work5[0][im-1][jm-1]+hh3*wrk4->work5[1][im-1][jm-1]+hinv*
|
wrk1->gb[im-1][jm-1] = hh1*wrk4->work5[0][im-1][jm-1]+hh3*wrk4->work5[1][im-1][jm-1]+hinv*
|
||||||
frcng->tauz[im-1][jm-1]+lf*hh1*wrk5->work7[0][im-1][jm-1]+lf*hh3*wrk5->work7[1][im-1][jm-1];
|
frcng->tauz[im-1][jm-1]+lf*hh1*wrk5->work7[0][im-1][jm-1]+lf*hh3*wrk5->work7[1][im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->ga[0][j] = wrk4->work5[0][0][j]-wrk4->work5[1][0][j]+eig2*
|
wrk1->ga[0][j] = wrk4->work5[0][0][j]-wrk4->work5[1][0][j]+eig2*
|
||||||
wrk6->work6[0][j]+h1inv*frcng->tauz[0][j]+lf*wrk5->work7[0][0][j]-lf*wrk5->work7[0][0][j];
|
wrk6->work6[0][j]+h1inv*frcng->tauz[0][j]+lf*wrk5->work7[0][0][j]-lf*wrk5->work7[0][0][j];
|
||||||
wrk1->gb[0][j] = hh1*wrk4->work5[0][0][j]+hh3*wrk4->work5[1][0][j]+hinv*
|
wrk1->gb[0][j] = hh1*wrk4->work5[0][0][j]+hh3*wrk4->work5[1][0][j]+hinv*
|
||||||
|
@ -546,7 +545,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->ga[im-1][j] = wrk4->work5[0][im-1][j]-wrk4->work5[1][im-1][j]+eig2*
|
wrk1->ga[im-1][j] = wrk4->work5[0][im-1][j]-wrk4->work5[1][im-1][j]+eig2*
|
||||||
wrk6->work6[im-1][j]+h1inv*frcng->tauz[im-1][j]+
|
wrk6->work6[im-1][j]+h1inv*frcng->tauz[im-1][j]+
|
||||||
lf*wrk5->work7[0][im-1][j]-lf*wrk5->work7[1][im-1][j];
|
lf*wrk5->work7[0][im-1][j]-lf*wrk5->work7[1][im-1][j];
|
||||||
|
@ -556,7 +555,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->ga[j][0] = wrk4->work5[0][j][0]-wrk4->work5[1][j][0]+eig2*
|
wrk1->ga[j][0] = wrk4->work5[0][j][0]-wrk4->work5[1][j][0]+eig2*
|
||||||
wrk6->work6[j][0]+h1inv*frcng->tauz[j][0]+lf*wrk5->work7[0][j][0]-lf*wrk5->work7[1][j][0];
|
wrk6->work6[j][0]+h1inv*frcng->tauz[j][0]+lf*wrk5->work7[0][j][0]-lf*wrk5->work7[1][j][0];
|
||||||
wrk1->gb[j][0] = hh1*wrk4->work5[0][j][0]+hh3*wrk4->work5[1][j][0]+hinv*
|
wrk1->gb[j][0] = hh1*wrk4->work5[0][j][0]+hh3*wrk4->work5[1][j][0]+hinv*
|
||||||
|
@ -564,7 +563,7 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->ga[j][jm-1] = wrk4->work5[0][j][jm-1]-wrk4->work5[1][j][jm-1]+eig2*
|
wrk1->ga[j][jm-1] = wrk4->work5[0][j][jm-1]-wrk4->work5[1][j][jm-1]+eig2*
|
||||||
wrk6->work6[j][jm-1]+h1inv*frcng->tauz[j][jm-1]+
|
wrk6->work6[j][jm-1]+h1inv*frcng->tauz[j][jm-1]+
|
||||||
lf*wrk5->work7[0][j][jm-1]-lf*wrk5->work7[1][j][jm-1];
|
lf*wrk5->work7[0][j][jm-1]-lf*wrk5->work7[1][j][jm-1];
|
||||||
|
@ -573,8 +572,8 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
lf*hh3*wrk5->work7[1][j][jm-1];
|
lf*hh3*wrk5->work7[1][j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk1->ga[i][iindex] = wrk4->work5[0][i][iindex]-wrk4->work5[1][i][iindex]+eig2*
|
wrk1->ga[i][iindex] = wrk4->work5[0][i][iindex]-wrk4->work5[1][i][iindex]+eig2*
|
||||||
wrk6->work6[i][iindex]+h1inv*frcng->tauz[i][iindex]+
|
wrk6->work6[i][iindex]+h1inv*frcng->tauz[i][iindex]+
|
||||||
lf*wrk5->work7[0][i][iindex]-lf*wrk5->work7[1][i][iindex];
|
lf*wrk5->work7[0][i][iindex]-lf*wrk5->work7[1][i][iindex];
|
||||||
|
@ -614,35 +613,35 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
if (jend == jm-2) {
|
if (jend == jm-2) {
|
||||||
jend = jm-1;
|
jend = jm-1;
|
||||||
}
|
}
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->rhs_multi[numlev-1][i][j] = wrk1->ga[i][j] * ressqr;
|
multi->rhs_multi[numlev-1][i][j] = wrk1->ga[i][j] * ressqr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (istart == 0) {
|
if (istart == 0) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->q_multi[numlev-1][0][j] = wrk1->ga[0][j];
|
multi->q_multi[numlev-1][0][j] = wrk1->ga[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iend == im-1) {
|
if (iend == im-1) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->q_multi[numlev-1][im-1][j] = wrk1->ga[im-1][j];
|
multi->q_multi[numlev-1][im-1][j] = wrk1->ga[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jstart == 0) {
|
if (jstart == 0) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
multi->q_multi[numlev-1][i][0] = wrk1->ga[i][0];
|
multi->q_multi[numlev-1][i][0] = wrk1->ga[i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jend == jm-1) {
|
if (jend == jm-1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
multi->q_multi[numlev-1][i][jm-1] = wrk1->ga[i][jm-1];
|
multi->q_multi[numlev-1][i][jm-1] = wrk1->ga[i][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fac = 1.0 / (4.0 - ressqr*eig2);
|
fac = 1.0 / (4.0 - ressqr*eig2);
|
||||||
for (i=ist;i<=ien;i++) {
|
for(i=ist;i<=ien;i++) {
|
||||||
for (j=jst;j<=jen;j++) {
|
for(j=jst;j<=jen;j++) {
|
||||||
multi->q_multi[numlev-1][i][j] = guess->oldga[i][j];
|
multi->q_multi[numlev-1][i][j] = guess->oldga[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -664,8 +663,8 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
|
|
||||||
/* copy the solution for use as initial guess in next time-step */
|
/* copy the solution for use as initial guess in next time-step */
|
||||||
|
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
wrk1->ga[i][j] = multi->q_multi[numlev-1][i][j];
|
wrk1->ga[i][j] = multi->q_multi[numlev-1][i][j];
|
||||||
guess->oldga[i][j] = multi->q_multi[numlev-1][i][j];
|
guess->oldga[i][j] = multi->q_multi[numlev-1][i][j];
|
||||||
}
|
}
|
||||||
|
@ -700,27 +699,27 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
psiaipriv=psiaipriv+0.25*(wrk1->ga[im-1][jm-1]);
|
psiaipriv=psiaipriv+0.25*(wrk1->ga[im-1][jm-1]);
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
psiaipriv = psiaipriv + 0.5*wrk1->ga[0][j];
|
psiaipriv = psiaipriv + 0.5*wrk1->ga[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
psiaipriv = psiaipriv + 0.5*wrk1->ga[im-1][j];
|
psiaipriv = psiaipriv + 0.5*wrk1->ga[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
psiaipriv = psiaipriv + 0.5*wrk1->ga[j][0];
|
psiaipriv = psiaipriv + 0.5*wrk1->ga[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
psiaipriv = psiaipriv + 0.5*wrk1->ga[j][jm-1];
|
psiaipriv = psiaipriv + 0.5*wrk1->ga[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
psiaipriv = psiaipriv + wrk1->ga[i][iindex];
|
psiaipriv = psiaipriv + wrk1->ga[i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -761,27 +760,27 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk1->ga[im-1][jm-1] = wrk1->ga[im-1][jm-1]+f4*wrk1->psib[im-1][jm-1];
|
wrk1->ga[im-1][jm-1] = wrk1->ga[im-1][jm-1]+f4*wrk1->psib[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->ga[0][j] = wrk1->ga[0][j]+f4*wrk1->psib[0][j];
|
wrk1->ga[0][j] = wrk1->ga[0][j]+f4*wrk1->psib[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk1->ga[im-1][j] = wrk1->ga[im-1][j]+f4*wrk1->psib[im-1][j];
|
wrk1->ga[im-1][j] = wrk1->ga[im-1][j]+f4*wrk1->psib[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->ga[j][0] = wrk1->ga[j][0]+f4*wrk1->psib[j][0];
|
wrk1->ga[j][0] = wrk1->ga[j][0]+f4*wrk1->psib[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk1->ga[j][jm-1] = wrk1->ga[j][jm-1]+f4*wrk1->psib[j][jm-1];
|
wrk1->ga[j][jm-1] = wrk1->ga[j][jm-1]+f4*wrk1->psib[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk1->ga[i][iindex] = wrk1->ga[i][iindex]+f4*wrk1->psib[i][iindex];
|
wrk1->ga[i][iindex] = wrk1->ga[i][iindex]+f4*wrk1->psib[i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -790,35 +789,35 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
#else
|
#else
|
||||||
BARRIER(bars->barrier,nprocs)
|
BARRIER(bars->barrier,nprocs)
|
||||||
#endif
|
#endif
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->rhs_multi[numlev-1][i][j] = wrk1->gb[i][j] * ressqr;
|
multi->rhs_multi[numlev-1][i][j] = wrk1->gb[i][j] * ressqr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (istart == 0) {
|
if (istart == 0) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->q_multi[numlev-1][0][j] = wrk1->gb[0][j];
|
multi->q_multi[numlev-1][0][j] = wrk1->gb[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (iend == im-1) {
|
if (iend == im-1) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
multi->q_multi[numlev-1][im-1][j] = wrk1->gb[im-1][j];
|
multi->q_multi[numlev-1][im-1][j] = wrk1->gb[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jstart == 0) {
|
if (jstart == 0) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
multi->q_multi[numlev-1][i][0] = wrk1->gb[i][0];
|
multi->q_multi[numlev-1][i][0] = wrk1->gb[i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jend == jm-1) {
|
if (jend == jm-1) {
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
multi->q_multi[numlev-1][i][jm-1] = wrk1->gb[i][jm-1];
|
multi->q_multi[numlev-1][i][jm-1] = wrk1->gb[i][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fac = 1.0 / (4.0 - ressqr*eig2);
|
fac = 1.0 / (4.0 - ressqr*eig2);
|
||||||
for (i=ist;i<=ien;i++) {
|
for(i=ist;i<=ien;i++) {
|
||||||
for (j=jst;j<=jen;j++) {
|
for(j=jst;j<=jen;j++) {
|
||||||
multi->q_multi[numlev-1][i][j] = guess->oldgb[i][j];
|
multi->q_multi[numlev-1][i][j] = guess->oldgb[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -834,8 +833,8 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
gp[procid].multi_time += (multi_end - multi_start);
|
gp[procid].multi_time += (multi_end - multi_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=istart;i<=iend;i++) {
|
for(i=istart;i<=iend;i++) {
|
||||||
for (j=jstart;j<=jend;j++) {
|
for(j=jstart;j<=jend;j++) {
|
||||||
wrk1->gb[i][j] = multi->q_multi[numlev-1][i][j];
|
wrk1->gb[i][j] = multi->q_multi[numlev-1][i][j];
|
||||||
guess->oldgb[i][j] = multi->q_multi[numlev-1][i][j];
|
guess->oldgb[i][j] = multi->q_multi[numlev-1][i][j];
|
||||||
}
|
}
|
||||||
|
@ -877,32 +876,32 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
wrk2->work3[im-1][jm-1] = wrk1->gb[im-1][jm-1]+hh3*wrk1->ga[im-1][jm-1];
|
wrk2->work3[im-1][jm-1] = wrk1->gb[im-1][jm-1]+hh3*wrk1->ga[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk2->work3[0][j] = wrk1->gb[0][j]+hh3*wrk1->ga[0][j];
|
wrk2->work3[0][j] = wrk1->gb[0][j]+hh3*wrk1->ga[0][j];
|
||||||
wrk3->work2[0][j] = wrk1->gb[0][j]-hh1*wrk1->ga[0][j];
|
wrk3->work2[0][j] = wrk1->gb[0][j]-hh1*wrk1->ga[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
wrk2->work3[im-1][j] = wrk1->gb[im-1][j]+hh3*wrk1->ga[im-1][j];
|
wrk2->work3[im-1][j] = wrk1->gb[im-1][j]+hh3*wrk1->ga[im-1][j];
|
||||||
wrk3->work2[im-1][j] = wrk1->gb[im-1][j]-hh1*wrk1->ga[im-1][j];
|
wrk3->work2[im-1][j] = wrk1->gb[im-1][j]-hh1*wrk1->ga[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk2->work3[j][0] = wrk1->gb[j][0]+hh3*wrk1->ga[j][0];
|
wrk2->work3[j][0] = wrk1->gb[j][0]+hh3*wrk1->ga[j][0];
|
||||||
wrk3->work2[j][0] = wrk1->gb[j][0]-hh1*wrk1->ga[j][0];
|
wrk3->work2[j][0] = wrk1->gb[j][0]-hh1*wrk1->ga[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
wrk2->work3[j][jm-1] = wrk1->gb[j][jm-1]+hh3*wrk1->ga[j][jm-1];
|
wrk2->work3[j][jm-1] = wrk1->gb[j][jm-1]+hh3*wrk1->ga[j][jm-1];
|
||||||
wrk3->work2[j][jm-1] = wrk1->gb[j][jm-1]-hh1*wrk1->ga[j][jm-1];
|
wrk3->work2[j][jm-1] = wrk1->gb[j][jm-1]-hh1*wrk1->ga[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
wrk2->work3[i][iindex] = wrk1->gb[i][iindex]+hh3*wrk1->ga[i][iindex];
|
wrk2->work3[i][iindex] = wrk1->gb[i][iindex]+hh3*wrk1->ga[i][iindex];
|
||||||
wrk3->work2[i][iindex] = wrk1->gb[i][iindex]-hh1*wrk1->ga[i][iindex];
|
wrk3->work2[i][iindex] = wrk1->gb[i][iindex]-hh1*wrk1->ga[i][iindex];
|
||||||
}
|
}
|
||||||
|
@ -936,27 +935,27 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
fields->psi[0][im-1][jm-1] = fields->psi[0][im-1][jm-1] + timst*wrk2->work3[im-1][jm-1];
|
fields->psi[0][im-1][jm-1] = fields->psi[0][im-1][jm-1] + timst*wrk2->work3[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psi[0][0][j] = fields->psi[0][0][j] + timst*wrk2->work3[0][j];
|
fields->psi[0][0][j] = fields->psi[0][0][j] + timst*wrk2->work3[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psi[0][im-1][j] = fields->psi[0][im-1][j] + timst*wrk2->work3[im-1][j];
|
fields->psi[0][im-1][j] = fields->psi[0][im-1][j] + timst*wrk2->work3[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psi[0][j][0] = fields->psi[0][j][0] + timst*wrk2->work3[j][0];
|
fields->psi[0][j][0] = fields->psi[0][j][0] + timst*wrk2->work3[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psi[0][j][jm-1] = fields->psi[0][j][jm-1] + timst*wrk2->work3[j][jm-1];
|
fields->psi[0][j][jm-1] = fields->psi[0][j][jm-1] + timst*wrk2->work3[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields->psi[0][i][iindex] = fields->psi[0][i][iindex] + timst*wrk2->work3[i][iindex];
|
fields->psi[0][i][iindex] = fields->psi[0][i][iindex] + timst*wrk2->work3[i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -974,28 +973,28 @@ void slave2(long procid, long firstrow, long lastrow, long numrows, long firstco
|
||||||
fields->psi[1][im-1][jm-1] = fields->psi[1][im-1][jm-1] + timst*wrk3->work2[im-1][jm-1];
|
fields->psi[1][im-1][jm-1] = fields->psi[1][im-1][jm-1] + timst*wrk3->work2[im-1][jm-1];
|
||||||
}
|
}
|
||||||
if (firstrow == 1) {
|
if (firstrow == 1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psi[1][0][j] = fields->psi[1][0][j] + timst*wrk3->work2[0][j];
|
fields->psi[1][0][j] = fields->psi[1][0][j] + timst*wrk3->work2[0][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstrow+numrows) == im-1) {
|
if ((firstrow+numrows) == im-1) {
|
||||||
for (j=firstcol;j<=lastcol;j++) {
|
for(j=firstcol;j<=lastcol;j++) {
|
||||||
fields->psi[1][im-1][j] = fields->psi[1][im-1][j] + timst*wrk3->work2[im-1][j];
|
fields->psi[1][im-1][j] = fields->psi[1][im-1][j] + timst*wrk3->work2[im-1][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstcol == 1) {
|
if (firstcol == 1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psi[1][j][0] = fields->psi[1][j][0] + timst*wrk3->work2[j][0];
|
fields->psi[1][j][0] = fields->psi[1][j][0] + timst*wrk3->work2[j][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((firstcol+numcols) == jm-1) {
|
if ((firstcol+numcols) == jm-1) {
|
||||||
for (j=firstrow;j<=lastrow;j++) {
|
for(j=firstrow;j<=lastrow;j++) {
|
||||||
fields->psi[1][j][jm-1] = fields->psi[1][j][jm-1] + timst*wrk3->work2[j][jm-1];
|
fields->psi[1][j][jm-1] = fields->psi[1][j][jm-1] + timst*wrk3->work2[j][jm-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=firstrow;i<=lastrow;i++) {
|
for(i=firstrow;i<=lastrow;i++) {
|
||||||
for (iindex=firstcol;iindex<=lastcol;iindex++) {
|
for(iindex=firstcol;iindex<=lastcol;iindex++) {
|
||||||
fields->psi[1][i][iindex] = fields->psi[1][i][iindex] + timst*wrk3->work2[i][iindex];
|
fields->psi[1][i][iindex] = fields->psi[1][i][iindex] + timst*wrk3->work2[i][iindex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ void radiosity_averaging(Element *elem, long mode, long process_id)
|
||||||
Vertex pc ;
|
Vertex pc ;
|
||||||
long reverse ;
|
long reverse ;
|
||||||
|
|
||||||
if ( ! LEAF_ELEMENT(elem) )
|
if( ! LEAF_ELEMENT(elem) )
|
||||||
{
|
{
|
||||||
create_radavg_task( elem->center, mode, process_id ) ;
|
create_radavg_task( elem->center, mode, process_id ) ;
|
||||||
create_radavg_task( elem->top, mode, process_id ) ;
|
create_radavg_task( elem->top, mode, process_id ) ;
|
||||||
|
@ -46,7 +46,7 @@ void radiosity_averaging(Element *elem, long mode, long process_id)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( mode == RAD_AVERAGING_MODE )
|
else if( mode == RAD_AVERAGING_MODE )
|
||||||
{
|
{
|
||||||
/* Compute center point */
|
/* Compute center point */
|
||||||
center_point( &elem->ev1->p, &elem->ev2->p, &elem->ev3->p, &pc ) ;
|
center_point( &elem->ev1->p, &elem->ev2->p, &elem->ev3->p, &pc ) ;
|
||||||
|
@ -62,7 +62,7 @@ void radiosity_averaging(Element *elem, long mode, long process_id)
|
||||||
{
|
{
|
||||||
/* Normalize it */
|
/* Normalize it */
|
||||||
LOCK(elem->ev1->ev_lock->lock);
|
LOCK(elem->ev1->ev_lock->lock);
|
||||||
if ( elem->ev1->weight != 1.0 )
|
if( elem->ev1->weight != 1.0 )
|
||||||
{
|
{
|
||||||
inv_weight = (float)1.0 / elem->ev1->weight ;
|
inv_weight = (float)1.0 / elem->ev1->weight ;
|
||||||
elem->ev1->col.r *= inv_weight ;
|
elem->ev1->col.r *= inv_weight ;
|
||||||
|
@ -73,7 +73,7 @@ void radiosity_averaging(Element *elem, long mode, long process_id)
|
||||||
UNLOCK(elem->ev1->ev_lock->lock);
|
UNLOCK(elem->ev1->ev_lock->lock);
|
||||||
|
|
||||||
LOCK(elem->ev2->ev_lock->lock);
|
LOCK(elem->ev2->ev_lock->lock);
|
||||||
if ( elem->ev2->weight != 1.0 )
|
if( elem->ev2->weight != 1.0 )
|
||||||
{
|
{
|
||||||
inv_weight = (float)1.0 / elem->ev2->weight ;
|
inv_weight = (float)1.0 / elem->ev2->weight ;
|
||||||
elem->ev2->col.r *= inv_weight ;
|
elem->ev2->col.r *= inv_weight ;
|
||||||
|
@ -84,7 +84,7 @@ void radiosity_averaging(Element *elem, long mode, long process_id)
|
||||||
UNLOCK(elem->ev2->ev_lock->lock);
|
UNLOCK(elem->ev2->ev_lock->lock);
|
||||||
|
|
||||||
LOCK(elem->ev3->ev_lock->lock);
|
LOCK(elem->ev3->ev_lock->lock);
|
||||||
if ( elem->ev3->weight != 1.0 )
|
if( elem->ev3->weight != 1.0 )
|
||||||
{
|
{
|
||||||
inv_weight = (float)1.0 / elem->ev3->weight ;
|
inv_weight = (float)1.0 / elem->ev3->weight ;
|
||||||
elem->ev3->col.r *= inv_weight ;
|
elem->ev3->col.r *= inv_weight ;
|
||||||
|
@ -101,7 +101,7 @@ static void add_radiosity_to_vertex(Edge *edge, long reverse, Element *elem, Ver
|
||||||
ElemVertex *ev ;
|
ElemVertex *ev ;
|
||||||
float weight ;
|
float weight ;
|
||||||
|
|
||||||
if ( reverse )
|
if( reverse )
|
||||||
ev = edge->pb ;
|
ev = edge->pb ;
|
||||||
else
|
else
|
||||||
ev = edge->pa ;
|
ev = edge->pa ;
|
||||||
|
@ -176,28 +176,28 @@ void display_scene(long fill_sw, long patch_sw, long mesh_sw, long interaction_s
|
||||||
/* Set matrix */
|
/* Set matrix */
|
||||||
g_setup_view( view_rot_x, view_rot_y, view_dist, view_zoom ) ;
|
g_setup_view( view_rot_x, view_rot_y, view_dist, view_zoom ) ;
|
||||||
|
|
||||||
if ( fill_sw == 2 )
|
if( fill_sw == 2 )
|
||||||
{
|
{
|
||||||
/* Fill surfaces */
|
/* Fill surfaces */
|
||||||
display_elements_in_bsp_tree( DISPLAY_SHADED, process_id ) ;
|
display_elements_in_bsp_tree( DISPLAY_SHADED, process_id ) ;
|
||||||
}
|
}
|
||||||
if ( fill_sw == 1 )
|
if( fill_sw == 1 )
|
||||||
{
|
{
|
||||||
/* Fill surfaces */
|
/* Fill surfaces */
|
||||||
display_elements_in_bsp_tree( DISPLAY_FILLED, process_id ) ;
|
display_elements_in_bsp_tree( DISPLAY_FILLED, process_id ) ;
|
||||||
}
|
}
|
||||||
if ( mesh_sw )
|
if( mesh_sw )
|
||||||
{
|
{
|
||||||
/* Draw mesh */
|
/* Draw mesh */
|
||||||
g_color( G_BLUE ) ;
|
g_color( G_BLUE ) ;
|
||||||
display_elements_in_bsp_tree( DISPLAY_EDGEONLY, process_id ) ;
|
display_elements_in_bsp_tree( DISPLAY_EDGEONLY, process_id ) ;
|
||||||
}
|
}
|
||||||
if ( patch_sw )
|
if( patch_sw )
|
||||||
{
|
{
|
||||||
g_color( G_RED ) ;
|
g_color( G_RED ) ;
|
||||||
display_patches_in_bsp_tree( DISPLAY_EDGEONLY, process_id ) ;
|
display_patches_in_bsp_tree( DISPLAY_EDGEONLY, process_id ) ;
|
||||||
}
|
}
|
||||||
if ( interaction_sw )
|
if( interaction_sw )
|
||||||
{
|
{
|
||||||
g_color( G_GREEN ) ;
|
g_color( G_GREEN ) ;
|
||||||
display_interactions_in_bsp_tree(process_id) ;
|
display_interactions_in_bsp_tree(process_id) ;
|
||||||
|
@ -218,9 +218,9 @@ void display_patch(Patch *patch, long mode, long process_id)
|
||||||
Vertex p_buf[4] ;
|
Vertex p_buf[4] ;
|
||||||
Rgb c_buf[4] ;
|
Rgb c_buf[4] ;
|
||||||
|
|
||||||
if ( mode == DISPLAY_SHADED )
|
if( mode == DISPLAY_SHADED )
|
||||||
{
|
{
|
||||||
if ( inner_product( &patch->plane_equ.n, &view_vec ) < F_ZERO )
|
if( inner_product( &patch->plane_equ.n, &view_vec ) < F_ZERO )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
p_buf[0] = patch->p1 ;
|
p_buf[0] = patch->p1 ;
|
||||||
|
@ -232,9 +232,9 @@ void display_patch(Patch *patch, long mode, long process_id)
|
||||||
|
|
||||||
g_spolygon( 3, p_buf, c_buf ) ;
|
g_spolygon( 3, p_buf, c_buf ) ;
|
||||||
}
|
}
|
||||||
else if ( mode == DISPLAY_FILLED )
|
else if( mode == DISPLAY_FILLED )
|
||||||
{
|
{
|
||||||
if ( inner_product( &patch->plane_equ.n, &view_vec ) < F_ZERO )
|
if( inner_product( &patch->plane_equ.n, &view_vec ) < F_ZERO )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
p_buf[0] = patch->p1 ;
|
p_buf[0] = patch->p1 ;
|
||||||
|
@ -275,16 +275,16 @@ void display_element(Element *element, long mode, long process_id)
|
||||||
{
|
{
|
||||||
Vertex p_buf[4] ;
|
Vertex p_buf[4] ;
|
||||||
|
|
||||||
if ( inner_product( &element->patch->plane_equ.n, &view_vec ) < F_ZERO )
|
if( inner_product( &element->patch->plane_equ.n, &view_vec ) < F_ZERO )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( mode == DISPLAY_SHADED )
|
if( mode == DISPLAY_SHADED )
|
||||||
{
|
{
|
||||||
_display_shaded_triangle( element->ev1, element->ev2,
|
_display_shaded_triangle( element->ev1, element->ev2,
|
||||||
element->ev3,
|
element->ev3,
|
||||||
element->e12, element->e23, element->e31, process_id ) ;
|
element->e12, element->e23, element->e31, process_id ) ;
|
||||||
}
|
}
|
||||||
else if ( mode == DISPLAY_FILLED )
|
else if( mode == DISPLAY_FILLED )
|
||||||
{
|
{
|
||||||
g_rgb( element->rad ) ;
|
g_rgb( element->rad ) ;
|
||||||
p_buf[0] = element->ev1->p ;
|
p_buf[0] = element->ev1->p ;
|
||||||
|
@ -361,7 +361,7 @@ static void _disp_interactions(Element *elem, Interaction *inter, long mode, lon
|
||||||
|
|
||||||
|
|
||||||
/* Display interactions only with a particular patch */
|
/* Display interactions only with a particular patch */
|
||||||
if ( (mode == DISPLAY_HALF_INTERACTIONS)
|
if( (mode == DISPLAY_HALF_INTERACTIONS)
|
||||||
&& (inter->destination->patch->seq_no >= elem->patch->seq_no ) )
|
&& (inter->destination->patch->seq_no >= elem->patch->seq_no ) )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
@ -417,24 +417,24 @@ void display_interactions_in_bsp_tree(long process_id)
|
||||||
|
|
||||||
void ps_display_scene(long fill_sw, long patch_sw, long mesh_sw, long interaction_sw, long process_id)
|
void ps_display_scene(long fill_sw, long patch_sw, long mesh_sw, long interaction_sw, long process_id)
|
||||||
{
|
{
|
||||||
if ( fill_sw )
|
if( fill_sw )
|
||||||
{
|
{
|
||||||
/* Fill surfaces */
|
/* Fill surfaces */
|
||||||
ps_display_elements_in_bsp_tree( DISPLAY_SHADED, process_id ) ;
|
ps_display_elements_in_bsp_tree( DISPLAY_SHADED, process_id ) ;
|
||||||
}
|
}
|
||||||
if ( mesh_sw )
|
if( mesh_sw )
|
||||||
{
|
{
|
||||||
/* Draw mesh */
|
/* Draw mesh */
|
||||||
ps_linewidth( 0.5 ) ;
|
ps_linewidth( 0.5 ) ;
|
||||||
ps_display_elements_in_bsp_tree( DISPLAY_EDGEONLY, process_id ) ;
|
ps_display_elements_in_bsp_tree( DISPLAY_EDGEONLY, process_id ) ;
|
||||||
}
|
}
|
||||||
if ( patch_sw )
|
if( patch_sw )
|
||||||
{
|
{
|
||||||
/* Draw patches */
|
/* Draw patches */
|
||||||
ps_linewidth( 1.2 ) ;
|
ps_linewidth( 1.2 ) ;
|
||||||
ps_display_patches_in_bsp_tree( DISPLAY_EDGEONLY, process_id ) ;
|
ps_display_patches_in_bsp_tree( DISPLAY_EDGEONLY, process_id ) ;
|
||||||
}
|
}
|
||||||
if ( interaction_sw )
|
if( interaction_sw )
|
||||||
{
|
{
|
||||||
/* Draw interactions */
|
/* Draw interactions */
|
||||||
ps_linewidth( 0.2 ) ;
|
ps_linewidth( 0.2 ) ;
|
||||||
|
@ -454,9 +454,9 @@ void ps_display_patch(Patch *patch, long mode, long process_id)
|
||||||
Vertex p_buf[4] ;
|
Vertex p_buf[4] ;
|
||||||
Rgb c_buf[4] ;
|
Rgb c_buf[4] ;
|
||||||
|
|
||||||
if ( mode == DISPLAY_SHADED )
|
if( mode == DISPLAY_SHADED )
|
||||||
{
|
{
|
||||||
if ( inner_product( &patch->plane_equ.n, &view_vec ) < F_ZERO )
|
if( inner_product( &patch->plane_equ.n, &view_vec ) < F_ZERO )
|
||||||
return ;
|
return ;
|
||||||
p_buf[0] = patch->p1 ;
|
p_buf[0] = patch->p1 ;
|
||||||
p_buf[1] = patch->p2 ;
|
p_buf[1] = patch->p2 ;
|
||||||
|
@ -467,9 +467,9 @@ void ps_display_patch(Patch *patch, long mode, long process_id)
|
||||||
|
|
||||||
ps_spolygon( 3, p_buf, c_buf ) ;
|
ps_spolygon( 3, p_buf, c_buf ) ;
|
||||||
}
|
}
|
||||||
else if ( mode == DISPLAY_FILLED )
|
else if( mode == DISPLAY_FILLED )
|
||||||
{
|
{
|
||||||
if ( inner_product( &patch->plane_equ.n, &view_vec ) < F_ZERO )
|
if( inner_product( &patch->plane_equ.n, &view_vec ) < F_ZERO )
|
||||||
return ;
|
return ;
|
||||||
p_buf[0] = patch->p1 ;
|
p_buf[0] = patch->p1 ;
|
||||||
p_buf[1] = patch->p2 ;
|
p_buf[1] = patch->p2 ;
|
||||||
|
@ -512,9 +512,9 @@ void ps_display_element(Element *element, long mode, long process_id)
|
||||||
Vertex p_buf[4] ;
|
Vertex p_buf[4] ;
|
||||||
Rgb c_buf[4] ;
|
Rgb c_buf[4] ;
|
||||||
|
|
||||||
if ( mode == DISPLAY_SHADED )
|
if( mode == DISPLAY_SHADED )
|
||||||
{
|
{
|
||||||
if ( inner_product( &element->patch->plane_equ.n, &view_vec )
|
if( inner_product( &element->patch->plane_equ.n, &view_vec )
|
||||||
< F_ZERO )
|
< F_ZERO )
|
||||||
return ;
|
return ;
|
||||||
p_buf[0] = element->ev1->p ;
|
p_buf[0] = element->ev1->p ;
|
||||||
|
@ -526,9 +526,9 @@ void ps_display_element(Element *element, long mode, long process_id)
|
||||||
|
|
||||||
ps_spolygon( 3, p_buf, c_buf ) ;
|
ps_spolygon( 3, p_buf, c_buf ) ;
|
||||||
}
|
}
|
||||||
else if ( mode == DISPLAY_FILLED )
|
else if( mode == DISPLAY_FILLED )
|
||||||
{
|
{
|
||||||
if ( inner_product( &element->patch->plane_equ.n, &view_vec )
|
if( inner_product( &element->patch->plane_equ.n, &view_vec )
|
||||||
< F_ZERO )
|
< F_ZERO )
|
||||||
return ;
|
return ;
|
||||||
p_buf[0] = element->ev1->p ;
|
p_buf[0] = element->ev1->p ;
|
||||||
|
@ -589,7 +589,7 @@ static void _ps_disp_interactions(Element *elem, Interaction *inter, long mode,
|
||||||
Element *edst ;
|
Element *edst ;
|
||||||
|
|
||||||
/* Display interactions only with a particular patch */
|
/* Display interactions only with a particular patch */
|
||||||
if ( (mode == DISPLAY_HALF_INTERACTIONS)
|
if( (mode == DISPLAY_HALF_INTERACTIONS)
|
||||||
&& (inter->destination->patch->seq_no >= elem->patch->seq_no ) )
|
&& (inter->destination->patch->seq_no >= elem->patch->seq_no ) )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ void foreach_element_in_patch(Patch *patch, void (*func)(), long arg1, long pro
|
||||||
|
|
||||||
static void _foreach_element(Element *elem, void (*func)(), long arg1, long process_id)
|
static void _foreach_element(Element *elem, void (*func)(), long arg1, long process_id)
|
||||||
{
|
{
|
||||||
if ( elem == 0 )
|
if( elem == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Process children */
|
/* Process children */
|
||||||
if ( ! LEAF_ELEMENT( elem ) )
|
if( ! LEAF_ELEMENT( elem ) )
|
||||||
{
|
{
|
||||||
_foreach_element( elem->center, func, arg1, process_id ) ;
|
_foreach_element( elem->center, func, arg1, process_id ) ;
|
||||||
_foreach_element( elem->top, func, arg1, process_id ) ;
|
_foreach_element( elem->top, func, arg1, process_id ) ;
|
||||||
|
@ -90,11 +90,11 @@ void foreach_leaf_element_in_patch(Patch *patch, void (*func)(), long arg1, lon
|
||||||
|
|
||||||
static void _foreach_leaf_element(Element *elem, void (*func)(), long arg1, long process_id )
|
static void _foreach_leaf_element(Element *elem, void (*func)(), long arg1, long process_id )
|
||||||
{
|
{
|
||||||
if ( elem == 0 )
|
if( elem == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Process children */
|
/* Process children */
|
||||||
if ( LEAF_ELEMENT( elem ) )
|
if( LEAF_ELEMENT( elem ) )
|
||||||
func( elem, arg1, process_id ) ;
|
func( elem, arg1, process_id ) ;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -141,11 +141,11 @@ void ff_refine_elements(Element *e1, Element *e2, long level, long process_id)
|
||||||
subdiv_advice = error_analysis( e1, e2, &i12, &i21, process_id ) ;
|
subdiv_advice = error_analysis( e1, e2, &i12, &i21, process_id ) ;
|
||||||
|
|
||||||
/* Execute subdivision procedure */
|
/* Execute subdivision procedure */
|
||||||
if ( NO_INTERACTION(subdiv_advice) )
|
if( NO_INTERACTION(subdiv_advice) )
|
||||||
/* Two elements are mutually invisible. Do nothing */
|
/* Two elements are mutually invisible. Do nothing */
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
else if ( NO_REFINEMENT_NECESSARY(subdiv_advice) )
|
else if( NO_REFINEMENT_NECESSARY(subdiv_advice) )
|
||||||
{
|
{
|
||||||
/* Create links and finish the job */
|
/* Create links and finish the job */
|
||||||
inter = get_interaction(process_id) ;
|
inter = get_interaction(process_id) ;
|
||||||
|
@ -162,12 +162,12 @@ void ff_refine_elements(Element *e1, Element *e2, long level, long process_id)
|
||||||
/* Update cost variable */
|
/* Update cost variable */
|
||||||
pc1 = &global->patch_cost[ e1->patch->seq_no ] ;
|
pc1 = &global->patch_cost[ e1->patch->seq_no ] ;
|
||||||
pc2 = &global->patch_cost[ e2->patch->seq_no ] ;
|
pc2 = &global->patch_cost[ e2->patch->seq_no ] ;
|
||||||
if ( pc1->n_total_inter <= 13 )
|
if( pc1->n_total_inter <= 13 )
|
||||||
cost1 = (long)ceil(e1->area / Area_epsilon) ;
|
cost1 = (long)ceil(e1->area / Area_epsilon) ;
|
||||||
else
|
else
|
||||||
cost1 = 1 ;
|
cost1 = 1 ;
|
||||||
|
|
||||||
if ( pc2->n_total_inter <= 13 )
|
if( pc2->n_total_inter <= 13 )
|
||||||
cost2 = (long)ceil(e2->area / Area_epsilon) ;
|
cost2 = (long)ceil(e2->area / Area_epsilon) ;
|
||||||
else
|
else
|
||||||
cost2 = 1 ;
|
cost2 = 1 ;
|
||||||
|
@ -183,7 +183,7 @@ void ff_refine_elements(Element *e1, Element *e2, long level, long process_id)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( REFINE_PATCH_1(subdiv_advice) )
|
else if( REFINE_PATCH_1(subdiv_advice) )
|
||||||
{
|
{
|
||||||
/* Refine patch 1 */
|
/* Refine patch 1 */
|
||||||
subdivide_element( e1, process_id ) ;
|
subdivide_element( e1, process_id ) ;
|
||||||
|
@ -224,13 +224,13 @@ long error_analysis(Element *e1, Element *e2, Interaction *inter12, Interaction
|
||||||
/* Check visibility */
|
/* Check visibility */
|
||||||
cc = patch_intersection( &e1->patch->plane_equ,
|
cc = patch_intersection( &e1->patch->plane_equ,
|
||||||
&e2->ev1->p, &e2->ev2->p, &e2->ev3->p, process_id ) ;
|
&e2->ev1->p, &e2->ev2->p, &e2->ev3->p, process_id ) ;
|
||||||
if ( NEGATIVE_SIDE(cc) )
|
if( NEGATIVE_SIDE(cc) )
|
||||||
/* If negative or on the plane, then do nothing */
|
/* If negative or on the plane, then do nothing */
|
||||||
return( _NO_INTERACTION ) ;
|
return( _NO_INTERACTION ) ;
|
||||||
|
|
||||||
cc = patch_intersection( &e2->patch->plane_equ,
|
cc = patch_intersection( &e2->patch->plane_equ,
|
||||||
&e1->ev1->p, &e1->ev2->p, &e1->ev3->p, process_id ) ;
|
&e1->ev1->p, &e1->ev2->p, &e1->ev3->p, process_id ) ;
|
||||||
if ( NEGATIVE_SIDE(cc) )
|
if( NEGATIVE_SIDE(cc) )
|
||||||
/* If negative or on the plane, then do nothing */
|
/* If negative or on the plane, then do nothing */
|
||||||
return( _NO_INTERACTION ) ;
|
return( _NO_INTERACTION ) ;
|
||||||
|
|
||||||
|
@ -261,14 +261,14 @@ static long bf_refine_element(long subdiv, Element *elem, Interaction *inter, l
|
||||||
visibility_val = NO_VISIBILITY_NECESSARY(subdiv)?
|
visibility_val = NO_VISIBILITY_NECESSARY(subdiv)?
|
||||||
(float)1.0 : VISIBILITY_UNDEF ;
|
(float)1.0 : VISIBILITY_UNDEF ;
|
||||||
|
|
||||||
if ( REFINE_PATCH_1(subdiv) )
|
if( REFINE_PATCH_1(subdiv) )
|
||||||
{
|
{
|
||||||
/* Refine this element */
|
/* Refine this element */
|
||||||
/* (1) Make sure it has children */
|
/* (1) Make sure it has children */
|
||||||
subdivide_element( elem, process_id ) ;
|
subdivide_element( elem, process_id ) ;
|
||||||
|
|
||||||
/* (2) For each of the patch, create an interaction */
|
/* (2) For each of the patch, create an interaction */
|
||||||
if ( element_completely_invisible( elem->center, e_dst, process_id ) == 0 )
|
if( element_completely_invisible( elem->center, e_dst, process_id ) == 0 )
|
||||||
{
|
{
|
||||||
pi = get_interaction(process_id) ;
|
pi = get_interaction(process_id) ;
|
||||||
compute_formfactor( elem->center, e_dst, pi, process_id ) ;
|
compute_formfactor( elem->center, e_dst, pi, process_id ) ;
|
||||||
|
@ -276,7 +276,7 @@ static long bf_refine_element(long subdiv, Element *elem, Interaction *inter, l
|
||||||
insert_vis_undef_interaction( elem->center, pi, process_id ) ;
|
insert_vis_undef_interaction( elem->center, pi, process_id ) ;
|
||||||
new_inter++ ;
|
new_inter++ ;
|
||||||
}
|
}
|
||||||
if ( element_completely_invisible( elem->top, e_dst, process_id ) == 0 )
|
if( element_completely_invisible( elem->top, e_dst, process_id ) == 0 )
|
||||||
{
|
{
|
||||||
pi = get_interaction(process_id) ;
|
pi = get_interaction(process_id) ;
|
||||||
compute_formfactor( elem->top, e_dst, pi, process_id ) ;
|
compute_formfactor( elem->top, e_dst, pi, process_id ) ;
|
||||||
|
@ -284,7 +284,7 @@ static long bf_refine_element(long subdiv, Element *elem, Interaction *inter, l
|
||||||
insert_vis_undef_interaction( elem->top, pi, process_id ) ;
|
insert_vis_undef_interaction( elem->top, pi, process_id ) ;
|
||||||
new_inter++ ;
|
new_inter++ ;
|
||||||
}
|
}
|
||||||
if ( element_completely_invisible( elem->left, e_dst, process_id ) == 0 )
|
if( element_completely_invisible( elem->left, e_dst, process_id ) == 0 )
|
||||||
{
|
{
|
||||||
pi = get_interaction(process_id) ;
|
pi = get_interaction(process_id) ;
|
||||||
compute_formfactor( elem->left, e_dst, pi, process_id ) ;
|
compute_formfactor( elem->left, e_dst, pi, process_id ) ;
|
||||||
|
@ -292,7 +292,7 @@ static long bf_refine_element(long subdiv, Element *elem, Interaction *inter, l
|
||||||
insert_vis_undef_interaction( elem->left, pi, process_id ) ;
|
insert_vis_undef_interaction( elem->left, pi, process_id ) ;
|
||||||
new_inter++ ;
|
new_inter++ ;
|
||||||
}
|
}
|
||||||
if ( element_completely_invisible( elem->right, e_dst, process_id ) == 0 )
|
if( element_completely_invisible( elem->right, e_dst, process_id ) == 0 )
|
||||||
{
|
{
|
||||||
pi = get_interaction(process_id) ;
|
pi = get_interaction(process_id) ;
|
||||||
compute_formfactor( elem->right, e_dst, pi, process_id ) ;
|
compute_formfactor( elem->right, e_dst, pi, process_id ) ;
|
||||||
|
@ -311,7 +311,7 @@ static long bf_refine_element(long subdiv, Element *elem, Interaction *inter, l
|
||||||
NOTE: Use *inter as a place holder to link 4 new interactions
|
NOTE: Use *inter as a place holder to link 4 new interactions
|
||||||
since *prev may be NULL */
|
since *prev may be NULL */
|
||||||
|
|
||||||
if ( element_completely_invisible( elem, e_dst->center, process_id ) == 0 )
|
if( element_completely_invisible( elem, e_dst->center, process_id ) == 0 )
|
||||||
{
|
{
|
||||||
pi = get_interaction(process_id) ;
|
pi = get_interaction(process_id) ;
|
||||||
compute_formfactor( elem, e_dst->center, pi, process_id ) ;
|
compute_formfactor( elem, e_dst->center, pi, process_id ) ;
|
||||||
|
@ -319,7 +319,7 @@ static long bf_refine_element(long subdiv, Element *elem, Interaction *inter, l
|
||||||
insert_vis_undef_interaction( elem, pi, process_id ) ;
|
insert_vis_undef_interaction( elem, pi, process_id ) ;
|
||||||
new_inter++ ;
|
new_inter++ ;
|
||||||
}
|
}
|
||||||
if ( element_completely_invisible( elem, e_dst->top, process_id ) == 0 )
|
if( element_completely_invisible( elem, e_dst->top, process_id ) == 0 )
|
||||||
{
|
{
|
||||||
pi = get_interaction(process_id) ;
|
pi = get_interaction(process_id) ;
|
||||||
compute_formfactor( elem, e_dst->top, pi, process_id ) ;
|
compute_formfactor( elem, e_dst->top, pi, process_id ) ;
|
||||||
|
@ -327,7 +327,7 @@ static long bf_refine_element(long subdiv, Element *elem, Interaction *inter, l
|
||||||
insert_vis_undef_interaction( elem, pi, process_id ) ;
|
insert_vis_undef_interaction( elem, pi, process_id ) ;
|
||||||
new_inter++ ;
|
new_inter++ ;
|
||||||
}
|
}
|
||||||
if ( element_completely_invisible( elem, e_dst->left, process_id ) == 0 )
|
if( element_completely_invisible( elem, e_dst->left, process_id ) == 0 )
|
||||||
{
|
{
|
||||||
pi = get_interaction(process_id) ;
|
pi = get_interaction(process_id) ;
|
||||||
compute_formfactor( elem, e_dst->left, pi, process_id ) ;
|
compute_formfactor( elem, e_dst->left, pi, process_id ) ;
|
||||||
|
@ -335,7 +335,7 @@ static long bf_refine_element(long subdiv, Element *elem, Interaction *inter, l
|
||||||
insert_vis_undef_interaction( elem, pi, process_id ) ;
|
insert_vis_undef_interaction( elem, pi, process_id ) ;
|
||||||
new_inter++ ;
|
new_inter++ ;
|
||||||
}
|
}
|
||||||
if ( element_completely_invisible( elem, e_dst->right, process_id ) == 0 )
|
if( element_completely_invisible( elem, e_dst->right, process_id ) == 0 )
|
||||||
{
|
{
|
||||||
pi = get_interaction(process_id) ;
|
pi = get_interaction(process_id) ;
|
||||||
compute_formfactor( elem, e_dst->right, pi, process_id ) ;
|
compute_formfactor( elem, e_dst->right, pi, process_id ) ;
|
||||||
|
@ -372,12 +372,12 @@ void bf_error_analysis_list(Element *elem, Interaction *i_list, long process_id)
|
||||||
long delta_n_inter = 0 ;
|
long delta_n_inter = 0 ;
|
||||||
|
|
||||||
|
|
||||||
while ( inter )
|
while( inter )
|
||||||
{
|
{
|
||||||
/* Analyze error */
|
/* Analyze error */
|
||||||
subdiv_advice = bf_error_analysis( elem, inter, process_id ) ;
|
subdiv_advice = bf_error_analysis( elem, inter, process_id ) ;
|
||||||
|
|
||||||
if ( NO_REFINEMENT_NECESSARY(subdiv_advice) )
|
if( NO_REFINEMENT_NECESSARY(subdiv_advice) )
|
||||||
{
|
{
|
||||||
/* Go on to the next interaction */
|
/* Go on to the next interaction */
|
||||||
prev = inter ;
|
prev = inter ;
|
||||||
|
@ -389,7 +389,7 @@ void bf_error_analysis_list(Element *elem, Interaction *i_list, long process_id)
|
||||||
/* Remove this interaction from the list */
|
/* Remove this interaction from the list */
|
||||||
refine_inter = inter ;
|
refine_inter = inter ;
|
||||||
inter = inter->next ;
|
inter = inter->next ;
|
||||||
if ( prev == 0 )
|
if( prev == 0 )
|
||||||
i_list = inter ;
|
i_list = inter ;
|
||||||
else
|
else
|
||||||
prev->next = inter ;
|
prev->next = inter ;
|
||||||
|
@ -405,7 +405,7 @@ void bf_error_analysis_list(Element *elem, Interaction *i_list, long process_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Link good interactions to elem->intearctions */
|
/* Link good interactions to elem->intearctions */
|
||||||
if ( i_len > 0 )
|
if( i_len > 0 )
|
||||||
{
|
{
|
||||||
LOCK(elem->elem_lock->lock);
|
LOCK(elem->elem_lock->lock);
|
||||||
prev->next = elem->interactions ;
|
prev->next = elem->interactions ;
|
||||||
|
@ -416,7 +416,7 @@ void bf_error_analysis_list(Element *elem, Interaction *i_list, long process_id)
|
||||||
|
|
||||||
#if PATCH_ASSIGNMENT == PATCH_ASSIGNMENT_COSTBASED
|
#if PATCH_ASSIGNMENT == PATCH_ASSIGNMENT_COSTBASED
|
||||||
/* Update patch interaction count */
|
/* Update patch interaction count */
|
||||||
if ( delta_n_inter != 0 )
|
if( delta_n_inter != 0 )
|
||||||
{
|
{
|
||||||
Patch_Cost *pc ;
|
Patch_Cost *pc ;
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ long bf_error_analysis(Element *elem, Interaction *inter, long process_id)
|
||||||
= B FV + B (Ferr V + F Verr + Ferr Verr)
|
= B FV + B (Ferr V + F Verr + Ferr Verr)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( (0.0 < inter->visibility) && (inter->visibility < 1.0) )
|
if( (0.0 < inter->visibility) && (inter->visibility < 1.0) )
|
||||||
visibility_error = 1.0 ;
|
visibility_error = 1.0 ;
|
||||||
else
|
else
|
||||||
visibility_error = FF_VISIBILITY_ERROR ;
|
visibility_error = FF_VISIBILITY_ERROR ;
|
||||||
|
@ -467,21 +467,21 @@ long bf_error_analysis(Element *elem, Interaction *inter, long process_id)
|
||||||
+ visibility_error * inter->formfactor_err) * rad_avg ;
|
+ visibility_error * inter->formfactor_err) * rad_avg ;
|
||||||
|
|
||||||
/* If BF is smaller than the threshold, then not subdivide */
|
/* If BF is smaller than the threshold, then not subdivide */
|
||||||
if ( (total_error <= BFepsilon) && (elem->n_interactions <= 10) )
|
if( (total_error <= BFepsilon) && (elem->n_interactions <= 10) )
|
||||||
return( _NO_REFINEMENT_NECESSARY ) ;
|
return( _NO_REFINEMENT_NECESSARY ) ;
|
||||||
else if ( total_error <= BFepsilon * 0.5 )
|
else if( total_error <= BFepsilon * 0.5 )
|
||||||
return( _NO_REFINEMENT_NECESSARY ) ;
|
return( _NO_REFINEMENT_NECESSARY ) ;
|
||||||
|
|
||||||
/* Subdivide light source or receiver whichever is larger */
|
/* Subdivide light source or receiver whichever is larger */
|
||||||
if ( elem->area > inter->destination->area )
|
if( elem->area > inter->destination->area )
|
||||||
{
|
{
|
||||||
if ( elem->area > Area_epsilon )
|
if( elem->area > Area_epsilon )
|
||||||
/* Subdivide this element (receiver) */
|
/* Subdivide this element (receiver) */
|
||||||
return( _REFINE_PATCH_1 | vis_code ) ;
|
return( _REFINE_PATCH_1 | vis_code ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( inter->destination->area > Area_epsilon )
|
if( inter->destination->area > Area_epsilon )
|
||||||
|
|
||||||
/* Subdivide source element */
|
/* Subdivide source element */
|
||||||
return( _REFINE_PATCH_2 | vis_code ) ;
|
return( _REFINE_PATCH_2 | vis_code ) ;
|
||||||
|
@ -518,7 +518,7 @@ long radiosity_converged(long process_id)
|
||||||
prev_total += 1.0e-4 ;
|
prev_total += 1.0e-4 ;
|
||||||
difference = fabs( (current_total / prev_total) - (float)1.0 ) ;
|
difference = fabs( (current_total / prev_total) - (float)1.0 ) ;
|
||||||
|
|
||||||
if ( verbose_mode )
|
if( verbose_mode )
|
||||||
{
|
{
|
||||||
rad = global->total_energy ;
|
rad = global->total_energy ;
|
||||||
rad.r /= global->total_patch_area ;
|
rad.r /= global->total_patch_area ;
|
||||||
|
@ -531,7 +531,7 @@ long radiosity_converged(long process_id)
|
||||||
printf( "Difference %.2f%%\n", difference * 100.0 ) ;
|
printf( "Difference %.2f%%\n", difference * 100.0 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( difference <= Energy_epsilon )
|
if( difference <= Energy_epsilon )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
else
|
else
|
||||||
return( 0 ) ;
|
return( 0 ) ;
|
||||||
|
@ -558,7 +558,7 @@ void subdivide_element(Element *e, long process_id)
|
||||||
LOCK(e->elem_lock->lock);
|
LOCK(e->elem_lock->lock);
|
||||||
|
|
||||||
/* Check if the element already has children */
|
/* Check if the element already has children */
|
||||||
if ( ! _LEAF_ELEMENT(e) )
|
if( ! _LEAF_ELEMENT(e) )
|
||||||
{
|
{
|
||||||
UNLOCK(e->elem_lock->lock);
|
UNLOCK(e->elem_lock->lock);
|
||||||
return ;
|
return ;
|
||||||
|
@ -710,7 +710,7 @@ void process_rays(Element *e, long process_id)
|
||||||
/* For each interaction, do BF-error-analysis */
|
/* For each interaction, do BF-error-analysis */
|
||||||
bf_error_analysis_list( e, i_list, process_id ) ;
|
bf_error_analysis_list( e, i_list, process_id ) ;
|
||||||
|
|
||||||
if ( e->n_vis_undef_inter == 0 )
|
if( e->n_vis_undef_inter == 0 )
|
||||||
process_rays3( e, process_id ) ;
|
process_rays3( e, process_id ) ;
|
||||||
else
|
else
|
||||||
/* Some interactions were refined.
|
/* Some interactions were refined.
|
||||||
|
@ -736,7 +736,7 @@ static void process_rays2(Element *e, long process_id)
|
||||||
/* For each interaction, do BF-error-analysis */
|
/* For each interaction, do BF-error-analysis */
|
||||||
bf_error_analysis_list( e, i_list, process_id ) ;
|
bf_error_analysis_list( e, i_list, process_id ) ;
|
||||||
|
|
||||||
if ( e->n_vis_undef_inter == 0 )
|
if( e->n_vis_undef_inter == 0 )
|
||||||
process_rays3( e, process_id ) ;
|
process_rays3( e, process_id ) ;
|
||||||
else
|
else
|
||||||
/* Some interactions were refined.
|
/* Some interactions were refined.
|
||||||
|
@ -755,7 +755,7 @@ static void process_rays3(Element *e, long process_id)
|
||||||
gather_rays( e, process_id ) ;
|
gather_rays( e, process_id ) ;
|
||||||
|
|
||||||
/* Now visit children */
|
/* Now visit children */
|
||||||
if ( ! LEAF_ELEMENT(e) )
|
if( ! LEAF_ELEMENT(e) )
|
||||||
{
|
{
|
||||||
/* Compute radiosity that is pushed to descendents */
|
/* Compute radiosity that is pushed to descendents */
|
||||||
rad_push.r = e->rad_in.r + e->rad_subtree.r ;
|
rad_push.r = e->rad_in.r + e->rad_subtree.r ;
|
||||||
|
@ -822,7 +822,7 @@ static void elem_join_operation(Element *e, Element *ec, long process_id)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
while ( e != 0 )
|
while( e != 0 )
|
||||||
{
|
{
|
||||||
/* Get radiosity of the child and add to my radiosity */
|
/* Get radiosity of the child and add to my radiosity */
|
||||||
LOCK(e->elem_lock->lock);
|
LOCK(e->elem_lock->lock);
|
||||||
|
@ -833,7 +833,7 @@ static void elem_join_operation(Element *e, Element *ec, long process_id)
|
||||||
join_flag = (e->join_counter == 0) ;
|
join_flag = (e->join_counter == 0) ;
|
||||||
UNLOCK(e->elem_lock->lock);
|
UNLOCK(e->elem_lock->lock);
|
||||||
|
|
||||||
if ( join_flag == 0 )
|
if( join_flag == 0 )
|
||||||
/* Other children are not finished. Return. */
|
/* Other children are not finished. Return. */
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
@ -892,7 +892,7 @@ static void gather_rays(Element *elem, long process_id)
|
||||||
|
|
||||||
|
|
||||||
/* Return immediately if there is no interaction */
|
/* Return immediately if there is no interaction */
|
||||||
if ( (inter = elem->interactions) == 0 )
|
if( (inter = elem->interactions) == 0 )
|
||||||
{
|
{
|
||||||
elem->rad_subtree.r = 0.0 ;
|
elem->rad_subtree.r = 0.0 ;
|
||||||
elem->rad_subtree.g = 0.0 ;
|
elem->rad_subtree.g = 0.0 ;
|
||||||
|
@ -907,7 +907,7 @@ static void gather_rays(Element *elem, long process_id)
|
||||||
rad_elem.g = 0.0 ;
|
rad_elem.g = 0.0 ;
|
||||||
rad_elem.b = 0.0 ;
|
rad_elem.b = 0.0 ;
|
||||||
|
|
||||||
while ( inter )
|
while( inter )
|
||||||
{
|
{
|
||||||
/* Be careful !
|
/* Be careful !
|
||||||
Use FF(out) to compute incoming energy */
|
Use FF(out) to compute incoming energy */
|
||||||
|
@ -951,13 +951,13 @@ long element_completely_invisible(Element *e1, Element *e2, long process_id)
|
||||||
/* Check visibility */
|
/* Check visibility */
|
||||||
cc = patch_intersection( &e1->patch->plane_equ,
|
cc = patch_intersection( &e1->patch->plane_equ,
|
||||||
&e2->ev1->p, &e2->ev2->p, &e2->ev3->p, process_id ) ;
|
&e2->ev1->p, &e2->ev2->p, &e2->ev3->p, process_id ) ;
|
||||||
if ( NEGATIVE_SIDE(cc) )
|
if( NEGATIVE_SIDE(cc) )
|
||||||
/* If negative or on the plane, then do nothing */
|
/* If negative or on the plane, then do nothing */
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
|
|
||||||
cc = patch_intersection( &e2->patch->plane_equ,
|
cc = patch_intersection( &e2->patch->plane_equ,
|
||||||
&e1->ev1->p, &e1->ev2->p, &e1->ev3->p, process_id ) ;
|
&e1->ev1->p, &e1->ev2->p, &e1->ev3->p, process_id ) ;
|
||||||
if ( NEGATIVE_SIDE(cc) )
|
if( NEGATIVE_SIDE(cc) )
|
||||||
/* If negative or on the plane, then do nothing */
|
/* If negative or on the plane, then do nothing */
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
|
|
||||||
|
@ -981,7 +981,7 @@ Element *get_element(long process_id)
|
||||||
LOCK(global->free_element_lock);
|
LOCK(global->free_element_lock);
|
||||||
|
|
||||||
/* Test pointer */
|
/* Test pointer */
|
||||||
if ( global->free_element == 0 )
|
if( global->free_element == 0 )
|
||||||
{
|
{
|
||||||
printf( "Fatal: Ran out of element buffer\n" ) ;
|
printf( "Fatal: Ran out of element buffer\n" ) ;
|
||||||
UNLOCK(global->free_element_lock);
|
UNLOCK(global->free_element_lock);
|
||||||
|
@ -1049,7 +1049,7 @@ void init_elemlist(long process_id)
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
/* Initialize Element free list */
|
/* Initialize Element free list */
|
||||||
for ( i = 0 ; i < MAX_ELEMENTS-1 ; i++ )
|
for( i = 0 ; i < MAX_ELEMENTS-1 ; i++ )
|
||||||
{
|
{
|
||||||
global->element_buf[i].center = &global->element_buf[i+1] ;
|
global->element_buf[i].center = &global->element_buf[i+1] ;
|
||||||
/* Initialize lock variable */
|
/* Initialize lock variable */
|
||||||
|
@ -1110,10 +1110,10 @@ void foreach_interaction_in_element(Element *elem, void (*func)(), long arg1, lo
|
||||||
{
|
{
|
||||||
Interaction *inter ;
|
Interaction *inter ;
|
||||||
|
|
||||||
if ( elem == 0 )
|
if( elem == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
for ( inter = elem->interactions ; inter ; inter = inter->next )
|
for( inter = elem->interactions ; inter ; inter = inter->next )
|
||||||
func( elem, inter, arg1, process_id ) ;
|
func( elem, inter, arg1, process_id ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,18 +1147,18 @@ void compute_formfactor(Element *e_src, Element *e_dst, Interaction *inter, long
|
||||||
ff_c1 = compute_diff_disc_formfactor( &pc1_src, e_src, &pc_dst, e_dst, process_id ) ;
|
ff_c1 = compute_diff_disc_formfactor( &pc1_src, e_src, &pc_dst, e_dst, process_id ) ;
|
||||||
ff_c2 = compute_diff_disc_formfactor( &pc2_src, e_src, &pc_dst, e_dst, process_id ) ;
|
ff_c2 = compute_diff_disc_formfactor( &pc2_src, e_src, &pc_dst, e_dst, process_id ) ;
|
||||||
ff_c3 = compute_diff_disc_formfactor( &pc3_src, e_src, &pc_dst, e_dst, process_id ) ;
|
ff_c3 = compute_diff_disc_formfactor( &pc3_src, e_src, &pc_dst, e_dst, process_id ) ;
|
||||||
if ( ff_c < 0 ) ff_c = 0 ;
|
if( ff_c < 0 ) ff_c = 0 ;
|
||||||
if ( ff_c1 < 0 ) ff_c1 = 0 ;
|
if( ff_c1 < 0 ) ff_c1 = 0 ;
|
||||||
if ( ff_c2 < 0 ) ff_c2 = 0 ;
|
if( ff_c2 < 0 ) ff_c2 = 0 ;
|
||||||
if ( ff_c3 < 0 ) ff_c3 = 0 ;
|
if( ff_c3 < 0 ) ff_c3 = 0 ;
|
||||||
ff_avg = (ff_c + ff_c1 + ff_c2 + ff_c3) * (float)0.25 ;
|
ff_avg = (ff_c + ff_c1 + ff_c2 + ff_c3) * (float)0.25 ;
|
||||||
ff_min = ff_max = ff_c ;
|
ff_min = ff_max = ff_c ;
|
||||||
if ( ff_min > ff_c1 ) ff_min = ff_c1 ;
|
if( ff_min > ff_c1 ) ff_min = ff_c1 ;
|
||||||
if ( ff_min > ff_c2 ) ff_min = ff_c2 ;
|
if( ff_min > ff_c2 ) ff_min = ff_c2 ;
|
||||||
if ( ff_min > ff_c3 ) ff_min = ff_c3 ;
|
if( ff_min > ff_c3 ) ff_min = ff_c3 ;
|
||||||
if ( ff_max < ff_c1 ) ff_max = ff_c1 ;
|
if( ff_max < ff_c1 ) ff_max = ff_c1 ;
|
||||||
if ( ff_max < ff_c2 ) ff_max = ff_c2 ;
|
if( ff_max < ff_c2 ) ff_max = ff_c2 ;
|
||||||
if ( ff_max < ff_c3 ) ff_max = ff_c3 ;
|
if( ff_max < ff_c3 ) ff_max = ff_c3 ;
|
||||||
|
|
||||||
/* (2) Compute FF(diff-disc) from the 3 vertices of the source */
|
/* (2) Compute FF(diff-disc) from the 3 vertices of the source */
|
||||||
ff_1 = compute_diff_disc_formfactor( &e_src->ev1->p, e_src,
|
ff_1 = compute_diff_disc_formfactor( &e_src->ev1->p, e_src,
|
||||||
|
@ -1170,26 +1170,26 @@ void compute_formfactor(Element *e_src, Element *e_dst, Interaction *inter, long
|
||||||
|
|
||||||
/* (3) Find FF min and max */
|
/* (3) Find FF min and max */
|
||||||
ff_min = ff_max = ff_c ;
|
ff_min = ff_max = ff_c ;
|
||||||
if ( ff_min > ff_1 ) ff_min = ff_1 ;
|
if( ff_min > ff_1 ) ff_min = ff_1 ;
|
||||||
if ( ff_min > ff_2 ) ff_min = ff_2 ;
|
if( ff_min > ff_2 ) ff_min = ff_2 ;
|
||||||
if ( ff_min > ff_3 ) ff_min = ff_3 ;
|
if( ff_min > ff_3 ) ff_min = ff_3 ;
|
||||||
if ( ff_max < ff_1 ) ff_max = ff_1 ;
|
if( ff_max < ff_1 ) ff_max = ff_1 ;
|
||||||
if ( ff_max < ff_2 ) ff_max = ff_2 ;
|
if( ff_max < ff_2 ) ff_max = ff_2 ;
|
||||||
if ( ff_max < ff_3 ) ff_max = ff_3 ;
|
if( ff_max < ff_3 ) ff_max = ff_3 ;
|
||||||
|
|
||||||
/* (4) Clip FF(diff-disc) if it is negative */
|
/* (4) Clip FF(diff-disc) if it is negative */
|
||||||
if ( ff_avg < 0 )
|
if( ff_avg < 0 )
|
||||||
ff_avg = 0 ;
|
ff_avg = 0 ;
|
||||||
inter->formfactor_out = ff_avg ;
|
inter->formfactor_out = ff_avg ;
|
||||||
|
|
||||||
/* (5) Then find maximum difference from the FF at the center */
|
/* (5) Then find maximum difference from the FF at the center */
|
||||||
ff_err = (ff_max - ff_avg) ;
|
ff_err = (ff_max - ff_avg) ;
|
||||||
if ( ff_err < (ff_avg - ff_min) )
|
if( ff_err < (ff_avg - ff_min) )
|
||||||
ff_err = ff_avg - ff_min ;
|
ff_err = ff_avg - ff_min ;
|
||||||
inter->formfactor_err = ff_err ;
|
inter->formfactor_err = ff_err ;
|
||||||
|
|
||||||
/* (6) Correct visibility if partially visible */
|
/* (6) Correct visibility if partially visible */
|
||||||
if ( (ff_avg < 0) && (inter->visibility == 0) )
|
if( (ff_avg < 0) && (inter->visibility == 0) )
|
||||||
/* All ray missed the visible portion of the elements.
|
/* All ray missed the visible portion of the elements.
|
||||||
Set visibility to a non-zero value manually */
|
Set visibility to a non-zero value manually */
|
||||||
/** inter->visibility = FF_VISIBILITY_ERROR **/ ;
|
/** inter->visibility = FF_VISIBILITY_ERROR **/ ;
|
||||||
|
@ -1244,10 +1244,10 @@ static float compute_diff_disc_formfactor(Vertex *p, Element *e_src, Vertex *p_d
|
||||||
ff_c3= _diff_disc_formfactor( p, e_src, &p_c3, quarter_area,
|
ff_c3= _diff_disc_formfactor( p, e_src, &p_c3, quarter_area,
|
||||||
&e_dst->patch->plane_equ.n, process_id ) ;
|
&e_dst->patch->plane_equ.n, process_id ) ;
|
||||||
|
|
||||||
if ( ff_c < 0 ) ff_c = 0 ;
|
if( ff_c < 0 ) ff_c = 0 ;
|
||||||
if ( ff_c1 < 0 ) ff_c1 = 0 ;
|
if( ff_c1 < 0 ) ff_c1 = 0 ;
|
||||||
if ( ff_c2 < 0 ) ff_c2 = 0 ;
|
if( ff_c2 < 0 ) ff_c2 = 0 ;
|
||||||
if ( ff_c3 < 0 ) ff_c3 = 0 ;
|
if( ff_c3 < 0 ) ff_c3 = 0 ;
|
||||||
|
|
||||||
return( ff_c + ff_c1 + ff_c2 + ff_c3 ) ;
|
return( ff_c + ff_c1 + ff_c2 + ff_c3 ) ;
|
||||||
}
|
}
|
||||||
|
@ -1256,7 +1256,7 @@ static float compute_diff_disc_formfactor(Vertex *p, Element *e_src, Vertex *p_d
|
||||||
void compute_interaction(Element *e_src, Element *e_dst, Interaction *inter, long subdiv, long process_id)
|
void compute_interaction(Element *e_src, Element *e_dst, Interaction *inter, long subdiv, long process_id)
|
||||||
{
|
{
|
||||||
/* (1) Check visibility. */
|
/* (1) Check visibility. */
|
||||||
if ( NO_VISIBILITY_NECESSARY(subdiv) )
|
if( NO_VISIBILITY_NECESSARY(subdiv) )
|
||||||
inter->visibility = 1.0 ;
|
inter->visibility = 1.0 ;
|
||||||
else
|
else
|
||||||
inter->visibility = VISIBILITY_UNDEF ;
|
inter->visibility = VISIBILITY_UNDEF ;
|
||||||
|
@ -1296,7 +1296,7 @@ void delete_interaction(Element *elem, Interaction *prev, Interaction *inter, lo
|
||||||
{
|
{
|
||||||
/* Remove from the list */
|
/* Remove from the list */
|
||||||
LOCK(elem->elem_lock->lock);
|
LOCK(elem->elem_lock->lock);
|
||||||
if ( prev == 0 )
|
if( prev == 0 )
|
||||||
elem->interactions = inter->next ;
|
elem->interactions = inter->next ;
|
||||||
else
|
else
|
||||||
prev->next = inter->next ;
|
prev->next = inter->next ;
|
||||||
|
@ -1323,7 +1323,7 @@ void delete_vis_undef_interaction(Element *elem, Interaction *prev, Interaction
|
||||||
{
|
{
|
||||||
/* Remove from the list */
|
/* Remove from the list */
|
||||||
LOCK(elem->elem_lock->lock);
|
LOCK(elem->elem_lock->lock);
|
||||||
if ( prev == 0 )
|
if( prev == 0 )
|
||||||
elem->vis_undef_inter = inter->next ;
|
elem->vis_undef_inter = inter->next ;
|
||||||
else
|
else
|
||||||
prev->next = inter->next ;
|
prev->next = inter->next ;
|
||||||
|
@ -1349,7 +1349,7 @@ Interaction *get_interaction(long process_id)
|
||||||
LOCK(global->free_interaction_lock);
|
LOCK(global->free_interaction_lock);
|
||||||
|
|
||||||
/* Test pointer */
|
/* Test pointer */
|
||||||
if ( global->free_interaction == 0 )
|
if( global->free_interaction == 0 )
|
||||||
{
|
{
|
||||||
printf( "Fatal: Ran out of interaction buffer\n" ) ;
|
printf( "Fatal: Ran out of interaction buffer\n" ) ;
|
||||||
UNLOCK(global->free_interaction_lock);
|
UNLOCK(global->free_interaction_lock);
|
||||||
|
@ -1402,7 +1402,7 @@ void init_interactionlist(long process_id)
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
/* Initialize Interaction free list */
|
/* Initialize Interaction free list */
|
||||||
for ( i = 0 ; i < MAX_INTERACTIONS-1 ; i++ )
|
for( i = 0 ; i < MAX_INTERACTIONS-1 ; i++ )
|
||||||
global->interaction_buf[i].next = &global->interaction_buf[i+1] ;
|
global->interaction_buf[i].next = &global->interaction_buf[i+1] ;
|
||||||
global->interaction_buf[ MAX_INTERACTIONS-1 ].next = 0 ;
|
global->interaction_buf[ MAX_INTERACTIONS-1 ].next = 0 ;
|
||||||
global->free_interaction = global->interaction_buf ;
|
global->free_interaction = global->interaction_buf ;
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
*
|
*
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
#include "pslib.h"
|
#include "pslib.h"
|
||||||
|
|
||||||
#define SCREEN_WIDTH (6.0*72)
|
#define SCREEN_WIDTH (6.0*72)
|
||||||
|
@ -70,10 +69,10 @@ static double cdet(Matrix *m, long r0, long r1, long r2, long c0, long c1, long
|
||||||
|
|
||||||
long ps_open(char *file)
|
long ps_open(char *file)
|
||||||
{
|
{
|
||||||
if ( (ps_fd = fopen( file, "w" )) == 0 )
|
if( (ps_fd = fopen( file, "w" )) == 0 )
|
||||||
{
|
{
|
||||||
perror( file ) ;
|
perror( file ) ;
|
||||||
return( 0 ) ;
|
return( 0 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print out preamble */
|
/* Print out preamble */
|
||||||
|
@ -97,8 +96,8 @@ long ps_open(char *file)
|
||||||
|
|
||||||
void ps_close()
|
void ps_close()
|
||||||
{
|
{
|
||||||
if ( ps_fd == 0 )
|
if( ps_fd == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
|
||||||
fprintf( ps_fd, "showpage\n" ) ;
|
fprintf( ps_fd, "showpage\n" ) ;
|
||||||
|
@ -118,8 +117,8 @@ void ps_close()
|
||||||
|
|
||||||
void ps_linewidth(float w)
|
void ps_linewidth(float w)
|
||||||
{
|
{
|
||||||
if ( ps_fd == 0 )
|
if( ps_fd == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
fprintf( ps_fd, "%f setlinewidth\n", w ) ;
|
fprintf( ps_fd, "%f setlinewidth\n", w ) ;
|
||||||
}
|
}
|
||||||
|
@ -137,8 +136,8 @@ void ps_line(Vertex *p1, Vertex *p2)
|
||||||
Vertex2 v1, v2 ;
|
Vertex2 v1, v2 ;
|
||||||
float x1, y1, x2, y2 ;
|
float x1, y1, x2, y2 ;
|
||||||
|
|
||||||
if ( ps_fd == 0 )
|
if( ps_fd == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
v1.v[0] = p1->x ; v1.v[1] = p1->y ; v1.v[2] = p1->z ; v1.v[3] = 1.0 ;
|
v1.v[0] = p1->x ; v1.v[1] = p1->y ; v1.v[2] = p1->z ; v1.v[3] = 1.0 ;
|
||||||
v2.v[0] = p2->x ; v2.v[1] = p2->y ; v2.v[2] = p2->z ; v2.v[3] = 1.0 ;
|
v2.v[0] = p2->x ; v2.v[1] = p2->y ; v2.v[2] = p2->z ; v2.v[3] = 1.0 ;
|
||||||
|
@ -167,8 +166,8 @@ void ps_polygonedge(long n, Vertex *p_list)
|
||||||
Vertex2 v ;
|
Vertex2 v ;
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
if ( ps_fd == 0 )
|
if( ps_fd == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Transform */
|
/* Transform */
|
||||||
v.v[0] = p_list[0].x ;
|
v.v[0] = p_list[0].x ;
|
||||||
|
@ -180,18 +179,18 @@ void ps_polygonedge(long n, Vertex *p_list)
|
||||||
dcy = v.v[1] / v.v[3] ;
|
dcy = v.v[1] / v.v[3] ;
|
||||||
fprintf( ps_fd, "newpath\n%f %f moveto\n", dcx, dcy ) ;
|
fprintf( ps_fd, "newpath\n%f %f moveto\n", dcx, dcy ) ;
|
||||||
|
|
||||||
for ( i = 1 ; i < n ; i++ )
|
for( i = 1 ; i < n ; i++ )
|
||||||
{
|
{
|
||||||
/* Transform */
|
/* Transform */
|
||||||
v.v[0] = p_list[i].x ;
|
v.v[0] = p_list[i].x ;
|
||||||
v.v[1] = p_list[i].y ;
|
v.v[1] = p_list[i].y ;
|
||||||
v.v[2] = p_list[i].z ;
|
v.v[2] = p_list[i].z ;
|
||||||
v.v[3] = 1.0 ;
|
v.v[3] = 1.0 ;
|
||||||
gtransform( &v, &v, &trans_mtx ) ;
|
gtransform( &v, &v, &trans_mtx ) ;
|
||||||
dcx = v.v[0] / v.v[3] ;
|
dcx = v.v[0] / v.v[3] ;
|
||||||
dcy = v.v[1] / v.v[3] ;
|
dcy = v.v[1] / v.v[3] ;
|
||||||
|
|
||||||
fprintf( ps_fd, "%f %f lineto\n", dcx, dcy ) ;
|
fprintf( ps_fd, "%f %f lineto\n", dcx, dcy ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( ps_fd, "closepath stroke\n" ) ;
|
fprintf( ps_fd, "closepath stroke\n" ) ;
|
||||||
|
@ -210,8 +209,8 @@ void ps_polygon(long n, Vertex *p_list)
|
||||||
Vertex2 v ;
|
Vertex2 v ;
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
if ( ps_fd == 0 )
|
if( ps_fd == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Transform */
|
/* Transform */
|
||||||
v.v[0] = p_list[0].x ;
|
v.v[0] = p_list[0].x ;
|
||||||
|
@ -223,18 +222,18 @@ void ps_polygon(long n, Vertex *p_list)
|
||||||
dcy = v.v[1] / v.v[3] ;
|
dcy = v.v[1] / v.v[3] ;
|
||||||
fprintf( ps_fd, "newpath\n%f %f moveto\n", dcx, dcy ) ;
|
fprintf( ps_fd, "newpath\n%f %f moveto\n", dcx, dcy ) ;
|
||||||
|
|
||||||
for ( i = 1 ; i < n ; i++ )
|
for( i = 1 ; i < n ; i++ )
|
||||||
{
|
{
|
||||||
/* Transform */
|
/* Transform */
|
||||||
v.v[0] = p_list[i].x ;
|
v.v[0] = p_list[i].x ;
|
||||||
v.v[1] = p_list[i].y ;
|
v.v[1] = p_list[i].y ;
|
||||||
v.v[2] = p_list[i].z ;
|
v.v[2] = p_list[i].z ;
|
||||||
v.v[3] = 1.0 ;
|
v.v[3] = 1.0 ;
|
||||||
gtransform( &v, &v, &trans_mtx ) ;
|
gtransform( &v, &v, &trans_mtx ) ;
|
||||||
dcx = v.v[0] / v.v[3] ;
|
dcx = v.v[0] / v.v[3] ;
|
||||||
dcy = v.v[1] / v.v[3] ;
|
dcy = v.v[1] / v.v[3] ;
|
||||||
|
|
||||||
fprintf( ps_fd, "%f %f lineto\n", dcx, dcy ) ;
|
fprintf( ps_fd, "%f %f lineto\n", dcx, dcy ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf( ps_fd, "closepath fill\n" ) ;
|
fprintf( ps_fd, "closepath fill\n" ) ;
|
||||||
|
@ -254,8 +253,8 @@ void ps_spolygon(long n, Vertex *p_list, Rgb *c_list)
|
||||||
long i ;
|
long i ;
|
||||||
float gray_scale ;
|
float gray_scale ;
|
||||||
|
|
||||||
if ( ps_fd == 0 )
|
if( ps_fd == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Transform */
|
/* Transform */
|
||||||
v.v[0] = p_list[0].x ;
|
v.v[0] = p_list[0].x ;
|
||||||
|
@ -267,25 +266,25 @@ void ps_spolygon(long n, Vertex *p_list, Rgb *c_list)
|
||||||
dcy = v.v[1] / v.v[3] ;
|
dcy = v.v[1] / v.v[3] ;
|
||||||
fprintf( ps_fd, "newpath\n%f %f moveto\n", dcx, dcy ) ;
|
fprintf( ps_fd, "newpath\n%f %f moveto\n", dcx, dcy ) ;
|
||||||
|
|
||||||
for ( i = 1 ; i < n ; i++ )
|
for( i = 1 ; i < n ; i++ )
|
||||||
{
|
{
|
||||||
/* Transform */
|
/* Transform */
|
||||||
v.v[0] = p_list[i].x ;
|
v.v[0] = p_list[i].x ;
|
||||||
v.v[1] = p_list[i].y ;
|
v.v[1] = p_list[i].y ;
|
||||||
v.v[2] = p_list[i].z ;
|
v.v[2] = p_list[i].z ;
|
||||||
v.v[3] = 1.0 ;
|
v.v[3] = 1.0 ;
|
||||||
gtransform( &v, &v, &trans_mtx ) ;
|
gtransform( &v, &v, &trans_mtx ) ;
|
||||||
dcx = v.v[0] / v.v[3] ;
|
dcx = v.v[0] / v.v[3] ;
|
||||||
dcy = v.v[1] / v.v[3] ;
|
dcy = v.v[1] / v.v[3] ;
|
||||||
|
|
||||||
fprintf( ps_fd, "%f %f lineto\n", dcx, dcy ) ;
|
fprintf( ps_fd, "%f %f lineto\n", dcx, dcy ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
gray_scale = c_list[0].g ;
|
gray_scale = c_list[0].g ;
|
||||||
if ( gray_scale > 1.0 )
|
if( gray_scale > 1.0 )
|
||||||
gray_scale = 1.0 ;
|
gray_scale = 1.0 ;
|
||||||
else if ( gray_scale < 0.0 )
|
else if( gray_scale < 0.0 )
|
||||||
gray_scale = 0.0 ;
|
gray_scale = 0.0 ;
|
||||||
|
|
||||||
fprintf( ps_fd, "closepath %f setgray fill\n", gray_scale ) ;
|
fprintf( ps_fd, "closepath %f setgray fill\n", gray_scale ) ;
|
||||||
}
|
}
|
||||||
|
@ -356,17 +355,17 @@ static void setup_transformation()
|
||||||
|
|
||||||
/* Window-Viewport */
|
/* Window-Viewport */
|
||||||
gscale_matrix( POST_CAT, &trans_mtx,
|
gscale_matrix( POST_CAT, &trans_mtx,
|
||||||
(float)SCREEN_WIDTH / (clip_right - clip_left),
|
(float)SCREEN_WIDTH / (clip_right - clip_left),
|
||||||
(float)SCREEN_HEIGHT / (clip_top - clip_bottom),
|
(float)SCREEN_HEIGHT / (clip_top - clip_bottom),
|
||||||
(float)SCREEN_DEPTH / (cf_z - cb_z) ) ;
|
(float)SCREEN_DEPTH / (cf_z - cb_z) ) ;
|
||||||
|
|
||||||
gtranslate_matrix( POST_CAT, &trans_mtx,
|
gtranslate_matrix( POST_CAT, &trans_mtx,
|
||||||
-(float)SCREEN_WIDTH * clip_left / (clip_right - clip_left),
|
-(float)SCREEN_WIDTH * clip_left / (clip_right - clip_left),
|
||||||
-(float)SCREEN_HEIGHT* clip_top / (clip_bottom - clip_top),
|
-(float)SCREEN_HEIGHT* clip_top / (clip_bottom - clip_top),
|
||||||
-(float)SCREEN_DEPTH * cb_z / (cf_z - cb_z) ) ;
|
-(float)SCREEN_DEPTH * cb_z / (cf_z - cb_z) ) ;
|
||||||
|
|
||||||
gtranslate_matrix( POST_CAT, &trans_mtx,
|
gtranslate_matrix( POST_CAT, &trans_mtx,
|
||||||
(float)(1.0*72), (float)(0.5*72), 0 ) ;
|
(float)(1.0*72), (float)(0.5*72), 0 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -414,13 +413,13 @@ static void gset_unit_matrix(Matrix *mtx)
|
||||||
long row, col ;
|
long row, col ;
|
||||||
|
|
||||||
/* Clear the matrix */
|
/* Clear the matrix */
|
||||||
for ( row = 0 ; row < 4 ; row++ )
|
for( row = 0 ; row < 4 ; row++ )
|
||||||
for ( col = 0 ; col < 4 ; col++ )
|
for( col = 0 ; col < 4 ; col++ )
|
||||||
mtx->m[row][col] = 0.0 ;
|
mtx->m[row][col] = 0.0 ;
|
||||||
|
|
||||||
/* Set 1.0s along diagonal line */
|
/* Set 1.0s along diagonal line */
|
||||||
for ( row = 0 ; row < 4 ; row++ )
|
for( row = 0 ; row < 4 ; row++ )
|
||||||
mtx->m[row][row] = 1.0 ;
|
mtx->m[row][row] = 1.0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -444,21 +443,21 @@ static void gconcatenate_matrix(long precat, Matrix *m1, Matrix *m2)
|
||||||
|
|
||||||
/* Swap pointer according to the concatenation mode */
|
/* Swap pointer according to the concatenation mode */
|
||||||
dest = m1 ;
|
dest = m1 ;
|
||||||
if ( precat == 1 )
|
if( precat == 1 )
|
||||||
{
|
{
|
||||||
m1 = m2 ;
|
m1 = m2 ;
|
||||||
m2 = dest ;
|
m2 = dest ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* concatenate it */
|
/* concatenate it */
|
||||||
for ( row = 0 ; row < 4 ; row++ )
|
for( row = 0 ; row < 4 ; row++ )
|
||||||
for ( col = 0 ; col < 4 ; col++ )
|
for( col = 0 ; col < 4 ; col++ )
|
||||||
{
|
{
|
||||||
temp.m[row][col] = 0.0 ;
|
temp.m[row][col] = 0.0 ;
|
||||||
for ( scan = 0 ; scan < 4 ; scan++ )
|
for( scan = 0 ; scan < 4 ; scan++ )
|
||||||
temp.m[row][col] +=
|
temp.m[row][col] +=
|
||||||
m1->m[row][scan] * m2->m[scan][col];
|
m1->m[row][scan] * m2->m[scan][col];
|
||||||
}
|
}
|
||||||
|
|
||||||
*dest = temp ;
|
*dest = temp ;
|
||||||
}
|
}
|
||||||
|
@ -660,14 +659,14 @@ static double det(Matrix *m)
|
||||||
|
|
||||||
/* Expand with respect to column 4 */
|
/* Expand with respect to column 4 */
|
||||||
det_sum = 0.0 ;
|
det_sum = 0.0 ;
|
||||||
if ( m->m[0][3] != 0.0 )
|
if( m->m[0][3] != 0.0 )
|
||||||
det_sum -= m->m[0][3] * cdet( m, 1, 2, 3, 0, 1, 2 ) ;
|
det_sum -= m->m[0][3] * cdet( m, 1, 2, 3, 0, 1, 2 ) ;
|
||||||
if ( m->m[1][3] != 0.0 )
|
if( m->m[1][3] != 0.0 )
|
||||||
det_sum += m->m[1][3] * cdet( m, 0, 2, 3, 0, 1, 2 ) ;
|
det_sum += m->m[1][3] * cdet( m, 0, 2, 3, 0, 1, 2 ) ;
|
||||||
if ( m->m[2][3] != 0.0 )
|
if( m->m[2][3] != 0.0 )
|
||||||
det_sum -= m->m[2][3] * cdet( m, 0, 1, 3, 0, 1, 2 ) ;
|
det_sum -= m->m[2][3] * cdet( m, 0, 1, 3, 0, 1, 2 ) ;
|
||||||
if ( m->m[3][3] != 0.0 )
|
if( m->m[3][3] != 0.0 )
|
||||||
det_sum += m->m[3][3] * cdet( m, 0, 1, 2, 0, 1, 2 ) ;
|
det_sum += m->m[3][3] * cdet( m, 0, 1, 2, 0, 1, 2 ) ;
|
||||||
|
|
||||||
return( det_sum ) ;
|
return( det_sum ) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float v[4] ; /* x, y, z, and w */
|
float v[4] ; /* x, y, z, and w */
|
||||||
} Vertex2;
|
} Vertex2;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float m[4][4] ; /* m[row][column], row vector assumed */
|
float m[4][4] ; /* m[row][column], row vector assumed */
|
||||||
} Matrix;
|
} Matrix;
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
*
|
*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ void init_modeling_tasks(long process_id)
|
||||||
extern ModelDataBase room_model[] ;
|
extern ModelDataBase room_model[] ;
|
||||||
extern ModelDataBase largeroom_model[] ;
|
extern ModelDataBase largeroom_model[] ;
|
||||||
|
|
||||||
if ( ! check_task_counter() )
|
if( ! check_task_counter() )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
switch( model_selector )
|
switch( model_selector )
|
||||||
|
@ -161,7 +161,7 @@ static void init_room_model_tasks(ModelDataBase *model, long process_id)
|
||||||
{
|
{
|
||||||
ModelDataBase *pm ;
|
ModelDataBase *pm ;
|
||||||
|
|
||||||
for ( pm = model ; pm->type != MODEL_NULL ; pm++ )
|
for( pm = model ; pm->type != MODEL_NULL ; pm++ )
|
||||||
create_modeling_task( &pm->model, pm->type, process_id ) ;
|
create_modeling_task( &pm->model, pm->type, process_id ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
*
|
*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
|
@ -60,18 +60,18 @@ void foreach_patch_in_bsp(void (*func)(), long arg1, long process_id)
|
||||||
|
|
||||||
static void _foreach_patch(Patch *node, void (*func)(), long arg1, long process_id)
|
static void _foreach_patch(Patch *node, void (*func)(), long arg1, long process_id)
|
||||||
{
|
{
|
||||||
if ( node == 0 )
|
if( node == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Process subtree(-) */
|
/* Process subtree(-) */
|
||||||
if ( node->bsp_negative )
|
if( node->bsp_negative )
|
||||||
_foreach_patch( node->bsp_negative, func, arg1, process_id ) ;
|
_foreach_patch( node->bsp_negative, func, arg1, process_id ) ;
|
||||||
|
|
||||||
/* Apply function to this node */
|
/* Apply function to this node */
|
||||||
func( node, arg1, process_id ) ;
|
func( node, arg1, process_id ) ;
|
||||||
|
|
||||||
/* Process subtree(+) */
|
/* Process subtree(+) */
|
||||||
if ( node->bsp_positive )
|
if( node->bsp_positive )
|
||||||
_foreach_patch( node->bsp_positive, func, arg1, process_id ) ;
|
_foreach_patch( node->bsp_positive, func, arg1, process_id ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,38 +99,38 @@ static void _foreach_d_s_patch(Vertex *svec, Patch *node, void (*func)(), long a
|
||||||
{
|
{
|
||||||
float sign ;
|
float sign ;
|
||||||
|
|
||||||
if ( node == 0 )
|
if( node == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Compute inner product */
|
/* Compute inner product */
|
||||||
sign = inner_product( svec, &node->plane_equ.n ) ;
|
sign = inner_product( svec, &node->plane_equ.n ) ;
|
||||||
|
|
||||||
if ( sign >= 0.0 )
|
if( sign >= 0.0 )
|
||||||
{
|
{
|
||||||
/* The vector is approaching from the negative side of the patch */
|
/* The vector is approaching from the negative side of the patch */
|
||||||
|
|
||||||
/* Process subtree(-) */
|
/* Process subtree(-) */
|
||||||
if ( node->bsp_negative )
|
if( node->bsp_negative )
|
||||||
_foreach_d_s_patch( svec, node->bsp_negative, func, arg1, process_id ) ;
|
_foreach_d_s_patch( svec, node->bsp_negative, func, arg1, process_id ) ;
|
||||||
|
|
||||||
/* Apply function to this node */
|
/* Apply function to this node */
|
||||||
func( node, arg1, process_id ) ;
|
func( node, arg1, process_id ) ;
|
||||||
|
|
||||||
/* Process subtree(+) */
|
/* Process subtree(+) */
|
||||||
if ( node->bsp_positive )
|
if( node->bsp_positive )
|
||||||
_foreach_d_s_patch( svec, node->bsp_positive, func, arg1, process_id ) ;
|
_foreach_d_s_patch( svec, node->bsp_positive, func, arg1, process_id ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Process subtree(+) */
|
/* Process subtree(+) */
|
||||||
if ( node->bsp_positive )
|
if( node->bsp_positive )
|
||||||
_foreach_d_s_patch( svec, node->bsp_positive, func, arg1, process_id ) ;
|
_foreach_d_s_patch( svec, node->bsp_positive, func, arg1, process_id ) ;
|
||||||
|
|
||||||
/* Apply function to this node */
|
/* Apply function to this node */
|
||||||
func( node, arg1, process_id ) ;
|
func( node, arg1, process_id ) ;
|
||||||
|
|
||||||
/* Process subtree(-) */
|
/* Process subtree(-) */
|
||||||
if ( node->bsp_negative )
|
if( node->bsp_negative )
|
||||||
_foreach_d_s_patch( svec, node->bsp_negative, func, arg1, process_id ) ;
|
_foreach_d_s_patch( svec, node->bsp_negative, func, arg1, process_id ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,9 +155,9 @@ void define_patch(Patch *patch, Patch *root, long process_id)
|
||||||
LOCK(global->bsp_tree_lock);
|
LOCK(global->bsp_tree_lock);
|
||||||
|
|
||||||
/* If this is the first patch, link directly */
|
/* If this is the first patch, link directly */
|
||||||
if ( parent == 0 )
|
if( parent == 0 )
|
||||||
{
|
{
|
||||||
if ( global->bsp_root == 0 )
|
if( global->bsp_root == 0 )
|
||||||
{
|
{
|
||||||
/* This is really the first patch */
|
/* This is really the first patch */
|
||||||
global->bsp_root = patch ;
|
global->bsp_root = patch ;
|
||||||
|
@ -176,16 +176,16 @@ void define_patch(Patch *patch, Patch *root, long process_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Traverse the BSP tree and get to the leaf node */
|
/* Traverse the BSP tree and get to the leaf node */
|
||||||
while ( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
/* Check the sign */
|
/* Check the sign */
|
||||||
xing_code = patch_intersection( &parent->plane_equ, &patch->p1,
|
xing_code = patch_intersection( &parent->plane_equ, &patch->p1,
|
||||||
&patch->p2, &patch->p3, process_id ) ;
|
&patch->p2, &patch->p3, process_id ) ;
|
||||||
|
|
||||||
/* Traverse down the tree according to the sign */
|
/* Traverse down the tree according to the sign */
|
||||||
if ( POSITIVE_SIDE( xing_code ) )
|
if( POSITIVE_SIDE( xing_code ) )
|
||||||
{
|
{
|
||||||
if ( parent->bsp_positive == 0 )
|
if( parent->bsp_positive == 0 )
|
||||||
{
|
{
|
||||||
/* Insert the patch */
|
/* Insert the patch */
|
||||||
parent->bsp_positive = patch ;
|
parent->bsp_positive = patch ;
|
||||||
|
@ -200,9 +200,9 @@ void define_patch(Patch *patch, Patch *root, long process_id)
|
||||||
/* Traverse down to the subtree(+) */
|
/* Traverse down to the subtree(+) */
|
||||||
parent = parent->bsp_positive ;
|
parent = parent->bsp_positive ;
|
||||||
}
|
}
|
||||||
else if ( NEGATIVE_SIDE( xing_code ) )
|
else if( NEGATIVE_SIDE( xing_code ) )
|
||||||
{
|
{
|
||||||
if ( parent->bsp_negative == 0 )
|
if( parent->bsp_negative == 0 )
|
||||||
{
|
{
|
||||||
/* Insert the patch */
|
/* Insert the patch */
|
||||||
parent->bsp_negative = patch ;
|
parent->bsp_negative = patch ;
|
||||||
|
@ -255,23 +255,23 @@ void split_patch(Patch *patch, Patch *node, long xing_code, long process_id)
|
||||||
c3 = P3_CODE( xing_code ) ;
|
c3 = P3_CODE( xing_code ) ;
|
||||||
|
|
||||||
/* Classify intersection type */
|
/* Classify intersection type */
|
||||||
if ( c1 == c2 )
|
if( c1 == c2 )
|
||||||
/* P3 is on the oposite side */
|
/* P3 is on the oposite side */
|
||||||
split_into_3( patch, patch->ev3, patch->ev1, patch->ev2,
|
split_into_3( patch, patch->ev3, patch->ev1, patch->ev2,
|
||||||
patch->e31, patch->e12, patch->e23, node, process_id) ;
|
patch->e31, patch->e12, patch->e23, node, process_id) ;
|
||||||
else if ( c1 == c3 )
|
else if( c1 == c3 )
|
||||||
/* P2 is on the oposite side */
|
/* P2 is on the oposite side */
|
||||||
split_into_3( patch, patch->ev2, patch->ev3, patch->ev1,
|
split_into_3( patch, patch->ev2, patch->ev3, patch->ev1,
|
||||||
patch->e23, patch->e31, patch->e12, node, process_id ) ;
|
patch->e23, patch->e31, patch->e12, node, process_id ) ;
|
||||||
else if ( c2 == c3 )
|
else if( c2 == c3 )
|
||||||
/* P1 is on the oposite side */
|
/* P1 is on the oposite side */
|
||||||
split_into_3( patch, patch->ev1, patch->ev2, patch->ev3,
|
split_into_3( patch, patch->ev1, patch->ev2, patch->ev3,
|
||||||
patch->e12, patch->e23, patch->e31, node, process_id ) ;
|
patch->e12, patch->e23, patch->e31, node, process_id ) ;
|
||||||
else if ( c1 == POINT_ON_PLANE )
|
else if( c1 == POINT_ON_PLANE )
|
||||||
/* P1 is on the plane. P2 and P3 are on the oposite side */
|
/* P1 is on the plane. P2 and P3 are on the oposite side */
|
||||||
split_into_2( patch, patch->ev1, patch->ev2, patch->ev3,
|
split_into_2( patch, patch->ev1, patch->ev2, patch->ev3,
|
||||||
patch->e12, patch->e23, patch->e31, node, process_id ) ;
|
patch->e12, patch->e23, patch->e31, node, process_id ) ;
|
||||||
else if ( c2 == POINT_ON_PLANE )
|
else if( c2 == POINT_ON_PLANE )
|
||||||
/* P2 is on the plane. P3 and P1 are on the oposite side */
|
/* P2 is on the plane. P3 and P1 are on the oposite side */
|
||||||
split_into_2( patch, patch->ev2, patch->ev3, patch->ev1,
|
split_into_2( patch, patch->ev2, patch->ev3, patch->ev1,
|
||||||
patch->e23, patch->e31, patch->e12, node, process_id ) ;
|
patch->e23, patch->e31, patch->e12, node, process_id ) ;
|
||||||
|
@ -302,14 +302,14 @@ static void split_into_3(Patch *patch, ElemVertex *ev1, ElemVertex *ev2, ElemVer
|
||||||
/* NOTE: Length of P1-P2 and P1-P3 are at least 2*F_COPLANAR.
|
/* NOTE: Length of P1-P2 and P1-P3 are at least 2*F_COPLANAR.
|
||||||
So, no check is necessary before division */
|
So, no check is necessary before division */
|
||||||
u2 = h1 / (h1 - h2) ;
|
u2 = h1 / (h1 - h2) ;
|
||||||
if ( (rev_e12 = EDGE_REVERSE( e12, ev1, ev2 )) )
|
if( (rev_e12 = EDGE_REVERSE( e12, ev1, ev2 )) )
|
||||||
subdivide_edge( e12, u2, process_id ) ;
|
subdivide_edge( e12, u2, process_id ) ;
|
||||||
else
|
else
|
||||||
subdivide_edge( e12, (float)1.0 - u2, process_id ) ;
|
subdivide_edge( e12, (float)1.0 - u2, process_id ) ;
|
||||||
ev_a = e12->ea->pb ;
|
ev_a = e12->ea->pb ;
|
||||||
|
|
||||||
u3 = h1 / (h1 - h3) ;
|
u3 = h1 / (h1 - h3) ;
|
||||||
if ( (rev_e31 = EDGE_REVERSE( e31, ev3, ev1 )) )
|
if( (rev_e31 = EDGE_REVERSE( e31, ev3, ev1 )) )
|
||||||
subdivide_edge( e31, (float)1.0 - u3, process_id ) ;
|
subdivide_edge( e31, (float)1.0 - u3, process_id ) ;
|
||||||
else
|
else
|
||||||
subdivide_edge( e31, u3, process_id ) ;
|
subdivide_edge( e31, u3, process_id ) ;
|
||||||
|
@ -391,7 +391,7 @@ static void split_into_2(Patch *patch, ElemVertex *ev1, ElemVertex *ev2, ElemVer
|
||||||
/* NOTE: Length of P2-P3 is at least 2*F_COPLANAR.
|
/* NOTE: Length of P2-P3 is at least 2*F_COPLANAR.
|
||||||
So, no check is necessary before division */
|
So, no check is necessary before division */
|
||||||
u2 = h2 / (h2 - h3) ;
|
u2 = h2 / (h2 - h3) ;
|
||||||
if ( (rev_e23 = EDGE_REVERSE( e23, ev2, ev3 )) )
|
if( (rev_e23 = EDGE_REVERSE( e23, ev2, ev3 )) )
|
||||||
subdivide_edge( e23, u2, process_id ) ;
|
subdivide_edge( e23, u2, process_id ) ;
|
||||||
else
|
else
|
||||||
subdivide_edge( e23, (float)1.0 - u2, process_id ) ;
|
subdivide_edge( e23, (float)1.0 - u2, process_id ) ;
|
||||||
|
@ -488,20 +488,20 @@ void refine_newpatch(Patch *patch, long newpatch, long process_id)
|
||||||
Patch *new_patch = (Patch *)newpatch ;
|
Patch *new_patch = (Patch *)newpatch ;
|
||||||
|
|
||||||
/* Check sequence number */
|
/* Check sequence number */
|
||||||
if ( patch->seq_no >= new_patch->seq_no )
|
if( patch->seq_no >= new_patch->seq_no )
|
||||||
/* Racing condition due to multiprocessing */
|
/* Racing condition due to multiprocessing */
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Check visibility */
|
/* Check visibility */
|
||||||
cc = patch_intersection( &patch->plane_equ,
|
cc = patch_intersection( &patch->plane_equ,
|
||||||
&new_patch->p1, &new_patch->p2, &new_patch->p3, process_id ) ;
|
&new_patch->p1, &new_patch->p2, &new_patch->p3, process_id ) ;
|
||||||
if ( NEGATIVE_SIDE(cc) )
|
if( NEGATIVE_SIDE(cc) )
|
||||||
/* If negative or on the plane, then do nothing */
|
/* If negative or on the plane, then do nothing */
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
cc = patch_intersection( &new_patch->plane_equ,
|
cc = patch_intersection( &new_patch->plane_equ,
|
||||||
&patch->p1, &patch->p2, &patch->p3, process_id ) ;
|
&patch->p1, &patch->p2, &patch->p3, process_id ) ;
|
||||||
if ( NEGATIVE_SIDE(cc) )
|
if( NEGATIVE_SIDE(cc) )
|
||||||
/* If negative or on the plane, then do nothing */
|
/* If negative or on the plane, then do nothing */
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ Patch *get_patch(long process_id)
|
||||||
LOCK(global->free_patch_lock);
|
LOCK(global->free_patch_lock);
|
||||||
|
|
||||||
/* Test pointer */
|
/* Test pointer */
|
||||||
if ( global->free_patch == 0 )
|
if( global->free_patch == 0 )
|
||||||
{
|
{
|
||||||
printf( "Fatal: Ran out of patch buffer\n" ) ;
|
printf( "Fatal: Ran out of patch buffer\n" ) ;
|
||||||
UNLOCK(global->free_patch_lock);
|
UNLOCK(global->free_patch_lock);
|
||||||
|
@ -566,7 +566,7 @@ void init_patchlist(long process_id)
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
/* Initialize Patch free list */
|
/* Initialize Patch free list */
|
||||||
for ( i = 0 ; i < MAX_PATCHES-1 ; i++ )
|
for( i = 0 ; i < MAX_PATCHES-1 ; i++ )
|
||||||
{
|
{
|
||||||
global->patch_buf[i].bsp_positive = &global->patch_buf[i+1] ;
|
global->patch_buf[i].bsp_positive = &global->patch_buf[i+1] ;
|
||||||
global->patch_buf[i].seq_no = i ;
|
global->patch_buf[i].seq_no = i ;
|
||||||
|
@ -581,7 +581,7 @@ void init_patchlist(long process_id)
|
||||||
|
|
||||||
#if PATCH_ASSIGNMENT == PATCH_ASSIGNMENT_COSTBASED
|
#if PATCH_ASSIGNMENT == PATCH_ASSIGNMENT_COSTBASED
|
||||||
/* Initialize Patch_Cost structure */
|
/* Initialize Patch_Cost structure */
|
||||||
for ( i = 0 ; i < MAX_PATCHES ; i++ )
|
for( i = 0 ; i < MAX_PATCHES ; i++ )
|
||||||
{
|
{
|
||||||
global->patch_cost[i].patch = &global->patch_buf[i] ;
|
global->patch_cost[i].patch = &global->patch_buf[i] ;
|
||||||
global->patch_cost[i].cost_lock
|
global->patch_cost[i].cost_lock
|
||||||
|
@ -710,9 +710,9 @@ long point_intersection(PlaneEqu *plane, Vertex *point, long process_id)
|
||||||
long result_code = 0 ;
|
long result_code = 0 ;
|
||||||
|
|
||||||
/* Compare H(x,y,z) against allowance */
|
/* Compare H(x,y,z) against allowance */
|
||||||
if ( (h = plane_equ( plane, point, process_id )) < -F_COPLANAR )
|
if( (h = plane_equ( plane, point, process_id )) < -F_COPLANAR )
|
||||||
result_code |= POINT_NEGATIVE_SIDE ;
|
result_code |= POINT_NEGATIVE_SIDE ;
|
||||||
if ( h > F_COPLANAR )
|
if( h > F_COPLANAR )
|
||||||
result_code |= POINT_POSITIVE_SIDE ;
|
result_code |= POINT_POSITIVE_SIDE ;
|
||||||
|
|
||||||
return( result_code ) ;
|
return( result_code ) ;
|
||||||
|
|
|
@ -22,15 +22,12 @@
|
||||||
*
|
*
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
#include <cstring>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(SGI_GL)
|
#if defined(SGI_GL)
|
||||||
#include <gl.h>
|
#include <gl.h>
|
||||||
|
|
||||||
#if defined(GL_NASA)
|
#if defined(GL_NASA)
|
||||||
#include <panel.h>
|
#include <panel.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -160,7 +157,7 @@ int main(int argc, char *argv[])
|
||||||
choices[2].init_value = model_selector ;
|
choices[2].init_value = model_selector ;
|
||||||
|
|
||||||
/* Initialize graphic device */
|
/* Initialize graphic device */
|
||||||
if ( batch_mode == 0 )
|
if( batch_mode == 0 )
|
||||||
{
|
{
|
||||||
g_init(argc, argv) ;
|
g_init(argc, argv) ;
|
||||||
setup_view( DFLT_VIEW_ROT_X, DFLT_VIEW_ROT_Y,
|
setup_view( DFLT_VIEW_ROT_X, DFLT_VIEW_ROT_Y,
|
||||||
|
@ -172,7 +169,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Allocate global shared memory and initialize */
|
/* Allocate global shared memory and initialize */
|
||||||
global = (Global *) G_MALLOC(sizeof(Global)) ;
|
global = (Global *) G_MALLOC(sizeof(Global)) ;
|
||||||
if ( global == 0 )
|
if( global == 0 )
|
||||||
{
|
{
|
||||||
printf( "Can't allocate memory\n" ) ;
|
printf( "Can't allocate memory\n" ) ;
|
||||||
exit(1) ;
|
exit(1) ;
|
||||||
|
@ -208,7 +205,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( batch_mode )
|
if( batch_mode )
|
||||||
{
|
{
|
||||||
/* In batch mode, create child processes and start immediately */
|
/* In batch mode, create child processes and start immediately */
|
||||||
|
|
||||||
|
@ -216,7 +213,7 @@ int main(int argc, char *argv[])
|
||||||
CLOCK( time_rad_start );
|
CLOCK( time_rad_start );
|
||||||
|
|
||||||
global->index = 0;
|
global->index = 0;
|
||||||
for ( i = 0 ; i < n_processors ; i++ )
|
for( i = 0 ; i < n_processors ; i++ )
|
||||||
{
|
{
|
||||||
taskqueue_id[i] = assign_taskq(0) ;
|
taskqueue_id[i] = assign_taskq(0) ;
|
||||||
}
|
}
|
||||||
|
@ -283,16 +280,9 @@ int main(int argc, char *argv[])
|
||||||
min_vertex_time = timing[i]->vertex_time;
|
min_vertex_time = timing[i]->vertex_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n\n%8s%20lu%20lu%12lu%12lu\n","Max", max_rad_time, max_refine_time,
|
printf("\n\n%8s%20lu%20lu%12lu%12lu\n","Max", max_rad_time, max_refine_time, max_wait_time, max_vertex_time);
|
||||||
max_wait_time, max_vertex_time);
|
printf("\n%8s%20lu%20lu%12lu%12lu\n","Min", min_rad_time, min_refine_time, min_wait_time, min_vertex_time);
|
||||||
printf("\n%8s%20lu%20lu%12lu%12lu\n","Min", min_rad_time, min_refine_time,
|
printf("\n%8s%20lu%20lu%12lu%12lu\n","Avg", (long) (((double) total_rad_time) / ((double) (1.0 * n_processors))), (long) (((double) total_refine_time) / ((double) (1.0 * n_processors))), (long) (((double) total_wait_time) / ((double) (1.0 * n_processors))), (long) (((double) total_vertex_time) / ((double) (1.0 * n_processors))));
|
||||||
min_wait_time, min_vertex_time);
|
|
||||||
printf("\n%8s%20lu%20lu%12lu%12lu\n","Avg",
|
|
||||||
(long) (((double) total_rad_time) /
|
|
||||||
((double) (1.0 * n_processors))),
|
|
||||||
(long) (((double) total_refine_time) / ((double) (1.0 * n_processors))),
|
|
||||||
(long) (((double) total_wait_time) / ((double) (1.0 * n_processors))),
|
|
||||||
(long) (((double) total_vertex_time) / ((double) (1.0 * n_processors))));
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -354,9 +344,9 @@ void start_radiosity(long val)
|
||||||
val = g_get_choice_val( ap, &choices[0] ) ;
|
val = g_get_choice_val( ap, &choices[0] ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( val == CHOICE_RAD_RUN )
|
if( val == CHOICE_RAD_RUN )
|
||||||
{
|
{
|
||||||
if ( state == -1 )
|
if( state == -1 )
|
||||||
{
|
{
|
||||||
printf( "Please reset first\007\n" ) ;
|
printf( "Please reset first\007\n" ) ;
|
||||||
return ;
|
return ;
|
||||||
|
@ -456,9 +446,9 @@ void start_radiosity(long val)
|
||||||
state = -1 ;
|
state = -1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( val == CHOICE_RAD_STEP )
|
else if( val == CHOICE_RAD_STEP )
|
||||||
{
|
{
|
||||||
if ( state == -1 )
|
if( state == -1 )
|
||||||
{
|
{
|
||||||
printf( "Please reset first\007\n" ) ;
|
printf( "Please reset first\007\n" ) ;
|
||||||
return ;
|
return ;
|
||||||
|
@ -488,7 +478,7 @@ void start_radiosity(long val)
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if ( init_ray_tasks(0) )
|
if( init_ray_tasks(0) )
|
||||||
{
|
{
|
||||||
BARRIER(global->barrier, n_processors);
|
BARRIER(global->barrier, n_processors);
|
||||||
process_tasks(0) ;
|
process_tasks(0) ;
|
||||||
|
@ -512,7 +502,7 @@ void start_radiosity(long val)
|
||||||
disp_mesh_switch, disp_interaction_switch, 0) ;
|
disp_mesh_switch, disp_interaction_switch, 0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( val == CHOICE_RAD_RESET )
|
else if( val == CHOICE_RAD_RESET )
|
||||||
{
|
{
|
||||||
/* Initialize global variables again */
|
/* Initialize global variables again */
|
||||||
init_global(0) ;
|
init_global(0) ;
|
||||||
|
@ -566,11 +556,11 @@ void change_display(long val)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( disp_fill_switch == 0 )
|
if( disp_fill_switch == 0 )
|
||||||
disp_fill_mode = 0 ;
|
disp_fill_mode = 0 ;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( disp_shade_switch == 0 )
|
if( disp_shade_switch == 0 )
|
||||||
disp_fill_mode = 1 ;
|
disp_fill_mode = 1 ;
|
||||||
else
|
else
|
||||||
disp_fill_mode = 2 ;
|
disp_fill_mode = 2 ;
|
||||||
|
@ -753,7 +743,7 @@ void utility_tools(long val)
|
||||||
print_statistics( stdout, 0 ) ;
|
print_statistics( stdout, 0 ) ;
|
||||||
break ;
|
break ;
|
||||||
case CHOICE_UTIL_STAT_FILE:
|
case CHOICE_UTIL_STAT_FILE:
|
||||||
if ( (fd = fopen( "radiosity_stat", "w" )) == 0 )
|
if( (fd = fopen( "radiosity_stat", "w" )) == 0 )
|
||||||
{
|
{
|
||||||
perror( "radiosity_stat" ) ;
|
perror( "radiosity_stat" ) ;
|
||||||
break ;
|
break ;
|
||||||
|
@ -814,7 +804,7 @@ void radiosity()
|
||||||
process_tasks(process_id) ;
|
process_tasks(process_id) ;
|
||||||
|
|
||||||
/* Gather rays & do BF refinement */
|
/* Gather rays & do BF refinement */
|
||||||
while ( init_ray_tasks(process_id) )
|
while( init_ray_tasks(process_id) )
|
||||||
{
|
{
|
||||||
/* Wait till tasks are put in the queue */
|
/* Wait till tasks are put in the queue */
|
||||||
BARRIER(global->barrier, n_processors);
|
BARRIER(global->barrier, n_processors);
|
||||||
|
@ -886,7 +876,7 @@ long init_ray_tasks(long process_id)
|
||||||
|
|
||||||
/* If this is not the first process to initialize, then return */
|
/* If this is not the first process to initialize, then return */
|
||||||
LOCK(global->avg_radiosity_lock);
|
LOCK(global->avg_radiosity_lock);
|
||||||
if ( ! check_task_counter() )
|
if( ! check_task_counter() )
|
||||||
{
|
{
|
||||||
conv = global->converged ;
|
conv = global->converged ;
|
||||||
UNLOCK(global->avg_radiosity_lock);
|
UNLOCK(global->avg_radiosity_lock);
|
||||||
|
@ -909,7 +899,7 @@ long init_ray_tasks(long process_id)
|
||||||
UNLOCK(global->avg_radiosity_lock);
|
UNLOCK(global->avg_radiosity_lock);
|
||||||
|
|
||||||
/* If radiosity converged, then return 0 */
|
/* If radiosity converged, then return 0 */
|
||||||
if ( conv )
|
if( conv )
|
||||||
return( 0 ) ;
|
return( 0 ) ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -918,7 +908,7 @@ long init_ray_tasks(long process_id)
|
||||||
The 'cost_sum' is not locked since no one is processing rays
|
The 'cost_sum' is not locked since no one is processing rays
|
||||||
at this moment */
|
at this moment */
|
||||||
|
|
||||||
for ( crnt_qid = 0 ; crnt_qid < n_taskqueues ; crnt_qid++ )
|
for( crnt_qid = 0 ; crnt_qid < n_taskqueues ; crnt_qid++ )
|
||||||
queue_cost[ crnt_qid ] = 0 ;
|
queue_cost[ crnt_qid ] = 0 ;
|
||||||
|
|
||||||
avg_cost_of_q = global->cost_estimate_sum / n_taskqueues ;
|
avg_cost_of_q = global->cost_estimate_sum / n_taskqueues ;
|
||||||
|
@ -964,29 +954,29 @@ static void _init_ray_tasks_cost2(Patch *p, long layer, long process_id)
|
||||||
pc = &global->patch_cost[ p->seq_no ] ;
|
pc = &global->patch_cost[ p->seq_no ] ;
|
||||||
c_est = pc->cost_estimate ;
|
c_est = pc->cost_estimate ;
|
||||||
|
|
||||||
if ( c_est < 0 )
|
if( c_est < 0 )
|
||||||
/* Already processed */
|
/* Already processed */
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( c_est < avg_cost_of_patch * layer )
|
if( c_est < avg_cost_of_patch * layer )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Find the first available queue */
|
/* Find the first available queue */
|
||||||
min_cost_q = 0 ;
|
min_cost_q = 0 ;
|
||||||
min_cost = queue_cost[ 0 ] ;
|
min_cost = queue_cost[ 0 ] ;
|
||||||
for ( qid = 0 ; qid < n_taskqueues ; qid++ )
|
for( qid = 0 ; qid < n_taskqueues ; qid++ )
|
||||||
{
|
{
|
||||||
if ( (c_est + queue_cost[ qid ]) <= avg_cost_of_q )
|
if( (c_est + queue_cost[ qid ]) <= avg_cost_of_q )
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
if ( min_cost > queue_cost[ qid ] )
|
if( min_cost > queue_cost[ qid ] )
|
||||||
{
|
{
|
||||||
min_cost_q = qid ;
|
min_cost_q = qid ;
|
||||||
min_cost = queue_cost[ qid ] ;
|
min_cost = queue_cost[ qid ] ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( qid >= n_taskqueues )
|
if( qid >= n_taskqueues )
|
||||||
{
|
{
|
||||||
/* All queues are nearly full. Put to min-cost queue */
|
/* All queues are nearly full. Put to min-cost queue */
|
||||||
qid = min_cost_q ;
|
qid = min_cost_q ;
|
||||||
|
@ -1025,7 +1015,7 @@ void init_radavg_tasks(long mode, long process_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* If this is not the first process to initialize, then return */
|
/* If this is not the first process to initialize, then return */
|
||||||
if ( ! check_task_counter() )
|
if( ! check_task_counter() )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
/* Create RadAvg tasks */
|
/* Create RadAvg tasks */
|
||||||
|
@ -1108,36 +1098,36 @@ static void parse_args(int argc, char *argv[])
|
||||||
long cnt ;
|
long cnt ;
|
||||||
|
|
||||||
/* Parse arguments */
|
/* Parse arguments */
|
||||||
for ( cnt = 1 ; cnt < argc ; cnt++ )
|
for( cnt = 1 ; cnt < argc ; cnt++ )
|
||||||
{
|
{
|
||||||
if ( strcmp( argv[cnt], "-p" ) == 0 ) {
|
if( strcmp( argv[cnt], "-p" ) == 0 ) {
|
||||||
sscanf( argv[++cnt], "%ld", &n_processors ) ;
|
sscanf( argv[++cnt], "%ld", &n_processors ) ;
|
||||||
n_taskqueues = n_processors;
|
n_taskqueues = n_processors;
|
||||||
}
|
}
|
||||||
else if ( strcmp( argv[cnt], "-tq" ) == 0 )
|
else if( strcmp( argv[cnt], "-tq" ) == 0 )
|
||||||
sscanf( argv[++cnt], "%ld", &n_tasks_per_queue ) ;
|
sscanf( argv[++cnt], "%ld", &n_tasks_per_queue ) ;
|
||||||
else if ( strcmp( argv[cnt], "-ae" ) == 0 )
|
else if( strcmp( argv[cnt], "-ae" ) == 0 )
|
||||||
sscanf( argv[++cnt], "%f", &Area_epsilon ) ;
|
sscanf( argv[++cnt], "%f", &Area_epsilon ) ;
|
||||||
else if ( strcmp( argv[cnt], "-pr" ) == 0 )
|
else if( strcmp( argv[cnt], "-pr" ) == 0 )
|
||||||
sscanf( argv[++cnt], "%ld", &N_inter_parallel_bf_refine ) ;
|
sscanf( argv[++cnt], "%ld", &N_inter_parallel_bf_refine ) ;
|
||||||
else if ( strcmp( argv[cnt], "-pv" ) == 0 )
|
else if( strcmp( argv[cnt], "-pv" ) == 0 )
|
||||||
sscanf( argv[++cnt], "%ld", &N_visibility_per_task ) ;
|
sscanf( argv[++cnt], "%ld", &N_visibility_per_task ) ;
|
||||||
else if ( strcmp( argv[cnt], "-bf" ) == 0 )
|
else if( strcmp( argv[cnt], "-bf" ) == 0 )
|
||||||
sscanf( argv[++cnt], "%f", &BFepsilon ) ;
|
sscanf( argv[++cnt], "%f", &BFepsilon ) ;
|
||||||
else if ( strcmp( argv[cnt], "-en" ) == 0 )
|
else if( strcmp( argv[cnt], "-en" ) == 0 )
|
||||||
sscanf( argv[++cnt], "%f", &Energy_epsilon ) ;
|
sscanf( argv[++cnt], "%f", &Energy_epsilon ) ;
|
||||||
|
|
||||||
else if ( strcmp( argv[cnt], "-batch" ) == 0 )
|
else if( strcmp( argv[cnt], "-batch" ) == 0 )
|
||||||
batch_mode = 1 ;
|
batch_mode = 1 ;
|
||||||
else if ( strcmp( argv[cnt], "-verbose" ) == 0 )
|
else if( strcmp( argv[cnt], "-verbose" ) == 0 )
|
||||||
verbose_mode = 1 ;
|
verbose_mode = 1 ;
|
||||||
else if ( strcmp( argv[cnt], "-s" ) == 0 )
|
else if( strcmp( argv[cnt], "-s" ) == 0 )
|
||||||
dostats = 1 ;
|
dostats = 1 ;
|
||||||
else if ( strcmp( argv[cnt], "-room" ) == 0 )
|
else if( strcmp( argv[cnt], "-room" ) == 0 )
|
||||||
model_selector = MODEL_ROOM_DATA ;
|
model_selector = MODEL_ROOM_DATA ;
|
||||||
else if ( strcmp( argv[cnt], "-largeroom" ) == 0 )
|
else if( strcmp( argv[cnt], "-largeroom" ) == 0 )
|
||||||
model_selector = MODEL_LARGEROOM_DATA ;
|
model_selector = MODEL_LARGEROOM_DATA ;
|
||||||
else if (( strcmp( argv[cnt], "-help" ) == 0 ) || ( strcmp( argv[cnt], "-h" ) == 0 ) || ( strcmp( argv[cnt], "-H" ) == 0 )) {
|
else if(( strcmp( argv[cnt], "-help" ) == 0 ) || ( strcmp( argv[cnt], "-h" ) == 0 ) || ( strcmp( argv[cnt], "-H" ) == 0 )) {
|
||||||
print_usage() ;
|
print_usage() ;
|
||||||
exit(0) ;
|
exit(0) ;
|
||||||
}
|
}
|
||||||
|
@ -1145,25 +1135,25 @@ static void parse_args(int argc, char *argv[])
|
||||||
|
|
||||||
|
|
||||||
/* Then check the arguments */
|
/* Then check the arguments */
|
||||||
if ( (n_processors < 1) || (MAX_PROCESSORS < n_processors) )
|
if( (n_processors < 1) || (MAX_PROCESSORS < n_processors) )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Bad number of processors: %ld\n",
|
fprintf( stderr, "Bad number of processors: %ld\n",
|
||||||
n_processors ) ;
|
n_processors ) ;
|
||||||
exit(1) ;
|
exit(1) ;
|
||||||
}
|
}
|
||||||
if ( (n_taskqueues < 1) || (MAX_TASKQUEUES < n_taskqueues) )
|
if( (n_taskqueues < 1) || (MAX_TASKQUEUES < n_taskqueues) )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Bad number of task queues: %ld\n",
|
fprintf( stderr, "Bad number of task queues: %ld\n",
|
||||||
n_taskqueues ) ;
|
n_taskqueues ) ;
|
||||||
exit(1) ;
|
exit(1) ;
|
||||||
}
|
}
|
||||||
/* Check epsilon values */
|
/* Check epsilon values */
|
||||||
if ( Area_epsilon < 0.0 )
|
if( Area_epsilon < 0.0 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Area epsilon must be positive\n" ) ;
|
fprintf( stderr, "Area epsilon must be positive\n" ) ;
|
||||||
exit(1) ;
|
exit(1) ;
|
||||||
}
|
}
|
||||||
if ( BFepsilon < 0.0 )
|
if( BFepsilon < 0.0 )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "BFepsilon must be within [0,1]\n" ) ;
|
fprintf( stderr, "BFepsilon must be within [0,1]\n" ) ;
|
||||||
exit(1) ;
|
exit(1) ;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ void print_statistics(FILE *fd, long process_id)
|
||||||
total_match1 = 0 ;
|
total_match1 = 0 ;
|
||||||
total_match0 = 0 ;
|
total_match0 = 0 ;
|
||||||
|
|
||||||
for ( i = 0 ; i < MAX_INTERACTION_PER_ELEMENT ; i++ )
|
for( i = 0 ; i < MAX_INTERACTION_PER_ELEMENT ; i++ )
|
||||||
{
|
{
|
||||||
elem_interaction[i].count = 0 ;
|
elem_interaction[i].count = 0 ;
|
||||||
elem_interaction[i].area = 0 ;
|
elem_interaction[i].area = 0 ;
|
||||||
|
@ -92,21 +92,21 @@ void print_statistics(FILE *fd, long process_id)
|
||||||
fprintf( fd, " Histogram of interactions/elem\n" ) ;
|
fprintf( fd, " Histogram of interactions/elem\n" ) ;
|
||||||
fprintf( fd, "\t Interactions Occurrence\n" ) ;
|
fprintf( fd, "\t Interactions Occurrence\n" ) ;
|
||||||
fprintf( fd, "\t -------------------------------\n" ) ;
|
fprintf( fd, "\t -------------------------------\n" ) ;
|
||||||
if ( many_interaction.count > 0 )
|
if( many_interaction.count > 0 )
|
||||||
{
|
{
|
||||||
fprintf( fd, "\t (Over %d) %ld (%f)\n",
|
fprintf( fd, "\t (Over %d) %ld (%f)\n",
|
||||||
MAX_INTERACTION_PER_ELEMENT,
|
MAX_INTERACTION_PER_ELEMENT,
|
||||||
many_interaction.count,
|
many_interaction.count,
|
||||||
many_interaction.area / many_interaction.count ) ;
|
many_interaction.area / many_interaction.count ) ;
|
||||||
}
|
}
|
||||||
for ( i = MAX_INTERACTION_PER_ELEMENT ;
|
for( i = MAX_INTERACTION_PER_ELEMENT ;
|
||||||
elem_interaction[i].count == 0 ; i-- ) ;
|
elem_interaction[i].count == 0 ; i-- ) ;
|
||||||
for ( ; i >= 0 ; i-- )
|
for( ; i >= 0 ; i-- )
|
||||||
{
|
{
|
||||||
if ( elem_interaction[i].count == 0 )
|
if( elem_interaction[i].count == 0 )
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
if ( elem_interaction[i].count == 0 )
|
if( elem_interaction[i].count == 0 )
|
||||||
fprintf( fd, "\t %ld %ld (---)\n",
|
fprintf( fd, "\t %ld %ld (---)\n",
|
||||||
i, elem_interaction[i].count ) ;
|
i, elem_interaction[i].count ) ;
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ void print_per_process_info(FILE *fd, long process)
|
||||||
fprintf( fd, "\t\tPatch cache hit ratio: %.2f%%\n",
|
fprintf( fd, "\t\tPatch cache hit ratio: %.2f%%\n",
|
||||||
ps->total_patch_cache_hit * 100 /
|
ps->total_patch_cache_hit * 100 /
|
||||||
(ps->total_patch_cache_check + 0.01) ) ;
|
(ps->total_patch_cache_check + 0.01) ) ;
|
||||||
for ( cache_line = 0 ; cache_line < PATCH_CACHE_SIZE ; cache_line++ )
|
for( cache_line = 0 ; cache_line < PATCH_CACHE_SIZE ; cache_line++ )
|
||||||
fprintf( fd, "\t\t (level %ld): %.2f%%\n",
|
fprintf( fd, "\t\t (level %ld): %.2f%%\n",
|
||||||
cache_line,
|
cache_line,
|
||||||
ps->patch_cache_hit[cache_line] * 100 /
|
ps->patch_cache_hit[cache_line] * 100 /
|
||||||
|
@ -221,7 +221,7 @@ void print_per_process_info(FILE *fd, long process)
|
||||||
|
|
||||||
/* Per iteration info */
|
/* Per iteration info */
|
||||||
fprintf( fd, "\t\tPer iteration info.\n" ) ;
|
fprintf( fd, "\t\tPer iteration info.\n" ) ;
|
||||||
for ( iteration = 0 ; iteration < global->iteration_count ; iteration++ )
|
for( iteration = 0 ; iteration < global->iteration_count ; iteration++ )
|
||||||
{
|
{
|
||||||
fprintf( fd, "\t\t [%ld] Interaction comp: %ld\n",
|
fprintf( fd, "\t\t [%ld] Interaction comp: %ld\n",
|
||||||
iteration, ps->per_iteration[iteration].visibility_comp ) ;
|
iteration, ps->per_iteration[iteration].visibility_comp ) ;
|
||||||
|
@ -234,9 +234,9 @@ void print_per_process_info(FILE *fd, long process)
|
||||||
fprintf( fd, "\t\t Process_task wait count: %ld\n",
|
fprintf( fd, "\t\t Process_task wait count: %ld\n",
|
||||||
ps->per_iteration[iteration].process_tasks_wait ) ;
|
ps->per_iteration[iteration].process_tasks_wait ) ;
|
||||||
e = ps->per_iteration[iteration].last_pr_task ;
|
e = ps->per_iteration[iteration].last_pr_task ;
|
||||||
if ( e == 0 )
|
if( e == 0 )
|
||||||
continue ;
|
continue ;
|
||||||
if ( e->parent == 0 )
|
if( e->parent == 0 )
|
||||||
{
|
{
|
||||||
fprintf( fd, "\t\t Last task: Patch level\n" ) ;
|
fprintf( fd, "\t\t Last task: Patch level\n" ) ;
|
||||||
fprintf( fd, "\t\t (%ld root inter)\n",
|
fprintf( fd, "\t\t (%ld root inter)\n",
|
||||||
|
@ -289,7 +289,7 @@ void get_patch_stat(Patch *patch, long dummy, long process_id)
|
||||||
total_invisible_interactions += n_invisible_interactions ;
|
total_invisible_interactions += n_invisible_interactions ;
|
||||||
|
|
||||||
#if PATCH_ASSIGNMENT == PATCH_ASSIGNMENT_COSTBASED
|
#if PATCH_ASSIGNMENT == PATCH_ASSIGNMENT_COSTBASED
|
||||||
if ( n_interactions_in_patch
|
if( n_interactions_in_patch
|
||||||
!= global->patch_cost[patch->seq_no].n_total_inter )
|
!= global->patch_cost[patch->seq_no].n_total_inter )
|
||||||
{
|
{
|
||||||
printf( "Error: patch(%d) Inter counted: %d (n_total_inter %d)\n",
|
printf( "Error: patch(%d) Inter counted: %d (n_total_inter %d)\n",
|
||||||
|
@ -310,7 +310,7 @@ void get_elem_stat(Element *elem, long dummy, long process_id)
|
||||||
|
|
||||||
n_elements_in_patch++ ;
|
n_elements_in_patch++ ;
|
||||||
|
|
||||||
while ( elem->area < min_elem_area )
|
while( elem->area < min_elem_area )
|
||||||
{
|
{
|
||||||
min_elem_area *= 0.25 ;
|
min_elem_area *= 0.25 ;
|
||||||
n_equiv_elem_in_patch *= 4 ;
|
n_equiv_elem_in_patch *= 4 ;
|
||||||
|
@ -318,21 +318,21 @@ void get_elem_stat(Element *elem, long dummy, long process_id)
|
||||||
|
|
||||||
/* Classify visibility */
|
/* Classify visibility */
|
||||||
n_interactions_in_patch += elem->n_interactions ;
|
n_interactions_in_patch += elem->n_interactions ;
|
||||||
for ( pi = elem->interactions ; pi ; pi = pi->next )
|
for( pi = elem->interactions ; pi ; pi = pi->next )
|
||||||
{
|
{
|
||||||
if ( pi->visibility == 0.0 )
|
if( pi->visibility == 0.0 )
|
||||||
i_visible++ ;
|
i_visible++ ;
|
||||||
else if ( pi->visibility == 1.0 )
|
else if( pi->visibility == 1.0 )
|
||||||
c_visible++ ;
|
c_visible++ ;
|
||||||
else
|
else
|
||||||
p_visible++ ;
|
p_visible++ ;
|
||||||
}
|
}
|
||||||
if ( i_visible + c_visible + p_visible != elem->n_interactions )
|
if( i_visible + c_visible + p_visible != elem->n_interactions )
|
||||||
printf( "Fatal: Interactions count miss match\n" ) ;
|
printf( "Fatal: Interactions count miss match\n" ) ;
|
||||||
if ( elem->n_vis_undef_inter != 0 )
|
if( elem->n_vis_undef_inter != 0 )
|
||||||
printf( "Fatal: Visibility undef list count non zero(%ld)\n",
|
printf( "Fatal: Visibility undef list count non zero(%ld)\n",
|
||||||
elem->n_vis_undef_inter ) ;
|
elem->n_vis_undef_inter ) ;
|
||||||
if ( elem->vis_undef_inter != 0 )
|
if( elem->vis_undef_inter != 0 )
|
||||||
printf( "Fatal: Visibility undef list not empty\n" ) ;
|
printf( "Fatal: Visibility undef list not empty\n" ) ;
|
||||||
|
|
||||||
n_comp_visible_interactions += c_visible ;
|
n_comp_visible_interactions += c_visible ;
|
||||||
|
@ -340,7 +340,7 @@ void get_elem_stat(Element *elem, long dummy, long process_id)
|
||||||
|
|
||||||
|
|
||||||
/* Count interactions / element */
|
/* Count interactions / element */
|
||||||
if ( elem->n_interactions > MAX_INTERACTION_PER_ELEMENT )
|
if( elem->n_interactions > MAX_INTERACTION_PER_ELEMENT )
|
||||||
{
|
{
|
||||||
many_interaction.count++ ;
|
many_interaction.count++ ;
|
||||||
many_interaction.area += elem->area ;
|
many_interaction.area += elem->area ;
|
||||||
|
@ -352,7 +352,7 @@ void get_elem_stat(Element *elem, long dummy, long process_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Analyze object coherence */
|
/* Analyze object coherence */
|
||||||
if ( ! LEAF_ELEMENT( elem ) )
|
if( ! LEAF_ELEMENT( elem ) )
|
||||||
{
|
{
|
||||||
match0 = match1 = match2 = match3 = 0 ;
|
match0 = match1 = match2 = match3 = 0 ;
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ void count_interaction(Element *es, Element *e1, Element *e2, Element *e3, long
|
||||||
Interaction *pi ;
|
Interaction *pi ;
|
||||||
long occurrence ;
|
long occurrence ;
|
||||||
|
|
||||||
for ( pi = es->interactions ; pi ; pi = pi->next )
|
for( pi = es->interactions ; pi ; pi = pi->next )
|
||||||
{
|
{
|
||||||
occurrence = search_intearction( e1->interactions, pi, process_id ) ;
|
occurrence = search_intearction( e1->interactions, pi, process_id ) ;
|
||||||
occurrence += search_intearction( e2->interactions, pi, process_id ) ;
|
occurrence += search_intearction( e2->interactions, pi, process_id ) ;
|
||||||
|
@ -396,9 +396,9 @@ void count_interaction(Element *es, Element *e1, Element *e2, Element *e3, long
|
||||||
|
|
||||||
long search_intearction(Interaction *int_list, Interaction *inter, long process_id)
|
long search_intearction(Interaction *int_list, Interaction *inter, long process_id)
|
||||||
{
|
{
|
||||||
while ( int_list )
|
while( int_list )
|
||||||
{
|
{
|
||||||
if ( int_list->destination == inter->destination )
|
if( int_list->destination == inter->destination )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
|
|
||||||
int_list = int_list->next ;
|
int_list = int_list->next ;
|
||||||
|
@ -419,9 +419,9 @@ void print_running_time(long process_id)
|
||||||
|
|
||||||
time_diff = time_rad_end - time_rad_start ;
|
time_diff = time_rad_end - time_rad_start ;
|
||||||
time_diff1 = time_rad_end - timing[0]->rad_start;
|
time_diff1 = time_rad_end - timing[0]->rad_start;
|
||||||
if ( time_diff < 0 )
|
if( time_diff < 0 )
|
||||||
time_diff += CLOCK_MAX_VAL ;
|
time_diff += CLOCK_MAX_VAL ;
|
||||||
if ( time_diff1 < 0 )
|
if( time_diff1 < 0 )
|
||||||
time_diff1 += CLOCK_MAX_VAL ;
|
time_diff1 += CLOCK_MAX_VAL ;
|
||||||
|
|
||||||
printf( "\tOverall start time\t%20lu\n", time_rad_start);
|
printf( "\tOverall start time\t%20lu\n", time_rad_start);
|
||||||
|
@ -441,11 +441,11 @@ void print_fork_time(long process_id)
|
||||||
{
|
{
|
||||||
long pid ;
|
long pid ;
|
||||||
|
|
||||||
if ( n_processors <= 1 )
|
if( n_processors <= 1 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
printf( "\tProcess fork overhead\n" ) ;
|
printf( "\tProcess fork overhead\n" ) ;
|
||||||
for ( pid = 0 ; pid < n_processors-1 ; pid++ )
|
for( pid = 0 ; pid < n_processors-1 ; pid++ )
|
||||||
{
|
{
|
||||||
printf( "\t Process %ld %.2f mS\n",
|
printf( "\t Process %ld %.2f mS\n",
|
||||||
pid,
|
pid,
|
||||||
|
@ -469,7 +469,7 @@ void init_stat_info(long process_id)
|
||||||
long i ;
|
long i ;
|
||||||
StatisticalInfo *ps ;
|
StatisticalInfo *ps ;
|
||||||
|
|
||||||
for ( pid = 0 ; pid < MAX_PROCESSORS ; pid++ )
|
for( pid = 0 ; pid < MAX_PROCESSORS ; pid++ )
|
||||||
{
|
{
|
||||||
ps = &global->stat_info[ pid ] ;
|
ps = &global->stat_info[ pid ] ;
|
||||||
ps->total_modeling_tasks = 0 ;
|
ps->total_modeling_tasks = 0 ;
|
||||||
|
@ -484,10 +484,10 @@ void init_stat_info(long process_id)
|
||||||
ps->total_patch_cache_check = 0 ;
|
ps->total_patch_cache_check = 0 ;
|
||||||
ps->total_patch_cache_hit = 0 ;
|
ps->total_patch_cache_hit = 0 ;
|
||||||
|
|
||||||
for ( i = 0 ; i < PATCH_CACHE_SIZE ; i++ )
|
for( i = 0 ; i < PATCH_CACHE_SIZE ; i++ )
|
||||||
ps->patch_cache_hit[i] = 0 ;
|
ps->patch_cache_hit[i] = 0 ;
|
||||||
|
|
||||||
for ( i = 0 ; i < MAX_ITERATION_INFO ; i++ )
|
for( i = 0 ; i < MAX_ITERATION_INFO ; i++ )
|
||||||
{
|
{
|
||||||
ps->per_iteration[ i ].visibility_comp = 0 ;
|
ps->per_iteration[ i ].visibility_comp = 0 ;
|
||||||
ps->per_iteration[ i ].ray_intersect_test = 0 ;
|
ps->per_iteration[ i ].ray_intersect_test = 0 ;
|
||||||
|
|
|
@ -21,8 +21,7 @@ of the program, as well as lobal data structure declarations */
|
||||||
#ifndef _RADIOSITY_H
|
#ifndef _RADIOSITY_H
|
||||||
#define _RADIOSITY_H
|
#define _RADIOSITY_H
|
||||||
|
|
||||||
#include <cmath>
|
#include <math.h>
|
||||||
|
|
||||||
include(parallel.h)
|
include(parallel.h)
|
||||||
include(patch.h)
|
include(patch.h)
|
||||||
include(model.h)
|
include(model.h)
|
||||||
|
@ -30,6 +29,7 @@ include(task.h)
|
||||||
#include "glib.h"
|
#include "glib.h"
|
||||||
#include "pslib.h"
|
#include "pslib.h"
|
||||||
|
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
*
|
*
|
||||||
* Configuration Parameters
|
* Configuration Parameters
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
include(radiosity.h)
|
include(radiosity.h)
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
*
|
*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ ElemVertex *get_elemvertex(long process_id)
|
||||||
{
|
{
|
||||||
ElemVertex *ev ;
|
ElemVertex *ev ;
|
||||||
|
|
||||||
if ( sobj_struct[process_id].n_local_free_elemvertex == 0 )
|
if( sobj_struct[process_id].n_local_free_elemvertex == 0 )
|
||||||
{
|
{
|
||||||
LOCK(global->free_elemvertex_lock);
|
LOCK(global->free_elemvertex_lock);
|
||||||
if ( MAX_ELEMVERTICES - global->free_elemvertex
|
if ( MAX_ELEMVERTICES - global->free_elemvertex
|
||||||
|
@ -355,7 +355,7 @@ void init_elemvertex(long process_id)
|
||||||
global->free_elemvertex = 0 ;
|
global->free_elemvertex = 0 ;
|
||||||
|
|
||||||
/* Allocate locks */
|
/* Allocate locks */
|
||||||
for ( ev_cnt = 0 ; ev_cnt < MAX_ELEMVERTICES ; ev_cnt++ )
|
for( ev_cnt = 0 ; ev_cnt < MAX_ELEMVERTICES ; ev_cnt++ )
|
||||||
global->elemvertex_buf[ ev_cnt ].ev_lock
|
global->elemvertex_buf[ ev_cnt ].ev_lock
|
||||||
= get_sharedlock( SHARED_LOCK_SEGANY, process_id ) ;
|
= get_sharedlock( SHARED_LOCK_SEGANY, process_id ) ;
|
||||||
|
|
||||||
|
@ -390,14 +390,14 @@ void foreach_leaf_edge(Edge *edge, long reverse, void (*func)(), long arg1, long
|
||||||
{
|
{
|
||||||
Edge *first, *second ;
|
Edge *first, *second ;
|
||||||
|
|
||||||
if ( edge == 0 )
|
if( edge == 0 )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( (edge->ea == 0) && (edge->eb == 0) )
|
if( (edge->ea == 0) && (edge->eb == 0) )
|
||||||
func( edge, reverse, arg1, arg2, process_id ) ;
|
func( edge, reverse, arg1, arg2, process_id ) ;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( reverse )
|
if( reverse )
|
||||||
{
|
{
|
||||||
first = edge->eb ;
|
first = edge->eb ;
|
||||||
second = edge->ea ;
|
second = edge->ea ;
|
||||||
|
@ -407,9 +407,9 @@ void foreach_leaf_edge(Edge *edge, long reverse, void (*func)(), long arg1, long
|
||||||
first = edge->ea ;
|
first = edge->ea ;
|
||||||
second = edge->eb ;
|
second = edge->eb ;
|
||||||
}
|
}
|
||||||
if ( first )
|
if( first )
|
||||||
foreach_leaf_edge( first, reverse, func, arg1, arg2, process_id ) ;
|
foreach_leaf_edge( first, reverse, func, arg1, arg2, process_id ) ;
|
||||||
if ( second )
|
if( second )
|
||||||
foreach_leaf_edge( second, reverse, func, arg1, arg2, process_id ) ;
|
foreach_leaf_edge( second, reverse, func, arg1, arg2, process_id ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ void subdivide_edge(Edge *e, float a_ratio, long process_id)
|
||||||
LOCK(e->edge_lock->lock);
|
LOCK(e->edge_lock->lock);
|
||||||
|
|
||||||
/* Check if the element already has children */
|
/* Check if the element already has children */
|
||||||
if ( ! _LEAF_EDGE(e) )
|
if( ! _LEAF_EDGE(e) )
|
||||||
{
|
{
|
||||||
UNLOCK(e->edge_lock->lock);
|
UNLOCK(e->edge_lock->lock);
|
||||||
return ;
|
return ;
|
||||||
|
@ -499,7 +499,7 @@ Edge *get_edge(long process_id)
|
||||||
{
|
{
|
||||||
Edge *edge ;
|
Edge *edge ;
|
||||||
|
|
||||||
if ( sobj_struct[process_id].n_local_free_edge == 0 )
|
if( sobj_struct[process_id].n_local_free_edge == 0 )
|
||||||
{
|
{
|
||||||
LOCK(global->free_edge_lock);
|
LOCK(global->free_edge_lock);
|
||||||
if ( MAX_EDGES - global->free_edge < N_EDGE_ALLOCATE )
|
if ( MAX_EDGES - global->free_edge < N_EDGE_ALLOCATE )
|
||||||
|
@ -548,7 +548,7 @@ void init_edge(long process_id)
|
||||||
global->free_edge = 0 ;
|
global->free_edge = 0 ;
|
||||||
|
|
||||||
/* Allocate locks */
|
/* Allocate locks */
|
||||||
for ( edge_cnt = 0 ; edge_cnt < MAX_EDGES ; edge_cnt++ )
|
for( edge_cnt = 0 ; edge_cnt < MAX_EDGES ; edge_cnt++ )
|
||||||
global->edge_buf[ edge_cnt ].edge_lock
|
global->edge_buf[ edge_cnt ].edge_lock
|
||||||
= get_sharedlock( SHARED_LOCK_SEG0, process_id ) ;
|
= get_sharedlock( SHARED_LOCK_SEG0, process_id ) ;
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ void init_sharedlock(long process_id)
|
||||||
{
|
{
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
for ( i = 0 ; i < MAX_SHARED_LOCK ; i++ )
|
for( i = 0 ; i < MAX_SHARED_LOCK ; i++ )
|
||||||
{
|
{
|
||||||
LOCKINIT(global->sh_lock[i].lock);
|
LOCKINIT(global->sh_lock[i].lock);
|
||||||
}
|
}
|
||||||
|
@ -627,7 +627,7 @@ Shared_Lock *get_sharedlock(long segment, long process_id)
|
||||||
|
|
||||||
/* Update the lock counter */
|
/* Update the lock counter */
|
||||||
sobj_struct[process_id].lock_alloc_counter++ ;
|
sobj_struct[process_id].lock_alloc_counter++ ;
|
||||||
if ( sobj_struct[process_id].lock_alloc_counter >= MAX_SHARED_LOCK )
|
if( sobj_struct[process_id].lock_alloc_counter >= MAX_SHARED_LOCK )
|
||||||
sobj_struct[process_id].lock_alloc_counter = 0 ;
|
sobj_struct[process_id].lock_alloc_counter = 0 ;
|
||||||
|
|
||||||
return( pshl ) ;
|
return( pshl ) ;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float x, y, z ;
|
float x, y, z ;
|
||||||
} Vertex;
|
} Vertex;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -18,7 +18,7 @@ typedef struct {
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float r, g, b ;
|
float r, g, b ;
|
||||||
} Rgb;
|
} Rgb;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -28,7 +28,7 @@ typedef struct {
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
} Ray;
|
} Ray;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
*
|
*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ void process_tasks(long process_id)
|
||||||
t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ;
|
t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ;
|
||||||
|
|
||||||
retry_entry:
|
retry_entry:
|
||||||
while ( t )
|
while( t )
|
||||||
{
|
{
|
||||||
switch( t->task_type )
|
switch( t->task_type )
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ void process_tasks(long process_id)
|
||||||
|
|
||||||
LOCK(global->pbar_lock);
|
LOCK(global->pbar_lock);
|
||||||
/* Reset the barrier counter if not initialized */
|
/* Reset the barrier counter if not initialized */
|
||||||
if ( global->pbar_count >= n_processors )
|
if( global->pbar_count >= n_processors )
|
||||||
global->pbar_count = 0 ;
|
global->pbar_count = 0 ;
|
||||||
|
|
||||||
/* Increment the counter */
|
/* Increment the counter */
|
||||||
|
@ -115,16 +115,16 @@ void process_tasks(long process_id)
|
||||||
UNLOCK(global->pbar_lock);
|
UNLOCK(global->pbar_lock);
|
||||||
|
|
||||||
/* barrier spin-wait loop */
|
/* barrier spin-wait loop */
|
||||||
while ( global->pbar_count < n_processors )
|
while( global->pbar_count < n_processors )
|
||||||
{
|
{
|
||||||
/* Wait for a while and then retry dequeue */
|
/* Wait for a while and then retry dequeue */
|
||||||
if ( _process_task_wait_loop() )
|
if( _process_task_wait_loop() )
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
/* Waited for a while but other processors are still running.
|
/* Waited for a while but other processors are still running.
|
||||||
Poll the task queue again */
|
Poll the task queue again */
|
||||||
t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ;
|
t = DEQUEUE_TASK( taskqueue_id[process_id], QUEUES_VISITED, process_id ) ;
|
||||||
if ( t )
|
if( t )
|
||||||
{
|
{
|
||||||
/* Task found. Exit the barrier and work on it */
|
/* Task found. Exit the barrier and work on it */
|
||||||
LOCK(global->pbar_lock);
|
LOCK(global->pbar_lock);
|
||||||
|
@ -145,9 +145,9 @@ long _process_task_wait_loop()
|
||||||
long finished = 0 ;
|
long finished = 0 ;
|
||||||
|
|
||||||
/* Wait for a while and then retry */
|
/* Wait for a while and then retry */
|
||||||
for ( i = 0 ; i < 1000 && ! finished ; i++ )
|
for( i = 0 ; i < 1000 && ! finished ; i++ )
|
||||||
{
|
{
|
||||||
if ( ((i & 0xff) == 0) && ((volatile long)global->pbar_count >= n_processors) )
|
if( ((i & 0xff) == 0) && ((volatile long)global->pbar_count >= n_processors) )
|
||||||
|
|
||||||
finished = 1 ;
|
finished = 1 ;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ void create_ff_refine_task(Element *e1, Element *e2, long level, long process_id
|
||||||
Task *t ;
|
Task *t ;
|
||||||
|
|
||||||
/* Check existing parallelism */
|
/* Check existing parallelism */
|
||||||
if ( taskq_too_long(&global->task_queue[ taskqueue_id[process_id] ]) )
|
if( taskq_too_long(&global->task_queue[ taskqueue_id[process_id] ]) )
|
||||||
{
|
{
|
||||||
/* Task queue is too long. Solve it immediately */
|
/* Task queue is too long. Solve it immediately */
|
||||||
ff_refine_elements( e1, e2, level, process_id ) ;
|
ff_refine_elements( e1, e2, level, process_id ) ;
|
||||||
|
@ -217,7 +217,7 @@ void create_ff_refine_task(Element *e1, Element *e2, long level, long process_id
|
||||||
void create_ray_task(Element *e, long process_id)
|
void create_ray_task(Element *e, long process_id)
|
||||||
{
|
{
|
||||||
/* Check existing parallelism */
|
/* Check existing parallelism */
|
||||||
if ( ((e->n_interactions + e->n_vis_undef_inter)
|
if( ((e->n_interactions + e->n_vis_undef_inter)
|
||||||
< N_inter_parallel_bf_refine)
|
< N_inter_parallel_bf_refine)
|
||||||
|| taskq_too_long(&global->task_queue[ taskqueue_id[process_id] ]) )
|
|| taskq_too_long(&global->task_queue[ taskqueue_id[process_id] ]) )
|
||||||
{
|
{
|
||||||
|
@ -257,11 +257,11 @@ void create_visibility_tasks(Element *e, void (*k)(), long process_id)
|
||||||
long tasks_created = 0 ;
|
long tasks_created = 0 ;
|
||||||
|
|
||||||
/* Check number of hard problems */
|
/* Check number of hard problems */
|
||||||
for ( top = e->vis_undef_inter ; top ; top = top->next )
|
for( top = e->vis_undef_inter ; top ; top = top->next )
|
||||||
if ( top->visibility == VISIBILITY_UNDEF )
|
if( top->visibility == VISIBILITY_UNDEF )
|
||||||
total_undefs++ ;
|
total_undefs++ ;
|
||||||
|
|
||||||
if ( total_undefs == 0 )
|
if( total_undefs == 0 )
|
||||||
{
|
{
|
||||||
/* No process needs to be created. Call the continuation
|
/* No process needs to be created. Call the continuation
|
||||||
immediately */
|
immediately */
|
||||||
|
@ -270,7 +270,7 @@ void create_visibility_tasks(Element *e, void (*k)(), long process_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check existing parallelism */
|
/* Check existing parallelism */
|
||||||
if ( (total_undefs < N_visibility_per_task)
|
if( (total_undefs < N_visibility_per_task)
|
||||||
|| taskq_too_long(&global->task_queue[ taskqueue_id[process_id] ]) )
|
|| taskq_too_long(&global->task_queue[ taskqueue_id[process_id] ]) )
|
||||||
{
|
{
|
||||||
/* Task size is small, or the queue is too long.
|
/* Task size is small, or the queue is too long.
|
||||||
|
@ -293,24 +293,24 @@ void create_visibility_tasks(Element *e, void (*k)(), long process_id)
|
||||||
/ N_visibility_per_task ;
|
/ N_visibility_per_task ;
|
||||||
remainder = 0 ;
|
remainder = 0 ;
|
||||||
i_cnt = 0 ;
|
i_cnt = 0 ;
|
||||||
for ( top = e->vis_undef_inter, tail = top ; tail ; tail = tail->next )
|
for( top = e->vis_undef_inter, tail = top ; tail ; tail = tail->next )
|
||||||
{
|
{
|
||||||
i_cnt++ ;
|
i_cnt++ ;
|
||||||
|
|
||||||
if ( tail->visibility != VISIBILITY_UNDEF )
|
if( tail->visibility != VISIBILITY_UNDEF )
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
remainder += n_tasks ;
|
remainder += n_tasks ;
|
||||||
|
|
||||||
if ( remainder >= total_undefs )
|
if( remainder >= total_undefs )
|
||||||
{
|
{
|
||||||
/* Create a task */
|
/* Create a task */
|
||||||
|
|
||||||
/* For the last task, append following (easy) interactions
|
/* For the last task, append following (easy) interactions
|
||||||
if there is any */
|
if there is any */
|
||||||
tasks_created++ ;
|
tasks_created++ ;
|
||||||
if ( tasks_created >= n_tasks )
|
if( tasks_created >= n_tasks )
|
||||||
for ( ; tail->next ; tail = tail->next, i_cnt++ ) ;
|
for( ; tail->next ; tail = tail->next, i_cnt++ ) ;
|
||||||
|
|
||||||
/* Set task descriptor */
|
/* Set task descriptor */
|
||||||
t = get_task(process_id) ;
|
t = get_task(process_id) ;
|
||||||
|
@ -337,7 +337,7 @@ void create_visibility_tasks(Element *e, void (*k)(), long process_id)
|
||||||
void create_radavg_task(Element *e, long mode, long process_id)
|
void create_radavg_task(Element *e, long mode, long process_id)
|
||||||
{
|
{
|
||||||
/* Check existing parallelism */
|
/* Check existing parallelism */
|
||||||
if ( (e->n_interactions < N_inter_parallel_bf_refine)
|
if( (e->n_interactions < N_inter_parallel_bf_refine)
|
||||||
|| taskq_too_long(&global->task_queue[ taskqueue_id[process_id] ]) )
|
|| taskq_too_long(&global->task_queue[ taskqueue_id[process_id] ]) )
|
||||||
{
|
{
|
||||||
/* Task size is too small or queue is too long.
|
/* Task size is too small or queue is too long.
|
||||||
|
@ -384,7 +384,7 @@ void enqueue_task(long qid, Task *task, long mode)
|
||||||
/* Lock the task queue */
|
/* Lock the task queue */
|
||||||
LOCK(tq->q_lock);
|
LOCK(tq->q_lock);
|
||||||
|
|
||||||
if ( tq->tail == 0 )
|
if( tq->tail == 0 )
|
||||||
{
|
{
|
||||||
/* The first task in the queue */
|
/* The first task in the queue */
|
||||||
tq->tail = task ;
|
tq->tail = task ;
|
||||||
|
@ -394,7 +394,7 @@ void enqueue_task(long qid, Task *task, long mode)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Usual case */
|
/* Usual case */
|
||||||
if ( mode == TASK_APPEND )
|
if( mode == TASK_APPEND )
|
||||||
{
|
{
|
||||||
tq->tail->next = task ;
|
tq->tail->next = task ;
|
||||||
tq->tail = task ;
|
tq->tail = task ;
|
||||||
|
@ -433,37 +433,37 @@ Task *dequeue_task(long qid, long max_visit, long process_id)
|
||||||
long offset ;
|
long offset ;
|
||||||
|
|
||||||
/* Check number of queues to be visited */
|
/* Check number of queues to be visited */
|
||||||
if ( max_visit > n_taskqueues )
|
if( max_visit > n_taskqueues )
|
||||||
max_visit = n_taskqueues ;
|
max_visit = n_taskqueues ;
|
||||||
|
|
||||||
/* Get next task */
|
/* Get next task */
|
||||||
while ( visit_count < max_visit )
|
while( visit_count < max_visit )
|
||||||
{
|
{
|
||||||
/* Select a task queue */
|
/* Select a task queue */
|
||||||
tq = &global->task_queue[ qid ] ;
|
tq = &global->task_queue[ qid ] ;
|
||||||
|
|
||||||
/* Check the length (test-test&set) */
|
/* Check the length (test-test&set) */
|
||||||
if ( tq->n_tasks > 0 )
|
if( tq->n_tasks > 0 )
|
||||||
{
|
{
|
||||||
/* Lock the task queue */
|
/* Lock the task queue */
|
||||||
LOCK(tq->q_lock);
|
LOCK(tq->q_lock);
|
||||||
if ( tq->top )
|
if( tq->top )
|
||||||
{
|
{
|
||||||
if ( qid == taskqueue_id[process_id] )
|
if( qid == taskqueue_id[process_id] )
|
||||||
{
|
{
|
||||||
t = tq->top ;
|
t = tq->top ;
|
||||||
tq->top = t->next ;
|
tq->top = t->next ;
|
||||||
if ( tq->top == 0 )
|
if( tq->top == 0 )
|
||||||
tq->tail = 0 ;
|
tq->tail = 0 ;
|
||||||
tq->n_tasks-- ;
|
tq->n_tasks-- ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Get tail */
|
/* Get tail */
|
||||||
for ( prev = 0, t = tq->top ; t->next ;
|
for( prev = 0, t = tq->top ; t->next ;
|
||||||
prev = t, t = t->next ) ;
|
prev = t, t = t->next ) ;
|
||||||
|
|
||||||
if ( prev == 0 )
|
if( prev == 0 )
|
||||||
tq->top = 0 ;
|
tq->top = 0 ;
|
||||||
else
|
else
|
||||||
prev->next = 0 ;
|
prev->next = 0 ;
|
||||||
|
@ -484,9 +484,9 @@ Task *dequeue_task(long qid, long max_visit, long process_id)
|
||||||
sign = -sign ;
|
sign = -sign ;
|
||||||
|
|
||||||
qid += offset ;
|
qid += offset ;
|
||||||
if ( qid < 0 )
|
if( qid < 0 )
|
||||||
qid += n_taskqueues ;
|
qid += n_taskqueues ;
|
||||||
else if ( qid >= n_taskqueues )
|
else if( qid >= n_taskqueues )
|
||||||
qid -= n_taskqueues ;
|
qid -= n_taskqueues ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,22 +511,22 @@ Task *get_task(long process_id)
|
||||||
long retry_count = 0 ;
|
long retry_count = 0 ;
|
||||||
|
|
||||||
/* First, check local task queue */
|
/* First, check local task queue */
|
||||||
if ( task_struct[process_id].local_free_task == 0 )
|
if( task_struct[process_id].local_free_task == 0 )
|
||||||
{
|
{
|
||||||
/* If empty, allocate task objects from the shared list */
|
/* If empty, allocate task objects from the shared list */
|
||||||
q_id = taskqueue_id[process_id] ;
|
q_id = taskqueue_id[process_id] ;
|
||||||
|
|
||||||
while ( task_struct[process_id].local_free_task == 0 )
|
while( task_struct[process_id].local_free_task == 0 )
|
||||||
{
|
{
|
||||||
tq = &global->task_queue[ q_id ] ;
|
tq = &global->task_queue[ q_id ] ;
|
||||||
|
|
||||||
if ( tq->n_free > 0 )
|
if( tq->n_free > 0 )
|
||||||
{
|
{
|
||||||
LOCK(tq->f_lock);
|
LOCK(tq->f_lock);
|
||||||
if ( tq->free )
|
if( tq->free )
|
||||||
{
|
{
|
||||||
/* Scan the free list */
|
/* Scan the free list */
|
||||||
for ( i = 1, p = tq->free ;
|
for( i = 1, p = tq->free ;
|
||||||
(i < N_ALLOCATE_LOCAL_TASK) && p->next ;
|
(i < N_ALLOCATE_LOCAL_TASK) && p->next ;
|
||||||
i++, p = p->next ) ;
|
i++, p = p->next ) ;
|
||||||
|
|
||||||
|
@ -542,11 +542,11 @@ Task *get_task(long process_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try next task queue */
|
/* Try next task queue */
|
||||||
if ( ++q_id >= n_taskqueues )
|
if( ++q_id >= n_taskqueues )
|
||||||
q_id = 0 ;
|
q_id = 0 ;
|
||||||
|
|
||||||
/* Check retry count */
|
/* Check retry count */
|
||||||
if ( ++retry_count > MAX_TASKGET_RETRY )
|
if( ++retry_count > MAX_TASKGET_RETRY )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Panic(P%ld):No free task\n",
|
fprintf( stderr, "Panic(P%ld):No free task\n",
|
||||||
process_id ) ;
|
process_id ) ;
|
||||||
|
@ -587,11 +587,11 @@ void free_task(Task *task, long process_id)
|
||||||
task_struct[process_id].n_local_free_task++ ;
|
task_struct[process_id].n_local_free_task++ ;
|
||||||
|
|
||||||
/* If local list is too long, export some tasks */
|
/* If local list is too long, export some tasks */
|
||||||
if ( task_struct[process_id].n_local_free_task >= (N_ALLOCATE_LOCAL_TASK * 2) )
|
if( task_struct[process_id].n_local_free_task >= (N_ALLOCATE_LOCAL_TASK * 2) )
|
||||||
{
|
{
|
||||||
tq = &global->task_queue[ taskqueue_id[process_id] ] ;
|
tq = &global->task_queue[ taskqueue_id[process_id] ] ;
|
||||||
|
|
||||||
for ( i = 1, p = task_struct[process_id].local_free_task ;
|
for( i = 1, p = task_struct[process_id].local_free_task ;
|
||||||
i < N_ALLOCATE_LOCAL_TASK ; i++, p = p->next ) ;
|
i < N_ALLOCATE_LOCAL_TASK ; i++, p = p->next ) ;
|
||||||
|
|
||||||
/* Update local list */
|
/* Update local list */
|
||||||
|
@ -634,7 +634,7 @@ void init_taskq(long process_id)
|
||||||
/* Initialize task queues */
|
/* Initialize task queues */
|
||||||
task_per_queue = (MAX_TASKS + n_taskqueues - 1) / n_taskqueues ;
|
task_per_queue = (MAX_TASKS + n_taskqueues - 1) / n_taskqueues ;
|
||||||
|
|
||||||
for ( qid = 0 ; qid < n_taskqueues ; qid++ )
|
for( qid = 0 ; qid < n_taskqueues ; qid++ )
|
||||||
{
|
{
|
||||||
/* Initialize free list */
|
/* Initialize free list */
|
||||||
if (task_index + task_per_queue > MAX_TASKS )
|
if (task_index + task_per_queue > MAX_TASKS )
|
||||||
|
@ -642,7 +642,7 @@ void init_taskq(long process_id)
|
||||||
else
|
else
|
||||||
n_tasks = task_per_queue ;
|
n_tasks = task_per_queue ;
|
||||||
|
|
||||||
for ( i = task_index ; i < task_index + n_tasks - 1 ; i++ )
|
for( i = task_index ; i < task_index + n_tasks - 1 ; i++ )
|
||||||
global->task_buf[i].next = &global->task_buf[i+1] ;
|
global->task_buf[i].next = &global->task_buf[i+1] ;
|
||||||
global->task_buf[ i ].next = 0 ;
|
global->task_buf[ i ].next = 0 ;
|
||||||
|
|
||||||
|
@ -684,12 +684,12 @@ long check_task_counter()
|
||||||
|
|
||||||
LOCK(global->task_counter_lock);
|
LOCK(global->task_counter_lock);
|
||||||
|
|
||||||
if ( global->task_counter == 0 )
|
if( global->task_counter == 0 )
|
||||||
/* First processor */
|
/* First processor */
|
||||||
flag = 1 ;
|
flag = 1 ;
|
||||||
|
|
||||||
global->task_counter++ ;
|
global->task_counter++ ;
|
||||||
if ( global->task_counter >= n_processors )
|
if( global->task_counter >= n_processors )
|
||||||
global->task_counter = 0 ;
|
global->task_counter = 0 ;
|
||||||
|
|
||||||
UNLOCK(global->task_counter_lock);
|
UNLOCK(global->task_counter_lock);
|
||||||
|
@ -713,7 +713,7 @@ long assign_taskq(long process_id)
|
||||||
|
|
||||||
qid = task_struct[process_id].crnt_taskq_id++ ;
|
qid = task_struct[process_id].crnt_taskq_id++ ;
|
||||||
|
|
||||||
if ( task_struct[process_id].crnt_taskq_id >= n_taskqueues )
|
if( task_struct[process_id].crnt_taskq_id >= n_taskqueues )
|
||||||
task_struct[process_id].crnt_taskq_id = 0 ;
|
task_struct[process_id].crnt_taskq_id = 0 ;
|
||||||
|
|
||||||
return( qid ) ;
|
return( qid ) ;
|
||||||
|
@ -731,7 +731,7 @@ long assign_taskq(long process_id)
|
||||||
|
|
||||||
void print_task(Task *task)
|
void print_task(Task *task)
|
||||||
{
|
{
|
||||||
if ( task == 0 )
|
if( task == 0 )
|
||||||
{
|
{
|
||||||
printf( "Task (NULL)\n" ) ;
|
printf( "Task (NULL)\n" ) ;
|
||||||
return ;
|
return ;
|
||||||
|
@ -770,7 +770,7 @@ void print_taskq(Task_Queue *tq)
|
||||||
Task *t ;
|
Task *t ;
|
||||||
|
|
||||||
printf( "TaskQ: %ld tasks in the queue\n", taskq_length(tq) ) ;
|
printf( "TaskQ: %ld tasks in the queue\n", taskq_length(tq) ) ;
|
||||||
for ( t = taskq_top(tq) ; t ; t = t->next )
|
for( t = taskq_top(tq) ; t ; t = t->next )
|
||||||
{
|
{
|
||||||
printf( " " ) ;
|
printf( " " ) ;
|
||||||
print_task( t ) ;
|
print_task( t ) ;
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
*
|
*
|
||||||
***************************************************************/
|
***************************************************************/
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
EXTERN_ENV;
|
EXTERN_ENV;
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ void get_test_rays(Vertex *p_src, Ray *v, long no, long process_id)
|
||||||
Vertex p_dst ;
|
Vertex p_dst ;
|
||||||
float fv1, fv2 ;
|
float fv1, fv2 ;
|
||||||
|
|
||||||
if ( no > VISI_RAYS_MAX )
|
if( no > VISI_RAYS_MAX )
|
||||||
no = VISI_RAYS_MAX ;
|
no = VISI_RAYS_MAX ;
|
||||||
|
|
||||||
for (i = 0, g_index = 0 ; i < no; i++, g_index++) {
|
for (i = 0, g_index = 0 ; i < no; i++, g_index++) {
|
||||||
|
@ -330,37 +330,37 @@ long traverse_bsp(Patch *src_node, Vertex *p, Ray *ray, float r_min, float r_max
|
||||||
|
|
||||||
|
|
||||||
/* (1) Check patch cache */
|
/* (1) Check patch cache */
|
||||||
if ( check_patch_cache( p, ray, r_min, r_max, process_id ) )
|
if( check_patch_cache( p, ray, r_min, r_max, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
|
|
||||||
/* (2) Check S+(src_node) */
|
/* (2) Check S+(src_node) */
|
||||||
if ( traverse_subtree( src_node->bsp_positive, p, ray, r_min, r_max, process_id ) )
|
if( traverse_subtree( src_node->bsp_positive, p, ray, r_min, r_max, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
|
|
||||||
/* (3) Continue in-order traversal till root is encountered */
|
/* (3) Continue in-order traversal till root is encountered */
|
||||||
for ( parent = src_node->bsp_parent, visited_child = src_node ;
|
for( parent = src_node->bsp_parent, visited_child = src_node ;
|
||||||
parent ;
|
parent ;
|
||||||
visited_child = parent, parent = parent->bsp_parent )
|
visited_child = parent, parent = parent->bsp_parent )
|
||||||
{
|
{
|
||||||
/* Check intersection at this node */
|
/* Check intersection at this node */
|
||||||
advice = intersection_type( parent, p, ray, &t, r_min, r_max ) ;
|
advice = intersection_type( parent, p, ray, &t, r_min, r_max ) ;
|
||||||
if ( (advice != POSITIVE_SUBTREE_ONLY) && (advice != NEGATIVE_SUBTREE_ONLY) )
|
if( (advice != POSITIVE_SUBTREE_ONLY) && (advice != NEGATIVE_SUBTREE_ONLY) )
|
||||||
{
|
{
|
||||||
if ( test_intersection( parent, p, ray, t, process_id ) )
|
if( test_intersection( parent, p, ray, t, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
|
|
||||||
r_min = t - VIS_RANGE_MARGIN ;
|
r_min = t - VIS_RANGE_MARGIN ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Traverse unvisited subtree of the node */
|
/* Traverse unvisited subtree of the node */
|
||||||
if ( (parent->bsp_positive == visited_child) && (advice != POSITIVE_SUBTREE_ONLY) )
|
if( (parent->bsp_positive == visited_child) && (advice != POSITIVE_SUBTREE_ONLY) )
|
||||||
{
|
{
|
||||||
if ( traverse_subtree( parent->bsp_negative, p, ray, r_min, r_max, process_id ) )
|
if( traverse_subtree( parent->bsp_negative, p, ray, r_min, r_max, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
}
|
}
|
||||||
else if ( (parent->bsp_positive != visited_child) && (advice != NEGATIVE_SUBTREE_ONLY) )
|
else if( (parent->bsp_positive != visited_child) && (advice != NEGATIVE_SUBTREE_ONLY) )
|
||||||
{
|
{
|
||||||
if ( traverse_subtree( parent->bsp_positive, p, ray, r_min, r_max, process_id ) )
|
if( traverse_subtree( parent->bsp_positive, p, ray, r_min, r_max, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,39 +389,39 @@ long traverse_subtree(Patch *node, Vertex *p, Ray *ray, float r_min, float r_max
|
||||||
long advice ;
|
long advice ;
|
||||||
|
|
||||||
|
|
||||||
if ( node == 0 )
|
if( node == 0 )
|
||||||
return( 0 ) ;
|
return( 0 ) ;
|
||||||
|
|
||||||
advice = intersection_type( node, p, ray, &t, r_min, r_max ) ;
|
advice = intersection_type( node, p, ray, &t, r_min, r_max ) ;
|
||||||
if ( advice == POSITIVE_SIDE_FIRST )
|
if( advice == POSITIVE_SIDE_FIRST )
|
||||||
{
|
{
|
||||||
/* The ray is approaching from the positive side of the patch */
|
/* The ray is approaching from the positive side of the patch */
|
||||||
if ( traverse_subtree( node->bsp_positive, p, ray,
|
if( traverse_subtree( node->bsp_positive, p, ray,
|
||||||
r_min, t + VIS_RANGE_MARGIN, process_id ) )
|
r_min, t + VIS_RANGE_MARGIN, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
|
|
||||||
if ( test_intersection( node, p, ray, t, process_id ) )
|
if( test_intersection( node, p, ray, t, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
return( traverse_subtree( node->bsp_negative, p, ray,
|
return( traverse_subtree( node->bsp_negative, p, ray,
|
||||||
t - VIS_RANGE_MARGIN, r_max, process_id ) ) ;
|
t - VIS_RANGE_MARGIN, r_max, process_id ) ) ;
|
||||||
}
|
}
|
||||||
else if ( advice == NEGATIVE_SIDE_FIRST )
|
else if( advice == NEGATIVE_SIDE_FIRST )
|
||||||
{
|
{
|
||||||
/* The ray is approaching from the negative side of the patch */
|
/* The ray is approaching from the negative side of the patch */
|
||||||
if ( traverse_subtree( node->bsp_negative, p, ray,
|
if( traverse_subtree( node->bsp_negative, p, ray,
|
||||||
r_min, t + VIS_RANGE_MARGIN, process_id ) )
|
r_min, t + VIS_RANGE_MARGIN, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
if ( test_intersection( node, p, ray, t, process_id ) )
|
if( test_intersection( node, p, ray, t, process_id ) )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
|
|
||||||
return( traverse_subtree( node->bsp_positive, p, ray,
|
return( traverse_subtree( node->bsp_positive, p, ray,
|
||||||
t - VIS_RANGE_MARGIN, r_max, process_id ) ) ;
|
t - VIS_RANGE_MARGIN, r_max, process_id ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( advice == POSITIVE_SUBTREE_ONLY )
|
else if( advice == POSITIVE_SUBTREE_ONLY )
|
||||||
return( traverse_subtree( node->bsp_positive, p, ray,
|
return( traverse_subtree( node->bsp_positive, p, ray,
|
||||||
r_min, r_max, process_id ) ) ;
|
r_min, r_max, process_id ) ) ;
|
||||||
else if ( advice == NEGATIVE_SUBTREE_ONLY )
|
else if( advice == NEGATIVE_SUBTREE_ONLY )
|
||||||
return( traverse_subtree( node->bsp_negative, p, ray,
|
return( traverse_subtree( node->bsp_negative, p, ray,
|
||||||
r_min, r_max, process_id ) ) ;
|
r_min, r_max, process_id ) ) ;
|
||||||
else
|
else
|
||||||
|
@ -469,11 +469,11 @@ long intersection_type(Patch *patch, Vertex *p, Ray *ray, float *tval, float ra
|
||||||
r_dot_n = nx * ray->x + ny * ray->y + nz * ray->z ;
|
r_dot_n = nx * ray->x + ny * ray->y + nz * ray->z ;
|
||||||
dist = patch->plane_equ.c + p->x * nx + p->y * ny + p->z * nz ;
|
dist = patch->plane_equ.c + p->x * nx + p->y * ny + p->z * nz ;
|
||||||
|
|
||||||
if ( (-(float)F_ZERO < r_dot_n) && (r_dot_n < (float)F_ZERO) )
|
if( (-(float)F_ZERO < r_dot_n) && (r_dot_n < (float)F_ZERO) )
|
||||||
{
|
{
|
||||||
if ( dist > (float)F_COPLANAR )
|
if( dist > (float)F_COPLANAR )
|
||||||
return( POSITIVE_SUBTREE_ONLY ) ;
|
return( POSITIVE_SUBTREE_ONLY ) ;
|
||||||
else if ( dist < -F_COPLANAR )
|
else if( dist < -F_COPLANAR )
|
||||||
return( NEGATIVE_SUBTREE_ONLY ) ;
|
return( NEGATIVE_SUBTREE_ONLY ) ;
|
||||||
|
|
||||||
return( ON_THE_PLANE ) ;
|
return( ON_THE_PLANE ) ;
|
||||||
|
@ -482,23 +482,23 @@ long intersection_type(Patch *patch, Vertex *p, Ray *ray, float *tval, float ra
|
||||||
t = -dist / r_dot_n ;
|
t = -dist / r_dot_n ;
|
||||||
*tval = t ;
|
*tval = t ;
|
||||||
|
|
||||||
if ( t < range_min )
|
if( t < range_min )
|
||||||
{
|
{
|
||||||
if ( r_dot_n >= 0 )
|
if( r_dot_n >= 0 )
|
||||||
return( POSITIVE_SUBTREE_ONLY ) ;
|
return( POSITIVE_SUBTREE_ONLY ) ;
|
||||||
else
|
else
|
||||||
return( NEGATIVE_SUBTREE_ONLY ) ;
|
return( NEGATIVE_SUBTREE_ONLY ) ;
|
||||||
}
|
}
|
||||||
else if ( t > range_max )
|
else if ( t > range_max )
|
||||||
{
|
{
|
||||||
if ( r_dot_n >= 0 )
|
if( r_dot_n >= 0 )
|
||||||
return( NEGATIVE_SUBTREE_ONLY ) ;
|
return( NEGATIVE_SUBTREE_ONLY ) ;
|
||||||
else
|
else
|
||||||
return( POSITIVE_SUBTREE_ONLY ) ;
|
return( POSITIVE_SUBTREE_ONLY ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( r_dot_n >= 0 )
|
if( r_dot_n >= 0 )
|
||||||
return( NEGATIVE_SIDE_FIRST ) ;
|
return( NEGATIVE_SIDE_FIRST ) ;
|
||||||
else
|
else
|
||||||
return( POSITIVE_SIDE_FIRST ) ;
|
return( POSITIVE_SIDE_FIRST ) ;
|
||||||
|
@ -517,16 +517,16 @@ long test_intersection(Patch *patch, Vertex *p, Ray *ray, float tval, long proce
|
||||||
/* Rays always hit the destination. Note that (R.Ndest) is already
|
/* Rays always hit the destination. Note that (R.Ndest) is already
|
||||||
checked by visibility() */
|
checked by visibility() */
|
||||||
|
|
||||||
if ( patch == vis_struct[process_id].v_dest_patch )
|
if( patch == vis_struct[process_id].v_dest_patch )
|
||||||
{
|
{
|
||||||
vis_struct[process_id].pool_dst_hits++ ;
|
vis_struct[process_id].pool_dst_hits++ ;
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( patch_tested( patch, process_id ) )
|
if( patch_tested( patch, process_id ) )
|
||||||
return( 0 ) ;
|
return( 0 ) ;
|
||||||
|
|
||||||
if ( v_intersect( patch, p, ray, tval ) )
|
if( v_intersect( patch, p, ray, tval ) )
|
||||||
{
|
{
|
||||||
/* Store it in the patch-cache */
|
/* Store it in the patch-cache */
|
||||||
update_patch_cache( patch, process_id ) ;
|
update_patch_cache( patch, process_id ) ;
|
||||||
|
@ -563,7 +563,7 @@ void update_patch_cache(Patch *patch, long process_id)
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
/* Shift current contents */
|
/* Shift current contents */
|
||||||
for ( i = PATCH_CACHE_SIZE-1 ; i > 0 ; i-- )
|
for( i = PATCH_CACHE_SIZE-1 ; i > 0 ; i-- )
|
||||||
vis_struct[process_id].patch_cache[i] = vis_struct[process_id].patch_cache[i-1] ;
|
vis_struct[process_id].patch_cache[i] = vis_struct[process_id].patch_cache[i-1] ;
|
||||||
|
|
||||||
/* Store the new patch data */
|
/* Store the new patch data */
|
||||||
|
@ -579,9 +579,9 @@ long check_patch_cache(Vertex *p, Ray *ray, float r_min, float r_max, long proce
|
||||||
Patch *temp ;
|
Patch *temp ;
|
||||||
long advice ;
|
long advice ;
|
||||||
|
|
||||||
for ( i = 0 ; i < PATCH_CACHE_SIZE ; i++ )
|
for( i = 0 ; i < PATCH_CACHE_SIZE ; i++ )
|
||||||
{
|
{
|
||||||
if ( (vis_struct[process_id].patch_cache[i] == 0)
|
if( (vis_struct[process_id].patch_cache[i] == 0)
|
||||||
|| (vis_struct[process_id].patch_cache[i] == vis_struct[process_id].v_dest_patch)
|
|| (vis_struct[process_id].patch_cache[i] == vis_struct[process_id].v_dest_patch)
|
||||||
|| (vis_struct[process_id].patch_cache[i] == vis_struct[process_id].v_src_patch) )
|
|| (vis_struct[process_id].patch_cache[i] == vis_struct[process_id].v_src_patch) )
|
||||||
continue ;
|
continue ;
|
||||||
|
@ -589,14 +589,14 @@ long check_patch_cache(Vertex *p, Ray *ray, float r_min, float r_max, long proce
|
||||||
advice = intersection_type( vis_struct[process_id].patch_cache[i], p, ray, &t, r_min, r_max ) ;
|
advice = intersection_type( vis_struct[process_id].patch_cache[i], p, ray, &t, r_min, r_max ) ;
|
||||||
|
|
||||||
/* If no intersection, then skip */
|
/* If no intersection, then skip */
|
||||||
if ( (advice == POSITIVE_SUBTREE_ONLY)
|
if( (advice == POSITIVE_SUBTREE_ONLY)
|
||||||
|| (advice == NEGATIVE_SUBTREE_ONLY) )
|
|| (advice == NEGATIVE_SUBTREE_ONLY) )
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
if ( (advice == ON_THE_PLANE) || v_intersect( vis_struct[process_id].patch_cache[i], p, ray, t ) )
|
if( (advice == ON_THE_PLANE) || v_intersect( vis_struct[process_id].patch_cache[i], p, ray, t ) )
|
||||||
{
|
{
|
||||||
/* Change priority */
|
/* Change priority */
|
||||||
if ( i > 0 )
|
if( i > 0 )
|
||||||
{
|
{
|
||||||
temp = vis_struct[process_id].patch_cache[ i-1 ] ;
|
temp = vis_struct[process_id].patch_cache[ i-1 ] ;
|
||||||
vis_struct[process_id].patch_cache[ i-1 ] = vis_struct[process_id].patch_cache[ i ] ;
|
vis_struct[process_id].patch_cache[ i-1 ] = vis_struct[process_id].patch_cache[ i ] ;
|
||||||
|
@ -617,7 +617,7 @@ void init_patch_cache(long process_id)
|
||||||
{
|
{
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
for ( i = 0 ; i < PATCH_CACHE_SIZE ; i++ )
|
for( i = 0 ; i < PATCH_CACHE_SIZE ; i++ )
|
||||||
vis_struct[process_id].patch_cache[ i ] = 0 ;
|
vis_struct[process_id].patch_cache[ i ] = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,9 +626,9 @@ long patch_tested(Patch *p, long process_id)
|
||||||
{
|
{
|
||||||
long i ;
|
long i ;
|
||||||
|
|
||||||
for ( i = 0 ; i < PATCH_CACHE_SIZE ; i++ )
|
for( i = 0 ; i < PATCH_CACHE_SIZE ; i++ )
|
||||||
{
|
{
|
||||||
if ( p == vis_struct[process_id].patch_cache[i] )
|
if( p == vis_struct[process_id].patch_cache[i] )
|
||||||
return( 1 ) ;
|
return( 1 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,9 +714,9 @@ float visibility(Element *e1, Element *e2, long n_rays, long process_id)
|
||||||
|
|
||||||
void compute_visibility_values(Element *elem, Interaction *inter, long n_inter, long process_id)
|
void compute_visibility_values(Element *elem, Interaction *inter, long n_inter, long process_id)
|
||||||
{
|
{
|
||||||
for ( ; n_inter > 0 ; inter = inter->next, n_inter-- )
|
for( ; n_inter > 0 ; inter = inter->next, n_inter-- )
|
||||||
{
|
{
|
||||||
if ( inter->visibility != VISIBILITY_UNDEF )
|
if( inter->visibility != VISIBILITY_UNDEF )
|
||||||
continue ;
|
continue ;
|
||||||
|
|
||||||
vis_struct[process_id].bsp_nodes_visited = 0 ;
|
vis_struct[process_id].bsp_nodes_visited = 0 ;
|
||||||
|
@ -764,6 +764,6 @@ void visibility_task(Element *elem, Interaction *inter, long n_inter, void (*k)(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Call continuation if this is the last task finished. */
|
/* Call continuation if this is the last task finished. */
|
||||||
if ( new_vis_undef_count == 0 )
|
if( new_vis_undef_count == 0 )
|
||||||
k( elem, process_id ) ;
|
k( elem, process_id ) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME
|
* NAME
|
||||||
* InquireBoundBoxValues - return min and max bound values for each coordinate axis
|
* InquireBoundBoxValues - return min and max bound values for each coordinate axis
|
||||||
|
@ -45,14 +46,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID InquireBoundBoxValues(BBOX *pbb, REAL *minx, REAL *miny, REAL *minz, REAL *maxx, REAL *maxy, REAL *maxz)
|
VOID InquireBoundBoxValues(BBOX *pbb, REAL *minx, REAL *miny, REAL *minz, REAL *maxx, REAL *maxy, REAL *maxz)
|
||||||
{
|
{
|
||||||
*minx = pbb->dnear[0];
|
*minx = pbb->dnear[0];
|
||||||
*miny = pbb->dnear[1];
|
*miny = pbb->dnear[1];
|
||||||
*minz = pbb->dnear[2];
|
*minz = pbb->dnear[2];
|
||||||
*maxx = pbb->dfar[0];
|
*maxx = pbb->dfar[0];
|
||||||
*maxy = pbb->dfar[1];
|
*maxy = pbb->dfar[1];
|
||||||
*maxz = pbb->dfar[2];
|
*maxz = pbb->dfar[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,31 +71,31 @@ VOID InquireBoundBoxValues(BBOX *pbb, REAL *minx, REAL *miny, REAL *minz, REAL *
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID NormalizeBoundBox(BBOX *pbb, MATRIX mat)
|
VOID NormalizeBoundBox(BBOX *pbb, MATRIX mat)
|
||||||
{
|
{
|
||||||
POINT tmp;
|
POINT tmp;
|
||||||
|
|
||||||
/* dnear and dfar are only vectors of length 3 */
|
/* dnear and dfar are only vectors of length 3 */
|
||||||
|
|
||||||
tmp[0] = pbb->dnear[0];
|
tmp[0] = pbb->dnear[0];
|
||||||
tmp[1] = pbb->dnear[1];
|
tmp[1] = pbb->dnear[1];
|
||||||
tmp[2] = pbb->dnear[2];
|
tmp[2] = pbb->dnear[2];
|
||||||
tmp[3] = 1.0;
|
tmp[3] = 1.0;
|
||||||
|
|
||||||
VecMatMult(tmp, mat, tmp);
|
VecMatMult(tmp, mat, tmp);
|
||||||
|
|
||||||
pbb->dnear[0] = tmp[0];
|
pbb->dnear[0] = tmp[0];
|
||||||
pbb->dnear[1] = tmp[1];
|
pbb->dnear[1] = tmp[1];
|
||||||
pbb->dnear[2] = tmp[2];
|
pbb->dnear[2] = tmp[2];
|
||||||
|
|
||||||
tmp[0] = pbb->dfar[0];
|
tmp[0] = pbb->dfar[0];
|
||||||
tmp[1] = pbb->dfar[1];
|
tmp[1] = pbb->dfar[1];
|
||||||
tmp[2] = pbb->dfar[2];
|
tmp[2] = pbb->dfar[2];
|
||||||
tmp[3] = 1.0;
|
tmp[3] = 1.0;
|
||||||
|
|
||||||
VecMatMult(tmp, mat, tmp);
|
VecMatMult(tmp, mat, tmp);
|
||||||
|
|
||||||
pbb->dfar[0] = tmp[0];
|
pbb->dfar[0] = tmp[0];
|
||||||
pbb->dfar[1] = tmp[1];
|
pbb->dfar[1] = tmp[1];
|
||||||
pbb->dfar[2] = tmp[2];
|
pbb->dfar[2] = tmp[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -31,23 +31,24 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct /* Runlength pixel definition. */
|
static struct /* Runlength pixel definition. */
|
||||||
{
|
{
|
||||||
U8 r, g, b; /* Color. */
|
U8 r, g, b; /* Color. */
|
||||||
U8 count; /* Pixel count for color. */
|
U8 count; /* Pixel count for color. */
|
||||||
}
|
}
|
||||||
image[MAX_X];
|
image[MAX_X];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
image does not have have to be made an array for tango-lite
|
image does not have have to be made an array for tango-lite
|
||||||
since it is only used in RunLengthEncode, which is only
|
since it is only used in RunLengthEncode, which is only
|
||||||
called by CloseFrameBuffer, which is only called after
|
called by CloseFrameBuffer, which is only called after
|
||||||
all children have terminated
|
all children have terminated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,48 +68,48 @@ static struct /* Runlength pixel definition. */
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID RunLengthEncode(FILE *pf, PIXEL *fb, INT xsize)
|
VOID RunLengthEncode(FILE *pf, PIXEL *fb, INT xsize)
|
||||||
{
|
{
|
||||||
INT x; /* Original buffer entry address. */
|
INT x; /* Original buffer entry address. */
|
||||||
INT rl; /* Runlength buffer entry address. */
|
INT rl; /* Runlength buffer entry address. */
|
||||||
INT numpixels; /* Running count of identical pixels.*/
|
INT numpixels; /* Running count of identical pixels.*/
|
||||||
U8 red, green, blue; /* Color holders. */
|
U8 red, green, blue; /* Color holders. */
|
||||||
|
|
||||||
rl = 0;
|
rl = 0;
|
||||||
numpixels = 0;
|
numpixels = 0;
|
||||||
|
|
||||||
image[0].r = (U8)( (INT) (fb[0].r * 255.0));
|
image[0].r = (U8)( (INT) (fb[0].r * 255.0));
|
||||||
image[0].g = (U8)( (INT) (fb[0].g * 255.0));
|
image[0].g = (U8)( (INT) (fb[0].g * 255.0));
|
||||||
image[0].b = (U8)( (INT) (fb[0].b * 255.0));
|
image[0].b = (U8)( (INT) (fb[0].b * 255.0));
|
||||||
|
|
||||||
for (x = 1; x < xsize; x++)
|
for (x = 1; x < xsize; x++)
|
||||||
{
|
{
|
||||||
red = (U8)( (INT) (fb[x].r * 255.0));
|
red = (U8)( (INT) (fb[x].r * 255.0));
|
||||||
green = (U8)( (INT) (fb[x].g * 255.0));
|
green = (U8)( (INT) (fb[x].g * 255.0));
|
||||||
blue = (U8)( (INT) (fb[x].b * 255.0));
|
blue = (U8)( (INT) (fb[x].b * 255.0));
|
||||||
|
|
||||||
|
|
||||||
if (red == image[rl].r &&
|
if (red == image[rl].r &&
|
||||||
green == image[rl].g &&
|
green == image[rl].g &&
|
||||||
blue == image[rl].b &&
|
blue == image[rl].b &&
|
||||||
numpixels < 255)
|
numpixels < 255)
|
||||||
numpixels++;
|
numpixels++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
image[rl].count = (U8)numpixels;
|
image[rl].count = (U8)numpixels;
|
||||||
rl++;
|
rl++;
|
||||||
|
|
||||||
image[rl].r = red;
|
image[rl].r = red;
|
||||||
image[rl].g = green;
|
image[rl].g = green;
|
||||||
image[rl].b = blue;
|
image[rl].b = blue;
|
||||||
numpixels = 0;
|
numpixels = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
image[rl].count = (U8)numpixels;
|
image[rl].count = (U8)numpixels;
|
||||||
|
|
||||||
for (x = 0; x <= rl; x++)
|
for (x = 0; x <= rl; x++)
|
||||||
fprintf(pf, "%c%c%c%c", image[x].r, image[x].g, image[x].b, image[x].count);
|
fprintf(pf, "%c%c%c%c", image[x].r, image[x].g, image[x].b, image[x].count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,20 +125,20 @@ VOID RunLengthEncode(FILE *pf, PIXEL *fb, INT xsize)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID OpenFrameBuffer()
|
VOID OpenFrameBuffer()
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
PIXEL *fb;
|
PIXEL *fb;
|
||||||
|
|
||||||
fb = Display.framebuffer = GlobalMalloc(Display.numpixels*sizeof(PIXEL), "fbuf.c");
|
fb = Display.framebuffer = GlobalMalloc(Display.numpixels*sizeof(PIXEL), "fbuf.c");
|
||||||
|
|
||||||
for (i = 0; i < Display.numpixels; i++)
|
for (i = 0; i < Display.numpixels; i++)
|
||||||
{
|
{
|
||||||
fb->r = 0.0;
|
fb->r = 0.0;
|
||||||
fb->g = 0.0;
|
fb->g = 0.0;
|
||||||
fb->b = 0.0;
|
fb->b = 0.0;
|
||||||
fb++;
|
fb++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,17 +157,17 @@ VOID OpenFrameBuffer()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID AddPixelColor(COLOR c, INT x, INT y)
|
VOID AddPixelColor(COLOR c, INT x, INT y)
|
||||||
{
|
{
|
||||||
INT addr; /* Index into framebuffer. */
|
INT addr; /* Index into framebuffer. */
|
||||||
PIXEL *fb; /* Ptr to framebuffer. */
|
PIXEL *fb; /* Ptr to framebuffer. */
|
||||||
|
|
||||||
addr = Display.xres * y + x;
|
addr = Display.xres * y + x;
|
||||||
fb = Display.framebuffer;
|
fb = Display.framebuffer;
|
||||||
|
|
||||||
fb[addr].r += c[0];
|
fb[addr].r += c[0];
|
||||||
fb[addr].g += c[1];
|
fb[addr].g += c[1];
|
||||||
fb[addr].b += c[2];
|
fb[addr].b += c[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,50 +184,50 @@ VOID AddPixelColor(COLOR c, INT x, INT y)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID CloseFrameBuffer(CHAR *PicFileName)
|
VOID CloseFrameBuffer(CHAR *PicFileName)
|
||||||
{
|
{
|
||||||
INT x;
|
INT x;
|
||||||
INT y;
|
INT y;
|
||||||
PIXEL *fb; /* Ptr to framebuffer. */
|
PIXEL *fb; /* Ptr to framebuffer. */
|
||||||
FILE *pf; /* Ptr to picture file. */
|
FILE *pf; /* Ptr to picture file. */
|
||||||
|
|
||||||
pf = fopen(PicFileName, "wb");
|
pf = fopen(PicFileName, "wb");
|
||||||
if (!pf)
|
if (!pf)
|
||||||
{
|
{
|
||||||
printf("Unable to open picture file %s.\n", PicFileName);
|
printf("Unable to open picture file %s.\n", PicFileName);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Write file header. */
|
/* Write file header. */
|
||||||
|
|
||||||
x = Display.xres;
|
x = Display.xres;
|
||||||
y = Display.yres;
|
y = Display.yres;
|
||||||
fb = Display.framebuffer;
|
fb = Display.framebuffer;
|
||||||
|
|
||||||
fprintf(pf, "%c%c%c%c%c%c%c%c",
|
fprintf(pf, "%c%c%c%c%c%c%c%c",
|
||||||
(char)(0), (char)(0), (char)(x/256), (char) (x%256),
|
(char)(0), (char)(0), (char)(x/256), (char) (x%256),
|
||||||
(char)(0), (char)(0), (char)(y/256), (char) (y%256));
|
(char)(0), (char)(0), (char)(y/256), (char) (y%256));
|
||||||
|
|
||||||
|
|
||||||
/* Clamp, run-length encode, and write out pixels on a scanline basis. */
|
/* Clamp, run-length encode, and write out pixels on a scanline basis. */
|
||||||
|
|
||||||
for (y = 0; y < Display.yres; y++)
|
for (y = 0; y < Display.yres; y++)
|
||||||
{
|
{
|
||||||
for (x = 0; x < Display.xres; x++)
|
for (x = 0; x < Display.xres; x++)
|
||||||
{
|
{
|
||||||
fb[x].r = Min(fb[x].r, 1.0);
|
fb[x].r = Min(fb[x].r, 1.0);
|
||||||
fb[x].g = Min(fb[x].g, 1.0);
|
fb[x].g = Min(fb[x].g, 1.0);
|
||||||
fb[x].b = Min(fb[x].b, 1.0);
|
fb[x].b = Min(fb[x].b, 1.0);
|
||||||
fb[x].r = Max(fb[x].r, 0.0);
|
fb[x].r = Max(fb[x].r, 0.0);
|
||||||
fb[x].g = Max(fb[x].g, 0.0);
|
fb[x].g = Max(fb[x].g, 0.0);
|
||||||
fb[x].b = Max(fb[x].b, 0.0);
|
fb[x].b = Max(fb[x].b, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
RunLengthEncode(pf, fb, Display.xres);
|
RunLengthEncode(pf, fb, Display.xres);
|
||||||
fb += Display.xres;
|
fb += Display.xres;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(pf);
|
fclose(pf);
|
||||||
GlobalFree(Display.framebuffer);
|
GlobalFree(Display.framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,49 +27,49 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <math.h>
|
||||||
#include <cmath>
|
#include <string.h>
|
||||||
#include <cstdio>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and initialize sphere function pointer array.
|
* Allocate and initialize sphere function pointer array.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PPROCS SphProcs =
|
static PPROCS SphProcs =
|
||||||
{
|
{
|
||||||
SphName,
|
SphName,
|
||||||
SphPrint,
|
SphPrint,
|
||||||
SphRead,
|
SphRead,
|
||||||
NULL,
|
NULL,
|
||||||
SphTransform,
|
SphTransform,
|
||||||
SphIntersect,
|
SphIntersect,
|
||||||
SphPeIntersect,
|
SphPeIntersect,
|
||||||
SphNormal,
|
SphNormal,
|
||||||
SphDataNormalize,
|
SphDataNormalize,
|
||||||
SphBoundBox
|
SphBoundBox
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and initialize polygon function pointer array.
|
* Allocate and initialize polygon function pointer array.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PPROCS PolyProcs =
|
static PPROCS PolyProcs =
|
||||||
{
|
{
|
||||||
PolyName,
|
PolyName,
|
||||||
PolyPrint,
|
PolyPrint,
|
||||||
PolyRead,
|
PolyRead,
|
||||||
NULL,
|
NULL,
|
||||||
PolyTransform,
|
PolyTransform,
|
||||||
PolyIntersect,
|
PolyIntersect,
|
||||||
PolyPeIntersect,
|
PolyPeIntersect,
|
||||||
PolyNormal,
|
PolyNormal,
|
||||||
PolyDataNormalize,
|
PolyDataNormalize,
|
||||||
PolyBoundBox
|
PolyBoundBox
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,18 +78,18 @@ static PPROCS PolyProcs =
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PPROCS TriProcs =
|
static PPROCS TriProcs =
|
||||||
{
|
{
|
||||||
TriName,
|
TriName,
|
||||||
TriPrint,
|
TriPrint,
|
||||||
TriRead,
|
TriRead,
|
||||||
NULL,
|
NULL,
|
||||||
TriTransform,
|
TriTransform,
|
||||||
TriIntersect,
|
TriIntersect,
|
||||||
TriPeIntersect,
|
TriPeIntersect,
|
||||||
TriNormal,
|
TriNormal,
|
||||||
TriDataNormalize,
|
TriDataNormalize,
|
||||||
TriBoundBox
|
TriBoundBox
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,34 +107,34 @@ static PPROCS TriProcs =
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ELEMENT **MakeElementArray(INT *totalElements)
|
ELEMENT **MakeElementArray(INT *totalElements)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
OBJECT *po; /* Ptr to object. */
|
OBJECT *po; /* Ptr to object. */
|
||||||
INT currArrayPosition = 0;
|
INT currArrayPosition = 0;
|
||||||
ELEMENT **npepa;
|
ELEMENT **npepa;
|
||||||
|
|
||||||
po = gm->modelroot;
|
po = gm->modelroot;
|
||||||
*totalElements = 0;
|
*totalElements = 0;
|
||||||
|
|
||||||
while (po)
|
while (po)
|
||||||
{
|
{
|
||||||
(*totalElements) += po->numelements;
|
(*totalElements) += po->numelements;
|
||||||
po = po->next;
|
po = po->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
po = gm->modelroot;
|
po = gm->modelroot;
|
||||||
npepa = ObjectMalloc(OT_PEPARRAY, *totalElements);
|
npepa = ObjectMalloc(OT_PEPARRAY, *totalElements);
|
||||||
|
|
||||||
while (po)
|
while (po)
|
||||||
{
|
{
|
||||||
for (i = 0; i < po->numelements; i++)
|
for (i = 0; i < po->numelements; i++)
|
||||||
npepa[currArrayPosition++] = po->pelem + i;
|
npepa[currArrayPosition++] = po->pelem + i;
|
||||||
|
|
||||||
po = po->next;
|
po = po->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (npepa);
|
return (npepa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,23 +151,23 @@ ELEMENT **MakeElementArray(INT *totalElements)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID PrintGeo(OBJECT *po)
|
VOID PrintGeo(OBJECT *po)
|
||||||
{
|
{
|
||||||
while (po)
|
while (po)
|
||||||
{
|
{
|
||||||
fprintf(stdout, "Object %s\n", po->name);
|
fprintf(stdout, "Object %s\n", po->name);
|
||||||
fprintf(stdout, "\tcolor %f %f %f %f %f %f\n",
|
fprintf(stdout, "\tcolor %f %f %f %f %f %f\n",
|
||||||
po->surf->fcolor[0], po->surf->fcolor[1],
|
po->surf->fcolor[0], po->surf->fcolor[1],
|
||||||
po->surf->fcolor[2], po->surf->bcolor[0],
|
po->surf->fcolor[2], po->surf->bcolor[0],
|
||||||
po->surf->bcolor[1], po->surf->bcolor[2]);
|
po->surf->bcolor[1], po->surf->bcolor[2]);
|
||||||
|
|
||||||
fprintf(stdout, "\tcoeffs %f %f %f %f %f\n",
|
fprintf(stdout, "\tcoeffs %f %f %f %f %f\n",
|
||||||
po->surf->kdiff, po->surf->kspec, po->surf->ktran,
|
po->surf->kdiff, po->surf->kspec, po->surf->ktran,
|
||||||
po->surf->refrindex, po->surf->kspecn);
|
po->surf->refrindex, po->surf->kspecn);
|
||||||
|
|
||||||
(*po->procs->print)(po);
|
(*po->procs->print)(po);
|
||||||
po = po->next;
|
po = po->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,70 +186,70 @@ VOID PrintGeo(OBJECT *po)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID NormalizeGeo(OBJECT *po, MATRIX model, MATRIX modelInvT)
|
VOID NormalizeGeo(OBJECT *po, MATRIX model, MATRIX modelInvT)
|
||||||
{
|
{
|
||||||
REAL norm_minx; /* Normalize min values. */
|
REAL norm_minx; /* Normalize min values. */
|
||||||
REAL norm_miny;
|
REAL norm_miny;
|
||||||
REAL norm_minz;
|
REAL norm_minz;
|
||||||
REAL norm_maxx; /* Normalize max values. */
|
REAL norm_maxx; /* Normalize max values. */
|
||||||
REAL norm_maxy;
|
REAL norm_maxy;
|
||||||
REAL norm_maxz;
|
REAL norm_maxz;
|
||||||
REAL scale_min; /* Object min max values. */
|
REAL scale_min; /* Object min max values. */
|
||||||
REAL scale_max;
|
REAL scale_max;
|
||||||
REAL scale; /* Normalization scale val. */
|
REAL scale; /* Normalization scale val. */
|
||||||
REAL trans; /* Normalization xlat val. */
|
REAL trans; /* Normalization xlat val. */
|
||||||
OBJECT *poHead; /* Ptr to head of object list*/
|
OBJECT *poHead; /* Ptr to head of object list*/
|
||||||
MATRIX normMat; /* Normalization matrix. */
|
MATRIX normMat; /* Normalization matrix. */
|
||||||
MATRIX tempMat; /* Temporary work matrix. */
|
MATRIX tempMat; /* Temporary work matrix. */
|
||||||
|
|
||||||
|
|
||||||
poHead = po; /* Save ptr to head of list. */
|
poHead = po; /* Save ptr to head of list. */
|
||||||
|
|
||||||
if (! (TraversalType == TT_LIST && ModelNorm == FALSE) )
|
if (! (TraversalType == TT_LIST && ModelNorm == FALSE) )
|
||||||
{
|
{
|
||||||
/* Find global bound box min/max. */
|
/* Find global bound box min/max. */
|
||||||
|
|
||||||
norm_minx = norm_miny = norm_minz = HUGE_REAL;
|
norm_minx = norm_miny = norm_minz = HUGE_REAL;
|
||||||
norm_maxx = norm_maxy = norm_maxz = -HUGE_REAL;
|
norm_maxx = norm_maxy = norm_maxz = -HUGE_REAL;
|
||||||
|
|
||||||
while (po)
|
while (po)
|
||||||
{
|
{
|
||||||
norm_minx = Min(norm_minx, po->bv.dnear[0]);
|
norm_minx = Min(norm_minx, po->bv.dnear[0]);
|
||||||
norm_miny = Min(norm_miny, po->bv.dnear[1]);
|
norm_miny = Min(norm_miny, po->bv.dnear[1]);
|
||||||
norm_minz = Min(norm_minz, po->bv.dnear[2]);
|
norm_minz = Min(norm_minz, po->bv.dnear[2]);
|
||||||
norm_maxx = Max(norm_maxx, po->bv.dfar[0]);
|
norm_maxx = Max(norm_maxx, po->bv.dfar[0]);
|
||||||
norm_maxy = Max(norm_maxy, po->bv.dfar[1]);
|
norm_maxy = Max(norm_maxy, po->bv.dfar[1]);
|
||||||
norm_maxz = Max(norm_maxz, po->bv.dfar[2]);
|
norm_maxz = Max(norm_maxz, po->bv.dfar[2]);
|
||||||
|
|
||||||
po = po->next;
|
po = po->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Compute scale factor. */
|
/* Compute scale factor. */
|
||||||
|
|
||||||
scale_min = Min(norm_minx, norm_miny);
|
scale_min = Min(norm_minx, norm_miny);
|
||||||
scale_min = Min(scale_min, norm_minz);
|
scale_min = Min(scale_min, norm_minz);
|
||||||
scale_max = Max(norm_maxx, norm_maxy);
|
scale_max = Max(norm_maxx, norm_maxy);
|
||||||
scale_max = Max(scale_max, norm_maxz);
|
scale_max = Max(scale_max, norm_maxz);
|
||||||
|
|
||||||
scale = 1.0/(scale_max - scale_min);
|
scale = 1.0/(scale_max - scale_min);
|
||||||
trans = (-scale_min*scale);
|
trans = (-scale_min*scale);
|
||||||
|
|
||||||
Scale(tempMat, scale, scale, scale);
|
Scale(tempMat, scale, scale, scale);
|
||||||
Translate(normMat, trans, trans, trans);
|
Translate(normMat, trans, trans, trans);
|
||||||
MatrixMult(normMat, tempMat, normMat);
|
MatrixMult(normMat, tempMat, normMat);
|
||||||
|
|
||||||
|
|
||||||
/* Now, normalize object data. */
|
/* Now, normalize object data. */
|
||||||
|
|
||||||
po = poHead;
|
po = poHead;
|
||||||
|
|
||||||
while (po)
|
while (po)
|
||||||
{
|
{
|
||||||
(*po->procs->normalize)(po, normMat);
|
(*po->procs->normalize)(po, normMat);
|
||||||
po = po->next;
|
po = po->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,187 +275,187 @@ VOID NormalizeGeo(OBJECT *po, MATRIX model, MATRIX modelInvT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID ReadGeoFile(CHAR *GeoFileName)
|
VOID ReadGeoFile(CHAR *GeoFileName)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
INT dummy;
|
INT dummy;
|
||||||
INT stat; /* Input read counter. */
|
INT stat; /* Input read counter. */
|
||||||
CHAR comchar;
|
CHAR comchar;
|
||||||
CHAR primop; /* Primitive opcode. */
|
CHAR primop; /* Primitive opcode. */
|
||||||
CHAR objstr[NAME_LEN]; /* Object descriptions. */
|
CHAR objstr[NAME_LEN]; /* Object descriptions. */
|
||||||
CHAR objname[NAME_LEN];
|
CHAR objname[NAME_LEN];
|
||||||
FILE *pf; /* Ptr to geo file desc. */
|
FILE *pf; /* Ptr to geo file desc. */
|
||||||
SURF *ps; /* Ptr to surface desc. */
|
SURF *ps; /* Ptr to surface desc. */
|
||||||
MATRIX model; /* Model matrix. */
|
MATRIX model; /* Model matrix. */
|
||||||
MATRIX modelInv; /* Model matrix inverse. */
|
MATRIX modelInv; /* Model matrix inverse. */
|
||||||
MATRIX modelInvT; /* Model matrix inv transpose*/
|
MATRIX modelInvT; /* Model matrix inv transpose*/
|
||||||
OBJECT *prev; /* Ptr to previous object. */
|
OBJECT *prev; /* Ptr to previous object. */
|
||||||
OBJECT *curr; /* Ptr to current object. */
|
OBJECT *curr; /* Ptr to current object. */
|
||||||
ELEMENT *pe; /* Ptr to the element list. */
|
ELEMENT *pe; /* Ptr to the element list. */
|
||||||
|
|
||||||
|
|
||||||
/* Open the model file. */
|
/* Open the model file. */
|
||||||
|
|
||||||
pf = fopen(GeoFileName, "r");
|
pf = fopen(GeoFileName, "r");
|
||||||
if (!pf)
|
if (!pf)
|
||||||
{
|
{
|
||||||
printf("Unable to open model file %s.\n", GeoFileName);
|
printf("Unable to open model file %s.\n", GeoFileName);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Initialize pointers and counters. */
|
/* Initialize pointers and counters. */
|
||||||
|
|
||||||
curr = NULL;
|
curr = NULL;
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
gm->modelroot = NULL;
|
gm->modelroot = NULL;
|
||||||
prim_obj_cnt = 0;
|
prim_obj_cnt = 0;
|
||||||
prim_elem_cnt = 0;
|
prim_elem_cnt = 0;
|
||||||
|
|
||||||
|
|
||||||
/* Retrieve model transform. */
|
/* Retrieve model transform. */
|
||||||
|
|
||||||
MatrixCopy(model, View.model);
|
MatrixCopy(model, View.model);
|
||||||
MatrixInverse(modelInv, model);
|
MatrixInverse(modelInv, model);
|
||||||
MatrixTranspose(modelInvT, modelInv);
|
MatrixTranspose(modelInvT, modelInv);
|
||||||
|
|
||||||
|
|
||||||
/* Check for comments. */
|
/* Check for comments. */
|
||||||
|
|
||||||
if ((comchar = getc(pf)) != '#')
|
if ((comchar = getc(pf)) != '#')
|
||||||
ungetc(comchar, pf);
|
ungetc(comchar, pf);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
comchar = '\0'; /* Set to other than '#'. */
|
comchar = '\0'; /* Set to other than '#'. */
|
||||||
|
|
||||||
while (comchar != '#')
|
while (comchar != '#')
|
||||||
if ((comchar = getc(pf)) == EOF)
|
if ((comchar = getc(pf)) == EOF)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Incorrect comment in geometry file.\n");
|
fprintf(stderr, "Incorrect comment in geometry file.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Process the file data for each object. */
|
/* Process the file data for each object. */
|
||||||
|
|
||||||
while ((stat = fscanf(pf, "%s %s", objstr, objname)) != EOF)
|
while ((stat = fscanf(pf, "%s %s", objstr, objname)) != EOF)
|
||||||
{
|
{
|
||||||
if (stat != 2 || strcmp(objstr, "object") != 0)
|
if (stat != 2 || strcmp(objstr, "object") != 0)
|
||||||
{
|
{
|
||||||
printf("Invalid object definition %s.\n", objstr);
|
printf("Invalid object definition %s.\n", objstr);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Allocate next object and set list pointers. */
|
/* Allocate next object and set list pointers. */
|
||||||
|
|
||||||
prim_obj_cnt++;
|
prim_obj_cnt++;
|
||||||
|
|
||||||
curr = GlobalMalloc(sizeof(OBJECT), "geo.c");
|
curr = GlobalMalloc(sizeof(OBJECT), "geo.c");
|
||||||
curr->index = prim_obj_cnt;
|
curr->index = prim_obj_cnt;
|
||||||
curr->next = NULL;
|
curr->next = NULL;
|
||||||
|
|
||||||
strcpy(curr->name, objname);
|
strcpy(curr->name, objname);
|
||||||
|
|
||||||
if (gm->modelroot == NULL)
|
if (gm->modelroot == NULL)
|
||||||
gm->modelroot = curr;
|
gm->modelroot = curr;
|
||||||
else
|
else
|
||||||
prev->next = curr;
|
prev->next = curr;
|
||||||
|
|
||||||
|
|
||||||
/* Get surface characteristics. */
|
/* Get surface characteristics. */
|
||||||
|
|
||||||
ps = GlobalMalloc(sizeof(SURF), "geo.c");
|
ps = GlobalMalloc(sizeof(SURF), "geo.c");
|
||||||
curr->surf = ps;
|
curr->surf = ps;
|
||||||
|
|
||||||
stat = fscanf(pf, "%lf %lf %lf %lf %lf %lf",
|
stat = fscanf(pf, "%lf %lf %lf %lf %lf %lf",
|
||||||
&(ps->fcolor[0]), &(ps->fcolor[1]), &(ps->fcolor[2]),
|
&(ps->fcolor[0]), &(ps->fcolor[1]), &(ps->fcolor[2]),
|
||||||
&(ps->bcolor[0]), &(ps->bcolor[1]), &(ps->bcolor[2]));
|
&(ps->bcolor[0]), &(ps->bcolor[1]), &(ps->bcolor[2]));
|
||||||
|
|
||||||
if (stat != 6)
|
if (stat != 6)
|
||||||
{
|
{
|
||||||
printf("Object color incorrect.\n");
|
printf("Object color incorrect.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
stat = fscanf(pf, "%lf %lf %lf %lf %lf",
|
stat = fscanf(pf, "%lf %lf %lf %lf %lf",
|
||||||
&(ps->kdiff), &(ps->kspec), &(ps->ktran),
|
&(ps->kdiff), &(ps->kspec), &(ps->ktran),
|
||||||
&(ps->refrindex), &(ps->kspecn));
|
&(ps->refrindex), &(ps->kspecn));
|
||||||
|
|
||||||
if (stat != 5)
|
if (stat != 5)
|
||||||
{
|
{
|
||||||
printf("Object surface coefficients incorrect.\n");
|
printf("Object surface coefficients incorrect.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Get texture and flag information. */
|
/* Get texture and flag information. */
|
||||||
|
|
||||||
stat = fscanf(pf, "%ld %ld %ld %ld\n", &dummy, &dummy, &dummy, &dummy);
|
stat = fscanf(pf, "%ld %ld %ld %ld\n", &dummy, &dummy, &dummy, &dummy);
|
||||||
|
|
||||||
if (stat != 4)
|
if (stat != 4)
|
||||||
{
|
{
|
||||||
printf("Texture and/or flag information not all present.\n");
|
printf("Texture and/or flag information not all present.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Get primitive opcode. */
|
/* Get primitive opcode. */
|
||||||
|
|
||||||
stat = fscanf(pf, "%c %ld", &primop, &(curr->numelements));
|
stat = fscanf(pf, "%c %ld", &primop, &(curr->numelements));
|
||||||
|
|
||||||
if (stat != 2)
|
if (stat != 2)
|
||||||
{
|
{
|
||||||
printf("Object primitive opcode.\n");
|
printf("Object primitive opcode.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (primop)
|
switch (primop)
|
||||||
{
|
{
|
||||||
case 's':
|
case 's':
|
||||||
curr->procs = &SphProcs;
|
curr->procs = &SphProcs;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
curr->procs = &PolyProcs;
|
curr->procs = &PolyProcs;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
curr->procs = &TriProcs;
|
curr->procs = &TriProcs;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'q':
|
case 'q':
|
||||||
printf("Code for cylinders and quadrics not implemented yet.\n");
|
printf("Code for cylinders and quadrics not implemented yet.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Invalid primitive type \'%c\'.\n", primop);
|
printf("Invalid primitive type \'%c\'.\n", primop);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Allocate primitive elements and create indices. */
|
/* Allocate primitive elements and create indices. */
|
||||||
|
|
||||||
pe = GlobalMalloc(sizeof(ELEMENT)*curr->numelements, "geo.c");
|
pe = GlobalMalloc(sizeof(ELEMENT)*curr->numelements, "geo.c");
|
||||||
curr->pelem = pe;
|
curr->pelem = pe;
|
||||||
|
|
||||||
prim_elem_cnt += curr->numelements;
|
prim_elem_cnt += curr->numelements;
|
||||||
|
|
||||||
for (i = 1; i <= curr->numelements; i++, pe++)
|
for (i = 1; i <= curr->numelements; i++, pe++)
|
||||||
pe->index = i;
|
pe->index = i;
|
||||||
|
|
||||||
|
|
||||||
/* Read, transform, and compute bounding box for object. */
|
/* Read, transform, and compute bounding box for object. */
|
||||||
|
|
||||||
(*curr->procs->read)(curr, pf);
|
(*curr->procs->read)(curr, pf);
|
||||||
(*curr->procs->transform)(curr, model, modelInvT);
|
(*curr->procs->transform)(curr, model, modelInvT);
|
||||||
(*curr->procs->bbox)(curr);
|
(*curr->procs->bbox)(curr);
|
||||||
|
|
||||||
prev = curr;
|
prev = curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NormalizeGeo(gm->modelroot, model, modelInvT);
|
NormalizeGeo(gm->modelroot, model, modelInvT);
|
||||||
fclose(pf);
|
fclose(pf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,196 +25,195 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
VOID prn_voxel(VOXEL *v)
|
VOID prn_voxel(VOXEL *v)
|
||||||
{
|
{
|
||||||
ELEMENT *pe, **pepa;
|
ELEMENT *pe, **pepa;
|
||||||
GRID *g;
|
GRID *g;
|
||||||
INT i;
|
INT i;
|
||||||
|
|
||||||
fprintf(stderr, " Print Voxel id = %ld \n", v->id);
|
fprintf(stderr, " Print Voxel id = %ld \n", v->id);
|
||||||
fprintf(stderr, " celltype %d \n", v->celltype);
|
fprintf(stderr, " celltype %d \n", v->celltype);
|
||||||
|
|
||||||
if (v->celltype == GSM_VOXEL)
|
if (v->celltype == GSM_VOXEL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, " gsm_voxel \n");
|
fprintf(stderr, " gsm_voxel \n");
|
||||||
fprintf(stderr, " primElement index list:\n");
|
fprintf(stderr, " primElement index list:\n");
|
||||||
|
|
||||||
pepa = (ELEMENT**)v->cell;
|
pepa = (ELEMENT**)v->cell;
|
||||||
|
|
||||||
|
|
||||||
for (i=0; i < v->numelements; i++)
|
for (i=0; i < v->numelements; i++)
|
||||||
{
|
{
|
||||||
pe = pepa[i];
|
pe = pepa[i];
|
||||||
fprintf(stderr, " %ld \n", pe->index);
|
fprintf(stderr, " %ld \n", pe->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v->celltype == GSM_GRID)
|
if (v->celltype == GSM_GRID)
|
||||||
{
|
{
|
||||||
g = (GRID *)v->cell;
|
g = (GRID *)v->cell;
|
||||||
prn_grid(g);
|
prn_grid(g);
|
||||||
fprintf(stderr, " gsm_grid id %ld \n", g->id);
|
fprintf(stderr, " gsm_grid id %ld \n", g->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, " End Voxel \n");
|
fprintf(stderr, " End Voxel \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID prn_grid(GRID *g)
|
VOID prn_grid(GRID *g)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
INT n;
|
INT n;
|
||||||
GRID *ng;
|
GRID *ng;
|
||||||
VOXEL *v;
|
VOXEL *v;
|
||||||
|
|
||||||
fprintf(stderr, " Print Grid %ld \n", g->id);
|
fprintf(stderr, " Print Grid %ld \n", g->id);
|
||||||
fprintf(stderr, " num_prims = %ld \n", g->num_prims);
|
fprintf(stderr, " num_prims = %ld \n", g->num_prims);
|
||||||
fprintf(stderr, " indx_inc[0,1,2] = %ld, %ld, %ld \n", g->indx_inc[0], g->indx_inc[1], g->indx_inc[2]);
|
fprintf(stderr, " indx_inc[0,1,2] = %ld, %ld, %ld \n", g->indx_inc[0], g->indx_inc[1], g->indx_inc[2]);
|
||||||
fprintf(stderr, " num_buckets = %ld \n", g->num_buckets);
|
fprintf(stderr, " num_buckets = %ld \n", g->num_buckets);
|
||||||
fprintf(stderr, " min[0,1,2] = %lf, %lf, %lf \n", g->min[0], g->min[1], g->min[2] );
|
fprintf(stderr, " min[0,1,2] = %lf, %lf, %lf \n", g->min[0], g->min[1], g->min[2] );
|
||||||
fprintf(stderr, " cellsize[0,1,2] = %lf, %lf, %lf \n", g->cellsize[0], g->cellsize[1], g->cellsize[2]);
|
fprintf(stderr, " cellsize[0,1,2] = %lf, %lf, %lf \n", g->cellsize[0], g->cellsize[1], g->cellsize[2]);
|
||||||
fprintf(stderr, " subdiv_level = %ld \n", g->subdiv_level);
|
fprintf(stderr, " subdiv_level = %ld \n", g->subdiv_level);
|
||||||
|
|
||||||
if (g->next != NULL)
|
if (g->next != NULL)
|
||||||
{
|
{
|
||||||
ng = g->next;
|
ng = g->next;
|
||||||
fprintf(stderr, " next grid id %ld \n", ng->id);
|
fprintf(stderr, " next grid id %ld \n", ng->id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(stderr, " next grid id NULL \n");
|
fprintf(stderr, " next grid id NULL \n");
|
||||||
|
|
||||||
fprintf(stderr, " Voxel List \n");
|
fprintf(stderr, " Voxel List \n");
|
||||||
|
|
||||||
n = g->indx_inc[1] * g->indx_inc[2];
|
n = g->indx_inc[1] * g->indx_inc[2];
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
if (lookup_emptycells(i, g) == EMPTY)
|
if (lookup_emptycells(i, g) == EMPTY)
|
||||||
fprintf(stderr, " Voxel %ld is empty. \n", i);
|
fprintf(stderr, " Voxel %ld is empty. \n", i);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v = lookup_hashtable(i, g);
|
v = lookup_hashtable(i, g);
|
||||||
prn_voxel(v);
|
prn_voxel(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fprintf(stderr, " End Grid \n");
|
fprintf(stderr, " End Grid \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID prn_ray(RAY *r)
|
VOID prn_ray(RAY *r)
|
||||||
{
|
{
|
||||||
RAYINFO *ri;
|
RAYINFO *ri;
|
||||||
GRID *g;
|
GRID *g;
|
||||||
|
|
||||||
fprintf(stderr, " Print Ray id %ld \n", r->id );
|
fprintf(stderr, " Print Ray id %ld \n", r->id );
|
||||||
fprintf(stderr, " origin: ( %lf, %lf, %lf ) \n", r->P[0], r->P[1], r->P[2]);
|
fprintf(stderr, " origin: ( %lf, %lf, %lf ) \n", r->P[0], r->P[1], r->P[2]);
|
||||||
fprintf(stderr, " direction: ( %lf, %lf, %lf ) \n", r->D[0], r->D[1], r->D[2] );
|
fprintf(stderr, " direction: ( %lf, %lf, %lf ) \n", r->D[0], r->D[1], r->D[2] );
|
||||||
fprintf(stderr, " indx_inc3D[0,1,2] = [ %ld, %ld, %ld ] \n", r->indx_inc3D[0],r->indx_inc3D[1],r->indx_inc3D[2] );
|
fprintf(stderr, " indx_inc3D[0,1,2] = [ %ld, %ld, %ld ] \n", r->indx_inc3D[0],r->indx_inc3D[1],r->indx_inc3D[2] );
|
||||||
fprintf(stderr, " ri_indx = %ld \n", r->ri_indx);
|
fprintf(stderr, " ri_indx = %ld \n", r->ri_indx);
|
||||||
fprintf(stderr, " rayinfo: \n");
|
fprintf(stderr, " rayinfo: \n");
|
||||||
|
|
||||||
ri = r->ri;
|
ri = r->ri;
|
||||||
g = ri->grid;
|
g = ri->grid;
|
||||||
|
|
||||||
fprintf(stderr, " ray is in grid %ld \n", g->id );
|
fprintf(stderr, " ray is in grid %ld \n", g->id );
|
||||||
fprintf(stderr, " d[0,1,2] = [ %lf, %lf, %lf ] \n", ri->d[0], ri->d[1], ri->d[2]);
|
fprintf(stderr, " d[0,1,2] = [ %lf, %lf, %lf ] \n", ri->d[0], ri->d[1], ri->d[2]);
|
||||||
fprintf(stderr, " entry_plane %ld \n", ri->entry_plane );
|
fprintf(stderr, " entry_plane %ld \n", ri->entry_plane );
|
||||||
fprintf(stderr, " t_in = %lf \n", ri->t_in );
|
fprintf(stderr, " t_in = %lf \n", ri->t_in );
|
||||||
fprintf(stderr, " exit_plane %ld \n", ri->exit_plane );
|
fprintf(stderr, " exit_plane %ld \n", ri->exit_plane );
|
||||||
fprintf(stderr, " t_out = %lf \n", ri->t_out );
|
fprintf(stderr, " t_out = %lf \n", ri->t_out );
|
||||||
fprintf(stderr, " delta[0,1,2] = [ %lf, %lf, %lf ] \n", ri->delta[0], ri->delta[1], ri->delta[2]);
|
fprintf(stderr, " delta[0,1,2] = [ %lf, %lf, %lf ] \n", ri->delta[0], ri->delta[1], ri->delta[2]);
|
||||||
fprintf(stderr, " index3D[0,1,2] = [ %ld, %ld, %ld ] \n", ri->index3D[0], ri->index3D[1], ri->index3D[2]);
|
fprintf(stderr, " index3D[0,1,2] = [ %ld, %ld, %ld ] \n", ri->index3D[0], ri->index3D[1], ri->index3D[2]);
|
||||||
fprintf(stderr, " index1D = %ld \n", ri->index1D );
|
fprintf(stderr, " index1D = %ld \n", ri->index1D );
|
||||||
fprintf(stderr, " indx_inc1D[0,1,2] = [ %ld, %ld, %ld ] \n", ri->indx_inc1D[0], ri->indx_inc1D[1], ri->indx_inc1D[2]);
|
fprintf(stderr, " indx_inc1D[0,1,2] = [ %ld, %ld, %ld ] \n", ri->indx_inc1D[0], ri->indx_inc1D[1], ri->indx_inc1D[2]);
|
||||||
fprintf(stderr, " End Ray \n");
|
fprintf(stderr, " End Ray \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID prn_PrimElem(ELEMENT *p)
|
VOID prn_PrimElem(ELEMENT *p)
|
||||||
{
|
{
|
||||||
BBOX b;
|
BBOX b;
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: prn_PrimElem: Null pointer.\n", ProgName);
|
fprintf(stderr, "%s: prn_PrimElem: Null pointer.\n", ProgName);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "PrimElem: index %ld ptr %p, PrimObj index %ld ptr %p \n",
|
fprintf(stderr, "PrimElem: index %ld ptr %p, PrimObj index %ld ptr %p \n",
|
||||||
p->index, p, p->parent->index, p->parent);
|
p->index, p, p->parent->index, p->parent);
|
||||||
|
|
||||||
b = p->bv;
|
b = p->bv;
|
||||||
|
|
||||||
fprintf(stderr, " BBox: ( %lf, %lf, %lf ) -> \n ( %lf, %lf, %lf ) \n",
|
fprintf(stderr, " BBox: ( %lf, %lf, %lf ) -> \n ( %lf, %lf, %lf ) \n",
|
||||||
b.dnear[0],b.dnear[1],b.dnear[2],b.dfar[0],b.dfar[1],b.dfar[2] );
|
b.dnear[0],b.dnear[1],b.dnear[2],b.dfar[0],b.dfar[1],b.dfar[2] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID prn_bintree_node(BTNODE *b)
|
VOID prn_bintree_node(BTNODE *b)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
|
|
||||||
fprintf(stderr, "Bintree node: \n");
|
fprintf(stderr, "Bintree node: \n");
|
||||||
fprintf(stderr, " indecies of cell: ( %ld, %ld, %ld ) \n", b->i[0], b->i[1], b->i[2]);
|
fprintf(stderr, " indecies of cell: ( %ld, %ld, %ld ) \n", b->i[0], b->i[1], b->i[2]);
|
||||||
fprintf(stderr, " gridsizes: ( %ld, %ld, %ld ) \n", b->n[0], b->n[1], b->n[2]);
|
fprintf(stderr, " gridsizes: ( %ld, %ld, %ld ) \n", b->n[0], b->n[1], b->n[2]);
|
||||||
fprintf(stderr, " minimum point ( %lf, %lf, %lf ) \n", b->p[0], b->p[1], b->p[2]);
|
fprintf(stderr, " minimum point ( %lf, %lf, %lf ) \n", b->p[0], b->p[1], b->p[2]);
|
||||||
fprintf(stderr, " subdiv axis %ld \n", b->axis);
|
fprintf(stderr, " subdiv axis %ld \n", b->axis);
|
||||||
fprintf(stderr, " number of primitives %ld \n", b->nprims);
|
fprintf(stderr, " number of primitives %ld \n", b->nprims);
|
||||||
fprintf(stderr, " Primitive element list: \n");
|
fprintf(stderr, " Primitive element list: \n");
|
||||||
|
|
||||||
if (b->nprims > 0)
|
if (b->nprims > 0)
|
||||||
for (i = 0; i < b->nprims; i++)
|
for (i = 0; i < b->nprims; i++)
|
||||||
{
|
{
|
||||||
fprintf(stderr, " %ld", b->pe[i]->index);
|
fprintf(stderr, " %ld", b->pe[i]->index);
|
||||||
|
|
||||||
if (i % 8 == 7)
|
if (i % 8 == 7)
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "\n End of bintree node \n");
|
fprintf(stderr, "\n End of bintree node \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VOID prn_bintree_leaves(BTNODE *root)
|
VOID prn_bintree_leaves(BTNODE *root)
|
||||||
{
|
{
|
||||||
BTNODE *b;
|
BTNODE *b;
|
||||||
|
|
||||||
b = root;
|
b = root;
|
||||||
if (b->axis == -1)
|
if (b->axis == -1)
|
||||||
prn_bintree_node(b);
|
prn_bintree_node(b);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prn_bintree_leaves(b->btn[0]);
|
prn_bintree_leaves(b->btn[0]);
|
||||||
prn_bintree_leaves(b->btn[1]);
|
prn_bintree_leaves(b->btn[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID prn_pepa_prim_list(ELEMENT **pepa, INT nprims)
|
VOID prn_pepa_prim_list(ELEMENT **pepa, INT nprims)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
|
|
||||||
if (nprims > 0)
|
if (nprims > 0)
|
||||||
{
|
{
|
||||||
for (i = 0; i < nprims; i++)
|
for (i = 0; i < nprims; i++)
|
||||||
{
|
{
|
||||||
fprintf(stderr, " %ld", pepa[i]->index);
|
fprintf(stderr, " %ld", pepa[i]->index);
|
||||||
|
|
||||||
if (i % 8 == 7)
|
if (i % 8 == 7)
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME
|
* NAME
|
||||||
* Huniform_defaults - setup the five HUG parameter defaults
|
* Huniform_defaults - setup the five HUG parameter defaults
|
||||||
|
@ -43,13 +44,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID Huniform_defaults()
|
VOID Huniform_defaults()
|
||||||
{
|
{
|
||||||
hu_max_prims_cell = 2;
|
hu_max_prims_cell = 2;
|
||||||
hu_gridsize = 5;
|
hu_gridsize = 5;
|
||||||
hu_numbuckets = 23;
|
hu_numbuckets = 23;
|
||||||
hu_max_subdiv_level = 1;
|
hu_max_subdiv_level = 1;
|
||||||
hu_lazy = 0;
|
hu_lazy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,27 +67,27 @@ VOID Huniform_defaults()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID BuildHierarchy_Uniform()
|
VOID BuildHierarchy_Uniform()
|
||||||
{
|
{
|
||||||
INT num_pe;
|
INT num_pe;
|
||||||
GRID *g;
|
GRID *g;
|
||||||
GRID *ng;
|
GRID *ng;
|
||||||
VOXEL *v;
|
VOXEL *v;
|
||||||
ELEMENT **pepa;
|
ELEMENT **pepa;
|
||||||
|
|
||||||
init_masks();
|
init_masks();
|
||||||
|
|
||||||
|
|
||||||
pepa = MakeElementArray(&num_pe);
|
pepa = MakeElementArray(&num_pe);
|
||||||
|
|
||||||
v = init_world_voxel(pepa,num_pe);
|
v = init_world_voxel(pepa,num_pe);
|
||||||
|
|
||||||
gm->world_level_grid = init_world_grid(v, pepa, num_pe);
|
gm->world_level_grid = init_world_grid(v, pepa, num_pe);
|
||||||
g = gm->world_level_grid;
|
g = gm->world_level_grid;
|
||||||
|
|
||||||
ng = create_grid(v, g, num_pe);
|
ng = create_grid(v, g, num_pe);
|
||||||
|
|
||||||
fprintf(stderr, "Uniform Hierarchy built.\n");
|
fprintf(stderr, "Uniform Hierarchy built.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,34 +109,34 @@ VOID BuildHierarchy_Uniform()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID IntersectHuniformPrimlist(INT *intersectPrim, IRECORD *hit, VOXEL *v, RAY *r, INT pid)
|
VOID IntersectHuniformPrimlist(INT *intersectPrim, IRECORD *hit, VOXEL *v, RAY *r, INT pid)
|
||||||
{
|
{
|
||||||
ELEMENT **pptr; /* Primitive element list ptr. */
|
ELEMENT **pptr; /* Primitive element list ptr. */
|
||||||
OBJECT *peParent; /* Ptr to parent object. */
|
OBJECT *peParent; /* Ptr to parent object. */
|
||||||
ELEMENT *pe; /* Primitive element ptr. */
|
ELEMENT *pe; /* Primitive element ptr. */
|
||||||
IRECORD newhit[ISECT_MAX]; /* Hit recorder. */
|
IRECORD newhit[ISECT_MAX]; /* Hit recorder. */
|
||||||
INT hitcode,i;
|
INT hitcode,i;
|
||||||
REAL t_out;
|
REAL t_out;
|
||||||
|
|
||||||
t_out = r->ri->t_out;
|
t_out = r->ri->t_out;
|
||||||
hit[0].t = HUGE_REAL;
|
hit[0].t = HUGE_REAL;
|
||||||
pptr = (ELEMENT**)v->cell;
|
pptr = (ELEMENT**)v->cell;
|
||||||
|
|
||||||
for (i = 0; i < v->numelements; i++)
|
for (i = 0; i < v->numelements; i++)
|
||||||
{
|
{
|
||||||
pe = pptr[i];
|
pe = pptr[i];
|
||||||
peParent = pe->parent;
|
peParent = pe->parent;
|
||||||
hitcode = (*peParent->procs->pe_intersect)(r, pe, newhit);
|
hitcode = (*peParent->procs->pe_intersect)(r, pe, newhit);
|
||||||
|
|
||||||
if (hitcode)
|
if (hitcode)
|
||||||
if (newhit[0].t < hit[0].t && newhit[0].t < t_out)
|
if (newhit[0].t < hit[0].t && newhit[0].t < t_out)
|
||||||
hit[0] = newhit[0];
|
hit[0] = newhit[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hit[0].t < HUGE_REAL)
|
if (hit[0].t < HUGE_REAL)
|
||||||
*intersectPrim = TRUE;
|
*intersectPrim = TRUE;
|
||||||
else
|
else
|
||||||
*intersectPrim = FALSE;
|
*intersectPrim = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,56 +157,56 @@ VOID IntersectHuniformPrimlist(INT *intersectPrim, IRECORD *hit, VOXEL *v, RAY *
|
||||||
*/
|
*/
|
||||||
|
|
||||||
REAL HuniformShadowIntersect(RAY *r, REAL lightlength, ELEMENT *pe, INT pid)
|
REAL HuniformShadowIntersect(RAY *r, REAL lightlength, ELEMENT *pe, INT pid)
|
||||||
{
|
{
|
||||||
INT status;
|
INT status;
|
||||||
INT hitcode,i;
|
INT hitcode,i;
|
||||||
REAL trans; /* Transparency factor. */
|
REAL trans; /* Transparency factor. */
|
||||||
OBJECT *peParent; /* Ptr to parent object. */
|
OBJECT *peParent; /* Ptr to parent object. */
|
||||||
ELEMENT **pptr; /* Primitive element list ptr. */
|
ELEMENT **pptr; /* Primitive element list ptr. */
|
||||||
ELEMENT *pe2; /* Ptr to element. */
|
ELEMENT *pe2; /* Ptr to element. */
|
||||||
IRECORD newhit[ISECT_MAX]; /* Hit record. */
|
IRECORD newhit[ISECT_MAX]; /* Hit record. */
|
||||||
VOXEL *v;
|
VOXEL *v;
|
||||||
|
|
||||||
trans = 1.0;
|
trans = 1.0;
|
||||||
|
|
||||||
/* Now try uniform hierarchy. */
|
/* Now try uniform hierarchy. */
|
||||||
|
|
||||||
r->ri = NULL;
|
r->ri = NULL;
|
||||||
v = init_ray(r, gm->world_level_grid);
|
v = init_ray(r, gm->world_level_grid);
|
||||||
|
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
{
|
{
|
||||||
reset_rayinfo(r);
|
reset_rayinfo(r);
|
||||||
return(trans);
|
return(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
newhit[0].t = HUGE_REAL;
|
newhit[0].t = HUGE_REAL;
|
||||||
status = IN_WORLD;
|
status = IN_WORLD;
|
||||||
|
|
||||||
while (trans > 0.0 && status != EXITED_WORLD)
|
while (trans > 0.0 && status != EXITED_WORLD)
|
||||||
{
|
{
|
||||||
/* Intersect primitives in cell. */
|
/* Intersect primitives in cell. */
|
||||||
|
|
||||||
pptr = (ELEMENT**)v->cell;
|
pptr = (ELEMENT**)v->cell;
|
||||||
|
|
||||||
for (i = 0; (i < v->numelements) && (trans > 0.0); i++)
|
for (i = 0; (i < v->numelements) && (trans > 0.0); i++)
|
||||||
{
|
{
|
||||||
pe2 = pptr[i];
|
pe2 = pptr[i];
|
||||||
peParent = pe2->parent;
|
peParent = pe2->parent;
|
||||||
hitcode = (*peParent->procs->pe_intersect)(r, pe2, newhit);
|
hitcode = (*peParent->procs->pe_intersect)(r, pe2, newhit);
|
||||||
|
|
||||||
if (hitcode && newhit[0].pelem != pe && newhit[0].t < lightlength)
|
if (hitcode && newhit[0].pelem != pe && newhit[0].t < lightlength)
|
||||||
trans *= newhit[0].pelem->parent->surf->ktran;
|
trans *= newhit[0].pelem->parent->surf->ktran;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans > 0.0)
|
if (trans > 0.0)
|
||||||
v = next_nonempty_leaf(r, STEP, &status);
|
v = next_nonempty_leaf(r, STEP, &status);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_rayinfo(r);
|
reset_rayinfo(r);
|
||||||
return (trans);
|
return (trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -225,33 +226,33 @@ REAL HuniformShadowIntersect(RAY *r, REAL lightlength, ELEMENT *pe, INT pid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL TraverseHierarchyUniform(RAY *r, IRECORD *hit, INT pid)
|
BOOL TraverseHierarchyUniform(RAY *r, IRECORD *hit, INT pid)
|
||||||
{
|
{
|
||||||
INT status;
|
INT status;
|
||||||
INT intersectPrim;
|
INT intersectPrim;
|
||||||
VOXEL *v;
|
VOXEL *v;
|
||||||
|
|
||||||
r->ri = NULL;
|
r->ri = NULL;
|
||||||
v = init_ray(r, gm->world_level_grid);
|
v = init_ray(r, gm->world_level_grid);
|
||||||
|
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
{
|
{
|
||||||
reset_rayinfo(r);
|
reset_rayinfo(r);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
intersectPrim = FALSE;
|
intersectPrim = FALSE;
|
||||||
hit[0].t = HUGE_REAL;
|
hit[0].t = HUGE_REAL;
|
||||||
status = IN_WORLD;
|
status = IN_WORLD;
|
||||||
|
|
||||||
while (!intersectPrim && status != EXITED_WORLD)
|
while (!intersectPrim && status != EXITED_WORLD)
|
||||||
{
|
{
|
||||||
IntersectHuniformPrimlist(&intersectPrim, hit, v, r, pid);
|
IntersectHuniformPrimlist(&intersectPrim, hit, v, r, pid);
|
||||||
|
|
||||||
if (!intersectPrim)
|
if (!intersectPrim)
|
||||||
v = next_nonempty_leaf(r, STEP, &status);
|
v = next_nonempty_leaf(r, STEP, &status);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_rayinfo(r);
|
reset_rayinfo(r);
|
||||||
return (intersectPrim);
|
return (intersectPrim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,11 +26,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME
|
* NAME
|
||||||
* Intersect - intersect ray with objects in linked list
|
* Intersect - intersect ray with objects in linked list
|
||||||
|
@ -45,28 +46,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL Intersect(RAY *pr, IRECORD *hit)
|
BOOL Intersect(RAY *pr, IRECORD *hit)
|
||||||
{
|
{
|
||||||
OBJECT *po; /* Ptr to the object. */
|
OBJECT *po; /* Ptr to the object. */
|
||||||
IRECORD newhit; /* New intersection. */
|
IRECORD newhit; /* New intersection. */
|
||||||
|
|
||||||
po = gm->modelroot;
|
po = gm->modelroot;
|
||||||
hit->t = HUGE_REAL;
|
hit->t = HUGE_REAL;
|
||||||
hit->pelem = NULL;
|
hit->pelem = NULL;
|
||||||
|
|
||||||
while (po)
|
while (po)
|
||||||
{
|
{
|
||||||
if ((*po->procs->intersect)(pr, po, &newhit))
|
if ((*po->procs->intersect)(pr, po, &newhit))
|
||||||
if (newhit.t < hit[0].t)
|
if (newhit.t < hit[0].t)
|
||||||
*hit = newhit;
|
*hit = newhit;
|
||||||
|
|
||||||
po = po->next;
|
po = po->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hit->t < HUGE_REAL)
|
if (hit->t < HUGE_REAL)
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
else
|
else
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,22 +89,22 @@ BOOL Intersect(RAY *pr, IRECORD *hit)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
REAL ShadowIntersect(RAY *pr, REAL lightdist, ELEMENT *pe)
|
REAL ShadowIntersect(RAY *pr, REAL lightdist, ELEMENT *pe)
|
||||||
{
|
{
|
||||||
REAL trans; /* Transparency factor. */
|
REAL trans; /* Transparency factor. */
|
||||||
OBJECT *po; /* Ptr to the object. */
|
OBJECT *po; /* Ptr to the object. */
|
||||||
IRECORD newhit; /* New hit record. */
|
IRECORD newhit; /* New hit record. */
|
||||||
|
|
||||||
trans = 1.0;
|
trans = 1.0;
|
||||||
po = gm->modelroot;
|
po = gm->modelroot;
|
||||||
|
|
||||||
while (po && trans > 0.0)
|
while (po && trans > 0.0)
|
||||||
{
|
{
|
||||||
if ((*po->procs->intersect)(pr, po, &newhit) && newhit.pelem != pe && newhit.t < lightdist)
|
if ((*po->procs->intersect)(pr, po, &newhit) && newhit.pelem != pe && newhit.t < lightdist)
|
||||||
trans *= newhit.pelem->parent->surf->ktran;
|
trans *= newhit.pelem->parent->surf->ktran;
|
||||||
|
|
||||||
po = po->next;
|
po = po->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (trans);
|
return (trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,11 +80,11 @@
|
||||||
#define VERSION "1.00"
|
#define VERSION "1.00"
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
CHAR *ProgName = "RAYTRACE"; /* The program name. */
|
CHAR *ProgName = "RAYTRACE"; /* The program name. */
|
||||||
INT nprocs = 1; /* The number of processors to use. */
|
INT nprocs = 1; /* The number of processors to use. */
|
||||||
INT MaxGlobMem = 32; /* Maximum global memory needed (MB).*/
|
INT MaxGlobMem = 32; /* Maximum global memory needed (MB).*/
|
||||||
|
@ -104,19 +104,19 @@ INT dostats = 0;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID Usage()
|
VOID Usage()
|
||||||
{
|
{
|
||||||
fprintf(stdout, "%s - parallel ray tracer\n", ProgName);
|
fprintf(stdout, "%s - parallel ray tracer\n", ProgName);
|
||||||
fprintf(stdout, "Version %s\n\n", VERSION);
|
fprintf(stdout, "Version %s\n\n", VERSION);
|
||||||
|
|
||||||
fprintf(stdout, "Usage:\t%s [options] envfile\n\n", ProgName);
|
fprintf(stdout, "Usage:\t%s [options] envfile\n\n", ProgName);
|
||||||
|
|
||||||
fprintf(stdout, "\t-h\tPrint this usage message.\n");
|
fprintf(stdout, "\t-h\tPrint this usage message.\n");
|
||||||
fprintf(stdout, "\t-a<n>\tEnable antialiasing with n subpixels (default = 1).\n\tWhen using with SPLASH suite for evaluation, use default (no antialiasing)\n");
|
fprintf(stdout, "\t-a<n>\tEnable antialiasing with n subpixels (default = 1).\n\tWhen using with SPLASH suite for evaluation, use default (no antialiasing)\n");
|
||||||
fprintf(stdout, "\t-m<n>\tRequest n megabytes of global memory (default = 32).\n");
|
fprintf(stdout, "\t-m<n>\tRequest n megabytes of global memory (default = 32).\n");
|
||||||
fprintf(stdout, "\t-p<n>\tRun on n processors (default = 1).\n");
|
fprintf(stdout, "\t-p<n>\tRun on n processors (default = 1).\n");
|
||||||
fprintf(stdout, "\t-s\tMeasure and print per-process timing information.\n");
|
fprintf(stdout, "\t-s\tMeasure and print per-process timing information.\n");
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,37 +132,37 @@ VOID Usage()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID PrintStatistics()
|
VOID PrintStatistics()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
printf("\n****** Ray trace Stats ******\n");
|
printf("\n****** Ray trace Stats ******\n");
|
||||||
|
|
||||||
printf("\tResolution:\t\t%ld by %ld\n", Display.xres+1, Display.yres+1);
|
printf("\tResolution:\t\t%ld by %ld\n", Display.xres+1, Display.yres+1);
|
||||||
printf("\tNumber Lights:\t\t%ld\n", nlights);
|
printf("\tNumber Lights:\t\t%ld\n", nlights);
|
||||||
printf("\tAnti level:\t\t%ld\n", Display.maxAAsubdiv);
|
printf("\tAnti level:\t\t%ld\n", Display.maxAAsubdiv);
|
||||||
printf("\tTotal Rays:\t\t%ld\n", Stats.total_rays);
|
printf("\tTotal Rays:\t\t%ld\n", Stats.total_rays);
|
||||||
printf("\tPrimary Rays:\t\t%ld\n", Stats.prim_rays);
|
printf("\tPrimary Rays:\t\t%ld\n", Stats.prim_rays);
|
||||||
printf("\tShadow Rays:\t\t%ld\n", Stats.shad_rays);
|
printf("\tShadow Rays:\t\t%ld\n", Stats.shad_rays);
|
||||||
printf("\tShadow Rays Hit:\t%ld\n", Stats.shad_rays_hit);
|
printf("\tShadow Rays Hit:\t%ld\n", Stats.shad_rays_hit);
|
||||||
printf("\tShadow Rays Not Hit:\t%ld\n", Stats.shad_rays_not_hit);
|
printf("\tShadow Rays Not Hit:\t%ld\n", Stats.shad_rays_not_hit);
|
||||||
printf("\tShadow Coherence Rays:\t%ld\n", Stats.shad_coherence_rays);
|
printf("\tShadow Coherence Rays:\t%ld\n", Stats.shad_coherence_rays);
|
||||||
printf("\tReflective Rays:\t%ld\n", Stats.refl_rays);
|
printf("\tReflective Rays:\t%ld\n", Stats.refl_rays);
|
||||||
printf("\tTransmissiveRays:\t%ld\n", Stats.trans_rays);
|
printf("\tTransmissiveRays:\t%ld\n", Stats.trans_rays);
|
||||||
printf("\tAnti-Aliasing Rays:\t%ld\n", Stats.aa_rays);
|
printf("\tAnti-Aliasing Rays:\t%ld\n", Stats.aa_rays);
|
||||||
printf("\tBackground Pixels:\t%ld\n", Stats.coverage);
|
printf("\tBackground Pixels:\t%ld\n", Stats.coverage);
|
||||||
printf("\tMax Tree depth reached:\t%ld\n", Stats.max_tree_depth);
|
printf("\tMax Tree depth reached:\t%ld\n", Stats.max_tree_depth);
|
||||||
printf("\tMax # prims tested for a ray:\t%ld\n", Stats.max_objs_ray);
|
printf("\tMax # prims tested for a ray:\t%ld\n", Stats.max_objs_ray);
|
||||||
printf("\tMax Rays shot for a pixel:\t%ld\n", Stats.max_rays_pixel);
|
printf("\tMax Rays shot for a pixel:\t%ld\n", Stats.max_rays_pixel);
|
||||||
printf("\tMax # prims tested for a pixel:\t%ld\n", Stats.max_objs_pixel);
|
printf("\tMax # prims tested for a pixel:\t%ld\n", Stats.max_objs_pixel);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (TraversalType == TT_HUG)
|
if (TraversalType == TT_HUG)
|
||||||
{
|
{
|
||||||
/* prn_ds_stats();
|
/* prn_ds_stats();
|
||||||
prn_tv_stats(); */
|
prn_tv_stats(); */
|
||||||
ma_print();
|
ma_print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,47 +178,47 @@ VOID PrintStatistics()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID StartRayTrace()
|
VOID StartRayTrace()
|
||||||
{
|
{
|
||||||
INT pid; /* Our internal process id number. */
|
INT pid; /* Our internal process id number. */
|
||||||
UINT begin;
|
UINT begin;
|
||||||
UINT end;
|
UINT end;
|
||||||
|
|
||||||
LOCK(gm->pidlock)
|
LOCK(gm->pidlock)
|
||||||
pid = gm->pid++;
|
pid = gm->pid++;
|
||||||
UNLOCK(gm->pidlock)
|
UNLOCK(gm->pidlock)
|
||||||
|
|
||||||
BARINCLUDE(gm->start);
|
BARINCLUDE(gm->start);
|
||||||
|
|
||||||
if ((pid == 0) || (dostats))
|
if ((pid == 0) || (dostats))
|
||||||
CLOCK(begin);
|
CLOCK(begin);
|
||||||
|
|
||||||
/* POSSIBLE ENHANCEMENT: Here's where one might lock processes down
|
/* POSSIBLE ENHANCEMENT: Here's where one might lock processes down
|
||||||
to processors if need be */
|
to processors if need be */
|
||||||
|
|
||||||
InitWorkPool(pid);
|
InitWorkPool(pid);
|
||||||
InitRayTreeStack(Display.maxlevel, pid);
|
InitRayTreeStack(Display.maxlevel, pid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for all processes to be created, initialize their work
|
* Wait for all processes to be created, initialize their work
|
||||||
* pools, and arrive at this point; then proceed. This BARRIER
|
* pools, and arrive at this point; then proceed. This BARRIER
|
||||||
* is absolutely required. Read comments in PutJob before
|
* is absolutely required. Read comments in PutJob before
|
||||||
* moving this barrier.
|
* moving this barrier.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BARRIER(gm->start, gm->nprocs)
|
BARRIER(gm->start, gm->nprocs)
|
||||||
|
|
||||||
/* POSSIBLE ENHANCEMENT: Here's where one would RESET STATISTICS
|
/* POSSIBLE ENHANCEMENT: Here's where one would RESET STATISTICS
|
||||||
and TIMING if one wanted to measure only the parallel part */
|
and TIMING if one wanted to measure only the parallel part */
|
||||||
|
|
||||||
RayTrace(pid);
|
RayTrace(pid);
|
||||||
|
|
||||||
|
|
||||||
if ((pid == 0) || (dostats)) {
|
if ((pid == 0) || (dostats)) {
|
||||||
CLOCK(end);
|
CLOCK(end);
|
||||||
gm->partime[pid] = (end - begin) & 0x7FFFFFFF;
|
gm->partime[pid] = (end - begin) & 0x7FFFFFFF;
|
||||||
if (pid == 0) gm->par_start_time = begin;
|
if (pid == 0) gm->par_start_time = begin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,191 +242,191 @@ VOID StartRayTrace()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(int argc, CHAR *argv[])
|
int main(int argc, CHAR *argv[])
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
UINT begin;
|
UINT begin;
|
||||||
UINT end;
|
UINT end;
|
||||||
UINT lapsed;
|
UINT lapsed;
|
||||||
MATRIX vtrans, Vinv; /* View transformation and inverse. */
|
MATRIX vtrans, Vinv; /* View transformation and inverse. */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First, process command line arguments.
|
* First, process command line arguments.
|
||||||
*/
|
*/
|
||||||
i = 1;
|
i = 1;
|
||||||
while ((i < argc) && (argv[i][0] == '-')) {
|
while ((i < argc) && (argv[i][0] == '-')) {
|
||||||
switch (argv[i][1]) {
|
switch (argv[i][1]) {
|
||||||
case '?':
|
case '?':
|
||||||
case 'h':
|
case 'h':
|
||||||
case 'H':
|
case 'H':
|
||||||
Usage();
|
Usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'A':
|
case 'A':
|
||||||
AntiAlias = TRUE;
|
AntiAlias = TRUE;
|
||||||
if (argv[i][2] != '\0') {
|
if (argv[i][2] != '\0') {
|
||||||
NumSubRays = atoi(&argv[i][2]);
|
NumSubRays = atoi(&argv[i][2]);
|
||||||
} else {
|
} else {
|
||||||
NumSubRays = atoi(&argv[++i][0]);
|
NumSubRays = atoi(&argv[++i][0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
if (argv[i][2] != '\0') {
|
if (argv[i][2] != '\0') {
|
||||||
MaxGlobMem = atoi(&argv[i][2]);
|
MaxGlobMem = atoi(&argv[i][2]);
|
||||||
} else {
|
} else {
|
||||||
MaxGlobMem = atoi(&argv[++i][0]);
|
MaxGlobMem = atoi(&argv[++i][0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
if (argv[i][2] != '\0') {
|
if (argv[i][2] != '\0') {
|
||||||
nprocs = atoi(&argv[i][2]);
|
nprocs = atoi(&argv[i][2]);
|
||||||
} else {
|
} else {
|
||||||
nprocs = atoi(&argv[++i][0]);
|
nprocs = atoi(&argv[++i][0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
case 'S':
|
case 'S':
|
||||||
dostats = TRUE;
|
dostats = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: Invalid option \'%c\'.\n", ProgName, argv[i][0]);
|
fprintf(stderr, "%s: Invalid option \'%c\'.\n", ProgName, argv[i][0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == argc) {
|
if (i == argc) {
|
||||||
Usage();
|
Usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure nprocs is within valid range.
|
* Make sure nprocs is within valid range.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (nprocs < 1 || nprocs > MAX_PROCS)
|
if (nprocs < 1 || nprocs > MAX_PROCS)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: Valid range for #processors is [1, %d].\n", ProgName, MAX_PROCS);
|
fprintf(stderr, "%s: Valid range for #processors is [1, %d].\n", ProgName, MAX_PROCS);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print command line parameters.
|
* Print command line parameters.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Number of processors: \t%ld\n", nprocs);
|
printf("Number of processors: \t%ld\n", nprocs);
|
||||||
printf("Global shared memory size:\t%ld MB\n", MaxGlobMem);
|
printf("Global shared memory size:\t%ld MB\n", MaxGlobMem);
|
||||||
printf("Samples per pixel: \t%ld\n", NumSubRays);
|
printf("Samples per pixel: \t%ld\n", NumSubRays);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the shared memory environment and request the total
|
* Initialize the shared memory environment and request the total
|
||||||
* amount of amount of shared memory we might need. This
|
* amount of amount of shared memory we might need. This
|
||||||
* includes memory for the database, grid, and framebuffer.
|
* includes memory for the database, grid, and framebuffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MaxGlobMem <<= 20; /* Convert MB to bytes. */
|
MaxGlobMem <<= 20; /* Convert MB to bytes. */
|
||||||
MAIN_INITENV(,MaxGlobMem + 512*1024)
|
MAIN_INITENV(,MaxGlobMem + 512*1024)
|
||||||
gm = (GMEM *)G_MALLOC(sizeof(GMEM));
|
gm = (GMEM *)G_MALLOC(sizeof(GMEM));
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform shared environment initializations.
|
* Perform shared environment initializations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gm->nprocs = nprocs;
|
gm->nprocs = nprocs;
|
||||||
gm->pid = 0;
|
gm->pid = 0;
|
||||||
gm->rid = 1;
|
gm->rid = 1;
|
||||||
|
|
||||||
BARINIT(gm->start, nprocs)
|
BARINIT(gm->start, nprocs)
|
||||||
LOCKINIT(gm->pidlock)
|
LOCKINIT(gm->pidlock)
|
||||||
LOCKINIT(gm->ridlock)
|
LOCKINIT(gm->ridlock)
|
||||||
LOCKINIT(gm->memlock)
|
LOCKINIT(gm->memlock)
|
||||||
ALOCKINIT(gm->wplock, nprocs)
|
ALOCKINIT(gm->wplock, nprocs)
|
||||||
|
|
||||||
/* POSSIBLE ENHANCEMENT: Here is where one might distribute the
|
/* POSSIBLE ENHANCEMENT: Here is where one might distribute the
|
||||||
raystruct data structure across physically distributed memories as
|
raystruct data structure across physically distributed memories as
|
||||||
desired. */
|
desired. */
|
||||||
|
|
||||||
if (!GlobalHeapInit(MaxGlobMem))
|
if (!GlobalHeapInit(MaxGlobMem))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: Cannot initialize global heap.\n", ProgName);
|
fprintf(stderr, "%s: Cannot initialize global heap.\n", ProgName);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize HUG parameters, read environment and geometry files.
|
* Initialize HUG parameters, read environment and geometry files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Huniform_defaults();
|
Huniform_defaults();
|
||||||
ReadEnvFile(/* *argv*/argv[i]);
|
ReadEnvFile(/* *argv*/argv[i]);
|
||||||
ReadGeoFile(GeoFileName);
|
ReadGeoFile(GeoFileName);
|
||||||
OpenFrameBuffer();
|
OpenFrameBuffer();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute view transform and its inverse.
|
* Compute view transform and its inverse.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CreateViewMatrix();
|
CreateViewMatrix();
|
||||||
MatrixCopy(vtrans, View.vtrans);
|
MatrixCopy(vtrans, View.vtrans);
|
||||||
MatrixInverse(Vinv, vtrans);
|
MatrixInverse(Vinv, vtrans);
|
||||||
MatrixCopy(View.vtransInv, Vinv);
|
MatrixCopy(View.vtransInv, Vinv);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print out what we have so far.
|
* Print out what we have so far.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
printf("Number of primitive objects: \t%ld\n", prim_obj_cnt);
|
printf("Number of primitive objects: \t%ld\n", prim_obj_cnt);
|
||||||
printf("Number of primitive elements:\t%ld\n", prim_elem_cnt);
|
printf("Number of primitive elements:\t%ld\n", prim_elem_cnt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Preprocess database into hierarchical uniform grid.
|
* Preprocess database into hierarchical uniform grid.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (TraversalType == TT_HUG)
|
if (TraversalType == TT_HUG)
|
||||||
BuildHierarchy_Uniform();
|
BuildHierarchy_Uniform();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now create slave processes.
|
* Now create slave processes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CLOCK(begin)
|
CLOCK(begin)
|
||||||
CREATE(StartRayTrace, gm->nprocs);
|
CREATE(StartRayTrace, gm->nprocs);
|
||||||
WAIT_FOR_END(gm->nprocs);
|
WAIT_FOR_END(gm->nprocs);
|
||||||
CLOCK(end)
|
CLOCK(end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are finished. Clean up, print statistics and run time.
|
* We are finished. Clean up, print statistics and run time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CloseFrameBuffer(PicFileName);
|
CloseFrameBuffer(PicFileName);
|
||||||
PrintStatistics();
|
PrintStatistics();
|
||||||
|
|
||||||
lapsed = (end - begin) & 0x7FFFFFFF;
|
lapsed = (end - begin) & 0x7FFFFFFF;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printf("TIMING STATISTICS MEASURED BY MAIN PROCESS:\n");
|
printf("TIMING STATISTICS MEASURED BY MAIN PROCESS:\n");
|
||||||
printf(" Overall start time %20lu\n", begin);
|
printf(" Overall start time %20lu\n", begin);
|
||||||
printf(" Overall end time %20lu\n", end);
|
printf(" Overall end time %20lu\n", end);
|
||||||
printf(" Total time with initialization %20lu\n", lapsed);
|
printf(" Total time with initialization %20lu\n", lapsed);
|
||||||
printf(" Total time without initialization %20lu\n", end - gm->par_start_time);
|
printf(" Total time without initialization %20lu\n", end - gm->par_start_time);
|
||||||
|
|
||||||
if (dostats) {
|
if (dostats) {
|
||||||
unsigned totalproctime, maxproctime, minproctime;
|
unsigned totalproctime, maxproctime, minproctime;
|
||||||
|
@ -454,6 +454,6 @@ int main(int argc, CHAR *argv[])
|
||||||
printf("%20s%20d\n","Avg = ",(int) (((double) totalproctime) / ((double) (1.0 * gm->nprocs))));
|
printf("%20s%20d\n","Avg = ",(int) (((double) totalproctime) / ((double) (1.0 * gm->nprocs))));
|
||||||
}
|
}
|
||||||
|
|
||||||
MAIN_END
|
MAIN_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef REAL GJMATRIX[4][8]; /* Matrix for Gauss-Jordan inversion.*/
|
typedef REAL GJMATRIX[4][8]; /* Matrix for Gauss-Jordan inversion.*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,17 +48,17 @@ typedef REAL GJMATRIX[4][8]; /* Matrix for Gauss-Jordan inversion.*/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID VecNorm(POINT V)
|
VOID VecNorm(POINT V)
|
||||||
{
|
{
|
||||||
REAL l;
|
REAL l;
|
||||||
|
|
||||||
l = VecLen(V);
|
l = VecLen(V);
|
||||||
if (l > 0.0000001)
|
if (l > 0.0000001)
|
||||||
{
|
{
|
||||||
V[0] /= l;
|
V[0] /= l;
|
||||||
V[1] /= l;
|
V[1] /= l;
|
||||||
V[2] /= l;
|
V[2] /= l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,24 +77,24 @@ VOID VecNorm(POINT V)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID VecMatMult(POINT Vt, MATRIX M, POINT V)
|
VOID VecMatMult(POINT Vt, MATRIX M, POINT V)
|
||||||
{
|
{
|
||||||
INT i, j;
|
INT i, j;
|
||||||
POINT tvec;
|
POINT tvec;
|
||||||
|
|
||||||
/* tvec = M * V */
|
/* tvec = M * V */
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
tvec[i] = 0.0;
|
tvec[i] = 0.0;
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
tvec[i] += V[j] * M[j][i];
|
tvec[i] += V[j] * M[j][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy tvec to Vt */
|
/* copy tvec to Vt */
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
Vt[i] = tvec[i];
|
Vt[i] = tvec[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,21 +112,21 @@ VOID VecMatMult(POINT Vt, MATRIX M, POINT V)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID PrintMatrix(MATRIX M, CHAR *s)
|
VOID PrintMatrix(MATRIX M, CHAR *s)
|
||||||
{
|
{
|
||||||
INT i, j;
|
INT i, j;
|
||||||
|
|
||||||
printf("\n%s\n", s);
|
printf("\n%s\n", s);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
printf("\t");
|
printf("\t");
|
||||||
|
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
printf("%f ", M[i][j]);
|
printf("%f ", M[i][j]);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,18 +143,18 @@ VOID PrintMatrix(MATRIX M, CHAR *s)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID MatrixIdentity(MATRIX M)
|
VOID MatrixIdentity(MATRIX M)
|
||||||
{
|
{
|
||||||
INT i, j;
|
INT i, j;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
M[i][j] = 0.0;
|
M[i][j] = 0.0;
|
||||||
|
|
||||||
M[0][0] = 1.0;
|
M[0][0] = 1.0;
|
||||||
M[1][1] = 1.0;
|
M[1][1] = 1.0;
|
||||||
M[2][2] = 1.0;
|
M[2][2] = 1.0;
|
||||||
M[3][3] = 1.0;
|
M[3][3] = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,13 +172,13 @@ VOID MatrixIdentity(MATRIX M)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID MatrixCopy(MATRIX A, MATRIX B)
|
VOID MatrixCopy(MATRIX A, MATRIX B)
|
||||||
{
|
{
|
||||||
INT i, j;
|
INT i, j;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
A[i][j] = B[i][j];
|
A[i][j] = B[i][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,16 +196,16 @@ VOID MatrixCopy(MATRIX A, MATRIX B)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID MatrixTranspose(MATRIX MT, MATRIX M)
|
VOID MatrixTranspose(MATRIX MT, MATRIX M)
|
||||||
{
|
{
|
||||||
INT i, j;
|
INT i, j;
|
||||||
MATRIX tmp;
|
MATRIX tmp;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
tmp[j][i] = M[i][j];
|
tmp[j][i] = M[i][j];
|
||||||
|
|
||||||
MatrixCopy(MT, tmp);
|
MatrixCopy(MT, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,26 +222,26 @@ VOID MatrixTranspose(MATRIX MT, MATRIX M)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID MatrixMult(MATRIX C, MATRIX A, MATRIX B)
|
VOID MatrixMult(MATRIX C, MATRIX A, MATRIX B)
|
||||||
{
|
{
|
||||||
INT i, j, k;
|
INT i, j, k;
|
||||||
MATRIX T; /* Temporary matrix. */
|
MATRIX T; /* Temporary matrix. */
|
||||||
|
|
||||||
/* T = A*B */
|
/* T = A*B */
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
T[i][j] = 0.0;
|
T[i][j] = 0.0;
|
||||||
for (k = 0; k < 4; k++)
|
for (k = 0; k < 4; k++)
|
||||||
T[i][j] += A[i][k] * B[k][j];
|
T[i][j] += A[i][k] * B[k][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy T to C */
|
/* copy T to C */
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
C[i][j] = T[i][j];
|
C[i][j] = T[i][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,98 +259,98 @@ VOID MatrixMult(MATRIX C, MATRIX A, MATRIX B)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID MatrixInverse(MATRIX Minv, MATRIX Mat)
|
VOID MatrixInverse(MATRIX Minv, MATRIX Mat)
|
||||||
{
|
{
|
||||||
INT i, j, k; /* Indices. */
|
INT i, j, k; /* Indices. */
|
||||||
GJMATRIX gjmat; /* Inverse calculator. */
|
GJMATRIX gjmat; /* Inverse calculator. */
|
||||||
REAL tbuf[8]; /* Row holder. */
|
REAL tbuf[8]; /* Row holder. */
|
||||||
REAL pval, aval; /* Pivot candidates. */
|
REAL pval, aval; /* Pivot candidates. */
|
||||||
INT prow; /* Pivot row number. */
|
INT prow; /* Pivot row number. */
|
||||||
REAL c; /* Pivot scale factor. */
|
REAL c; /* Pivot scale factor. */
|
||||||
MATRIX tmp;
|
MATRIX tmp;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
gjmat[i][j] = Mat[i][j];
|
gjmat[i][j] = Mat[i][j];
|
||||||
|
|
||||||
|
|
||||||
k = 0;
|
k = 0;
|
||||||
for (i = 4; i < 8; i++)
|
for (i = 4; i < 8; i++)
|
||||||
{
|
{
|
||||||
for (j = 4; j < 8; j++)
|
for (j = 4; j < 8; j++)
|
||||||
if (i == j)
|
if (i == j)
|
||||||
gjmat[k][j] = 1.0;
|
gjmat[k][j] = 1.0;
|
||||||
else
|
else
|
||||||
gjmat[k][j] = 0.0;
|
gjmat[k][j] = 0.0;
|
||||||
k++ ;
|
k++ ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Gaussian elimination. */
|
/* Gaussian elimination. */
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
pval = ABS(gjmat[i][i]);
|
pval = ABS(gjmat[i][i]);
|
||||||
prow = i;
|
prow = i;
|
||||||
|
|
||||||
for (j = i + 1; j < 4; j++)
|
for (j = i + 1; j < 4; j++)
|
||||||
{
|
{
|
||||||
aval = ABS(gjmat[j][i]);
|
aval = ABS(gjmat[j][i]);
|
||||||
if (aval > pval)
|
if (aval > pval)
|
||||||
{
|
{
|
||||||
pval = aval;
|
pval = aval;
|
||||||
prow = j;
|
prow = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != prow)
|
if (i != prow)
|
||||||
{
|
{
|
||||||
for (k = 0; k < 8; k++)
|
for (k = 0; k < 8; k++)
|
||||||
tbuf[k] = gjmat[i][k];
|
tbuf[k] = gjmat[i][k];
|
||||||
|
|
||||||
for (k = 0; k < 8; k++)
|
for (k = 0; k < 8; k++)
|
||||||
gjmat[i][k] = gjmat[prow][k];
|
gjmat[i][k] = gjmat[prow][k];
|
||||||
|
|
||||||
for (k = 0; k < 8; k++)
|
for (k = 0; k < 8; k++)
|
||||||
gjmat[prow][k] = tbuf[k];
|
gjmat[prow][k] = tbuf[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = i + 1; j < 4; j++)
|
for (j = i + 1; j < 4; j++)
|
||||||
{
|
{
|
||||||
c = gjmat[j][i] / gjmat[i][i];
|
c = gjmat[j][i] / gjmat[i][i];
|
||||||
gjmat[j][i] = 0.0;
|
gjmat[j][i] = 0.0;
|
||||||
|
|
||||||
for (k = i + 1; k < 8; k++)
|
for (k = i + 1; k < 8; k++)
|
||||||
gjmat[j][k] = gjmat[j][k] - c * gjmat[i][k];
|
gjmat[j][k] = gjmat[j][k] - c * gjmat[i][k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Zero columns */
|
/* Zero columns */
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
for (j = i + 1; j < 4; j++)
|
for (j = i + 1; j < 4; j++)
|
||||||
{
|
{
|
||||||
c = gjmat[i][j] / gjmat[j][j];
|
c = gjmat[i][j] / gjmat[j][j];
|
||||||
gjmat[i][j] = 0.0;
|
gjmat[i][j] = 0.0;
|
||||||
|
|
||||||
for (k = j + 1; k < 8; k++)
|
for (k = j + 1; k < 8; k++)
|
||||||
gjmat[i][k] = gjmat[i][k] - c * gjmat[j][k];
|
gjmat[i][k] = gjmat[i][k] - c * gjmat[j][k];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (k = 4; k < 8; k++) /* normalize row */
|
for (k = 4; k < 8; k++) /* normalize row */
|
||||||
gjmat[i][k] /= gjmat[i][i];
|
gjmat[i][k] /= gjmat[i][i];
|
||||||
|
|
||||||
|
|
||||||
/* Generate inverse matrix. */
|
/* Generate inverse matrix. */
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 4; j < 8; j++)
|
for (j = 4; j < 8; j++)
|
||||||
Minv[i][j - 4] = gjmat[i][j];
|
Minv[i][j - 4] = gjmat[i][j];
|
||||||
|
|
||||||
MatrixMult(tmp, Mat, Minv);
|
MatrixMult(tmp, Mat, Minv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,13 +368,13 @@ VOID MatrixInverse(MATRIX Minv, MATRIX Mat)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID Translate(MATRIX M, REAL dx, REAL dy, REAL dz)
|
VOID Translate(MATRIX M, REAL dx, REAL dy, REAL dz)
|
||||||
{
|
{
|
||||||
MatrixIdentity(M);
|
MatrixIdentity(M);
|
||||||
|
|
||||||
M[3][0] = dx;
|
M[3][0] = dx;
|
||||||
M[3][1] = dy;
|
M[3][1] = dy;
|
||||||
M[3][2] = dz;
|
M[3][2] = dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,13 +392,13 @@ VOID Translate(MATRIX M, REAL dx, REAL dy, REAL dz)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID Scale(MATRIX M, REAL sx, REAL sy, REAL sz)
|
VOID Scale(MATRIX M, REAL sx, REAL sy, REAL sz)
|
||||||
{
|
{
|
||||||
MatrixIdentity(M);
|
MatrixIdentity(M);
|
||||||
|
|
||||||
M[0][0] = sx;
|
M[0][0] = sx;
|
||||||
M[1][1] = sy;
|
M[1][1] = sy;
|
||||||
M[2][2] = sz;
|
M[2][2] = sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -416,41 +417,41 @@ VOID Scale(MATRIX M, REAL sx, REAL sy, REAL sz)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID Rotate(INT axis, MATRIX M, REAL angle)
|
VOID Rotate(INT axis, MATRIX M, REAL angle)
|
||||||
{
|
{
|
||||||
REAL cosangle;
|
REAL cosangle;
|
||||||
REAL sinangle;
|
REAL sinangle;
|
||||||
|
|
||||||
MatrixIdentity(M);
|
MatrixIdentity(M);
|
||||||
|
|
||||||
cosangle = cos(angle);
|
cosangle = cos(angle);
|
||||||
sinangle = sin(angle);
|
sinangle = sin(angle);
|
||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case X_AXIS:
|
case X_AXIS:
|
||||||
M[1][1] = cosangle;
|
M[1][1] = cosangle;
|
||||||
M[1][2] = sinangle;
|
M[1][2] = sinangle;
|
||||||
M[2][1] = -sinangle;
|
M[2][1] = -sinangle;
|
||||||
M[2][2] = cosangle;
|
M[2][2] = cosangle;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Y_AXIS:
|
case Y_AXIS:
|
||||||
M[0][0] = cosangle;
|
M[0][0] = cosangle;
|
||||||
M[0][2] = -sinangle;
|
M[0][2] = -sinangle;
|
||||||
M[2][0] = sinangle;
|
M[2][0] = sinangle;
|
||||||
M[2][2] = cosangle;
|
M[2][2] = cosangle;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Z_AXIS:
|
case Z_AXIS:
|
||||||
M[0][0] = cosangle;
|
M[0][0] = cosangle;
|
||||||
M[0][1] = sinangle;
|
M[0][1] = sinangle;
|
||||||
M[1][0] = -sinangle;
|
M[1][0] = -sinangle;
|
||||||
M[1][1] = cosangle;
|
M[1][1] = cosangle;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unknown rotation axis %ld.\n", axis);
|
printf("Unknown rotation axis %ld.\n", axis);
|
||||||
exit(5);
|
exit(5);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -35,25 +35,24 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
#define PAGE_SIZE 4096
|
#define PAGE_SIZE 4096
|
||||||
|
|
||||||
struct r_struct {
|
struct r_struct {
|
||||||
INT pad1[PAGE_SIZE]; /* This pad is inserted to avoid
|
INT pad1[PAGE_SIZE]; /* This pad is inserted to avoid
|
||||||
false-sharing due to artifacts
|
false-sharing due to artifacts
|
||||||
of not having a private space
|
of not having a private space
|
||||||
in the sproc model */
|
in the sproc model */
|
||||||
RAY *Stack; /* Ptr to ray tree stack. */
|
RAY *Stack; /* Ptr to ray tree stack. */
|
||||||
INT StackTop; /* Top of ray tree stack. */
|
INT StackTop; /* Top of ray tree stack. */
|
||||||
INT StackSize; /* Maximum size of ray tree stack. */
|
INT StackSize; /* Maximum size of ray tree stack. */
|
||||||
INT pad2[PAGE_SIZE]; /* This pad is inserted to avoid
|
INT pad2[PAGE_SIZE]; /* This pad is inserted to avoid
|
||||||
false-sharing due to artifacts
|
false-sharing due to artifacts
|
||||||
of not having a private space
|
of not having a private space
|
||||||
in the sproc model */
|
in the sproc model */
|
||||||
|
|
||||||
} raystruct[MAX_PROCS];
|
} raystruct[MAX_PROCS];
|
||||||
|
|
||||||
|
@ -72,19 +71,19 @@ INT pad2[PAGE_SIZE]; /* This pad is inserted to avoid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID CopyRayMsg(RAY *rdst, RAY *rsrc)
|
VOID CopyRayMsg(RAY *rdst, RAY *rsrc)
|
||||||
{
|
{
|
||||||
rdst->id = rsrc->id;
|
rdst->id = rsrc->id;
|
||||||
rdst->x = rsrc->x;
|
rdst->x = rsrc->x;
|
||||||
rdst->y = rsrc->y;
|
rdst->y = rsrc->y;
|
||||||
|
|
||||||
VecCopy(rdst->P, rsrc->P);
|
VecCopy(rdst->P, rsrc->P);
|
||||||
VecCopy(rdst->D, rsrc->D);
|
VecCopy(rdst->D, rsrc->D);
|
||||||
|
|
||||||
rdst->level = rsrc->level;
|
rdst->level = rsrc->level;
|
||||||
rdst->weight = rsrc->weight;
|
rdst->weight = rsrc->weight;
|
||||||
|
|
||||||
/* Other fields are initialized with InitRay. */
|
/* Other fields are initialized with InitRay. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,12 +105,12 @@ VOID CopyRayMsg(RAY *rdst, RAY *rsrc)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID InitRayTreeStack(INT TreeDepth, INT pid)
|
VOID InitRayTreeStack(INT TreeDepth, INT pid)
|
||||||
{
|
{
|
||||||
raystruct[pid].StackSize = powint(2, TreeDepth) - 1;
|
raystruct[pid].StackSize = powint(2, TreeDepth) - 1;
|
||||||
raystruct[pid].StackSize += NumSubRays;
|
raystruct[pid].StackSize += NumSubRays;
|
||||||
raystruct[pid].Stack = LocalMalloc(raystruct[pid].StackSize*sizeof(RAY), "raystack.c");
|
raystruct[pid].Stack = LocalMalloc(raystruct[pid].StackSize*sizeof(RAY), "raystack.c");
|
||||||
raystruct[pid].StackTop = -1; /* Empty condition. */
|
raystruct[pid].StackTop = -1; /* Empty condition. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned long powint(long i, long j)
|
unsigned long powint(long i, long j)
|
||||||
|
@ -139,17 +138,17 @@ unsigned long powint(long i, long j)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID PushRayTreeStack(RAY *rmsg, INT pid)
|
VOID PushRayTreeStack(RAY *rmsg, INT pid)
|
||||||
{
|
{
|
||||||
raystruct[pid].StackTop++;
|
raystruct[pid].StackTop++;
|
||||||
|
|
||||||
if (raystruct[pid].StackTop == raystruct[pid].StackSize)
|
if (raystruct[pid].StackTop == raystruct[pid].StackSize)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: Ray tree stack overflow.\n", ProgName);
|
fprintf(stderr,"%s: Ray tree stack overflow.\n", ProgName);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyRayMsg(&(raystruct[pid].Stack[raystruct[pid].StackTop]), rmsg);
|
CopyRayMsg(&(raystruct[pid].Stack[raystruct[pid].StackTop]), rmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,13 +166,13 @@ VOID PushRayTreeStack(RAY *rmsg, INT pid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INT PopRayTreeStack(RAY *rmsg, INT pid)
|
INT PopRayTreeStack(RAY *rmsg, INT pid)
|
||||||
{
|
{
|
||||||
if (raystruct[pid].StackTop < 0)
|
if (raystruct[pid].StackTop < 0)
|
||||||
return (RTS_EMPTY);
|
return (RTS_EMPTY);
|
||||||
|
|
||||||
CopyRayMsg(rmsg, &(raystruct[pid].Stack[raystruct[pid].StackTop]));
|
CopyRayMsg(rmsg, &(raystruct[pid].Stack[raystruct[pid].StackTop]));
|
||||||
|
|
||||||
raystruct[pid].StackTop--;
|
raystruct[pid].StackTop--;
|
||||||
return (RTS_VALID);
|
return (RTS_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,11 @@
|
||||||
/* */
|
/* */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include <malloc.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "tiff_rgba_io.h"
|
#include "tiff_rgba_io.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
typedef short SHORT;
|
typedef short SHORT;
|
||||||
typedef long LONG;
|
typedef long LONG;
|
||||||
|
@ -38,66 +37,66 @@ typedef unsigned long ULONG;
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
SHORT sFileType; /* Mark what kind of file we have. */
|
SHORT sFileType; /* Mark what kind of file we have. */
|
||||||
SHORT sBpp; /* Bits per pixel, 1, 4, 8, 24, 32. */
|
SHORT sBpp; /* Bits per pixel, 1, 4, 8, 24, 32. */
|
||||||
SHORT sRows; /* Up to 1024. */
|
SHORT sRows; /* Up to 1024. */
|
||||||
SHORT sCols; /* Up to 1024. */
|
SHORT sCols; /* Up to 1024. */
|
||||||
SHORT sVectorType; /* So far, 0 = rectangular blocks. */
|
SHORT sVectorType; /* So far, 0 = rectangular blocks. */
|
||||||
SHORT sVectorSize; /* So far, 16 for 4x4 square blocks. */
|
SHORT sVectorSize; /* So far, 16 for 4x4 square blocks. */
|
||||||
LONG lCntVectors; /* Up to 65536. */
|
LONG lCntVectors; /* Up to 65536. */
|
||||||
SHORT sBrows; /* Number of block rows. */
|
SHORT sBrows; /* Number of block rows. */
|
||||||
SHORT sBcols; /* Number of block cols. */
|
SHORT sBcols; /* Number of block cols. */
|
||||||
SHORT sVrows; /* Number of vector rows. */
|
SHORT sVrows; /* Number of vector rows. */
|
||||||
SHORT sVcols; /* Number of vector cols. */
|
SHORT sVcols; /* Number of vector cols. */
|
||||||
CHAR achReserved[104]; /* Pad variable space to 128 bytes. */
|
CHAR achReserved[104]; /* Pad variable space to 128 bytes. */
|
||||||
CHAR achUser[128]; /* User application space. */
|
CHAR achUser[128]; /* User application space. */
|
||||||
CHAR achComment[256]; /* Rest of 1st block for comments. */
|
CHAR achComment[256]; /* Rest of 1st block for comments. */
|
||||||
}
|
}
|
||||||
ISPHDR;
|
ISPHDR;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
USHORT usRes1;
|
USHORT usRes1;
|
||||||
USHORT usRes2;
|
USHORT usRes2;
|
||||||
USHORT usRes3;
|
USHORT usRes3;
|
||||||
USHORT usRes4;
|
USHORT usRes4;
|
||||||
USHORT usRes5;
|
USHORT usRes5;
|
||||||
USHORT usRes6;
|
USHORT usRes6;
|
||||||
USHORT usResX;
|
USHORT usResX;
|
||||||
USHORT usResY;
|
USHORT usResY;
|
||||||
USHORT usRes7;
|
USHORT usRes7;
|
||||||
}
|
}
|
||||||
TGAHDR;
|
TGAHDR;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BYTE b;
|
BYTE b;
|
||||||
BYTE g;
|
BYTE g;
|
||||||
BYTE r;
|
BYTE r;
|
||||||
}
|
}
|
||||||
TGAPIX;
|
TGAPIX;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BYTE r;
|
BYTE r;
|
||||||
BYTE g;
|
BYTE g;
|
||||||
BYTE b;
|
BYTE b;
|
||||||
BYTE count;
|
BYTE count;
|
||||||
}
|
}
|
||||||
SPAPIX;
|
SPAPIX;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
USHORT ausBase[] =
|
USHORT ausBase[] =
|
||||||
{
|
{
|
||||||
HST_BASE2,
|
HST_BASE2,
|
||||||
HST_BASE1,
|
HST_BASE1,
|
||||||
HST_BASE0
|
HST_BASE0
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CHAR *pchProgName = "rltotiff"; /* The program name. */
|
CHAR *pchProgName = "rltotiff"; /* The program name. */
|
||||||
|
@ -148,8 +147,8 @@ int main(int argc, char **argv)
|
||||||
char *spachfile, *tiffile;
|
char *spachfile, *tiffile;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
fprintf(stderr, "spachtotiff <infile> <outfile>\n");
|
fprintf(stderr, "spachtotiff <infile> <outfile>\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
spachfile = argv[1];
|
spachfile = argv[1];
|
||||||
tiffile = argv[2];
|
tiffile = argv[2];
|
||||||
|
@ -157,8 +156,8 @@ int main(int argc, char **argv)
|
||||||
fp = fopen(spachfile, "rb");
|
fp = fopen(spachfile, "rb");
|
||||||
|
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
fprintf(stderr, "spachtotiff: could not open file %s\n", spachfile);
|
fprintf(stderr, "spachtotiff: could not open file %s\n", spachfile);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessSpachFile(fp, spachfile);
|
ProcessSpachFile(fp, spachfile);
|
||||||
|
@ -180,10 +179,10 @@ void
|
||||||
SetPixel24(INT i, INT j, BYTE r, BYTE g, BYTE b)
|
SetPixel24(INT i, INT j, BYTE r, BYTE g, BYTE b)
|
||||||
{
|
{
|
||||||
if (i+j*gbWidth >= gbWidth*gbHeight)
|
if (i+j*gbWidth >= gbWidth*gbHeight)
|
||||||
fprintf(stderr, "Bug!\n");
|
fprintf(stderr, "Bug!\n");
|
||||||
|
|
||||||
gbRGBA[i+(gbHeight-j-1)*gbWidth] =
|
gbRGBA[i+(gbHeight-j-1)*gbWidth] =
|
||||||
((UINT)r)*256*256 + ((UINT)g)*256 + ((UINT)b);
|
((UINT)r)*256*256 + ((UINT)g)*256 + ((UINT)b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,63 +200,63 @@ SetPixel24(INT i, INT j, BYTE r, BYTE g, BYTE b)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID ProcessSpachFile(FILE *pf, CHAR *pchFileName)
|
VOID ProcessSpachFile(FILE *pf, CHAR *pchFileName)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
INT j;
|
INT j;
|
||||||
INT k;
|
INT k;
|
||||||
INT count;
|
INT count;
|
||||||
UINT ui;
|
UINT ui;
|
||||||
LONG lPixCnt;
|
LONG lPixCnt;
|
||||||
|
|
||||||
ui = getc(pf);
|
ui = getc(pf);
|
||||||
ui = getc(pf);
|
ui = getc(pf);
|
||||||
ui = getc(pf);
|
ui = getc(pf);
|
||||||
iCntResX = ui*256 + (UINT)getc(pf);
|
iCntResX = ui*256 + (UINT)getc(pf);
|
||||||
|
|
||||||
ui = getc(pf);
|
ui = getc(pf);
|
||||||
ui = getc(pf);
|
ui = getc(pf);
|
||||||
ui = getc(pf);
|
ui = getc(pf);
|
||||||
iCntResY = ui*256 + (UINT)getc(pf);
|
iCntResY = ui*256 + (UINT)getc(pf);
|
||||||
|
|
||||||
gbWidth = iCntResX;
|
gbWidth = iCntResX;
|
||||||
gbHeight = iCntResY;
|
gbHeight = iCntResY;
|
||||||
|
|
||||||
lPixCnt = (ULONG)iCntResX*(ULONG)iCntResY;
|
lPixCnt = (ULONG)iCntResX*(ULONG)iCntResY;
|
||||||
|
|
||||||
configRGBABuf();
|
configRGBABuf();
|
||||||
|
|
||||||
|
|
||||||
if (fCenter)
|
if (fCenter)
|
||||||
{
|
{
|
||||||
iOffsetX = (iCntDcX - iCntResX)/2;
|
iOffsetX = (iCntDcX - iCntResX)/2;
|
||||||
iOffsetY = (iCntDcY - iCntResY)/2;
|
iOffsetY = (iCntDcY - iCntResY)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, j = 0; lPixCnt > 0; lPixCnt -= count)
|
for (i = 0, j = 0; lPixCnt > 0; lPixCnt -= count)
|
||||||
{
|
{
|
||||||
if (fread(&sp, 1, sizeof(sp), pf) != sizeof(sp))
|
if (fread(&sp, 1, sizeof(sp), pf) != sizeof(sp))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: Unexpected EOF in file \"%s\".\n", pchProgName, pchFileName);
|
fprintf(stderr, "%s: Unexpected EOF in file \"%s\".\n", pchProgName, pchFileName);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
count = (UINT)sp.count + 1;
|
count = (UINT)sp.count + 1;
|
||||||
|
|
||||||
for (k = 0; k < count; k++, i++)
|
for (k = 0; k < count; k++, i++)
|
||||||
{
|
{
|
||||||
if (i >= iCntResX)
|
if (i >= iCntResX)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fDebug)
|
if (fDebug)
|
||||||
printf("%ld\t%ld\t0x%02X\t0x%02X\t0x%02X\t0x%02X\n",
|
printf("%ld\t%ld\t0x%02X\t0x%02X\t0x%02X\t0x%02X\n",
|
||||||
i, j, sp.count, sp.r, sp.g, sp.b);
|
i, j, sp.count, sp.r, sp.g, sp.b);
|
||||||
|
|
||||||
SetPixel24(i, j, sp.r, sp.g, sp.b);
|
SetPixel24(i, j, sp.r, sp.g, sp.b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ static char sccsid[] = "@(#)savemap.c 1.3 2/6/9q";
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <tiffio.h>
|
#include <tiffio.h>
|
||||||
|
|
||||||
#include "tiff_rgba_io.h"
|
#include "tiff_rgba_io.h"
|
||||||
|
|
||||||
#define streq(a,b) (strcmp(a,b) == 0)
|
#define streq(a,b) (strcmp(a,b) == 0)
|
||||||
|
@ -55,76 +54,76 @@ static long orientation = ORIENTATION_BOTLEFT;
|
||||||
long
|
long
|
||||||
tiff_save_rgba(char *name, long *pixels, long width, long height)
|
tiff_save_rgba(char *name, long *pixels, long width, long height)
|
||||||
{
|
{
|
||||||
TIFF *tif;
|
TIFF *tif;
|
||||||
long xsize, ysize;
|
long xsize, ysize;
|
||||||
long y;
|
long y;
|
||||||
long *pos;
|
long *pos;
|
||||||
|
|
||||||
xsize = width;
|
xsize = width;
|
||||||
ysize = height;
|
ysize = height;
|
||||||
|
|
||||||
tif = TIFFOpen(name, "w");
|
tif = TIFFOpen(name, "w");
|
||||||
if (tif == NULL)
|
if (tif == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, xsize);
|
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, xsize);
|
||||||
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, ysize);
|
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, ysize);
|
||||||
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
|
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
|
||||||
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
|
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
|
||||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
|
||||||
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config);
|
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config);
|
||||||
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);
|
TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);
|
||||||
TIFFSetField(tif, TIFFTAG_ORIENTATION, orientation);
|
TIFFSetField(tif, TIFFTAG_ORIENTATION, orientation);
|
||||||
if (rowsperstrip <= 0)
|
if (rowsperstrip <= 0)
|
||||||
rowsperstrip = (8*1024)/TIFFScanlineSize(tif);
|
rowsperstrip = (8*1024)/TIFFScanlineSize(tif);
|
||||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
|
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,
|
||||||
rowsperstrip == 0 ? 1 : rowsperstrip);
|
rowsperstrip == 0 ? 1 : rowsperstrip);
|
||||||
if (config == PLANARCONFIG_CONTIG)
|
if (config == PLANARCONFIG_CONTIG)
|
||||||
scanline = (u_char *)malloc(TIFFScanlineSize(tif));
|
scanline = (u_char *)malloc(TIFFScanlineSize(tif));
|
||||||
|
|
||||||
for (y = 0, pos = pixels; y < ysize;
|
for (y = 0, pos = pixels; y < ysize;
|
||||||
y++, pos += xsize) {
|
y++, pos += xsize) {
|
||||||
|
|
||||||
if (config == PLANARCONFIG_CONTIG) {
|
if (config == PLANARCONFIG_CONTIG) {
|
||||||
#ifdef BYTESWAP
|
#ifdef BYTESWAP
|
||||||
register char *sp = (char *) pos;
|
register char *sp = (char *) pos;
|
||||||
register char *tp = (char *) scanline;
|
register char *tp = (char *) scanline;
|
||||||
register long x;
|
register long x;
|
||||||
|
|
||||||
for (x = 0; x < xsize; x++) {
|
for (x = 0; x < xsize; x++) {
|
||||||
tp[3] = sp[0];
|
tp[3] = sp[0];
|
||||||
tp[2] = sp[1];
|
tp[2] = sp[1];
|
||||||
tp[1] = sp[2];
|
tp[1] = sp[2];
|
||||||
tp[0] = sp[3];
|
tp[0] = sp[3];
|
||||||
sp += 4;
|
sp += 4;
|
||||||
tp += 4;
|
tp += 4;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef BYTESWAP
|
#ifndef BYTESWAP
|
||||||
bcopy(pos, scanline, xsize*4);
|
bcopy(pos, scanline, xsize*4);
|
||||||
#endif
|
#endif
|
||||||
if (TIFFWriteScanline(tif, scanline, y, 0) < 0)
|
if (TIFFWriteScanline(tif, scanline, y, 0) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (config == PLANARCONFIG_SEPARATE) {
|
else if (config == PLANARCONFIG_SEPARATE) {
|
||||||
|
|
||||||
register char *pp = (char *) pos;
|
register char *pp = (char *) pos;
|
||||||
register long x;
|
register long x;
|
||||||
|
|
||||||
for (x = 0; x < xsize; x++) {
|
for (x = 0; x < xsize; x++) {
|
||||||
rbuf[x] = pp[0];
|
rbuf[x] = pp[0];
|
||||||
gbuf[x] = pp[1];
|
gbuf[x] = pp[1];
|
||||||
bbuf[x] = pp[2];
|
bbuf[x] = pp[2];
|
||||||
abuf[x] = pp[3];
|
abuf[x] = pp[3];
|
||||||
pp += 4;
|
pp += 4;
|
||||||
}
|
}
|
||||||
if (TIFFWriteScanline(tif, rbuf, y, 0) < 0 ||
|
if (TIFFWriteScanline(tif, rbuf, y, 0) < 0 ||
|
||||||
TIFFWriteScanline(tif, gbuf, y, 1) < 0 ||
|
TIFFWriteScanline(tif, gbuf, y, 1) < 0 ||
|
||||||
TIFFWriteScanline(tif, bbuf, y, 2) < 0 ||
|
TIFFWriteScanline(tif, bbuf, y, 2) < 0 ||
|
||||||
TIFFWriteScanline(tif, abuf, y, 3) < 0)
|
TIFFWriteScanline(tif, abuf, y, 3) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void) TIFFClose(tif);
|
(void) TIFFClose(tif);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -133,121 +132,121 @@ tiff_save_rgba(char *name, long *pixels, long width, long height)
|
||||||
long
|
long
|
||||||
tiff_load_rgba(char *file, long **pixels, long *width, long *height)
|
tiff_load_rgba(char *file, long **pixels, long *width, long *height)
|
||||||
{
|
{
|
||||||
TIFF *tif;
|
TIFF *tif;
|
||||||
u_short bitspersample, samplesperpixel;
|
u_short bitspersample, samplesperpixel;
|
||||||
u_long xsize, ysize;
|
u_long xsize, ysize;
|
||||||
register long x, y, rowbytes;
|
register long x, y, rowbytes;
|
||||||
u_char *buf;
|
u_char *buf;
|
||||||
long temp;
|
long temp;
|
||||||
ushort orient;
|
ushort orient;
|
||||||
register char *tp ;
|
register char *tp ;
|
||||||
register char *sp ;
|
register char *sp ;
|
||||||
|
|
||||||
if ((tif = TIFFOpen(file, "r")) == NULL) {
|
if ((tif = TIFFOpen(file, "r")) == NULL) {
|
||||||
fprintf(stderr, "%s: error opening file.\n", file);
|
fprintf(stderr, "%s: error opening file.\n", file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample);
|
||||||
switch (bitspersample) {
|
switch (bitspersample) {
|
||||||
case 8:
|
case 8:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: Can not image a %d-bit/sample image.\n",
|
fprintf(stderr, "%s: Can not image a %d-bit/sample image.\n",
|
||||||
file, bitspersample);
|
file, bitspersample);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
|
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
|
||||||
switch (samplesperpixel) {
|
switch (samplesperpixel) {
|
||||||
case 3: case 4:
|
case 3: case 4:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: Can not image a %d samples/pixel image.\n",
|
fprintf(stderr, "%s: Can not image a %d samples/pixel image.\n",
|
||||||
file, bitspersample);
|
file, bitspersample);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &xsize);
|
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &xsize);
|
||||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &ysize);
|
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &ysize);
|
||||||
TIFFGetField(tif, TIFFTAG_ORIENTATION, &orient);
|
TIFFGetField(tif, TIFFTAG_ORIENTATION, &orient);
|
||||||
switch (orient) {
|
switch (orient) {
|
||||||
case ORIENTATION_TOPLEFT: case ORIENTATION_BOTLEFT:
|
case ORIENTATION_TOPLEFT: case ORIENTATION_BOTLEFT:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: Unsupported orientation. Will assume ORIENTATION_TOPLEFT.\n" , file);
|
fprintf(stderr, "%s: Unsupported orientation. Will assume ORIENTATION_TOPLEFT.\n" , file);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rowbytes =TIFFScanlineSize(tif);
|
rowbytes =TIFFScanlineSize(tif);
|
||||||
|
|
||||||
*width = xsize;
|
*width = xsize;
|
||||||
*height = ysize;
|
*height = ysize;
|
||||||
*pixels = (long *) malloc(ysize*xsize*sizeof(long));
|
*pixels = (long *) malloc(ysize*xsize*sizeof(long));
|
||||||
|
|
||||||
|
|
||||||
switch (samplesperpixel) {
|
switch (samplesperpixel) {
|
||||||
case 3:
|
case 3:
|
||||||
tp = (char *) (*pixels);
|
tp = (char *) (*pixels);
|
||||||
if (orient != ORIENTATION_BOTLEFT)
|
if (orient != ORIENTATION_BOTLEFT)
|
||||||
tp += 4 * (*height-1) * *width;
|
tp += 4 * (*height-1) * *width;
|
||||||
buf = (u_char *) malloc(rowbytes);
|
buf = (u_char *) malloc(rowbytes);
|
||||||
|
|
||||||
for (y = 0; y < ysize; y++) {
|
for (y = 0; y < ysize; y++) {
|
||||||
if (TIFFReadScanline(tif, buf, y, 0) < 0)
|
if (TIFFReadScanline(tif, buf, y, 0) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef BYTESWAP
|
#ifdef BYTESWAP
|
||||||
sp = (char *) buf;
|
sp = (char *) buf;
|
||||||
|
|
||||||
for (x = 0; x < xsize; x++) {
|
for (x = 0; x < xsize; x++) {
|
||||||
tp[3] = sp[0];
|
tp[3] = sp[0];
|
||||||
tp[2] = sp[1];
|
tp[2] = sp[1];
|
||||||
tp[1] = sp[2];
|
tp[1] = sp[2];
|
||||||
tp[0] = 0;
|
tp[0] = 0;
|
||||||
tp += 4;
|
tp += 4;
|
||||||
sp += 3;
|
sp += 3;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (orient != ORIENTATION_BOTLEFT)
|
if (orient != ORIENTATION_BOTLEFT)
|
||||||
tp -= 8* *width;
|
tp -= 8* *width;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
buf = (u_char *) (*pixels);
|
buf = (u_char *) (*pixels);
|
||||||
if (orient != ORIENTATION_BOTLEFT)
|
if (orient != ORIENTATION_BOTLEFT)
|
||||||
buf += (*height-1) * rowbytes;
|
buf += (*height-1) * rowbytes;
|
||||||
for (y = 0; y < ysize; y++) {
|
for (y = 0; y < ysize; y++) {
|
||||||
if (TIFFReadScanline(tif, buf, y, 0) < 0)
|
if (TIFFReadScanline(tif, buf, y, 0) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
#ifdef BYTESWAP
|
#ifdef BYTESWAP
|
||||||
tp = (char *) buf;
|
tp = (char *) buf;
|
||||||
sp = (char *) &temp;
|
sp = (char *) &temp;
|
||||||
|
|
||||||
for (x = 0; x < xsize; x++) {
|
for (x = 0; x < xsize; x++) {
|
||||||
temp = *((long *)tp);
|
temp = *((long *)tp);
|
||||||
tp[3] = sp[0];
|
tp[3] = sp[0];
|
||||||
tp[2] = sp[1];
|
tp[2] = sp[1];
|
||||||
tp[1] = sp[2];
|
tp[1] = sp[2];
|
||||||
tp[0] = sp[3];
|
tp[0] = sp[3];
|
||||||
tp += 4;
|
tp += 4;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (orient != ORIENTATION_BOTLEFT)
|
if (orient != ORIENTATION_BOTLEFT)
|
||||||
buf -= rowbytes;
|
buf -= rowbytes;
|
||||||
else
|
else
|
||||||
buf += rowbytes;
|
buf += rowbytes;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: Can not image a %d samples/pixel image.\n",
|
fprintf(stderr, "%s: Can not image a %d samples/pixel image.\n",
|
||||||
file, bitspersample);
|
file, bitspersample);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) TIFFClose(tif);
|
(void) TIFFClose(tif);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,14 +67,14 @@ EXTERN_ENV
|
||||||
#define MAX_AA_COL 9
|
#define MAX_AA_COL 9
|
||||||
|
|
||||||
#define INT_PAD_SIZE 256 /* padding size for 32-bit
|
#define INT_PAD_SIZE 256 /* padding size for 32-bit
|
||||||
quantities to avoid false-sharing. Pads are inserted in two
|
quantities to avoid false-sharing. Pads are inserted in two
|
||||||
situations: (i) when variables are really private to a processor
|
situations: (i) when variables are really private to a processor
|
||||||
but are declared in a shared array owing to the lack of a private
|
but are declared in a shared array owing to the lack of a private
|
||||||
space in the sproc lightweight threads model, and (ii) when
|
space in the sproc lightweight threads model, and (ii) when
|
||||||
there are simple situations of "control" variables that are written
|
there are simple situations of "control" variables that are written
|
||||||
by only one processor but read by several, and declared in a
|
by only one processor but read by several, and declared in a
|
||||||
shared array indexed by process id, e.g. wpstat and workpool
|
shared array indexed by process id, e.g. wpstat and workpool
|
||||||
declared in this file */
|
declared in this file */
|
||||||
|
|
||||||
#define MAX_SUBDIV_LEVEL 3 /* Max HUG subdivision level. */
|
#define MAX_SUBDIV_LEVEL 3 /* Max HUG subdivision level. */
|
||||||
#define MAX_RAYINFO (MAX_SUBDIV_LEVEL + 1)
|
#define MAX_RAYINFO (MAX_SUBDIV_LEVEL + 1)
|
||||||
|
@ -210,25 +210,25 @@ EXTERN_ENV
|
||||||
#define VecDot(A, B) ( A[0]*B[0] + A[1]*B[1] + A[2]*B[2] )
|
#define VecDot(A, B) ( A[0]*B[0] + A[1]*B[1] + A[2]*B[2] )
|
||||||
|
|
||||||
#define VecCross(C, A, B) { C[0] = A[1]*B[2] - A[2]*B[1]; \
|
#define VecCross(C, A, B) { C[0] = A[1]*B[2] - A[2]*B[1]; \
|
||||||
C[1] = A[2]*B[0] - A[0]*B[2]; \
|
C[1] = A[2]*B[0] - A[0]*B[2]; \
|
||||||
C[2] = A[0]*B[1] - A[1]*B[0]; }
|
C[2] = A[0]*B[1] - A[1]*B[0]; }
|
||||||
|
|
||||||
#define VecNegate(B, A) { B[0] = -A[0]; B[1] = -A[1]; B[2] = -A[2]; }
|
#define VecNegate(B, A) { B[0] = -A[0]; B[1] = -A[1]; B[2] = -A[2]; }
|
||||||
|
|
||||||
#define VecCopy(B, A) { B[0] = A[0]; B[1] = A[1]; B[2] = A[2]; }
|
#define VecCopy(B, A) { B[0] = A[0]; B[1] = A[1]; B[2] = A[2]; }
|
||||||
|
|
||||||
#define VecAdd(C, A, B) { C[0] = A[0] + B[0]; \
|
#define VecAdd(C, A, B) { C[0] = A[0] + B[0]; \
|
||||||
C[1] = A[1] + B[1]; \
|
C[1] = A[1] + B[1]; \
|
||||||
C[2] = A[2] + B[2]; }
|
C[2] = A[2] + B[2]; }
|
||||||
|
|
||||||
#define VecSub(C, A, B) { C[0] = A[0] - B[0]; \
|
#define VecSub(C, A, B) { C[0] = A[0] - B[0]; \
|
||||||
C[1] = A[1] - B[1]; \
|
C[1] = A[1] - B[1]; \
|
||||||
C[2] = A[2] - B[2]; }
|
C[2] = A[2] - B[2]; }
|
||||||
|
|
||||||
|
|
||||||
#define VecScale(B, scale, A) { B[0] = scale * A[0]; \
|
#define VecScale(B, scale, A) { B[0] = scale * A[0]; \
|
||||||
B[1] = scale * A[1]; \
|
B[1] = scale * A[1]; \
|
||||||
B[2] = scale * A[2]; }
|
B[2] = scale * A[2]; }
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -236,11 +236,11 @@ EXTERN_ENV
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define IsectAdd(hit, tval, P) { (hit)->t = tval; \
|
#define IsectAdd(hit, tval, P) { (hit)->t = tval; \
|
||||||
(hit)->pelem = P; }
|
(hit)->pelem = P; }
|
||||||
|
|
||||||
#define RayPoint(pi, ray, tval) { pi[0] = ray->P[0] + ray->D[0]*tval; \
|
#define RayPoint(pi, ray, tval) { pi[0] = ray->P[0] + ray->D[0]*tval; \
|
||||||
pi[1] = ray->P[1] + ray->D[1]*tval; \
|
pi[1] = ray->P[1] + ray->D[1]*tval; \
|
||||||
pi[2] = ray->P[2] + ray->D[2]*tval; }
|
pi[2] = ray->P[2] + ray->D[2]*tval; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -289,19 +289,19 @@ typedef VEC3 COLOR; /* An r, g, b color. */
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct pprocs
|
typedef struct pprocs
|
||||||
{
|
{
|
||||||
CHAR *(*name)(); /* Primitive name. */
|
CHAR *(*name)(); /* Primitive name. */
|
||||||
VOID (*print)(); /* Primitive print. */
|
VOID (*print)(); /* Primitive print. */
|
||||||
VOID (*read)(); /* Read from model file. */
|
VOID (*read)(); /* Read from model file. */
|
||||||
VOID (*binread)(); /* Binary read from model file. */
|
VOID (*binread)(); /* Binary read from model file. */
|
||||||
VOID (*transform)(); /* Transform primitive. */
|
VOID (*transform)(); /* Transform primitive. */
|
||||||
INT (*intersect)(); /* Intersect object with a ray. */
|
INT (*intersect)(); /* Intersect object with a ray. */
|
||||||
INT (*pe_intersect)(); /* Intersect primelement with a ray. */
|
INT (*pe_intersect)(); /* Intersect primelement with a ray. */
|
||||||
VOID (*normal)(); /* Compute normal vector. */
|
VOID (*normal)(); /* Compute normal vector. */
|
||||||
VOID (*normalize)(); /* Data normalization to unit cube. */
|
VOID (*normalize)(); /* Data normalization to unit cube. */
|
||||||
VOID (*bbox)(); /* Bounding box constructor. */
|
VOID (*bbox)(); /* Bounding box constructor. */
|
||||||
}
|
}
|
||||||
PPROCS;
|
PPROCS;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -309,16 +309,16 @@ typedef struct pprocs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct surf
|
typedef struct surf
|
||||||
{
|
{
|
||||||
COLOR fcolor; /* Front facing color. */
|
COLOR fcolor; /* Front facing color. */
|
||||||
COLOR bcolor; /* Back facing color. */
|
COLOR bcolor; /* Back facing color. */
|
||||||
REAL kdiff; /* Diffuse coefficient. */
|
REAL kdiff; /* Diffuse coefficient. */
|
||||||
REAL kspec; /* Specular coefficient. */
|
REAL kspec; /* Specular coefficient. */
|
||||||
REAL ktran; /* Transmission coefficient. */
|
REAL ktran; /* Transmission coefficient. */
|
||||||
REAL refrindex; /* Index of refraction. */
|
REAL refrindex; /* Index of refraction. */
|
||||||
REAL kspecn; /* Specular distribution coeff. */
|
REAL kspecn; /* Specular distribution coeff. */
|
||||||
}
|
}
|
||||||
SURF;
|
SURF;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,13 +327,13 @@ typedef struct surf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct light
|
typedef struct light
|
||||||
{
|
{
|
||||||
VEC4 pos; /* Light position. */
|
VEC4 pos; /* Light position. */
|
||||||
COLOR col; /* Light color. */
|
COLOR col; /* Light color. */
|
||||||
BOOL shadow; /* Send shadow rays? */
|
BOOL shadow; /* Send shadow rays? */
|
||||||
struct light *next; /* Ptr to next light. */
|
struct light *next; /* Ptr to next light. */
|
||||||
}
|
}
|
||||||
LIGHT;
|
LIGHT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -342,12 +342,12 @@ typedef struct light
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct pixel
|
typedef struct pixel
|
||||||
{
|
{
|
||||||
R32 r;
|
R32 r;
|
||||||
R32 g;
|
R32 g;
|
||||||
R32 b;
|
R32 b;
|
||||||
}
|
}
|
||||||
PIXEL;
|
PIXEL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -356,17 +356,17 @@ typedef struct pixel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct voxel
|
typedef struct voxel
|
||||||
{
|
{
|
||||||
INT id; /* id = index1D */
|
INT id; /* id = index1D */
|
||||||
INT numelements; /* Number of elements in voxel. */
|
INT numelements; /* Number of elements in voxel. */
|
||||||
struct voxel *next; /* Hashtable bucket list. */
|
struct voxel *next; /* Hashtable bucket list. */
|
||||||
CHAR *cell; /* Ptr to grid or ptr to ElemPtr list*/
|
CHAR *cell; /* Ptr to grid or ptr to ElemPtr list*/
|
||||||
CHAR celltype; /* 0 => local voxel, 1 => local grid */
|
CHAR celltype; /* 0 => local voxel, 1 => local grid */
|
||||||
/* 2 => GSM voxel, 3 => GSM grid */
|
/* 2 => GSM voxel, 3 => GSM grid */
|
||||||
/* 4 => remote voxel, 5 =>remote grid*/
|
/* 4 => remote voxel, 5 =>remote grid*/
|
||||||
CHAR dummy[sizeof(INT) - 1];
|
CHAR dummy[sizeof(INT) - 1];
|
||||||
}
|
}
|
||||||
VOXEL;
|
VOXEL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,11 +375,11 @@ typedef struct voxel
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct bbox
|
typedef struct bbox
|
||||||
{
|
{
|
||||||
REAL dnear[3];
|
REAL dnear[3];
|
||||||
REAL dfar[3];
|
REAL dfar[3];
|
||||||
}
|
}
|
||||||
BBOX;
|
BBOX;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,20 +388,20 @@ typedef struct bbox
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct view
|
typedef struct view
|
||||||
{
|
{
|
||||||
POINT eye; /* Eye position. */
|
POINT eye; /* Eye position. */
|
||||||
POINT coi; /* Center position */
|
POINT coi; /* Center position */
|
||||||
MATRIX vtrans; /* Viewing transformation */
|
MATRIX vtrans; /* Viewing transformation */
|
||||||
MATRIX vtransInv; /* Inverse viewing transformation */
|
MATRIX vtransInv; /* Inverse viewing transformation */
|
||||||
MATRIX model; /* Global model transformation */
|
MATRIX model; /* Global model transformation */
|
||||||
COLOR bkg; /* Background color. */
|
COLOR bkg; /* Background color. */
|
||||||
INT projection; /* Projection type. */
|
INT projection; /* Projection type. */
|
||||||
REAL vang; /* View angle. */
|
REAL vang; /* View angle. */
|
||||||
COLOR ambient; /* Ambient light. */
|
COLOR ambient; /* Ambient light. */
|
||||||
BOOL shad; /* Shadow indicator. */
|
BOOL shad; /* Shadow indicator. */
|
||||||
BOOL shading; /* Shading indicator. */
|
BOOL shading; /* Shading indicator. */
|
||||||
}
|
}
|
||||||
VIEW;
|
VIEW;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -409,25 +409,25 @@ typedef struct view
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct display
|
typedef struct display
|
||||||
{
|
{
|
||||||
INT maxlevel; /* Maximum raytrace level. */
|
INT maxlevel; /* Maximum raytrace level. */
|
||||||
INT maxAAsubdiv; /* Maximum antialiasing subdivision. */
|
INT maxAAsubdiv; /* Maximum antialiasing subdivision. */
|
||||||
INT aarow; /* Max anti row index for super-sampling. */
|
INT aarow; /* Max anti row index for super-sampling. */
|
||||||
INT aacol; /* Max anti column index for super-sampling. */
|
INT aacol; /* Max anti column index for super-sampling. */
|
||||||
REAL aatolerance; /* Antialiasing tolerance color difference. */
|
REAL aatolerance; /* Antialiasing tolerance color difference. */
|
||||||
INT xres,yres; /* Display resolution. */
|
INT xres,yres; /* Display resolution. */
|
||||||
INT numpixels; /* Total number of pixels in framebuffer. */
|
INT numpixels; /* Total number of pixels in framebuffer. */
|
||||||
REAL minweight; /* Minimum ray weight. */
|
REAL minweight; /* Minimum ray weight. */
|
||||||
REAL scrDist; /* Screen distance from eye. */
|
REAL scrDist; /* Screen distance from eye. */
|
||||||
REAL scrWidth; /* Screen width. */
|
REAL scrWidth; /* Screen width. */
|
||||||
REAL scrHeight; /* Screen height. */
|
REAL scrHeight; /* Screen height. */
|
||||||
REAL scrHalfWidth; /* Screen half width. */
|
REAL scrHalfWidth; /* Screen half width. */
|
||||||
REAL scrHalfHeight; /* Screen half height. */
|
REAL scrHalfHeight; /* Screen half height. */
|
||||||
REAL vWscale; /* Screen width scale. */
|
REAL vWscale; /* Screen width scale. */
|
||||||
REAL vHscale; /* Screen height scale. */
|
REAL vHscale; /* Screen height scale. */
|
||||||
PIXEL *framebuffer; /* Ptr to the framebuffer. */
|
PIXEL *framebuffer; /* Ptr to the framebuffer. */
|
||||||
}
|
}
|
||||||
DISPLAY;
|
DISPLAY;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -436,13 +436,13 @@ typedef struct display
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct element
|
typedef struct element
|
||||||
{
|
{
|
||||||
INT index;
|
INT index;
|
||||||
struct object *parent; /* Ptr back to parent object. */
|
struct object *parent; /* Ptr back to parent object. */
|
||||||
CHAR *data; /* Pointer to data info. */
|
CHAR *data; /* Pointer to data info. */
|
||||||
BBOX bv; /* Element bounding volume. */
|
BBOX bv; /* Element bounding volume. */
|
||||||
}
|
}
|
||||||
ELEMENT;
|
ELEMENT;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -450,17 +450,17 @@ typedef struct element
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct object
|
typedef struct object
|
||||||
{
|
{
|
||||||
INT index;
|
INT index;
|
||||||
CHAR name[NAME_LEN]; /* Name of object. */
|
CHAR name[NAME_LEN]; /* Name of object. */
|
||||||
BBOX bv; /* Bound volume. */
|
BBOX bv; /* Bound volume. */
|
||||||
ELEMENT *pelem; /* Pointer to prim element list. */
|
ELEMENT *pelem; /* Pointer to prim element list. */
|
||||||
INT numelements; /* Number of primitive elements. */
|
INT numelements; /* Number of primitive elements. */
|
||||||
PPROCS *procs; /* Pointer to primitive procs. */
|
PPROCS *procs; /* Pointer to primitive procs. */
|
||||||
SURF *surf; /* Pointer to surface properties. */
|
SURF *surf; /* Pointer to surface properties. */
|
||||||
struct object *next; /* Next primitive (linked list). */
|
struct object *next; /* Next primitive (linked list). */
|
||||||
}
|
}
|
||||||
OBJECT;
|
OBJECT;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -468,14 +468,14 @@ typedef struct object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct irecord
|
typedef struct irecord
|
||||||
{
|
{
|
||||||
REAL t; /* Line parameter at intersection. */
|
REAL t; /* Line parameter at intersection. */
|
||||||
ELEMENT *pelem; /* Primitve element. */
|
ELEMENT *pelem; /* Primitve element. */
|
||||||
REAL b1; /* Barycentric coordinates of */
|
REAL b1; /* Barycentric coordinates of */
|
||||||
REAL b2; /* intersection for triangles. */
|
REAL b2; /* intersection for triangles. */
|
||||||
REAL b3;
|
REAL b3;
|
||||||
}
|
}
|
||||||
IRECORD;
|
IRECORD;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -484,56 +484,56 @@ typedef struct irecord
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct btnode
|
typedef struct btnode
|
||||||
{
|
{
|
||||||
ELEMENT **pe; /* Array of primitive element ptrs in node. */
|
ELEMENT **pe; /* Array of primitive element ptrs in node. */
|
||||||
REAL p[3]; /* Lower left corner of bounding box */
|
REAL p[3]; /* Lower left corner of bounding box */
|
||||||
/* of space represented by node. */
|
/* of space represented by node. */
|
||||||
INT nprims; /* # prims in node primElem list. */
|
INT nprims; /* # prims in node primElem list. */
|
||||||
INT n[3]; /* Gridsizes for this box. */
|
INT n[3]; /* Gridsizes for this box. */
|
||||||
INT i[3]; /* Indices of cell (lower left corner */
|
INT i[3]; /* Indices of cell (lower left corner */
|
||||||
/* if not a leaf) in grid. */
|
/* if not a leaf) in grid. */
|
||||||
INT axis; /* subdiv axis, 0,1,2 => x,y,z */
|
INT axis; /* subdiv axis, 0,1,2 => x,y,z */
|
||||||
INT totalPrimsAllocated; /* This is used for garbage allocation.*/
|
INT totalPrimsAllocated; /* This is used for garbage allocation.*/
|
||||||
struct btnode *btn[2]; /* Ptrs to children. */
|
struct btnode *btn[2]; /* Ptrs to children. */
|
||||||
}
|
}
|
||||||
BTNODE;
|
BTNODE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct grid
|
typedef struct grid
|
||||||
{
|
{
|
||||||
INT id;
|
INT id;
|
||||||
VOXEL **hashtable; /* hashtable[ num_buckets ] is indexed */
|
VOXEL **hashtable; /* hashtable[ num_buckets ] is indexed */
|
||||||
/* by index1D mod num_buckets, */
|
/* by index1D mod num_buckets, */
|
||||||
/* num_buckets and n, the # of cells/ */
|
/* num_buckets and n, the # of cells/ */
|
||||||
/* axis, should be relatively prime, */
|
/* axis, should be relatively prime, */
|
||||||
/* grids at different levels may */
|
/* grids at different levels may */
|
||||||
/* have different num_buckets. */
|
/* have different num_buckets. */
|
||||||
UINT *emptycells; /* emptycells[ ceil( NumCells */
|
UINT *emptycells; /* emptycells[ ceil( NumCells */
|
||||||
/* sizeof(unsigned) ) ], a packed */
|
/* sizeof(unsigned) ) ], a packed */
|
||||||
/* array of bits indicating for */
|
/* array of bits indicating for */
|
||||||
/* each cell if it is empty, */
|
/* each cell if it is empty, */
|
||||||
/* 1 => empty, */
|
/* 1 => empty, */
|
||||||
/* grids at different levels may */
|
/* grids at different levels may */
|
||||||
/* have different NumCells. */
|
/* have different NumCells. */
|
||||||
ELEMENT **pepa; /* prim element pointer list */
|
ELEMENT **pepa; /* prim element pointer list */
|
||||||
INT num_prims; /* number of prims on prim element */
|
INT num_prims; /* number of prims on prim element */
|
||||||
/* list */
|
/* list */
|
||||||
INT indx_inc[3]; /* if n is # of cells per axis, */
|
INT indx_inc[3]; /* if n is # of cells per axis, */
|
||||||
/* NumCells is n**3, */
|
/* NumCells is n**3, */
|
||||||
/* indx_inc[0,1,2] = 1, n, n**2; */
|
/* indx_inc[0,1,2] = 1, n, n**2; */
|
||||||
/* inc for index1D. */
|
/* inc for index1D. */
|
||||||
INT num_buckets; /* # buckets in hashtable */
|
INT num_buckets; /* # buckets in hashtable */
|
||||||
REAL min[3]; /* cell min boundary, world coord */
|
REAL min[3]; /* cell min boundary, world coord */
|
||||||
REAL cellsize[3]; /* cellsize of voxels in this grid */
|
REAL cellsize[3]; /* cellsize of voxels in this grid */
|
||||||
/* in world coord */
|
/* in world coord */
|
||||||
INT subdiv_level; /* # levels of space subdiv */
|
INT subdiv_level; /* # levels of space subdiv */
|
||||||
/* to reach this grid, */
|
/* to reach this grid, */
|
||||||
/* 0 is top level. */
|
/* 0 is top level. */
|
||||||
BTNODE *bintree; /* root of bintree for this grid */
|
BTNODE *bintree; /* root of bintree for this grid */
|
||||||
struct grid *next; /* grid list */
|
struct grid *next; /* grid list */
|
||||||
}
|
}
|
||||||
GRID;
|
GRID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -544,27 +544,27 @@ typedef struct grid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct rayinfo
|
typedef struct rayinfo
|
||||||
{
|
{
|
||||||
GRID *grid; /* Grid for this rayinfo. */
|
GRID *grid; /* Grid for this rayinfo. */
|
||||||
REAL d[3]; /* Dist along ray from world coord origin to */
|
REAL d[3]; /* Dist along ray from world coord origin to */
|
||||||
/* next voxel boundary. */
|
/* next voxel boundary. */
|
||||||
INT entry_plane; /* Entry plane for current voxel, */
|
INT entry_plane; /* Entry plane for current voxel, */
|
||||||
/* (0,1,2) => (x,y,z). */
|
/* (0,1,2) => (x,y,z). */
|
||||||
REAL t_in; /* Dist along ray from world coord origin to */
|
REAL t_in; /* Dist along ray from world coord origin to */
|
||||||
/* entry point of current voxel. */
|
/* entry point of current voxel. */
|
||||||
INT exit_plane; /* Exit plane for current voxel, */
|
INT exit_plane; /* Exit plane for current voxel, */
|
||||||
/* (0,1,2) => (x,y,z). */
|
/* (0,1,2) => (x,y,z). */
|
||||||
REAL t_out; /* Dist along ray from world coord origin to */
|
REAL t_out; /* Dist along ray from world coord origin to */
|
||||||
/* exit point of current voxel. */
|
/* exit point of current voxel. */
|
||||||
REAL delta[3]; /* Dist along ray between voxel boundaries. */
|
REAL delta[3]; /* Dist along ray between voxel boundaries. */
|
||||||
INT index3D[3]; /* Current cell in cell units wrt grid origin*/
|
INT index3D[3]; /* Current cell in cell units wrt grid origin*/
|
||||||
INT index1D; /* Index1D = i + j * n + k * n**2 */
|
INT index1D; /* Index1D = i + j * n + k * n**2 */
|
||||||
/* where index3D[] = i,j,k and n is the */
|
/* where index3D[] = i,j,k and n is the */
|
||||||
/* # of divisions per axis. */
|
/* # of divisions per axis. */
|
||||||
INT indx_inc1D[3]; /* Including sign of ray direction. */
|
INT indx_inc1D[3]; /* Including sign of ray direction. */
|
||||||
struct rayinfo *next; /* Ptr to next structure. */
|
struct rayinfo *next; /* Ptr to next structure. */
|
||||||
}
|
}
|
||||||
RAYINFO;
|
RAYINFO;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -573,20 +573,20 @@ typedef struct rayinfo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct ray
|
typedef struct ray
|
||||||
{
|
{
|
||||||
LONG id; /* Ray id. */
|
LONG id; /* Ray id. */
|
||||||
INT x, y; /* Pixel ray is part of. */
|
INT x, y; /* Pixel ray is part of. */
|
||||||
VEC3 P; /* Position (origin). */
|
VEC3 P; /* Position (origin). */
|
||||||
VEC3 D; /* Direction. */
|
VEC3 D; /* Direction. */
|
||||||
INT level; /* Level of ray in ray tree. */
|
INT level; /* Level of ray in ray tree. */
|
||||||
RAYINFO *ri; /* Grid dependent ray info. */
|
RAYINFO *ri; /* Grid dependent ray info. */
|
||||||
INT ri_indx;
|
INT ri_indx;
|
||||||
INT indx_inc3D[3]; /* Incl sign of ray direction*/
|
INT indx_inc3D[3]; /* Incl sign of ray direction*/
|
||||||
RAYINFO rinfo[MAX_RAYINFO + 1];
|
RAYINFO rinfo[MAX_RAYINFO + 1];
|
||||||
R32 weight; /* Ray weight. */
|
R32 weight; /* Ray weight. */
|
||||||
R32 dummy;
|
R32 dummy;
|
||||||
}
|
}
|
||||||
RAY;
|
RAY;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -595,12 +595,12 @@ typedef struct ray
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct rayjob
|
typedef struct rayjob
|
||||||
{
|
{
|
||||||
INT x, y; /* Primary ray pixel start address. */
|
INT x, y; /* Primary ray pixel start address. */
|
||||||
INT xlen, ylen; /* Length of scanline bundle. */
|
INT xlen, ylen; /* Length of scanline bundle. */
|
||||||
INT xcurr, ycurr; /* Current ray pixel address. */
|
INT xcurr, ycurr; /* Current ray pixel address. */
|
||||||
}
|
}
|
||||||
RAYJOB;
|
RAYJOB;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -609,12 +609,12 @@ typedef struct rayjob
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct wpjob
|
typedef struct wpjob
|
||||||
{
|
{
|
||||||
INT ypix, xpix; /* Primary ray pixel address. */
|
INT ypix, xpix; /* Primary ray pixel address. */
|
||||||
INT xdim, ydim; /* Pixel bundle size. */
|
INT xdim, ydim; /* Pixel bundle size. */
|
||||||
struct wpjob *next;
|
struct wpjob *next;
|
||||||
}
|
}
|
||||||
WPJOB;
|
WPJOB;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -623,13 +623,13 @@ typedef struct wpjob
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct node
|
typedef struct node
|
||||||
{
|
{
|
||||||
struct node huge *next; /* Ptr to next free node. */
|
struct node huge *next; /* Ptr to next free node. */
|
||||||
UINT size; /* Size of node in bytes excl header.*/
|
UINT size; /* Size of node in bytes excl header.*/
|
||||||
BOOL free; /* TRUE = free, FALSE = in use. */
|
BOOL free; /* TRUE = free, FALSE = in use. */
|
||||||
UINT cksm; /* Arena integrity check. */
|
UINT cksm; /* Arena integrity check. */
|
||||||
}
|
}
|
||||||
NODE;
|
NODE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -638,29 +638,29 @@ typedef struct node
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct gmem
|
typedef struct gmem
|
||||||
{
|
{
|
||||||
INT nprocs; /* Number of processes. */
|
INT nprocs; /* Number of processes. */
|
||||||
INT pid; /* Global process id counter. */
|
INT pid; /* Global process id counter. */
|
||||||
INT rid; /* Global ray id counter. */
|
INT rid; /* Global ray id counter. */
|
||||||
OBJECT *modelroot; /* Root of model list. */
|
OBJECT *modelroot; /* Root of model list. */
|
||||||
GRID *world_level_grid; /* Zero level grid pointer. */
|
GRID *world_level_grid; /* Zero level grid pointer. */
|
||||||
NODE huge *freelist; /* Ptr to global free memory heap. */
|
NODE huge *freelist; /* Ptr to global free memory heap. */
|
||||||
INT wpstat[MAX_PROCS][INT_PAD_SIZE]; /* Shared work pool
|
INT wpstat[MAX_PROCS][INT_PAD_SIZE]; /* Shared work pool
|
||||||
status hints. Padded to avoid
|
status hints. Padded to avoid
|
||||||
false-sharing */
|
false-sharing */
|
||||||
WPJOB *workpool[MAX_PROCS][INT_PAD_SIZE]; /* Ptr to heads of
|
WPJOB *workpool[MAX_PROCS][INT_PAD_SIZE]; /* Ptr to heads of
|
||||||
shared work pools. Padded to
|
shared work pools. Padded to
|
||||||
avoid false-sharing */
|
avoid false-sharing */
|
||||||
|
|
||||||
BARDEC(start) /* Barrier for startup sync. */
|
BARDEC(start) /* Barrier for startup sync. */
|
||||||
LOCKDEC(pidlock) /* Lock to increment pid. */
|
LOCKDEC(pidlock) /* Lock to increment pid. */
|
||||||
LOCKDEC(ridlock) /* Lock to increment rid. */
|
LOCKDEC(ridlock) /* Lock to increment rid. */
|
||||||
LOCKDEC(memlock) /* Lock for memory manager. */
|
LOCKDEC(memlock) /* Lock for memory manager. */
|
||||||
ALOCKDEC(wplock, MAX_PROCS) /* Locks for shared work pools. */
|
ALOCKDEC(wplock, MAX_PROCS) /* Locks for shared work pools. */
|
||||||
UINT par_start_time;
|
UINT par_start_time;
|
||||||
UINT partime[MAX_PROCS];
|
UINT partime[MAX_PROCS];
|
||||||
}
|
}
|
||||||
GMEM;
|
GMEM;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME
|
* NAME
|
||||||
* SpecularDirection - compute reflected ray
|
* SpecularDirection - compute reflected ray
|
||||||
|
@ -48,23 +49,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID SpecularDirection(POINT R, POINT N, POINT I)
|
VOID SpecularDirection(POINT R, POINT N, POINT I)
|
||||||
{
|
{
|
||||||
REAL I_dot_N; /* I*N */
|
REAL I_dot_N; /* I*N */
|
||||||
POINT N2; /* 2N */
|
POINT N2; /* 2N */
|
||||||
POINT vprime; /* Scale of I */
|
POINT vprime; /* Scale of I */
|
||||||
|
|
||||||
/* Turner's calculation from first paper. */
|
/* Turner's calculation from first paper. */
|
||||||
|
|
||||||
I_dot_N = VecDot(I,N);
|
I_dot_N = VecDot(I,N);
|
||||||
I_dot_N = ABS(I_dot_N);
|
I_dot_N = ABS(I_dot_N);
|
||||||
I_dot_N = 1.0/I_dot_N;
|
I_dot_N = 1.0/I_dot_N;
|
||||||
|
|
||||||
VecScale(vprime, I_dot_N, I);
|
VecScale(vprime, I_dot_N, I);
|
||||||
VecScale(N2, 2.0, N);
|
VecScale(N2, 2.0, N);
|
||||||
|
|
||||||
VecAdd(R, vprime, N2);
|
VecAdd(R, vprime, N2);
|
||||||
VecNorm(R);
|
VecNorm(R);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,41 +85,41 @@ VOID SpecularDirection(POINT R, POINT N, POINT I)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL TransmissionDirection(POINT T, POINT N, POINT I, REAL kn)
|
BOOL TransmissionDirection(POINT T, POINT N, POINT I, REAL kn)
|
||||||
{
|
{
|
||||||
POINT vprime; /* Parameters in calculation. */
|
POINT vprime; /* Parameters in calculation. */
|
||||||
POINT vplusn;
|
POINT vplusn;
|
||||||
REAL I_dot_N;
|
REAL I_dot_N;
|
||||||
REAL kf;
|
REAL kf;
|
||||||
REAL vprime_sq;
|
REAL vprime_sq;
|
||||||
REAL vplusn_sq;
|
REAL vplusn_sq;
|
||||||
|
|
||||||
/* Turner's calculation from first paper. */
|
/* Turner's calculation from first paper. */
|
||||||
|
|
||||||
I_dot_N = VecDot(I,N);
|
I_dot_N = VecDot(I,N);
|
||||||
I_dot_N = ABS(I_dot_N);
|
I_dot_N = ABS(I_dot_N);
|
||||||
I_dot_N = 1.0/I_dot_N;
|
I_dot_N = 1.0/I_dot_N;
|
||||||
|
|
||||||
VecScale(vprime, I_dot_N, I);
|
VecScale(vprime, I_dot_N, I);
|
||||||
VecAdd(vplusn, vprime, N);
|
VecAdd(vplusn, vprime, N);
|
||||||
|
|
||||||
vprime_sq = VecDot(vprime, vprime);
|
vprime_sq = VecDot(vprime, vprime);
|
||||||
vplusn_sq = VecDot(vplusn, vplusn);
|
vplusn_sq = VecDot(vplusn, vplusn);
|
||||||
|
|
||||||
kf = kn*kn*vprime_sq - vplusn_sq;
|
kf = kn*kn*vprime_sq - vplusn_sq;
|
||||||
|
|
||||||
if (kf > RAYEPS)
|
if (kf > RAYEPS)
|
||||||
{
|
{
|
||||||
kf = 1.0/sqrt(kf);
|
kf = 1.0/sqrt(kf);
|
||||||
|
|
||||||
VecScale(vplusn, kf, vplusn);
|
VecScale(vplusn, kf, vplusn);
|
||||||
VecSub(T, vplusn, N);
|
VecSub(T, vplusn, N);
|
||||||
VecNorm(T);
|
VecNorm(T);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,162 +140,162 @@ BOOL TransmissionDirection(POINT T, POINT N, POINT I, REAL kn)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID Shade(VEC3 iP, VEC3 N, RAY *ray, IRECORD *hit, INT pid)
|
VOID Shade(VEC3 iP, VEC3 N, RAY *ray, IRECORD *hit, INT pid)
|
||||||
{
|
{
|
||||||
VEC3 Lvec; /* Light vector. */
|
VEC3 Lvec; /* Light vector. */
|
||||||
VEC3 Hvec; /* Highlight vector. */
|
VEC3 Hvec; /* Highlight vector. */
|
||||||
VEC3 Evec; /* Eye vector. */
|
VEC3 Evec; /* Eye vector. */
|
||||||
RAY shad_ray; /* Shadow ray. */
|
RAY shad_ray; /* Shadow ray. */
|
||||||
RAY secondary_ray; /* Secondary ray. */
|
RAY secondary_ray; /* Secondary ray. */
|
||||||
COLOR surfcol; /* Primitive surface color. */
|
COLOR surfcol; /* Primitive surface color. */
|
||||||
COLOR col; /* Ray color contribution. */
|
COLOR col; /* Ray color contribution. */
|
||||||
REAL NdotL; /* Diffuse conritbution. */
|
REAL NdotL; /* Diffuse conritbution. */
|
||||||
REAL Diff; /* Diffuse variable. */
|
REAL Diff; /* Diffuse variable. */
|
||||||
REAL NdotH; /* Highlight contribution. */
|
REAL NdotH; /* Highlight contribution. */
|
||||||
REAL spec; /* Highlight variable. */
|
REAL spec; /* Highlight variable. */
|
||||||
OBJECT *po; /* Ptr to object. */
|
OBJECT *po; /* Ptr to object. */
|
||||||
SURF *s; /* Surface pointer. */
|
SURF *s; /* Surface pointer. */
|
||||||
INT i; /* Index variables. */
|
INT i; /* Index variables. */
|
||||||
REAL lightlen; /* Length of light vector. */
|
REAL lightlen; /* Length of light vector. */
|
||||||
REAL shadtrans; /* Shadow transmission. */
|
REAL shadtrans; /* Shadow transmission. */
|
||||||
LIGHT *lptr; /* Light pointer. */
|
LIGHT *lptr; /* Light pointer. */
|
||||||
|
|
||||||
/* Initialize primitive info and ray color. */
|
/* Initialize primitive info and ray color. */
|
||||||
|
|
||||||
po = hit->pelem->parent;
|
po = hit->pelem->parent;
|
||||||
s = po->surf;
|
s = po->surf;
|
||||||
VecCopy(surfcol, s->fcolor);
|
VecCopy(surfcol, s->fcolor);
|
||||||
|
|
||||||
/* Initialize color to ambient. */
|
/* Initialize color to ambient. */
|
||||||
|
|
||||||
col[0] = View.ambient[0] * surfcol[0];
|
col[0] = View.ambient[0] * surfcol[0];
|
||||||
col[1] = View.ambient[1] * surfcol[1];
|
col[1] = View.ambient[1] * surfcol[1];
|
||||||
col[2] = View.ambient[2] * surfcol[2];
|
col[2] = View.ambient[2] * surfcol[2];
|
||||||
|
|
||||||
/* Set shadow ray origin. */
|
/* Set shadow ray origin. */
|
||||||
|
|
||||||
VecCopy(shad_ray.P, iP);
|
VecCopy(shad_ray.P, iP);
|
||||||
VecNegate(Evec, ray->D);
|
VecNegate(Evec, ray->D);
|
||||||
|
|
||||||
/* Account for all lights. */
|
/* Account for all lights. */
|
||||||
|
|
||||||
lptr = lights;
|
lptr = lights;
|
||||||
for (i = 0; i < nlights; i++)
|
for (i = 0; i < nlights; i++)
|
||||||
{
|
{
|
||||||
VecSub(Lvec, lptr->pos, iP);
|
VecSub(Lvec, lptr->pos, iP);
|
||||||
lightlen = VecLen(Lvec);
|
lightlen = VecLen(Lvec);
|
||||||
VecNorm(Lvec);
|
VecNorm(Lvec);
|
||||||
VecCopy(shad_ray.D, Lvec);
|
VecCopy(shad_ray.D, Lvec);
|
||||||
|
|
||||||
LOCK(gm->ridlock);
|
LOCK(gm->ridlock);
|
||||||
shad_ray.id = gm->rid++;
|
shad_ray.id = gm->rid++;
|
||||||
UNLOCK(gm->ridlock);
|
UNLOCK(gm->ridlock);
|
||||||
|
|
||||||
NdotL = VecDot(N, Lvec);
|
NdotL = VecDot(N, Lvec);
|
||||||
|
|
||||||
if (NdotL > 0.0)
|
if (NdotL > 0.0)
|
||||||
{
|
{
|
||||||
/* Test to see if point shadowed. */
|
/* Test to see if point shadowed. */
|
||||||
|
|
||||||
if (View.shad && !lptr->shadow)
|
if (View.shad && !lptr->shadow)
|
||||||
{
|
{
|
||||||
switch (TraversalType)
|
switch (TraversalType)
|
||||||
{
|
{
|
||||||
case TT_LIST:
|
case TT_LIST:
|
||||||
shadtrans = ShadowIntersect(&shad_ray, lightlen, hit->pelem);
|
shadtrans = ShadowIntersect(&shad_ray, lightlen, hit->pelem);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TT_HUG:
|
case TT_HUG:
|
||||||
shadtrans = HuniformShadowIntersect(&shad_ray, lightlen, hit->pelem, pid);
|
shadtrans = HuniformShadowIntersect(&shad_ray, lightlen, hit->pelem, pid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
shadtrans = 1.0;
|
shadtrans = 1.0;
|
||||||
|
|
||||||
/* Compute non-shadowed shades. */
|
/* Compute non-shadowed shades. */
|
||||||
|
|
||||||
if (shadtrans > 0.0)
|
if (shadtrans > 0.0)
|
||||||
{
|
{
|
||||||
Diff = po->surf->kdiff * NdotL * shadtrans;
|
Diff = po->surf->kdiff * NdotL * shadtrans;
|
||||||
|
|
||||||
col[0] += surfcol[0] * lptr->col[0] * Diff;
|
col[0] += surfcol[0] * lptr->col[0] * Diff;
|
||||||
col[1] += surfcol[1] * lptr->col[1] * Diff;
|
col[1] += surfcol[1] * lptr->col[1] * Diff;
|
||||||
col[2] += surfcol[2] * lptr->col[2] * Diff;
|
col[2] += surfcol[2] * lptr->col[2] * Diff;
|
||||||
|
|
||||||
/* Add specular. */
|
/* Add specular. */
|
||||||
|
|
||||||
if (s->kspec > 0.0)
|
if (s->kspec > 0.0)
|
||||||
{
|
{
|
||||||
VecAdd(Hvec,Lvec,Evec);
|
VecAdd(Hvec,Lvec,Evec);
|
||||||
VecNorm(Hvec);
|
VecNorm(Hvec);
|
||||||
NdotH = VecDot(N,Hvec);
|
NdotH = VecDot(N,Hvec);
|
||||||
|
|
||||||
if (NdotH > 0.0)
|
if (NdotH > 0.0)
|
||||||
{
|
{
|
||||||
spec = pow(NdotH, s->kspecn);
|
spec = pow(NdotH, s->kspecn);
|
||||||
spec *= s->kspec;
|
spec *= s->kspec;
|
||||||
|
|
||||||
col[0] += lptr->col[0]*spec;
|
col[0] += lptr->col[0]*spec;
|
||||||
col[1] += lptr->col[1]*spec;
|
col[1] += lptr->col[1]*spec;
|
||||||
col[2] += lptr->col[2]*spec;
|
col[2] += lptr->col[2]*spec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lptr = lptr->next;
|
lptr = lptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add color to pixel frame buffer. */
|
/* Add color to pixel frame buffer. */
|
||||||
|
|
||||||
VecScale(col, ray->weight, col);
|
VecScale(col, ray->weight, col);
|
||||||
AddPixelColor(col, ray->x, ray->y);
|
AddPixelColor(col, ray->x, ray->y);
|
||||||
|
|
||||||
/* Recurse if not at maximum level. */
|
/* Recurse if not at maximum level. */
|
||||||
|
|
||||||
if ((ray->level) + 1 < Display.maxlevel)
|
if ((ray->level) + 1 < Display.maxlevel)
|
||||||
{
|
{
|
||||||
VecCopy(secondary_ray.P, iP);
|
VecCopy(secondary_ray.P, iP);
|
||||||
|
|
||||||
/* Specular. */
|
/* Specular. */
|
||||||
secondary_ray.weight = po->surf->kspec * ray->weight;
|
secondary_ray.weight = po->surf->kspec * ray->weight;
|
||||||
|
|
||||||
if (secondary_ray.weight > Display.minweight)
|
if (secondary_ray.weight > Display.minweight)
|
||||||
{
|
{
|
||||||
SpecularDirection(secondary_ray.D, N, ray->D);
|
SpecularDirection(secondary_ray.D, N, ray->D);
|
||||||
secondary_ray.level = ray->level + 1;
|
secondary_ray.level = ray->level + 1;
|
||||||
|
|
||||||
LOCK(gm->ridlock);
|
LOCK(gm->ridlock);
|
||||||
secondary_ray.id = gm->rid++;
|
secondary_ray.id = gm->rid++;
|
||||||
UNLOCK(gm->ridlock);
|
UNLOCK(gm->ridlock);
|
||||||
|
|
||||||
secondary_ray.x = ray->x;
|
secondary_ray.x = ray->x;
|
||||||
secondary_ray.y = ray->y;
|
secondary_ray.y = ray->y;
|
||||||
|
|
||||||
PushRayTreeStack(&secondary_ray, pid);
|
PushRayTreeStack(&secondary_ray, pid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transmission. */
|
/* Transmission. */
|
||||||
secondary_ray.weight = po->surf->ktran * ray->weight;
|
secondary_ray.weight = po->surf->ktran * ray->weight;
|
||||||
|
|
||||||
if (secondary_ray.weight > Display.minweight)
|
if (secondary_ray.weight > Display.minweight)
|
||||||
{
|
{
|
||||||
if (TransmissionDirection(secondary_ray.D, N, ray->D, po->surf->refrindex))
|
if (TransmissionDirection(secondary_ray.D, N, ray->D, po->surf->refrindex))
|
||||||
{
|
{
|
||||||
secondary_ray.level = ray->level + 1;
|
secondary_ray.level = ray->level + 1;
|
||||||
|
|
||||||
LOCK(gm->ridlock);
|
LOCK(gm->ridlock);
|
||||||
secondary_ray.id = gm->rid++;
|
secondary_ray.id = gm->rid++;
|
||||||
UNLOCK(gm->ridlock);
|
UNLOCK(gm->ridlock);
|
||||||
|
|
||||||
secondary_ray.x = ray->x;
|
secondary_ray.x = ray->x;
|
||||||
secondary_ray.y = ray->y;
|
secondary_ray.y = ray->y;
|
||||||
|
|
||||||
PushRayTreeStack(&secondary_ray, pid);
|
PushRayTreeStack(&secondary_ray, pid);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME
|
* NAME
|
||||||
* SphName - return the object name
|
* SphName - return the object name
|
||||||
|
@ -42,9 +43,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CHAR *SphName()
|
CHAR *SphName()
|
||||||
{
|
{
|
||||||
return ("sphere");
|
return ("sphere");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,22 +62,22 @@ CHAR *SphName()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID SphPrint(OBJECT *po)
|
VOID SphPrint(OBJECT *po)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
SPHERE *ps; /* Ptr to sphere data. */
|
SPHERE *ps; /* Ptr to sphere data. */
|
||||||
ELEMENT *pe; /* Ptr to sphere element. */
|
ELEMENT *pe; /* Ptr to sphere element. */
|
||||||
|
|
||||||
pe = po->pelem;
|
pe = po->pelem;
|
||||||
fprintf(stderr,"\tSphere object\n");
|
fprintf(stderr,"\tSphere object\n");
|
||||||
|
|
||||||
for (i = 0; i < po->numelements; i++)
|
for (i = 0; i < po->numelements; i++)
|
||||||
{
|
{
|
||||||
ps = (SPHERE *)(pe->data);
|
ps = (SPHERE *)(pe->data);
|
||||||
fprintf(stderr,"\t\tcenter %f %f %f\n", ps->center[0], ps->center[1], ps->center[2]);
|
fprintf(stderr,"\t\tcenter %f %f %f\n", ps->center[0], ps->center[1], ps->center[2]);
|
||||||
fprintf(stderr,"\t\t radius %f %f\n\n", ps->rad, ps->rad2);
|
fprintf(stderr,"\t\t radius %f %f\n\n", ps->rad, ps->rad2);
|
||||||
pe++;
|
pe++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,19 +95,19 @@ VOID SphPrint(OBJECT *po)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID SphElementBoundBox(ELEMENT *pe, SPHERE *ps)
|
VOID SphElementBoundBox(ELEMENT *pe, SPHERE *ps)
|
||||||
{
|
{
|
||||||
BBOX *pbb; /* Ptr to bounding box. */
|
BBOX *pbb; /* Ptr to bounding box. */
|
||||||
|
|
||||||
pbb = &(pe->bv);
|
pbb = &(pe->bv);
|
||||||
|
|
||||||
pbb->dnear[0] = ps->center[0] - ps->rad;
|
pbb->dnear[0] = ps->center[0] - ps->rad;
|
||||||
pbb->dnear[1] = ps->center[1] - ps->rad;
|
pbb->dnear[1] = ps->center[1] - ps->rad;
|
||||||
pbb->dnear[2] = ps->center[2] - ps->rad;
|
pbb->dnear[2] = ps->center[2] - ps->rad;
|
||||||
|
|
||||||
pbb->dfar[0] = ps->center[0] + ps->rad;
|
pbb->dfar[0] = ps->center[0] + ps->rad;
|
||||||
pbb->dfar[1] = ps->center[1] + ps->rad;
|
pbb->dfar[1] = ps->center[1] + ps->rad;
|
||||||
pbb->dfar[2] = ps->center[2] + ps->rad;
|
pbb->dfar[2] = ps->center[2] + ps->rad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,45 +124,45 @@ VOID SphElementBoundBox(ELEMENT *pe, SPHERE *ps)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID SphBoundBox(OBJECT *po)
|
VOID SphBoundBox(OBJECT *po)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
SPHERE *ps; /* Ptr to sphere data. */
|
SPHERE *ps; /* Ptr to sphere data. */
|
||||||
ELEMENT *pe; /* Ptr to sphere element. */
|
ELEMENT *pe; /* Ptr to sphere element. */
|
||||||
BBOX *pbb; /* Ptr to bounding box. */
|
BBOX *pbb; /* Ptr to bounding box. */
|
||||||
REAL minx, maxx;
|
REAL minx, maxx;
|
||||||
REAL miny, maxy;
|
REAL miny, maxy;
|
||||||
REAL minz, maxz;
|
REAL minz, maxz;
|
||||||
|
|
||||||
pe = po->pelem;
|
pe = po->pelem;
|
||||||
pbb = &(po->bv);
|
pbb = &(po->bv);
|
||||||
|
|
||||||
minx = miny = minz = HUGE_REAL;
|
minx = miny = minz = HUGE_REAL;
|
||||||
maxx = maxy = maxz = -HUGE_REAL;
|
maxx = maxy = maxz = -HUGE_REAL;
|
||||||
|
|
||||||
for (i = 0; i < po->numelements; i++)
|
for (i = 0; i < po->numelements; i++)
|
||||||
{
|
{
|
||||||
ps = (SPHERE *)(pe->data);
|
ps = (SPHERE *)(pe->data);
|
||||||
SphElementBoundBox(pe, ps);
|
SphElementBoundBox(pe, ps);
|
||||||
|
|
||||||
minx = Min(minx, pe->bv.dnear[0]);
|
minx = Min(minx, pe->bv.dnear[0]);
|
||||||
miny = Min(miny, pe->bv.dnear[1]);
|
miny = Min(miny, pe->bv.dnear[1]);
|
||||||
minz = Min(minz, pe->bv.dnear[2]);
|
minz = Min(minz, pe->bv.dnear[2]);
|
||||||
|
|
||||||
maxx = Max(maxx, pe->bv.dfar[0]);
|
maxx = Max(maxx, pe->bv.dfar[0]);
|
||||||
maxy = Max(maxy, pe->bv.dfar[1]);
|
maxy = Max(maxy, pe->bv.dfar[1]);
|
||||||
maxz = Max(maxz, pe->bv.dfar[2]);
|
maxz = Max(maxz, pe->bv.dfar[2]);
|
||||||
|
|
||||||
pe++;
|
pe++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pbb->dnear[0] = minx;
|
pbb->dnear[0] = minx;
|
||||||
pbb->dnear[1] = miny;
|
pbb->dnear[1] = miny;
|
||||||
pbb->dnear[2] = minz;
|
pbb->dnear[2] = minz;
|
||||||
|
|
||||||
pbb->dfar[0] = maxx;
|
pbb->dfar[0] = maxx;
|
||||||
pbb->dfar[1] = maxy;
|
pbb->dfar[1] = maxy;
|
||||||
pbb->dfar[2] = maxz;
|
pbb->dfar[2] = maxz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,20 +185,20 @@ VOID SphBoundBox(OBJECT *po)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID SphNormal(IRECORD *hit, POINT Pi, POINT Ni)
|
VOID SphNormal(IRECORD *hit, POINT Pi, POINT Ni)
|
||||||
{
|
{
|
||||||
ELEMENT *pe;
|
ELEMENT *pe;
|
||||||
SPHERE *ps; /* Ptr to sphere data. */
|
SPHERE *ps; /* Ptr to sphere data. */
|
||||||
|
|
||||||
/* Compute normal and make it a unit vector. */
|
/* Compute normal and make it a unit vector. */
|
||||||
|
|
||||||
pe = hit->pelem;
|
pe = hit->pelem;
|
||||||
ps = (SPHERE *)pe->data;
|
ps = (SPHERE *)pe->data;
|
||||||
VecSub(Ni, Pi, ps->center);
|
VecSub(Ni, Pi, ps->center);
|
||||||
|
|
||||||
Ni[0] /= ps->rad;
|
Ni[0] /= ps->rad;
|
||||||
Ni[1] /= ps->rad;
|
Ni[1] /= ps->rad;
|
||||||
Ni[2] /= ps->rad;
|
Ni[2] /= ps->rad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,52 +216,52 @@ VOID SphNormal(IRECORD *hit, POINT Pi, POINT Ni)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID SphDataNormalize(OBJECT *po, MATRIX normMat)
|
VOID SphDataNormalize(OBJECT *po, MATRIX normMat)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
SPHERE *ps; /* Ptr to sphere data. */
|
SPHERE *ps; /* Ptr to sphere data. */
|
||||||
ELEMENT *pe; /* Ptr to sphere element. */
|
ELEMENT *pe; /* Ptr to sphere element. */
|
||||||
POINT surf_point; /* Point on surface. */
|
POINT surf_point; /* Point on surface. */
|
||||||
POINT center_point; /* Center point. */
|
POINT center_point; /* Center point. */
|
||||||
POINT rad_vector; /* Radius vector. */
|
POINT rad_vector; /* Radius vector. */
|
||||||
|
|
||||||
NormalizeBoundBox(&po->bv, normMat);
|
NormalizeBoundBox(&po->bv, normMat);
|
||||||
|
|
||||||
pe = po->pelem;
|
pe = po->pelem;
|
||||||
|
|
||||||
for (i = 0; i < po->numelements; i++)
|
for (i = 0; i < po->numelements; i++)
|
||||||
{
|
{
|
||||||
ps = (SPHERE *)pe->data;
|
ps = (SPHERE *)pe->data;
|
||||||
|
|
||||||
NormalizeBoundBox(&pe->bv, normMat);
|
NormalizeBoundBox(&pe->bv, normMat);
|
||||||
|
|
||||||
surf_point[0] = ps->center[0] + ps->rad;
|
surf_point[0] = ps->center[0] + ps->rad;
|
||||||
surf_point[1] = ps->center[1];
|
surf_point[1] = ps->center[1];
|
||||||
surf_point[2] = ps->center[2];
|
surf_point[2] = ps->center[2];
|
||||||
surf_point[3] = 1.0;
|
surf_point[3] = 1.0;
|
||||||
|
|
||||||
center_point[0] = ps->center[0];
|
center_point[0] = ps->center[0];
|
||||||
center_point[1] = ps->center[1];
|
center_point[1] = ps->center[1];
|
||||||
center_point[2] = ps->center[2];
|
center_point[2] = ps->center[2];
|
||||||
center_point[3] = 1.0;
|
center_point[3] = 1.0;
|
||||||
|
|
||||||
|
|
||||||
/* Transform center point. */
|
/* Transform center point. */
|
||||||
|
|
||||||
VecMatMult(center_point, normMat, center_point);
|
VecMatMult(center_point, normMat, center_point);
|
||||||
VecMatMult(surf_point, normMat, surf_point);
|
VecMatMult(surf_point, normMat, surf_point);
|
||||||
|
|
||||||
|
|
||||||
/* Find new radius. */
|
/* Find new radius. */
|
||||||
|
|
||||||
VecSub(rad_vector, surf_point, center_point);
|
VecSub(rad_vector, surf_point, center_point);
|
||||||
VecCopy(ps->center, center_point);
|
VecCopy(ps->center, center_point);
|
||||||
|
|
||||||
ps->rad = VecLen(rad_vector);
|
ps->rad = VecLen(rad_vector);
|
||||||
ps->rad2 = ps->rad * ps->rad;
|
ps->rad2 = ps->rad * ps->rad;
|
||||||
|
|
||||||
pe++;
|
pe++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -286,47 +287,47 @@ VOID SphDataNormalize(OBJECT *po, MATRIX normMat)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INT SphPeIntersect(RAY *pr, ELEMENT *pe, IRECORD *hit)
|
INT SphPeIntersect(RAY *pr, ELEMENT *pe, IRECORD *hit)
|
||||||
{
|
{
|
||||||
INT nhits; /* Number of hits. */
|
INT nhits; /* Number of hits. */
|
||||||
REAL b, disc, t1, t2, vsq; /* Formula variables. */
|
REAL b, disc, t1, t2, vsq; /* Formula variables. */
|
||||||
SPHERE *ps; /* Ptr to sphere data. */
|
SPHERE *ps; /* Ptr to sphere data. */
|
||||||
POINT V; /* C - P */
|
POINT V; /* C - P */
|
||||||
IRECORD *sphhit;
|
IRECORD *sphhit;
|
||||||
|
|
||||||
ps = (SPHERE *)(pe->data);
|
ps = (SPHERE *)(pe->data);
|
||||||
sphhit = hit;
|
sphhit = hit;
|
||||||
|
|
||||||
VecSub(V, ps->center, pr->P); /* Ray from origin to center.*/
|
VecSub(V, ps->center, pr->P); /* Ray from origin to center.*/
|
||||||
vsq = VecDot(V, V); /* Length sq of V. */
|
vsq = VecDot(V, V); /* Length sq of V. */
|
||||||
b = VecDot(V, pr->D); /* Perpendicular scale of V. */
|
b = VecDot(V, pr->D); /* Perpendicular scale of V. */
|
||||||
|
|
||||||
if (vsq > ps->rad2 && b < RAYEPS) /* Behind ray origin. */
|
if (vsq > ps->rad2 && b < RAYEPS) /* Behind ray origin. */
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
disc = b*b - vsq + ps->rad2; /* Discriminate. */
|
disc = b*b - vsq + ps->rad2; /* Discriminate. */
|
||||||
if (disc < 0.0) /* Misses ray. */
|
if (disc < 0.0) /* Misses ray. */
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
disc = sqrt(disc); /* Find intersection param. */
|
disc = sqrt(disc); /* Find intersection param. */
|
||||||
t2 = b + disc;
|
t2 = b + disc;
|
||||||
t1 = b - disc;
|
t1 = b - disc;
|
||||||
|
|
||||||
if (t2 <= RAYEPS) /* Behind ray origin. */
|
if (t2 <= RAYEPS) /* Behind ray origin. */
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
nhits = 0;
|
nhits = 0;
|
||||||
if (t1 > RAYEPS) /* Entering sphere. */
|
if (t1 > RAYEPS) /* Entering sphere. */
|
||||||
{
|
{
|
||||||
IsectAdd(sphhit, t1, pe);
|
IsectAdd(sphhit, t1, pe);
|
||||||
sphhit++;
|
sphhit++;
|
||||||
nhits++;
|
nhits++;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsectAdd(sphhit, t2, pe); /* Exiting sphere */
|
IsectAdd(sphhit, t2, pe); /* Exiting sphere */
|
||||||
nhits++;
|
nhits++;
|
||||||
|
|
||||||
return (nhits);
|
return (nhits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -345,32 +346,32 @@ INT SphPeIntersect(RAY *pr, ELEMENT *pe, IRECORD *hit)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INT SphIntersect(RAY *pr, OBJECT *po, IRECORD *hit)
|
INT SphIntersect(RAY *pr, OBJECT *po, IRECORD *hit)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
INT nhits; /* # hits in sphere. */
|
INT nhits; /* # hits in sphere. */
|
||||||
ELEMENT *pe; /* Ptr to sphere element. */
|
ELEMENT *pe; /* Ptr to sphere element. */
|
||||||
IRECORD newhit[2]; /* Hit list. */
|
IRECORD newhit[2]; /* Hit list. */
|
||||||
|
|
||||||
/* Traverse sphere list to find intersections. */
|
/* Traverse sphere list to find intersections. */
|
||||||
|
|
||||||
nhits = 0;
|
nhits = 0;
|
||||||
pe = po->pelem;
|
pe = po->pelem;
|
||||||
hit[0].t = HUGE_REAL;
|
hit[0].t = HUGE_REAL;
|
||||||
|
|
||||||
for (i = 0; i < po->numelements; i++)
|
for (i = 0; i < po->numelements; i++)
|
||||||
{
|
{
|
||||||
if (SphPeIntersect(pr, pe, newhit))
|
if (SphPeIntersect(pr, pe, newhit))
|
||||||
if (newhit[0].t < hit[0].t)
|
if (newhit[0].t < hit[0].t)
|
||||||
{
|
{
|
||||||
nhits++;
|
nhits++;
|
||||||
hit[0].t = newhit[0].t;
|
hit[0].t = newhit[0].t;
|
||||||
hit[0].pelem = newhit[0].pelem;
|
hit[0].pelem = newhit[0].pelem;
|
||||||
}
|
}
|
||||||
pe++;
|
pe++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (nhits);
|
return (nhits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -389,56 +390,56 @@ INT SphIntersect(RAY *pr, OBJECT *po, IRECORD *hit)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID SphTransform(OBJECT *po, MATRIX xtrans, MATRIX xinvT)
|
VOID SphTransform(OBJECT *po, MATRIX xtrans, MATRIX xinvT)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
INT numelems; /* Number of object elements. */
|
INT numelems; /* Number of object elements. */
|
||||||
REAL new_rad;
|
REAL new_rad;
|
||||||
SPHERE *ps; /* Ptr to sphere data. */
|
SPHERE *ps; /* Ptr to sphere data. */
|
||||||
ELEMENT *pe; /* Ptr to sphere element. */
|
ELEMENT *pe; /* Ptr to sphere element. */
|
||||||
POINT surf_point; /* Point on surface. */
|
POINT surf_point; /* Point on surface. */
|
||||||
POINT center_point; /* Center_point. */
|
POINT center_point; /* Center_point. */
|
||||||
POINT rad_vector; /* Radius vector. */
|
POINT rad_vector; /* Radius vector. */
|
||||||
|
|
||||||
pe = po->pelem;
|
pe = po->pelem;
|
||||||
numelems = po->numelements;
|
numelems = po->numelements;
|
||||||
|
|
||||||
for (i = 0; i < numelems; i++)
|
for (i = 0; i < numelems; i++)
|
||||||
{
|
{
|
||||||
ps = (SPHERE *)pe->data;
|
ps = (SPHERE *)pe->data;
|
||||||
|
|
||||||
/* See if radius has changed with a scale. */
|
/* See if radius has changed with a scale. */
|
||||||
|
|
||||||
surf_point[0] = ps->center[0] + ps->rad;
|
surf_point[0] = ps->center[0] + ps->rad;
|
||||||
surf_point[1] = ps->center[1];
|
surf_point[1] = ps->center[1];
|
||||||
surf_point[2] = ps->center[2];
|
surf_point[2] = ps->center[2];
|
||||||
surf_point[3] = 1.0;
|
surf_point[3] = 1.0;
|
||||||
|
|
||||||
center_point[0] = ps->center[0];
|
center_point[0] = ps->center[0];
|
||||||
center_point[1] = ps->center[1];
|
center_point[1] = ps->center[1];
|
||||||
center_point[2] = ps->center[2];
|
center_point[2] = ps->center[2];
|
||||||
center_point[3] = 1.0;
|
center_point[3] = 1.0;
|
||||||
|
|
||||||
/* Transform center point. */
|
/* Transform center point. */
|
||||||
|
|
||||||
VecMatMult(center_point, xtrans, center_point);
|
VecMatMult(center_point, xtrans, center_point);
|
||||||
VecMatMult(surf_point, xtrans, surf_point);
|
VecMatMult(surf_point, xtrans, surf_point);
|
||||||
|
|
||||||
/* Find radius. */
|
/* Find radius. */
|
||||||
|
|
||||||
VecSub(rad_vector, surf_point, center_point);
|
VecSub(rad_vector, surf_point, center_point);
|
||||||
VecCopy(ps->center, center_point);
|
VecCopy(ps->center, center_point);
|
||||||
|
|
||||||
new_rad = VecLen(rad_vector);
|
new_rad = VecLen(rad_vector);
|
||||||
|
|
||||||
if (new_rad != ps->rad)
|
if (new_rad != ps->rad)
|
||||||
{
|
{
|
||||||
ps->rad = new_rad;
|
ps->rad = new_rad;
|
||||||
ps->rad2 = ps->rad * ps->rad;
|
ps->rad2 = ps->rad * ps->rad;
|
||||||
}
|
}
|
||||||
|
|
||||||
pe++;
|
pe++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -456,35 +457,35 @@ VOID SphTransform(OBJECT *po, MATRIX xtrans, MATRIX xinvT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID SphRead(OBJECT *po, FILE *pf)
|
VOID SphRead(OBJECT *po, FILE *pf)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
INT instat; /* Input counter */
|
INT instat; /* Input counter */
|
||||||
SPHERE *ps; /* Ptr to sphere data. */
|
SPHERE *ps; /* Ptr to sphere data. */
|
||||||
ELEMENT *pe; /* Ptr to sphere element. */
|
ELEMENT *pe; /* Ptr to sphere element. */
|
||||||
|
|
||||||
pe = po->pelem;
|
pe = po->pelem;
|
||||||
ps = GlobalMalloc(sizeof(SPHERE)*po->numelements, "sph.c");
|
ps = GlobalMalloc(sizeof(SPHERE)*po->numelements, "sph.c");
|
||||||
|
|
||||||
for (i = 0; i < po->numelements; i++)
|
for (i = 0; i < po->numelements; i++)
|
||||||
{
|
{
|
||||||
instat = fscanf(pf,"%lf %lf %lf %lf", &(ps->center[0]), &(ps->center[1]), &(ps->center[2]), &(ps->rad));
|
instat = fscanf(pf,"%lf %lf %lf %lf", &(ps->center[0]), &(ps->center[1]), &(ps->center[2]), &(ps->rad));
|
||||||
|
|
||||||
if (instat != 4)
|
if (instat != 4)
|
||||||
{
|
{
|
||||||
printf("Error in SphRead: sphere %ld.\n", i);
|
printf("Error in SphRead: sphere %ld.\n", i);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ps->center[3] = 1.0; /* w initialization. */
|
ps->center[3] = 1.0; /* w initialization. */
|
||||||
ps->rad2 = ps->rad*ps->rad;
|
ps->rad2 = ps->rad*ps->rad;
|
||||||
|
|
||||||
pe->data = (CHAR *)ps;
|
pe->data = (CHAR *)ps;
|
||||||
pe->parent = po;
|
pe->parent = po;
|
||||||
|
|
||||||
SphElementBoundBox(pe, ps);
|
SphElementBoundBox(pe, ps);
|
||||||
|
|
||||||
ps++;
|
ps++;
|
||||||
pe++;
|
pe++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,14 +42,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
REAL frand()
|
REAL frand()
|
||||||
{
|
{
|
||||||
REAL r;
|
REAL r;
|
||||||
static LONG lLastRand = 0;
|
static LONG lLastRand = 0;
|
||||||
|
|
||||||
lLastRand = lLastRand*214013L + 2531011L;
|
lLastRand = lLastRand*214013L + 2531011L;
|
||||||
r = (REAL)((lLastRand >> 16) & 0x7FFF)/32768.0;
|
r = (REAL)((lLastRand >> 16) & 0x7FFF)/32768.0;
|
||||||
return (r);
|
return (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,22 +76,22 @@ REAL frand()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL GetRayJobFromBundle(RAYJOB *job, INT *x, INT *y)
|
BOOL GetRayJobFromBundle(RAYJOB *job, INT *x, INT *y)
|
||||||
{
|
{
|
||||||
*x = job->xcurr; /* Set pixel address first. */
|
*x = job->xcurr; /* Set pixel address first. */
|
||||||
*y = job->ycurr;
|
*y = job->ycurr;
|
||||||
|
|
||||||
if ((job->y + job->ylen) == job->ycurr) /* All done? */
|
if ((job->y + job->ylen) == job->ycurr) /* All done? */
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
job->xcurr++; /* Update to next pixel. */
|
job->xcurr++; /* Update to next pixel. */
|
||||||
if ((job->x +job->xlen) == job->xcurr )
|
if ((job->x +job->xlen) == job->xcurr )
|
||||||
{
|
{
|
||||||
job->xcurr = job->x; /* Go to new scanline. */
|
job->xcurr = job->x; /* Go to new scanline. */
|
||||||
job->ycurr++;
|
job->ycurr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,66 +124,66 @@ BOOL GetRayJobFromBundle(RAYJOB *job, INT *x, INT *y)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID ConvertPrimRayJobToRayMsg(RAY *ray, REAL x, REAL y)
|
VOID ConvertPrimRayJobToRayMsg(RAY *ray, REAL x, REAL y)
|
||||||
{
|
{
|
||||||
VEC4 dir;
|
VEC4 dir;
|
||||||
VEC4 origin;
|
VEC4 origin;
|
||||||
|
|
||||||
if (View.projection == PT_PERSP)
|
if (View.projection == PT_PERSP)
|
||||||
{
|
{
|
||||||
dir[0] = -Display.scrHalfWidth + (x*Display.vWscale);
|
dir[0] = -Display.scrHalfWidth + (x*Display.vWscale);
|
||||||
dir[1] = Display.scrHalfHeight - (y*Display.vHscale);
|
dir[1] = Display.scrHalfHeight - (y*Display.vHscale);
|
||||||
dir[2] = Display.scrDist;
|
dir[2] = Display.scrDist;
|
||||||
dir[3] = 0.0;
|
dir[3] = 0.0;
|
||||||
|
|
||||||
/* Transform ray back to world. */
|
/* Transform ray back to world. */
|
||||||
TransformViewRay(dir);
|
TransformViewRay(dir);
|
||||||
|
|
||||||
VecNorm(dir);
|
VecNorm(dir);
|
||||||
VecCopy(ray->D, dir);
|
VecCopy(ray->D, dir);
|
||||||
VecCopy(ray->P, View.eye);
|
VecCopy(ray->P, View.eye);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Orthographic projection. */
|
/* Orthographic projection. */
|
||||||
|
|
||||||
dir[0] = 0.0;
|
dir[0] = 0.0;
|
||||||
dir[1] = 0.0;
|
dir[1] = 0.0;
|
||||||
dir[2] = 1.0;
|
dir[2] = 1.0;
|
||||||
dir[3] = 0.0;
|
dir[3] = 0.0;
|
||||||
|
|
||||||
/* Transform ray back to world. */
|
/* Transform ray back to world. */
|
||||||
TransformViewRay(dir);
|
TransformViewRay(dir);
|
||||||
VecNorm(dir);
|
VecNorm(dir);
|
||||||
|
|
||||||
VecCopy(ray->D, dir);
|
VecCopy(ray->D, dir);
|
||||||
|
|
||||||
/* Calculate origin. */
|
/* Calculate origin. */
|
||||||
|
|
||||||
origin[0] = -Display.scrHalfWidth + (x*Display.vWscale);
|
origin[0] = -Display.scrHalfWidth + (x*Display.vWscale);
|
||||||
origin[1] = Display.scrHalfHeight - (y*Display.vHscale);
|
origin[1] = Display.scrHalfHeight - (y*Display.vHscale);
|
||||||
origin[2] = 0.0;
|
origin[2] = 0.0;
|
||||||
origin[3] = 1.0;
|
origin[3] = 1.0;
|
||||||
|
|
||||||
/* Transform origin back to world. */
|
/* Transform origin back to world. */
|
||||||
|
|
||||||
TransformViewRay(origin);
|
TransformViewRay(origin);
|
||||||
VecCopy(ray->P, origin);
|
VecCopy(ray->P, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Initialize other fields of ray message. */
|
/* Initialize other fields of ray message. */
|
||||||
|
|
||||||
ray->level = 0;
|
ray->level = 0;
|
||||||
ray->weight = 1.0/(REAL)NumSubRays;
|
ray->weight = 1.0/(REAL)NumSubRays;
|
||||||
|
|
||||||
LOCK(gm->ridlock);
|
LOCK(gm->ridlock);
|
||||||
ray->id = gm->rid++;
|
ray->id = gm->rid++;
|
||||||
UNLOCK(gm->ridlock);
|
UNLOCK(gm->ridlock);
|
||||||
|
|
||||||
ray->x = (INT)x;
|
ray->x = (INT)x;
|
||||||
ray->y = (INT)y;
|
ray->y = (INT)y;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,97 +217,97 @@ VOID ConvertPrimRayJobToRayMsg(RAY *ray, REAL x, REAL y)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID RayTrace(INT pid)
|
VOID RayTrace(INT pid)
|
||||||
{
|
{
|
||||||
INT j;
|
INT j;
|
||||||
INT x, y; /* Pixel address. */
|
INT x, y; /* Pixel address. */
|
||||||
REAL xx, yy;
|
REAL xx, yy;
|
||||||
VEC3 N; /* Normal at intersection. */
|
VEC3 N; /* Normal at intersection. */
|
||||||
VEC3 Ipoint; /* Intersection point. */
|
VEC3 Ipoint; /* Intersection point. */
|
||||||
COLOR c; /* Color for storing background. */
|
COLOR c; /* Color for storing background. */
|
||||||
RAY *ray; /* Ray pointer. */
|
RAY *ray; /* Ray pointer. */
|
||||||
RAY rmsg; /* Ray message. */
|
RAY rmsg; /* Ray message. */
|
||||||
RAYJOB job; /* Ray job from work pool. */
|
RAYJOB job; /* Ray job from work pool. */
|
||||||
OBJECT *po; /* Ptr to object. */
|
OBJECT *po; /* Ptr to object. */
|
||||||
BOOL hit; /* An object hit? */
|
BOOL hit; /* An object hit? */
|
||||||
IRECORD hitrecord; /* Intersection record. */
|
IRECORD hitrecord; /* Intersection record. */
|
||||||
|
|
||||||
ray = &rmsg;
|
ray = &rmsg;
|
||||||
|
|
||||||
while (GetJobs(&job, pid) != WPS_EMPTY)
|
while (GetJobs(&job, pid) != WPS_EMPTY)
|
||||||
{
|
{
|
||||||
while (GetRayJobFromBundle(&job, &x, &y))
|
while (GetRayJobFromBundle(&job, &x, &y))
|
||||||
{
|
{
|
||||||
/* Convert the ray job to the ray message format. */
|
/* Convert the ray job to the ray message format. */
|
||||||
|
|
||||||
xx = (REAL)x;
|
xx = (REAL)x;
|
||||||
yy = (REAL)y;
|
yy = (REAL)y;
|
||||||
|
|
||||||
if (AntiAlias)
|
if (AntiAlias)
|
||||||
for (j = 0; j < NumSubRays; j++)
|
for (j = 0; j < NumSubRays; j++)
|
||||||
{
|
{
|
||||||
ConvertPrimRayJobToRayMsg(ray, xx + frand(), yy + frand());
|
ConvertPrimRayJobToRayMsg(ray, xx + frand(), yy + frand());
|
||||||
PushRayTreeStack(ray, pid);
|
PushRayTreeStack(ray, pid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConvertPrimRayJobToRayMsg(ray, xx, yy);
|
ConvertPrimRayJobToRayMsg(ray, xx, yy);
|
||||||
PushRayTreeStack(ray, pid);
|
PushRayTreeStack(ray, pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (PopRayTreeStack(ray, pid) != RTS_EMPTY)
|
while (PopRayTreeStack(ray, pid) != RTS_EMPTY)
|
||||||
{
|
{
|
||||||
/* Find which object is closest along the ray. */
|
/* Find which object is closest along the ray. */
|
||||||
|
|
||||||
switch (TraversalType)
|
switch (TraversalType)
|
||||||
{
|
{
|
||||||
case TT_LIST:
|
case TT_LIST:
|
||||||
hit = Intersect(ray, &hitrecord);
|
hit = Intersect(ray, &hitrecord);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TT_HUG:
|
case TT_HUG:
|
||||||
hit = TraverseHierarchyUniform(ray, &hitrecord, pid);
|
hit = TraverseHierarchyUniform(ray, &hitrecord, pid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process the object ray hit. */
|
/* Process the object ray hit. */
|
||||||
|
|
||||||
if (hit)
|
if (hit)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Get parent object to be able to access
|
* Get parent object to be able to access
|
||||||
* object operations.
|
* object operations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
po = hitrecord.pelem->parent;
|
po = hitrecord.pelem->parent;
|
||||||
|
|
||||||
/* Calculate intersection point. */
|
/* Calculate intersection point. */
|
||||||
RayPoint(Ipoint, ray, hitrecord.t);
|
RayPoint(Ipoint, ray, hitrecord.t);
|
||||||
|
|
||||||
/* Calculate normal at this point. */
|
/* Calculate normal at this point. */
|
||||||
(*po->procs->normal)(&hitrecord, Ipoint, N);
|
(*po->procs->normal)(&hitrecord, Ipoint, N);
|
||||||
|
|
||||||
/* Make sure normal is pointing toward ray origin. */
|
/* Make sure normal is pointing toward ray origin. */
|
||||||
if ((VecDot(ray->D, N)) > 0.0)
|
if ((VecDot(ray->D, N)) > 0.0)
|
||||||
VecNegate(N, N);
|
VecNegate(N, N);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compute shade at this point - will process
|
* Compute shade at this point - will process
|
||||||
* shadow rays and add secondary reflection
|
* shadow rays and add secondary reflection
|
||||||
* and refraction rays to ray tree stack
|
* and refraction rays to ray tree stack
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Shade(Ipoint, N, ray, &hitrecord, pid);
|
Shade(Ipoint, N, ray, &hitrecord, pid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Add background as pixel contribution. */
|
/* Add background as pixel contribution. */
|
||||||
|
|
||||||
VecCopy(c, View.bkg);
|
VecCopy(c, View.bkg);
|
||||||
VecScale(c, ray->weight, c);
|
VecScale(c, ray->weight, c);
|
||||||
AddPixelColor(c, ray->x, ray->y);
|
AddPixelColor(c, ray->x, ray->y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -30,11 +30,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <cmath>
|
#include <stdio.h>
|
||||||
#include <cstdio>
|
#include <math.h>
|
||||||
|
|
||||||
#include "rt.h"
|
#include "rt.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NAME
|
* NAME
|
||||||
* PutJob - put another job into pid's work pool
|
* PutJob - put another job into pid's work pool
|
||||||
|
@ -64,65 +65,65 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID PutJob(INT xs, INT ys, INT xe, INT ye, INT xbe, INT ybe, INT pid)
|
VOID PutJob(INT xs, INT ys, INT xe, INT ye, INT xbe, INT ybe, INT pid)
|
||||||
{
|
{
|
||||||
INT i, j;
|
INT i, j;
|
||||||
INT xb_addr, yb_addr; /* Bundle pixel address. */
|
INT xb_addr, yb_addr; /* Bundle pixel address. */
|
||||||
INT xb_end, yb_end; /* End bundle pixels. */
|
INT xb_end, yb_end; /* End bundle pixels. */
|
||||||
INT xb_size, yb_size; /* Bundle size. */
|
INT xb_size, yb_size; /* Bundle size. */
|
||||||
WPJOB *wpentry; /* New work pool entry. */
|
WPJOB *wpentry; /* New work pool entry. */
|
||||||
|
|
||||||
/* Starting block pixel address (upper left pixel). */
|
/* Starting block pixel address (upper left pixel). */
|
||||||
|
|
||||||
xb_addr = xs;
|
xb_addr = xs;
|
||||||
yb_addr = ys;
|
yb_addr = ys;
|
||||||
|
|
||||||
/* Ending block pixel address (lower right pixel). */
|
/* Ending block pixel address (lower right pixel). */
|
||||||
|
|
||||||
xb_end = xb_addr + xe - 1;
|
xb_end = xb_addr + xe - 1;
|
||||||
yb_end = yb_addr + ye - 1;
|
yb_end = yb_addr + ye - 1;
|
||||||
|
|
||||||
for (i = 0; i < ye; i += ybe)
|
for (i = 0; i < ye; i += ybe)
|
||||||
{
|
{
|
||||||
for (j = 0; j < xe; j += xbe)
|
for (j = 0; j < xe; j += xbe)
|
||||||
{
|
{
|
||||||
/* Determine bundle size. */
|
/* Determine bundle size. */
|
||||||
|
|
||||||
if ((xb_addr + xbe - 1) <= xb_end)
|
if ((xb_addr + xbe - 1) <= xb_end)
|
||||||
xb_size = xbe;
|
xb_size = xbe;
|
||||||
else
|
else
|
||||||
xb_size = xb_end - xb_addr + 1;
|
xb_size = xb_end - xb_addr + 1;
|
||||||
|
|
||||||
if ((yb_addr + ybe - 1) <= yb_end)
|
if ((yb_addr + ybe - 1) <= yb_end)
|
||||||
yb_size = ybe;
|
yb_size = ybe;
|
||||||
else
|
else
|
||||||
yb_size = yb_end - yb_addr + 1;
|
yb_size = yb_end - yb_addr + 1;
|
||||||
|
|
||||||
|
|
||||||
/* Initialize work pool entry. */
|
/* Initialize work pool entry. */
|
||||||
|
|
||||||
wpentry = GlobalMalloc(sizeof(WPJOB), "workpool.c");
|
wpentry = GlobalMalloc(sizeof(WPJOB), "workpool.c");
|
||||||
|
|
||||||
wpentry->xpix = xb_addr;
|
wpentry->xpix = xb_addr;
|
||||||
wpentry->ypix = yb_addr;
|
wpentry->ypix = yb_addr;
|
||||||
wpentry->xdim = xb_size;
|
wpentry->xdim = xb_size;
|
||||||
wpentry->ydim = yb_size;
|
wpentry->ydim = yb_size;
|
||||||
|
|
||||||
|
|
||||||
/* Add to top of work pool stack. */
|
/* Add to top of work pool stack. */
|
||||||
|
|
||||||
if (!gm->workpool[pid][0])
|
if (!gm->workpool[pid][0])
|
||||||
wpentry->next = NULL;
|
wpentry->next = NULL;
|
||||||
else
|
else
|
||||||
wpentry->next = gm->workpool[pid][0];
|
wpentry->next = gm->workpool[pid][0];
|
||||||
|
|
||||||
gm->workpool[pid][0] = wpentry;
|
gm->workpool[pid][0] = wpentry;
|
||||||
xb_addr += xbe;
|
xb_addr += xbe;
|
||||||
}
|
}
|
||||||
|
|
||||||
xb_addr = xs;
|
xb_addr = xs;
|
||||||
yb_addr += ybe;
|
yb_addr += ybe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,34 +146,34 @@ VOID PutJob(INT xs, INT ys, INT xe, INT ye, INT xbe, INT ybe, INT pid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INT GetJob(RAYJOB *job, INT pid)
|
INT GetJob(RAYJOB *job, INT pid)
|
||||||
{
|
{
|
||||||
WPJOB *wpentry; /* Work pool entry. */
|
WPJOB *wpentry; /* Work pool entry. */
|
||||||
|
|
||||||
ALOCK(gm->wplock, pid)
|
ALOCK(gm->wplock, pid)
|
||||||
wpentry = gm->workpool[pid][0];
|
wpentry = gm->workpool[pid][0];
|
||||||
|
|
||||||
if (!wpentry)
|
if (!wpentry)
|
||||||
{
|
{
|
||||||
gm->wpstat[pid][0] = WPS_EMPTY;
|
gm->wpstat[pid][0] = WPS_EMPTY;
|
||||||
AULOCK(gm->wplock, pid)
|
AULOCK(gm->wplock, pid)
|
||||||
return (WPS_EMPTY);
|
return (WPS_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
gm->workpool[pid][0] = wpentry->next;
|
gm->workpool[pid][0] = wpentry->next;
|
||||||
AULOCK(gm->wplock, pid)
|
AULOCK(gm->wplock, pid)
|
||||||
|
|
||||||
/* Set up ray job information. */
|
/* Set up ray job information. */
|
||||||
|
|
||||||
job->x = wpentry->xpix;
|
job->x = wpentry->xpix;
|
||||||
job->y = wpentry->ypix;
|
job->y = wpentry->ypix;
|
||||||
job->xcurr = wpentry->xpix;
|
job->xcurr = wpentry->xpix;
|
||||||
job->ycurr = wpentry->ypix;
|
job->ycurr = wpentry->ypix;
|
||||||
job->xlen = wpentry->xdim;
|
job->xlen = wpentry->xdim;
|
||||||
job->ylen = wpentry->ydim;
|
job->ylen = wpentry->ydim;
|
||||||
|
|
||||||
GlobalFree(wpentry);
|
GlobalFree(wpentry);
|
||||||
return (WPS_VALID);
|
return (WPS_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,40 +193,40 @@ INT GetJob(RAYJOB *job, INT pid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
INT GetJobs(RAYJOB *job, INT pid)
|
INT GetJobs(RAYJOB *job, INT pid)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
|
|
||||||
i = pid;
|
i = pid;
|
||||||
|
|
||||||
/* First, try to get job from pid's own pool (or pool 0). */
|
/* First, try to get job from pid's own pool (or pool 0). */
|
||||||
|
|
||||||
if (gm->wpstat[i][0] == WPS_VALID)
|
if (gm->wpstat[i][0] == WPS_VALID)
|
||||||
if (GetJob(job, i) == WPS_VALID)
|
if (GetJob(job, i) == WPS_VALID)
|
||||||
{
|
{
|
||||||
return (WPS_VALID);
|
return (WPS_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If that failed, try to get job from another pid's work
|
* If that failed, try to get job from another pid's work
|
||||||
* pool.
|
* pool.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
i = (pid + 1) % gm->nprocs;
|
i = (pid + 1) % gm->nprocs;
|
||||||
|
|
||||||
while (i != pid)
|
while (i != pid)
|
||||||
{
|
{
|
||||||
if (gm->wpstat[i][0] == WPS_VALID)
|
if (gm->wpstat[i][0] == WPS_VALID)
|
||||||
if (GetJob(job, i) == WPS_VALID)
|
if (GetJob(job, i) == WPS_VALID)
|
||||||
{
|
{
|
||||||
return (WPS_VALID);
|
return (WPS_VALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = (i + 1) % gm->nprocs;
|
i = (i + 1) % gm->nprocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (WPS_EMPTY);
|
return (WPS_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,17 +243,17 @@ INT GetJobs(RAYJOB *job, INT pid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID PrintWorkPool(INT pid)
|
VOID PrintWorkPool(INT pid)
|
||||||
{
|
{
|
||||||
WPJOB *j;
|
WPJOB *j;
|
||||||
|
|
||||||
j = gm->workpool[pid][0];
|
j = gm->workpool[pid][0];
|
||||||
|
|
||||||
while (j)
|
while (j)
|
||||||
{
|
{
|
||||||
printf("Workpool entry: pid=%3ld xs=%3ld ys=%3ld xe=%3ld ye=%3ld\n", pid, j->xpix, j->ypix, j->xdim, j->ydim);
|
printf("Workpool entry: pid=%3ld xs=%3ld ys=%3ld xe=%3ld ye=%3ld\n", pid, j->xpix, j->ypix, j->xdim, j->ydim);
|
||||||
j = j->next;
|
j = j->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -269,39 +270,39 @@ VOID PrintWorkPool(INT pid)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID InitWorkPool(INT pid)
|
VOID InitWorkPool(INT pid)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
INT x, y;
|
INT x, y;
|
||||||
INT xe, ye;
|
INT xe, ye;
|
||||||
INT xsize, ysize;
|
INT xsize, ysize;
|
||||||
|
|
||||||
gm->wpstat[pid][0] = WPS_VALID;
|
gm->wpstat[pid][0] = WPS_VALID;
|
||||||
gm->workpool[pid][0] = NULL;
|
gm->workpool[pid][0] = NULL;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
xsize = Display.xres/blockx;
|
xsize = Display.xres/blockx;
|
||||||
ysize = Display.yres/blocky;
|
ysize = Display.yres/blocky;
|
||||||
|
|
||||||
for (y = 0; y < Display.yres; y += ysize)
|
for (y = 0; y < Display.yres; y += ysize)
|
||||||
{
|
{
|
||||||
if (y + ysize > Display.yres)
|
if (y + ysize > Display.yres)
|
||||||
ye = Display.yres - y;
|
ye = Display.yres - y;
|
||||||
else
|
else
|
||||||
ye = ysize;
|
ye = ysize;
|
||||||
|
|
||||||
for (x = 0; x < Display.xres; x += xsize)
|
for (x = 0; x < Display.xres; x += xsize)
|
||||||
{
|
{
|
||||||
if (x + xsize > Display.xres)
|
if (x + xsize > Display.xres)
|
||||||
xe = Display.xres - x;
|
xe = Display.xres - x;
|
||||||
else
|
else
|
||||||
xe = xsize;
|
xe = xsize;
|
||||||
|
|
||||||
if (i == pid)
|
if (i == pid)
|
||||||
PutJob(x, y, xe, ye, bundlex, bundley, pid);
|
PutJob(x, y, xe, ye, bundlex, bundley, pid);
|
||||||
|
|
||||||
i = (i + 1)%gm->nprocs;
|
i = (i + 1)%gm->nprocs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
#include "incl.h"
|
#include "incl.h"
|
||||||
|
|
||||||
float invjacobian[NM][NM]; /* Jacobian matrix showing object space */
|
float invjacobian[NM][NM]; /* Jacobian matrix showing object space */
|
||||||
/* d{x,y,z} per image space d{x,y,z} */
|
/* d{x,y,z} per image space d{x,y,z} */
|
||||||
/* [0][0] is dx(object)/dx(image) */
|
/* [0][0] is dx(object)/dx(image) */
|
||||||
/* [0][2] is dz(object)/dx(image) */
|
/* [0][2] is dz(object)/dx(image) */
|
||||||
/* [2][0] is dx(object)/dz(image) */
|
/* [2][0] is dx(object)/dz(image) */
|
||||||
float invinvjacobian[NM][NM]; /* [i][j] = 1.0 / invjacobian[i][j] */
|
float invinvjacobian[NM][NM]; /* [i][j] = 1.0 / invjacobian[i][j] */
|
||||||
/* For gathering statistics: */
|
/* For gathering statistics: */
|
||||||
long num_rays_traced; /* number of calls to Trace_Ray */
|
long num_rays_traced; /* number of calls to Trace_Ray */
|
||||||
|
@ -75,7 +75,7 @@ void Ray_Trace(long my_node)
|
||||||
for (i=0; i<NM; i++) {
|
for (i=0; i<NM; i++) {
|
||||||
for (j=0; j<NM; j++) {
|
for (j=0; j<NM; j++) {
|
||||||
if (ABS(invjacobian[i][j]) > SMALL)
|
if (ABS(invjacobian[i][j]) > SMALL)
|
||||||
invinvjacobian[i][j] = 1.0 / invjacobian[i][j];
|
invinvjacobian[i][j] = 1.0 / invjacobian[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,8 +149,8 @@ void Ray_Trace(long my_node)
|
||||||
|
|
||||||
LOCK(Global->CountLock);
|
LOCK(Global->CountLock);
|
||||||
printf("%3ld\t%3ld\t%6ld\t%6ld\t%6ld\t%6ld\t%8ld\n",my_node,frame,exectime,
|
printf("%3ld\t%3ld\t%6ld\t%6ld\t%6ld\t%6ld\t%8ld\n",my_node,frame,exectime,
|
||||||
exectime1,num_rays_traced,num_traced_rays_hit_volume,
|
exectime1,num_rays_traced,num_traced_rays_hit_volume,
|
||||||
num_samples_trilirped);
|
num_samples_trilirped);
|
||||||
|
|
||||||
UNLOCK(Global->CountLock);
|
UNLOCK(Global->CountLock);
|
||||||
|
|
||||||
|
@ -192,14 +192,14 @@ void Ray_Trace_Adaptively(long my_node)
|
||||||
xindex = xstart + (work%lnum_xblocks)*block_xlen;
|
xindex = xstart + (work%lnum_xblocks)*block_xlen;
|
||||||
yindex = ystart + (work/lnum_xblocks)*block_ylen;
|
yindex = ystart + (work/lnum_xblocks)*block_ylen;
|
||||||
for (outy=yindex; outy<yindex+block_ylen && outy<ystop;
|
for (outy=yindex; outy<yindex+block_ylen && outy<ystop;
|
||||||
outy+=highest_sampling_boxlen) {
|
outy+=highest_sampling_boxlen) {
|
||||||
for (outx=xindex; outx<xindex+block_xlen && outx<xstop;
|
for (outx=xindex; outx<xindex+block_xlen && outx<xstop;
|
||||||
outx+=highest_sampling_boxlen) {
|
outx+=highest_sampling_boxlen) {
|
||||||
|
|
||||||
/* Trace rays within square box of highest sampling size */
|
/* Trace rays within square box of highest sampling size */
|
||||||
/* whose lower-left corner is current image space location. */
|
/* whose lower-left corner is current image space location. */
|
||||||
Ray_Trace_Adaptive_Box(outx,outy,highest_sampling_boxlen);
|
Ray_Trace_Adaptive_Box(outx,outy,highest_sampling_boxlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ALOCK(Global->QLock,local_node);
|
ALOCK(Global->QLock,local_node);
|
||||||
work = Global->Queue[local_node][0];
|
work = Global->Queue[local_node][0];
|
||||||
|
@ -213,7 +213,7 @@ void Ray_Trace_Adaptively(long my_node)
|
||||||
}
|
}
|
||||||
local_node = (local_node+1)%num_nodes;
|
local_node = (local_node+1)%num_nodes;
|
||||||
while (Global->Queue[local_node][0] >= lnum_blocks &&
|
while (Global->Queue[local_node][0] >= lnum_blocks &&
|
||||||
Global->Queue[num_nodes][0] > 0)
|
Global->Queue[num_nodes][0] > 0)
|
||||||
local_node = (local_node+1)%num_nodes;
|
local_node = (local_node+1)%num_nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,21 +264,21 @@ void Ray_Trace_Adaptive_Box(long outx, long outy, long boxlen)
|
||||||
|
|
||||||
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
||||||
|
|
||||||
MASK_IMAGE(outy+i,outx+j) = START_RAY;
|
MASK_IMAGE(outy+i,outx+j) = START_RAY;
|
||||||
|
|
||||||
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
||||||
|
|
||||||
foutx = (float)(outx+j);
|
foutx = (float)(outx+j);
|
||||||
fouty = (float)(outy+i);
|
fouty = (float)(outy+i);
|
||||||
pixel_address = IMAGE_ADDRESS(outy+i,outx+j);
|
pixel_address = IMAGE_ADDRESS(outy+i,outx+j);
|
||||||
|
|
||||||
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
||||||
|
|
||||||
Trace_Ray(foutx,fouty,pixel_address);
|
Trace_Ray(foutx,fouty,pixel_address);
|
||||||
|
|
||||||
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
||||||
|
|
||||||
MASK_IMAGE(outy+i,outx+j) = RAY_TRACED;
|
MASK_IMAGE(outy+i,outx+j) = RAY_TRACED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ void Ray_Trace_Adaptive_Box(long outx, long outy, long boxlen)
|
||||||
|
|
||||||
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
||||||
|
|
||||||
imask = MASK_IMAGE(outy+i,outx+j);
|
imask = MASK_IMAGE(outy+i,outx+j);
|
||||||
|
|
||||||
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
/*reschedule processes here if rescheduling only at synch points on simulator*/
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ void Ray_Trace_Adaptive_Box(long outx, long outy, long boxlen)
|
||||||
half_boxlen = boxlen >> 1;
|
half_boxlen = boxlen >> 1;
|
||||||
for (i=0; i<boxlen && outy+i<image_len[Y]; i+=half_boxlen) {
|
for (i=0; i<boxlen && outy+i<image_len[Y]; i+=half_boxlen) {
|
||||||
for (j=0; j<boxlen && outx+j<image_len[X]; j+=half_boxlen) {
|
for (j=0; j<boxlen && outx+j<image_len[X]; j+=half_boxlen) {
|
||||||
Ray_Trace_Adaptive_Box(outx+j,outy+i,half_boxlen);
|
Ray_Trace_Adaptive_Box(outx+j,outy+i,half_boxlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,15 +354,15 @@ void Ray_Trace_Non_Adaptively(long my_node)
|
||||||
xindex = xstart + (work%lnum_xblocks)*block_xlen;
|
xindex = xstart + (work%lnum_xblocks)*block_xlen;
|
||||||
yindex = ystart + (work/lnum_xblocks)*block_ylen;
|
yindex = ystart + (work/lnum_xblocks)*block_ylen;
|
||||||
for (outy=yindex; outy<yindex+block_ylen && outy<ystop; outy++) {
|
for (outy=yindex; outy<yindex+block_ylen && outy<ystop; outy++) {
|
||||||
for (outx=xindex; outx<xindex+block_xlen && outx<xstop; outx++) {
|
for (outx=xindex; outx<xindex+block_xlen && outx<xstop; outx++) {
|
||||||
|
|
||||||
/* Trace ray from specified image space location into map. */
|
/* Trace ray from specified image space location into map. */
|
||||||
/* Stochastic sampling is as described in adaptive code. */
|
/* Stochastic sampling is as described in adaptive code. */
|
||||||
foutx = (float)(outx);
|
foutx = (float)(outx);
|
||||||
fouty = (float)(outy);
|
fouty = (float)(outy);
|
||||||
pixel_address = IMAGE_ADDRESS(outy,outx);
|
pixel_address = IMAGE_ADDRESS(outy,outx);
|
||||||
Trace_Ray(foutx,fouty,pixel_address);
|
Trace_Ray(foutx,fouty,pixel_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ALOCK(Global->QLock,local_node);
|
ALOCK(Global->QLock,local_node);
|
||||||
work = Global->Queue[local_node][0]++;
|
work = Global->Queue[local_node][0]++;
|
||||||
|
@ -375,7 +375,7 @@ void Ray_Trace_Non_Adaptively(long my_node)
|
||||||
}
|
}
|
||||||
local_node = (local_node+1)%num_nodes;
|
local_node = (local_node+1)%num_nodes;
|
||||||
while (Global->Queue[local_node][0] >= lnum_blocks &&
|
while (Global->Queue[local_node][0] >= lnum_blocks &&
|
||||||
Global->Queue[num_nodes][0] > 0)
|
Global->Queue[num_nodes][0] > 0)
|
||||||
local_node = (local_node+1)%num_nodes;
|
local_node = (local_node+1)%num_nodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,14 +396,14 @@ void Ray_Trace_Fast_Non_Adaptively(long my_node)
|
||||||
for (outx=xindex; outx<xindex+block_xlen &&
|
for (outx=xindex; outx<xindex+block_xlen &&
|
||||||
outx<image_len[X]; outx+=lowest_volume_boxlen) {
|
outx<image_len[X]; outx+=lowest_volume_boxlen) {
|
||||||
|
|
||||||
/* Trace ray from specified image space location into map. */
|
/* Trace ray from specified image space location into map. */
|
||||||
/* Stochastic sampling is as described in adaptive code. */
|
/* Stochastic sampling is as described in adaptive code. */
|
||||||
MASK_IMAGE(outy,outx) += RAY_TRACED;
|
MASK_IMAGE(outy,outx) += RAY_TRACED;
|
||||||
foutx = (float)(outx);
|
foutx = (float)(outx);
|
||||||
fouty = (float)(outy);
|
fouty = (float)(outy);
|
||||||
pixel_address = IMAGE_ADDRESS(outy,outx);
|
pixel_address = IMAGE_ADDRESS(outy,outx);
|
||||||
Trace_Ray(foutx,fouty,pixel_address);
|
Trace_Ray(foutx,fouty,pixel_address);
|
||||||
num_rays_traced++;
|
num_rays_traced++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,9 +423,9 @@ void Interpolate_Recursively(long my_node)
|
||||||
for (outx=xindex; outx<xindex+block_xlen &&
|
for (outx=xindex; outx<xindex+block_xlen &&
|
||||||
outx<image_len[X]; outx+=highest_sampling_boxlen) {
|
outx<image_len[X]; outx+=highest_sampling_boxlen) {
|
||||||
|
|
||||||
/* Fill in image within square box of highest sampling size */
|
/* Fill in image within square box of highest sampling size */
|
||||||
/* whose lower-left corner is current image space location. */
|
/* whose lower-left corner is current image space location. */
|
||||||
Interpolate_Recursive_Box(outx,outy,highest_sampling_boxlen);
|
Interpolate_Recursive_Box(outx,outy,highest_sampling_boxlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,12 +472,12 @@ void Interpolate_Recursive_Box(long outx, long outy, long boxlen)
|
||||||
xalpha = (float)j * one_over_boxlen;
|
xalpha = (float)j * one_over_boxlen;
|
||||||
one_minus_xalpha = 1.0 - xalpha;
|
one_minus_xalpha = 1.0 - xalpha;
|
||||||
if (MASK_IMAGE(outy+i,outx+j) == 0) {
|
if (MASK_IMAGE(outy+i,outx+j) == 0) {
|
||||||
color = corner_color[0][0]*one_minus_xalpha*one_minus_yalpha+
|
color = corner_color[0][0]*one_minus_xalpha*one_minus_yalpha+
|
||||||
corner_color[0][1]*xalpha*one_minus_yalpha+
|
corner_color[0][1]*xalpha*one_minus_yalpha+
|
||||||
corner_color[1][0]*one_minus_xalpha*yalpha+
|
corner_color[1][0]*one_minus_xalpha*yalpha+
|
||||||
corner_color[1][1]*xalpha*yalpha;
|
corner_color[1][1]*xalpha*yalpha;
|
||||||
IMAGE(outy+i,outx+j) = color;
|
IMAGE(outy+i,outx+j) = color;
|
||||||
MASK_IMAGE(outy+i,outx+j) += INTERPOLATED;
|
MASK_IMAGE(outy+i,outx+j) += INTERPOLATED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ void Interpolate_Recursive_Box(long outx, long outy, long boxlen)
|
||||||
if (half_boxlen > 1) {
|
if (half_boxlen > 1) {
|
||||||
for (i=0; i<boxlen && outy+i<image_len[Y]; i+=half_boxlen) {
|
for (i=0; i<boxlen && outy+i<image_len[Y]; i+=half_boxlen) {
|
||||||
for (j=0; j<boxlen && outx+j<image_len[X]; j+=half_boxlen) {
|
for (j=0; j<boxlen && outx+j<image_len[X]; j+=half_boxlen) {
|
||||||
Interpolate_Recursive_Box(outx+j,outy+i,half_boxlen);
|
Interpolate_Recursive_Box(outx+j,outy+i,half_boxlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,63 +21,63 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* Fast subscripted access to map */
|
/* Fast subscripted access to map */
|
||||||
/* (assumes mins = 0 and chars) */
|
/* (assumes mins = 0 and chars) */
|
||||||
#define MAP_ADDRESS(IZ,IY,IX) (map_address+\
|
#define MAP_ADDRESS(IZ,IY,IX) (map_address+\
|
||||||
((IZ)*map_len[Y]+(IY))*map_len[X]+(IX))
|
((IZ)*map_len[Y]+(IY))*map_len[X]+(IX))
|
||||||
#define MAP(IZ,IY,IX) (*MAP_ADDRESS(IZ,IY,IX))
|
#define MAP(IZ,IY,IX) (*MAP_ADDRESS(IZ,IY,IX))
|
||||||
|
|
||||||
|
|
||||||
/* Fast subscripted access to map */
|
/* Fast subscripted access to map */
|
||||||
/* (assumes mins = 0 and chars) */
|
/* (assumes mins = 0 and chars) */
|
||||||
#define GMAG_ADDRESS(IZ,IY,IX) (gmag_address+\
|
#define GMAG_ADDRESS(IZ,IY,IX) (gmag_address+\
|
||||||
((IZ)*gmag_len[Y]+(IY))*gmag_len[X]+(IX))
|
((IZ)*gmag_len[Y]+(IY))*gmag_len[X]+(IX))
|
||||||
#define GMAG(IZ,IY,IX) (*GMAG_ADDRESS(IZ,IY,IX))
|
#define GMAG(IZ,IY,IX) (*GMAG_ADDRESS(IZ,IY,IX))
|
||||||
|
|
||||||
|
|
||||||
/* Subscripted access to normal map */
|
/* Subscripted access to normal map */
|
||||||
/* (NM GRADIENTs at each IX,IY,IZ) */
|
/* (NM GRADIENTs at each IX,IY,IZ) */
|
||||||
|
|
||||||
#define TADDR(IZ,IY,IX) (LOOKUP_HSIZE+((IZ)*LOOKUP_PREC+(IY))*2+(IX))
|
#define TADDR(IZ,IY,IX) (LOOKUP_HSIZE+((IZ)*LOOKUP_PREC+(IY))*2+(IX))
|
||||||
|
|
||||||
#define NORM_ADDRESS(IZ,IY,IX,D) (norm_address+\
|
#define NORM_ADDRESS(IZ,IY,IX,D) (norm_address+\
|
||||||
((IZ)*norm_len[Y]+(IY))*norm_len[X]+(IX))
|
((IZ)*norm_len[Y]+(IY))*norm_len[X]+(IX))
|
||||||
|
|
||||||
#define NORM(IZ,IY,IX,D) (*NORM_ADDRESS(IZ,IY,IX,D))
|
#define NORM(IZ,IY,IX,D) (*NORM_ADDRESS(IZ,IY,IX,D))
|
||||||
|
|
||||||
|
|
||||||
/* Subscripted access to opacity map */
|
/* Subscripted access to opacity map */
|
||||||
/* (1 char at each IX,IY,IZ) */
|
/* (1 char at each IX,IY,IZ) */
|
||||||
#define OPC_ADDRESS(IZ,IY,IX) (opc_address+\
|
#define OPC_ADDRESS(IZ,IY,IX) (opc_address+\
|
||||||
((IZ)*opc_len[Y]+(IY))*opc_len[X]+(IX))
|
((IZ)*opc_len[Y]+(IY))*opc_len[X]+(IX))
|
||||||
#define OPC(IZ,IY,IX) (*OPC_ADDRESS(IZ,IY,IX))
|
#define OPC(IZ,IY,IX) (*OPC_ADDRESS(IZ,IY,IX))
|
||||||
|
|
||||||
|
|
||||||
/* Subscripted access to normal map */
|
/* Subscripted access to normal map */
|
||||||
/* (NM GRADIENTs at each IX,IY,IZ) */
|
/* (NM GRADIENTs at each IX,IY,IZ) */
|
||||||
#define VOX_ADDRESS(IZ,IY,IX,D) (vox_address+\
|
#define VOX_ADDRESS(IZ,IY,IX,D) (vox_address+\
|
||||||
(((IZ)*vox_len[Y]+(IY))*vox_len[X]+(IX))*\
|
(((IZ)*vox_len[Y]+(IY))*vox_len[X]+(IX))*\
|
||||||
2+(D))
|
2+(D))
|
||||||
#define VOX(IZ,IY,IX,D) (*VOX_ADDRESS(IZ,IY,IX,D))
|
#define VOX(IZ,IY,IX,D) (*VOX_ADDRESS(IZ,IY,IX,D))
|
||||||
|
|
||||||
|
|
||||||
#define PYR_ADDRESS(ILEVEL,IZ,IY,IX)\
|
#define PYR_ADDRESS(ILEVEL,IZ,IY,IX)\
|
||||||
(pyr_offset1=\
|
(pyr_offset1=\
|
||||||
((IZ)*pyr_len[ILEVEL][Y]+(IY))*\
|
((IZ)*pyr_len[ILEVEL][Y]+(IY))*\
|
||||||
pyr_len[ILEVEL][X]+(IX),\
|
pyr_len[ILEVEL][X]+(IX),\
|
||||||
pyr_offset2=pyr_offset1&7,\
|
pyr_offset2=pyr_offset1&7,\
|
||||||
pyr_address2=pyr_address[ILEVEL]+\
|
pyr_address2=pyr_address[ILEVEL]+\
|
||||||
(pyr_offset1>>3))
|
(pyr_offset1>>3))
|
||||||
#define PYR(ILEVEL,IZ,IY,IX)\
|
#define PYR(ILEVEL,IZ,IY,IX)\
|
||||||
(PYR_ADDRESS(ILEVEL,IZ,IY,IX),\
|
(PYR_ADDRESS(ILEVEL,IZ,IY,IX),\
|
||||||
(*pyr_address2>>pyr_offset2)&1)
|
(*pyr_address2>>pyr_offset2)&1)
|
||||||
|
|
||||||
|
|
||||||
#define IMAGE_ADDRESS(IY,IX) (image_address+(IY)*image_len[X]+(IX))
|
#define IMAGE_ADDRESS(IY,IX) (image_address+(IY)*image_len[X]+(IX))
|
||||||
#define IMAGE(IY,IX) (*IMAGE_ADDRESS(IY,IX))
|
#define IMAGE(IY,IX) (*IMAGE_ADDRESS(IY,IX))
|
||||||
|
|
||||||
/* Access to mask image */
|
/* Access to mask image */
|
||||||
#define MASK_IMAGE_ADDRESS(IY,IX) \
|
#define MASK_IMAGE_ADDRESS(IY,IX) \
|
||||||
(mask_image_address+\
|
(mask_image_address+\
|
||||||
(IY)*mask_image_len[X]+(IX))
|
(IY)*mask_image_len[X]+(IX))
|
||||||
#define MASK_IMAGE(IY,IX) (*MASK_IMAGE_ADDRESS(IY,IX))
|
#define MASK_IMAGE(IY,IX) (*MASK_IMAGE_ADDRESS(IY,IX))
|
||||||
|
|
|
@ -44,13 +44,13 @@
|
||||||
#define YES 1
|
#define YES 1
|
||||||
#define NO 0
|
#define NO 0
|
||||||
|
|
||||||
/* Definition of object space coordinates: */
|
/* Definition of object space coordinates: */
|
||||||
#define NM 3 /* number of coordinates */
|
#define NM 3 /* number of coordinates */
|
||||||
#define X 0 /* x-coordinate */
|
#define X 0 /* x-coordinate */
|
||||||
#define Y 1 /* y-coordinate */
|
#define Y 1 /* y-coordinate */
|
||||||
#define Z 2 /* z-coordinate */
|
#define Z 2 /* z-coordinate */
|
||||||
|
|
||||||
/* Definition of pixel image coordinates: */
|
/* Definition of pixel image coordinates: */
|
||||||
#define NI 2 /* number of coordinates */
|
#define NI 2 /* number of coordinates */
|
||||||
|
|
||||||
/* NORMAL constant using 16-bit signed short */
|
/* NORMAL constant using 16-bit signed short */
|
||||||
|
@ -71,11 +71,11 @@
|
||||||
#define NULL_PIXEL 0 /* initialization value for pixel */
|
#define NULL_PIXEL 0 /* initialization value for pixel */
|
||||||
#define PIX_CUR_VERSION 1 /* version of .pix file used */
|
#define PIX_CUR_VERSION 1 /* version of .pix file used */
|
||||||
|
|
||||||
/* Definition of string sizes: */
|
/* Definition of string sizes: */
|
||||||
#define FILENAME_SIZE 80 /* max user filename */
|
#define FILENAME_SIZE 80 /* max user filename */
|
||||||
#define FILENAME_STRING_SIZE (FILENAME_SIZE+1) /* + 1 for null char */
|
#define FILENAME_STRING_SIZE (FILENAME_SIZE+1) /* + 1 for null char */
|
||||||
|
|
||||||
/* Definition of minimum and maximum values: */
|
/* Definition of minimum and maximum values: */
|
||||||
#define MIN_DENSITY 0 /* density */
|
#define MIN_DENSITY 0 /* density */
|
||||||
#define MAX_DENSITY 255 /* density */
|
#define MAX_DENSITY 255 /* density */
|
||||||
#define MIN_MAGNITUDE 0 /* magnitude of density gradient */
|
#define MIN_MAGNITUDE 0 /* magnitude of density gradient */
|
||||||
|
@ -99,5 +99,5 @@
|
||||||
/* operator not 5x5 */
|
/* operator not 5x5 */
|
||||||
|
|
||||||
#define MAX_PYRLEVEL 9 /* Maximum level in binary pyramid */
|
#define MAX_PYRLEVEL 9 /* Maximum level in binary pyramid */
|
||||||
/* (allows 1x1x1..512x512x512 voxels) */
|
/* (allows 1x1x1..512x512x512 voxels) */
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
/********** storing/loading of large arrays to/from files **********/
|
/********** storing/loading of large arrays to/from files **********/
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "incl.h"
|
#include "incl.h"
|
||||||
|
|
||||||
#define PMODE 0644 /* RW for owner, R for group, R for others */
|
#define PMODE 0644 /* RW for owner, R for group, R for others */
|
||||||
|
@ -53,7 +52,7 @@ void Write_Bytes(int fd, unsigned char array[], long length)
|
||||||
if (n_written != -1) {
|
if (n_written != -1) {
|
||||||
while (n_written < length) {
|
while (n_written < length) {
|
||||||
more_written = write(fd,&array[n_written],
|
more_written = write(fd,&array[n_written],
|
||||||
MIN(length-n_written,32766));
|
MIN(length-n_written,32766));
|
||||||
if (more_written == -1) break;
|
if (more_written == -1) break;
|
||||||
n_written += more_written;
|
n_written += more_written;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +79,7 @@ void Write_Shorts(int fd, unsigned char array[], long length)
|
||||||
if (n_written != -1) {
|
if (n_written != -1) {
|
||||||
while (n_written < length) {
|
while (n_written < length) {
|
||||||
more_written = write(fd,&array[n_written],
|
more_written = write(fd,&array[n_written],
|
||||||
MIN(length-n_written,32766));
|
MIN(length-n_written,32766));
|
||||||
if (more_written == -1) break;
|
if (more_written == -1) break;
|
||||||
n_written += more_written;
|
n_written += more_written;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +116,7 @@ void Write_Longs(int fd, unsigned char array[], long length)
|
||||||
if (n_written != -1) {
|
if (n_written != -1) {
|
||||||
while (n_written < length) {
|
while (n_written < length) {
|
||||||
more_written = write(fd,&array[n_written],
|
more_written = write(fd,&array[n_written],
|
||||||
MIN(length-n_written,32766));
|
MIN(length-n_written,32766));
|
||||||
if (more_written == -1) break;
|
if (more_written == -1) break;
|
||||||
n_written += more_written;
|
n_written += more_written;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +146,7 @@ void Read_Bytes(int fd, unsigned char array[], long length)
|
||||||
if (n_read != -1 && n_read != 0) {
|
if (n_read != -1 && n_read != 0) {
|
||||||
while (n_read < length) {
|
while (n_read < length) {
|
||||||
more_read = read(fd,&array[n_read],
|
more_read = read(fd,&array[n_read],
|
||||||
MIN(length-n_read,32766));
|
MIN(length-n_read,32766));
|
||||||
if (more_read == -1 || more_read == 0) break;
|
if (more_read == -1 || more_read == 0) break;
|
||||||
n_read += more_read;
|
n_read += more_read;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +166,7 @@ void Read_Shorts(int fd, unsigned char array[], long length)
|
||||||
if (n_read != -1 && n_read != 0) {
|
if (n_read != -1 && n_read != 0) {
|
||||||
while (n_read < length) {
|
while (n_read < length) {
|
||||||
more_read = read(fd,&array[n_read],
|
more_read = read(fd,&array[n_read],
|
||||||
MIN(length-n_read,32766));
|
MIN(length-n_read,32766));
|
||||||
if (more_read == -1 || more_read == 0) break;
|
if (more_read == -1 || more_read == 0) break;
|
||||||
n_read += more_read;
|
n_read += more_read;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +193,7 @@ void Read_Longs(int fd, unsigned char array[], long length)
|
||||||
if (n_read != -1 && n_read != 0) {
|
if (n_read != -1 && n_read != 0) {
|
||||||
while (n_read < length) {
|
while (n_read < length) {
|
||||||
more_read = read(fd,&array[n_read],
|
more_read = read(fd,&array[n_read],
|
||||||
MIN(length-n_read,32766));
|
MIN(length-n_read,32766));
|
||||||
if (more_read == -1 || more_read == 0) break;
|
if (more_read == -1 || more_read == 0) break;
|
||||||
n_read += more_read;
|
n_read += more_read;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ extern float density_opacity[MAX_DENSITY+1];
|
||||||
extern float magnitude_opacity[MAX_MAGNITUDE+1];
|
extern float magnitude_opacity[MAX_MAGNITUDE+1];
|
||||||
/* opacity as function of magnitude */
|
/* opacity as function of magnitude */
|
||||||
extern long density_epsilon; /* minimum (density*map_divisor) */
|
extern long density_epsilon; /* minimum (density*map_divisor) */
|
||||||
/* (>= MIN_DENSITY) */
|
/* (>= MIN_DENSITY) */
|
||||||
extern long magnitude_epsilon; /* minimum (magnitude*grd_divisor)**2 */
|
extern long magnitude_epsilon; /* minimum (magnitude*grd_divisor)**2 */
|
||||||
/* (> MIN_MAGNITUDE) */
|
/* (> MIN_MAGNITUDE) */
|
||||||
extern PIXEL background; /* color of background */
|
extern PIXEL background; /* color of background */
|
||||||
extern float light[NM]; /* normalized vector from object to light */
|
extern float light[NM]; /* normalized vector from object to light */
|
||||||
extern float ambient_color; /* color of ambient reflection */
|
extern float ambient_color; /* color of ambient reflection */
|
||||||
|
@ -53,31 +53,31 @@ extern float depth_hither; /* percentage of full intensity at hither */
|
||||||
extern float depth_yon; /* percentage of full intensity at yon */
|
extern float depth_yon; /* percentage of full intensity at yon */
|
||||||
extern float depth_exponent; /* exponent of falloff from hither to yon */
|
extern float depth_exponent; /* exponent of falloff from hither to yon */
|
||||||
extern float opacity_epsilon; /* minimum opacity */
|
extern float opacity_epsilon; /* minimum opacity */
|
||||||
/* (usually >= MIN_OPACITY, */
|
/* (usually >= MIN_OPACITY, */
|
||||||
/* < MIN_OPACITY during shading shades */
|
/* < MIN_OPACITY during shading shades */
|
||||||
/* all voxels for generation of mipmap) */
|
/* all voxels for generation of mipmap) */
|
||||||
extern float opacity_cutoff; /* cutoff opacity */
|
extern float opacity_cutoff; /* cutoff opacity */
|
||||||
/* (<= MAX_OPACITY) */
|
/* (<= MAX_OPACITY) */
|
||||||
extern long highest_sampling_boxlen;
|
extern long highest_sampling_boxlen;
|
||||||
/* highest boxlen for adaptive sampling */
|
/* highest boxlen for adaptive sampling */
|
||||||
/* (>= 1) */
|
/* (>= 1) */
|
||||||
extern long lowest_volume_boxlen;/* lowest boxlen for volume data */
|
extern long lowest_volume_boxlen;/* lowest boxlen for volume data */
|
||||||
/* (>= 1) */
|
/* (>= 1) */
|
||||||
extern long volume_color_difference;
|
extern long volume_color_difference;
|
||||||
/* minimum color diff for volume data */
|
/* minimum color diff for volume data */
|
||||||
/* (>= MIN_PIXEL) */
|
/* (>= MIN_PIXEL) */
|
||||||
extern float angle[NM]; /* initial viewing angle */
|
extern float angle[NM]; /* initial viewing angle */
|
||||||
extern long pyr_highest_level; /* highest level of pyramid to look at */
|
extern long pyr_highest_level; /* highest level of pyramid to look at */
|
||||||
/* (<= MAX_PYRLEVEL) */
|
/* (<= MAX_PYRLEVEL) */
|
||||||
extern long pyr_lowest_level; /* lowest level of pyramid to look at */
|
extern long pyr_lowest_level; /* lowest level of pyramid to look at */
|
||||||
/* (>= 0) */
|
/* (>= 0) */
|
||||||
|
|
||||||
/* Pre_View Globals */
|
/* Pre_View Globals */
|
||||||
extern long frust_len; /* Size of clipping frustum */
|
extern long frust_len; /* Size of clipping frustum */
|
||||||
/* (mins will be 0 in this program, */
|
/* (mins will be 0 in this program, */
|
||||||
/* {x,y}len will be <= IK{X,Y}SIZE) */
|
/* {x,y}len will be <= IK{X,Y}SIZE) */
|
||||||
extern float depth_cueing[MAX_OUTLEN];
|
extern float depth_cueing[MAX_OUTLEN];
|
||||||
/* Pre-computed table of depth cueing */
|
/* Pre-computed table of depth cueing */
|
||||||
extern long image_zlen; /* number of samples along viewing ray */
|
extern long image_zlen; /* number of samples along viewing ray */
|
||||||
extern float in_max[NM]; /* Pre-computed clipping aids */
|
extern float in_max[NM]; /* Pre-computed clipping aids */
|
||||||
extern long opc_xlen,opc_xylen;
|
extern long opc_xlen,opc_xylen;
|
||||||
|
@ -103,47 +103,47 @@ extern float uout_invvertex[2][2][2][NM];
|
||||||
extern float obslight[NM]; /* observer transformed light vector */
|
extern float obslight[NM]; /* observer transformed light vector */
|
||||||
extern float obshighlight[NM]; /* observer transformed highlight vector */
|
extern float obshighlight[NM]; /* observer transformed highlight vector */
|
||||||
extern float invjacobian[NM][NM];
|
extern float invjacobian[NM][NM];
|
||||||
/* Jacobian matrix showing object space */
|
/* Jacobian matrix showing object space */
|
||||||
/* d{x,y,z} per image space d{x,y,z} */
|
/* d{x,y,z} per image space d{x,y,z} */
|
||||||
/* [0][0] is dx(object)/dx(image) */
|
/* [0][0] is dx(object)/dx(image) */
|
||||||
/* [0][2] is dz(object)/dx(image) */
|
/* [0][2] is dz(object)/dx(image) */
|
||||||
/* [2][0] is dx(object)/dz(image) */
|
/* [2][0] is dx(object)/dz(image) */
|
||||||
extern float invinvjacobian[NM][NM];
|
extern float invinvjacobian[NM][NM];
|
||||||
/* [i][j] = 1.0 / invjacobian[i][j] */
|
/* [i][j] = 1.0 / invjacobian[i][j] */
|
||||||
|
|
||||||
|
|
||||||
/* Density map globals */
|
/* Density map globals */
|
||||||
extern short map_len[NM]; /* Size of this density map */
|
extern short map_len[NM]; /* Size of this density map */
|
||||||
extern int map_length; /* Total number of densities in map */
|
extern int map_length; /* Total number of densities in map */
|
||||||
/* (= product of lens) */
|
/* (= product of lens) */
|
||||||
extern DENSITY *map_address; /* Pointer to map */
|
extern DENSITY *map_address; /* Pointer to map */
|
||||||
|
|
||||||
/* Normal and gradient magnitude map globals */
|
/* Normal and gradient magnitude map globals */
|
||||||
extern short norm_len[NM]; /* Size of this normal map */
|
extern short norm_len[NM]; /* Size of this normal map */
|
||||||
extern int norm_length; /* Total number of normals in map */
|
extern int norm_length; /* Total number of normals in map */
|
||||||
/* (= NM * product of lens) */
|
/* (= NM * product of lens) */
|
||||||
extern NORMAL *norm_address; /* Pointer to normal map */
|
extern NORMAL *norm_address; /* Pointer to normal map */
|
||||||
extern float nmag_epsilon;
|
extern float nmag_epsilon;
|
||||||
|
|
||||||
/* Opacity map globals */
|
/* Opacity map globals */
|
||||||
extern short opc_len[NM]; /* Size of this opacity map */
|
extern short opc_len[NM]; /* Size of this opacity map */
|
||||||
extern int opc_length; /* Total number of opacities in map */
|
extern int opc_length; /* Total number of opacities in map */
|
||||||
/* (= product of lens) */
|
/* (= product of lens) */
|
||||||
extern OPACITY *opc_address; /* Pointer to opacity map */
|
extern OPACITY *opc_address; /* Pointer to opacity map */
|
||||||
|
|
||||||
/* Octree globals */
|
/* Octree globals */
|
||||||
extern short pyr_levels; /* Number of levels in this pyramid */
|
extern short pyr_levels; /* Number of levels in this pyramid */
|
||||||
extern short pyr_len[MAX_PYRLEVEL+1][NM];
|
extern short pyr_len[MAX_PYRLEVEL+1][NM];
|
||||||
/* Number of voxels on each level */
|
/* Number of voxels on each level */
|
||||||
extern short pyr_voxlen[MAX_PYRLEVEL+1][NM];
|
extern short pyr_voxlen[MAX_PYRLEVEL+1][NM];
|
||||||
/* Size of voxels on each level */
|
/* Size of voxels on each level */
|
||||||
extern int pyr_length[MAX_PYRLEVEL+1];
|
extern int pyr_length[MAX_PYRLEVEL+1];
|
||||||
/* Total number of bytes on this level */
|
/* Total number of bytes on this level */
|
||||||
/* (= (long)((product of lens+7)/8)) */
|
/* (= (long)((product of lens+7)/8)) */
|
||||||
extern BYTE *pyr_address[MAX_PYRLEVEL+1];
|
extern BYTE *pyr_address[MAX_PYRLEVEL+1];
|
||||||
/* Pointer to binary pyramid */
|
/* Pointer to binary pyramid */
|
||||||
/* (only pyr_levels sets of lens, lengths, */
|
/* (only pyr_levels sets of lens, lengths, */
|
||||||
/* and 3-D arrays are written to file) */
|
/* and 3-D arrays are written to file) */
|
||||||
extern long pyr_offset1; /* Bit offset of desired bit within pyramid */
|
extern long pyr_offset1; /* Bit offset of desired bit within pyramid */
|
||||||
extern long pyr_offset2; /* Bit offset of bit within byte */
|
extern long pyr_offset2; /* Bit offset of bit within byte */
|
||||||
extern BYTE *pyr_address2; /* Pointer to byte containing bit */
|
extern BYTE *pyr_address2; /* Pointer to byte containing bit */
|
||||||
|
|
|
@ -21,15 +21,13 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include "user_options.h" /* User options defined at compile time */
|
||||||
|
|
||||||
#include <climits>
|
|
||||||
#include <cmath> /* Definitions for mathematical library */
|
|
||||||
#include <cstdio> /* Definitions for standard I/O library */
|
|
||||||
|
|
||||||
#include "address.h" /* Map address macros */
|
|
||||||
#include "const.h" /* Constant definitions */
|
#include "const.h" /* Constant definitions */
|
||||||
|
#include "my_types.h" /* User defined type */
|
||||||
#include "global.h" /* Global variables */
|
#include "global.h" /* Global variables */
|
||||||
#include "macros.h" /* Definition of general C macros */
|
#include "macros.h" /* Definition of general C macros */
|
||||||
#include "my_types.h" /* User defined type */
|
#include "address.h" /* Map address macros */
|
||||||
#include "user_options.h" /* User options defined at compile time */
|
#include <stdio.h> /* Definitions for standard I/O library */
|
||||||
|
#include <math.h> /* Definitions for mathematical library */
|
||||||
|
#include <limits.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
|
@ -26,13 +26,11 @@
|
||||||
|
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <climits>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "incl.h"
|
#include "incl.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "tiffio.h"
|
#include "tiffio.h"
|
||||||
|
|
||||||
#define SH_MEM_AMT 60000000
|
#define SH_MEM_AMT 60000000
|
||||||
|
@ -259,35 +257,35 @@ void Render_Loop()
|
||||||
for (step=0; step<ROTATE_STEPS; step++) { /* do rotation sequence */
|
for (step=0; step<ROTATE_STEPS; step++) { /* do rotation sequence */
|
||||||
|
|
||||||
/* POSSIBLE ENHANCEMENT: Here is where one might reset statistics, if
|
/* POSSIBLE ENHANCEMENT: Here is where one might reset statistics, if
|
||||||
one wanted to.
|
one wanted to.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
frame = step;
|
frame = step;
|
||||||
/* initialize images here */
|
/* initialize images here */
|
||||||
local_image_address = image_address + image_partition * my_node;
|
local_image_address = image_address + image_partition * my_node;
|
||||||
local_mask_image_address = mask_image_address +
|
local_mask_image_address = mask_image_address +
|
||||||
mask_image_partition * my_node;
|
mask_image_partition * my_node;
|
||||||
|
|
||||||
BARRIER(Global->SlaveBarrier,num_nodes);
|
BARRIER(Global->SlaveBarrier,num_nodes);
|
||||||
|
|
||||||
if (my_node == num_nodes-1) {
|
if (my_node == num_nodes-1) {
|
||||||
for (i=image_partition*my_node; i<image_length; i++)
|
for (i=image_partition*my_node; i<image_length; i++)
|
||||||
*local_image_address++ = background;
|
*local_image_address++ = background;
|
||||||
if (adaptive)
|
if (adaptive)
|
||||||
for (i=mask_image_partition*my_node; i<mask_image_length; i++)
|
for (i=mask_image_partition*my_node; i<mask_image_length; i++)
|
||||||
*local_mask_image_address++ = NULL_PIXEL;
|
*local_mask_image_address++ = NULL_PIXEL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (i=0; i<image_partition; i++)
|
for (i=0; i<image_partition; i++)
|
||||||
*local_image_address++ = background;
|
*local_image_address++ = background;
|
||||||
if (adaptive)
|
if (adaptive)
|
||||||
for (i=0; i<mask_image_partition; i++)
|
for (i=0; i<mask_image_partition; i++)
|
||||||
*local_mask_image_address++ = NULL_PIXEL;
|
*local_mask_image_address++ = NULL_PIXEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (my_node == ROOT) {
|
if (my_node == ROOT) {
|
||||||
#ifdef DIM
|
#ifdef DIM
|
||||||
Select_View((float)STEP_SIZE, dim);
|
Select_View((float)STEP_SIZE, dim);
|
||||||
#else
|
#else
|
||||||
Select_View((float)STEP_SIZE, Y);
|
Select_View((float)STEP_SIZE, Y);
|
||||||
#endif
|
#endif
|
||||||
|
@ -302,33 +300,33 @@ void Render_Loop()
|
||||||
Render(my_node);
|
Render(my_node);
|
||||||
|
|
||||||
if (my_node == ROOT) {
|
if (my_node == ROOT) {
|
||||||
if (ROTATE_STEPS > 1) {
|
if (ROTATE_STEPS > 1) {
|
||||||
#ifdef DIM
|
#ifdef DIM
|
||||||
sprintf(outfile, "%s_%ld",filename, 1000+dim*ROTATE_STEPS+step);
|
sprintf(outfile, "%s_%ld",filename, 1000+dim*ROTATE_STEPS+step);
|
||||||
#else
|
#else
|
||||||
sprintf(outfile, "%s_%ld.tiff",filename, 1000+step);
|
sprintf(outfile, "%s_%ld.tiff",filename, 1000+step);
|
||||||
#endif
|
#endif
|
||||||
/* Store_Image(outfile);
|
/* Store_Image(outfile);
|
||||||
p = image_address;
|
p = image_address;
|
||||||
for (zz = 0;zz < image_length;zz++) {
|
for (zz = 0;zz < image_length;zz++) {
|
||||||
tiff_image[zz] = (long) ((*p)*256*256*256 + (*p)*256*256 +
|
tiff_image[zz] = (long) ((*p)*256*256*256 + (*p)*256*256 +
|
||||||
(*p)*256 + (*p));
|
(*p)*256 + (*p));
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
tiff_save_rgba(outfile,tiff_image,image_len[X],image_len[Y]); */
|
tiff_save_rgba(outfile,tiff_image,image_len[X],image_len[Y]); */
|
||||||
WriteGrayscaleTIFF(outfile, image_len[X],image_len[Y],image_len[X], image_address);
|
WriteGrayscaleTIFF(outfile, image_len[X],image_len[Y],image_len[X], image_address);
|
||||||
} else {
|
} else {
|
||||||
/* Store_Image(filename);
|
/* Store_Image(filename);
|
||||||
p = image_address;
|
p = image_address;
|
||||||
for (zz = 0;zz < image_length;zz++) {
|
for (zz = 0;zz < image_length;zz++) {
|
||||||
tiff_image[zz] = (long) ((*p)*256*256*256 + (*p)*256*256 +
|
tiff_image[zz] = (long) ((*p)*256*256*256 + (*p)*256*256 +
|
||||||
(*p)*256 + (*p));
|
(*p)*256 + (*p));
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
tiff_save_rgba(filename,tiff_image,image_len[X],image_len[Y]); */
|
tiff_save_rgba(filename,tiff_image,image_len[X],image_len[Y]); */
|
||||||
strcat(filename,".tiff");
|
strcat(filename,".tiff");
|
||||||
WriteGrayscaleTIFF(filename, image_len[X],image_len[Y],image_len[X], image_address);
|
WriteGrayscaleTIFF(filename, image_len[X],image_len[Y],image_len[X], image_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DIM
|
#ifdef DIM
|
||||||
|
@ -345,21 +343,21 @@ void Error(char string[], char *arg1, char *arg2, char *arg3, char *arg4, char *
|
||||||
#else
|
#else
|
||||||
void Error(char string[], ...)
|
void Error(char string[], ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *arg1 = NULL, *arg2 = NULL, *arg3 = NULL, *arg4 = NULL, *arg5 = NULL, *arg6 = NULL, *arg7 = NULL, *arg8 = NULL;
|
char *arg1 = NULL, *arg2 = NULL, *arg3 = NULL, *arg4 = NULL, *arg5 = NULL, *arg6 = NULL, *arg7 = NULL, *arg8 = NULL;
|
||||||
|
|
||||||
va_start(ap, string);
|
va_start(ap, string);
|
||||||
arg1 = va_arg(ap, char *);
|
arg1 = va_arg(ap, char *);
|
||||||
arg1 = va_arg(ap, char *);
|
arg1 = va_arg(ap, char *);
|
||||||
arg1 = va_arg(ap, char *);
|
arg1 = va_arg(ap, char *);
|
||||||
arg1 = va_arg(ap, char *);
|
arg1 = va_arg(ap, char *);
|
||||||
arg1 = va_arg(ap, char *);
|
arg1 = va_arg(ap, char *);
|
||||||
arg1 = va_arg(ap, char *);
|
arg1 = va_arg(ap, char *);
|
||||||
arg1 = va_arg(ap, char *);
|
arg1 = va_arg(ap, char *);
|
||||||
arg1 = va_arg(ap, char *);
|
arg1 = va_arg(ap, char *);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fprintf(stderr,string,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
|
fprintf(stderr,string,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -372,7 +370,7 @@ void Allocate_Image(PIXEL **address, long length)
|
||||||
*address = (PIXEL *)NU_MALLOC(length*sizeof(PIXEL),0);
|
*address = (PIXEL *)NU_MALLOC(length*sizeof(PIXEL),0);
|
||||||
|
|
||||||
if (*address == NULL)
|
if (*address == NULL)
|
||||||
Error(" No space available for image.\n", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
Error(" No space available for image.\n", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
for (i=0; i<length; i++) *(*address+i) = 0;
|
for (i=0; i<length; i++) *(*address+i) = 0;
|
||||||
|
|
||||||
|
@ -440,7 +438,7 @@ void Allocate_Shading_Table(PIXEL **address1, long length)
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
printf(" Allocating shade lookup table of %ld bytes...\n",
|
printf(" Allocating shade lookup table of %ld bytes...\n",
|
||||||
length*sizeof(PIXEL));
|
length*sizeof(PIXEL));
|
||||||
|
|
||||||
/* POSSIBLE ENHANCEMENT: If you want to replicate the shade table,
|
/* POSSIBLE ENHANCEMENT: If you want to replicate the shade table,
|
||||||
replace the macro with a simple malloc in the line below */
|
replace the macro with a simple malloc in the line below */
|
||||||
|
|
|
@ -20,15 +20,14 @@
|
||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include <cstring>
|
#include <string.h>
|
||||||
|
|
||||||
#include "incl.h"
|
#include "incl.h"
|
||||||
|
|
||||||
/* The following declarations show the layout of the .den file. */
|
/* The following declarations show the layout of the .den file. */
|
||||||
/* If changed, the version number must be incremented and code */
|
/* If changed, the version number must be incremented and code */
|
||||||
/* written to handle loading of both old and current versions. */
|
/* written to handle loading of both old and current versions. */
|
||||||
|
|
||||||
/* Version for new .den files: */
|
/* Version for new .den files: */
|
||||||
#define MAP_CUR_VERSION 1 /* Initial release */
|
#define MAP_CUR_VERSION 1 /* Initial release */
|
||||||
short map_version; /* Version of this .den file */
|
short map_version; /* Version of this .den file */
|
||||||
|
|
||||||
|
@ -45,10 +44,10 @@ short map_min[NM], /* Dimensions of this map */
|
||||||
map_len[NM]; /* lens may be != extr if warps > 0) */
|
map_len[NM]; /* lens may be != extr if warps > 0) */
|
||||||
|
|
||||||
short map_warps; /* Number of warps since extraction */
|
short map_warps; /* Number of warps since extraction */
|
||||||
/* (0 = none) */
|
/* (0 = none) */
|
||||||
|
|
||||||
int map_length; /* Total number of densities in map */
|
int map_length; /* Total number of densities in map */
|
||||||
/* (= product of lens) */
|
/* (= product of lens) */
|
||||||
DENSITY *map_address; /* Pointer to map */
|
DENSITY *map_address; /* Pointer to map */
|
||||||
|
|
||||||
/* End of layout of .den file. */
|
/* End of layout of .den file. */
|
||||||
|
@ -100,7 +99,7 @@ void Allocate_Map(address, length)
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
printf(" Allocating density map of %ld bytes...\n",
|
printf(" Allocating density map of %ld bytes...\n",
|
||||||
length*sizeof(DENSITY));
|
length*sizeof(DENSITY));
|
||||||
|
|
||||||
*address = (DENSITY *)NU_MALLOC(length*sizeof(DENSITY),0);
|
*address = (DENSITY *)NU_MALLOC(length*sizeof(DENSITY),0);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/* Definition of user-defined types: */
|
/* Definition of user-defined types: */
|
||||||
typedef unsigned char DENSITY; /* density */
|
typedef unsigned char DENSITY; /* density */
|
||||||
typedef unsigned char BYTE; /* general purpose byte */
|
typedef unsigned char BYTE; /* general purpose byte */
|
||||||
typedef signed short NORMAL; /* density normal */
|
typedef signed short NORMAL; /* density normal */
|
||||||
|
|
|
@ -21,22 +21,21 @@
|
||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include <cstring>
|
#include <string.h>
|
||||||
|
|
||||||
#include "incl.h"
|
#include "incl.h"
|
||||||
|
|
||||||
/* The following declarations show the layout of the .norm file. */
|
/* The following declarations show the layout of the .norm file. */
|
||||||
/* If changed, the version number must be incremented and code */
|
/* If changed, the version number must be incremented and code */
|
||||||
/* written to handle loading of both old and current versions. */
|
/* written to handle loading of both old and current versions. */
|
||||||
|
|
||||||
/* Version for new .norm files: */
|
/* Version for new .norm files: */
|
||||||
#define NORM_CUR_VERSION 1 /* Initial release */
|
#define NORM_CUR_VERSION 1 /* Initial release */
|
||||||
short norm_version; /* Version of this .norm file */
|
short norm_version; /* Version of this .norm file */
|
||||||
|
|
||||||
short norm_len[NM]; /* Size of this normal map */
|
short norm_len[NM]; /* Size of this normal map */
|
||||||
|
|
||||||
int norm_length; /* Total number of normals in map */
|
int norm_length; /* Total number of normals in map */
|
||||||
/* (= NM * product of lens) */
|
/* (= NM * product of lens) */
|
||||||
NORMAL *norm_address; /* Pointer to normal map */
|
NORMAL *norm_address; /* Pointer to normal map */
|
||||||
|
|
||||||
/* End of layout of .norm file. */
|
/* End of layout of .norm file. */
|
||||||
|
@ -78,7 +77,7 @@ void Allocate_Normal(address, length)
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
printf(" Allocating normal map of %ld bytes...\n",
|
printf(" Allocating normal map of %ld bytes...\n",
|
||||||
length*sizeof(NORMAL));
|
length*sizeof(NORMAL));
|
||||||
|
|
||||||
*address = (NORMAL *)NU_MALLOC(length*sizeof(NORMAL),0);
|
*address = (NORMAL *)NU_MALLOC(length*sizeof(NORMAL),0);
|
||||||
|
|
||||||
|
@ -144,32 +143,32 @@ void Normal_Compute()
|
||||||
for (outy=ystart; outy<ystop; outy++) {
|
for (outy=ystart; outy<ystop; outy++) {
|
||||||
for (outx=xstart; outx<xstop; outx++) {
|
for (outx=xstart; outx<xstop; outx++) {
|
||||||
|
|
||||||
inx = INSET + outx;
|
inx = INSET + outx;
|
||||||
iny = INSET + outy;
|
iny = INSET + outy;
|
||||||
inz = INSET + outz;
|
inz = INSET + outz;
|
||||||
|
|
||||||
/* Compute voxel gradient assuming gradient operator is 1x3 */
|
/* Compute voxel gradient assuming gradient operator is 1x3 */
|
||||||
grd_x = (double)((long)MAP(inz,iny,inx+1) - (long)MAP(inz,iny,inx-1));
|
grd_x = (double)((long)MAP(inz,iny,inx+1) - (long)MAP(inz,iny,inx-1));
|
||||||
grd_y = (double)((long)MAP(inz,iny+1,inx) - (long)MAP(inz,iny-1,inx));
|
grd_y = (double)((long)MAP(inz,iny+1,inx) - (long)MAP(inz,iny-1,inx));
|
||||||
grd_z = (double)((long)MAP(inz+1,iny,inx) - (long)MAP(inz-1,iny,inx));
|
grd_z = (double)((long)MAP(inz+1,iny,inx) - (long)MAP(inz-1,iny,inx));
|
||||||
|
|
||||||
/* Compute (magnitude*grd_divisor)**2 of gradient */
|
/* Compute (magnitude*grd_divisor)**2 of gradient */
|
||||||
/* Reduce (magnitude*grd_divisor)**2 to magnitude*grd_divisor */
|
/* Reduce (magnitude*grd_divisor)**2 to magnitude*grd_divisor */
|
||||||
/* Reduce magnitude*grd_divisor to magnitude */
|
/* Reduce magnitude*grd_divisor to magnitude */
|
||||||
magnitude = grd_x*grd_x+grd_y*grd_y+grd_z*grd_z;
|
magnitude = grd_x*grd_x+grd_y*grd_y+grd_z*grd_z;
|
||||||
|
|
||||||
local_norm_address = NORM_ADDRESS(outz,outy,outx,X);
|
local_norm_address = NORM_ADDRESS(outz,outy,outx,X);
|
||||||
if (magnitude > SMALL) {
|
if (magnitude > SMALL) {
|
||||||
inv_mag_shift = norm_lshift/sqrt(magnitude);
|
inv_mag_shift = norm_lshift/sqrt(magnitude);
|
||||||
if (grd_x*inv_mag_shift > 0.0) xnorm = 1;
|
if (grd_x*inv_mag_shift > 0.0) xnorm = 1;
|
||||||
else xnorm = 0;
|
else xnorm = 0;
|
||||||
ynorm = (long)(grd_y*inv_mag_shift);
|
ynorm = (long)(grd_y*inv_mag_shift);
|
||||||
znorm = (long)(grd_z*inv_mag_shift);
|
znorm = (long)(grd_z*inv_mag_shift);
|
||||||
*local_norm_address = TADDR(znorm,ynorm,xnorm);
|
*local_norm_address = TADDR(znorm,ynorm,xnorm);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*local_norm_address = TADDR(norm0,2,1);
|
*local_norm_address = TADDR(norm0,2,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,18 @@
|
||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include <cstring>
|
#include <string.h>
|
||||||
|
|
||||||
#include "incl.h"
|
#include "incl.h"
|
||||||
|
|
||||||
#define WRITE_PYR(IBIT,ILEVEL,IZ,IY,IX)\
|
#define WRITE_PYR(IBIT,ILEVEL,IZ,IY,IX)\
|
||||||
(PYR_ADDRESS(ILEVEL,IZ,IY,IX),\
|
(PYR_ADDRESS(ILEVEL,IZ,IY,IX),\
|
||||||
*pyr_address2|=(IBIT)<<pyr_offset2)
|
*pyr_address2|=(IBIT)<<pyr_offset2)
|
||||||
|
|
||||||
/* The following declarations show the layout of the .pyr file. */
|
/* The following declarations show the layout of the .pyr file. */
|
||||||
/* If changed, the version number must be incremented and code */
|
/* If changed, the version number must be incremented and code */
|
||||||
/* written to handle loading of both old and current versions. */
|
/* written to handle loading of both old and current versions. */
|
||||||
|
|
||||||
/* Version for new .pyr files: */
|
/* Version for new .pyr files: */
|
||||||
#define PYR_CUR_VERSION 1 /* Initial release */
|
#define PYR_CUR_VERSION 1 /* Initial release */
|
||||||
short pyr_version; /* Version of this .pyr file */
|
short pyr_version; /* Version of this .pyr file */
|
||||||
|
|
||||||
|
@ -42,26 +41,26 @@ short pyr_len[MAX_PYRLEVEL+1][NM]; /* Number of voxels on each level */
|
||||||
short pyr_voxlen[MAX_PYRLEVEL+1][NM]; /* Size of voxels on each level */
|
short pyr_voxlen[MAX_PYRLEVEL+1][NM]; /* Size of voxels on each level */
|
||||||
|
|
||||||
int pyr_length[MAX_PYRLEVEL+1];/* Total number of bytes on this level */
|
int pyr_length[MAX_PYRLEVEL+1];/* Total number of bytes on this level */
|
||||||
/* (= (long)((product of lens+7)/8)) */
|
/* (= (long)((product of lens+7)/8)) */
|
||||||
BYTE *pyr_address[MAX_PYRLEVEL+1];/* Pointer to binary pyramid */
|
BYTE *pyr_address[MAX_PYRLEVEL+1];/* Pointer to binary pyramid */
|
||||||
/* (only pyr_levels sets of lens, lengths, */
|
/* (only pyr_levels sets of lens, lengths, */
|
||||||
/* and 3-D arrays are written to file) */
|
/* and 3-D arrays are written to file) */
|
||||||
|
|
||||||
/* End of layout of .pyr file. */
|
/* End of layout of .pyr file. */
|
||||||
|
|
||||||
/* Subscripted access to binary pyramid */
|
/* Subscripted access to binary pyramid */
|
||||||
/* (PYR_ADDRESS only computes temporaries, */
|
/* (PYR_ADDRESS only computes temporaries, */
|
||||||
/* most others invoke PYR_ADDRESS, then: */
|
/* most others invoke PYR_ADDRESS, then: */
|
||||||
/* PYR returns char with bit in low bit,*/
|
/* PYR returns char with bit in low bit,*/
|
||||||
/* CLEAR_PYR clears bit to 0, */
|
/* CLEAR_PYR clears bit to 0, */
|
||||||
/* SET_PYR sets bit to 1, */
|
/* SET_PYR sets bit to 1, */
|
||||||
/* WRITE_PYR ORs BOOLEAN IBIT into bit, */
|
/* WRITE_PYR ORs BOOLEAN IBIT into bit, */
|
||||||
/* OVERWRITE_PYR clears, then ORs IBIT, */
|
/* OVERWRITE_PYR clears, then ORs IBIT, */
|
||||||
/* CURRENT_PYR returns at current address)*/
|
/* CURRENT_PYR returns at current address)*/
|
||||||
/* Warning: do not invoke any of these */
|
/* Warning: do not invoke any of these */
|
||||||
/* macros more than once per statement, */
|
/* macros more than once per statement, */
|
||||||
/* or values of temporaries may conflict, */
|
/* or values of temporaries may conflict, */
|
||||||
/* depending on optimization by compiler. */
|
/* depending on optimization by compiler. */
|
||||||
long pyr_offset1, /* Bit offset of desired bit within pyramid */
|
long pyr_offset1, /* Bit offset of desired bit within pyramid */
|
||||||
pyr_offset2; /* Bit offset of bit within byte */
|
pyr_offset2; /* Bit offset of bit within byte */
|
||||||
BYTE *pyr_address2; /* Pointer to byte containing bit */
|
BYTE *pyr_address2; /* Pointer to byte containing bit */
|
||||||
|
@ -82,7 +81,7 @@ void Compute_Octree()
|
||||||
while ((1<<(pyr_levels-1)) < max_len)
|
while ((1<<(pyr_levels-1)) < max_len)
|
||||||
pyr_levels++;
|
pyr_levels++;
|
||||||
printf(" Computing binary pyramid of %d levels...\n",
|
printf(" Computing binary pyramid of %d levels...\n",
|
||||||
pyr_levels);
|
pyr_levels);
|
||||||
|
|
||||||
for (i=0; i<NM; i++) {
|
for (i=0; i<NM; i++) {
|
||||||
pyr_len[0][i] = opc_len[i];
|
pyr_len[0][i] = opc_len[i];
|
||||||
|
@ -123,20 +122,20 @@ on all processors, don't do this create.
|
||||||
for (level=1; level<pyr_levels; level++) {
|
for (level=1; level<pyr_levels; level++) {
|
||||||
for (i=0; i<NM; i++) {
|
for (i=0; i<NM; i++) {
|
||||||
if (pyr_len[level-1][i] > 1) {
|
if (pyr_len[level-1][i] > 1) {
|
||||||
pyr_len[level][i] =
|
pyr_len[level][i] =
|
||||||
(pyr_len[level-1][i]+1)>>1;
|
(pyr_len[level-1][i]+1)>>1;
|
||||||
pyr_voxlen[level][i] =
|
pyr_voxlen[level][i] =
|
||||||
pyr_voxlen[level-1][i]<<1;
|
pyr_voxlen[level-1][i]<<1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pyr_len[level][i] =
|
pyr_len[level][i] =
|
||||||
pyr_len[level-1][i];
|
pyr_len[level-1][i];
|
||||||
pyr_voxlen[level][i] =
|
pyr_voxlen[level][i] =
|
||||||
pyr_voxlen[level-1][i];
|
pyr_voxlen[level-1][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pyr_length[level] = (pyr_len[level][X]*
|
pyr_length[level] = (pyr_len[level][X]*
|
||||||
pyr_len[level][Y]*pyr_len[level][Z]+7)/8;
|
pyr_len[level][Y]*pyr_len[level][Z]+7)/8;
|
||||||
Allocate_Pyramid_Level(&pyr_address[level], pyr_length[level]);
|
Allocate_Pyramid_Level(&pyr_address[level], pyr_length[level]);
|
||||||
Compute_Pyramid_Level(level);
|
Compute_Pyramid_Level(level);
|
||||||
}
|
}
|
||||||
|
@ -187,10 +186,10 @@ on all processors, then execute what's in the SERIAL_PREPROC ifdef below.
|
||||||
for (outz=zstart; outz<zstop; outz++) {
|
for (outz=zstart; outz<zstop; outz++) {
|
||||||
for (outy=ystart; outy<ystop; outy++) {
|
for (outy=ystart; outy<ystop; outy++) {
|
||||||
for (outx=xstart; outx<xstop; outx++) {
|
for (outx=xstart; outx<xstop; outx++) {
|
||||||
if (OPC(outz,outy,outx) == 0) /* mask bit is one unless opacity */
|
if (OPC(outz,outy,outx) == 0) /* mask bit is one unless opacity */
|
||||||
WRITE_PYR(0,0,outz,outy,outx); /* value is zero. */
|
WRITE_PYR(0,0,outz,outy,outx); /* value is zero. */
|
||||||
else
|
else
|
||||||
WRITE_PYR(1,0,outz,outy,outx);
|
WRITE_PYR(1,0,outz,outy,outx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,18 +242,18 @@ on all processors, then you should execute what's in the SERIAL_PREPROC
|
||||||
for (outy=0; outy<pyr_len[0][Y]; outy++) {
|
for (outy=0; outy<pyr_len[0][Y]; outy++) {
|
||||||
outy_plus_one = MIN(outy+1,pyr_len[0][Y]-1);
|
outy_plus_one = MIN(outy+1,pyr_len[0][Y]-1);
|
||||||
for (outx=0; outx<pyr_len[0][X]; outx++) {
|
for (outx=0; outx<pyr_len[0][X]; outx++) {
|
||||||
outx_plus_one = MIN(outx+1,pyr_len[0][X]-1);
|
outx_plus_one = MIN(outx+1,pyr_len[0][X]-1);
|
||||||
|
|
||||||
bit = PYR(0,outz,outy,outx);
|
bit = PYR(0,outz,outy,outx);
|
||||||
bit |= PYR(0,outz,outy,outx_plus_one);
|
bit |= PYR(0,outz,outy,outx_plus_one);
|
||||||
bit |= PYR(0,outz,outy_plus_one,outx);
|
bit |= PYR(0,outz,outy_plus_one,outx);
|
||||||
bit |= PYR(0,outz,outy_plus_one,outx_plus_one);
|
bit |= PYR(0,outz,outy_plus_one,outx_plus_one);
|
||||||
bit |= PYR(0,outz_plus_one,outy,outx);
|
bit |= PYR(0,outz_plus_one,outy,outx);
|
||||||
bit |= PYR(0,outz_plus_one,outy,outx_plus_one);
|
bit |= PYR(0,outz_plus_one,outy,outx_plus_one);
|
||||||
bit |= PYR(0,outz_plus_one,outy_plus_one,outx);
|
bit |= PYR(0,outz_plus_one,outy_plus_one,outx);
|
||||||
bit |= PYR(0,outz_plus_one,outy_plus_one,outx_plus_one);
|
bit |= PYR(0,outz_plus_one,outy_plus_one,outx_plus_one);
|
||||||
|
|
||||||
WRITE_PYR(bit,0,outz,outy,outx);
|
WRITE_PYR(bit,0,outz,outy,outx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +276,7 @@ void Allocate_Pyramid_Level(address, length)
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
printf(" Allocating pyramid level of %ld bytes...\n",
|
printf(" Allocating pyramid level of %ld bytes...\n",
|
||||||
length*sizeof(BYTE));
|
length*sizeof(BYTE));
|
||||||
|
|
||||||
/* POSSIBLE ENHANCEMENT: If you want to replicate the octree
|
/* POSSIBLE ENHANCEMENT: If you want to replicate the octree
|
||||||
on all processors, then replace the macro below with a regular malloc.
|
on all processors, then replace the macro below with a regular malloc.
|
||||||
|
@ -306,7 +305,7 @@ void Compute_Pyramid_Level(level)
|
||||||
BOOLEAN bit;
|
BOOLEAN bit;
|
||||||
|
|
||||||
printf(" Computing pyramid level %ld from level %ld...\n",
|
printf(" Computing pyramid level %ld from level %ld...\n",
|
||||||
level,level-1);
|
level,level-1);
|
||||||
for (outz=0; outz<pyr_len[level][Z]; outz++) {
|
for (outz=0; outz<pyr_len[level][Z]; outz++) {
|
||||||
inz = outz<<1;
|
inz = outz<<1;
|
||||||
inz_plus_one = MIN(inz+1,pyr_len[level-1][Z]-1);
|
inz_plus_one = MIN(inz+1,pyr_len[level-1][Z]-1);
|
||||||
|
@ -314,19 +313,19 @@ void Compute_Pyramid_Level(level)
|
||||||
iny = outy<<1;
|
iny = outy<<1;
|
||||||
iny_plus_one = MIN(iny+1,pyr_len[level-1][Y]-1);
|
iny_plus_one = MIN(iny+1,pyr_len[level-1][Y]-1);
|
||||||
for (outx=0; outx<pyr_len[level][X]; outx++) {
|
for (outx=0; outx<pyr_len[level][X]; outx++) {
|
||||||
inx = outx<<1;
|
inx = outx<<1;
|
||||||
inx_plus_one = MIN(inx+1,pyr_len[level-1][X]-1);
|
inx_plus_one = MIN(inx+1,pyr_len[level-1][X]-1);
|
||||||
|
|
||||||
bit = PYR(level-1,inz,iny,inx);
|
bit = PYR(level-1,inz,iny,inx);
|
||||||
bit |= PYR(level-1,inz,iny,inx_plus_one);
|
bit |= PYR(level-1,inz,iny,inx_plus_one);
|
||||||
bit |= PYR(level-1,inz,iny_plus_one,inx);
|
bit |= PYR(level-1,inz,iny_plus_one,inx);
|
||||||
bit |= PYR(level-1,inz,iny_plus_one,inx_plus_one);
|
bit |= PYR(level-1,inz,iny_plus_one,inx_plus_one);
|
||||||
bit |= PYR(level-1,inz_plus_one,iny,inx);
|
bit |= PYR(level-1,inz_plus_one,iny,inx);
|
||||||
bit |= PYR(level-1,inz_plus_one,iny,inx_plus_one);
|
bit |= PYR(level-1,inz_plus_one,iny,inx_plus_one);
|
||||||
bit |= PYR(level-1,inz_plus_one,iny_plus_one,inx);
|
bit |= PYR(level-1,inz_plus_one,iny_plus_one,inx);
|
||||||
bit |= PYR(level-1,inz_plus_one,iny_plus_one,inx_plus_one);
|
bit |= PYR(level-1,inz_plus_one,iny_plus_one,inx_plus_one);
|
||||||
|
|
||||||
WRITE_PYR(bit,level,outz,outy,outx);
|
WRITE_PYR(bit,level,outz,outy,outx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,22 +21,21 @@
|
||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include <cstring>
|
#include <string.h>
|
||||||
|
|
||||||
#include "incl.h"
|
#include "incl.h"
|
||||||
|
|
||||||
/* The following declarations show the layout of the .opc file. */
|
/* The following declarations show the layout of the .opc file. */
|
||||||
/* If changed, the version number must be incremented and code */
|
/* If changed, the version number must be incremented and code */
|
||||||
/* written to handle loading of both old and current versions. */
|
/* written to handle loading of both old and current versions. */
|
||||||
|
|
||||||
/* Version for new .opc files: */
|
/* Version for new .opc files: */
|
||||||
#define OPC_CUR_VERSION 1 /* Initial release */
|
#define OPC_CUR_VERSION 1 /* Initial release */
|
||||||
short opc_version; /* Version of this .opc file */
|
short opc_version; /* Version of this .opc file */
|
||||||
|
|
||||||
short opc_len[NM]; /* Size of this opacity map */
|
short opc_len[NM]; /* Size of this opacity map */
|
||||||
|
|
||||||
int opc_length; /* Total number of opacities in map */
|
int opc_length; /* Total number of opacities in map */
|
||||||
/* (= product of lens) */
|
/* (= product of lens) */
|
||||||
OPACITY *opc_address; /* Pointer to opacity map */
|
OPACITY *opc_address; /* Pointer to opacity map */
|
||||||
|
|
||||||
/* End of layout of .opc file. */
|
/* End of layout of .opc file. */
|
||||||
|
@ -77,7 +76,7 @@ void Allocate_Opacity(address, length)
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
printf(" Allocating opacity map of %ld bytes...\n",
|
printf(" Allocating opacity map of %ld bytes...\n",
|
||||||
length*sizeof(OPACITY));
|
length*sizeof(OPACITY));
|
||||||
|
|
||||||
*address = (OPACITY *)NU_MALLOC(length*sizeof(OPACITY),0);
|
*address = (OPACITY *)NU_MALLOC(length*sizeof(OPACITY),0);
|
||||||
|
|
||||||
|
@ -138,34 +137,34 @@ void Opacity_Compute()
|
||||||
for (outy=ystart; outy<ystop; outy++) {
|
for (outy=ystart; outy<ystop; outy++) {
|
||||||
for (outx=xstart; outx<xstop; outx++) {
|
for (outx=xstart; outx<xstop; outx++) {
|
||||||
|
|
||||||
inx = INSET + outx;
|
inx = INSET + outx;
|
||||||
iny = INSET + outy;
|
iny = INSET + outy;
|
||||||
inz = INSET + outz;
|
inz = INSET + outz;
|
||||||
|
|
||||||
density = MAP(inz,iny,inx);
|
density = MAP(inz,iny,inx);
|
||||||
if (density > density_epsilon) {
|
if (density > density_epsilon) {
|
||||||
|
|
||||||
grd_x = (float)((long)MAP(inz,iny,inx+1) - (long)MAP(inz,iny,inx-1));
|
grd_x = (float)((long)MAP(inz,iny,inx+1) - (long)MAP(inz,iny,inx-1));
|
||||||
grd_y = (float)((long)MAP(inz,iny+1,inx) - (long)MAP(inz,iny-1,inx));
|
grd_y = (float)((long)MAP(inz,iny+1,inx) - (long)MAP(inz,iny-1,inx));
|
||||||
grd_z = (float)((long)MAP(inz+1,iny,inx) - (long)MAP(inz-1,iny,inx));
|
grd_z = (float)((long)MAP(inz+1,iny,inx) - (long)MAP(inz-1,iny,inx));
|
||||||
magnitude = grd_x*grd_x+grd_y*grd_y+grd_z*grd_z;
|
magnitude = grd_x*grd_x+grd_y*grd_y+grd_z*grd_z;
|
||||||
|
|
||||||
/* If (magnitude*grd_divisor)**2 is small, skip voxel */
|
/* If (magnitude*grd_divisor)**2 is small, skip voxel */
|
||||||
if (magnitude > nmag_epsilon) {
|
if (magnitude > nmag_epsilon) {
|
||||||
magnitude = .5*sqrt(magnitude);
|
magnitude = .5*sqrt(magnitude);
|
||||||
/* For density * magnitude (d*m) operator: */
|
/* For density * magnitude (d*m) operator: */
|
||||||
/* Set opacity of surface to the product of user-specified */
|
/* Set opacity of surface to the product of user-specified */
|
||||||
/* functions of local density and gradient magnitude. */
|
/* functions of local density and gradient magnitude. */
|
||||||
/* Detects both front and rear-facing surfaces. */
|
/* Detects both front and rear-facing surfaces. */
|
||||||
opacity = density_opacity[density] *
|
opacity = density_opacity[density] *
|
||||||
magnitude_opacity[(long)magnitude];
|
magnitude_opacity[(long)magnitude];
|
||||||
/* If opacity is small, skip shading and compositing of sample */
|
/* If opacity is small, skip shading and compositing of sample */
|
||||||
if (opacity > opacity_epsilon)
|
if (opacity > opacity_epsilon)
|
||||||
OPC(outz,outy,outx) = NINT(opacity*MAX_OPC);
|
OPC(outz,outy,outx) = NINT(opacity*MAX_OPC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
OPC(outz,outy,outx) = MIN_OPC;
|
OPC(outz,outy,outx) = MIN_OPC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,54 +25,54 @@
|
||||||
long block_xlen,block_ylen;
|
long block_xlen,block_ylen;
|
||||||
BOOLEAN adaptive; /* adaptive ray tracing? */
|
BOOLEAN adaptive; /* adaptive ray tracing? */
|
||||||
|
|
||||||
/* During shading: */
|
/* During shading: */
|
||||||
long density_epsilon; /* minimum (density*map_divisor) */
|
long density_epsilon; /* minimum (density*map_divisor) */
|
||||||
/* (>= MIN_DENSITY) */
|
/* (>= MIN_DENSITY) */
|
||||||
long magnitude_epsilon; /* minimum (magnitude*grd_divisor)**2 */
|
long magnitude_epsilon; /* minimum (magnitude*grd_divisor)**2 */
|
||||||
/* (> MIN_MAGNITUDE) */
|
/* (> MIN_MAGNITUDE) */
|
||||||
|
|
||||||
/* Shading parameters of reflective surface: */
|
/* Shading parameters of reflective surface: */
|
||||||
float density_opacity[MAX_DENSITY+1]; /* opacity as function of density */
|
float density_opacity[MAX_DENSITY+1]; /* opacity as function of density */
|
||||||
float magnitude_opacity[MAX_MAGNITUDE+1];/* opacity as function of magnitude*/
|
float magnitude_opacity[MAX_MAGNITUDE+1];/* opacity as function of magnitude*/
|
||||||
|
|
||||||
/* Global lighting parameters: */
|
/* Global lighting parameters: */
|
||||||
PIXEL background; /* color of background assumed to be zero */
|
PIXEL background; /* color of background assumed to be zero */
|
||||||
/* because of hack for producing final */
|
/* because of hack for producing final */
|
||||||
/* image on host from node images */
|
/* image on host from node images */
|
||||||
float light[NM]; /* normalized vector from object to light */
|
float light[NM]; /* normalized vector from object to light */
|
||||||
|
|
||||||
/* Lighting parameters of reflective surface:*/
|
/* Lighting parameters of reflective surface:*/
|
||||||
float ambient_color; /* color of ambient reflection */
|
float ambient_color; /* color of ambient reflection */
|
||||||
float diffuse_color; /* color of diffuse reflection */
|
float diffuse_color; /* color of diffuse reflection */
|
||||||
float specular_color; /* color of specular reflection */
|
float specular_color; /* color of specular reflection */
|
||||||
float specular_exponent; /* exponent of specular reflection */
|
float specular_exponent; /* exponent of specular reflection */
|
||||||
|
|
||||||
/* Depth cueing parameters: */
|
/* Depth cueing parameters: */
|
||||||
float depth_hither; /* percentage of full intensity at hither */
|
float depth_hither; /* percentage of full intensity at hither */
|
||||||
float depth_yon; /* percentage of full intensity at yon */
|
float depth_yon; /* percentage of full intensity at yon */
|
||||||
float depth_exponent; /* exponent of falloff from hither to yon */
|
float depth_exponent; /* exponent of falloff from hither to yon */
|
||||||
|
|
||||||
/* During shading, rendering, ray tracing: */
|
/* During shading, rendering, ray tracing: */
|
||||||
float opacity_epsilon; /* minimum opacity */
|
float opacity_epsilon; /* minimum opacity */
|
||||||
/* (usually >= MIN_OPACITY, */
|
/* (usually >= MIN_OPACITY, */
|
||||||
/* < MIN_OPACITY during shading shades */
|
/* < MIN_OPACITY during shading shades */
|
||||||
/* all voxels for generation of mipmap) */
|
/* all voxels for generation of mipmap) */
|
||||||
|
|
||||||
/* During rendering and ray tracing: */
|
/* During rendering and ray tracing: */
|
||||||
float opacity_cutoff; /* cutoff opacity */
|
float opacity_cutoff; /* cutoff opacity */
|
||||||
/* (<= MAX_OPACITY) */
|
/* (<= MAX_OPACITY) */
|
||||||
|
|
||||||
/* During ray tracing: */
|
/* During ray tracing: */
|
||||||
long highest_sampling_boxlen; /* highest boxlen for adaptive sampling */
|
long highest_sampling_boxlen; /* highest boxlen for adaptive sampling */
|
||||||
/* (>= 1) */
|
/* (>= 1) */
|
||||||
long lowest_volume_boxlen; /* lowest boxlen for volume data */
|
long lowest_volume_boxlen; /* lowest boxlen for volume data */
|
||||||
/* (>= 1) */
|
/* (>= 1) */
|
||||||
long volume_color_difference; /* minimum color diff for volume data */
|
long volume_color_difference; /* minimum color diff for volume data */
|
||||||
/* (>= MIN_PIXEL) */
|
/* (>= MIN_PIXEL) */
|
||||||
long pyr_highest_level; /* highest level of pyramid to look at */
|
long pyr_highest_level; /* highest level of pyramid to look at */
|
||||||
/* (<= MAX_PYRLEVEL) */
|
/* (<= MAX_PYRLEVEL) */
|
||||||
long pyr_lowest_level; /* lowest level of pyramid to look at */
|
long pyr_lowest_level; /* lowest level of pyramid to look at */
|
||||||
/* (>= 0) */
|
/* (>= 0) */
|
||||||
float angle[NM]; /* initial viewing angle */
|
float angle[NM]; /* initial viewing angle */
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,8 +145,8 @@ void Init_Lighting()
|
||||||
light[Y] = 0.7;
|
light[Y] = 0.7;
|
||||||
light[Z] = -1.0;
|
light[Z] = -1.0;
|
||||||
inv_magnitude = 1.0/sqrt(light[X]*light[X] +
|
inv_magnitude = 1.0/sqrt(light[X]*light[X] +
|
||||||
light[Y]*light[Y] +
|
light[Y]*light[Y] +
|
||||||
light[Z]*light[Z]);
|
light[Z]*light[Z]);
|
||||||
light[X] = light[X]*inv_magnitude;
|
light[X] = light[X]*inv_magnitude;
|
||||||
light[Y] = light[Y]*inv_magnitude;
|
light[Y] = light[Y]*inv_magnitude;
|
||||||
light[Z] = light[Z]*inv_magnitude;
|
light[Z] = light[Z]*inv_magnitude;
|
||||||
|
|
|
@ -27,8 +27,8 @@ extern long num_samples_trilirped;
|
||||||
extern long traversal_time,trilirp_time,init_time,composite_time;
|
extern long traversal_time,trilirp_time,init_time,composite_time;
|
||||||
|
|
||||||
#define VXEL(X,SIGN) ((SIGN) > 0 ? \
|
#define VXEL(X,SIGN) ((SIGN) > 0 ? \
|
||||||
(long)((X)+SMALL) : \
|
(long)((X)+SMALL) : \
|
||||||
(long)((X)-SMALL))
|
(long)((X)-SMALL))
|
||||||
|
|
||||||
#define SBIT_ADDRESS(TA) (sbit_address+(TA))
|
#define SBIT_ADDRESS(TA) (sbit_address+(TA))
|
||||||
#define SHD_ADDRESS(TA) (shd_address+(TA))
|
#define SHD_ADDRESS(TA) (shd_address+(TA))
|
||||||
|
@ -96,7 +96,7 @@ void Trace_Ray(foutx, fouty, pixel_address)
|
||||||
for (i=0; i<NM; i++) {
|
for (i=0; i<NM; i++) {
|
||||||
ray[0][i] = out_invvertex[0][0][0][i] +
|
ray[0][i] = out_invvertex[0][0][0][i] +
|
||||||
invjacobian[X][i]*foutx +
|
invjacobian[X][i]*foutx +
|
||||||
invjacobian[Y][i]*fouty;
|
invjacobian[Y][i]*fouty;
|
||||||
ray[1][i] = ray[0][i] + invjacobian[Z][i]*image_zlen;
|
ray[1][i] = ray[0][i] + invjacobian[Z][i]*image_zlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,12 +114,12 @@ void Trace_Ray(foutx, fouty, pixel_address)
|
||||||
for (i=0; i<NM; i++) {
|
for (i=0; i<NM; i++) {
|
||||||
if (ABS(ray[1][i] - ray[0][i]) < SMALL) {
|
if (ABS(ray[1][i] - ray[0][i]) < SMALL) {
|
||||||
if ((ray[0][i] < 0.0 &&
|
if ((ray[0][i] < 0.0 &&
|
||||||
ray[1][i] < 0.0) ||
|
ray[1][i] < 0.0) ||
|
||||||
(ray[0][i] > (float)(opc_len[i]-1) &&
|
(ray[0][i] > (float)(opc_len[i]-1) &&
|
||||||
ray[1][i] > (float)(opc_len[i]-1)))
|
ray[1][i] > (float)(opc_len[i]-1)))
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
rmin = (0.0 - ray[0][i]) / (ray[1][i] - ray[0][i]);
|
rmin = (0.0 - ray[0][i]) / (ray[1][i] - ray[0][i]);
|
||||||
rmax = ((float)(opc_len[i]-1) - ray[0][i]) / (ray[1][i] - ray[0][i]);
|
rmax = ((float)(opc_len[i]-1) - ray[0][i]) / (ray[1][i] - ray[0][i]);
|
||||||
|
@ -178,8 +178,8 @@ void Trace_Ray(foutx, fouty, pixel_address)
|
||||||
/* but use of un-OR'ed pyramid and trilirp is invalid. */
|
/* but use of un-OR'ed pyramid and trilirp is invalid. */
|
||||||
|
|
||||||
bit = PYR(level,ivoxel[Z]>>level,
|
bit = PYR(level,ivoxel[Z]>>level,
|
||||||
ivoxel[Y]>>level,
|
ivoxel[Y]>>level,
|
||||||
ivoxel[X]>>level);
|
ivoxel[X]>>level);
|
||||||
if (bit && level > pyr_lowest_level) {
|
if (bit && level > pyr_lowest_level) {
|
||||||
|
|
||||||
/* This pyramid box contains something interesting, */
|
/* This pyramid box contains something interesting, */
|
||||||
|
@ -199,38 +199,38 @@ void Trace_Ray(foutx, fouty, pixel_address)
|
||||||
min_jump = BIG;
|
min_jump = BIG;
|
||||||
if (invjacobian[Z][X] > SMALL) {
|
if (invjacobian[Z][X] > SMALL) {
|
||||||
jump[X] = invinvjacobian[Z][X] *
|
jump[X] = invinvjacobian[Z][X] *
|
||||||
(((ROUNDDOWN(voxel[X])>>level)+1)*
|
(((ROUNDDOWN(voxel[X])>>level)+1)*
|
||||||
pyr_voxlen[level][X]-voxel[X]);
|
pyr_voxlen[level][X]-voxel[X]);
|
||||||
min_jump = MIN(min_jump,jump[X]);
|
min_jump = MIN(min_jump,jump[X]);
|
||||||
}
|
}
|
||||||
else if (invjacobian[Z][X] < -SMALL) {
|
else if (invjacobian[Z][X] < -SMALL) {
|
||||||
jump[X] = invinvjacobian[Z][X] *
|
jump[X] = invinvjacobian[Z][X] *
|
||||||
((STEPDOWN(voxel[X])>>level)*
|
((STEPDOWN(voxel[X])>>level)*
|
||||||
pyr_voxlen[level][X]-voxel[X]);
|
pyr_voxlen[level][X]-voxel[X]);
|
||||||
min_jump = MIN(min_jump,jump[X]);
|
min_jump = MIN(min_jump,jump[X]);
|
||||||
}
|
}
|
||||||
if (invjacobian[Z][Y] > SMALL) {
|
if (invjacobian[Z][Y] > SMALL) {
|
||||||
jump[Y] = invinvjacobian[Z][Y] *
|
jump[Y] = invinvjacobian[Z][Y] *
|
||||||
(((ROUNDDOWN(voxel[Y])>>level)+1)*
|
(((ROUNDDOWN(voxel[Y])>>level)+1)*
|
||||||
pyr_voxlen[level][Y]-voxel[Y]);
|
pyr_voxlen[level][Y]-voxel[Y]);
|
||||||
min_jump = MIN(min_jump,jump[Y]);
|
min_jump = MIN(min_jump,jump[Y]);
|
||||||
}
|
}
|
||||||
else if (invjacobian[Z][Y] < -SMALL) {
|
else if (invjacobian[Z][Y] < -SMALL) {
|
||||||
jump[Y] = invinvjacobian[Z][Y] *
|
jump[Y] = invinvjacobian[Z][Y] *
|
||||||
((STEPDOWN(voxel[Y])>>level)*
|
((STEPDOWN(voxel[Y])>>level)*
|
||||||
pyr_voxlen[level][Y]-voxel[Y]);
|
pyr_voxlen[level][Y]-voxel[Y]);
|
||||||
min_jump = MIN(min_jump,jump[Y]);
|
min_jump = MIN(min_jump,jump[Y]);
|
||||||
}
|
}
|
||||||
if (invjacobian[Z][Z] > SMALL) {
|
if (invjacobian[Z][Z] > SMALL) {
|
||||||
jump[Z] = invinvjacobian[Z][Z] *
|
jump[Z] = invinvjacobian[Z][Z] *
|
||||||
(((ROUNDDOWN(voxel[Z])>>level)+1)*
|
(((ROUNDDOWN(voxel[Z])>>level)+1)*
|
||||||
pyr_voxlen[level][Z]-voxel[Z]);
|
pyr_voxlen[level][Z]-voxel[Z]);
|
||||||
min_jump = MIN(min_jump,jump[Z]);
|
min_jump = MIN(min_jump,jump[Z]);
|
||||||
}
|
}
|
||||||
else if (invjacobian[Z][Z] < -SMALL) {
|
else if (invjacobian[Z][Z] < -SMALL) {
|
||||||
jump[Z] = invinvjacobian[Z][Z] *
|
jump[Z] = invinvjacobian[Z][Z] *
|
||||||
((STEPDOWN(voxel[Z])>>level)*
|
((STEPDOWN(voxel[Z])>>level)*
|
||||||
pyr_voxlen[level][Z]-voxel[Z]);
|
pyr_voxlen[level][Z]-voxel[Z]);
|
||||||
min_jump = MIN(min_jump,jump[Z]);
|
min_jump = MIN(min_jump,jump[Z]);
|
||||||
}
|
}
|
||||||
box_zmax = box_zmin + min_jump;
|
box_zmax = box_zmin + min_jump;
|
||||||
|
@ -268,16 +268,16 @@ void Trace_Ray(foutx, fouty, pixel_address)
|
||||||
/* Popping can be repeated until parent boxes match */
|
/* Popping can be repeated until parent boxes match */
|
||||||
/* or until next box is at starting level. */
|
/* or until next box is at starting level. */
|
||||||
while (level < starting_level) {
|
while (level < starting_level) {
|
||||||
if (next_ivoxel[X]>>(level+1) !=
|
if(next_ivoxel[X]>>(level+1) !=
|
||||||
ivoxel[X]>>(level+1) ||
|
ivoxel[X]>>(level+1) ||
|
||||||
next_ivoxel[Y]>>(level+1) !=
|
next_ivoxel[Y]>>(level+1) !=
|
||||||
ivoxel[Y]>>(level+1) ||
|
ivoxel[Y]>>(level+1) ||
|
||||||
next_ivoxel[Z]>>(level+1) !=
|
next_ivoxel[Z]>>(level+1) !=
|
||||||
ivoxel[Z]>>(level+1)) {
|
ivoxel[Z]>>(level+1)) {
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Advance voxel coordinates to near boundary of next box */
|
/* Advance voxel coordinates to near boundary of next box */
|
||||||
|
@ -509,37 +509,37 @@ of the frame.
|
||||||
normal[Y] = (float)ynorm * NORM_RSHIFT;
|
normal[Y] = (float)ynorm * NORM_RSHIFT;
|
||||||
mag = 1.0 - normal[Z] * normal[Z] - normal[Y] * normal[Y];
|
mag = 1.0 - normal[Z] * normal[Z] - normal[Y] * normal[Y];
|
||||||
if (mag > error) {
|
if (mag > error) {
|
||||||
mag = MAX(mag,0.0);
|
mag = MAX(mag,0.0);
|
||||||
normal[X] = sqrt(mag);
|
normal[X] = sqrt(mag);
|
||||||
xnorm = (long)normal[X];
|
xnorm = (long)normal[X];
|
||||||
dpartial_product1 = normal[Z] * obslight[Z] + normal[Y] * obslight[Y];
|
dpartial_product1 = normal[Z] * obslight[Z] + normal[Y] * obslight[Y];
|
||||||
dpartial_product2 = normal[X] * obslight[X];
|
dpartial_product2 = normal[X] * obslight[X];
|
||||||
spartial_product1 = normal[Z] * obshighlight[Z] +
|
spartial_product1 = normal[Z] * obshighlight[Z] +
|
||||||
normal[Y] * obshighlight[Y];
|
normal[Y] * obshighlight[Y];
|
||||||
spartial_product2 = normal[X] * obshighlight[X];
|
spartial_product2 = normal[X] * obshighlight[X];
|
||||||
table_addr = LOOKUP_HSIZE+(znorm*LOOKUP_PREC+ynorm)*2;
|
table_addr = LOOKUP_HSIZE+(znorm*LOOKUP_PREC+ynorm)*2;
|
||||||
dot_product = dpartial_product1 + dpartial_product2;
|
dot_product = dpartial_product1 + dpartial_product2;
|
||||||
diffuse = MAX(dot_product,0.0);
|
diffuse = MAX(dot_product,0.0);
|
||||||
dot_product = spartial_product1 + spartial_product2;
|
dot_product = spartial_product1 + spartial_product2;
|
||||||
specular = MAX(dot_product,0.0);
|
specular = MAX(dot_product,0.0);
|
||||||
specular = pow(specular,specular_exponent);
|
specular = pow(specular,specular_exponent);
|
||||||
color = ambient_color + diffuse*diffuse_color +
|
color = ambient_color + diffuse*diffuse_color +
|
||||||
specular*specular_color;
|
specular*specular_color;
|
||||||
color = NINT(MIN(color,MAX_PIXEL));
|
color = NINT(MIN(color,MAX_PIXEL));
|
||||||
temp = (long) color;
|
temp = (long) color;
|
||||||
SHD(table_addr+1) = (unsigned char) temp;
|
SHD(table_addr+1) = (unsigned char) temp;
|
||||||
if (normal[X] > 0.0) {
|
if (normal[X] > 0.0) {
|
||||||
dot_product = dpartial_product1 - dpartial_product2;
|
dot_product = dpartial_product1 - dpartial_product2;
|
||||||
diffuse = MAX(dot_product,0.0);
|
diffuse = MAX(dot_product,0.0);
|
||||||
dot_product = spartial_product1 - spartial_product2;
|
dot_product = spartial_product1 - spartial_product2;
|
||||||
specular = MAX(dot_product,0.0);
|
specular = MAX(dot_product,0.0);
|
||||||
specular = pow(specular,specular_exponent);
|
specular = pow(specular,specular_exponent);
|
||||||
color = ambient_color + diffuse*diffuse_color +
|
color = ambient_color + diffuse*diffuse_color +
|
||||||
specular*specular_color;
|
specular*specular_color;
|
||||||
color = NINT(MIN(color,MAX_PIXEL));
|
color = NINT(MIN(color,MAX_PIXEL));
|
||||||
}
|
}
|
||||||
temp = (long) color;
|
temp = (long) color;
|
||||||
SHD(table_addr) = (unsigned char) temp;
|
SHD(table_addr) = (unsigned char) temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "incl.h"
|
#include "incl.h"
|
||||||
|
|
||||||
/* Derived values: */
|
/* Derived values: */
|
||||||
float obslight[NM]; /* observer transformed light vector */
|
float obslight[NM]; /* observer transformed light vector */
|
||||||
float obshighlight[NM]; /* observer transformed highlight vector */
|
float obshighlight[NM]; /* observer transformed highlight vector */
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ void Observer_Transform_Light_Vector()
|
||||||
/* scaling and rotation is used during shading and ray tracing, */
|
/* scaling and rotation is used during shading and ray tracing, */
|
||||||
/* light source will appear fixed relative to observer. */
|
/* light source will appear fixed relative to observer. */
|
||||||
Transform_Point(light[X],light[Y],light[Z],
|
Transform_Point(light[X],light[Y],light[Z],
|
||||||
&obslight[X],&obslight[Y],&obslight[Z]);
|
&obslight[X],&obslight[Y],&obslight[Z]);
|
||||||
|
|
||||||
/* Normalize transformed light vector */
|
/* Normalize transformed light vector */
|
||||||
inv_magnitude = 1.0/sqrt(obslight[X]*obslight[X] +
|
inv_magnitude = 1.0/sqrt(obslight[X]*obslight[X] +
|
||||||
obslight[Y]*obslight[Y] +
|
obslight[Y]*obslight[Y] +
|
||||||
obslight[Z]*obslight[Z]);
|
obslight[Z]*obslight[Z]);
|
||||||
obslight[X] = obslight[X] * inv_magnitude;
|
obslight[X] = obslight[X] * inv_magnitude;
|
||||||
obslight[Y] = obslight[Y] * inv_magnitude;
|
obslight[Y] = obslight[Y] * inv_magnitude;
|
||||||
obslight[Z] = obslight[Z] * inv_magnitude;
|
obslight[Z] = obslight[Z] * inv_magnitude;
|
||||||
|
@ -81,8 +81,8 @@ void Compute_Observer_Transformed_Highlight_Vector()
|
||||||
|
|
||||||
/* Normalize transformed eye vector */
|
/* Normalize transformed eye vector */
|
||||||
inv_magnitude = 1.0/sqrt(obseye[X]*obseye[X] +
|
inv_magnitude = 1.0/sqrt(obseye[X]*obseye[X] +
|
||||||
obseye[Y]*obseye[Y] +
|
obseye[Y]*obseye[Y] +
|
||||||
obseye[Z]*obseye[Z]);
|
obseye[Z]*obseye[Z]);
|
||||||
obseye[X] = obseye[X] * inv_magnitude;
|
obseye[X] = obseye[X] * inv_magnitude;
|
||||||
obseye[Y] = obseye[Y] * inv_magnitude;
|
obseye[Y] = obseye[Y] * inv_magnitude;
|
||||||
obseye[Z] = obseye[Z] * inv_magnitude;
|
obseye[Z] = obseye[Z] * inv_magnitude;
|
||||||
|
@ -96,8 +96,8 @@ void Compute_Observer_Transformed_Highlight_Vector()
|
||||||
|
|
||||||
/* Normalize transformed highlight vector */
|
/* Normalize transformed highlight vector */
|
||||||
inv_magnitude = 1.0/sqrt(obshighlight[X]*obshighlight[X] +
|
inv_magnitude = 1.0/sqrt(obshighlight[X]*obshighlight[X] +
|
||||||
obshighlight[Y]*obshighlight[Y] +
|
obshighlight[Y]*obshighlight[Y] +
|
||||||
obshighlight[Z]*obshighlight[Z]);
|
obshighlight[Z]*obshighlight[Z]);
|
||||||
obshighlight[X] = obshighlight[X] * inv_magnitude * brightness;
|
obshighlight[X] = obshighlight[X] * inv_magnitude * brightness;
|
||||||
obshighlight[Y] = obshighlight[Y] * inv_magnitude * brightness;
|
obshighlight[Y] = obshighlight[Y] * inv_magnitude * brightness;
|
||||||
obshighlight[Z] = obshighlight[Z] * inv_magnitude * brightness;
|
obshighlight[Z] = obshighlight[Z] * inv_magnitude * brightness;
|
||||||
|
|
|
@ -245,7 +245,7 @@ void Compute_Input_Unit_Vector()
|
||||||
void Load_Transformation_Matrix(matrix)
|
void Load_Transformation_Matrix(matrix)
|
||||||
float matrix[4][4];
|
float matrix[4][4];
|
||||||
{
|
{
|
||||||
Copy_Matrix(matrix,transformation_matrix);
|
Copy_Matrix(matrix,transformation_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,20 +253,20 @@ void Transform_Point(xold,yold,zold,xnew,ynew,znew)
|
||||||
float xold,yold,zold;
|
float xold,yold,zold;
|
||||||
float *xnew,*ynew,*znew;
|
float *xnew,*ynew,*znew;
|
||||||
{
|
{
|
||||||
*xnew =
|
*xnew =
|
||||||
xold * transformation_matrix[0][0] +
|
xold * transformation_matrix[0][0] +
|
||||||
yold * transformation_matrix[1][0] +
|
yold * transformation_matrix[1][0] +
|
||||||
zold * transformation_matrix[2][0] +
|
zold * transformation_matrix[2][0] +
|
||||||
transformation_matrix[3][0];
|
transformation_matrix[3][0];
|
||||||
|
|
||||||
*ynew =
|
*ynew =
|
||||||
xold * transformation_matrix[0][1] +
|
xold * transformation_matrix[0][1] +
|
||||||
yold * transformation_matrix[1][1] +
|
yold * transformation_matrix[1][1] +
|
||||||
zold * transformation_matrix[2][1] +
|
zold * transformation_matrix[2][1] +
|
||||||
transformation_matrix[3][1];
|
transformation_matrix[3][1];
|
||||||
|
|
||||||
*znew =
|
*znew =
|
||||||
xold * transformation_matrix[0][2] +
|
xold * transformation_matrix[0][2] +
|
||||||
yold * transformation_matrix[1][2] +
|
yold * transformation_matrix[1][2] +
|
||||||
zold * transformation_matrix[2][2] +
|
zold * transformation_matrix[2][2] +
|
||||||
transformation_matrix[3][2];
|
transformation_matrix[3][2];
|
||||||
|
@ -276,18 +276,18 @@ void Transform_Point(xold,yold,zold,xnew,ynew,znew)
|
||||||
void Inverse_Concatenate_Translation(matrix,xoffset,yoffset,zoffset)
|
void Inverse_Concatenate_Translation(matrix,xoffset,yoffset,zoffset)
|
||||||
float matrix[4][4],xoffset,yoffset,zoffset;
|
float matrix[4][4],xoffset,yoffset,zoffset;
|
||||||
{
|
{
|
||||||
float translation_matrix[4][4];
|
float translation_matrix[4][4];
|
||||||
Load_Translation_Matrix(translation_matrix,xoffset,yoffset,zoffset);
|
Load_Translation_Matrix(translation_matrix,xoffset,yoffset,zoffset);
|
||||||
Inverse_Concatenate_Transform(matrix,translation_matrix);
|
Inverse_Concatenate_Transform(matrix,translation_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Inverse_Concatenate_Scaling(matrix,xscale,yscale,zscale)
|
void Inverse_Concatenate_Scaling(matrix,xscale,yscale,zscale)
|
||||||
float matrix[4][4],xscale,yscale,zscale;
|
float matrix[4][4],xscale,yscale,zscale;
|
||||||
{
|
{
|
||||||
float scaling_matrix[4][4];
|
float scaling_matrix[4][4];
|
||||||
Load_Scaling_Matrix(scaling_matrix,xscale,yscale,zscale);
|
Load_Scaling_Matrix(scaling_matrix,xscale,yscale,zscale);
|
||||||
Inverse_Concatenate_Transform(matrix,scaling_matrix);
|
Inverse_Concatenate_Transform(matrix,scaling_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,41 +295,41 @@ void Inverse_Concatenate_Rotation(matrix,axis,angle)
|
||||||
float matrix[4][4],angle;
|
float matrix[4][4],angle;
|
||||||
long axis;
|
long axis;
|
||||||
{
|
{
|
||||||
float rotation_matrix[4][4];
|
float rotation_matrix[4][4];
|
||||||
Load_Rotation_Matrix(rotation_matrix,axis,angle);
|
Load_Rotation_Matrix(rotation_matrix,axis,angle);
|
||||||
Inverse_Concatenate_Transform(matrix,rotation_matrix);
|
Inverse_Concatenate_Transform(matrix,rotation_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Load_Identity_Matrix(matrix)
|
void Load_Identity_Matrix(matrix)
|
||||||
float matrix[4][4];
|
float matrix[4][4];
|
||||||
{
|
{
|
||||||
long i,j;
|
long i,j;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
for (j=0; j<4; j++) {
|
for (j=0; j<4; j++) {
|
||||||
matrix[i][j] = 0;
|
matrix[i][j] = 0;
|
||||||
}
|
}
|
||||||
matrix[i][i] = 1.0;
|
matrix[i][i] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Load_Translation_Matrix(matrix,xoffset,yoffset,zoffset)
|
void Load_Translation_Matrix(matrix,xoffset,yoffset,zoffset)
|
||||||
float matrix[4][4],xoffset,yoffset,zoffset;
|
float matrix[4][4],xoffset,yoffset,zoffset;
|
||||||
{
|
{
|
||||||
Load_Identity_Matrix(matrix);
|
Load_Identity_Matrix(matrix);
|
||||||
matrix[3][0] = xoffset;
|
matrix[3][0] = xoffset;
|
||||||
matrix[3][1] = yoffset;
|
matrix[3][1] = yoffset;
|
||||||
matrix[3][2] = zoffset;
|
matrix[3][2] = zoffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Load_Scaling_Matrix(matrix,xscale,yscale,zscale)
|
void Load_Scaling_Matrix(matrix,xscale,yscale,zscale)
|
||||||
float matrix[4][4],xscale,yscale,zscale;
|
float matrix[4][4],xscale,yscale,zscale;
|
||||||
{
|
{
|
||||||
Load_Identity_Matrix(matrix);
|
Load_Identity_Matrix(matrix);
|
||||||
matrix[0][0] = xscale;
|
matrix[0][0] = xscale;
|
||||||
matrix[1][1] = yscale;
|
matrix[1][1] = yscale;
|
||||||
matrix[2][2] = zscale;
|
matrix[2][2] = zscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -337,72 +337,72 @@ void Load_Rotation_Matrix(matrix,axis,angle)
|
||||||
float matrix[4][4],angle;
|
float matrix[4][4],angle;
|
||||||
long axis;
|
long axis;
|
||||||
{
|
{
|
||||||
Load_Identity_Matrix(matrix);
|
Load_Identity_Matrix(matrix);
|
||||||
if (axis == XAXIS) {
|
if (axis == XAXIS) {
|
||||||
matrix[1][1] = cos(angle/180.0*PI);
|
matrix[1][1] = cos(angle/180.0*PI);
|
||||||
matrix[1][2] = sin(angle/180.0*PI);
|
matrix[1][2] = sin(angle/180.0*PI);
|
||||||
matrix[2][1] = -sin(angle/180.0*PI);
|
matrix[2][1] = -sin(angle/180.0*PI);
|
||||||
matrix[2][2] = cos(angle/180.0*PI);
|
matrix[2][2] = cos(angle/180.0*PI);
|
||||||
}
|
}
|
||||||
else if (axis == YAXIS) {
|
else if (axis == YAXIS) {
|
||||||
matrix[0][0] = cos(angle/180.0*PI);
|
matrix[0][0] = cos(angle/180.0*PI);
|
||||||
matrix[0][2] = -sin(angle/180.0*PI);
|
matrix[0][2] = -sin(angle/180.0*PI);
|
||||||
matrix[2][0] = sin(angle/180.0*PI);
|
matrix[2][0] = sin(angle/180.0*PI);
|
||||||
matrix[2][2] = cos(angle/180.0*PI);
|
matrix[2][2] = cos(angle/180.0*PI);
|
||||||
}
|
}
|
||||||
else if (axis == ZAXIS) {
|
else if (axis == ZAXIS) {
|
||||||
matrix[0][0] = cos(angle/180.0*PI);
|
matrix[0][0] = cos(angle/180.0*PI);
|
||||||
matrix[0][1] = sin(angle/180.0*PI);
|
matrix[0][1] = sin(angle/180.0*PI);
|
||||||
matrix[1][0] = -sin(angle/180.0*PI);
|
matrix[1][0] = -sin(angle/180.0*PI);
|
||||||
matrix[1][1] = cos(angle/180.0*PI);
|
matrix[1][1] = cos(angle/180.0*PI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Concatenate_Transform(composite_matrix,transformation_matrix)
|
void Concatenate_Transform(composite_matrix,transformation_matrix)
|
||||||
float composite_matrix[][4],transformation_matrix[][4];
|
float composite_matrix[][4],transformation_matrix[][4];
|
||||||
{
|
{
|
||||||
float temp_matrix[4][4];
|
float temp_matrix[4][4];
|
||||||
Multiply_Matrices(composite_matrix,transformation_matrix,temp_matrix);
|
Multiply_Matrices(composite_matrix,transformation_matrix,temp_matrix);
|
||||||
Copy_Matrix(temp_matrix,composite_matrix);
|
Copy_Matrix(temp_matrix,composite_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inverse_Concatenate_Transform(composite_matrix,transformation_matrix)
|
void Inverse_Concatenate_Transform(composite_matrix,transformation_matrix)
|
||||||
float composite_matrix[][4],transformation_matrix[][4];
|
float composite_matrix[][4],transformation_matrix[][4];
|
||||||
{
|
{
|
||||||
float temp_matrix[4][4];
|
float temp_matrix[4][4];
|
||||||
Multiply_Matrices(transformation_matrix,composite_matrix,temp_matrix);
|
Multiply_Matrices(transformation_matrix,composite_matrix,temp_matrix);
|
||||||
Copy_Matrix(temp_matrix,composite_matrix);
|
Copy_Matrix(temp_matrix,composite_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Multiply_Matrices(input_matrix1,input_matrix2,output_matrix)
|
void Multiply_Matrices(input_matrix1,input_matrix2,output_matrix)
|
||||||
float input_matrix1[][4],input_matrix2[][4],output_matrix[][4];
|
float input_matrix1[][4],input_matrix2[][4],output_matrix[][4];
|
||||||
{
|
{
|
||||||
long i,j;
|
long i,j;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
for (j=0; j<4; j++) {
|
for (j=0; j<4; j++) {
|
||||||
output_matrix[i][j] =
|
output_matrix[i][j] =
|
||||||
input_matrix1[i][0] *
|
input_matrix1[i][0] *
|
||||||
input_matrix2[0][j] +
|
input_matrix2[0][j] +
|
||||||
input_matrix1[i][1] *
|
input_matrix1[i][1] *
|
||||||
input_matrix2[1][j] +
|
input_matrix2[1][j] +
|
||||||
input_matrix1[i][2] *
|
input_matrix1[i][2] *
|
||||||
input_matrix2[2][j] +
|
input_matrix2[2][j] +
|
||||||
input_matrix1[i][3] *
|
input_matrix1[i][3] *
|
||||||
input_matrix2[3][j];
|
input_matrix2[3][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Copy_Matrix(input_matrix,output_matrix)
|
void Copy_Matrix(input_matrix,output_matrix)
|
||||||
float input_matrix[][4],output_matrix[][4];
|
float input_matrix[][4],output_matrix[][4];
|
||||||
{
|
{
|
||||||
long i,j;
|
long i,j;
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
for (j=0; j<4; j++) {
|
for (j=0; j<4; j++) {
|
||||||
output_matrix[i][j] = input_matrix[i][j];
|
output_matrix[i][j] = input_matrix[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include "global.h"
|
|
||||||
#include "mddata.h"
|
|
||||||
#include "mdvar.h"
|
#include "mdvar.h"
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
|
#include "mddata.h"
|
||||||
#include "split.h"
|
#include "split.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
/* this routine puts the molecules back inside the box if they are out */
|
/* this routine puts the molecules back inside the box if they are out */
|
||||||
void BNDRY(long ProcID)
|
void BNDRY(long ProcID)
|
||||||
|
|
|
@ -15,15 +15,14 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include <cstdio>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "cnst.h"
|
|
||||||
#include "fileio.h"
|
|
||||||
#include "frcnst.h"
|
|
||||||
#include "global.h"
|
|
||||||
#include "parameters.h"
|
|
||||||
#include "water.h"
|
#include "water.h"
|
||||||
#include "wwpot.h"
|
#include "wwpot.h"
|
||||||
|
#include "cnst.h"
|
||||||
|
#include "frcnst.h"
|
||||||
|
#include "fileio.h"
|
||||||
|
#include "parameters.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
/* set up some constants
|
/* set up some constants
|
||||||
* N : NORDER + 1 = 7 for a sixth-order method
|
* N : NORDER + 1 = 7 for a sixth-order method
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include <cmath>
|
#include <math.h>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
/* return the value of a with the same sign as b */
|
/* return the value of a with the same sign as b */
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
|
#include "math.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "mdvar.h"
|
||||||
|
#include "water.h"
|
||||||
#include "cnst.h"
|
#include "cnst.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "global.h"
|
|
||||||
#include "math.h"
|
|
||||||
#include "mddata.h"
|
|
||||||
#include "mdvar.h"
|
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
|
#include "mddata.h"
|
||||||
#include "split.h"
|
#include "split.h"
|
||||||
#include "stdio.h"
|
#include "global.h"
|
||||||
#include "water.h"
|
|
||||||
|
|
||||||
void INITIA()
|
void INITIA()
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include "cnst.h"
|
|
||||||
#include "global.h"
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "mddata.h"
|
|
||||||
#include "mdvar.h"
|
#include "mdvar.h"
|
||||||
#include "parameters.h"
|
|
||||||
#include "split.h"
|
|
||||||
#include "water.h"
|
#include "water.h"
|
||||||
#include "wwpot.h"
|
#include "wwpot.h"
|
||||||
|
#include "cnst.h"
|
||||||
|
#include "parameters.h"
|
||||||
|
#include "mddata.h"
|
||||||
|
#include "split.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
double ****PFORCES;
|
double ****PFORCES;
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include "frcnst.h"
|
|
||||||
#include "global.h"
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "mddata.h"
|
#include "frcnst.h"
|
||||||
#include "mdvar.h"
|
#include "mdvar.h"
|
||||||
#include "parameters.h"
|
|
||||||
#include "split.h"
|
|
||||||
#include "water.h"
|
#include "water.h"
|
||||||
#include "wwpot.h"
|
#include "wwpot.h"
|
||||||
|
#include "parameters.h"
|
||||||
|
#include "mddata.h"
|
||||||
|
#include "split.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
void INTRAF(double *VIR, long ProcID)
|
void INTRAF(double *VIR, long ProcID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include "global.h"
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "mddata.h"
|
|
||||||
#include "mdvar.h"
|
#include "mdvar.h"
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
|
#include "mddata.h"
|
||||||
#include "split.h"
|
#include "split.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
/* this routine computes kinetic energy in each of the three spatial
|
/* this routine computes kinetic energy in each of the three spatial
|
||||||
dimensions, and puts the computed values in the SUM array */
|
dimensions, and puts the computed values in the SUM array */
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include "cnst.h"
|
|
||||||
#include "fileio.h"
|
|
||||||
#include "global.h"
|
|
||||||
#include "mddata.h"
|
|
||||||
#include "mdvar.h"
|
|
||||||
#include "parameters.h"
|
|
||||||
#include "split.h"
|
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
#include "parameters.h"
|
||||||
|
#include "mdvar.h"
|
||||||
#include "water.h"
|
#include "water.h"
|
||||||
#include "wwpot.h"
|
#include "wwpot.h"
|
||||||
|
#include "cnst.h"
|
||||||
|
#include "mddata.h"
|
||||||
|
#include "fileio.h"
|
||||||
|
#include "split.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
/* contains the definitions of certain system constants */
|
/* contains the definitions of certain system constants */
|
||||||
|
|
||||||
#define MAXODR 7 /* Order of predictor-corrector method + 1 */
|
#define MAXODR 7 /* Order of predictor-corrector method + 1 */
|
||||||
#define NATOM 3 /* Atoms per molecule, H-O-H */
|
#define NATOM 3 /* Atoms per molecule, H-O-H */
|
||||||
#define MXOD2 (MAXODR+2) /* Variables maintained per mol */
|
#define MXOD2 (MAXODR+2) /* Variables maintained per mol */
|
||||||
#define NDIR 3 /* Number of spatial directions */
|
#define NDIR 3 /* Number of spatial directions */
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include "frcnst.h"
|
|
||||||
#include "global.h"
|
|
||||||
#include "math.h"
|
|
||||||
#include "mddata.h"
|
|
||||||
#include "mdvar.h"
|
#include "mdvar.h"
|
||||||
#include "parameters.h"
|
#include "frcnst.h"
|
||||||
#include "split.h"
|
|
||||||
#include "water.h"
|
#include "water.h"
|
||||||
#include "wwpot.h"
|
#include "wwpot.h"
|
||||||
|
#include "math.h"
|
||||||
|
#include "parameters.h"
|
||||||
|
#include "mddata.h"
|
||||||
|
#include "split.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
void POTENG(double *POTA, double *POTR, double *PTRF, long ProcID)
|
void POTENG(double *POTA, double *POTR, double *PTRF, long ProcID)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
EXTERN_ENV
|
EXTERN_ENV
|
||||||
#include "global.h"
|
|
||||||
#include "mddata.h"
|
|
||||||
#include "mdvar.h"
|
#include "mdvar.h"
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
|
#include "mddata.h"
|
||||||
#include "split.h"
|
#include "split.h"
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
/* predicts new values for displacement and its five derivatives
|
/* predicts new values for displacement and its five derivatives
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
/* some constant definitions */
|
/* some constant definitions */
|
||||||
|
|
||||||
#define H1 0
|
#define H1 0
|
||||||
#define O 1
|
#define O 1
|
||||||
#define H2 2
|
#define H2 2
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue