2 .. module:: mesh_dfn.py
3 :synopsis: meshing driver for DFN
4 .. moduleauthor:: Jeffrey Hyman <jhyman@lanl.gov>
10 from numpy
import genfromtxt, sort
26 concurrent_samples=10,
30 ''' Mesh fracture network using LaGriT
37 If prune is False, mesh entire network. If prune is True, mesh only fractures in self.prune_file
39 If true, mesh is uniform resolution. If False, mesh is spatially variable
40 production_mode : bool
41 If True, all working files while meshing are cleaned up. If False, then working files will not be deleted
43 If the user wants to run in a different meshing mode from what is in params.txt,
44 set visual_mode = True/False on command line to override meshing mode
46 Maximum resolution of the mesh. Given as a factor of h
48 slope of variable coarsening resolution.
50 Range of constant min-distance around an intersection (in units of h).
52 Range over which the min-distance between nodes increases (in units of h)
53 concurrent_samples : int
54 number of new candidates sampled around an accepted node at a time.
56 side length of the occupancy grid is given by H/occupancy_factor
58 If well flag is true, higher resolution around the points in
66 1. For uniform resolution mesh, set slope = 0
67 2. All fractures in self.prune_file must intersect at least 1 other fracture
72 print(
"Meshing DFN using LaGriT : Starting")
79 if self.prune_file ==
"":
80 error =
"ERROR!! User requested pruning in meshing but \
81 did not provide file of fractures to keep.\nExiting program.\n"
83 sys.stderr.write(error)
86 mh.create_mesh_links(self.path)
87 num_poly, h, params_visual_mode, dudded_points, domain = mh.parse_params_file(
89 if visual_mode ==
None:
90 visual_mode = params_visual_mode
93 print(
"\n--> Running in Visual Mode\n")
95 f
"Loading list of fractures to remain in network from {self.prune_file}"
97 fracture_list = sort(genfromtxt(self.prune_file).astype(int))
100 lagrit.edit_intersection_files(num_poly, fracture_list, self.path)
101 num_poly = len(fracture_list)
104 num_poly, h, params_visual_mode, dudded_points, domain = mh.parse_params_file(
106 if visual_mode ==
None:
107 visual_mode = params_visual_mode
109 fracture_list = range(1, num_poly + 1)
114 ncpu = min(self.ncpu, num_poly)
118 print(
"\n--> Running in Visual Mode\n")
120 print(
"\n--> Running in Full Meshing Mode\n")
123 lagrit.create_parameter_mlgi_file(fracture_list, h, slope=slope)
125 lagrit.create_lagrit_scripts_reduced_mesh(fracture_list)
130 if not os.path.isfile(
"well_points.dat"):
131 error =
"ERROR!!! Well flag is set to True in DFN.mesh_network(), but file 'well_points.dat' cannot be found.\nPlease run DFN.find_well_intersection_points() for each well prior to meshing\nOr set well_flag = False\nExiting Program\n"
132 sys.stderr.write(error)
135 dump_poisson_params(h, coarse_factor, slope, min_dist, max_dist,
136 concurrent_samples, grid_size, well_flag)
138 lagrit.create_lagrit_scripts_poisson(fracture_list)
146 failure = run_mesh.mesh_fractures_header(fracture_list, ncpu, visual_mode,
150 error =
"One or more fractures failed to mesh properly.\nExiting Program\n"
151 sys.stderr.write(error)
154 n_jobs = lagrit.create_merge_poly_files(ncpu, num_poly, fracture_list, h,
158 run_mesh.merge_the_meshes(num_poly, ncpu, n_jobs, visual_mode)
160 if (
not visual_mode
and not prune):
161 if not mh.check_dudded_points(dudded_points):
163 error =
"ERROR!!! Incorrect Number of dudded points.\nExiting Program\n"
164 sys.stderr.write(error)
171 lagrit.define_zones()
174 mh.clean_up_files_after_prune(self)
176 mh.output_meshing_report(self.local_jobname, visual_mode)
178 print(
"Meshing DFN using LaGriT : Complete")
def mesh_network(self, prune=False, uniform_mesh=False, production_mode=True, coarse_factor=8, slope=0.1, min_dist=1, max_dist=40, concurrent_samples=10, grid_size=10, visual_mode=None, well_flag=False)