DFNgen  2.0
DFN Model Generator
readInput.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <vector>
4 #include <math.h>
5 #include <cstdlib>
6 #include <string>
7 #include "input.h"
8 #include "readInputFunctions.h"
9 #include "generatingPoints.h"
10 
13 
15 unsigned int nPoly;
16 
18 double domainSize[3];
19 
21 double h;
22 
27 
31 
37 
42 
52 bool boundaryFaces[6];
53 
62 
68 
75 
83 
88 
93 
97 
103 
105 unsigned int seed;
106 
112 
113 
117 
121 
133 float *famProb;
134 
138 
148 int *edistr;
149 
151 float *easpect;
152 
158 unsigned int *enumPoints;
159 
164 
168 float *etheta;
169 
174 float *ephi;
175 
178 float *ebeta;
179 
183 float *ekappa;
184 
186 float *eLogMean;
187 
189 float *esd;
190 
192 float *eExpMean;
193 
195 float *rLogMin;
196 
198 float *rLogMax;
199 
201 float *rExpMin;
202 
204 float *rExpMax;
205 
207 float *eLogMin;
208 
210 float *eLogMax;
211 
213 float *eExpMin;
214 
216 float *eExpMax;
217 
219 float *econst;
220 
222 float *emin;
223 
225 float *emax;
226 
228 float *ealpha;
229 
233 
243 unsigned int *rdistr;
244 
246 float *raspect;
247 
252 
261 
264 float *rtheta;
265 
269 float *rphi;
270 
272 float *rbeta;
273 
277 float *rkappa;
278 
280 float *rLogMean;
281 
283 float *rsd;
284 
286 float *rmin;
287 
289 float *rmax;
290 
292 float *ralpha;
293 
297 
299 float *rExpMean;
300 
302 float *rconst;
303 
307 
310 
315 
317 float *ueRadii;
318 
320 float *ueBeta;
321 
323 float *ueaspect;
324 
327 
329 double *uenormal;
330 
332 unsigned int *uenumPoints;
333 
337 
341 
345 
350 
358 
361 
363 float *urRadii;
364 
369 
371 float *urBeta;
372 
374 float *uraspect;
375 
377 double *urtranslation;
378 
380 double *urnormal;
381 
383 unsigned int nRectByCoord;
384 
386 unsigned int nEllByCoord;
387 
389 unsigned int nEllNodes;
390 
394 
398 
402 
405 float stdAperture;
406 
413 int aperture;
414 
421 
424 
430 
433 
440 
443 float *layers;
444 
447 float *layerVol;
448 
449 /* Defines which domain, or layer, the family belings to.
450  Layer 0 is the entire domain ('domainSize').
451  Layers numbered > 0 coorespond to layers defined above (see 'Layers:').
452  1 corresponts to the first layer listed, 2 is the next layer listed, etc*/
453 int *rLayer;
454 
459 int *eLayer;
460 
468 bool *p32Status;
469 
474 
477 
478 /******************************************************************/
485 void getInput(char* input, std::vector<Shape> &shapeFamily){
486 
487  std::string tempstring;
488  char ch;
489 
490  std::ifstream inputFile;
491  std::cout<<"DFN Generator Input File: "<< input <<"\n\n";
492 
493  // Open input file and initialize variables
494 
495  inputFile.open(input, std::ifstream::in);
496  checkIfOpen(inputFile, tempstring.c_str());
497 
498  searchVar(inputFile, "stopCondition:");
499  inputFile >> stopCondition;
500 
501  searchVar(inputFile, "printRejectReasons:");
502  inputFile >> printRejectReasons;
503 
504  searchVar(inputFile, "domainSize:");
505  inputFile >> ch >> domainSize[0] >> ch >> domainSize[1] >> ch >> domainSize[2];
506 
507  searchVar(inputFile, "numOfLayers:");
508  inputFile >> numOfLayers;
509 
510 
511  if (numOfLayers > 0 ) {
512  layers = new float[numOfLayers*2]; // Multiply by 2 for +z and -z for each layer
513  layerVol = new float[numOfLayers];
514  searchVar(inputFile, "layers:");
515 
516  std::cout << "Number of Layers: " << numOfLayers << "\n";
517  for (int i = 0; i < numOfLayers; i++){
518  int idx = i*2;
519  inputFile >> ch >> layers[idx] >> ch >> layers[idx+1] >> ch;
520  std::cout<<" Layer "<<i+1<<"{-z,+z}: {"<< layers[idx] << ","<<layers[idx+1] << "}, Volume: ";
521  layerVol[i] = domainSize[0]*domainSize[1]* (std::abs(layers[idx+1]-layers[idx]));
522  std::cout << layerVol[i] << "m^3\n";
523  }
524  std::cout<<"\n";
525  }
526 
527  searchVar(inputFile, "h:");
528  inputFile >> h;
529 
530  searchVar(inputFile, "disableFram:");
531  inputFile >> disableFram;
532 
533  if (disableFram == true) {
534  std::cout<<"\nFRAM IS DISABLED\n";
535  }
536 
537  searchVar(inputFile, "tripleIntersections:");
538  inputFile >> tripleIntersections;
539 
540  searchVar(inputFile, "forceLargeFractures:");
541  inputFile >> forceLargeFractures;
542 
543  searchVar(inputFile, "visualizationMode:");
544  inputFile >> visualizationMode;
545 
546  if (disableFram == true){
547  visualizationMode = 1;
548  }
549 
550  searchVar(inputFile, "outputAllRadii:");
551  inputFile >> outputAllRadii;
552 
553  searchVar(inputFile, "outputFinalRadiiPerFamily:");
554  inputFile >> outputFinalRadiiPerFamily;
555 
556  searchVar(inputFile, "outputAcceptedRadiiPerFamily:");
557  inputFile >> outputAcceptedRadiiPerFamily;
558 
559  searchVar(inputFile, "seed:");
560  inputFile >> seed;
561 
562  searchVar(inputFile, "domainSizeIncrease:");
563  inputFile >> ch >> domainSizeIncrease[0] >> ch >> domainSizeIncrease[1] >> ch >> domainSizeIncrease[2];
564 
565  searchVar(inputFile, "keepOnlyLargestCluster:");
566  inputFile >> keepOnlyLargestCluster;
567 
568  searchVar(inputFile, "ignoreBoundaryFaces:");
569  inputFile >> ignoreBoundaryFaces;
570 
571  searchVar(inputFile, "boundaryFaces:");
572  inputFile >>ch>>boundaryFaces[0]>>ch>>boundaryFaces[1]>>ch>>boundaryFaces[2]>>ch>>boundaryFaces[3]>>ch>>boundaryFaces[4]>>ch>>boundaryFaces[5];
573 
574  searchVar(inputFile, "rejectsPerFracture:");
575  inputFile>>rejectsPerFracture;
576 
577  searchVar(inputFile, "nFamRect:");
578  inputFile >> nFamRect;
579 
580  searchVar(inputFile, "nFamEll:");
581  inputFile >> nFamEll;
582 
583  searchVar(inputFile, "removeFracturesLessThan:");
584  inputFile >> removeFracturesLessThan;
585 
586  if (nFamEll > 0 || nFamRect >0) {
587  searchVar(inputFile, "famProb:");
588  famProb = new float[(nFamEll+nFamRect)];
589  getInputAry(inputFile, famProb, (nFamEll+nFamRect));
590 
591  searchVar(inputFile, "famProb:");
592  famProbOriginal = new float[(nFamEll+nFamRect)];
593  getInputAry(inputFile, famProbOriginal, (nFamEll+nFamRect));
594 
595  searchVar(inputFile, "radiiListIncrease:");
596  inputFile >> radiiListIncrease;
597 
598  }
599 
600 
601  if (nFamEll > 0) {
602 
603  searchVar(inputFile, "ebetaDistribution:");
604  ebetaDistribution = new bool[nFamEll];
605  getInputAry(inputFile, ebetaDistribution, nFamEll);
606 
607  searchVar(inputFile, "eLayer:");
608  eLayer = new int[nFamEll];
609  getInputAry(inputFile, eLayer, nFamEll);
610 
611  searchVar(inputFile, "edistr:");
612  edistr = new int[nFamEll];
613  getInputAry(inputFile, edistr, nFamEll);
614 
615  searchVar(inputFile, "easpect:");
616  easpect = new float[nFamEll];
617  getInputAry(inputFile, easpect, nFamEll);
618 
619  searchVar(inputFile, "enumPoints:");
620  enumPoints = new unsigned int[nFamEll];
621  getInputAry(inputFile,enumPoints, nFamEll);
622 
623  searchVar(inputFile, "eAngleOption:");
624  inputFile >> eAngleOption;
625 
626  searchVar(inputFile, "etheta:");
627  etheta = new float[nFamEll];
628  getInputAry(inputFile, etheta, nFamEll);
629 
630  searchVar(inputFile, "ephi:");
631  ephi = new float[nFamEll];
632  getInputAry(inputFile, ephi, nFamEll);
633 
634  searchVar(inputFile, "ebeta:");
635  ebeta = new float[nFamEll];
636  getInputAry(inputFile, ebeta, nFamEll);
637 
638  searchVar(inputFile, "ekappa:");
639  ekappa = new float[nFamEll];
640  getInputAry(inputFile, ekappa, nFamEll);
641 
642  searchVar(inputFile, "eLogMean:");
643  eLogMean = new float[nFamEll];
644  getInputAry(inputFile, eLogMean, nFamEll);
645 
646  searchVar(inputFile, "esd:");
647  esd = new float[nFamEll];
648  getInputAry(inputFile, esd, nFamEll);
649 
650  searchVar(inputFile, "eExpMean:");
651  eExpMean = new float[nFamEll];
652  getInputAry(inputFile, eExpMean, nFamEll);
653 
654  searchVar(inputFile, "emin:");
655  emin = new float[nFamEll];
656  getInputAry(inputFile, emin, nFamEll);
657 
658  searchVar(inputFile, "emax:");
659  emax = new float[nFamEll];
660  getInputAry(inputFile, emax, nFamEll);
661 
662  searchVar(inputFile, "ealpha:");
663  ealpha = new float[nFamEll];
664  getInputAry(inputFile, ealpha, nFamEll);
665 
666  searchVar(inputFile, "econst:");
667  econst = new float[nFamEll];
668  getInputAry(inputFile, econst, nFamEll);
669 
670  searchVar(inputFile, "eLogMin:");
671  eLogMin = new float[nFamEll];
672  getInputAry(inputFile, eLogMin, nFamEll);
673 
674  searchVar(inputFile, "eLogMax:");
675  eLogMax = new float[nFamEll];
676  getInputAry(inputFile, eLogMax, nFamEll);
677 
678  searchVar(inputFile, "eExpMin:");
679  eExpMin = new float[nFamEll];
680  getInputAry(inputFile, eExpMin, nFamEll);
681 
682  searchVar(inputFile, "eExpMax:");
683  eExpMax = new float[nFamEll];
684  getInputAry(inputFile, eExpMax, nFamEll);
685 
686 
687  if (stopCondition == 1) {
688  // Get temp array for ellipse p32 targets
689  // Used to simplify initialization of shape family structures below
690  searchVar(inputFile, "e_p32Targets:");
691  e_p32Targets = new float[nFamEll];
692  getInputAry(inputFile, e_p32Targets, nFamEll);
693  }
694  }
695 
696 
697  // Distribution counters
698  int shape1 = 0; //longnormal dist counter
699  int shape2 = 0; //truncated power-law dist counter
700  int shape3 = 0; //exponential dist counter
701  int shape4 = 0; //constant dist counter
702  int betaCount = 0;
703 
704  // Create shape strucutres from data gathered above
705  for (int i = 0; i < nFamEll; i++){
706  struct Shape newShapeFam;
707 
708  newShapeFam.shapeFamily = 0; // shapFam = 0 = ellipse, 1 = rect
709  newShapeFam.distributionType = edistr[i];
710  newShapeFam.numPoints = enumPoints[i];
711  newShapeFam.aspectRatio = easpect[i];
712  newShapeFam.theta = etheta[i];
713  newShapeFam.phi = ephi[i];
714  newShapeFam.kappa = ekappa[i];
715  newShapeFam.angleOption = eAngleOption;
716  newShapeFam.layer = eLayer[i];
717 
718  generateTheta(newShapeFam.thetaList, newShapeFam.aspectRatio, newShapeFam.numPoints);
719 
720 
721  if (ebetaDistribution[i] == 1 ){ // If constant user defined beta option
722  newShapeFam.betaDistribution = 1;
723  newShapeFam.beta = ebeta[betaCount];
724  betaCount++;
725  }
726  else {
727  newShapeFam.betaDistribution = 0;
728  }
729 
730  // dist options:1 = lognormal, 2= truncated power-law, 3= exponential, 4=constant
731  switch (edistr[i]) {
732  case 1: // Lognormal
733  newShapeFam.mean = eLogMean[shape1];
734  newShapeFam.sd = esd[shape1];
735  newShapeFam.logMin = eLogMin[shape1];
736  newShapeFam.logMax = eLogMax[shape1];
737  shape1++;
738  break;
739  case 2: // Truncated power-law
740  newShapeFam.min = emin[shape2];
741  newShapeFam.max = emax[shape2];
742  newShapeFam.alpha = ealpha[shape2];
743  shape2++;
744  break;
745  case 3:
746 
747  newShapeFam.expMean = eExpMean[shape3];
748  newShapeFam.expLambda = 1/eExpMean[shape3];
749  newShapeFam.expMin = eExpMin[shape3];
750  newShapeFam.expMax = eExpMax[shape3];
751  shape3++;
752  break;
753  case 4:
754  newShapeFam.constRadi = econst[shape4];
755  shape4++;
756  break;
757  }
758 
759  if (stopCondition == 1){
760  newShapeFam.p32Target = e_p32Targets[i];
761  }
762 
763  // Save shape family to perminant array
764  shapeFamily.push_back(newShapeFam);
765 
766  }
767 
768  if (nFamEll > 0 ) {
769  // Can now delete/free the memory for these arrays
770  delete[] ebetaDistribution;
771  delete[] edistr;
772  delete[] easpect;
773  delete[] enumPoints;
774  delete[] etheta;
775  delete[] ephi;
776  delete[] ebeta;
777  delete[] ekappa;
778  delete[] eLogMean;
779  delete[] esd;
780  delete[] eExpMean;
781  delete[] emin;
782  delete[] emax;
783  delete[] ealpha;
784  delete[] econst;
785  delete[] eLayer;
786  delete[] eLogMin;
787  delete[] eLogMax;
788  delete[] eExpMin;
789  delete[] eExpMax;
790 
791  if (stopCondition == 1){
792  delete[] e_p32Targets;
793  }
794  }
795 
796 
797  if (nFamRect >0) {
798 
799  searchVar(inputFile, "rbetaDistribution:");
800  rbetaDistribution = new bool[nFamRect];
801  getInputAry(inputFile, rbetaDistribution, nFamRect);
802 
803  searchVar(inputFile, "rdistr:");
804  rdistr = new unsigned int[nFamRect];
805  getInputAry(inputFile, rdistr, nFamRect);
806 
807  searchVar(inputFile, "rLayer:");
808  rLayer = new int[nFamRect];
809  getInputAry(inputFile, rLayer, nFamRect);
810 
811  searchVar(inputFile, "raspect:");
812  raspect = new float[nFamRect];
813  getInputAry(inputFile, raspect, nFamRect);
814 
815  searchVar(inputFile, "rAngleOption:");
816  inputFile >> rAngleOption;
817 
818  searchVar(inputFile, "rtheta:");
819  rtheta = new float[nFamRect];
820  getInputAry(inputFile, rtheta, nFamRect);
821 
822  searchVar(inputFile, "rphi:");
823  rphi = new float[nFamRect];
824  getInputAry(inputFile, rphi, nFamRect);
825 
826  searchVar(inputFile, "rbeta:");
827  rbeta = new float[nFamRect];
828  getInputAry(inputFile, rbeta, nFamRect);
829 
830  searchVar(inputFile, "rkappa:");
831  rkappa = new float[nFamRect];
832  getInputAry(inputFile, rkappa, nFamRect);
833 
834  searchVar(inputFile, "rLogMean:");
835  rLogMean = new float[nFamRect];
836  getInputAry(inputFile, rLogMean, nFamRect);
837 
838  searchVar(inputFile, "rsd:");
839  rsd = new float[nFamRect];
840  getInputAry(inputFile, rsd, nFamRect);
841 
842  searchVar(inputFile, "rmin:");
843  rmin = new float[nFamRect];
844  getInputAry(inputFile, rmin, nFamRect);
845 
846  searchVar(inputFile, "rmax:");
847  rmax = new float[nFamRect];
848  getInputAry(inputFile, rmax, nFamRect);
849 
850  searchVar(inputFile, "ralpha:");
851  ralpha = new float[nFamRect];
852  getInputAry(inputFile, ralpha, nFamRect);
853 
854  searchVar(inputFile, "rExpMean:");
855  rExpMean = new float[nFamRect];
856  getInputAry(inputFile, rExpMean, nFamRect);
857 
858  searchVar(inputFile, "rconst:");
859  rconst = new float[nFamRect];
860  getInputAry(inputFile, rconst, nFamRect);
861 
862  searchVar(inputFile, "rLogMin:");
863  rLogMin = new float[nFamRect];
864  getInputAry(inputFile, rLogMin, nFamRect);
865 
866  searchVar(inputFile, "rLogMax:");
867  rLogMax = new float[nFamRect];
868  getInputAry(inputFile, rLogMax, nFamRect);
869 
870  searchVar(inputFile, "rExpMin:");
871  rExpMin = new float[nFamRect];
872  getInputAry(inputFile, rExpMin, nFamRect);
873 
874  searchVar(inputFile, "rExpMax:");
875  rExpMax = new float[nFamRect];
876  getInputAry(inputFile, rExpMax, nFamRect);
877 
878  if (stopCondition == 1) {
879  // Get temp array for rectangle p32 targets,
880  // Used to simplify initialization of shape family structures below
881  searchVar(inputFile, "r_p32Targets:");
882  r_p32Targets = new float[nFamRect];
883  getInputAry(inputFile, r_p32Targets, nFamRect);
884  }
885  }
886 
887 
888  // Set stop condition variables
889  if (nFamRect > 0 || nFamEll > 0) {
890 
891  if (stopCondition == 0){ // npoly option
892  searchVar(inputFile, "nPoly:");
893  inputFile >> nPoly;
894  }
895  else if (stopCondition == 1) { // Stop program when p32 conditions per fracture family are met
896  p32Status = new bool [nFamRect + nFamEll]; // Staus array for whether or not the family has reached its p32 requirement
897 
898  for (int i = 0; i < (nFamRect + nFamEll); i++){
899  // Zero the status flags
900  p32Status[i] = 0;
901  }
902  }
903  }
904 
905 
906  // Counters, used to place variable into correct array index
907  // distribution counters
908  shape1 = 0; // Longnormal dist counter
909  shape2 = 0; // Truncated power-law dist counter
910  shape3 = 0; // Exponential dist counter
911  shape4 = 0; // Constant dist counter
912  betaCount = 0;
913 
914 
915  // Create shape strucutres from data gathered above
916  for (int i = 0; i < nFamRect; i++) {
917 
918  struct Shape newShapeFam;
919 
920  newShapeFam.shapeFamily = 1; // shapFam = 0 = ellipse, 1 = rect
921  newShapeFam.distributionType = rdistr[i];
922  newShapeFam.numPoints = 4; // Rectangle
923  newShapeFam.aspectRatio = raspect[i];
924  newShapeFam.theta = rtheta[i];
925  newShapeFam.phi = rphi[i];
926  newShapeFam.kappa = rkappa[i];
927  newShapeFam.angleOption = rAngleOption;
928  newShapeFam.layer = rLayer[i];
929 
930  if (rbetaDistribution[i] == 1 ) { // If constant beta option
931  newShapeFam.betaDistribution = 1;
932  newShapeFam.beta = rbeta[betaCount];
933  betaCount++;
934 
935  }
936  else {
937  newShapeFam.betaDistribution = 0;
938  }
939 
940  // dist options:1 = lognormal, 2= truncated power-law, 3= exponential, 4=constant
941  switch (rdistr[i]) {
942  case 1: // Lognormal
943  newShapeFam.mean = rLogMean[shape1];
944  newShapeFam.sd = rsd[shape1];
945  newShapeFam.logMin = rLogMin[shape1];
946  newShapeFam.logMax = rLogMax[shape1];
947  shape1++;
948  break;
949  case 2: // Truncated power-law
950  newShapeFam.min = rmin[shape2];
951  newShapeFam.max = rmax[shape2];
952  newShapeFam.alpha = ralpha[shape2];
953  shape2++;
954  break;
955  case 3:
956  newShapeFam.expMean = rExpMean[shape3];
957  newShapeFam.expLambda = 1/rExpMean[shape3];
958  newShapeFam.expMin = rExpMin[shape3];
959  newShapeFam.expMax = rExpMax[shape3];
960  shape3++;
961  break;
962  case 4:
963  newShapeFam.constRadi = rconst[shape4];
964  shape4++;
965  break;
966  }
967 
968  if (stopCondition == 1){
969  newShapeFam.p32Target = r_p32Targets[i];
970  }
971 
972 
973  // Save family to perminant array
974  shapeFamily.push_back(newShapeFam);
975 
976  }
977 
978  if (nFamRect > 0 ) {
979  // Can now delete/free the memory for these arrays
980  delete[] rbetaDistribution;
981  delete[] rdistr;
982  delete[] raspect;
983  delete[] rtheta;
984  delete[] rphi;
985  delete[] rbeta;
986  delete[] rkappa;
987  delete[] rLogMean;
988  delete[] rsd;
989  delete[] rExpMean;
990  delete[] rmin;
991  delete[] rmax;
992  delete[] ralpha;
993  delete[] rconst;
994  delete[] rLayer;
995  delete[] rLogMin;
996  delete[] rLogMax;
997  delete[] rExpMin;
998  delete[] rExpMax;
999 
1000  if (stopCondition == 1) {
1001  delete[] r_p32Targets;
1002  }
1003  }
1004 
1005 
1006  searchVar(inputFile, "userEllipsesOnOff:");
1007  inputFile >> userEllipsesOnOff;
1008 
1009  if (userEllipsesOnOff != 0) {
1010 
1011  searchVar(inputFile, "UserEll_Input_File_Path:");
1012  inputFile >> tempstring;
1013  std::ifstream uEllFile;
1014  uEllFile.open(tempstring.c_str(),std::ifstream::in);
1015  checkIfOpen(uEllFile, tempstring);
1016  std::cout << "User Defined Ellipses File: " << tempstring << std::endl;
1017 
1018  searchVar(uEllFile, "nUserEll:");
1019  uEllFile >> nUserEll;
1020 
1021  searchVar(uEllFile, "Radii:");
1022  ueRadii = new float[nUserEll];
1023  getElements(uEllFile, ueRadii, nUserEll);
1024 
1025  searchVar(uEllFile, "Aspect_Ratio:");
1026  ueaspect = new float[nUserEll];
1027  getElements(uEllFile, ueaspect, nUserEll);
1028 
1029  searchVar(uEllFile, "AngleOption:");
1030  uEllFile >> ueAngleOption;
1031 
1032  searchVar(uEllFile, "Beta:");
1033  ueBeta = new float[nUserEll];
1034  getElements(uEllFile, ueBeta, nUserEll);
1035 
1036  searchVar(uEllFile, "Translation:");
1037  uetranslation = new double[3*nUserEll];
1038  get2dAry(uEllFile, uetranslation, nUserEll);
1039 
1040  searchVar(uEllFile, "Normal:");
1041  uenormal = new double[3*nUserEll];
1042  get2dAry(uEllFile, uenormal, nUserEll);
1043 
1044  searchVar(uEllFile, "Number_of_Vertices:");
1045  uenumPoints = new unsigned int[nUserEll];
1046  getElements(uEllFile, uenumPoints, nUserEll);
1047 
1048  uEllFile.close();
1049  }
1050 
1051 
1052  searchVar(inputFile, "userRectanglesOnOff:");
1053  inputFile >> userRectanglesOnOff;
1054 
1055 
1056  if (userRectanglesOnOff != 0) {
1057 
1058  searchVar(inputFile, "UserRect_Input_File_Path:");
1059 
1060  inputFile >> tempstring;
1061  std::ifstream uRectFile;
1062  uRectFile.open(tempstring.c_str(),std::ifstream::in);
1063  checkIfOpen(uRectFile, tempstring);
1064  std::cout << "User Defined Rectangles File: " << tempstring << std::endl;
1065 
1066  searchVar(uRectFile,"nUserRect:");
1067  uRectFile >> nUserRect;
1068 
1069  searchVar(uRectFile, "Radii:");
1070  urRadii = new float[nUserRect];
1071  getElements(uRectFile, urRadii, nUserRect);
1072 
1073 
1074  searchVar(uRectFile, "AngleOption:");
1075  uRectFile >> urAngleOption;
1076 
1077 
1078  searchVar(uRectFile, "Beta:");
1079  urBeta = new float[nUserRect];
1080  getElements(uRectFile, urBeta, nUserRect);
1081 
1082 
1083  searchVar(uRectFile, "Aspect_Ratio:");
1084  uraspect = new float[nUserRect];
1085  getElements(uRectFile, uraspect, nUserRect);
1086 
1087 
1088  searchVar(uRectFile, "Translation:");
1089  urtranslation = new double[3*nUserRect];
1090  get2dAry(uRectFile, urtranslation, nUserRect);
1091 
1092  searchVar(uRectFile, "Normal:");
1093  urnormal = new double[3*nUserRect];
1094  get2dAry(uRectFile, urnormal, nUserRect);
1095 
1096 
1097 
1098  uRectFile.close();
1099  }
1100 
1101  searchVar(inputFile, "userEllByCoord:");
1102  inputFile >> userEllByCoord;
1103 
1104  searchVar(inputFile, "userRecByCoord:");
1105  inputFile >> userRecByCoord;
1106 
1107 
1108 
1109  if ((userRectanglesOnOff == 1 || userRecByCoord == 1) && (userEllipsesOnOff == 1 || userEllByCoord == 1)) {
1110  searchVar(inputFile, "insertUserRectanglesFirst:");
1111  inputFile >> insertUserRectanglesFirst;
1112  }
1113  else {
1115  }
1116 
1117 
1118 
1119  if (userEllByCoord != 0) {
1120  searchVar(inputFile, "EllByCoord_Input_File_Path:");
1121  inputFile >> tempstring;
1122  std::ifstream file;
1123  file.open(tempstring.c_str(),std::ifstream::in);
1124  checkIfOpen(file, tempstring);
1125  std::cout << "User Defined Ellipses by Coordinates File: " << tempstring << std::endl;
1126 
1127  searchVar(file, "nEllipses:");
1128  file >> nEllByCoord;
1129 
1130  searchVar(file, "nNodes:");
1131  file >> nEllNodes;
1132 
1133  userEllCoordVertices = new double[3 * nEllNodes * nEllByCoord];
1134  searchVar(file, "Coordinates:");
1135 
1136  getCords(file, userEllCoordVertices, nEllByCoord, nEllNodes);
1137 
1138  file.close();
1139  }
1140 
1141 
1142  if (userRecByCoord != 0) {
1143  searchVar(inputFile, "RectByCood_Input_File_Path:");
1144  inputFile >> tempstring;
1145  std::ifstream uCoordFile;
1146  uCoordFile.open(tempstring.c_str(),std::ifstream::in);
1147  checkIfOpen(uCoordFile, tempstring);
1148  std::cout << "User Defined Rectangles by Coordinates File: " << tempstring << std::endl;
1149 
1150  searchVar(uCoordFile, "nRectangles:");
1151  uCoordFile >> nRectByCoord;
1152 
1153  searchVar(uCoordFile, "Coordinates:");
1154  //4 vertices, 12 elements x,y,z per rectangle:
1155  userRectCoordVertices = new double[12 * nRectByCoord];
1156  getRectCoords(uCoordFile, userRectCoordVertices, nRectByCoord);
1157 
1158  uCoordFile.close();
1159  }
1160 
1161  searchVar(inputFile, "aperture:");
1162  inputFile >> aperture;
1163 
1164  if (aperture == 1) {
1165 
1166  searchVar(inputFile, "meanAperture:");
1167  inputFile >> meanAperture;
1168 
1169  searchVar(inputFile, "stdAperture:");
1170  inputFile >> stdAperture;
1171 
1172  }
1173  else if (aperture == 2) {
1174  searchVar(inputFile,"apertureFromTransmissivity:");
1175  getInputAry(inputFile, apertureFromTransmissivity, 2);
1176  }
1177  else if (aperture == 3) {
1178  searchVar(inputFile, "constantAperture:");
1179  inputFile >> constantAperture;
1180  }
1181  else if (aperture == 4) {
1182  searchVar(inputFile, "lengthCorrelatedAperture:");
1183  getInputAry(inputFile, lengthCorrelatedAperture, 2);
1184  }
1185  else {
1186  std::cerr<<"\nERROR: Aperture option not recognised\n";
1187  exit(1);
1188  }
1189 
1190  searchVar(inputFile, "permOption:");
1191  inputFile >> permOption;
1192  if (permOption != 0) {
1193  searchVar(inputFile, "constantPermeability:");
1194  inputFile >> constantPermeability;
1195  }
1196 
1197  // Error check on stopping parameter
1198  if (nFamEll + nFamRect == 0 && stopCondition != 0) { // If no stochastic shapes, use nPoly option with npoly = number of user polygons
1199  std::cout<<"\nWARNING: You have defined stopCondition = 1 (P32 program stopping condition) but have no stochastic shape families defined. Automatically setting stopCondition to 0 for use with user defined polygons and nPoly.\n\n";
1200  stopCondition = 0;
1201 
1202  if (userEllipsesOnOff == 0 && userRectanglesOnOff == 0 && userRecByCoord == 0 ) {
1203  std::cout << "ERROR: All polygon generating options are off or undefined, please check input file for errors.\n\n";
1204  exit(1);
1205  }
1206 
1207  int count = 0; // Count of user defined polygons
1208  if (userEllipsesOnOff == 1){
1209  count += nUserEll;
1210  }
1211 
1212  if (userRectanglesOnOff == 1){
1213  count += nUserRect;
1214  }
1215 
1216  if (userRecByCoord == 1) {
1217  count += nRectByCoord;
1218  }
1219 
1220  // Set nPoly to the amount of user defined polygons
1221  nPoly = count;
1222 
1223  }
1224 
1225  inputFile.close();
1226 
1227  // Convert angles to rad if necessary, all functions and code require radians
1228  for (unsigned int i = 0; i < shapeFamily.size(); i ++) {
1229  if (shapeFamily[i].angleOption == 1 ) { // Convert deg to rad
1230  double temp = M_PI/180;
1231  shapeFamily[i].beta *= temp;
1232  shapeFamily[i].theta *= temp;
1233  shapeFamily[i].phi *= temp;
1234  shapeFamily[i].angleOption = 0; // Angles now in radians
1235  }
1236  }
1237 
1238 
1239 }
1240 
1241 /****************************************************************************************/
1242 // Depreciated Function
1243 // Prints all input variables, useful for debugging.
1244 // NOTE: Needs to be updated. There bave been changes to input variables
1246  std::cout << "npoly = " << nPoly << std::endl;
1247  std::cout<< "tripleIntersections = " << tripleIntersections << std::endl;
1248  std::cout << "domainsize = {" << domainSize[0] << ", " << domainSize[1] << ", " << domainSize[2] << "}\n";
1249  std::cout << "h = " << h << std::endl;
1250  std::cout << "visualizationMode = " << visualizationMode << std::endl;
1251  std::cout << "seed = " << seed << std::endl;
1252  std::cout << "keepOnlyLargestCluster = "<<keepOnlyLargestCluster << std::endl;
1253  std::cout << "domainSizeIncrease = {" << domainSizeIncrease[0]<<","<<domainSizeIncrease[1]<<","<<domainSizeIncrease[2]<< "}\n";
1254  std::cout<< "boundaryFaces = {"<<boundaryFaces[0]<<","<<boundaryFaces[1]<<","<<boundaryFaces[2]<<","<<boundaryFaces[3]<<","<<boundaryFaces[4]<<","<<boundaryFaces[5]<<"}\n";
1255  std::cout<< "nFamRect = " <<nFamRect<<std::endl;
1256  std::cout << "nFamEll = " << nFamEll << std::endl;
1257  printAry(famProb, "famProb", (nFamEll+nFamRect));
1258  printAry(edistr, "edistr", nFamEll);
1259  printAry(enumPoints, "enumPoints", nFamEll);
1260  std::cout << "eAngleOption = " << eAngleOption << std::endl;
1261  printAry(easpect, "easpect", nFamEll);
1262  printAry(etheta, "etheta", nFamEll);
1263  printAry(ephi, "ephi", nFamEll);
1264  printAry(ebeta, "ebeta", nFamEll);
1265  printAry(ekappa, "ekappa", nFamEll);
1266  printAry(eLogMean, "eLogMean", nFamEll);
1267  printAry(esd, "esd", nFamEll);
1268  printAry(eExpMean, "eExpMean", nFamEll);
1269  printAry(econst, "econst", nFamEll);
1270  printAry(emin, "emin", nFamEll);
1271  printAry(emax, "emax", nFamEll);
1272  printAry(ealpha, "ealpha", nFamEll);
1273  printAry(rdistr, "rdistr", nFamRect);
1274  printAry(raspect, "raspect", nFamRect);
1275  std::cout << "rAngleOption = " << rAngleOption << std::endl;
1276  printAry(rtheta, "rtheta", nFamRect);
1277  printAry(rphi, "rphi", nFamRect);
1278  printAry(rbeta, "rbeta", nFamRect);
1279  printAry(rLogMean, "rLogMean", nFamRect);
1280  printAry(rsd, "rsd", nFamRect);
1281  printAry(rmin, "rmin", nFamRect);
1282  printAry(rmax, "rmax", nFamRect);
1283  printAry(ralpha, "ralpha", nFamRect);
1284  printAry(rkappa, "rkappa", nFamRect);
1285  printAry(rExpMean, "rExpMean", nFamRect);
1286  printAry(rconst, "rconst", nFamRect);
1287  std::cout << "userEllipsesOnOff = " << userEllipsesOnOff << std::endl;
1288 
1289  if (userEllipsesOnOff != 0) {
1290  std::cout<<"nUserEll = " << nUserEll << "\n";
1291  printAry(ueRadii, "ueRadii", nUserEll);
1292  std::cout << "urAngleOption = " << ueAngleOption <<std::endl;
1293  printAry(ueBeta, "ueBeta", nUserEll);
1294  printAry(ueaspect, "ueaspect", nUserEll);
1295  print2dAry(uetranslation, "uetranslation", nUserEll);
1296  print2dAry(uenormal, "uenormal", nUserEll);
1297  printAry(uenumPoints, "uenumPoints", nUserEll);
1298  }
1299 
1300  std::cout << "userRectanglesOnOff = " << userRectanglesOnOff << std::endl;
1301 
1302  if (userRectanglesOnOff != 0) {
1303 
1304  std::cout<<"nUserRect = "<< nUserRect <<"\n";
1305  printAry(urRadii, "urRadii", nUserRect);
1306  std::cout<< "urAngleOption = " << urAngleOption << std::endl;
1307  printAry(urBeta, "urBeta", nUserRect);
1308  printAry(urRadii, "urRadii", nUserRect);
1309  printAry(uraspect, "uraspect", nUserRect);
1310  print2dAry(urtranslation, "urtranslation", nUserRect);
1311  print2dAry(urnormal, "urnormal", nUserRect);
1312  }
1313 
1314  std::cout << "userRecByCoord = " << userRecByCoord << std::endl;
1315  if (userRecByCoord != 0) {
1316  std::cout << "nRectByCoord = " << nRectByCoord << std::endl;
1317  printRectCoords(userRectCoordVertices, "userRectCoordVertices" , nRectByCoord);
1318  }
1319 
1320  std::cout << "aperture option: " << aperture << std::endl;
1321  if (aperture == 1) {
1322  std::cout << "meanAperture = " << meanAperture << std::endl;
1323  std::cout << "stdAperture = " << stdAperture << std::endl;
1324 
1325  }
1326  else if (aperture == 2) {
1327  printAry(apertureFromTransmissivity, "apertureFromTransmissivity", 2);
1328  }
1329  else if (aperture == 3) {
1330  std::cout << "constantAperture = " << constantAperture << std::endl;
1331  }
1332  else if (aperture == 4) {
1333  printAry(lengthCorrelatedAperture, "lengthCorrelatedAperture", 2);
1334  }
1335 
1336 
1337  if (permOption == 0) {
1338  std::cout << "Permeability: Function of aperture\n";
1339  }
1340  else{
1341  std::cout << "ConstantPermeability = " << constantPermeability << std::endl;
1342  }
1343 }
1344 
1345 
1346 
1347 
1348 
float * rExpMin
Definition: readInput.cpp:201
void getInputAry(std::ifstream &stream, T *var, int nElements)
bool * p32Status
Definition: readInput.cpp:468
void printInputVars()
Definition: readInput.cpp:1245
double theta
Definition: structures.h:439
float expMean
Definition: structures.h:466
void getElements(std::ifstream &stream, T *var, int nElements)
float * ralpha
Definition: readInput.cpp:292
double h
Definition: readInput.cpp:21
float meanAperture
Definition: readInput.cpp:401
bool ueAngleOption
Definition: readInput.cpp:314
float * rphi
Definition: readInput.cpp:269
double * userEllCoordVertices
Definition: readInput.cpp:397
bool insertUserRectanglesFirst
Definition: readInput.cpp:96
unsigned int * uenumPoints
Definition: readInput.cpp:332
float max
Definition: structures.h:502
float * urBeta
Definition: readInput.cpp:371
float * uraspect
Definition: readInput.cpp:374
bool visualizationMode
Definition: readInput.cpp:36
int nUserRect
Definition: readInput.cpp:360
unsigned int * enumPoints
Definition: readInput.cpp:158
float apertureFromTransmissivity[2]
Definition: readInput.cpp:420
float * ueRadii
Definition: readInput.cpp:317
bool keepOnlyLargestCluster
Definition: readInput.cpp:61
float * emin
Definition: readInput.cpp:222
float * esd
Definition: readInput.cpp:189
bool permOption
Definition: readInput.cpp:349
bool ignoreBoundaryFaces
Definition: readInput.cpp:473
double * uetranslation
Definition: readInput.cpp:326
float * rbeta
Definition: readInput.cpp:272
float constRadi
Definition: structures.h:496
unsigned int nEllNodes
Definition: readInput.cpp:389
short stopCondition
Definition: readInput.cpp:12
int nFamRect
Definition: readInput.cpp:116
bool betaDistribution
Definition: structures.h:431
double phi
Definition: structures.h:443
float * thetaList
Definition: structures.h:402
unsigned int nEllByCoord
Definition: readInput.cpp:386
bool userRecByCoord
Definition: readInput.cpp:340
bool outputAcceptedRadiiPerFamily
Definition: readInput.cpp:82
bool userRectanglesOnOff
Definition: readInput.cpp:336
bool printRejectReasons
Definition: readInput.cpp:67
double kappa
Definition: structures.h:448
unsigned int nPoly
Definition: readInput.cpp:15
bool userEllipsesOnOff
Definition: readInput.cpp:306
void getRectCoords(std::ifstream &stream, double *var, int nRectangles)
float * rLogMax
Definition: readInput.cpp:198
float * econst
Definition: readInput.cpp:219
float * ealpha
Definition: readInput.cpp:228
int * rLayer
Definition: readInput.cpp:453
void getInput(char *input, std::vector< Shape > &shapeFamily)
Definition: readInput.cpp:485
short layer
Definition: structures.h:412
float * urRadii
Definition: readInput.cpp:363
float * eLogMax
Definition: readInput.cpp:210
bool * rbetaDistribution
Definition: readInput.cpp:92
float * ekappa
Definition: readInput.cpp:183
float logMin
Definition: structures.h:490
double * userRectCoordVertices
Definition: readInput.cpp:393
float * ueaspect
Definition: readInput.cpp:323
int * eLayer
Definition: readInput.cpp:459
float * ebeta
Definition: readInput.cpp:178
bool angleOption
Definition: structures.h:426
float * layerVol
Definition: readInput.cpp:447
float sd
Definition: structures.h:486
float * rconst
Definition: readInput.cpp:302
float * rExpMax
Definition: readInput.cpp:204
void get2dAry(std::ifstream &stream, T *var, int rowSize)
float * rkappa
Definition: readInput.cpp:277
float * emax
Definition: readInput.cpp:225
double lengthCorrelatedAperture[2]
Definition: readInput.cpp:429
float * rmin
Definition: readInput.cpp:286
float * eLogMean
Definition: readInput.cpp:186
float radiiListIncrease
Definition: readInput.cpp:26
bool disableFram
Definition: readInput.cpp:30
int nFamEll
Definition: readInput.cpp:120
int numOfLayers
Definition: readInput.cpp:476
float * r_p32Targets
Definition: readInput.cpp:296
void searchVar(std::ifstream &stream, std::string search)
void printRectCoords(double *var, std::string varName, int nRectangles)
bool eAngleOption
Definition: readInput.cpp:163
float * rLogMin
Definition: readInput.cpp:195
void print2dAry(T *var, std::string varName, int rowSize)
void printAry(T *var, std::string varName, int nElements)
float expMax
Definition: structures.h:478
float * rLogMean
Definition: readInput.cpp:280
float * layers
Definition: readInput.cpp:443
bool outputFinalRadiiPerFamily
Definition: readInput.cpp:74
bool * ebetaDistribution
Definition: readInput.cpp:87
void getCords(std::ifstream &stream, double *outAry, int nPoly, int nVertices)
int nUserEll
Definition: readInput.cpp:309
unsigned int seed
Definition: readInput.cpp:105
double * urnormal
Definition: readInput.cpp:380
bool boundaryFaces[6]
Definition: readInput.cpp:52
unsigned int nRectByCoord
Definition: readInput.cpp:383
bool rAngleOption
Definition: readInput.cpp:251
float * eExpMean
Definition: readInput.cpp:192
float beta
Definition: structures.h:435
float expMin
Definition: structures.h:474
float expLambda
Definition: structures.h:470
float min
Definition: structures.h:499
float domainSizeIncrease[3]
Definition: readInput.cpp:111
bool tripleIntersections
Definition: readInput.cpp:41
float alpha
Definition: structures.h:505
short numPoints
Definition: structures.h:399
float * famProbOriginal
Definition: readInput.cpp:137
float logMax
Definition: structures.h:493
bool userEllByCoord
Definition: readInput.cpp:344
int aperture
Definition: readInput.cpp:413
short distributionType
Definition: structures.h:396
bool urAngleOption
Definition: readInput.cpp:368
float aspectRatio
Definition: structures.h:415
float mean
Definition: structures.h:482
float * rtheta
Definition: readInput.cpp:264
float * raspect
Definition: readInput.cpp:246
double * uenormal
Definition: readInput.cpp:329
float * rExpMean
Definition: readInput.cpp:299
float * ueBeta
Definition: readInput.cpp:320
bool forceLargeFractures
Definition: readInput.cpp:102
float p32Target
Definition: structures.h:418
double * urtranslation
Definition: readInput.cpp:377
short shapeFamily
Definition: structures.h:393
void generateTheta(float *&thetaArray, float aspectRatio, int nPoints)
float * famProb
Definition: readInput.cpp:133
float * easpect
Definition: readInput.cpp:151
int rejectsPerFracture
Definition: readInput.cpp:439
float * e_p32Targets
Definition: readInput.cpp:232
unsigned int * rdistr
Definition: readInput.cpp:243
double constantAperture
Definition: readInput.cpp:423
int * edistr
Definition: readInput.cpp:148
bool outputAllRadii
Definition: readInput.cpp:357
float * rmax
Definition: readInput.cpp:289
float * eExpMax
Definition: readInput.cpp:216
float * rsd
Definition: readInput.cpp:283
float * eLogMin
Definition: readInput.cpp:207
float removeFracturesLessThan
Definition: readInput.cpp:260
double constantPermeability
Definition: readInput.cpp:432
float * ephi
Definition: readInput.cpp:174
float * etheta
Definition: readInput.cpp:168
double domainSize[3]
Definition: readInput.cpp:18
float stdAperture
Definition: readInput.cpp:405
float * eExpMin
Definition: readInput.cpp:213
void checkIfOpen(std::ifstream &stream, std::string fileName)