9 def dfn_gen(self, output=True, visual_mode=None):
10 ''' Wrapper script the runs the dfnGen workflow:
11 1) make_working_directory: Create a directory with name of job
12 2) check_input: Check input parameters and create a clean version of the input file
13 3) create_network: Create network. DFNGEN v2.0 is called and creates the network
14 4) output_report: Generate a PDF summary of the DFN generation
15 5) mesh_network: calls module dfnGen_meshing and runs LaGriT to mesh the DFN
22 If True, output pdf will be created. If False, no pdf is made
24 If the user wants to run in a different meshing mode from what is in params.txt, set visual_mode = True/False on command line to override meshing mode
32 Details of each portion of the routine are in those sections
38 self.make_working_directory()
39 self.dump_time(
'Function: make_working_directory', time() - tic)
44 self.dump_time(
'Function: check_input', time() - tic)
49 self.dump_time(
'Function: create_network', time() - tic)
54 self.dump_time(
'output_report', time() - tic)
58 self.mesh_network(visual_mode=visual_mode)
59 self.dump_time(
'Function: mesh_network', time() - tic)
61 print(
'dfnGen Complete')
63 self.dump_time(
'Process: dfnGen', time() - tic_gen)
67 ''' Make working directory for dfnWorks Simulation
80 If directory already exists, user is prompted if they want to overwrite and proceed. If not, program exits.
85 os.mkdir(self.jobname)
87 if os.path.isdir(self.jobname):
88 print(
'\nFolder ', self.jobname,
' exists')
89 keep = input(
'Do you want to delete it? [yes/no] \n')
90 if keep ==
'yes' or keep ==
'y':
91 print(
'Deleting', self.jobname)
92 shutil.rmtree(self.jobname)
93 print(
'Creating', self.jobname)
94 os.mkdir(self.jobname)
95 elif keep ==
'no' or 'n':
96 error =
"Not deleting folder. Exiting Program\n"
97 sys.stderr.write(error)
100 error =
"Unknown Response. Exiting Program\n"
101 sys.stderr.write(error)
104 error = f
"Unable to create working directory {self.jobname}\n. Please check the provided path.\nExiting\n"
105 sys.stderr.write(error)
108 shutil.rmtree(self.jobname)
109 print(
'Creating ', self.jobname)
110 os.mkdir(self.jobname)
112 os.mkdir(self.jobname +
'/radii')
113 os.mkdir(self.jobname +
'/intersections')
114 os.mkdir(self.jobname +
'/polys')
115 os.chdir(self.jobname)
117 print(
"Current directory is now: %s\n" % os.getcwd())
118 print(
"Jobname is %s" % self.jobname)
135 After generation is complete, this script checks whether the generation of the fracture network failed or succeeded based on the existence of the file params.txt.
137 print(
'--> Running DFNGEN')
140 'DFNGEN_EXE'] +
' ' + self.local_dfnGen_file[:
141 -4] +
'_clean.dat' +
' ' + self.jobname
143 print(
"Running %s" % cmd)
144 subprocess.call(cmd, shell=
True)
146 if os.path.isfile(
"params.txt")
is False:
147 error =
"ERROR! Generation Failed\nExiting Program.\n"
148 sys.stderr.write(error)
151 num_poly, h, _, _, _ = parse_params_file(quiet=
True)
152 self.num_frac = num_poly
155 print(
"Generation Succeeded")
def dfn_gen(self, output=True, visual_mode=None)
def make_working_directory(self, delete=False)