Skip to content
Snippets Groups Projects
Commit f30f05cc authored by Julian Heinze's avatar Julian Heinze
Browse files

cleanup if-statements

parent f9c93a6c
No related branches found
No related tags found
No related merge requests found
...@@ -71,73 +71,57 @@ def cli(): ...@@ -71,73 +71,57 @@ def cli():
mesh = get_geo_mesh(doc) mesh = get_geo_mesh(doc)
if args.case == "geometry" or args.case == "geo_surface": if "properties" in args.case:
if args.case == "geo_surface":
# surface
surf = mesh.extract_surface()
pv.save_meshio(args.output, surf, file_format="vtu")
# log feflow version
log.info(
"The surface of the input mesh has been successfully converted."
)
else:
pv.save_meshio(args.output, mesh, file_format="vtu")
log.info(
"The geometry of the input mesh has been successfully converted."
)
elif args.case == "properties" or args.case == "properties_surface":
update_geo_mesh(mesh, doc) update_geo_mesh(mesh, doc)
if args.case == "properties_surface": mesh = mesh.extract_surface() if "surface" in args.case else mesh
surf = mesh.extract_surface() msg = {
pv.save_meshio(args.output, surf, file_format="vtu") "geo_surface": "surface",
log.info( "geometry": "geometry",
"The surface with properties of the input mesh have been successfully converted." "properties_surface": "surface with properties",
) "properties": "",
else: }
pv.save_meshio(args.output, mesh, file_format="vtu") pv.save_meshio(args.output, mesh, file_format="vtu")
log.info("The input mesh has been successfully converted.") log.info(
if args.BC == "BC": "The %s of the input mesh has been successfully converted.",
BC_mesh = mesh.copy() msg[args.case],
for cd in [ )
cell_data if "properties" not in args.case or args.BC != "BC":
for cell_data in BC_mesh.cell_data return
if cell_data not in ["P_SOUF", "P_IOFLOW"] BC_mesh = mesh.copy()
]: for cd in [
BC_mesh.cell_data.remove(cd) cell_data
# Only cell data are needed for cell_data in BC_mesh.cell_data
BC_mesh.point_data.clear() if cell_data not in ["P_SOUF", "P_IOFLOW"]
# get the topsurface since there are the cells of interest ]:
topsurf = get_specific_surface( BC_mesh.cell_data.remove(cd)
BC_mesh.extract_surface(), lambda normals: normals[:, 2] > 0 # Only cell data are needed
) BC_mesh.point_data.clear()
topsurf.save("topsurface_" + args.output) # get the topsurface since there are the cells of interest
# create the xml-file topsurf = get_specific_surface(
write_xml( BC_mesh.extract_surface(), lambda normals: normals[:, 2] > 0
"topsurface_" + args.output, )
"Neumann", topsurf.save("topsurface_" + args.output)
topsurf.cell_data, # create the xml-file
"MeshElement", write_xml(
) "topsurface_" + args.output,
"Neumann",
# remove all the point data that are not of interest topsurf.cell_data,
for point_data in mesh.point_data: "MeshElement",
if not all(["_BC_" in point_data]): )
mesh.point_data.remove(point_data) # remove all the point data that are not of interest
for point_data in mesh.point_data:
# Only selected point data is needed -> clear all cell data if not all(["_BC_" in point_data]):
mesh.cell_data.clear() mesh.point_data.remove(point_data)
# Only selected point data is needed -> clear all cell data
# remove all points with point data that are of "nan"-value mesh.cell_data.clear()
for point_data in mesh.point_data: # remove all points with point data that are of "nan"-value
filtered_points = mesh.extract_points( for point_data in mesh.point_data:
[not np.isnan(x) for x in mesh[point_data]], filtered_points = mesh.extract_points(
include_cells=False, [not np.isnan(x) for x in mesh[point_data]],
) include_cells=False,
# Only "BULK_NODE_ID" can be read by ogs )
filtered_points.rename_array( # Only "BULK_NODE_ID" can be read by ogs
"vtkOriginalPointIds", "BULK_NODE_ID" filtered_points.rename_array("vtkOriginalPointIds", "BULK_NODE_ID")
) filtered_points.save(point_data + ".vtu")
filtered_points.save(point_data + ".vtu") # create the xml-file
write_xml("", "Dirichlet", filtered_points.point_data, "MeshNode")
# create the xml-file
write_xml("", "Dirichlet", filtered_points.point_data, "MeshNode")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment