-
Notifications
You must be signed in to change notification settings - Fork 36
Nodes shared by wall and inlet/outlet marked as wall only #2
Description
In the current implementation of the script, nodes that belong to both the wall and the inlet/outlet boundaries are being included in multiple files: inlet.dat / outlet.dat and wall.dat.
Including shared nodes in both the inlet/outlet lists and the wall list might cause issues in the downstream solver. For example, in my case this led to errors in an Oasis simulation for a coronary model, since I believe the solver received conflicting boundary condition assignments for the same nodes.
Therefore, I think that nodes that belong to both boundaries should be marked as "wall" only. To address this, I have implemented a new function called "remove_common_nodes" (please see below) which ensures that shared nodes are removed from the inlet/outlet lists before writing the final files.
# Function to remove the common wall points from inlet and outlet
def remove_common_BCnodes(wall_file, input_file, filtered_file):
# 1. read wall IDs into a set (fast look-up, order not needed)
with open(wall_file) as f:
wall_ids = {int(line) for line in f if line.strip()} # ignore blank lines
# 2. read outlet IDs, keep only those not in wall_ids
with open(input_file) as f:
all_ids = [int(line) for line in f if line.strip()]
filtered_ids = [pid for pid in all_ids if pid not in wall_ids]
# 3. write the filtered list (one ID per line, same order as original)
with open(filtered_file, "w") as f:
f.write("\n".join(map(str, filtered_ids)))