diff --git a/ogstools/feflowlib/_cli.py b/ogstools/feflowlib/_cli.py index 196bd09e7225d190620c1695d9b06dbff4084945..333da14b13b966b150f3ec2870ba4992d1f345da 100644 --- a/ogstools/feflowlib/_cli.py +++ b/ogstools/feflowlib/_cli.py @@ -123,10 +123,11 @@ def feflow_converter(input: str, output: str, case: str, BC: str): return 0 # create separate meshes for the boundary condition write_point_boundary_conditions(Path(output).parent, mesh) - path_topsurface, topsurface = extract_cell_boundary_conditions( - Path(output), mesh - ) - topsurface.save(path_topsurface) + if doc.getNumberOfDimensions == 3: + path_topsurface, topsurface = extract_cell_boundary_conditions( + Path(output), mesh + ) + topsurface.save(path_topsurface) log.info( "Boundary conditions have been written to separate mesh vtu-files." @@ -139,7 +140,7 @@ def feflow_converter(input: str, output: str, case: str, BC: str): "There are inactive cells in FEFLOW, which are assigned to a MaterialID multiplied by -1 in the converted bulk mesh." ) # create a prj-file, which is not complete. Manual extensions are needed. - property_list = ["P_CONDX", "P_CONDY", "P_CONDZ"] + property_list = ["P_COND"] material_properties = combine_material_properties(mesh, property_list) for material_id, property_value in material_properties.items(): if any(prop == "inhomogeneous" for prop in property_value): diff --git a/ogstools/feflowlib/_feflowlib.py b/ogstools/feflowlib/_feflowlib.py index 41ba8414d5267046f65ceedd1dddddd8ae3df97a..b0334d8af073dd76aece14ac93d8e70e4b41fccb 100644 --- a/ogstools/feflowlib/_feflowlib.py +++ b/ogstools/feflowlib/_feflowlib.py @@ -192,11 +192,20 @@ def _point_and_cell_data(MaterialIDs: dict, doc: ifm.FeflowDoc): # 5. change format of cell data to a dictionary of lists cell_data = {key: [cell_data[key]] for key in cell_data} - # 6. add materialIDs to cell data + # 6. add MaterialIDs to cell data cell_data[str(list(MaterialIDs.keys())[0])] = [ list(MaterialIDs.values())[0] ] + # if MaterialIDs are not saved in selections but in P_LOOKUP_REGION + # then take them from P_LOOK_UP: + if "P_LOOKUP_REGION" in cell_data and len( + np.unique(MaterialIDs.values()) + ) < len(np.unique(cell_data["P_LOOKUP_REGION"])): + cell_data["MaterialIDs"] = np.array( + cell_data.pop("P_LOOKUP_REGION") + ).astype(np.int32) + # 7. write a list of all properties that have been dropped due to nans nan_arrays = [ x