diff --git a/docs/geos-mesh.rst b/docs/geos-mesh.rst index e13385d..9be1814 100644 --- a/docs/geos-mesh.rst +++ b/docs/geos-mesh.rst @@ -201,6 +201,8 @@ The ``generate_fractures`` module will split the mesh and generate the multi-blo [string]: For ".vtu" output format, the data mode can be binary or ascii. Defaults to binary. --fractures_output_dir FRACTURES_OUTPUT_DIR [string]: The output directory for the fractures meshes that will be generated from the mesh. + --fractures_data_mode FRACTURES_DATA_MODE + [string]: For ".vtu" output format, the data mode can be binary or ascii. Defaults to binary. ``generate_global_ids`` """"""""""""""""""""""" diff --git a/geos-mesh/src/geos/mesh/doctor/checks/generate_fractures.py b/geos-mesh/src/geos/mesh/doctor/checks/generate_fractures.py index 3cb041c..005770d 100644 --- a/geos-mesh/src/geos/mesh/doctor/checks/generate_fractures.py +++ b/geos-mesh/src/geos/mesh/doctor/checks/generate_fractures.py @@ -234,43 +234,6 @@ def __call__( self, index: int ) -> int: return result -def combined_and_fracture_mappings( all_mappings: list[ Mapping[ int, IDMapping ] ] ): - shortened_mappings: list[ Mapping[ int, IDMapping ] ] = all_mappings.copy() - for fracture in shortened_mappings: - toRemoveCellId: list[ int ] = list() - for cell_id, node_conversion in fracture.items(): - toRemoveNode: list[ int ] = list() - for node_init, node_final in node_conversion.items(): - if node_init == node_final: - toRemoveNode.append( node_init ) - for node_value in toRemoveNode: - del node_conversion[ node_value ] - if len( node_conversion ) == 0: - toRemoveCellId.append( cell_id ) - for cell_id_value in toRemoveCellId: - del fracture[ cell_id_value ] - - combined_mapping: Mapping[ int, IDMapping ] = dict() - for fracture in shortened_mappings: - for cell_id, node_conversion in fracture.items(): - if cell_id not in combined_mapping.keys(): - combined_mapping[ cell_id ] = dict() - for node_init, node_final in node_conversion.items(): - if node_init not in combined_mapping[ cell_id ].keys(): - combined_mapping[ cell_id ][ node_init ] = node_final - elif node_final < combined_mapping[ cell_id ][ node_init ]: - combined_mapping[ cell_id ][ node_init ] = node_final - - new_fracture_mappings: list[ Mapping[ int, IDMapping ] ] = list() - for fracture in all_mappings: - fracture_mapping: Mapping[ int, IDMapping ] = dict() - for cell_id in fracture.keys(): - fracture_mapping[ cell_id ] = combined_mapping[ cell_id ] - new_fracture_mappings.append( fracture_mapping ) - - return ( combined_mapping, new_fracture_mappings ) - - def truncated_coordinates_with_id( mesh: vtkUnstructuredGrid, decimals: int = 3 ) -> dict[ Coordinates3D, int ]: """Creates a mapping of truncated points coordinates with the their point id for every point of a mesh. diff --git a/geos-mesh/src/geos/mesh/doctor/parsing/generate_fractures_parsing.py b/geos-mesh/src/geos/mesh/doctor/parsing/generate_fractures_parsing.py index 954a496..9bc19ab 100644 --- a/geos-mesh/src/geos/mesh/doctor/parsing/generate_fractures_parsing.py +++ b/geos-mesh/src/geos/mesh/doctor/parsing/generate_fractures_parsing.py @@ -13,6 +13,7 @@ __FIELD_VALUES = "values" __FRACTURES_OUTPUT_DIR = "fractures_output_dir" +__FRACTURES_DATA_MODE = "fractures_data_mode" def convert_to_fracture_policy( s: str ) -> FracturePolicy: @@ -58,6 +59,10 @@ def fill_subparser( subparsers ) -> None: '--' + __FRACTURES_OUTPUT_DIR, type=str, help=f"[string]: The output directory for the fractures meshes that will be generated from the mesh." ) + p.add_argument( + '--' + __FRACTURES_DATA_MODE, + type=str, + help=f'[string]: For ".vtu" output format, the data mode can be binary or ascii. Defaults to binary.' ) def convert( parsed_options ) -> Options: @@ -71,21 +76,22 @@ def convert( parsed_options ) -> Options: ) all_values_no_separator: str = all_values.replace( ":", "," ) field_values_combined: frozenset[ int ] = frozenset( map( int, all_values_no_separator.split( "," ) ) ) - vtk_output = vtk_output_parsing.convert( parsed_options ) + mesh_vtk_output = vtk_output_parsing.convert( parsed_options ) # create the different fractures per_fracture: list[ str ] = all_values.split( ":" ) field_values_per_fracture: list[ frozenset[ int ] ] = [ frozenset( map( int, fracture.split( "," ) ) ) for fracture in per_fracture ] fracture_names: list[ str ] = [ "fracture_" + frac.replace( ",", "_" ) + ".vtu" for frac in per_fracture ] - fracture_output_dir: str = parsed_options[ __FRACTURES_OUTPUT_DIR ] - all_fractures_VtkOutput: list[ VtkOutput ] = build_all_fractures_VtkOutput( fracture_output_dir, vtk_output, - fracture_names ) + fractures_output_dir: str = parsed_options[ __FRACTURES_OUTPUT_DIR ] + fractures_data_mode: str = parsed_options[ __FRACTURES_DATA_MODE ] + all_fractures_VtkOutput: list[ VtkOutput ] = build_all_fractures_VtkOutput( fractures_output_dir, fractures_data_mode, + mesh_vtk_output, fracture_names ) return Options( policy=policy, field=field, field_values_combined=field_values_combined, field_values_per_fracture=field_values_per_fracture, - mesh_VtkOutput=vtk_output, + mesh_VtkOutput=mesh_vtk_output, all_fractures_VtkOutput=all_fractures_VtkOutput ) @@ -103,7 +109,9 @@ def are_values_parsable( values: str ) -> bool: return True -def build_all_fractures_VtkOutput( fracture_output_dir: str, vtk_output: VtkOutput, +def build_all_fractures_VtkOutput( fracture_output_dir: str, + fractures_data_mode: str, + mesh_vtk_output: VtkOutput, fracture_names: list[ str ] ) -> list[ VtkOutput ]: if not os.path.exists( fracture_output_dir ): raise ValueError( f"The --{__FRACTURES_OUTPUT_DIR} given directory does not exist." ) @@ -111,11 +119,11 @@ def build_all_fractures_VtkOutput( fracture_output_dir: str, vtk_output: VtkOutp if not os.access( fracture_output_dir, os.W_OK ): raise ValueError( f"The --{__FRACTURES_OUTPUT_DIR} given directory is not writable." ) - output_name = os.path.basename( vtk_output.output ) + output_name = os.path.basename( mesh_vtk_output.output ) splitted_name_without_expension: list[ str ] = output_name.split( "." )[ :-1 ] name_without_extension: str = '_'.join( splitted_name_without_expension ) + "_" all_fractures_VtkOuput: list[ VtkOutput ] = list() for fracture_name in fracture_names: fracture_path = os.path.join( fracture_output_dir, name_without_extension + fracture_name ) - all_fractures_VtkOuput.append( VtkOutput( fracture_path, vtk_output.is_data_mode_binary ) ) + all_fractures_VtkOuput.append( VtkOutput( fracture_path, fractures_data_mode ) ) return all_fractures_VtkOuput