pydfnWorks
python wrapper for dfnWorks
false_connections.py
Go to the documentation of this file.
1 """
2 .. module:: false_connections.py
3  :synopsis: Checks for false connections between fractures in upscaled mesh
4 .. moduleauthor:: Jeffrey Hyman <jhyman@lanl.gov>
5 
6 """
7 
8 import pickle
9 import os
10 
11 
12 def check_false_connections(self, path="../"):
13  """
14 
15  Parameters
16  ----------
17  self : object
18  DFN Class
19  fmc_filname : string
20  name of the pickled dictionary of mesh and fracture intersections
21 
22  Returns
23  -------
24  num_false_connections : int
25  number of false connections
26  num_cell_false : int
27  number of Voronoi cells with false connections
28  false_connections : list
29  list of tuples of false connections created by upscaling
30 
31  Notes
32  -----
33  map2continuum and upscale must be run first to create the fracture/mesh intersection
34  dictionary. Thus must be run in the main job directory which contains connectivity.dat
35 
36 
37  """
38  print("--> Checking for false connections in the upscaled mesh.")
39  # Create symbolic links to create fracture graph
40  files = ["connectivity.dat", "left.dat", "right.dat", "fracture_info.dat"]
41  for f in files:
42  try:
43  os.symlink(path + f, f)
44  except:
45  print(f"--> Warning!!! Unable to make symbolic link to {path+f}")
46  pass
47 
48  # create fracture graph, with arbitrary source/target
49  G = self.create_graph("fracture", "left", "right")
50  # remove source and target
51  G.remove_node("s")
52  G.remove_node("t")
53 
54  # Make a copy of G and remove all edges
55  H = G.copy()
56  for u, v in H.edges():
57  H.remove_edge(u, v)
58 
59  # load the fracture_mesh_connection dictionary
60  print("--> Loading mesh intersection information")
61  fmc = pickle.load(open("connections.p", "rb"))
62  print("--> Complete")
63  # Get cell ids for the cells that fractures intersect
64  cells = [key for key in fmc.keys()]
65 
66  # walk through the cells and add edges to graph H
67  # if two fractures are in the same cell
68  cell_false = [False] * len(cells)
69  for i, cell in enumerate(cells):
70  num_conn = len(fmc[cell])
71  # If more than one fracture intersects the mesh cell
72  # add edges
73  if num_conn > 1:
74  # add edges between all fractures in a cell
75  for j in range(num_conn):
76  id1 = fmc[cell][j][0]
77  for k in range(j + 1, num_conn):
78  id2 = fmc[cell][k][0]
79  H.add_edge(id1, id2)
80  cell_false[i] = True
81 
82 
83  print("--> Checking for false connections")
84  false_connections = []
85  for u, v, in H.edges():
86  if not G.has_edge(u, v):
87  print(f"--> False connection between fractures {u} and {v}")
88  false_connections.append((u, v))
89 
90  if len(false_connections) > 0:
91  num_false_connections = len(false_connections)
92  print(
93  f"--> There are {num_false_connections} false connections between fractures"
94  )
95  num_false_cells = sum(cell_false)
96  print(f"--> These occur in {num_false_cells} Voronoi cells")
97  else:
98  print(f"--> No false connections found")
99  num_false_cells = 0
100  num_false_connections = 0
101 
102  return (num_false_connections, num_false_cells, false_connections)