pydfnWorks
python wrapper for dfnWorks
poisson_class.py
Go to the documentation of this file.
1 # contains global variables
3  def __init__(self, fracture_id, path_to_polygon, path_to_intersections, H, R, A, F,
4  concurrent_samples, occupancy_factor, well_flag):
5  import numpy as np
6  """ Takes in input-parameters and contains all variables derived from
7  those, that are used by multiple functions.
8  Parameters
9  ---------
10  path_to_polygons : string
11  path to the file containing the vertices of the polygon to be sampled
12  path_to_intersections : string
13  path to the intersections-file
14  H : float
15  double the min distance of the system. defined in params.txx
16  R : float
17  Range over which the min-distance between nodes increases (in units of H)
18  named max_dist in mesh_dfn.py
19  A : float
20  slope of min-distance. Named slope in mesh_dfn.py
21  F : float
22  Range of constant min-distance around an intersection (in units of H).
23  Named min_dist in mesh_dfn.py
24  concurrent_samples : int
25  number of new candidates sampled around an accepted node at a time.
26  occupancy_factor : float
27  side length of the occupancy grid is given by H/occupancy_factor
28  named grid_size in mesh_dfn.py
29  Notes
30  -----
31  """
32  # Input parameters
33 
34  self.fracture_idfracture_id = fracture_id
35  self.path_polypath_poly = path_to_polygon
36  self.path_interpath_inter = path_to_intersections
37  self.kk = concurrent_samples
38  self.RR = R
39  self.HH = H
40  self.AA = min(A, .95) # sine of min angle in a triangulation
41  # is bounded by (1-A)/2, require 1-A>eps>0
42  self.FF = F
43  self.occupancy_grid_side_lengthoccupancy_grid_side_length = self.HH / occupancy_factor
44  self.well_flagwell_flag = well_flag
45 
46  # Derived from input
47 
49  self.max_exclusion_radiusmax_exclusion_radius = (self.AA * self.RR + .5) * self.HH
50  self.z_planez_plane = 0.0
51  # z-coordinate of the polygon, only needed for output
52  self.current_nodecurrent_node = 0
53  # number of the next already accepted node to be center of
54  # a sampling. Stored here, so main_sampling can continue,
55  # where it left off, if interrupted.
56  self.no_of_nodesno_of_nodes = 0 # current length of Coordinate-list
57  self.coordinatescoordinates = []
58  # list of coordinates. Every entry is an array with the first
59  # two components being x/y-coordinates and the third entry being
60  # the local exclusion radius of the node.
61 
62  # Geometry of Polygon
63  self.verticesvertices = [] # corner vertices of the polygon,
64  # clockwise order is required!!
65  self.no_of_verticesno_of_vertices = len(self.verticesvertices)
66  self.vertices_xvertices_x = [] # x-coordinates of vertices
67  self.vertices_yvertices_y = []
68  self.x_min, self.x_maxx_max = 0, 0
69  self.y_min, self.y_maxy_max = 0, 0
70  self.first_x_min_indexfirst_x_min_index = 0
71  # vertex-index of the vertex with the smallest y-value of the
72  # vertices with x-value x_min, used to define upper and lower
73  # boundary function. requires convexity of polygon to be well-def
74  self.last_x_min_indexlast_x_min_index = 0
75  # vertex-index of the vertex with the smallest y-value of the
76  # vertices with x-value x_min, used to define upper and lower
77  # boundary function. requires convexity of polygon to be well-def
78  self.slope_lower_boundaryslope_lower_boundary = 0 # boundaries of polygon are piecewise linear
79  self.slope_upper_boundaryslope_upper_boundary = 0
80 
81  # Neighbor-grid variables
82  self.neighbor_cell_sizeneighbor_cell_size = self.HH / 2 / np.sqrt(2)
83  self.neighbor_cell_size_invneighbor_cell_size_inv = 1 / self.neighbor_cell_sizeneighbor_cell_size
84  self.no_of_horizontal_neighbor_cellsno_of_horizontal_neighbor_cells = 1
85  self.no_of_horizontal_neighbor_cellsno_of_horizontal_neighbor_cells = 1
86  self.neighbor_gridneighbor_grid = np.zeros(1)
87 
88  # Intersection-related variables
89  self.intersect_range_sqintersect_range_sq = ((self.RR + self.FF) * self.HH)**2
90  # distance along which an intersection affects the local
91  # exclusion radius (squared)
92  if (self.intersect_range_sqintersect_range_sq) != 0:
93  self.intersect_grid_invintersect_grid_inv = 1 / (self.RR * self.HH + self.FF * self.HH)
94  # inverse cell-size of intersection-grid
95  else:
96  self.intersect_grid_invintersect_grid_inv = 1
97  # inverse cell-size of intersection-grid
98  self.intersect_endptsintersect_endpts = []
99  self.intersect_cellsintersect_cells = {}
100  # key (i,j) contains numbers of intersection within a distance
101  # of intersect-range or less to the intersect-cell (i,j)
102  self.square_nodessquare_nodes = np.array([[1, 0], [1, 1], [0, 1], [0, 0], [1, 0]])
103  # (k-1)-th and k-th row contain nodes of a square bounding the
104  # edge of that square in direction k, where k in [1,2,3,4]
105  # and the numbers corresponding to directions as follows:
106  # 1->right, 3->left, 2->up, 4->down.
107 
108  # Occupancy-grid variables
109  self.occupancy_grid_side_length_invoccupancy_grid_side_length_inv = 1 / self.occupancy_grid_side_lengthoccupancy_grid_side_length
110  self.no_of_horizontal_occupancy_cellsno_of_horizontal_occupancy_cells = 1
111  self.no_of_horizontal_occupancy_cellsno_of_horizontal_occupancy_cells = 1
112  self.occupancy_gridoccupancy_grid = np.zeros(1)
def __init__(self, fracture_id, path_to_polygon, path_to_intersections, H, R, A, F, concurrent_samples, occupancy_factor, well_flag)
Definition: poisson_class.py:4