Skip to content

Commit 1e91901

Browse files
committed
Fix to allow specification of the data mode of the fracture meshes
1 parent 4f70b93 commit 1e91901

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

geos-mesh/src/geos/mesh/doctor/parsing/generate_fractures_parsing.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
__FRACTURES_OUTPUT_DIR = "fractures_output_dir"
1616
__FRACTURES_DATA_MODE = "fractures_data_mode"
17+
__FRACTURES_DATA_MODE_VALUES = "binary", "ascii"
18+
__FRACTURES_DATA_MODE_DEFAULT = __FRACTURES_DATA_MODE_VALUES[ 0 ]
1719

1820

1921
def convert_to_fracture_policy( s: str ) -> FracturePolicy:
@@ -62,6 +64,8 @@ def fill_subparser( subparsers ) -> None:
6264
p.add_argument(
6365
'--' + __FRACTURES_DATA_MODE,
6466
type=str,
67+
metavar=", ".join( __FRACTURES_DATA_MODE_VALUES ),
68+
default=__FRACTURES_DATA_MODE_DEFAULT,
6569
help=f'[string]: For ".vtu" output format, the data mode can be binary or ascii. Defaults to binary.' )
6670

6771

@@ -84,7 +88,7 @@ def convert( parsed_options ) -> Options:
8488
]
8589
fracture_names: list[ str ] = [ "fracture_" + frac.replace( ",", "_" ) + ".vtu" for frac in per_fracture ]
8690
fractures_output_dir: str = parsed_options[ __FRACTURES_OUTPUT_DIR ]
87-
fractures_data_mode: str = parsed_options[ __FRACTURES_DATA_MODE ]
91+
fractures_data_mode: str = parsed_options[ __FRACTURES_DATA_MODE ] == __FRACTURES_DATA_MODE_DEFAULT
8892
all_fractures_VtkOutput: list[ VtkOutput ] = build_all_fractures_VtkOutput( fractures_output_dir,
8993
fractures_data_mode, mesh_vtk_output,
9094
fracture_names )
@@ -110,13 +114,13 @@ def are_values_parsable( values: str ) -> bool:
110114
return True
111115

112116

113-
def build_all_fractures_VtkOutput( fracture_output_dir: str, fractures_data_mode: str, mesh_vtk_output: VtkOutput,
117+
def build_all_fractures_VtkOutput( fracture_output_dir: str, fractures_data_mode: bool, mesh_vtk_output: VtkOutput,
114118
fracture_names: list[ str ] ) -> list[ VtkOutput ]:
115119
if not os.path.exists( fracture_output_dir ):
116-
raise ValueError( f"The --{__FRACTURES_OUTPUT_DIR} given directory does not exist." )
120+
raise ValueError( f"The --{__FRACTURES_OUTPUT_DIR} given directory '{fracture_output_dir}' does not exist." )
117121

118122
if not os.access( fracture_output_dir, os.W_OK ):
119-
raise ValueError( f"The --{__FRACTURES_OUTPUT_DIR} given directory is not writable." )
123+
raise ValueError( f"The --{__FRACTURES_OUTPUT_DIR} given directory '{fracture_output_dir}' is not writable." )
120124

121125
output_name = os.path.basename( mesh_vtk_output.output )
122126
splitted_name_without_expension: list[ str ] = output_name.split( "." )[ :-1 ]

0 commit comments

Comments
 (0)