81 unsigned int tort_o = 0;
85 if (inputfile.
flag < 0) {
88 res = strncmp(inputfile.
filename,
"yes", 3);
98 if (inputfile.
flag < 0) {
101 res = strncmp(inputfile.
filename,
"yes", 3);
110 res = strncmp(inputfile.
filename,
"yes", 3);
114 printf(
"\nFracture Intersection Rule: Streamline Routing \n");
116 printf(
"\nFracture Intersection Rule: Complete Mixing \n");
121 res = strncmp(inputfile.
filename,
"yes", 3);
129 res = strncmp(inputfile.
filename,
"yes", 3);
137 res = strncmp(inputfile.
filename,
"yes", 3);
146 if (inputfile.
flag < 0) {
149 res = strncmp(inputfile.
filename,
"yes", 3);
161 if (inputfile.
flag < 0) {
164 res = strncmp(inputfile.
filename,
"yes", 3);
176 if (inputfile.
flag < 0) {
179 res = strncmp(inputfile.
filename,
"yes", 3);
194 if (inputfile.
flag < 0) {
197 res = strncmp(inputfile.
filename,
"yes", 3);
200 printf(
"\nRunning with Time Domain Random Walk\n");
207 res = strncmp(inputfile.
filename,
"yes", 3);
211 printf(
"--> Running with Rate Limited TDRW\n");
214 printf(
"--> Rate Limited Distance: %0.2f m\n\n",
tdrw_lambda);
218 printf(
"--> Matrix Diffusivity: %0.2e m^2/s\n\n",
tdrw_diffcoeff);
229 fprintf(tp,
"# of time steps, flux weights, total advective travel time, total advective + diffusion time, total diffusion time, beta, total length[m] \n");
231 fprintf(tp,
"# of time steps, flux weights, total travel time, x-, y-, z-final pos, beta, total length[m] \n");
239 if (inputfile.
flag < 0) {
242 res = strncmp(inputfile.
filename,
"yes", 3);
248 fprintf(inp,
" #of particle, # of cell, # of fracture, x-, y-, z- initial position, flux weight ");
251 fprintf(fnp,
" #of particle, # of cell, # of fracture, x-, y-, z- final position, flux weight ");
262 fprintf(tort,
"Data for tortuosity calculation: total length of trajectory, x-,y-, z- of initial pos., x-, y-, z- final pos., number of intersections. \n");
271 fprintf(frac,
"Fractures ID \n");
278 if (inputfile.
flag < 0) {
281 res = strncmp(inputfile.
filename,
"yes", 3);
294 printf(
"\n All output trajectory files will be written in %s/ \n", path);
295 printf(
" Note: if the directory exists all the files in it will be replaced. \n \n");
299 if (inputfile.
flag < 0) {
302 res = strncmp(inputfile.
filename,
"yes", 3);
311 int out_control = 0, out_plane = 0, out_cylinder = 0;
320 if (inputfile.
flag < 0) {
323 res = strncmp(inputfile.
filename,
"yes", 3);
331 if ((out_cylinder + out_plane) > 0) {
336 unsigned int time_d = 1, kd = 1;
342 time_d = (int)inputfile.
param;
344 dtime = inputfile.
param;
348 double sumsquares[time_d][2];
350 unsigned int nd[time_d];
353 double inflowcoord = 0.0;
354 double outflowcoord = 0.0;
355 double controllength = 0.0;
356 double wellthick = 0.0;
357 char pathcontrol[125];
358 double deltaCP = 0, current_CP = 0.0;
359 int ic, icl = 0, idist = 0, flowd = 0, welld = 0;
362 for (ic = 0; ic < time_d - 1; ic++) {
363 sumsquares[ic][0] = 0.0;
364 sumsquares[ic][1] = 0.0;
373 flowd = inputfile.
param;
377 if (out_control == 1) {
380 mkdir(pathcontrol, 0777);
382 deltaCP = inputfile.
param;
384 if (out_plane == 1) {
386 flowd = inputfile.
param;
390 controllength = fabs(outflowcoord) + fabs(inflowcoord);
391 icl = controllength / deltaCP + 1;
394 if (out_cylinder == 1) {
396 welld = inputfile.
param;
398 controllength = inputfile.
param;
400 wellthick = inputfile.
param;
402 if (deltaCP < wellthick) {
403 icl = (controllength - wellthick / 2) / deltaCP + 1;
405 icl = controllength / deltaCP + 1;
412 int numbpart, initweight = 0;
415 printf(
"\n %ld time steps in the current run \n",
timesteps);
416 printf(
"\n Initial number of particles being placed: %d \n", numbpart);
418 res = strncmp(inputfile.
filename,
"yes", 3);
420 if ((res == 0) && (
flag_w == 1)) {
424 int i = 1, ins = 0, intersm = 0, curr_n = 1, curr_o = 1;
425 int t_end = 0, fracthit = 0;
426 struct posit3d particle3dposit, particle3dvelocity;
427 int counttimestep = 0, prevcell = 0, prevfract = 0;
428 double xcop, ycop, zcop, currentlength = 0, totallength = 0;
429 double xx = 0, yy = 0, zz = 0, xinit = 0, yinit = 0, zinit = 0;
434 if (initweight == 1) {
438 unsigned int percent_done = 0;
441 for (
np = 0;
np < numbpart;
np++) {
444 if ((
np >= (
int)(0.01 * numbpart)) && ( percent_done == 0)) {
445 printf(
"Done %d particles, 1%%. \n",
np);
449 if ((
np >= (
int)(0.05 * numbpart)) && ( percent_done == 1)) {
450 printf(
"Done %d particles, 5%%. \n",
np);
454 if ((
np >= (
int)(0.25 * numbpart)) && ( percent_done == 2)) {
455 printf(
"Done %d particles, 25%%. \n",
np);
459 if ((
np >= (
int)(0.5 * numbpart)) && ( percent_done == 3)) {
460 printf(
"Done %d particles, 50%%. \n",
np);
464 if ((
np >= (
int)(0.75 * numbpart)) && ( percent_done == 4)) {
465 printf(
"Done %d particles, 75%%. \n",
np);
471 sprintf(filename,
"%s/part3D_%d.inp", path, curr_n);
473 fprintf(wpt,
"%10lu %10d %10d %10d %10d\n",
timesteps, 0, 0, 0, 0);
475 sprintf(filename,
"%s/part3D_%d.att", path, curr_n);
477 fprintf(wpt_att,
"0008 1 1 1 1 1 1 1 1\n");
478 fprintf(wpt_att,
"fracture, integer\n");
479 fprintf(wpt_att,
"time, real\n");
480 fprintf(wpt_att,
"velocity, real\n");
481 fprintf(wpt_att,
"vel_x, real\n");
482 fprintf(wpt_att,
"vel_y, real\n");
483 fprintf(wpt_att,
"vel_z, real\n");
484 fprintf(wpt_att,
"aperture, real\n");
485 fprintf(wpt_att,
"pressure, real\n");
490 sprintf(filename,
"%s/traject_%d", path, curr_n);
492 fprintf(wv,
" Current time step, x-, y-, z- pos., Vx, Vy, Vz at this positions, # of cell, #of fracture, travel time, aperture, beta, intersect. fracture ID, fluid pressure at particle's position \n");
494 sprintf(filename,
"%s/inters_%d", path, curr_n);
496 fprintf(wint,
" Current traj. length, travel time, x-, y-, z- pos., fracture ID, beta, fluid pressure at part.pos. \n");
500 sprintf(filename,
"%s/tdrw_%d", path, curr_n);
502 fprintf(diff,
" Advective travel time on the fracture, Diffusion time on the fracture, Total travel time on the fracture, fracture ID, Accumulative advective travel time, Accumulative total time, Accumulative diffusion time \n");
512 double part_squares[time_d][3];
515 for (ic = 0; ic < time_d; ic++) {
516 part_squares[ic][0] = 0.0;
517 part_squares[ic][1] = 0.0;
518 part_squares[ic][2] = 0.0;
542 unsigned int fract_id[
nfract],
id = 0;
544 for (
id = 0;
id <
nfract;
id++) {
550 int stuck = 0, stuckcell = 0, cur_ind = 0, cur_node = 0;
560 xcop = particle3dposit.
cord3[0];
561 ycop = particle3dposit.
cord3[1];
562 zcop = particle3dposit.
cord3[2];
582 if (out_control == 1) {
583 for (ic = 0; ic < icl; ic++) {
588 sprintf(filename,
"%s/part_control_%d", pathcontrol, curr_n);
592 fprintf(tmp2,
" x-, y-, z- position, Vx, Vy, Vz, trajectory length, fracture ID , aperture, Accumulative advective travel time, Accumulative total time, Accumulative diffusion time \n");
594 fprintf(tmp2,
" travel time, x-, y-, z- position, Vx, Vy, Vz, trajectory length, # of current fracture, aperture \n");
597 if (out_plane == 1) {
599 fprintf(tmp2,
" %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %5.12E %5.12E %5.12E %5.12E \n", particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2], totallength,
particle[
np].
fracture,
node[
cell[
particle[
np].
cell - 1].
node_ind[0] - 1].
aperture,
particle[
np].
time,
particle[
np].
t_adv_diff,
particle[
np].
t_diff);
601 fprintf(tmp2,
"%5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %5.12E\n",
particle[
np].time, particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2], totallength,
particle[
np].
fracture,
node[
cell[
particle[
np].
cell - 1].
node_ind[0] - 1].
aperture);
604 if (inflowcoord < 0) {
605 current_CP = inflowcoord + deltaCP;
607 current_CP = inflowcoord - deltaCP;
611 if (out_cylinder == 1) {
612 current_CP = controllength;
617 sprintf(filename,
"%s/tempdata_%d",
maindir,
np);
630 xx = particle3dposit.
cord3[0] - xcop;
631 yy = particle3dposit.
cord3[1] - ycop;
632 zz = particle3dposit.
cord3[2] - zcop;
633 currentlength = sqrt(xx * xx + yy * yy + zz * zz);
634 totallength = totallength + currentlength;
635 xcop = particle3dposit.
cord3[0];
636 ycop = particle3dposit.
cord3[1];
637 zcop = particle3dposit.
cord3[2];
643 fprintf(tmp,
"%05d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %05d %5.12E %5.12E %5.12E %5.12E \n",
t,
particle[
np].position[0],
particle[
np].position[1], particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2],
particle[
np].
cell,
particle[
np].
fracture,
particle[
np].
time, beta, totallength,
particle[
np].
pressure);
650 printf(
"Allocation memory problem - tempdata\n");
651 printf(
"timecounter %d time %d capacity %d\n",
timecounter,
t, capacity);
674 capacity = 2 * capacity;
677 printf(
"overload\n");
687 printf(
"REAllocation memory problem - tempdata\n");
688 printf(
"timecounter %d time %d capacity %d\n",
timecounter,
t, capacity);
703 part_squares[kd - 1][0] = xcop;
704 part_squares[kd - 1][1] = ycop;
705 part_squares[kd - 1][2] = zcop;
714 double welldist = 0.0;
716 if (out_control == 1) {
717 if (out_plane == 1) {
718 if (( (inflowcoord < 0) && (cross[idist] == 0) && (particle3dposit.
cord3[flowd] >= current_CP)) || ( (inflowcoord > 0) && (cross[idist] == 0) && (particle3dposit.
cord3[flowd] <= current_CP))) {
731 fprintf(tmp2,
"%5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %5.12E %5.12E %5.12E %5.12E \n", particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2], totallength,
particle[
np].
fracture,
node[
cell[
particle[
np].
cell - 1].
node_ind[0] - 1].
aperture,
particle[
np].
time,
particle[
np].
t_adv_diff,
particle[
np].
t_diff);
733 fprintf(tmp2,
"%5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %5.12E\n",
particle[
np].time, particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2], totallength,
particle[
np].
fracture,
node[
cell[
particle[
np].
cell - 1].
node_ind[0] - 1].
aperture);
736 if (inflowcoord < 0) {
737 current_CP = current_CP + deltaCP;
739 current_CP = current_CP - deltaCP;
746 if ((out_cylinder == 1) && (current_CP >= wellthick / 2)) {
748 welldist = sqrt(ycop * ycop + zcop * zcop);
752 welldist = sqrt(xcop * xcop + zcop * zcop);
756 welldist = sqrt(xcop * xcop + ycop * ycop);
759 if ((cross[idist] == 0) && (welldist <= current_CP)) {
766 fprintf(tmp2,
"%5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %5.12E\n",
particle[
np].time, xcop, ycop, zcop, particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2], totallength,
particle[
np].
fracture,
node[
cell[
particle[
np].
cell - 1].
node_ind[0] - 1].
aperture);
767 current_CP = current_CP - deltaCP;
840 fracthit = fracthit + 1;
855 if (counttimestep > (
int)
timesteps / 10.0) {
879 sprintf(filename,
"%s/tempdata_%d",
maindir,
np);
880 status = remove(filename);
883 if (out_control == 1) {
902 fprintf(tmp,
"%05d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %05d %5.12E %5.12E %5.12E %5.12E \n",
t,
particle[
np].position[0],
particle[
np].position[1], particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2],
particle[
np].
cell,
particle[
np].
fracture,
particle[
np].
time, beta, totallength,
particle[
np].
pressure);
926 sprintf(filename,
"%s/tempdata_%d",
maindir,
np);
927 status = remove(filename);
952 for (ic = 0; ic < kd - 1; ic++) {
956 sprintf(filename,
"%s/dispers_t%d",
maindir, ic + 1);
958 fseek(dis, 0, SEEK_END);
959 fprintf(dis,
"%f %f %f \n", part_squares[ic][0], part_squares[ic][1], part_squares[ic][2]);
970 xx = particle3dposit.
cord3[0] - xcop;
971 yy = particle3dposit.
cord3[1] - ycop;
972 zz = particle3dposit.
cord3[2] - zcop;
973 currentlength = sqrt(xx * xx + yy * yy + zz * zz);
974 totallength = totallength + currentlength;
975 sprintf(filename,
"%s/initpos",
maindir);
989 fprintf(tp,
"%d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E \n", t_end,
particle[
np].fl_weight,
particle[
np].time, particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], beta, totallength);
993 fprintf(tort,
"%5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %d\n", totallength, xinit, yinit, zinit, particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], fracthit);
1000 fprintf(frac,
"%d ", fract_id[
id]);
1002 }
while (fract_id[
id] != 0);
1004 fprintf(frac,
"\n");
1009 if (out_control == 1) {
1022 fprintf(tmp2,
"%5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %5.12E %5.12E %5.12E %5.12E \n", particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2], totallength,
particle[
np].
fracture,
node[
cell[
particle[
np].
cell - 1].
node_ind[0] - 1].
aperture,
particle[
np].
time,
particle[
np].
t_adv_diff,
particle[
np].
t_diff);
1024 fprintf(tmp2,
"%5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %5.12E\n",
particle[
np].time, particle3dposit.
cord3[0], particle3dposit.
cord3[1], particle3dposit.
cord3[2], particle3dvelocity.
cord3[0], particle3dvelocity.
cord3[1], particle3dvelocity.
cord3[2], totallength,
particle[
np].
fracture,
node[
cell[
particle[
np].
cell - 1].
node_ind[0] - 1].
aperture);
1034 for (i = 0; i <
nodeID - 1; i++) {
1035 fprintf(wpt,
"%10d %5d line %10d %10d\n", i + 1, 1, i + 1, i + 2);
1039 fprintf(wpt,
"%10d %10d %10d %10d %10d\n",
nodeID,
nodeID - 1, 8, 0, 0);
1042 char filename1[125] = {0}, filename2[125] = {0}, filename3[125] = {0}, buffer[500] = {0};
1044 sprintf(filename1,
"%s/part3D_%d.inp", path, curr_n - 1);
1045 sprintf(filename2,
"%s/part3D_%d.att", path, curr_n - 1);
1046 sprintf(filename3,
"%s/part_%d.inp", path, curr_n - 1);
1047 sprintf(buffer,
"cat%c%s%c%s%c>%c%s", wspace, filename1, wspace, filename2, wspace, wspace, filename3);
1049 sprintf(buffer,
"rm%c-f%c%s%c%s ", wspace, wspace, filename1, wspace, filename2);
1057 fprintf(wv,
"%d \n",
nodeID);
1068 printf(
"\n Number of particles that went out through out-flow boundary: %d \n", curr_n - 1);
1070 printf(
"\n Number of particles completed %d, number of particles that went out through out-flow boundary: %d \n", curr_n - 1, curr_n - 1 - curr_o);
1091 sprintf(filename,
"%s/TotalNumberP",
maindir);
1092 FILE *tn =
OpenFile (filename,
"w");
1095 fprintf(tn,
" %10d \n", curr_n - 1);
1097 fprintf(tn,
" %10d %10d \n", curr_n - 1, curr_n - curr_o - 1);
1103 printf(
"\n Working on additional outputs \n");
1115 int n1 = 0, n2 = 0, n3 = 0, pcell;
1139 if ((
node[n1 - 1].typeN == 210) || (
node[n1 - 1].typeN == 212) || (
node[n1 - 1].typeN == 200) || (
node[n1 - 1].typeN == 202)) {
1143 if ((
node[n2 - 1].typeN == 210) || (
node[n2 - 1].typeN == 212) || (
node[n2 - 1].typeN == 200) || (
node[n2 - 1].typeN == 202)) {
1147 if ((
node[n3 - 1].typeN == 210) || (
node[n3 - 1].typeN == 212) || (
node[n3 - 1].typeN == 200) || (
node[n3 - 1].typeN == 202)) {
1159 if (((
node[n1 - 1].typeN == 10) || (
node[n1 - 1].typeN == 12))) {
1163 if (((
node[n2 - 1].typeN == 10) || (
node[n2 - 1].typeN == 12))) {
1167 if (((
node[n3 - 1].typeN == 10) || (
node[n3 - 1].typeN == 12))) {
1171 if ((cb > 0) && (
node[n1 - 1].typeN != 210) && (
node[n1 - 1].typeN != 212) && (
node[n2 - 1].typeN != 210) && (
node[n2 - 1].typeN != 212) && (
node[n3 - 1].typeN != 210) && (
node[n3 - 1].typeN != 212)) {
1197 if ((
node[n1 - 1].typeN == 210) || (
node[n1 - 1].typeN == 212) || (
node[n1 - 1].typeN == 200)) {
1201 if ((
node[n2 - 1].typeN == 210) || (
node[n2 - 1].typeN == 212) || (
node[n2 - 1].typeN == 200)) {
1205 if ((
node[n3 - 1].typeN == 210) || (
node[n3 - 1].typeN == 212) || (
node[n3 - 1].typeN == 200)) {
1216 if ((
node[
node[n1 - 1].indnodes[ii] - 1].typeN == 212) || (
node[
node[n1 - 1].indnodes[ii] - 1].typeN == 210)) {
1225 if ((
node[
node[n2 - 1].indnodes[ii] - 1].typeN == 212) || (
node[
node[n2 - 1].indnodes[ii] - 1].typeN == 210)) {
1235 if ((
node[
node[n3 - 1].indnodes[ii] - 1].typeN == 212) || (
node[
node[n3 - 1].indnodes[ii] - 1].typeN == 210)) {
1253 double n1x, n1y, n2x, n2y, n3x, n3y, deter;
1261 deter = (n2y - n3y) * (n1x - n3x) + (n3x - n2x) * (n1y - n3y);
1262 lambda.weights[0] = ((n2y - n3y) * (
particle[
np].position[0] - n3x) + (n3x - n2x) * (
particle[
np].position[1] - n3y)) / deter;
1263 lambda.weights[1] = ((n3y - n1y) * (
particle[
np].position[0] - n3x) + (n1x - n3x) * (
particle[
np].position[1] - n3y)) / deter;
1264 lambda.weights[2] = 1 - lambda.weights[0] - lambda.weights[1];
1267 if ((lambda.weights[0] >= -eps) && (lambda.weights[0] <= eps)) {
1268 lambda.weights[0] = 0.0;
1271 if ((lambda.weights[1] >= -eps) && (lambda.weights[1] <= eps)) {
1272 lambda.weights[1] = 0.0;
1275 lambda.weights[2] = 1 - lambda.weights[0] - lambda.weights[1];
1277 if ((lambda.weights[2] >= -eps) && (lambda.weights[2] <= eps)) {
1278 lambda.weights[2] = 0.0;
1329 int nk_1, nk_2, nk_3, inside, nb = 0;
1350 if (
node[nk_1 - 1].typeN == 10) {
1354 if (
node[nk_2 - 1].typeN == 10) {
1358 if (
node[nk_3 - 1].typeN == 10) {
1368 if (((
node[nk_1 - 1].typeN == 2) || (
node[nk_2 - 1].typeN == 2) || (
node[nk_3 - 1].typeN == 2) || (
node[nk_1 - 1].typeN == 12) || (
node[nk_2 - 1].typeN == 12) || (
node[nk_3 - 1].typeN == 12)) && (intc == 0)) {
1372 if ((nb > 0) && (
particle[
np].intcell == 1)) {
1386 int n1 = 0, n2 = 0, n3 = 0, v1 = 0, v2 = 0, v3 = 0;
1411 int n1 = 0, n2 = 0, n3 = 0, v1 = 0, v2 = 0, v3 = 0;
1429 int i = 0, j, inscell = 0;
1433 for (j = 0; j < 4; j++) {
1441 }
while ((inscell == 0) && (i <
node[k - 1].numneighb));
1451 double dotvel1, epsd = 1e-10;
1453 for (i = 0; i <
nnodes; i++) {
1456 for (j = 0; j < 4; j++) {
1459 if (dotvel1 > epsd) {
1460 if (
node[i].typeN == 10) {
1478 int dn1, dn2, dn3, int1 = 0, int2 = 0, int3 = 0, i, intm = 0;
1479 int ind_int2, fract_p;
1480 double px, py, dist, delta_t;
1481 double cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0;
1491 dist = sqrt(pow((
particle[
np].velocity[0] * delta_t), 2) + pow((
particle[
np].velocity[1] * delta_t), 2));
1494 if ((
node[dn1 - 1].typeN == 2) || (
node[dn1 - 1].typeN == 12)) {
1498 if ((
node[dn2 - 1].typeN == 2) || (
node[dn2 - 1].typeN == 12)) {
1506 if ((
node[dn3 - 1].typeN == 2) || (
node[dn3 - 1].typeN == 12)) {
1514 if ((int1 != 0) && (int2 != 0)) {
1529 if ((int3 != 0) && (int3 != -1)) {
1538 if ((int1 != 0) && (int2 != 0)) {
1544 if ((int1 != 0) && (int2 != 0) && (int3 != 0)) {
1546 double base, side1, side2, perim, area, height;
1547 base = sqrt(((cx2 - cx1) * (cx2 - cx1)) + ((cy2 - cy1) * (cy2 - cy1)));
1548 side2 = sqrt(((cx2 - px) * (cx2 - px)) + ((cy2 - py) * (cy2 - py)));
1549 side1 = sqrt(((cx1 - px) * (cx1 - px)) + ((cy1 - py) * (cy1 - py)));
1550 perim = (side1 + side2 + base) / 2.0;
1551 area = sqrt(perim * (perim - base) * (perim - side1) * (perim - side2));
1552 height = area / (base * 0.5);
1558 if (height <= dist) {
1559 double pr1, pr2, pr3, pr4, px1, py1, px2, py2;
1567 pr1 = (px1 - cx1) * (py2 - cy1) - (py1 - cy1) * (px2 - cx1);
1568 pr2 = (cx1 - px1) * (cy2 - py1) - (cy1 - py1) * (cx2 - px1);
1569 pr3 = (px1 - cx2) * (py2 - cy2) - (py1 - cy2) * (px2 - cx2);
1570 pr4 = (cx1 - px2) * (cy2 - py2) - (cy1 - py2) * (cx2 - px2);
1572 if ((pr1 * pr3 < 0) && (pr2 * pr4 < 0)) {
1574 pr1 = cx1 * cy2 - cy1 * cx2;
1575 pr2 = px1 * py2 - py1 * px2;
1576 pr3 = (cx1 - cx2) * (py1 - py2) - (cy1 - cy2) * (px1 - px2);
1577 px = ((px1 - px2) * pr1 - (cx1 - cx2) * pr2) / pr3;
1578 py = ((py1 - py2) * pr1 - (cy1 - cy2) * pr2) / pr3;
1614 if ((int1 != 0) && (int2 != 0) && (int3 == 0)) {
1615 double nposx = 0, nposy = 0, dist_init = 0, dist_fin = 0, inout = 0;
1617 nposx = (cx1 + cx2) / 2;
1618 nposy = (cy1 + cy2) / 2;
1619 dist_init = pow((
particle[
np].position[0] - nposx), 2) + pow((
particle[
np].position[1] - nposy), 2);
1621 dist_fin = pow((
particle[
np].position[0] - nposx), 2) + pow((
particle[
np].position[1] - nposy), 2);
1623 if (dist_init >= dist_fin) {
1657 printf(
"Particle is lost on end of intersection. \n");
1663 if (
node[int1 - 1].indnodes[i] == int2) {
1672 for (i = 0; i < 4; i++) {
1675 indc =
node[int1 - 1].
cells[ind_int2][i];
1722 if ((int1 == 0) || (int2 == 0)) {
1734 int n1n, n2n, n3n, v1v, v2v, v3v;
1738 double products = 0, product = 0;
1748 double tnx = 0, tny = 0;
1750 if ((
node[n1n - 1].typeN != 12) && (
node[n1n - 1].typeN != 2)) {
1754 if ((
node[n2n - 1].typeN != 12) && (
node[n2n - 1].typeN != 2)) {
1758 if ((
node[n3n - 1].typeN != 12) && (
node[n3n - 1].typeN != 2)) {
1764 double vintx = 0, vinty = 0, velocx = 0, velocy = 0;
1774 inoutf = products * product;
1788 int indj = -1, k, indcell, cell_win = 0, indk = 0;
1789 int n1n, n2n, n3n, v1v, v2v, v3v;
1792 double speedsq[4] = {0.0, 0.0, 0.0, 0.0}, velocx, velocy;
1793 double products[4] = {0.0, 0.0, 0.0, 0.0};
1794 int neighborcellind[4];
1795 int neighborfracind[4];
1799 if ((int1 != 0) && (int2 != 0)) {
1804 if (
node[int1 - 1].indnodes[k] == int2) {
1809 }
while ((indj < 0) && (k <
node[int1 - 1].numneighb));
1812 printf(
" Current cell not found: NODES %d %d pw %f %f %f \n", int1, int2,
particle[
np].weight[0],
particle[
np].weight[1],
particle[
np].weight[2]);
1816 for (k = 0; k < 4; k++) {
1817 if (
node[int1 - 1].cells[indj][k] != 0) {
1818 indcell =
node[int1 - 1].
cells[indj][k];
1819 neighborcellind[k] = indcell;
1827 double tnx = 0, tny = 0;
1829 if ((
node[n1n - 1].typeN != 12) && (
node[n1n - 1].typeN != 2)) {
1833 if ((
node[n2n - 1].typeN != 12) && (
node[n2n - 1].typeN != 2)) {
1837 if ((
node[n3n - 1].typeN != 12) && (
node[n3n - 1].typeN != 2)) {
1844 double product, vintx = 0, vinty = 0;
1848 if ((indcell) == prevcell) {
1861 products[k] = products[k] * product;
1862 speedsq[k] = velocx * velocx + velocy * velocy;
1874 cell_win =
StreamlineRandomSampling(products, speedsq, indj, int1, indk, neighborcellind, neighborfracind, prevfrac, prevcell);
1901 int StreamlineRandomSampling(
double products[4],
double speedsq[4],
int indj,
int int1,
int indk,
int neighborcellind[4],
int neighborfracind[4],
int prevfrac,
int prevcell) {
1903 int win_cell = 0, k, jj;
1904 int count = 0, outc[4] = {0, 0, 0, 0};
1907 double random_number, totalspeed = 0, minsp = 0.0, incomingspeedsq = 0, speedopp = 0, totalmag = 0;
1910 for (k = 0; k < 4; k++) {
1911 if (products[k] < 0) {
1914 totalspeed = totalspeed + speedsq[k];
1915 totalmag = totalmag + sqrt(speedsq[k]);
1925 for (k = 0; k < 4; k++)
1926 if ((speedsq[k] > minsp) && (k != indk)) {
1928 win_cell =
node[int1 - 1].
cells[indj][k];
1934 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
1939 for (jj = 0; jj < 4; jj++) {
1940 if ((neighborfracind[jj] == prevfrac) && (neighborcellind[jj] ==
node[int1 - 1].cells[indj][outc[0]] || neighborcellind[jj] ==
node[int1 - 1].cells[indj][outc[1]])) {
1941 oppcellind = neighborcellind[jj];
1946 if ((neighborfracind[jj] == prevfrac) && neighborcellind[jj] !=
node[int1 - 1].cells[indj][outc[0]] && neighborcellind[jj] !=
node[int1 - 1].cells[indj][outc[1]]) {
1947 incomingspeedsq = speedsq[jj];
1950 if(neighborcellind[jj] == prevcell) {
1951 incomingspeedsq = speedsq[jj];
1959 random_number = drand48();
1964 if (
node[int1 - 1].cells[indj][outc[0]] == oppcellind) {
1965 if (incomingspeedsq <= speedsq[outc[1]]) {
1966 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
1968 if (random_number <= sqrt(speedsq[outc[1]]) / sqrt(incomingspeedsq)) {
1969 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
1971 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
1976 if (incomingspeedsq <= speedsq[outc[0]]) {
1977 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
1979 if (random_number <= sqrt(speedsq[outc[0]]) / sqrt(incomingspeedsq)) {
1980 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
1982 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
1991 if(sqrt(incomingspeedsq) >= (sqrt(speedsq[outc[0]]) + sqrt(speedsq[outc[1]])) / 2) {
1992 if(speedsq[outc[1]] >= speedsq[outc[0]]) {
1994 if(random_number >= sqrt(speedsq[outc[1]]) / sqrt(incomingspeedsq)) {
1995 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
1997 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2001 if(random_number >= sqrt(speedsq[outc[0]]) / sqrt(incomingspeedsq)) {
2002 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2004 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2008 speedopp = sqrt(speedsq[outc[0]]) + sqrt(speedsq[outc[1]]) - sqrt(incomingspeedsq);
2010 if(speedsq[outc[1]] <= speedsq[outc[0]]) {
2012 if(random_number <= (sqrt(speedsq[outc[0]]) - speedopp) / sqrt(incomingspeedsq) && sqrt(speedsq[outc[0]]) >= speedopp) {
2013 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2015 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2019 if(random_number <= (sqrt(speedsq[outc[1]]) - speedopp) / sqrt(incomingspeedsq) && sqrt(speedsq[outc[1]]) >= speedopp) {
2020 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2022 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2038 random_number = drand48();
2040 if (random_number > ((sqrt(speedsq[outc[0]]) + sqrt(speedsq[outc[1]])) / totalmag))
2043 win_cell =
node[int1 - 1].
cells[indj][outc[2]];
2045 if (random_number <= (sqrt(speedsq[outc[0]]) / totalmag))
2048 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2050 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2056 random_number = drand48();
2058 if (random_number > ((speedsq[outc[0]] + speedsq[outc[1]] + speedsq[outc[2]]) / totalspeed)) {
2059 win_cell =
node[int1 - 1].
cells[indj][outc[3]];
2061 if (random_number > ((speedsq[outc[0]] + speedsq[outc[1]]) / totalspeed)) {
2062 win_cell =
node[int1 - 1].
cells[indj][outc[2]];
2064 if (random_number <= (speedsq[outc[0]] / totalspeed)) {
2065 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2067 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2091 int win_cell = 0, k;
2092 int count = 0, outc[4] = {0, 0, 0, 0};
2093 double random_number, totalspeed = 0, minsp = 0.0, totalmag = 0;
2096 for (k = 0; k < 4; k++) {
2097 if (products[k] < 0) {
2100 totalspeed = totalspeed + speedsq[k];
2101 totalmag = totalmag + sqrt(speedsq[k]);
2110 for (k = 0; k < 4; k++)
2111 if ((speedsq[k] > minsp) && (k != indk)) {
2113 win_cell =
node[int1 - 1].
cells[indj][k];
2119 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2124 random_number = drand48();
2126 if (random_number <= (sqrt(speedsq[outc[0]]) / totalmag))
2129 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2131 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2136 random_number = drand48();
2138 if (random_number > ((sqrt(speedsq[outc[0]]) + sqrt(speedsq[outc[1]])) / totalmag)) {
2140 win_cell =
node[int1 - 1].
cells[indj][outc[2]];
2143 if (random_number <= (sqrt(speedsq[outc[0]]) / totalmag))
2146 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2148 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2154 random_number = drand48();
2156 if (random_number > ((speedsq[outc[0]] + speedsq[outc[1]] + speedsq[outc[2]]) / totalspeed)) {
2157 win_cell =
node[int1 - 1].
cells[indj][outc[3]];
2159 if (random_number > ((speedsq[outc[0]] + speedsq[outc[1]]) / totalspeed)) {
2160 win_cell =
node[int1 - 1].
cells[indj][outc[2]];
2162 if (random_number <= (speedsq[outc[0]] / totalspeed)) {
2163 win_cell =
node[int1 - 1].
cells[indj][outc[0]];
2165 win_cell =
node[int1 - 1].
cells[indj][outc[1]];
2178 double centx = 0, centy = 0, n1x = 0, n2x = 0, n3x = 0, n1y = 0, n2y = 0, n3y = 0;
2179 int n1 = 0, n2 = 0, n3 = 0;
2189 centx = n1x + n2x + n3x;
2190 centy = n1y + n2y + n3y;
2201 int current_index = 0;
2202 int j, nc = 0, i = 0;
2204 if (stuck <
node[k - 1].numneighb) {
2208 for (j = 0; j < 4; j++) {
2212 current_index = i + 1;
2227 }
while ((nc == 0) && (i <
node[k - 1].numneighb));
2236 return current_index;
2242 int dn1 = 0, dn2 = 0, dn3 = 0, dv1 = 0, dv2 = 0, dv3 = 0;
2243 double current_delta_t;
2251 return current_delta_t;
2289 int n1 = 0, n2 = 0, n3 = 0;
2293 int k, j, nc = 0, i = 0, nc0 = 0, nc10 = 0, nc12 = 0, ncb = 0;
2296 if (
node[n1 - 1].typeN == 0) {
2299 if (
node[n2 - 1].typeN == 0) {
2307 for (j = 0; j < 4; j++) {
2309 if (
node[k - 1].cells[i][j] != prevcell) {
2312 if (
node[
cell[nc - 1].node_ind[0] - 1].typeN +
node[
cell[nc - 1].node_ind[1] - 1].typeN +
node[
cell[nc - 1].node_ind[2] - 1].typeN == 0) {
2317 if (
node[
cell[nc - 1].node_ind[0] - 1].typeN +
node[
cell[nc - 1].node_ind[1] - 1].typeN +
node[
cell[nc - 1].node_ind[2] - 1].typeN == 10) {
2321 if (
node[
cell[nc - 1].node_ind[0] - 1].typeN +
node[
cell[nc - 1].node_ind[1] - 1].typeN +
node[
cell[nc - 1].node_ind[2] - 1].typeN == 12) {
2325 if (
node[
cell[nc - 1].node_ind[0] - 1].typeN +
node[
cell[nc - 1].node_ind[1] - 1].typeN +
node[
cell[nc - 1].node_ind[2] - 1].typeN > 15) {
2340 }
while (i <
node[k - 1].numneighb);
2342 if ((nc0 == 0) && (nc10 != 0)) {
2347 if ((nc0 == 0) && (nc10 == 0) && (nc12 != 0)) {
2352 if ((nc0 == 0) && (nc10 == 0) && (nc12 == 0) && (ncb != 0)) {
2357 if (nc0 + nc10 + nc12 + ncb == 0) {
2371 double posit[3] = {0.0, 0.0, 0.0}, veloc[3] = {0.0, 0.0, 0.0};
2372 double startx, starty, endx, endy, midx, midy, time, velocity_t = 0.0, obeta = 0.0, length_t = 0.0;
2373 int i, tstart = -1, pcell = 0, pfrac = 0, tend = 0, tmid;
2374 int time_l, kdiv = 2;
2375 double eps = 0.05, pressure = 0.0;
2376 struct posit3d particle3dp, particle3dv;
2381 sprintf(filename,
"%s/tempdata_%d",
maindir,
np);
2383 fscanf(tmpp,
"%d %lf %lf %lf %lf %lf %lf %lf %lf %d %d %lf %lf %lf %lf\n ", &tstart, &startx, &starty, &posit[0], &posit[1], &posit[2], &veloc[0], &veloc[1], &veloc[2], &pcell, &pfrac, &time, &obeta, &length_t, &pressure);
2403 fprintf(wint,
"%5.12E %5.12E %5.12E %5.12E %5.12E %d %5.12E\n", length_t, time, posit[0], posit[1], posit[2], pfrac, obeta);
2413 if (tstart != tend) {
2415 fprintf(wv,
"%05d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %05d %5.12E %5.12E %5.12E %d %5.12E\n", tstart, posit[0], posit[1], posit[2], veloc[0], veloc[1], veloc[2], pcell, pfrac, time,
node[
cell[pcell - 1].node_ind[0] - 1].aperture, obeta, 0, pressure);
2421 fprintf(wpt,
"%05d %5.12E %5.12E %5.12E \n",
nodeID, posit[0], posit[1], posit[2]);
2422 velocity_t = sqrt(pow(veloc[0], 2) + pow(veloc[1], 2) + pow(veloc[2], 2));
2423 fprintf(wpt_att,
"%010d %06d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E\n",
nodeID, pfrac, time, velocity_t, veloc[0], veloc[1], veloc[2],
node[
cell[pcell - 1].node_ind[0] - 1].aperture, pressure);
2426 int tstep, flag = 0, isch = 0;
2430 time_l = tend - tstart;
2432 tstep = (int) (time_l / 2.0);
2438 for (isch = 0; isch < time_l; isch++) {
2440 fscanf(tmpp,
"%d %lf %lf %lf %lf %lf %lf %lf %lf %d %d %lf %lf %lf %lf\n ", &tmid, &midx, &midy, &posit[0], &posit[1], &posit[2], &veloc[0], &veloc[1], &veloc[2], &pcell, &pfrac, &time, &obeta, &length_t, &pressure);
2459 if (tmid == tstart + tstep) {
2464 angle_m =
DefineAngle(startx - midx, starty - midy, endx - midx, endy - midy);
2466 if (((angle_m > -eps) && (angle_m < eps)) || ((angle_m >
pi - eps) && (angle_m <
pi + eps))) {
2475 if (tend == tstart) {
2479 }
while (flag == 0);
2485 time_l =
t - tstart;
2488 tstep = (int)(time_l / kdiv);
2491 if (kdiv > time_l) {
2493 kdiv = (int)time_l / 2.0;
2505 for(i = 0; i < kdiv - 1; i++) {
2506 for (isch = 0; isch < time_l; isch++) {
2508 fscanf(tmpp,
"%d %lf %lf %lf %lf %lf %lf %lf %lf %d %d %lf %lf %lf %lf\n ", &tmid, &midx, &midy, &posit[0], &posit[1], &posit[2], &veloc[0], &veloc[1], &veloc[2], &pcell, &pfrac, &time, &obeta, &length_t, &pressure);
2527 if (tmid == tstart + tstep * (i + 1)) {
2533 fprintf(wv,
"%05d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %05d %5.12E %5.12E %5.12E %d %5.12E\n", tmid, posit[0], posit[1], posit[2], veloc[0], veloc[1], veloc[2], pcell, pfrac, time,
node[
cell[pcell - 1].node_ind[0] - 1].aperture, obeta, 0, pressure);
2539 fprintf(wpt,
"%05d %5.12E %5.12E %5.12E \n",
nodeID, posit[0], posit[1], posit[2]);
2540 velocity_t = sqrt(pow(veloc[0], 2) + pow(veloc[1], 2) + pow(veloc[2], 2));
2541 fprintf(wpt_att,
"%010d %06d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E\n",
nodeID, pfrac, time, velocity_t, veloc[0], veloc[1], veloc[2],
node[
cell[pcell - 1].node_ind[0] - 1].aperture, pressure);
2549 fscanf(tmpp,
"%d %lf %lf %lf %lf %lf %lf %lf %lf %d %d %lf %lf %lf %lf\n ", &tstart, &startx, &starty, &posit[0], &posit[1], &posit[2], &veloc[0], &veloc[1], &veloc[2], &pcell, &pfrac, &time, &obeta, &length_t, &pressure);
2551 time_l = currentt - tstart;
2554 time_l = currentt - tstart;
2557 for (i = 0; i < time_l; i++) {
2559 fscanf(tmpp,
"%d %lf %lf %lf %lf %lf %lf %lf %lf %d %d %lf %lf %lf %lf\n ", &tstart, &startx, &starty, &posit[0], &posit[1], &posit[2], &veloc[0], &veloc[1], &veloc[2], &pcell, &pfrac, &time, &obeta, &length_t, &pressure);
2581 fprintf(wpt,
"%05d %5.12E %5.12E %5.12E \n",
nodeID, posit[0], posit[1], posit[2]);
2582 velocity_t = sqrt(pow(veloc[0], 2) + pow(veloc[1], 2) + pow(veloc[2], 2));
2583 fprintf(wpt_att,
"%010d %06d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E\n",
nodeID, pfrac, time, velocity_t, veloc[0], veloc[1], veloc[2],
node[
cell[pcell - 1].node_ind[0] - 1].aperture, pressure);
2587 fprintf(wv,
"%05d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %05d %5.12E %5.12E %5.12E %d %5.12E\n", tstart, posit[0], posit[1], posit[2], veloc[0], veloc[1], veloc[2], pcell, pfrac, time,
node[
cell[pcell - 1].node_ind[0] - 1].aperture, obeta, 0, pressure);
2597 fprintf(wv,
"%05d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %05d %05d %5.12E %5.12E %5.12E %d %5.12E\n",
t, particle3dp.
cord3[0], particle3dp.
cord3[1], particle3dp.
cord3[2], particle3dv.
cord3[0], particle3dv.
cord3[1], particle3dv.
cord3[2],
particle[
np].
cell,
particle[
np].
fracture,
particle[
np].
time,
node[
cell[pcell - 1].
node_ind[0] - 1].
aperture, obeta, fract_p,
particle[
np].
pressure);
2603 fprintf(wpt,
"%05d %5.12E %5.12E %5.12E \n",
nodeID, particle3dp.
cord3[0], particle3dp.
cord3[1], particle3dp.
cord3[2]);
2604 velocity_t = sqrt(pow(particle3dv.
cord3[0], 2) + pow(particle3dv.
cord3[1], 2) + pow(particle3dv.
cord3[2], 2));
2605 fprintf(wpt_att,
"%010d %06d %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E %5.12E\n",
nodeID,
particle[
np].
fracture,
particle[
np].time, velocity_t, particle3dv.
cord3[0], particle3dv.
cord3[1], particle3dv.
cord3[2],
node[
cell[pcell - 1].
node_ind[0] - 1].
aperture,
particle[
np].
pressure);
2612 sprintf(filename,
"%s/tempdata_%d",
maindir,
np);
2613 status = remove(filename);
2617 printf(
"Unable to delete the file %s\n", filename);
2622 sprintf(filename,
"%s/tempdata_%d",
maindir,
np);
2638 int n1out = 0, n2out = 0;
2642 double cx1, cx2, cy1, cy2, px1, px2, py1, py2, ap, bp, cp, as, bs, cs, deter, xint, yint;
2644 if ((
node[n1 - 1].typeN == 210) || (
node[n1 - 1].typeN == 212) || (
node[n1 - 1].typeN == 200) || (
node[n1 - 1].typeN == 202)) {
2648 if ((
node[n2 - 1].typeN == 210) || (
node[n2 - 1].typeN == 212) || (
node[n2 - 1].typeN == 200) || (
node[n2 - 1].typeN == 202)) {
2656 if ((
node[n3 - 1].typeN == 210) || (
node[n3 - 1].typeN == 212) || (
node[n3 - 1].typeN == 200) || (
node[n3 - 1].typeN == 202)) {
2662 if ((n1out != 0) && (n2out != 0)) {
2664 double cx1, cx2, cy1, cy2, px1, px2, py1, py2, ap, bp, cp, as, bs, cs, deter, xint, yint;
2671 cs = as * cx1 + bs * cy1;
2678 cp = ap * px1 + bp * py1;
2679 deter = ap * bs - as * bp;
2680 xint = (bs * cp - bp * cs) / deter;
2681 yint = (ap * cs - as * cp) / deter;
2682 double distance = 0, tfinal;
2683 distance = sqrt((xint - px1) * (xint - px1) + (yint - py1) * (yint - py1));
2692 int ncent = 0, nnext = 0;
2693 ncent = n1out + n2out;
2699 if ((
node[
node[ncent - 1].indnodes[ii] - 1].typeN == 212) || (
node[
node[ncent - 1].indnodes[ii] - 1].typeN == 210) || (
node[
node[ncent - 1].indnodes[ii] - 1].typeN == 202)) {
2709 cs = as * cx1 + bs * cy1;
2716 cp = ap * px1 + bp * py1;
2717 deter = ap * bs - as * bp;
2718 xint = (bs * cp - bp * cs) / deter;
2719 yint = (ap * cs - as * cp) / deter;
2720 double distance = 0, tfinal;
2721 distance = sqrt((xint - px1) * (xint - px1) + (yint - py1) * (yint - py1));
2747 double currentdistance = 0.0, deltatau = 0.0, deltabeta = 0.0, velsquare = 0.0;
2749 currentdistance = pow((xcurrent - xprev), 2) + pow((ycurrent - yprev), 2) + pow((zcurrent - zprev), 2);
2750 velsquare = (pow(particle3dv.cord3[0], 2) + pow(particle3dv.cord3[1], 2) + pow(particle3dv.cord3[2], 2));
2751 deltatau = currentdistance / velsquare;
2753 if (currentdistance > 0.0) {
2783 double randomnumber = 0.0;
2786 double inverse_erfc = 0.0;
2789 unsigned int cnt = 0.0;
2806 randomnumber = drand48();
2807 z = 1.0 - randomnumber;
2809 inverse_erfc = 0.5 * sqrt(
pi) * (z + (
pi / 12) * pow(z, 3) + ((7 * pow(
pi, 2)) / 480) * pow(z, 5) + ((127 * pow(
pi, 3)) / 40320) * pow(z, 7) + ((4369 * pow(
pi, 4)) / 5806080) * pow(z, 9) + ((34807 * pow(
pi, 5)) / 182476800) * pow(z, 11));
2810 timediff = pow(((term_a * time_advect) / inverse_erfc), 2);
int String_Compare(char string1[], char string2[])
int YindexC(int nodenum, int ii)
unsigned long int timesteps
FILE * OpenFile(char filen[120], char fileopt[2])
struct inpfile Control_File(char fileobject[], int ctr)
double DefineAngle(double u1, double u2, double v1, double v2)
void FlowInWeight(int numbpart)
struct inpfile Control_File_Optional(char fileobject[], int ctr)
int XindexC(int nodenum, int ii)
void OutputMarPlumDisp(int currentnum, char path[125])
void ChangeFracture(int cell_win)
struct posit3d CalculateVelocity3D()
unsigned int * nodezoneout
struct inpfile Control_Param(char fileobject[], int ctr)
struct posit3d CalculatePosition3D()
struct material * fracture
unsigned int * nodezonein
double CalculateCurrentDT()
struct tempout * tempdata
int StreamlineRandomSampling(double products[4], double speedsq[4], int indj, int int1, int indk, int neighborcellind[4], int neighborfracind[4], int prevfrac, int prevcell)
struct intcoef CalculateWeights(int nn1, int nn2, int nn3)
void SearchNeighborCells(int nn1, int nn2, int nn3)
void Moving2NextCellBound(int prevcell)
unsigned int tdrw_limited
int InsideCell(unsigned int numc)
void AcrossIntersection(int prevcell, int int1, int int2, int mixing_rule)
int Xindex(int nodenum, int nnp)
void Moving2Center(int nnp, int cellnumber)
double InOutFlowCell(int indcell, int int1, double nposx, double nposy)
int CompleteMixingRandomSampling(double products[4], double speedsq[4], int indj, int int1, int indk)
int Moving2NextCell(int stuck, int k)
struct lagrangian CalculateLagrangian(double xcurrent, double ycurrent, double zcurrent, double xprev, double yprev, double zprev)
struct lagrangian lagvariable
double TimeDomainRW(double time_advect)
void NeighborCells(int k)
void ParticleOutput(int currentt, int fract_p)
int Yindex(int nodenum, int nnp)
unsigned int veloc_ind[3]