DFNgen  2.0
DFN Model Generator
removeFractures.cpp
Go to the documentation of this file.
1 #include "removeFractures.h"
3 #include "structures.h"
4 #include "input.h"
5 #include <vector>
6 #include <algorithm>
7 #include <iostream>
8 
9 /***********************************************************************/
10 /*********** Remove Fractures Smaller Than Minimum Size **************/
11 // Function is designed to be used AFTER DFN generation
12 // Originally created to compare the difference in distributions
13 // if small fractures were removed after a DFN was generated
14 // as opposed limiting their insertion during DFN generation.
15 //
16 // The minimum size options in the input files will still be used.
17 // If the user wishes to also removeFractures after DFN generation,
18 // 'minSize' here must be larger than the minimum size fractures in the
19 // input file. Fratrues with radii less than 'minSize' will be removed
20 // after DFN has been created.
21 // Arg 1: Minimum size. All fractures smaller than 'minSize' will be
22 // removed.
23 // Arg 2: Array of accepted polygons
24 // Arg 3: Array of accepted intersections
25 // Arg 4: Array of all triple intersection points
26 // Arg 5: Stats structure (DFN Statisctics)
27 //
28 // NOTE: Must be executed before getCluster()
29 // This funciton rebuilds the DFN. Using getCluster() before this
30 // funciton executes causes undefined behavior.
31 void removeFractures(double minSize, std::vector<Poly> &acceptedPolys, std::vector<IntPoints> &intPts, std::vector<Point> triplePoints, Stats &pstats) {
32 
33  std::vector<Poly> finalPolyList;
34 
35  // Clear GroupData
36  pstats.groupData.clear();
37  // Clear FractGroup
38  pstats.fractGroup.clear();
39  // Clear Triple Points
40  triplePoints.clear();
41  // Clear IntPoints
42  intPts.clear();
43 
44  // Re-init nextGroupNum
45  pstats.nextGroupNum = 1;
46 
47  for (unsigned int i = 0; i < acceptedPolys.size(); i++) {
48 
49  if (acceptedPolys[i].xradius < minSize) {
50  delete[] acceptedPolys[i].vertices;
51  continue;
52  }
53 
54  Poly newPoly = acceptedPolys[i];
55 
56  newPoly.groupNum = 0; // Reset cluster group number
57 
58  newPoly.intersectionIndex.clear(); // Remove ref to old intersections
59 
60  // Find line of intersection and FRAM check
61  int rejectCode = intersectionChecking(newPoly, finalPolyList, intPts, pstats, triplePoints);
62 
63  // IF POLY ACCEPTED:
64  if (rejectCode == 0) { // Intersections are ok
65 
66  // SAVING POLYGON (intersection and triple points saved witchin intersectionChecking())
67  finalPolyList.push_back(newPoly); // SAVE newPoly to accepted polys list
68  }
69 
70  else { // Poly rejected
71 
72  std::cout << "\nError rebuilding dfn, previously accepted fracture was rejected during DFN rebuild.\n";
73  }
74  }
75 
76  std::cout << "Rebuilding DFN complete.\n";
77 
78  acceptedPolys.clear();
79  acceptedPolys = finalPolyList;
80 }
81 
82 
unsigned int groupNum
Definition: structures.h:30
std::vector< struct FractureGroups > fractGroup
Definition: structures.h:374
std::vector< struct GroupData > groupData
Definition: structures.h:376
unsigned long long int nextGroupNum
Definition: structures.h:336
std::vector< unsigned int > intersectionIndex
Definition: structures.h:98
void removeFractures(double minSize, std::vector< Poly > &acceptedPolys, std::vector< IntPoints > &intPts, std::vector< Point > triplePoints, Stats &pstats)
int intersectionChecking(struct Poly &newPoly, std::vector< Poly > &acceptedPoly, std::vector< IntPoints > &intPtsList, struct Stats &pstats, std::vector< Point > &triplePoints)