25 printf(
"\n OPEN AND READ FILE: %s \n \n", inputfile.
filename);
28 if (fscanf(fpp,
"%d\n", &
nfract) != 1) {
32 printf(
" Number of fractures in the domain = %d \n",
nfract);
36 printf(
"\n OPEN AND READ AVS FILE: %s \n \n", inputfile.
filename);
39 if (fscanf(fp,
"%d %d %d %d %d\n", &
nnodes, &
ncells, &nn, &nn, &nn ) != 5) {
43 printf(
" Total number of nodes: %d, Total number of elements (triangles): %d\n",
nnodes,
ncells);
47 unsigned int snode_edge;
50 printf(
"\n OPEN AND READ STOR FILE: %s\n \n", inputfile.
filename);
54 for (i = 0; i < 2; i++) {
62 if (fscanf (fps,
" %d %d %d %d %d \n", &nedges, &node1, &snode_edge, &area_coef, &
max_neighb ) != 5) {
66 printf (
" Total number of edges in Voronoy polygons = %d, total number of nodes = %d \n", nedges, node1);
69 printf(
"the number of nodes in inp is not equal to number of nodes in stor file! \n");
79 for (i = 0; i <
nnodes; i++) {
88 node[i].
cells[j] = (
unsigned int*)malloc(4 *
sizeof(
unsigned int));
89 node[i].
fracts[j] = (
unsigned int*)malloc(4 *
sizeof(
unsigned int));
94 printf(
"Allocation memory problem - node\n");
101 printf(
"Allocation memory problem - cell\n");
108 printf(
"Allocation memory problem - fracture\n");
111 printf(
"\n Memory allocation is done successfully \n");
116 if (inputfile.
flag > 0) {
117 printf(
"\n OPEN AND READ FILE: %s \n \n", inputfile.
filename);
121 for (i = 0; i <
nfract; i++) {
122 if( fscanf(fpo,
"%d %d %f %f %f %d %f %f %d\n", &nf, &nnf, &
fracture[i].
theta,
133 for (i = 0; i < 7; i++) {
136 }
while (cs !=
'\n');
139 for (i = 0; i <
nfract; i++) {
140 if (fscanf(fpp,
"%d %f %f %f %d %f %f %d %d\n", &nf, &
fracture[i].
theta,
161 unsigned int snode_edge;
162 unsigned int area_coef;
163 unsigned int n1, j, l, ln;
166 char c[3], line[20], cs;
177 printf(
"\n OPEN AND READ FILE: %s \n ", inputfile.
filename);
179 if (fscanf(fp,
"%d %d %d %d %d\n", &n1, &n1, &nnv, &ncv, &n1 ) != 5) {
185 for (i = 0; i <
nnodes; i++) {
186 if (fscanf(fp,
"%d %lf %lf %lf \n", &n1, &
node[i].coord[0], &
node[i].coord[1], &
node[i].coord[2]) != 4) {
193 unsigned int current_fract = 1, previous_fract = 1;
194 unsigned int cell_f = 0;
197 for (i = 0; i <
ncells; i++) {
198 if (fscanf(fp,
"%d %d %c %c %c %d %d %d \n", &n1, &
cell[i].
fracture,
199 &c[0], &c[1], &c[2], &
cell[i].node_ind[0], &
cell[i].node_ind[1], &
cell[i].node_ind[2]) != 8) {
205 if (current_fract != previous_fract) {
207 previous_fract = current_fract;
217 if (fscanf(fp,
"%d", &n1) != 1) {
221 int k = 1, imt1_ind = 0, itp1_ind = 0, ni[nnv];
224 for (i = 0; i < nnv; i++) {
225 if (fscanf(fp,
"%d", &ni[i]) != 1) {
233 printf(
" Please check nodes attributes in inp file\n");
237 for (i = 0; i < nnv; i++) {
238 if (fscanf(fp,
"%s %s \n", var_name, line) != 2) {
242 int res = strncmp(var_name,
"imt1,", 5);
248 int res1 = strncmp(var_name,
"itp1,", 5);
258 int fr = 0, currentfr = 1;
262 for (i = 0; i <
nnodes; i++) {
266 for (j = 0; j < itp1_ind + 2; j++) {
267 if (fscanf(fp,
"%lf ", &fn) != 1) {
271 if (j == imt1_ind + 1) {
274 if (currentfr != fr) {
284 if (j == itp1_ind + 1) {
291 }
while (cs !=
'\n');
300 printf(
"\n OPEN AND READ FILE: %s \n \n", inputfile.
filename);
303 for (i = 0; i < 2; i++) {
306 }
while (cs !=
'\n');
311 if (fscanf (fps,
" %d %d %d %d %d \n", &nedges, &node1, &snode_edge, &area_coef, &
max_neighb ) != 5) {
316 printf(
"the number of nodes in inp file is not equal to number of nodes in stor file! \n");
322 for (i = 0; i <
nnodes; i++) {
323 if (fscanf(fps,
"%lf", &
node[i].pvolume) != 1) {
332 if (fscanf(fps,
"%d", &pn) != 1) {
336 for (i = 0; i <
nnodes; i++) {
337 if (fscanf(fps,
"%d", &cn) != 1) {
347 for (i = 0; i <
nnodes; i++) {
349 if (fscanf(fps,
"%d", &
node[i].indnodes[j]) != 1) {
359 for (i = 0; i < nedges; i++) {
360 if (fscanf(fps,
"%d", &cn) != 1) {
366 for (i = 0; i <
nnodes + 1; i++) {
367 if (fscanf(fps,
"%d", &cn) != 1) {
373 int count = 0, count1 = 0;
375 if (fscanf(fps,
"%d", &pn) != 1) {
379 for (i = 0; i <
nnodes - 1; i++) {
380 if (fscanf(fps,
"%d", &cn) != 1) {
384 count = count + cn - pn;
391 for (i = 0; i <
nnodes; i++) {
395 if (j <
node[i].numneighb) {
396 if (fscanf(fps,
"%lf", &
node[i].area[j]) != 1) {
409 res = strncmp(inputfile.
filename,
"yes", 3);
414 printf(
"\n There is no aperture file is defined. All fractures will have constant aperture equal to 'thickness' parameter. \n");
416 for (i = 0; i <
nnodes; i++) {
421 printf(
"\n----------------FLOW SOLUTION DATA READING--------------------\n");
425 res = strncmp(inputfile.
filename,
"yes", 3);
432 res = strncmp(inputfile.
filename,
"yes", 3);
438 printf(
"\n FLOW SOLUTION SOURCE IS NOT DEFINED. Program is terminated. \n");
444 for (i = 0; i <
nnodes; i++) {
449 if (
node[i].indnodes[j] != i + 1) {
454 if (
node[i].area[j] < 0) {
460 for (k = 0; k < 4; k++) {
472 for (ln = 0; ln <
ncells; ln++) {
491 if (
node[in - 1].indnodes[jj] == jn) {
492 for (kk = 0; kk < 4; kk++) {
493 if (
node[in - 1].cells[jj][kk] == 0) {
506 if (
node[in - 1].indnodes[jj] == kn) {
507 for (kk = 0; kk < 4; kk++) {
508 if (
node[in - 1].cells[jj][kk] == 0) {
531 printf(
"\n OPEN AND READ FILE: %s \n ", inputfile.
filename);
532 printf(
"\n Read the number and indices of nodes defined in flow in and flow out zones \n");
534 int zonenumb_in = 0, zonenumb_out = 0;
537 zonenumb_in = inputfile.
flag;
539 zonenumb_out = inputfile.
flag;
542 int nzone_out, i, fn, nn, res, nf, flag1 = 0, flag2 = 0;
544 if (fscanf(fpc,
"%s \n", line) != 1) {
551 if (fscanf(fpc,
" %d %s \n", &fn, line) != 2) {
555 if (fn == zonenumb_in) {
558 if (fscanf(fpc,
" %s \n ", line) != 1) {
562 if (fscanf(fpc,
" %d", &
nzone_in) != 1) {
570 if (fscanf(fpc,
" %d ", &nf) != 1) {
581 if (fn == zonenumb_out) {
584 if (fscanf(fpc,
" %s ", line) != 1) {
588 if (fscanf(fpc,
" %d", &nzone_out) != 1) {
589 nzone_out = nzone_out;
593 nodezoneout = (
unsigned int*) malloc (nzone_out *
sizeof(
unsigned int));
595 for (i = 0; i < nzone_out; i++) {
596 if (fscanf(fpc,
" %d ", &nf) != 1) {
607 if (fscanf(fpc,
" %s ", line) != 1) {
611 if (fscanf(fpc,
" %d ", &nn) != 1) {
615 for (i = 0; i < nn; i++) {
616 if (fscanf(fpc,
" %d ", &nf) != 1) {
622 }
while ((res = strncmp(line,
"stop", 4)));
624 if ((flag1 = 0) || (flag2 = 0)) {
625 printf(
"Please check zones in boundary zone file.\n");
629 printf(
"\n Number of nodes %d in flow-in zone. \n",
nzone_in);
630 printf(
"\n Number of nodes %d in flow-out zone. \n", nzone_out);
635 double sum_in = 0, sum_out = 0.0;
644 printf (
"Total in-flow volumetric flux = %12.5e [m^3/s] \n",
totalFluxIn);
651 for (i = 0; i < nzone_out; i++) {
658 printf (
"Total out-flow volumetric flux = %12.5e [m^3/s]\n", sum_out);
669 if ((filepointer = fopen (filen, fileopt)) == NULL) {
670 printf (
"File %s could not be opened. Program is terminated. \n", filen);
681 int n1 = 0, n2 = 0, i, n_flux, j, k, res1;
684 double floatnumber, areavalue;
689 printf(
"\n PFLOTRAN: OPEN AND READ FILE: %s \n \n", inputfile.
filename);
698 n_flux = (nedges -
nnodes) / 2.;
705 if ((cs !=
' ') && (csp ==
' ')) {
710 }
while (cs !=
'\n');
719 printf(
" THE VELOCITY FILE FORMAT IS INCORRECT \n");
727 for (i = 0; i < n_flux; i++) {
729 if (fscanf(pf,
" %d %d %lf %lf ", &n1, &n2, &l_flux, &l_dens) != 4) {
732 }
else if (fscanf(pf,
" %d %d %lf %lf %lf ", &n1, &n2, &l_flux, &l_dens, &l_area) != 5) {
737 if (
node[n1 - 1].indnodes[j] == n2) {
745 if (
node[n2 - 1].indnodes[k] == n1) {
750 node[n2 - 1].
flux[k] = l_flux * (-1.0) *
node[n2 - 1].area[k];
763 printf(
"\n PFLOTRAN: OPEN AND READ FILE: %s \n \n", inputfile.
filename);
765 printf(
" Reading pressure \n");
766 double maxpr = 0.0, minpr = 100.0, l_pres = 0.0;
768 for (i = 0; i <
nnodes; i++) {
769 if (fscanf(fp,
" %d %lf %lf %lf %lf \n", &n1, &l_flux, &l_flux, &l_dens, &l_pres) != 5) {
775 if (
node[n1 - 1].pressure > maxpr) {
779 if (
node[n1 - 1].pressure < minpr) {
785 printf(
" MAX pressure %5.8e [MPa]; MIN pressure %5.8e [MPa] \n", maxpr, minpr);
789 for (i = 0; i <
nnodes; i++) {
804 printf(
"\n FEHM: OPEN AND READ FILE: %s \n \n", inputfile.
filename);
807 for (i = 0; i < 4; i++) {
810 }
while (cs !=
'\n');
813 unsigned int par_flag = 0;
817 if (fscanf(fpr,
"%s \n", line) != 1) {
821 double maxpr = 0.0, minpr = 100.0;
822 int res = strncmp(line,
"pressure", 8);
826 printf(
" Reading %s\n", line);
828 for (i = 0; i <
nnodes; i++) {
829 if (fscanf(fpr,
"%lf", &
node[i].pressure) != 1) {
833 if (
node[i].pressure > maxpr) {
837 if (
node[i].pressure < minpr) {
842 printf(
" MAX pressure %5.8e MIN pressure %5.8e \n", maxpr, minpr);
844 }
while ((par_flag != 1) || (fgets(line, 16, fpr) != NULL));
847 printf(
" !!! THERE IS NO PRESSURE DATA !!! \n");
855 if (fscanf(fpr,
"%s", line) != 1) {
859 int res1 = strncmp(line,
"flux", 4);
863 printf(
"\n Reading %s\n", line);
865 if (fscanf(fpr,
"%d\n", &i) != 1) {
870 printf(
"number of edges in *.fin file (%d )is not the same as number of edges in *.stor file (%d)!\n", i, nedges);
875 for (i = 0; i <
nnodes; i++) {
877 if (j <
node[i].numneighb) {
878 if( fscanf(fpr,
"%lf", &
node[i].flux[j]) != 1) {
885 printf(
"\n Fluxes are read from FEHM file \n");
887 }
while ((par_flag != 1) || (fgets(line, 16, fpr) != NULL));
890 printf(
" !!! THERE IS NO FLUX DATA !!! \n");
906 printf(
"\n Output initial data structure \n");
910 for (i = 0; i <
nnodes; i++) {
911 fprintf(wp,
"\n Node %d, type %d, x=%5.8e, y=%5.8e, z=%5.8e, aperture=%5.8e, \n", i + 1,
916 fprintf(wp,
" Vx %5.8e Vy %5.8e \n",
node[i].velocity[0][0],
node[i].velocity[0][1] );
918 fprintf(wp,
" Vx %5.8e Vy %5.8e \n",
node[i].velocity[0][0],
node[i].velocity[0][1] );
919 fprintf(wp,
" Vx %5.8e Vy %5.8e \n",
node[i].velocity[1][0],
node[i].velocity[1][1] );
920 fprintf(wp,
" Vx %5.8e Vy %5.8e \n",
node[i].velocity[2][0],
node[i].velocity[2][1] );
921 fprintf(wp,
" Vx %5.8e Vy %5.8e \n",
node[i].velocity[3][0],
node[i].velocity[3][1] );
924 fprintf(wp,
" Pressure %5.8e, Volume %5.8e , Connections %d \n",
928 fprintf(wp,
" Face %d %d (type %d), flux %5.8e, area %5.8e, cells:\n",
929 i + 1,
node[i].indnodes[j],
node[i].type[j],
node[i].flux[j],
node[i].area[j]);
931 for (k = 0; k < 4; k++) {
932 if (
node[i].cells[j][k] != 0)
933 fprintf(wp,
"(%d) %d in fracture %d; ", k + 1,
934 node[i].cells[j][k],
node[i].fracts[j][k]);
947 for (i = 0; i <
nfract; i++) {
948 fprintf(wf,
"\n Fracture %d first node# %d last node# %d and theta %f\n",
950 fprintf(wf,
"\n Fracture %d has %d cells, starting from %d \n", i + 1,
954 fprintf(wf,
" cell %d, nodes: %d %d %d \n",
fracture[i].firstcell + j,
971 printf(
" GRID CHECK starts \n");
973 for (i = 0; i <
nnodes; i++) {
974 if ((
node[i].typeN == 0) || (
node[i].typeN == 10)) {
978 for (k = 0; k < 4; k++) {
980 printf(
"GRID ERROR: fracture %d node %d / fracture %d \n",
node[i].
fracture[0], i + 1,
node[i].fracts[j][k]);
981 printf(
" node %d %lf %lf %lf \n", i + 1,
node[i + 1].coord[0],
node[i + 1].coord[1],
node[i + 1].coord[2]);
994 printf(
" GRID CHECK is done \n");
1005 char* fileend =
"END";
1007 inputfile.
param = 0.0;
1008 inputfile.flag = -1;
1009 int res2 = 0, res1 = 0;
1012 if (fscanf(cf,
"\n %s", fileline) != 1) {
1020 end = strlen(fileend);
1026 if (fscanf(cf,
"%s", inputfile.filename) != 1) {
1031 end = strlen(fileend);
1033 }
while (end != strlen(fileend));
1035 if (inputfile.flag < 0) {
1036 printf(
"\n There is no %s input found in %s. Program is terminated. \n", fileobject,
controlfile);
1053 char* fileend =
"END";
1055 inputfile.
param = 0.0;
1056 inputfile.flag = -1;
1057 int res2 = 0, res1 = 0;
1060 if (fscanf(cf,
"\n %s", fileline) != 1) {
1068 end = strlen(fileend);
1074 if (fscanf(cf,
"%s", inputfile.filename) != 1) {
1079 end = strlen(fileend);
1081 }
while (end != strlen(fileend));
1092 int resultc = 1, res = 0, k = 0;
1094 for (res = 0; res < strlen(string2); res++) {
1095 if (string1[res] != string2[res]) {
1102 if (k == strlen(string2)) {
1120 char* fileend =
"END";
1121 inputfile.
flag = -1;
1122 inputfile.param = 0.0;
1123 int res2 = 0, res1 = 0;
1126 if (fscanf(cf,
"%s", fileline) != 1) {
1134 end = strlen(fileend);
1140 if (fscanf(cf,
"%ld", &inputfile.flag) != 1) {
1144 end = strlen(fileend);
1146 }
while (end != strlen(fileend));
1148 if (inputfile.flag < 0) {
1149 printf(
"\n There is no %s input found in %s. Program is terminated. \n", fileobject,
controlfile);
1164 char* fileend =
"END";
1166 inputfile.
param = 0.0;
1167 inputfile.flag = -1;
1168 int res2 = 0, res1 = 0;
1171 if (fscanf(cf,
"%s", fileline) != 1) {
1179 end = strlen(fileend);
1185 if (fscanf(cf,
"%lf", &inputfile.param) != 1) {
1190 end = strlen(fileend);
1192 }
while (end != strlen(fileend));
1194 if (inputfile.flag < 0) {
1195 printf(
"\n There is no %s input found in %s. Program is terminated. \n", fileobject,
controlfile);
1210 res_a = strncmp(inputfile.
filename,
"frac", 4);
1216 printf(
"\n OPEN AND READ FILE: %s \n ", inputfile.
filename);
1217 double currentap = 0.0, aperturem[
nfract];
1222 }
while (cs !=
'\n');
1224 for (i = 0; i <
nfract; i++) {
1225 if (fscanf(ad,
"%d %d %d %lf \n", &apmat, &zn, &zn, ¤tap) != 4) {
1229 apmat = apmat * (-1) - 6;
1230 aperturem[apmat - 1] = currentap;
1235 for (i = 0; i <
nnodes; i++) {
1248 res_a = strncmp(inputfile.
filename,
"cell", 4);
1254 printf(
"\n OPEN AND READ FILE: %s \n ", inputfile.
filename);
1255 double currentap = 0.0;
1257 aperturem = (
double*)malloc(
nnodes *
sizeof(
double));
1263 }
while (c !=
'\n');
1265 for (i = 0; i <
nnodes; i++) {
1266 if(fscanf(ada,
"%d %lf \n", &apmat, ¤tap) != 2) {
1270 aperturem[apmat - 1] = currentap;
1275 for (i = 0; i <
nnodes; i++) {
unsigned int * nodezoneout
struct material * fracture
unsigned int * nodezonein
int String_Compare(char string1[], char string2[])
FILE * OpenFile(char filen[120], char fileopt[2])
struct inpfile Control_File(char fileobject[], int ctr)
void ReadPFLOTRANfile(int nedges)
struct inpfile Control_File_Optional(char fileobject[], int ctr)
struct inpfile Control_Param(char fileobject[], int ctr)
void AdjacentCells(int ln, int in, int jn, int kn)
struct inpfile Control_Data(char fileobject[], int ctr)
void ReadFEHMfile(int nedges)
unsigned int veloc_ind[3]